From 7c5872a04c4c083c66beb1843a21ec8ad10ca3e9 Mon Sep 17 00:00:00 2001 From: Jesper Andersson <jesper@fmrib.ox.ac.uk> Date: Thu, 28 May 2009 17:58:54 +0000 Subject: [PATCH] Default behaviour is now that warnings are turned off --- SpMat.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/SpMat.h b/SpMat.h index 4e39924..105dc50 100644 --- a/SpMat.h +++ b/SpMat.h @@ -89,8 +89,8 @@ template<class T> class SpMat { public: - SpMat() : _m(0), _n(0), _nz(0), _ri(0), _val(0) {} - SpMat(unsigned int m, unsigned int n) : _m(m), _n(n), _nz(0), _ri(n), _val(n) {} + SpMat() : _m(0), _n(0), _nz(0), _ri(0), _val(0), _pw(false) {} + SpMat(unsigned int m, unsigned int n) : _m(m), _n(n), _nz(0), _ri(n), _val(n), _pw(false) {} SpMat(unsigned int m, unsigned int n, const unsigned int *irp, const unsigned int *jcp, const double *sp); SpMat(const NEWMAT::GeneralMatrix& M); SpMat(const std::string& fname); @@ -109,6 +109,8 @@ public: void Print(const std::string& fname) const {Print(fname,8);} void Print(unsigned int precision) const {Print(std::string(""),precision);} void Print() const {Print(8);} + void WarningsOn() {_pw=true;} + void WarningsOff() {_pw=false;} T Peek(unsigned int r, unsigned int c) const; @@ -173,6 +175,7 @@ private: unsigned long _nz; std::vector<std::vector<unsigned int> > _ri; std::vector<std::vector<T> > _val; + bool _pw; // Print Warnings bool found(const std::vector<unsigned int>& ri, unsigned int key, int& pos) const; T& here(unsigned int r, unsigned int c); @@ -305,7 +308,7 @@ private: template<class T> SpMat<T>::SpMat(unsigned int m, unsigned int n, const unsigned int *irp, const unsigned int *jcp, const double *sp) -: _m(m), _n(n), _nz(0), _ri(n), _val(n) + : _m(m), _n(n), _nz(0), _ri(n), _val(n), _pw(false) { _nz = jcp[n]; unsigned long nz = 0; @@ -335,7 +338,7 @@ SpMat<T>::SpMat(unsigned int m, unsigned int n, const unsigned int *irp, const u template<class T> SpMat<T>::SpMat(const NEWMAT::GeneralMatrix& M) -: _m(M.Nrows()), _n(M.Ncols()), _nz(0), _ri(M.Ncols()), _val(M.Ncols()) + : _m(M.Nrows()), _n(M.Ncols()), _nz(0), _ri(M.Ncols()), _val(M.Ncols()), _pw(false) { double *m = static_cast<double *>(M.Store()); @@ -371,7 +374,7 @@ SpMat<T>::SpMat(const NEWMAT::GeneralMatrix& M) template<class T> SpMat<T>::SpMat(const std::string& fname) -: _m(0), _n(0), _nz(0), _ri(0), _val(0) +: _m(0), _n(0), _nz(0), _ri(0), _val(0), _pw(false) { // First read data into (nz+1)x3 NEWMAT matrix NEWMAT::Matrix rcv; @@ -573,7 +576,7 @@ NEWMAT::ReturnMatrix SpMat<T>::SolveForx(const NEWMAT::ColumnVector& throw SpMatException("SolveForx: No idea how you got here. But you shouldn't be here, punk."); } - if (status) { + if (status && _pw) { cout << "SpMat::SolveForx: Warning requested tolerence not obtained." << endl; cout << "Requested tolerance was " << ltol << ", and achieved tolerance was " << tol << endl; cout << "This may or may not be a problem in your application, but you should look into it" << endl; -- GitLab