up previous next
DiagMat    --    matrix with given diagonal


Syntax
DiagMat(L: LIST): MAT
DiagMat(R: RING, L: LIST): MAT

Description
This function returns the diagonal matrix whose diagonal are the elements of the list L . By default the matrix is over QQ .

Example
/**/  DiagMat([3,4,5]);
matrix(QQ,
[
  [3, 0, 0],
  [0, 4, 0],
  [0, 0, 5]
])

/**/ DiagMat(ZZ,[5,6,7]);
matrix(ZZ,
[
  [5, 0, 0],
  [0, 6, 0],
  [0, 0, 7]
])

See Also