From a6bb12411bcda0d58e2405b11397e27744564210 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Tue, 21 Dec 1999 17:25:10 +0000 Subject: [PATCH] - matrix row/col made unsigned --- ginac/matrix.cpp | 166 +++++++++++++++++++++++------------------------ ginac/matrix.h | 28 ++++---- 2 files changed, 97 insertions(+), 97 deletions(-) diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index eddc6205..deeba280 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -92,20 +92,20 @@ void matrix::destroy(bool call_parent) * * @param r number of rows * @param c number of cols */ -matrix::matrix(int r, int c) +matrix::matrix(unsigned r, unsigned c) : basic(TINFO_matrix), row(r), col(c) { - debugmsg("matrix constructor from int,int",LOGLEVEL_CONSTRUCT); + debugmsg("matrix constructor from unsigned,unsigned",LOGLEVEL_CONSTRUCT); m.resize(r*c, _ex0()); } // protected /** Ctor from representation, for internal use only. */ -matrix::matrix(int r, int c, exvector const & m2) +matrix::matrix(unsigned r, unsigned c, exvector const & m2) : basic(TINFO_matrix), row(r), col(c), m(m2) { - debugmsg("matrix constructor from int,int,exvector",LOGLEVEL_CONSTRUCT); + debugmsg("matrix constructor from unsigned,unsigned,exvector",LOGLEVEL_CONSTRUCT); } ////////// @@ -124,15 +124,15 @@ void matrix::print(ostream & os, unsigned upper_precedence) const { debugmsg("matrix print",LOGLEVEL_PRINT); os << "[[ "; - for (int r=0; r=row || co<0 || co>=col) { throw (std::range_error("matrix::operator(): index out of range")); @@ -360,7 +360,7 @@ ex const & matrix::operator() (int ro, int co) const /** Set individual elements manually. * * @exception range_error (index out of range) */ -matrix & matrix::set(int ro, int co, ex value) +matrix & matrix::set(unsigned ro, unsigned co, ex value) { if (ro<0 || ro>=row || co<0 || co>=col) { throw (std::range_error("matrix::set(): index out of range")); @@ -377,8 +377,8 @@ matrix matrix::transpose(void) const { exvector trans(col*row); - for (int r=0; r sigma(M.cols()); - for (int i=0; i sigma(M.cols()); + for (unsigned i=0; i0; --r) { - int first_non_zero=1; + unsigned last_assigned_sol=n+1; + for (unsigned r=m; r>0; --r) { + unsigned first_non_zero=1; while ((first_non_zero<=n)&&(a.ffe_get(r,first_non_zero).is_zero())) { first_non_zero++; } @@ -762,11 +762,11 @@ matrix matrix::fraction_free_elim(matrix const & vars, } else { // assign solutions for vars between first_non_zero+1 and // last_assigned_sol-1: free parameters - for (int c=first_non_zero+1; c<=last_assigned_sol-1; ++c) { + for (unsigned c=first_non_zero+1; c<=last_assigned_sol-1; ++c) { sol.ffe_set(c,1,vars.ffe_get(c,1)); } ex e=b.ffe_get(r,1); - for (int c=first_non_zero+1; c<=n; ++c) { + for (unsigned c=first_non_zero+1; c<=n; ++c) { e=e-a.ffe_get(r,c)*sol.ffe_get(c,1); } sol.ffe_set(first_non_zero,1, @@ -776,21 +776,21 @@ matrix matrix::fraction_free_elim(matrix const & vars, } // assign solutions for vars between 1 and // last_assigned_sol-1: free parameters - for (int c=1; c<=last_assigned_sol-1; ++c) { + for (unsigned c=1; c<=last_assigned_sol-1; ++c) { sol.ffe_set(c,1,vars.ffe_get(c,1)); } /* - for (int c=1; c<=n; ++c) { + for (unsigned c=1; c<=n; ++c) { cout << vars.ffe_get(c,1) << "->" << sol.ffe_get(c,1) << endl; } */ #ifdef DO_GINAC_ASSERT // test solution with echelon matrix - for (int r=1; r<=m; ++r) { + for (unsigned r=1; r<=m; ++r) { ex e=0; - for (int c=1; c<=n; ++c) { + for (unsigned c=1; c<=n; ++c) { e=e+a.ffe_get(r,c)*sol.ffe_get(c,1); } if (!(e-b.ffe_get(r,1)).normal().is_zero()) { @@ -802,9 +802,9 @@ matrix matrix::fraction_free_elim(matrix const & vars, } // test solution with original matrix - for (int r=1; r<=m; ++r) { + for (unsigned r=1; r<=m; ++r) { ex e=0; - for (int c=1; c<=n; ++c) { + for (unsigned c=1; c<=n; ++c) { e=e+ffe_get(r,c)*sol.ffe_get(c,1); } try { @@ -837,24 +837,24 @@ matrix matrix::solve(matrix const & v) const // build the extended matrix of *this with v attached to the right matrix tmp(row,col+v.col); - for (int r=0; r=0; --r) { + for (unsigned c=0; c=0; --r) { sol[r*v.col+c] = tmp[r*tmp.col+c]; - for (int i=r+1; i