//=============================================================================
/*! _dsymatrix+dgsmatrix operator */
inline _dgematrix operator+(const _dsymatrix& matA, const dgsmatrix& matB)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator+(const _dsymatrix&, const dgsmatrix&)" << std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if(matA.N!=matB.M || matA.N!=matB.N){
std::cerr << "[ERROR] operator+(const _dsymatrix&, const dgsmatrix&)" << std::endl
<< "These two matrises can not make a summation." << std::endl
<< "Your input was (" << matA.N << "x" << matA.N << ") + (" << matB.M << "x" << matB.N << ")." << std::endl;
exit(1);
}
#endif//CPPL_DEBUG
dgematrix newmat( matA.to_dgematrix() );
for(std::vector<dcomponent>::const_iterator it=matB.Data.begin(); it!=matB.Data.end(); it++){
newmat(it->i,it->j) += it->v;
}
matA.destroy();
return _(newmat);
}
//=============================================================================
/*! _dsymatrix-dgsmatrix operator */
inline _dgematrix operator-(const _dsymatrix& matA, const dgsmatrix& matB)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator-(const _dsymatrix&, const dgsmatrix&)" << std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if(matA.N!=matB.M || matA.N!=matB.N){
std::cerr << "[ERROR] operator-(const _dsymatrix&, const dgsmatrix&)" << std::endl
<< "These two matrises can not make a subtraction." << std::endl
<< "Your input was (" << matA.N << "x" << matA.N << ") - (" << matB.M << "x" << matB.N << ")." << std::endl;
exit(1);
}
#endif//CPPL_DEBUG
dgematrix newmat( matA.to_dgematrix() );
for(std::vector<dcomponent>::const_iterator it=matB.Data.begin(); it!=matB.Data.end(); it++){
newmat(it->i,it->j) -= it->v;
}
matA.destroy();
return _(newmat);
}
//=============================================================================
/*! _dsymatrix*dgsmatrix operator */
inline _dgematrix operator*(const _dsymatrix& matA, const dgsmatrix& matB)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator*(const _dsymatrix&, const dgsmatrix&)" << std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if(matA.N!=matB.M){
std::cerr << "[ERROR] operator*(const _dsymatrix&, const dgsmatrix&)" << 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
dgematrix newmat(matA.N, matB.N);
newmat.zero();
for(std::vector<dcomponent>::const_iterator it=matB.Data.begin(); it!=matB.Data.end(); it++){
for(long i=0; i<matA.N; i++){
newmat(i,it->j) += matB(i,it->i)*it->v;
}
}
matA.destroy();
return _(newmat);
}