Macaulay2 » Documentation
Packages » Macaulay2Doc :: diagonalMatrix(Matrix)
next | previous | forward | backward | up | index | toc

diagonalMatrix(Matrix) -- make a diagonal matrix from entries of a matrix

Synopsis

Description

i1 : R = QQ[a..d];
i2 : diagonalMatrix vars R

o2 = | a 0 0 0 |
     | 0 b 0 0 |
     | 0 0 c 0 |
     | 0 0 0 d |

             4      4
o2 : Matrix R  <-- R
If the matrix has more than one row, the first column is placed on the diagonal first, then the second column, etc.
i3 : diagonalMatrix matrix{{0,2},{4,6}}

o3 = | 0 0 0 0 |
     | 0 4 0 0 |
     | 0 0 2 0 |
     | 0 0 0 6 |

              4       4
o3 : Matrix ZZ  <-- ZZ

See also

Ways to use this method: