Macaulay2 » Documentation
Packages » Macaulay2Doc » matrices » mutable matrices
next | previous | forward | backward | up | index | toc

mutable matrices

To and from matrices:

i1 : m = matrix{{1,2,3},{4,5,6}}

o1 = | 1 2 3 |
     | 4 5 6 |

              2       3
o1 : Matrix ZZ  <-- ZZ
i2 : n = mutableMatrix m

o2 = | 1 2 3 |
     | 4 5 6 |

                     2       3
o2 : MutableMatrix ZZ  <-- ZZ
i3 : m2 = matrix n

o3 = | 1 2 3 |
     | 4 5 6 |

              2       3
o3 : Matrix ZZ  <-- ZZ
i4 : m2 - m == 0

o4 = true

Modifying and accessing entries. Remember that the upper left entry is (0,0), not (1,1)!

i5 : n_(0,0) = 212314323

o5 = 212314323
i6 : n_(0,0)

o6 = 212314323
i7 : n

o7 = | 212314323 2 3 |
     | 4         5 6 |

                     2       3
o7 : MutableMatrix ZZ  <-- ZZ

Number of rows, columns, and the ring:

i8 : numrows n

o8 = 2
i9 : numColumns n

o9 = 3
i10 : numcols n

o10 = 3
i11 : ring n

o11 = ZZ

o11 : Ring

row and column operations

Some other methods for creating mutable matrices.

i12 : mutableIdentity(RR_100,5)

o12 = | 1 0 0 0 0 |
      | 0 1 0 0 0 |
      | 0 0 1 0 0 |
      | 0 0 0 1 0 |
      | 0 0 0 0 1 |

                         5          5
o12 : MutableMatrix RR     <-- RR
                      100        100
i13 : mutableMatrix(QQ,3,5)

o13 = 0

                      3       5
o13 : MutableMatrix QQ  <-- QQ
i14 : randomMutableMatrix(4,4,.5,100)

o14 = | -35 0 0  0   |
      | 100 0 0  0   |
      | 0   0 82 18  |
      | -14 0 0  -98 |

                      4       4
o14 : MutableMatrix ZZ  <-- ZZ

Menu


The source of this document is in /build/reproducible-path/macaulay2-1.26.11+ds/M2/Macaulay2/packages/Macaulay2Doc/doc_mutablematrices.m2:69:0.