chsvlib
chsv helper source code

◆ matrix_inverse_inplace()

bool Chusov::Math::matrix_inverse_inplace ( ValueType *  column_matrix,
std::size_t  n 
)

Computes a multiplicative inverse of a matrix in place.

Template Parameters
ValueTypeA type of a matrix element.
Parameters
[in,out]column_matrixA column-major two-dimensional array which represents the matrix, of n by n elements, to invert. On output the same array accepts the reciprocal.
nA number of columns and a number of rows in column_matrix.
Returns
true, if the reciprocal of the matrix is successfully calculated, and false, if the input matrix is singular and thus does not have a reciprocal.
Exceptions
std::bad_allocThe function failed to allocate memory necessary to complete the operation.

If the function returns false or throws an exception, the content of column_matrix is unspecified but valid, i.e. the elements of the output matrix have an unspecified but valid values that need destruction.

To write the reciprocal to a different non-overlapping buffer, use either matrix_inverse_copy, if the destination buffer already is an array of valid ValueType elements, or matrix_inverse_construct, if the destination buffer only provides uninitialized memory space.

See also
matrix_inverse_inplace_parallel The parallel version of the operation.