From 6a07d58854e6dbc380e2204f6b154992c574d009 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Mon, 18 Sep 2000 15:31:31 +0000 Subject: [PATCH] - matrix::gauss_elimination(): Added a shortcut for sparse cases. --- ginac/matrix.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index d6091aa4..d72104a4 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -944,11 +944,14 @@ int matrix::gauss_elimination(const bool det) if (indx > 0) sign = -sign; for (unsigned r2=r0+1; r2m[r2*n+r1] / this->m[r0*n+r1]; - for (unsigned c=r1+1; cm[r2*n+c] -= piv * this->m[r0*n+c]; - if (!this->m[r2*n+c].info(info_flags::numeric)) - this->m[r2*n+c] = this->m[r2*n+c].normal(); + if (!this->m[r2*n+r1].is_zero()) { + // 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]; + if (!this->m[r2*n+c].info(info_flags::numeric)) + this->m[r2*n+c] = this->m[r2*n+c].normal(); + } } // fill up left hand side with zeros for (unsigned c=0; c<=r1; ++c) -- 2.47.0