IdentityMat( n )
IdentityMat( n, F )
IdentityMat
returns the identity matrix with n rows and n columns
over the field F. If no field is given, IdentityMat
returns the
identity matrix over the field of rationals. Each call to IdentityMat
returns a new matrix, so it is safe to modify the result.
gap> IdentityMat( 3 ); [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ] gap> PrintArray( last ); [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ] gap> PrintArray( IdentityMat( 3, GF(2) ) ); [ [ Z(2)^0, 0*Z(2), 0*Z(2) ], [ 0*Z(2), Z(2)^0, 0*Z(2) ], [ 0*Z(2), 0*Z(2), Z(2)^0 ] ]
GAP 3.4.4