Loading src/CrsMatrix.h +9 −9 Original line number Diff line number Diff line Loading @@ -190,15 +190,15 @@ public: std::ClosureOperations::OP_MULT>& c) { CrsMatrix& x = *this; const CrsMatrix& y = c.v1_; const CrsMatrix& z = c.v2_; const CrsMatrix& y = c.r1; const CrsMatrix& z = c.r2; multiply(x,y,z); } CrsMatrix(const std::ClosureOperator<T,CrsMatrix,std::ClosureOperations::OP_MULT>& c) { *this = c.v2_; this->values_ *= c.v1_; *this = c.r2; this->values_ *= c.r1; } // end all ctors Loading Loading @@ -408,8 +408,8 @@ public: CrsMatrix, std::ClosureOperations::OP_MULT>& c) { *this = c.v2_; this->values_ *= c.v1_; *this = c.r2; this->values_ *= c.r1; return *this; } Loading @@ -421,7 +421,7 @@ public: std::ClosureOperations::OP_MULT>& c) { CrsMatrix s; add(s,c.v2_,c.v1_); add(s,c.r2,c.r1); *this = s; return *this; } Loading @@ -436,9 +436,9 @@ public: std::ClosureOperations::OP_MULT>& c) { CrsMatrix s; multiply(s,c.v1_.v2_,c.v2_); multiply(s,c.r1.r2,c.r2); CrsMatrix s2; add(s2,s,c.v1_.v1_); add(s2,s,c.r1.r1); *this = s2; return *this; } Loading src/Matrix.h +48 −48 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ public: // ctor closures Matrix(const std::ClosureOperator<Matrix,Matrix,std::ClosureOperations::OP_MULT>& c) { matrixMatrix(c.v1_,c.v2_,1.0); matrixMatrix(c.r1,c.r2,1.0); } template<typename T1> Loading @@ -90,7 +90,7 @@ public: std::ClosureOperations::OP_MULT>& c, typename EnableIf<Loki::TypeTraits<T1>::isArith,int>::Type = 0) { *this = c.v1_.v1_*c.v1_.v2_*c.v2_; *this = c.r1.r1*c.r1.r2*c.r2; } template<typename T1> Loading @@ -99,7 +99,7 @@ public: std::ClosureOperations::OP_MULT>& c, typename EnableIf<Loki::TypeTraits<T1>::isArith,int>::Type = 0) { *this = c.v1_*(c.v2_.v1_+c.v2_.v2_); *this = c.r1*(c.r2.r1+c.r2.r2); } // end all ctors Loading Loading @@ -249,36 +249,36 @@ public: template<typename T1> Matrix& operator+=(const std::ClosureOperator<T1,Matrix,std::ClosureOperations::OP_MULT>& c) { nrow_ = c.v2_.nrow_; ncol_ = c.v2_.ncol_; this->data_ += c.v1_*c.v2_.data_; nrow_ = c.r2.nrow_; ncol_ = c.r2.ncol_; this->data_ += c.r1*c.r2.data_; return *this; } template<typename T1> Matrix& operator+=(const std::ClosureOperator<Matrix,T1,std::ClosureOperations::OP_MULT>& c) { nrow_ = c.v1_.nrow_; ncol_ = c.v1_.ncol_; this->data_ += c.v2_*c.v1_.data_; nrow_ = c.r1.nrow_; ncol_ = c.r1.ncol_; this->data_ += c.r2*c.r1.data_; return *this; } template<typename T1> Matrix& operator=(const std::ClosureOperator<T1,Matrix,std::ClosureOperations::OP_MULT>& c) { nrow_ = c.v2_.nrow_; ncol_ = c.v2_.ncol_; this->data_ <= c.v1_*c.v2_.data_; nrow_ = c.r2.nrow_; ncol_ = c.r2.ncol_; this->data_ <= c.r1*c.r2.data_; return *this; } template<typename T1> Matrix& operator=(const std::ClosureOperator<Matrix,T1,std::ClosureOperations::OP_MULT>& c) { nrow_ = c.v1_.nrow_; ncol_ = c.v1_.ncol_; this->data_ <= c.v2_*c.v1_.data_; nrow_ = c.r1.nrow_; ncol_ = c.r1.ncol_; this->data_ <= c.r2*c.r1.data_; return *this; } Loading @@ -288,7 +288,7 @@ public: Matrix, std::ClosureOperations::OP_MULT>& c) { matrixMatrix(c.v1_.v2_,c.v2_,c.v1_.v1_); matrixMatrix(c.r1.r2,c.r2,c.r1.r1); return *this; } Loading @@ -297,9 +297,9 @@ public: std::ClosureOperator<Matrix,Matrix,std::ClosureOperations::OP_PLUS>, std::ClosureOperations::OP_MULT>& c) { this->nrow_ = c.v2_.v1_.nrow_; this->ncol_ = c.v2_.v1_.ncol_; this->data_ <= c.v1_*(c.v2_.v1_.data_ + c.v2_.v2_.data_); this->nrow_ = c.r2.r1.nrow_; this->ncol_ = c.r2.r1.ncol_; this->data_ <= c.r1*(c.r2.r1.data_ + c.r2.r2.data_); return *this; } Loading @@ -308,31 +308,31 @@ public: std::ClosureOperator<Matrix,Matrix,std::ClosureOperations::OP_MINUS>, std::ClosureOperations::OP_MULT>& c) { this->nrow_ = c.v2_.v1_.nrow_; this->ncol_ = c.v2_.v1_.ncol_; this->data_ <= c.v1_*(c.v2_.v1_.data_ - c.v2_.v2_.data_); this->nrow_ = c.r2.r1.nrow_; this->ncol_ = c.r2.r1.ncol_; this->data_ <= c.r1*(c.r2.r1.data_ - c.r2.r2.data_); return *this; } Matrix& operator= (const std::ClosureOperator<Matrix,Matrix,std::ClosureOperations::OP_PLUS>& c) { nrow_ = c.v1_.nrow_; ncol_ = c.v1_.ncol_; assert(nrow_ == c.v2_.nrow_); assert(ncol_ == c.v2_.ncol_); this->data_ <= c.v1_.data_ + c.v2_.data_; nrow_ = c.r1.nrow_; ncol_ = c.r1.ncol_; assert(nrow_ == c.r2.nrow_); assert(ncol_ == c.r2.ncol_); this->data_ <= c.r1.data_ + c.r2.data_; return *this; } Matrix& operator= (const std::ClosureOperator<Matrix,Matrix,std::ClosureOperations::OP_MINUS>& c) { nrow_ = c.v1_.nrow_; ncol_ = c.v1_.ncol_; assert(nrow_ == c.v2_.nrow_); assert(ncol_ == c.v2_.ncol_); this->data_ <= c.v1_.data_ - c.v2_.data_; nrow_ = c.r1.nrow_; ncol_ = c.r1.ncol_; assert(nrow_ == c.r2.nrow_); assert(ncol_ == c.r2.ncol_); this->data_ <= c.r1.data_ - c.r2.data_; return *this; } Loading @@ -342,11 +342,11 @@ public: std::ClosureOperator<T1,Matrix,std::ClosureOperations::OP_MULT>, std::ClosureOperations::OP_PLUS>& c) { nrow_ = c.v1_.nrow_; ncol_ = c.v1_.ncol_; assert(nrow_ == c.v2_.v2_.nrow_); assert(ncol_ == c.v2_.v2_.ncol_); this->data_ <= c.v1_.data_ + c.v2_.v1_*c.v2_.v2_.data_; nrow_ = c.r1.nrow_; ncol_ = c.r1.ncol_; assert(nrow_ == c.r2.r2.nrow_); assert(ncol_ == c.r2.r2.ncol_); this->data_ <= c.r1.data_ + c.r2.r1*c.r2.r2.data_; return *this; } Loading @@ -357,19 +357,19 @@ public: Matrix, std::ClosureOperations::OP_PLUS>& c) { nrow_ = c.v2_.nrow_; ncol_ = c.v2_.ncol_; assert(nrow_ == c.v1_.v2_.nrow_); assert(ncol_ == c.v1_.v2_.ncol_); this->data_ <= c.v2_.data_ + c.v1_.v1_*c.v1_.v2_.data_; nrow_ = c.r2.nrow_; ncol_ = c.r2.ncol_; assert(nrow_ == c.r1.r2.nrow_); assert(ncol_ == c.r1.r2.ncol_); this->data_ <= c.r2.data_ + c.r1.r1*c.r1.r2.data_; return *this; } Matrix& operator= (const std::ClosureOperator<Matrix<T>,Matrix,std::ClosureOperations::OP_MULT>& c) { const Matrix<T>& a = c.v1_; const Matrix<T>& b = c.v2_; const Matrix<T>& a = c.r1; const Matrix<T>& b = c.r2; matrixMatrix(a,b,1.0); return *this; Loading Loading @@ -650,8 +650,8 @@ void operator<=(std::vector<T,A>& v, const std::ClosureOperator<Matrix<T>, std::vector<T,A>, std::ClosureOperations::OP_MULT>& c) { const std::vector<T,A>& b = c.v2_; const Matrix<T>& a = c.v1_; const std::vector<T,A>& b = c.r2; const Matrix<T>& a = c.r1; assert(a.n_col()==b.size()); v.resize(a.n_row()); for (SizeType i=0;i<a.n_row();i++) { Loading @@ -666,8 +666,8 @@ void operator<=(std::vector<T,A>& v, const std::ClosureOperator<std::vector<T,A> Matrix<T>, std::ClosureOperations::OP_MULT>& c) { const std::vector<T,A>& b = c.v1_; const Matrix<T>& a = c.v2_; const std::vector<T,A>& b = c.r1; const Matrix<T>& a = c.r2; assert(a.n_row()==b.size()); v.resize(a.n_col()); for (SizeType i=0;i<a.n_col();i++) { Loading src/Vector.h +37 −41 Original line number Diff line number Diff line Loading @@ -103,15 +103,11 @@ class ClosureOperator { public: ClosureOperator(const T1& v1,const T2& v2) : v1_(v1),v2_(v2) : r1(v1),r2(v2) {} ClosureOperator(const T1& v1) : v1_(v1),v2_(v1) {} const T1& v1_; const T2& v2_; const T1& r1; const T2& r2; }; template<typename T> Loading Loading @@ -148,8 +144,8 @@ typename PsimagLite::EnableIf<Loki::TypeTraits<T1>::isArith,void>::Type operator<=(vector<T2,A>& v, const ClosureOperator<T1,vector<T2,A>,ClosureOperations::OP_MULT>& c) { v = c.v2_; for (SizeType i=0;i<v.size();i++) v[i] *= c.v1_; v = c.r2; for (SizeType i=0;i<v.size();i++) v[i] *= c.r1; } template<typename T1,typename T2,typename A> Loading @@ -158,8 +154,8 @@ void operator<=(vector<T2,A>& v, ClosureOperator<T2,std::vector<T2,A>,ClosureOperations::OP_MULT>, ClosureOperations::OP_MULT>& c) { v = c.v2_.v2_; T2 tmp = c.v1_*c.v2_.v1_; v = c.r2.r2; T2 tmp = c.r1*c.r2.r1; for (SizeType i=0;i<v.size();i++) v[i] *= tmp; } Loading Loading @@ -190,8 +186,8 @@ template<typename T1,typename T2,typename A> void operator<=(vector<T1,A>& v, const ClosureOperator<vector<T1,A>,vector<T2,A>,ClosureOperations::OP_PLUS>& c) { v.resize(c.v1_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_[i] + c.v2_[i]; v.resize(c.r1.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1[i] + c.r2[i]; } template<typename T1,typename T2,typename A> Loading @@ -200,8 +196,8 @@ void operator<=(vector<T2,A>& v, ClosureOperator<T1,vector<T2,A>, ClosureOperations::OP_MULT>, ClosureOperations::OP_PLUS>& c) { v.resize(c.v1_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_[i] + c.v2_.v1_*c.v2_.v2_[i]; v.resize(c.r1.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1[i] + c.r2.r1*c.r2.r2[i]; } template<typename T1,typename T2,typename A1, typename A2> Loading @@ -211,8 +207,8 @@ void operator<=(vector<T1,A1>& v, vector<T1,A1>, ClosureOperations::OP_PLUS>& c) { v.resize(c.v2_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_.v1_*c.v1_.v2_[i] + c.v2_[i]; v.resize(c.r2.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1.r1*c.r1.r2[i] + c.r2[i]; } template<typename T1,typename T2,typename A> Loading @@ -221,8 +217,8 @@ void operator<=(vector<T2,A>& v, ClosureOperator<vector<T2,A>,vector<T2,A>, ClosureOperations::OP_PLUS>, ClosureOperations::OP_MULT>& c) { v.resize(c.v2_.v2_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_*(c.v2_.v1_[i] + c.v2_.v2_[i]); v.resize(c.r2.r2.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1*(c.r2.r1[i] + c.r2.r2[i]); } template<typename T1,typename T2,typename A> Loading @@ -237,15 +233,15 @@ void operator<=(vector<T2,A>& v, ClosureOperator<T1,vector<T2,A>, ClosureOperations::OP_MULT>, ClosureOperations::OP_PLUS>& c) { v.resize(c.v2_.v2_.size()); T1 m1 = c.v2_.v1_; T1 m2 = c.v1_.v2_.v1_; T1 m3 = c.v1_.v1_.v2_.v1_; T1 m4 = c.v1_.v1_.v1_.v1_; const vector<T2,A>& k1 = c.v2_.v2_; const vector<T2,A>& k2 = c.v1_.v2_.v2_; const vector<T2,A>& k3 = c.v1_.v1_.v2_.v2_; const vector<T2,A>& k4 = c.v1_.v1_.v1_.v2_; v.resize(c.r2.r2.size()); T1 m1 = c.r2.r1; T1 m2 = c.r1.r2.r1; T1 m3 = c.r1.r1.r2.r1; T1 m4 = c.r1.r1.r1.r1; const vector<T2,A>& k1 = c.r2.r2; const vector<T2,A>& k2 = c.r1.r2.r2; const vector<T2,A>& k3 = c.r1.r1.r2.r2; const vector<T2,A>& k4 = c.r1.r1.r1.r2; for (SizeType i=0;i<v.size();i++) v[i] = m1*k1[i] + m2*k2[i] + m3*k3[i] + m4*k4[i]; } Loading @@ -271,8 +267,8 @@ template<typename T,typename A> void operator<=(vector<T,A>& v, const ClosureOperator<vector<T,A>,vector<T,A>,ClosureOperations::OP_MINUS>& c) { v.resize(c.v1_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_[i] - c.v2_[i]; v.resize(c.r1.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1[i] - c.r2[i]; } template<typename T1,typename T2,typename A1, typename A2> Loading @@ -281,8 +277,8 @@ void operator<=(vector<T1,A1>& v, ClosureOperator<T1,vector<T2,A2>, ClosureOperations::OP_MULT>, ClosureOperations::OP_MINUS>& c) { v.resize(c.v1_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_[i] - c.v2_.v1_*c.v2_.v2_[i]; v.resize(c.r1.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1[i] - c.r2.r1*c.r2.r2[i]; } template<typename T1,typename T2,typename A> Loading @@ -291,8 +287,8 @@ void operator<=(vector<T2,A>& v, ClosureOperator<vector<T2,A>,vector<T2,A>, ClosureOperations::OP_MINUS>, ClosureOperations::OP_MULT>& c) { v.resize(c.v2_.v2_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_*(c.v2_.v1_[i] - c.v2_.v2_[i]); v.resize(c.r2.r2.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1*(c.r2.r1[i] - c.r2.r2[i]); } template<typename T1, typename T2, typename A> Loading @@ -304,11 +300,11 @@ void operator<=(vector<T2,A>& v, ClosureOperator<T1,vector<T2,A>, ClosureOperations::OP_MULT>, ClosureOperations::OP_PLUS>& c) { T1 m2 = c.v1_.v2_.v1_; T1 m3 = c.v2_.v1_; const vector<T2,A>& k1 = c.v1_.v1_; const vector<T2,A>& k2 = c.v1_.v2_.v2_; const vector<T2,A>& k3 = c.v2_.v2_; T1 m2 = c.r1.r2.r1; T1 m3 = c.r2.r1; const vector<T2,A>& k1 = c.r1.r1; const vector<T2,A>& k2 = c.r1.r2.r2; const vector<T2,A>& k3 = c.r2.r2; v.resize(k1.size()); for (SizeType i=0;i<v.size();i++) Loading @@ -328,7 +324,7 @@ template<typename T1,typename T2,typename A> vector<T2,A> operator+=(vector<T2,A>& v, const ClosureOperator<T1,vector<T2,A>,ClosureOperations::OP_MULT>& w) { for (SizeType i=0;i<v.size();i++) v[i] += w.v1_*w.v2_[i]; for (SizeType i=0;i<v.size();i++) v[i] += w.r1*w.r2[i]; return v; } Loading @@ -344,7 +340,7 @@ template<typename T1,typename T2,typename A> vector<T2,A> operator-=(vector<T2,A>& v, const ClosureOperator<T1,vector<T2,A>,ClosureOperations::OP_MULT>& w) { for (SizeType i=0;i<v.size();i++) v[i] -= w.v1_*w.v2_[i]; for (SizeType i=0;i<v.size();i++) v[i] -= w.r1*w.r2[i]; return v; } Loading src/Version.h +1 −1 Original line number Diff line number Diff line #ifndef PSIMAGLITE_VERSION #define PSIMAGLITE_VERSION "1.06" #define PSIMAGLITE_VERSION "1.08" #endif Loading
src/CrsMatrix.h +9 −9 Original line number Diff line number Diff line Loading @@ -190,15 +190,15 @@ public: std::ClosureOperations::OP_MULT>& c) { CrsMatrix& x = *this; const CrsMatrix& y = c.v1_; const CrsMatrix& z = c.v2_; const CrsMatrix& y = c.r1; const CrsMatrix& z = c.r2; multiply(x,y,z); } CrsMatrix(const std::ClosureOperator<T,CrsMatrix,std::ClosureOperations::OP_MULT>& c) { *this = c.v2_; this->values_ *= c.v1_; *this = c.r2; this->values_ *= c.r1; } // end all ctors Loading Loading @@ -408,8 +408,8 @@ public: CrsMatrix, std::ClosureOperations::OP_MULT>& c) { *this = c.v2_; this->values_ *= c.v1_; *this = c.r2; this->values_ *= c.r1; return *this; } Loading @@ -421,7 +421,7 @@ public: std::ClosureOperations::OP_MULT>& c) { CrsMatrix s; add(s,c.v2_,c.v1_); add(s,c.r2,c.r1); *this = s; return *this; } Loading @@ -436,9 +436,9 @@ public: std::ClosureOperations::OP_MULT>& c) { CrsMatrix s; multiply(s,c.v1_.v2_,c.v2_); multiply(s,c.r1.r2,c.r2); CrsMatrix s2; add(s2,s,c.v1_.v1_); add(s2,s,c.r1.r1); *this = s2; return *this; } Loading
src/Matrix.h +48 −48 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ public: // ctor closures Matrix(const std::ClosureOperator<Matrix,Matrix,std::ClosureOperations::OP_MULT>& c) { matrixMatrix(c.v1_,c.v2_,1.0); matrixMatrix(c.r1,c.r2,1.0); } template<typename T1> Loading @@ -90,7 +90,7 @@ public: std::ClosureOperations::OP_MULT>& c, typename EnableIf<Loki::TypeTraits<T1>::isArith,int>::Type = 0) { *this = c.v1_.v1_*c.v1_.v2_*c.v2_; *this = c.r1.r1*c.r1.r2*c.r2; } template<typename T1> Loading @@ -99,7 +99,7 @@ public: std::ClosureOperations::OP_MULT>& c, typename EnableIf<Loki::TypeTraits<T1>::isArith,int>::Type = 0) { *this = c.v1_*(c.v2_.v1_+c.v2_.v2_); *this = c.r1*(c.r2.r1+c.r2.r2); } // end all ctors Loading Loading @@ -249,36 +249,36 @@ public: template<typename T1> Matrix& operator+=(const std::ClosureOperator<T1,Matrix,std::ClosureOperations::OP_MULT>& c) { nrow_ = c.v2_.nrow_; ncol_ = c.v2_.ncol_; this->data_ += c.v1_*c.v2_.data_; nrow_ = c.r2.nrow_; ncol_ = c.r2.ncol_; this->data_ += c.r1*c.r2.data_; return *this; } template<typename T1> Matrix& operator+=(const std::ClosureOperator<Matrix,T1,std::ClosureOperations::OP_MULT>& c) { nrow_ = c.v1_.nrow_; ncol_ = c.v1_.ncol_; this->data_ += c.v2_*c.v1_.data_; nrow_ = c.r1.nrow_; ncol_ = c.r1.ncol_; this->data_ += c.r2*c.r1.data_; return *this; } template<typename T1> Matrix& operator=(const std::ClosureOperator<T1,Matrix,std::ClosureOperations::OP_MULT>& c) { nrow_ = c.v2_.nrow_; ncol_ = c.v2_.ncol_; this->data_ <= c.v1_*c.v2_.data_; nrow_ = c.r2.nrow_; ncol_ = c.r2.ncol_; this->data_ <= c.r1*c.r2.data_; return *this; } template<typename T1> Matrix& operator=(const std::ClosureOperator<Matrix,T1,std::ClosureOperations::OP_MULT>& c) { nrow_ = c.v1_.nrow_; ncol_ = c.v1_.ncol_; this->data_ <= c.v2_*c.v1_.data_; nrow_ = c.r1.nrow_; ncol_ = c.r1.ncol_; this->data_ <= c.r2*c.r1.data_; return *this; } Loading @@ -288,7 +288,7 @@ public: Matrix, std::ClosureOperations::OP_MULT>& c) { matrixMatrix(c.v1_.v2_,c.v2_,c.v1_.v1_); matrixMatrix(c.r1.r2,c.r2,c.r1.r1); return *this; } Loading @@ -297,9 +297,9 @@ public: std::ClosureOperator<Matrix,Matrix,std::ClosureOperations::OP_PLUS>, std::ClosureOperations::OP_MULT>& c) { this->nrow_ = c.v2_.v1_.nrow_; this->ncol_ = c.v2_.v1_.ncol_; this->data_ <= c.v1_*(c.v2_.v1_.data_ + c.v2_.v2_.data_); this->nrow_ = c.r2.r1.nrow_; this->ncol_ = c.r2.r1.ncol_; this->data_ <= c.r1*(c.r2.r1.data_ + c.r2.r2.data_); return *this; } Loading @@ -308,31 +308,31 @@ public: std::ClosureOperator<Matrix,Matrix,std::ClosureOperations::OP_MINUS>, std::ClosureOperations::OP_MULT>& c) { this->nrow_ = c.v2_.v1_.nrow_; this->ncol_ = c.v2_.v1_.ncol_; this->data_ <= c.v1_*(c.v2_.v1_.data_ - c.v2_.v2_.data_); this->nrow_ = c.r2.r1.nrow_; this->ncol_ = c.r2.r1.ncol_; this->data_ <= c.r1*(c.r2.r1.data_ - c.r2.r2.data_); return *this; } Matrix& operator= (const std::ClosureOperator<Matrix,Matrix,std::ClosureOperations::OP_PLUS>& c) { nrow_ = c.v1_.nrow_; ncol_ = c.v1_.ncol_; assert(nrow_ == c.v2_.nrow_); assert(ncol_ == c.v2_.ncol_); this->data_ <= c.v1_.data_ + c.v2_.data_; nrow_ = c.r1.nrow_; ncol_ = c.r1.ncol_; assert(nrow_ == c.r2.nrow_); assert(ncol_ == c.r2.ncol_); this->data_ <= c.r1.data_ + c.r2.data_; return *this; } Matrix& operator= (const std::ClosureOperator<Matrix,Matrix,std::ClosureOperations::OP_MINUS>& c) { nrow_ = c.v1_.nrow_; ncol_ = c.v1_.ncol_; assert(nrow_ == c.v2_.nrow_); assert(ncol_ == c.v2_.ncol_); this->data_ <= c.v1_.data_ - c.v2_.data_; nrow_ = c.r1.nrow_; ncol_ = c.r1.ncol_; assert(nrow_ == c.r2.nrow_); assert(ncol_ == c.r2.ncol_); this->data_ <= c.r1.data_ - c.r2.data_; return *this; } Loading @@ -342,11 +342,11 @@ public: std::ClosureOperator<T1,Matrix,std::ClosureOperations::OP_MULT>, std::ClosureOperations::OP_PLUS>& c) { nrow_ = c.v1_.nrow_; ncol_ = c.v1_.ncol_; assert(nrow_ == c.v2_.v2_.nrow_); assert(ncol_ == c.v2_.v2_.ncol_); this->data_ <= c.v1_.data_ + c.v2_.v1_*c.v2_.v2_.data_; nrow_ = c.r1.nrow_; ncol_ = c.r1.ncol_; assert(nrow_ == c.r2.r2.nrow_); assert(ncol_ == c.r2.r2.ncol_); this->data_ <= c.r1.data_ + c.r2.r1*c.r2.r2.data_; return *this; } Loading @@ -357,19 +357,19 @@ public: Matrix, std::ClosureOperations::OP_PLUS>& c) { nrow_ = c.v2_.nrow_; ncol_ = c.v2_.ncol_; assert(nrow_ == c.v1_.v2_.nrow_); assert(ncol_ == c.v1_.v2_.ncol_); this->data_ <= c.v2_.data_ + c.v1_.v1_*c.v1_.v2_.data_; nrow_ = c.r2.nrow_; ncol_ = c.r2.ncol_; assert(nrow_ == c.r1.r2.nrow_); assert(ncol_ == c.r1.r2.ncol_); this->data_ <= c.r2.data_ + c.r1.r1*c.r1.r2.data_; return *this; } Matrix& operator= (const std::ClosureOperator<Matrix<T>,Matrix,std::ClosureOperations::OP_MULT>& c) { const Matrix<T>& a = c.v1_; const Matrix<T>& b = c.v2_; const Matrix<T>& a = c.r1; const Matrix<T>& b = c.r2; matrixMatrix(a,b,1.0); return *this; Loading Loading @@ -650,8 +650,8 @@ void operator<=(std::vector<T,A>& v, const std::ClosureOperator<Matrix<T>, std::vector<T,A>, std::ClosureOperations::OP_MULT>& c) { const std::vector<T,A>& b = c.v2_; const Matrix<T>& a = c.v1_; const std::vector<T,A>& b = c.r2; const Matrix<T>& a = c.r1; assert(a.n_col()==b.size()); v.resize(a.n_row()); for (SizeType i=0;i<a.n_row();i++) { Loading @@ -666,8 +666,8 @@ void operator<=(std::vector<T,A>& v, const std::ClosureOperator<std::vector<T,A> Matrix<T>, std::ClosureOperations::OP_MULT>& c) { const std::vector<T,A>& b = c.v1_; const Matrix<T>& a = c.v2_; const std::vector<T,A>& b = c.r1; const Matrix<T>& a = c.r2; assert(a.n_row()==b.size()); v.resize(a.n_col()); for (SizeType i=0;i<a.n_col();i++) { Loading
src/Vector.h +37 −41 Original line number Diff line number Diff line Loading @@ -103,15 +103,11 @@ class ClosureOperator { public: ClosureOperator(const T1& v1,const T2& v2) : v1_(v1),v2_(v2) : r1(v1),r2(v2) {} ClosureOperator(const T1& v1) : v1_(v1),v2_(v1) {} const T1& v1_; const T2& v2_; const T1& r1; const T2& r2; }; template<typename T> Loading Loading @@ -148,8 +144,8 @@ typename PsimagLite::EnableIf<Loki::TypeTraits<T1>::isArith,void>::Type operator<=(vector<T2,A>& v, const ClosureOperator<T1,vector<T2,A>,ClosureOperations::OP_MULT>& c) { v = c.v2_; for (SizeType i=0;i<v.size();i++) v[i] *= c.v1_; v = c.r2; for (SizeType i=0;i<v.size();i++) v[i] *= c.r1; } template<typename T1,typename T2,typename A> Loading @@ -158,8 +154,8 @@ void operator<=(vector<T2,A>& v, ClosureOperator<T2,std::vector<T2,A>,ClosureOperations::OP_MULT>, ClosureOperations::OP_MULT>& c) { v = c.v2_.v2_; T2 tmp = c.v1_*c.v2_.v1_; v = c.r2.r2; T2 tmp = c.r1*c.r2.r1; for (SizeType i=0;i<v.size();i++) v[i] *= tmp; } Loading Loading @@ -190,8 +186,8 @@ template<typename T1,typename T2,typename A> void operator<=(vector<T1,A>& v, const ClosureOperator<vector<T1,A>,vector<T2,A>,ClosureOperations::OP_PLUS>& c) { v.resize(c.v1_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_[i] + c.v2_[i]; v.resize(c.r1.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1[i] + c.r2[i]; } template<typename T1,typename T2,typename A> Loading @@ -200,8 +196,8 @@ void operator<=(vector<T2,A>& v, ClosureOperator<T1,vector<T2,A>, ClosureOperations::OP_MULT>, ClosureOperations::OP_PLUS>& c) { v.resize(c.v1_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_[i] + c.v2_.v1_*c.v2_.v2_[i]; v.resize(c.r1.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1[i] + c.r2.r1*c.r2.r2[i]; } template<typename T1,typename T2,typename A1, typename A2> Loading @@ -211,8 +207,8 @@ void operator<=(vector<T1,A1>& v, vector<T1,A1>, ClosureOperations::OP_PLUS>& c) { v.resize(c.v2_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_.v1_*c.v1_.v2_[i] + c.v2_[i]; v.resize(c.r2.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1.r1*c.r1.r2[i] + c.r2[i]; } template<typename T1,typename T2,typename A> Loading @@ -221,8 +217,8 @@ void operator<=(vector<T2,A>& v, ClosureOperator<vector<T2,A>,vector<T2,A>, ClosureOperations::OP_PLUS>, ClosureOperations::OP_MULT>& c) { v.resize(c.v2_.v2_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_*(c.v2_.v1_[i] + c.v2_.v2_[i]); v.resize(c.r2.r2.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1*(c.r2.r1[i] + c.r2.r2[i]); } template<typename T1,typename T2,typename A> Loading @@ -237,15 +233,15 @@ void operator<=(vector<T2,A>& v, ClosureOperator<T1,vector<T2,A>, ClosureOperations::OP_MULT>, ClosureOperations::OP_PLUS>& c) { v.resize(c.v2_.v2_.size()); T1 m1 = c.v2_.v1_; T1 m2 = c.v1_.v2_.v1_; T1 m3 = c.v1_.v1_.v2_.v1_; T1 m4 = c.v1_.v1_.v1_.v1_; const vector<T2,A>& k1 = c.v2_.v2_; const vector<T2,A>& k2 = c.v1_.v2_.v2_; const vector<T2,A>& k3 = c.v1_.v1_.v2_.v2_; const vector<T2,A>& k4 = c.v1_.v1_.v1_.v2_; v.resize(c.r2.r2.size()); T1 m1 = c.r2.r1; T1 m2 = c.r1.r2.r1; T1 m3 = c.r1.r1.r2.r1; T1 m4 = c.r1.r1.r1.r1; const vector<T2,A>& k1 = c.r2.r2; const vector<T2,A>& k2 = c.r1.r2.r2; const vector<T2,A>& k3 = c.r1.r1.r2.r2; const vector<T2,A>& k4 = c.r1.r1.r1.r2; for (SizeType i=0;i<v.size();i++) v[i] = m1*k1[i] + m2*k2[i] + m3*k3[i] + m4*k4[i]; } Loading @@ -271,8 +267,8 @@ template<typename T,typename A> void operator<=(vector<T,A>& v, const ClosureOperator<vector<T,A>,vector<T,A>,ClosureOperations::OP_MINUS>& c) { v.resize(c.v1_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_[i] - c.v2_[i]; v.resize(c.r1.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1[i] - c.r2[i]; } template<typename T1,typename T2,typename A1, typename A2> Loading @@ -281,8 +277,8 @@ void operator<=(vector<T1,A1>& v, ClosureOperator<T1,vector<T2,A2>, ClosureOperations::OP_MULT>, ClosureOperations::OP_MINUS>& c) { v.resize(c.v1_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_[i] - c.v2_.v1_*c.v2_.v2_[i]; v.resize(c.r1.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1[i] - c.r2.r1*c.r2.r2[i]; } template<typename T1,typename T2,typename A> Loading @@ -291,8 +287,8 @@ void operator<=(vector<T2,A>& v, ClosureOperator<vector<T2,A>,vector<T2,A>, ClosureOperations::OP_MINUS>, ClosureOperations::OP_MULT>& c) { v.resize(c.v2_.v2_.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.v1_*(c.v2_.v1_[i] - c.v2_.v2_[i]); v.resize(c.r2.r2.size()); for (SizeType i=0;i<v.size();i++) v[i] = c.r1*(c.r2.r1[i] - c.r2.r2[i]); } template<typename T1, typename T2, typename A> Loading @@ -304,11 +300,11 @@ void operator<=(vector<T2,A>& v, ClosureOperator<T1,vector<T2,A>, ClosureOperations::OP_MULT>, ClosureOperations::OP_PLUS>& c) { T1 m2 = c.v1_.v2_.v1_; T1 m3 = c.v2_.v1_; const vector<T2,A>& k1 = c.v1_.v1_; const vector<T2,A>& k2 = c.v1_.v2_.v2_; const vector<T2,A>& k3 = c.v2_.v2_; T1 m2 = c.r1.r2.r1; T1 m3 = c.r2.r1; const vector<T2,A>& k1 = c.r1.r1; const vector<T2,A>& k2 = c.r1.r2.r2; const vector<T2,A>& k3 = c.r2.r2; v.resize(k1.size()); for (SizeType i=0;i<v.size();i++) Loading @@ -328,7 +324,7 @@ template<typename T1,typename T2,typename A> vector<T2,A> operator+=(vector<T2,A>& v, const ClosureOperator<T1,vector<T2,A>,ClosureOperations::OP_MULT>& w) { for (SizeType i=0;i<v.size();i++) v[i] += w.v1_*w.v2_[i]; for (SizeType i=0;i<v.size();i++) v[i] += w.r1*w.r2[i]; return v; } Loading @@ -344,7 +340,7 @@ template<typename T1,typename T2,typename A> vector<T2,A> operator-=(vector<T2,A>& v, const ClosureOperator<T1,vector<T2,A>,ClosureOperations::OP_MULT>& w) { for (SizeType i=0;i<v.size();i++) v[i] -= w.v1_*w.v2_[i]; for (SizeType i=0;i<v.size();i++) v[i] -= w.r1*w.r2[i]; return v; } Loading
src/Version.h +1 −1 Original line number Diff line number Diff line #ifndef PSIMAGLITE_VERSION #define PSIMAGLITE_VERSION "1.06" #define PSIMAGLITE_VERSION "1.08" #endif