24.4 Matrix Constructions

  • IdentityMat( m[, F] ) F

    returns a (mutable) m ×m identity matrix over the field given by F (i.e. the smallest field containing the element F or F itself if it is a field).

  • NullMat( m, n[, F] ) F

    returns a (mutable) m ×n null matrix over the field given by F.

    gap> IdentityMat(3,1);
    [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]
    gap> NullMat(3,2,Z(3));
    [ [ 0*Z(3), 0*Z(3) ], [ 0*Z(3), 0*Z(3) ], [ 0*Z(3), 0*Z(3) ] ]
    
  • EmptyMatrix( char ) F

    is an empty (ordinary) matrix in characteristic char that can be added to or multiplied with empty lists (representing zero-dimensional row vectors). It also acts (via ^) on empty lists.

    gap> EmptyMatrix(5);
    EmptyMatrix( 5 )
    gap> AsList(last);
    [  ]
    

  • DiagonalMat( vector ) F

    returns a diagonal matrix mat with the diagonal entries given by vector.

    gap> DiagonalMat([1,2,3]); 
    [ [ 1, 0, 0 ], [ 0, 2, 0 ], [ 0, 0, 3 ] ]
    
  • PermutationMat( perm, dim[, F] ) F

    returns a matrix in dimension dim over the field given by F (i.e. the smallest field containing the element F or F itself if it is a field) that represents the permutation perm acting by permuting the basis vectors as it permutes points.

    gap> PermutationMat((1,2,3),4,1);
    [ [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 1, 0, 0, 0 ], [ 0, 0, 0, 1 ] ]
    

  • TransposedMat( mat ) A

    TransposedMat returns the transposed of the matrix mat, i.e., a new matrix trans such that trans[i][k] = mat[k][i]. As it is an attribute it returns an immutable matrix.

  • MutableTransposedMat( mat ) F

    MutableTransposedMat returns the transposed of the matrix mat as a mutable matrix, i.e., a new matrix trans such that trans[i][k] = mat[k][i].

  • TransposedMatDestructive( mat ) A

    If mat is a mutable matrix, then the transposed is computed by swapping the entries in mat. In this way mat gets changed. In all other cases the transposed is computed by TransposedMat.

    gap> TransposedMat([[1,2,3],[4,5,6],[7,8,9]]);
    [ [ 1, 4, 7 ], [ 2, 5, 8 ], [ 3, 6, 9 ] ]
    gap> mm:= [[1,2,3],[4,5,6],[7,8,9]];;
    gap> TransposedMatDestructive( mm );
    [ [ 1, 4, 7 ], [ 2, 5, 8 ], [ 3, 6, 9 ] ]
    gap> mm;
    [ [ 1, 4, 7 ], [ 2, 5, 8 ], [ 3, 6, 9 ] ]
    

  • KroneckerProduct( mat1, mat2 ) O

    The Kronecker product of two matrices is the matrix obtained when replacing each entry a of mat1 by the product a*mat2 in one matrix.

    gap> KroneckerProduct([[1,2]],[[5,7],[9,2]]);
    [ [ 5, 7, 10, 14 ], [ 9, 2, 18, 4 ] ]
    

  • ReflectionMat( coeffs ) F
  • ReflectionMat( coeffs, root ) F
  • ReflectionMat( coeffs, conj ) F
  • ReflectionMat( coeffs, conj, root ) F

    Let coeffs be a row vector. ReflectionMat returns the matrix of the reflection in this vector.

    More precisely, if coeffs is the coefficients of a vector v w.r.t. a basis B (see nowhere), say, then the returned matrix describes the reflection in v w.r.t. B as a map on a row space, with action from the right.

    The optional argument root is a root of unity that determines the order of the reflection. The default is a reflection of order 2. For triflections one should choose a third root of unity etc. (see nowhere).

    conj is a function of one argument that conjugates a ring element. The default is ComplexConjugate.

    The matrix of the reflection in v is defined as

    M = In +
    vtr
     
    ·w-1
    v
    vtr
     
    ·v
    where w = root, n is the length of the coefficient list, and [`] denotes the conjugation.

  • PrintArray( array ) F

    pretty-prints the array array.

  • MutableIdentityMat( m[, F] ) F

    returns a (mutable) m ×m identity matrix over the field given by F. This is identical to IdentityMat and is present in GAP 4.1 only for the sake of compatibility with beta-releases. It should not be used in new code.

  • MutableNullMat( m, n[, F] ) F

    returns a (mutable) m ×n null matrix over the field given by F. This is identical to NullMat and is present in GAP 4.1 only for the sake of compatibility with beta-releases. It should not be used in new code.

    [Top] [Previous] [Up] [Next] [Index]

    GAP 4 manual
    February 2000