diff --git a/fourindex.h b/fourindex.h index e3dd4ff..ff87971 100644 --- a/fourindex.h +++ b/fourindex.h @@ -619,6 +619,11 @@ fourindex_dense::fourindex_dense::iterator p; +#ifdef DEBUG +unsigned long I = SMat_index_1(p->index.indiv.i,p->index.indiv.j); +unsigned long J = SMat_index_1(p->index.indiv.k,p->index.indiv.l); +if (I<0 || I>=(unsigned long)NRSMat::nn || J<0 || J>=(unsigned long)NRSMat::nn) laerror("fourindex_dense index out of range in constructor"); +#endif for(p=rhs.begin(); p!= rhs.end(); ++p) (*this)(p->index.indiv.i,p->index.indiv.j,p->index.indiv.k,p->index.indiv.l) = p->elem; } @@ -627,8 +632,12 @@ fourindex_dense::fourindex_dense::iterator p; -for(p=rhs.begin(); p!= rhs.end(); ++p) (*this)(p->index.indiv.i,p->index.indiv.j -,p->index.indiv.k,p->index.indiv.l) = p->elem; +#ifdef DEBUG +unsigned long I = SMat_index_1(p->index.indiv.i,p->index.indiv.j); +unsigned long J = SMat_index_1(p->index.indiv.k,p->index.indiv.l); +if (I<0 || I>=(unsigned long)NRSMat::nn || J<0 || J>=(unsigned long)NRSMat::nn) laerror("fourindex_dense index out of range in constructor"); +#endif +for(p=rhs.begin(); p!= rhs.end(); ++p) (*this)(p->index.indiv.i,p->index.indiv.j ,p->index.indiv.k,p->index.indiv.l) = p->elem; } diff --git a/la_traits.h b/la_traits.h index 2ebd4ca..24651ba 100644 --- a/la_traits.h +++ b/la_traits.h @@ -21,9 +21,6 @@ extern "C" { } #endif -#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT -# define export -#endif //forward declarations template class NRVec; diff --git a/laerror.cc b/laerror.cc index 977097e..da5dfe8 100644 --- a/laerror.cc +++ b/laerror.cc @@ -3,6 +3,8 @@ #include "laerror.h" #include #include +#include + #ifdef USE_TRACEBACK #include "traceback.h" @@ -30,7 +32,7 @@ void laerror(const char *s1) //stub for f77 blas called from strassen routine extern "C" void xerbla_(const char name[6], int *n) { -char msg[128]; +char msg[1024]; strcpy(msg,"LAPACK or BLAS error in routine "); strncat(msg,name,6); sprintf(msg+strlen(msg),": illegal value of parameter #%d",*n); @@ -38,3 +40,30 @@ laerror(msg); } +//with atlas-cblas another error routine is necessary + +extern "C" void ATL_xerbla(int p, char *rout, char *form, ...) +{ + char msg0[1024], *msg; + va_list argptr; + va_start(argptr, form); + strcpy(msg0,"ATLAS error\n"); + msg=msg0+strlen(msg0); + if (p) {sprintf(msg, "Parameter %d to routine %s was incorrect\n", p, rout); msg+=strlen(msg);} + vsprintf(msg, form, argptr); + va_end(argptr); + laerror(msg0); +} + +int cblas_errprn(int ierr, int info, char *form, ...) +{ + char msg0[1024], *msg; + va_list argptr; + va_start(argptr, form); + sprintf(msg0,"CBLAS error %d %d\n",ierr,info); + msg=msg0+strlen(msg0); + vsprintf(msg, form, argptr); + va_end(argptr); + laerror(msg0); +return 0; +} diff --git a/mat.cc b/mat.cc index 04e7f52..1951229 100644 --- a/mat.cc +++ b/mat.cc @@ -779,8 +779,8 @@ void NRMat< complex >::diagmultr(const NRVec< complex > &rhs) -#ifdef oldversion // Mat * Smat, decomposed to nn x Vec * Smat +//NOTE: dsymm is not appropriate as it works on UNPACKED symmetric matrix template<> const NRMat NRMat::operator*(const NRSMat &rhs) const @@ -811,36 +811,6 @@ NRMat< complex >::operator*(const NRSMat< complex > &rhs) const return result; } -#else - -// Mat * Smat -template<> -const NRMat -NRMat::operator*(const NRSMat &rhs) const -{ -#ifdef DEBUG - if (mm != rhs.nrows()) laerror("incompatible dimension in Mat*SMat"); -#endif - NRMat result(nn, rhs.ncols()); - cblas_dsymm(CblasRowMajor, CblasRight, CblasLower, nn, mm, 1., &rhs[0],mm,(*this)[0],mm,0.,result[0],mm); - return result; -} - -template<> -const NRMat< complex > -NRMat< complex >::operator*(const NRSMat< complex > &rhs) const -{ -#ifdef DEBUG - if (mm != rhs.nrows()) laerror("incompatible dimension in Mat*SMat"); -#endif - NRMat< complex > result(nn, rhs.ncols()); - cblas_zhemm(CblasRowMajor, CblasRight, CblasLower, nn, mm, (void *)&CONE, &rhs[0],mm,(*this)[0],mm,(void *)&CZERO,result[0],mm); - return result; -} - - - -#endif // sum of rows diff --git a/noncblas.cc b/noncblas.cc index de8e3a3..ccb6954 100644 --- a/noncblas.cc +++ b/noncblas.cc @@ -222,4 +222,5 @@ for(int i=1; i::multiget(NN2,fd,v,dim); template NRSMat::NRSMat(const NRMat &rhs) { +nn=rhs.nrows(); #ifdef DEBUG if (nn != rhs.ncols()) laerror("attempt to convert non-square Mat to SMat"); #endif @@ -148,8 +149,10 @@ void NRSMat::fscanf(FILE *f, const char *format) * BLAS specializations for double and complex */ -#ifdef oldversion + + // SMat * Mat +//NOTE: dsymm is not appropriate as it works on UNPACKED symmetric matrix template<> const NRMat NRSMat::operator*(const NRMat &rhs) const { @@ -178,35 +181,6 @@ NRSMat< complex >::operator*(const NRMat< complex > &rhs) const return result; } -#else - -// SMat * Mat -template<> -const NRMat NRSMat::operator*(const NRMat &rhs) const -{ -#ifdef DEBUG - if (nn != rhs.nrows()) laerror("incompatible dimensions in SMat*Mat"); -#endif - NRMat result(nn, rhs.ncols()); - cblas_dsymm(CblasRowMajor, CblasLeft, CblasLower, nn, rhs.ncols(), 1., (*this),nn, rhs[0],rhs.ncols(), 0.,result[0],rhs.ncols()); - return result; -} - - -template<> -const NRMat< complex > -NRSMat< complex >::operator*(const NRMat< complex > &rhs) const -{ -#ifdef DEBUG - if (nn != rhs.nrows()) laerror("incompatible dimensions in SMat*Mat"); -#endif - NRMat< complex > result(nn, rhs.ncols()); - cblas_zhemm(CblasRowMajor, CblasLeft, CblasLower, nn, rhs.ncols(), &CONE, (*this),nn, rhs[0],rhs.ncols(), &CZERO,result[0],rhs.ncols()); - return result; -} - - -#endif // SMat * SMat diff --git a/sparsemat.cc b/sparsemat.cc index ede2dad..8a12b79 100644 --- a/sparsemat.cc +++ b/sparsemat.cc @@ -1309,7 +1309,6 @@ return *this; } -#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT #define INSTANTIZE(T) \ template SparseMat & SparseMat::oplusequal(const SparseMat &rhs);\ @@ -1363,4 +1362,3 @@ INSTANTIZE(double) INSTANTIZE(complex) //some functions are not OK for hermitean matrices, needs a revision!!! -#endif diff --git a/t.cc b/t.cc index 66569c5..9cdce7e 100644 --- a/t.cc +++ b/t.cc @@ -1105,7 +1105,7 @@ for(int iter=1; iter<100 && norm>1e-8 ; ++iter) } } -if(1) +if(0) { NRMat a,b; cin >>a; @@ -1115,5 +1115,14 @@ cout < a; +NRMat b; +cin >>a>>b; +cout <