Function navtk::sqrt_of_main_diagonal

Function Documentation

Matrix navtk::sqrt_of_main_diagonal(const Matrix &matrix)

Calculate the square root of all values on the main diagonal as an approximation to the Cholesky decomposition of a matrix.

This may be useful when matrix is not positive definite but an approximation is acceptable.

Parameters

matrix – A square matrix (NxN).

Throws

std::runtime_error – If A is non-square or contains a negative element along diagonal and the error mode is ErrorMode::DIE.

Returns

Diagonal matrix, same size as A (NxN).