Exemplo n.º 1
0
 def __init__(self, parent, A):
     """
     INPUT:
     
     
     -  ``parent`` - a homspace
     
     -  ``A`` - matrix
     
     
     EXAMPLES::
     
         sage: from sage.modules.matrix_morphism import MatrixMorphism
         sage: T = End(ZZ^3)
         sage: M = MatrixSpace(ZZ,3)
         sage: I = M.identity_matrix()
         sage: A = MatrixMorphism(T, I)
         sage: loads(A.dumps()) == A
         True
     """
     if not matrix.is_Matrix(A):
         A = matrix.MatrixSpace(parent.category().base_ring(),
                                parent.domain().rank(),
                                parent.codomain().rank())(A)
     R = A.base_ring()
     if A.nrows() != parent.domain().rank():
         raise ArithmeticError, "number of rows of matrix (=%s) must equal rank of domain (=%s)" % (
             A.nrows(), parent.domain().rank())
     if A.ncols() != parent.codomain().rank():
         raise ArithmeticError, "number of columns of matrix (=%s) must equal rank of codomain (=%s)" % (
             A.ncols(), parent.codomain().rank())
     self._matrix = A
     MatrixMorphism_abstract.__init__(self, parent)
Exemplo n.º 2
0
    def _matrix_space(self):
        """
        Return underlying matrix space that contains the matrices that define
        the homomorphisms in this free module homspace.

        OUTPUT:

        - matrix space

        EXAMPLES::

            sage: H = Hom(QQ^3, QQ^2)
            sage: H._matrix_space()
            Full MatrixSpace of 3 by 2 dense matrices over Rational Field
        """
        try:
            return self.__matrix_space
        except AttributeError:
            R = self.domain().base_ring()
            M = matrix.MatrixSpace(R, self.domain().rank(), self.codomain().rank())
            self.__matrix_space = M
            return M
Exemplo n.º 3
0
#  Distributed under the terms of the GNU General Public License (GPL)
#
#  The full text of the GPL is available at:
#
#                  http://www.gnu.org/licenses/
#
################################################################################

from sage.structure.element import MultiplicativeGroupElement
from sage.rings.all import ZZ
import sage.matrix.all as matrix
from sage.matrix.matrix_integer_2x2 import Matrix_integer_2x2 as mi2x2

from all import is_ArithmeticSubgroup

M2Z = matrix.MatrixSpace(ZZ, 2)


class ArithmeticSubgroupElement(MultiplicativeGroupElement):
    r"""
    An element of the group `{\rm SL}_2(\ZZ)`, i.e. a 2x2 integer matrix of
    determinant 1.
    """
    def __init__(self, parent, x, check=True):
        """
        Create an element of an arithmetic subgroup.

        INPUT:

        - parent - an arithmetic subgroup