/*! _dgbmatrix*_dcovector operator */ inline _dcovector operator*(const _dgbmatrix& mat, const _dcovector& vec) { #ifdef CPPL_VERBOSE std::cerr << "# [MARK] operator*(const _dgbmatrix&, const _dcovector&)" << std::endl; #endif//CPPL_VERBOSE #ifdef CPPL_DEBUG if(mat.N!=vec.L){ std::cerr << "[ERROR] operator*(const _dgbmatrix&, const _dcovector&)" << std::endl << "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 dcovector newvec(mat.M); dgbmv_( 'N', mat.M, mat.N, mat.KL, mat.KU, 1.0, mat.Array, mat.KL+mat.KU+1, vec.Array, 1, 0.0, newvec.array, 1 ); mat.destroy(); vec.destroy(); return _(newvec); }
/*! _dssmatrix*_dcovector operator */ inline _dcovector operator*(const _dssmatrix& mat, const _dcovector& 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.n << "x" << mat.n << ") * (" << vec.l << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG dcovector newvec(mat.n); newvec.zero(); for(std::vector<dcomponent>::iterator it=mat.data.begin(); it!=mat.data.end(); it++){ newvec(it->i) +=it->v*vec(it->j); if(it->i!=it->j){ newvec(it->j) +=it->v*vec(it->i); } } mat.destroy(); vec.destroy(); return _(newvec); }
/*! _dcovector*_drovector operator */ inline _dgematrix operator*(const _dcovector& covec, const _drovector& rovec) { #ifdef CPPL_VERBOSE std::cerr << "# [MARK] operator*(const _dcovector&, const _drovector&)" << std::endl; #endif//CPPL_VERBOSE #ifdef CPPL_DEBUG if(covec.L!=rovec.L){ std::cerr << "[ERROR] operator*(const dcovector&, const drovector&)" << std::endl << "These two vectors can not make a product." << std::endl << "Your input was (" << covec.L << ") * (" << rovec.L << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG dgematrix newmat(covec.L, covec.L); for(long i=0; i<newmat.m; i++){ for(long j=0; j<newmat.n; j++){ newmat(i,j) =covec(i)*rovec(j); } } covec.destroy(); rovec.destroy(); return _(newmat); }
/*! dcovector constructor to cast _dcovector */ inline dcovector::dcovector(const _dcovector& vec) {VERBOSE_REPORT; //////// initialize //////// l =vec.l; cap =vec.cap; array =vec.array; vec.nullify(); }
/*! return a transposed row vector */ inline drovector t(const _dcovector& covec) { VERBOSE_REPORT; _drovector rovec; rovec.l =covec.l; rovec.cap =covec.cap; delete [] rovec.array; rovec.array =covec.array; covec.nullify(); return rovec; }
/*! dcovector^T*dcovector operator (inner product) */ inline double operator%(const dcovector& vecA, const _dcovector& vecB) {VERBOSE_REPORT; #ifdef CPPL_DEBUG if(vecA.l!=vecB.l){ ERROR_REPORT; std::cerr << "These two vectors can not make a dot product." << std::endl << "Your input was (" << vecA.l << ") % (" << vecB.l << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG double val( ddot_( vecA.l, vecA.array, 1, vecB.array, 1 ) ); vecB.destroy(); return val; }
/*! dgematrix*_dcovector operator */ inline _dcovector operator*(const dgematrix& mat, const _dcovector& 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 dcovector newvec(mat.m); dgemv_( 'n', mat.m, mat.n, 1.0, mat.array, mat.m, vec.array, 1, 0.0, newvec.array, 1 ); vec.destroy(); return _(newvec); }
/*! return its largest absolute value */ inline double damax(const _dcovector& vec) { VERBOSE_REPORT; double val( vec.array[idamax_(vec.l, vec.array, 1)-1] ); vec.destroy(); return val; }
/*! return the index of element having the largest absolute value in 0-based numbering system */ inline long idamax(const _dcovector& vec) { VERBOSE_REPORT; long i( idamax_(vec.l, vec.array, 1) -1 ); vec.destroy(); return i; }
/*! return its Euclidean norm */ inline double nrm2(const _dcovector& vec) { VERBOSE_REPORT; double val( dnrm2_(vec.l, vec.array, 1) ); vec.destroy(); return val; }