From: Richard Kreckel Date: Mon, 18 Sep 2000 22:31:26 +0000 (+0000) Subject: - matrix::inverse(): Added a shortcut for sparse cases. X-Git-Tag: release_0-7-0~29 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=bfd4561481fc308e8db75c5a33b56787a43e6568 - matrix::inverse(): Added a shortcut for sparse cases. --- diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index d72104a4..763024c3 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -647,7 +647,7 @@ matrix matrix::inverse(void) const throw (std::logic_error("matrix::inverse(): matrix not square")); // NOTE: the Gauss-Jordan elimination used here can in principle be - // replaced this by two clever calls to gauss_elimination() and some to + // 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); @@ -673,14 +673,17 @@ matrix matrix::inverse(void) const } for (unsigned r2=0; r2m[r2*n+r1].is_zero()) { - // there is something to do in this row + // yes, there is something to do in this row ex piv = this->m[r2*n+r1] / this->m[r0*n+r1]; for (unsigned c=r1+1; cm[r2*n+c] -= piv * this->m[r0*n+c]; @@ -1189,7 +1192,7 @@ int matrix::pivot(unsigned ro, unsigned co, bool symbolic) // matrix needs pivoting, so swap rows k and ro ensure_if_modifiable(); for (unsigned c=0; cm[k*col+c].swap(this->m[ro*col+c]); return k; }