# chickadee » matrix-utils » make-matrix-diag

##### Identifier search
make-matrix-diag:procedure

Given procedures VECTOR-REF, MAKE-VECTOR and FILL-MATRIX!, returns a procedure DIAG of the form DIAG:: M * N * V [K * ORDER] -> D

Where procedure DIAG returns a diagonal matrix D of size M x N, with vector V on diagonal K. Argument K is optional. If it is positive, the vector is placed on the K-th super-diagonal of matrix D. If it is negative, it is placed on the -K-th sub-diagonal of matrix D. The default value of K is 0, and the vector is placed on the main diagonal of matrix D. Optional argument ORDER specifies the matrix layout: ColMajor or RowMajor, default is RowMajor. Vector V is always assumed to be a row vector.

VECTOR-REF and MAKE-VECTOR are two of the homogeneous vector procedures from SRFI-4, and FILL-MATRIX! is a procedure created by MAKE-FILL-MATRIX, above. FILL-MATRIX! must operate on the same type of vector as VECTOR-REF and MAKE-VECTOR.