[next][up][top][index]
search for:

making matrices

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}}

o2 = | x 0  yz |
     | 0 y2 x2 |

             2       3
o2 : Matrix R  <--- R

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)

              2           2           2
o3 = {{1, x, x }, {1, y, y }, {1, z, z }}

o3 : List
i4 : p = matrix oo

o4 = | 1 x x2 |
     | 1 y y2 |
     | 1 z z2 |

             3       3
o4 : Matrix R  <--- R
i5 : q = matrix table(3,3,(i,j) -> R_j^i)

o5 = | 1  1  1  |
     | x  y  z  |
     | x2 y2 z2 |

             3       3
o5 : Matrix R  <--- R

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

o6 = | x x2 x3  |
     | x xy xy2 |
     | x xz xz2 |

             3       3
o6 : Matrix R  <--- R
i7 : 11-p

o7 = | 10 -x    -x2    |
     | -1 -y+11 -y2    |
     | -1 -z    -z2+11 |

             3       3
o7 : Matrix R  <--- R
i8 : p*q

o8 = | x4+x2+1   x2y2+xy+1 x2z2+xz+1 |
     | x2y2+xy+1 y4+y2+1   y2z2+yz+1 |
     | x2z2+xz+1 y2z2+yz+1 z4+z2+1   |

             3       3
o8 : Matrix R  <--- R
i9 : p++q

o9 = | 1 x x2 0  0  0  |
     | 1 y y2 0  0  0  |
     | 1 z z2 0  0  0  |
     | 0 0 0  1  1  1  |
     | 0 0 0  x  y  z  |
     | 0 0 0  x2 y2 z2 |

             6       6
o9 : Matrix R  <--- R
i10 : r = p++x

o10 = | 1 x x2 0 |
      | 1 y y2 0 |
      | 1 z z2 0 |
      | 0 0 0  x |

              4       4
o10 : Matrix R  <--- R
i11 : x ++ y ++ z ++ x*y*z

o11 = | x 0 0 0   |
      | 0 y 0 0   |
      | 0 0 z 0   |
      | 0 0 0 xyz |

              4       4
o11 : Matrix R  <--- R
i12 : p**p

o12 = | 1 x x2 x x2 x3  x2 x3  x4   |
      | 1 y y2 x xy xy2 x2 x2y x2y2 |
      | 1 z z2 x xz xz2 x2 x2z x2z2 |
      | 1 x x2 y xy x2y y2 xy2 x2y2 |
      | 1 y y2 y y2 y3  y2 y3  y4   |
      | 1 z z2 y yz yz2 y2 y2z y2z2 |
      | 1 x x2 z xz x2z z2 xz2 x2z2 |
      | 1 y y2 z yz y2z z2 yz2 y2z2 |
      | 1 z z2 z z2 z3  z2 z3  z4   |

              9       9
o12 : Matrix R  <--- R

The components of a direct sum can be recovered later.

i13 : components r

o13 = {| 1 x x2 |, | x |}
       | 1 y y2 |
       | 1 z z2 |

o13 : List

There are commands for horizontal and vertical concatenation of matrices, and again, scalars are converted to scalar matrices when necessary.

i14 : p|q

o14 = | 1 x x2 1  1  1  |
      | 1 y y2 x  y  z  |
      | 1 z z2 x2 y2 z2 |

              3       6
o14 : Matrix R  <--- R
i15 : p||q

o15 = | 1  x  x2 |
      | 1  y  y2 |
      | 1  z  z2 |
      | 1  1  1  |
      | x  y  z  |
      | x2 y2 z2 |

              6       3
o15 : Matrix R  <--- R
i16 : p|1

o16 = | 1 x x2 1 0 0 |
      | 1 y y2 0 1 0 |
      | 1 z z2 0 0 1 |

              3       6
o16 : Matrix R  <--- R
i17 : x^3||p

o17 = {0} | x3 0  0  |
      {1} | 0  x3 0  |
      {2} | 0  0  x3 |
      {0} | 1  x  x2 |
      {0} | 1  y  y2 |
      {0} | 1  z  z2 |

              6       3
o17 : Matrix R  <--- R

An identity matrix can be obtained with id as the identity map on a free module.

i18 : id_(R^3)

o18 = | 1 0 0 |
      | 0 1 0 |
      | 0 0 1 |

              3       3
o18 : Matrix R  <--- R

A matrix is regarded as a homomorphism between two free modules, its source and target.

i19 : M = target f

       2
o19 = R

o19 : R-module, free
i20 : N = source f

       3
o20 = R

o20 : R-module, free, degrees {1, 2, 2}

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

o21 = {0}

o21 : List
i22 : degree M_1

o22 = {0}

o22 : List

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

o23 = {1}

o23 : List
i24 : degree N_1

o24 = {2}

o24 : List
i25 : degree N_2

o25 = {2}

o25 : List
i26 : isHomogeneous f

o26 = true

A list of the degrees of all the basis vectors can be obtained with degrees.

i27 : degrees N

o27 = {{1}, {2}, {2}}

o27 : List

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}}

o28 = | x  0  yz |
      | y2 x2 0  |

              2       3
o28 : Matrix R  <--- R
i29 : isHomogeneous g

o29 = false
i30 : degrees source g

o30 = {{2}, {2}, {2}}

o30 : List

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}}

o31 = {0}

o31 : List
i32 : degree f

o32 = {0}

o32 : List

Multiplying a matrix by a homogeneous polynomial adds the degree of the polynomial to the degree of the map.

i33 : h = x^10 * f

o33 = | x11 0     x10yz |
      | 0   x10y2 x12   |

              2       3
o33 : Matrix R  <--- R
i34 : degree h

o34 = {10}

o34 : List
i35 : degrees source h

o35 = {{1}, {2}, {2}}

o35 : List
i36 : isHomogeneous h

o36 = true

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

o37 = | x11 0     x10yz |
      | 0   x10y2 x12   |

              2       3
o37 : Matrix R  <--- R
i38 : degree h

o38 = {0}

o38 : List
i39 : degrees source h

o39 = {{11}, {12}, {12}}

o39 : List
i40 : isHomogeneous h

o40 = true

For more information about matrices, see Matrix.


[next][up][top][index]
search for: