chsvlib
chsv helper source code

◆ matrix_inverse_copy()

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

Computes a multiplicative inverse of a matrix and assigns it to a different matrix.

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.
[in,out]inversePoints to a two-dimensional array of n2 elements which receives the reciprocal of column_matrix. The buffer must not overlap with 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 becomes unspecified but valid, i.e. the elements of the output matrix have an unspecified but valid values that might need destruction.

The function performs assignment of the result of computation to the buffer pointed to by inverse which implies that on input inverse must address an array in which all n2 elements are valid prior to the call. To write the reciprocal into an uninitialized buffer, use matrix_inverse_construct.

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

See also
matrix_inverse_copy_parallel The parallel version of the operation.