/*! zssmatrix*_zgematrix operator */ inline _zgematrix operator*(const zssmatrix& matA, const _zgematrix& matB) { #ifdef CPPL_VERBOSE std::cerr << "# [MARK] operator*(const zssmatrix&, const _zgematrix&)" << std::endl; #endif//CPPL_VERBOSE #ifdef CPPL_DEBUG if(matA.N!=matB.M){ std::cerr << "[ERROR] operator*(const zssmatrix&, const _zgematrix&)" << std::endl << "These two matrises can not make a product." << std::endl << "Your input was (" << matA.M << "x" << matA.N << ") * (" << matB.N << "x" << matB.N << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG zgematrix newmat(matA.M, matB.N); newmat.zero(); for(long c=0; c<matA.VOL; c++){ for(long j=0; j<matB.N; j++){ newmat(matA.Indx[c],j) += matA.Array[c]*matB(matA.Jndx[c],j); } } matB.destroy(); return _(newmat); }
/*! _zgematrix*zgbmatrix operator */ inline _zgematrix operator*(const _zgematrix& matA, const zgbmatrix& matB) { #ifdef CPPL_VERBOSE std::cerr << "# [MARK] operator*(const _zgematrix&, const zgbmatrix&)" << std::endl; #endif//CPPL_VERBOSE #ifdef CPPL_DEBUG if(matA.N!=matB.M){ std::cerr << "[ERROR] operator*(_zgematrix&, zgbmatrix&)" << std::endl << "These two matrises can not make a product." << std::endl << "Your input was (" << matA.M << "x" << matA.N << ") * (" << matB.M << "x" << matB.N << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG zgematrix newmat( matA.M, matB.N ); newmat.zero(); long i, j, k; #pragma omp parallel for private(j,k) for(i=0; i<newmat.m; i++){ for(j=0; j<newmat.n; j++){ for(k=max(0,j-matB.KU); k<min(matB.M,j+matB.KL+1); k++){ newmat(i,j)+=matA(i,k)*matB(k,j); } } } matA.destroy(); return _(newmat); }
/*! _zgematrix*zgematrix operator */ inline _zgematrix operator*(const zhematrix& matA, const _zgematrix& matB) { #ifdef CPPL_VERBOSE std::cerr << "# [MARK] operator*(const zhematrix&, const _zgematrix&)" << std::endl; #endif//CPPL_VERBOSE #ifdef CPPL_DEBUG if(matA.N!=matB.M){ std::cerr << "[ERROR] operator*(zhematrix&, _zgematrix&)" << std::endl << "These two matrises can not make a product." << std::endl << "Your input was (" << matA.N << "x" << matA.N << ") * (" << matB.M << "x" << matB.N << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG zgematrix newmat( matA.N, matB.N ); zhemm_( 'L', 'L', matA.N, matB.N, std::complex<double>(1.0,0.0), matA.Array, matA.N, matB.Array, matB.M, std::complex<double>(0.0,0.0), newmat.array, newmat.m ); matB.destroy(); return _(newmat); }
/*! _zgematrix*_zgbmatrix operator */ inline _zgematrix operator*(const _zgematrix& matA, const _zgbmatrix& matB) {VERBOSE_REPORT; #ifdef CPPL_DEBUG if(matA.n!=matB.m){ ERROR_REPORT; std::cerr << "These two matrises can not make a product." << std::endl << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG zgematrix newmat( matA.m, matB.n ); newmat.zero(); for(long i=0; i<newmat.m; i++){ for(long j=0; j<newmat.n; j++){ for(long k=std::max(long(0),j-matB.ku); k<std::min(matB.m,j+matB.kl+1); k++){ newmat(i,j)+=matA(i,k)*matB(k,j); } } } matA.destroy(); matB.destroy(); return _(newmat); }
/*! return its largest absolute value */ inline comple damax(const _zgematrix& mat) {VERBOSE_REPORT; comple val( mat.array[izamax_(mat.m*mat.n, mat.array, 1) -1] ); mat.destroy(); return val; }
/*! search the index of element having the largest absolute value in 0-based numbering system */ inline void idamax(long& i, long& j, const _zgematrix& mat) {VERBOSE_REPORT; long index( izamax_(mat.m*mat.n, mat.array, 1) -1 ); i =index%mat.m; j =index/mat.m; mat.destroy(); }
/*! return its conjugate transposed matrix */ inline _zgematrix conjt(const _zgematrix& mat) {VERBOSE_REPORT; zgematrix newmat(mat.n,mat.m); for(long i=0; i<newmat.m; i++){ for(long j=0; j<newmat.n; j++){ newmat(i,j) =std::conj(mat(j,i)); } } mat.destroy(); return _(newmat); }
/*! _zgematrix*zcovector operator */ inline _zcovector operator*(const _zgematrix& mat, const zcovector& vec) {VERBOSE_REPORT; #ifdef CPPL_DEBUG if(mat.n!=vec.l){ ERROR_REPORT; std::cerr << "These matrix and vector can not make a product." << std::endl << "Your input was (" << mat.m << "x" << mat.n << ") * (" << vec.l << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG zcovector newvec(mat.m); zgemv_( 'n', mat.m, mat.n, comple(1.0,0.0), mat.array, mat.m, vec.array, 1, comple(0.0,0.0), newvec.array, 1 ); mat.destroy(); return _(newvec); }
/*! zgematrix*_zgematrix operator */ inline _zgematrix operator*(const zgematrix& matA, const _zgematrix& matB) {VERBOSE_REPORT; #ifdef CPPL_DEBUG if(matA.n!=matB.m){ ERROR_REPORT; std::cerr << "These two matrises can not make a product." << std::endl << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG zgematrix newmat( matA.m, matB.n ); zgemm_( 'n', 'n', matA.m, matB.n, matA.n, comple(1.0,0.0), matA.array, matA.m, matB.array, matB.m, comple(0.0,0.0), newmat.array, matA.m ); matB.destroy(); return _(newmat); }
/*! _zgematrix*zhematrix operator */ inline _zgematrix operator*(const _zgematrix& matA, const zhematrix& matB) {VERBOSE_REPORT; #ifdef CPPL_DEBUG if(matA.n!=matB.m){ ERROR_REPORT; std::cerr << "These two matrises can not make a product." << std::endl << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG zgematrix newmat(matA.m, matB.n); newmat.zero(); for(long c=0; c<matB.vol; c++){ for(long i=0; i<matA.m; i++){ newmat(i,matB.jndx[c]) += matA(i,matB.indx[c])*matB.array[c]; } } matA.destroy(); return _(newmat); }