Function opensn::InvertMatrix(const std::vector<std::vector<double>>&)

Function Documentation

std::vector<std::vector<double>> opensn::InvertMatrix(const std::vector<std::vector<double>> &matrix)

Invert a square matrix using SVD-based pseudo-inversion (LAPACK dgesvd).

Singular values below machine-epsilon * n * sigma_max are treated as zero. Emits a warning if the condition number exceeds 1e10.

Throws:

std::runtime_error – if the matrix is empty, non-square, or SVD fails.