diff --git a/SpMat.h b/SpMat.h index 8734f62820b8026511973906a51a3c305d0e3554..8a4ad59b4668c145b15a7467583ac685af9c7638 100644 --- a/SpMat.h +++ b/SpMat.h @@ -28,6 +28,7 @@ #include <thread> #include <chrono> #include "armawrap/newmat.h" +#include "utils/threading.h" #include "cg.h" #include "bicg.h" #include "miscmaths.h" @@ -92,10 +93,10 @@ class SpMat { public: SpMat() : _m(0), _n(0), _nz(0), _ri(0), _val(0), _pw(false), _nt(1) {} - SpMat(unsigned int m, unsigned int n, unsigned int nt=1) : _m(m), _n(n), _nz(0), _ri(n), _val(n), _pw(false), _nt(nt) {} - SpMat(unsigned int m, unsigned int n, const unsigned int *irp, const unsigned int *jcp, const double *sp, unsigned int nt=1); - SpMat(const NEWMAT::GeneralMatrix& M, unsigned int nt=1); - SpMat(const std::string& fname, unsigned int nt=1); + SpMat(unsigned int m, unsigned int n, Utilities::NoOfThreads nt=Utilities::NoOfThreads(1)) : _m(m), _n(n), _nz(0), _ri(n), _val(n), _pw(false), _nt(nt._n) {} + SpMat(unsigned int m, unsigned int n, const unsigned int *irp, const unsigned int *jcp, const double *sp, Utilities::NoOfThreads nt=Utilities::NoOfThreads(1)); + SpMat(const NEWMAT::GeneralMatrix& M, Utilities::NoOfThreads nt=Utilities::NoOfThreads(1)); + SpMat(const std::string& fname, Utilities::NoOfThreads nt=Utilities::NoOfThreads(1)); ~SpMat() {} unsigned int Nrows() const {return(_m);} @@ -385,8 +386,8 @@ private: ///////////////////////////////////////////////////////////////////// template<class T> -SpMat<T>::SpMat(unsigned int m, unsigned int n, const unsigned int *irp, const unsigned int *jcp, const double *sp, unsigned int nt) -: _m(m), _n(n), _nz(0), _ri(n), _val(n), _pw(false), _nt(nt) +SpMat<T>::SpMat(unsigned int m, unsigned int n, const unsigned int *irp, const unsigned int *jcp, const double *sp, Utilities::NoOfThreads nt) +: _m(m), _n(n), _nz(0), _ri(n), _val(n), _pw(false), _nt(nt._n) { _nz = jcp[n]; unsigned long nz = 0; @@ -415,8 +416,8 @@ 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, unsigned int nt) -: _m(M.Nrows()), _n(M.Ncols()), _nz(0), _ri(M.Ncols()), _val(M.Ncols()), _pw(false), _nt(nt) +SpMat<T>::SpMat(const NEWMAT::GeneralMatrix& M, Utilities::NoOfThreads nt) +: _m(M.Nrows()), _n(M.Ncols()), _nz(0), _ri(M.Ncols()), _val(M.Ncols()), _pw(false), _nt(nt._n) { double *m = static_cast<double *>(M.Store()); @@ -451,8 +452,8 @@ SpMat<T>::SpMat(const NEWMAT::GeneralMatrix& M, unsigned int nt) ///////////////////////////////////////////////////////////////////// template<class T> -SpMat<T>::SpMat(const std::string& fname, unsigned int nt) -: _m(0), _n(0), _nz(0), _ri(0), _val(0), _pw(false), _nt(nt) +SpMat<T>::SpMat(const std::string& fname, Utilities::NoOfThreads nt) +: _m(0), _n(0), _nz(0), _ri(0), _val(0), _pw(false), _nt(nt._n) { // First read data into (nz+1)x3 NEWMAT matrix NEWMAT::Matrix rcv; diff --git a/bfmatrix.h b/bfmatrix.h index 1db88105d16b3fb383e4e9e9636201bf5fc0414c..28af88c857d4f5fba0772733c4b54a7864b0b09c 100644 --- a/bfmatrix.h +++ b/bfmatrix.h @@ -30,6 +30,7 @@ #include <memory> #include "armawrap/newmat.h" +#include "utils/threading.h" #include "SpMat.h" #include "cg.h" #include "bicg.h" @@ -140,13 +141,13 @@ public: // Constructors, destructor and assignment SparseBFMatrix() : mp(std::shared_ptr<MISCMATHS::SpMat<T> >(new MISCMATHS::SpMat<T>())) {} - SparseBFMatrix(unsigned int m, unsigned int n, unsigned int nt=1) + SparseBFMatrix(unsigned int m, unsigned int n, Utilities::NoOfThreads nt=Utilities::NoOfThreads(1)) : mp(std::shared_ptr<MISCMATHS::SpMat<T> >(new MISCMATHS::SpMat<T>(m,n,nt))) {} - SparseBFMatrix(unsigned int m, unsigned int n, const unsigned int *irp, const unsigned int *jcp, const double *sp, unsigned int nt=1) + SparseBFMatrix(unsigned int m, unsigned int n, const unsigned int *irp, const unsigned int *jcp, const double *sp, Utilities::NoOfThreads nt=Utilities::NoOfThreads(1)) : mp(std::shared_ptr<MISCMATHS::SpMat<T> >(new MISCMATHS::SpMat<T>(m,n,irp,jcp,sp,nt))) {} SparseBFMatrix(const MISCMATHS::SpMat<T>& M) : mp(std::shared_ptr<MISCMATHS::SpMat<T> >(new MISCMATHS::SpMat<T>(M))) {} - SparseBFMatrix(const NEWMAT::Matrix& M, unsigned int nt=1) + SparseBFMatrix(const NEWMAT::Matrix& M, Utilities::NoOfThreads nt=Utilities::NoOfThreads(1)) : mp(std::shared_ptr<MISCMATHS::SpMat<T> >(new MISCMATHS::SpMat<T>(M,nt))) {} SparseBFMatrix(const SparseBFMatrix<T>& M) : mp(std::shared_ptr<MISCMATHS::SpMat<T> >(new MISCMATHS::SpMat<T>(*(M.mp)))) {}