chsvlib
chsv helper source code

◆ matrix_inverse_construct()

bool Chusov::Math::matrix_inverse_construct ( const ValueType *restrict  column_matrix,
std::size_t  n,
ValueType *restrict  inverse 
)

Computes a multiplicative inverse of a matrix and constructs the reciprocal matrix in an uninitialized memory buffer.

Template Parameters
ValueTypeA type of a matrix element.
Parameters
[in]column_matrixA column-major two-dimensional array which represents the input matrix, of n by n elements, to invert.
nA number of columns and a number of rows in column_matrix.
[out]inversePoints to a buffer capable of holding n2 elements of the type ValueType. On successful invocation the buffer receives the reciprocal of 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 inverse is left uninitialized.

The output buffer addressed by inverse is assumed uninitialized on input. No destruction of anything that was in inverse prior to the invocation of the function takes place.

To replace an array of existing n2 elements in a buffer different from input one, use matrix_inverse_copy.

To compute the inverse in place of the original matrix, use matrix_inverse_inplace.

See also
matrix_inverse_construct_parallel The parallel version of the operation.