The simplest way to make a matrix is to give a doubly nested list of ring elements to the matrix command.
i1 : R = ZZ/101[x,y,z]; |
i2 : f = matrix {{x,0,y*z},{0,y^2,x^2}} |
One way to construct a doubly nested list of ring elements is with the table command.
i3 : table(3,3,(i,j) -> R_i^j) |
i4 : p = matrix oo |
i5 : q = matrix table(3,3,(i,j) -> R_j^i) |
The usual arithmetic operations among matrices are available, including direct sum (++) and tensor product (**). Scalars are converted to scalar matrices when necessary.
i6 : x*p |
i7 : 11-p |
i8 : p*q |
i9 : p++q |
i10 : r = p++x |
i11 : x ++ y ++ z ++ x*y*z |
i12 : p**p |
The components of a direct sum can be recovered later.
i13 : components r |
There are commands for horizontal and vertical concatenation of matrices, and again, scalars are converted to scalar matrices when necessary.
i14 : p|q |
i15 : p||q |
i16 : p|1 |
i17 : x^3||p |
An identity matrix can be obtained with id as the identity map on a free module.
i18 : id_(R^3) |
A matrix is regarded as a homomorphism between two free modules, its source and target.
i19 : M = target f |
i20 : N = source f |
Free modules are actually graded free modules, with the same sort of grading that the ring comes with. The degrees of the basis vectors of the target are always zero.
i21 : degree M_0 |
i22 : degree M_1 |
If possible, the degrees of the basis vectors of the source are set so that the map f turns out to a homogeneous map of degree zero. This opportunism is important because certain algorithms will run faster on homogeneous maps.
i23 : degree N_0 |
i24 : degree N_1 |
i25 : degree N_2 |
i26 : isHomogeneous f |
A list of the degrees of all the basis vectors can be obtained with degrees.
i27 : degrees N |
It may happen that the matrix can not be made homogeneous. In that case, the degree of a basis vector is currently set to the degree of the largest monomial occurring in the corresponding column of the matrix. In a future version of the program it might be more sensible to set the degrees of the basis vectors all to zero.
i28 : g = matrix {{x,0,y*z},{y^2,x^2,0}} |
i29 : isHomogeneous g |
i30 : degrees source g |
Suppose we multiply a homogeneous polynomial by a homogeneous matrix. The result ought to be homogeneous, but how can we arrange that? Scalar multiplication should not change the source or target of a map! Instead, we introduce one final complication: each matrix records a degree of its own, which is normally zero, and is used when deciding whether the matrix is homogeneous.
i31 : degree matrix {{x^10}} |
i32 : degree f |
Multiplying a matrix by a homogeneous polynomial adds the degree of the polynomial to the degree of the map.
i33 : h = x^10 * f |
i34 : degree h |
i35 : degrees source h |
i36 : isHomogeneous h |
If you don't like this, you have an alternative. The degree of a tensor product of two matrices is the sum of the degrees, and its source module is the tensor product of the source modules.
i37 : h = x^10 ** f |
i38 : degree h |
i39 : degrees source h |
i40 : isHomogeneous h |
For more information about matrices, see Matrix.