Module Operator.Mat

val eye : int -> Symbol.Shape.Type.arr

eye n creates an n x n identity matrix, where all the elements on the main diagonal are 1, and all other elements are 0. Returns a new array representing the identity matrix.

diagm ?k v creates a diagonal matrix from the array v.

  • k specifies the diagonal to fill. The main diagonal is 0, positive values refer to diagonals above the main, and negative values refer to diagonals below the main. Returns a new array representing the diagonal matrix.

triu ?k a returns the upper triangular part of the array a, with elements below the k-th diagonal zeroed. The main diagonal is 0, positive values refer to diagonals above the main, and negative values refer to diagonals below the main. Returns a new array with the upper triangular part.

tril ?k a returns the lower triangular part of the array a, with elements above the k-th diagonal zeroed. The main diagonal is 0, positive values refer to diagonals above the main, and negative values refer to diagonals below the main. Returns a new array with the lower triangular part.