Skip to content
Snippets Groups Projects
Commit 57b9665a authored by Jesper Andersson's avatar Jesper Andersson
Browse files

Changed .Print() function for SparseBFMatrix to use row col val format

parent 73f01f11
No related branches found
No related tags found
No related merge requests found
......@@ -12,32 +12,11 @@
#include <boost/shared_ptr.hpp>
#include "newmat.h"
#include "newmatio.h"
#include "miscmaths/miscmaths.h"
#include "bfmatrix.h"
namespace MISCMATHS {
//
// Member functions for BFMatrix
//
void BFMatrix::print(const NEWMAT::Matrix& m,
const std::string& fname) const
{
if (!fname.length()) {
cout << endl << m << endl;
}
else {
try {
ofstream fout(fname.c_str());
fout << setprecision(10) << m;
}
catch(...) {
std::string errmsg("BFMatrix::print: Failed to write to file " + fname);
throw BFMatrixException(errmsg);
}
}
}
//
// Member functions for SparseBFMatrix
//
......@@ -252,6 +231,12 @@ NEWMAT::ReturnMatrix SparseBFMatrix::SolveForx(const NEWMAT::ColumnVector& b,
// Member functions for FullBFMatrix
//
void FullBFMatrix::Print(const std::string fname) const
{
if (!fname.length()) cout << endl << *mp << endl;
else write_ascii_matrix(fname,*mp);
}
boost::shared_ptr<BFMatrix> FullBFMatrix::Transpose()
const
{
......
......@@ -52,7 +52,7 @@ public:
class BFMatrix
{
protected:
virtual void print(const NEWMAT::Matrix& m, const std::string& fname) const;
public:
// Constructors, destructors and stuff
BFMatrix() {}
......@@ -144,7 +144,7 @@ public:
virtual unsigned int Ncols() const {return(mp->Ncols());}
// Print matrix (for debugging)
virtual void Print(const std::string fname=std::string("")) const {print(mp->AsNEWMAT(),fname);}
virtual void Print(const std::string fname=std::string("")) const {mp->Print(fname);}
// Setting, deleting or resizing the whole sparse matrix.
virtual void SetMatrix(const MISCMATHS::SpMat<double>& M) {mp = boost::shared_ptr<MISCMATHS::SpMat<double> >(new MISCMATHS::SpMat<double>(M));}
......@@ -217,7 +217,7 @@ public:
virtual unsigned int Ncols() const {return(mp->Ncols());}
// Print matrix (for debugging)
virtual void Print(const std::string fname=std::string("")) const {print(*mp,fname);}
virtual void Print(const std::string fname=std::string("")) const;
// Setting, deleting or resizing the whole matrix.
virtual void SetMatrix(const MISCMATHS::SpMat<double>& M) {mp = boost::shared_ptr<NEWMAT::Matrix>(new NEWMAT::Matrix(M.AsNEWMAT()));}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment