From 014f598fdbfa7aadd16cd08898f4375e790b3e79 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Mon, 23 Apr 2001 19:50:23 +0000 Subject: [PATCH] * class matrix: solve() doesn't call algorithms redundantly any more and inverse() falls back to solve() which works in more general cases. --- ginac/matrix.cpp | 66 ++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 41 deletions(-) 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