//=============================================================================
/*! 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;
}
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;
}
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;
}
}
return _(newmat);
}