chsvlib
chsv helper source code

◆ set_diagonal_matrix()

void Chusov::Math::set_diagonal_matrix ( ValueType *  column_matrix,
std::size_t  columns,
std::size_t  rows,
ValueType  diag 
)
noexcept

Assigns a diagonal matrix to elements in a buffer considered a column-major matrix representation.

Template Parameters
ValueTypeA type of a matrix element.
Parameters
[in,out]column_matrixA pointer to a two-dimensional array filled with matrix elements to be replaced by the assignment. The array must be sufficient to hold columns * rows elements of the type ValueType.
columnsA number of columns in the matrix to set.
rowsA number of rows in the matrix to set.
diagA value copy-assigned to elements of the main diagonal of the target matrix.
Exceptions
Anyexception thrown by the default constructor, copy- or move-assignment operator of ValueType.

The function copy-assigns diag to all elements of the main diagonal of the target matrix and assigns default-constructed ValueType elements to the other elements.

In order to construct elements of a diagonal matrix, rather than assign them, use construct_diagonal_matrix.