//=============================================================================
/*! _dsymatrix+dgbmatrix operator */
inline _dgematrix operator+(const _dsymatrix& matA, const dgbmatrix& matB)
{CPPL_VERBOSE_REPORT;
#ifdef CPPL_DEBUG
if(matA.n!=matB.n || matA.n!=matB.m){
ERROR_REPORT;
std::cerr << "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.n, matA.n);
for(long i=0; i<matB.m; i++){
for(long j=i; j<matA.n; j++){
newmat(i,j) = newmat(j,i) = matA(i,j);
}
const long jmax =std::min(matB.n,i+matB.ku+1);
for(long j=std::max(0l,i-matB.kl); j<jmax; j++){
newmat(i,j)+=matB(i,j);
}
}
matA.destroy();
return _(newmat);
}
//=============================================================================
/*! _dsymatrix-dgbmatrix operator */
inline _dgematrix operator-(const _dsymatrix& matA, const dgbmatrix& matB)
{CPPL_VERBOSE_REPORT;
#ifdef CPPL_DEBUG
if(matA.n!=matB.n || matA.n!=matB.m){
ERROR_REPORT;
std::cerr << "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.n, matA.n);
for(long i=0; i<matB.m; i++){
for(long j=i; j<matA.n; j++){
newmat(i,j) = newmat(j,i) = matA(i,j);
}
const long jmax =std::min(matB.n,i+matB.ku+1);
for(long j=std::max(0l,i-matB.kl); j<jmax; j++){
newmat(i,j)-=matB(i,j);
}
}
matA.destroy();
return _(newmat);
}
//=============================================================================
/*! _dgematrix*dgbmatrix operator */
inline _dgematrix operator*(const _dsymatrix& matA, const dgbmatrix& matB)
{CPPL_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.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(long i=0; i<newmat.m; i++){
for(long j=0; j<newmat.n; j++){
const long kmax =std::min(matB.m,j+matB.kl+1);
for(long k=std::max(0l,j-matB.ku); k<kmax; k++){
newmat(i,j) +=matA(i,k)*matB(k,j);
}
}
}
matA.destroy();
return _(newmat);
}