Defined in File matrix.h
int rc_matrix_diagonal(rc_matrix_t *A, rc_vector_t v)¶
Generates a diagonal matrix with the elements of specified vector v.
Resizes A to be a square matrix with the same number of rows and columns as vector v’s length. The diagonal entries of A are then populated with the contents of v and the off-diagonal entries are set to 0. The original contents of A are freed to avoid memory leaks.
A – Pointer to user’s matrix struct
v – [in] vector of diagonal entries
0 on success, -1 on failure.