From: Richard Kreckel Date: Mon, 23 Apr 2001 19:50:23 +0000 (+0000) Subject: * class matrix: solve() doesn't call algorithms redundantly any more and X-Git-Tag: release_0-8-2~6 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=014f598fdbfa7aadd16cd08898f4375e790b3e79 * class matrix: solve() doesn't call algorithms redundantly any more and inverse() falls back to solve() which works in more general cases. --- diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index 25de42bf..8a68b663 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -875,50 +875,32 @@ matrix matrix::inverse(void) const if (row != col) throw (std::logic_error("matrix::inverse(): matrix not square")); - // NOTE: the Gauss-Jordan elimination used here can in principle be - // replaced by two clever calls to gauss_elimination() and some to - // transpose(). Wouldn't be more efficient (maybe less?), just more - // orthogonal. - matrix tmp(row,col); - // set tmp to the unit matrix - for (unsigned i=0; isolve(vars,identity); + } catch (const std::runtime_error & e) { + if (e.what()==std::string("matrix::solve(): inconsistent linear system")) throw (std::runtime_error("matrix::inverse(): singular matrix")); - } - if (indx != 0) { // swap rows r and indx of matrix tmp - for (unsigned i=0; i