diff --git a/mat.cc b/mat.cc index e467085..f393596 100644 --- a/mat.cc +++ b/mat.cc @@ -913,24 +913,6 @@ NRMat< complex >::operator*(const NRSMat< complex > &rhs) const -// sum of rows -template<> -const NRVec NRMat::rsum() const -{ - NRVec result(mm); - for (int i=0; i -const NRVec NRMat::csum() const -{ - NRVec result(nn); - for (int i=0; i NRMat &NRMat::conjugateme() {return *this;} @@ -1082,37 +1064,24 @@ void NRMat< complex >::axpy(const complex alpha, // trace of Mat -template<> -const double NRMat::trace() const +template +const T NRMat::trace() const { #ifdef DEBUG if (nn != mm) laerror("no-square matrix in Mat::trace()"); #endif - return cblas_dasum(nn, (*this)[0], nn+1); - - -} - - - -template<> -const complex NRMat< complex >::trace() const -{ -#ifdef DEBUG - if (nn != mm) laerror("no-square matrix in Mat::trace()"); -#endif - register complex sum = CZERO; - for (int i=0; i diff --git a/vec.h b/vec.h index 33c4d86..4a61365 100644 --- a/vec.h +++ b/vec.h @@ -103,7 +103,8 @@ public: const NRVec operator*(const NRSMat &mat) const {NRVec result(mat.ncols()); result.gemv((T)0,mat,'t',(T)1,*this); return result;}; const NRVec operator*(const SparseMat &mat) const {NRVec result(mat.ncols()); result.gemv((T)0,mat,'t',(T)1,*this); return result;}; const NRMat operator|(const NRVec &rhs) const; - inline const T sum() const; //sum of its elements + inline const T sum() const {T sum=0; for(int i=0; i::operator*(const NRVec &rhs) const // Sum of elements template<> -inline const double NRVec::sum() const +inline const double NRVec::asum() const { return cblas_dasum(nn, v, 1); } -template<> -inline const complex -NRVec< complex >::sum() const -{ - complex sum = CZERO; - for (int i=0; i