Skip to main content

Diag

This function creates a diagonal matrix.

The generic syntax is given below.

Diag syntax
diagMat = Diag(d)
  • where, d denotes the main diagonal of the diagMat.
  • d can be a vector of Real32, Real64, Int8, Int16, Int32, Int64
  • The result is always n x n matrix of REAL(DFP).
info

We can also use Diag to access the diagonal of the matrix. The syntaxt is given below:

d = Diag(mat, diagNo)

where,

  • mat is a two-dimensional square matrix
  • diagNo is an integer, which stands for the diagonal
  • diagNo == 0 denotes the main diagonal
  • diagNo > 0 denotes the super-diagonal
  • diagNo < 0 denotes the sub diagonal