up previous next
matrix

convert a list into a matrix

Syntax
matrix(L: LIST): MAT
matrix(R: RING, L: LIST): MAT
matrix(R: RING, M: MAT): MAT

Description
This function returns a matrix in the ring R .

When the input is L , a rectangular LIST of LIST of RINGELEM all in R (or INT, or RAT). When the ring is not specified it "guesses" the right ring; if all elements are INT or RAT the resulting matrix is in QQ.

The third form is equivalent to apply(CanonicalHom(RingOf(M),R), M) (See apply , CanonicalHom ).

Example
/**/  L := [[1,2],[3,4]];
/**/  mat(L);
matrix(QQ,
 [[1, 2],
  [3, 4]])
/**/  mat(ZZ,L);
matrix(ZZ,
 [[1, 2],
  [3, 4]])

/**/  P ::= QQ[x,y];
/**/  M := mat(P,L); print M;
matrix( /*RingWithID(3, "QQ[x,y]")*/
 [[1, 2],
  [3, 4]])
/**/  RingOf(M);
RingWithID(3, "QQ[x,y]")

/**/ M := IdentityMat(ZZ,2);
/**/ matrix(QQ, M);
matrix(QQ,
 [[1, 0],
  [0, 1]])

See Also