//=============================================================================
/*! zgbmatrix+zhematrix operator */
inline _zgematrix operator+(const zgbmatrix& matA, const zhematrix& matB)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator+(const zgbmatrix&, const zhematrix&)"
<< std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if(matA.N!=matB.N || matA.M!=matB.M){
std::cerr << "[ERROR] operator+(const zgbmatrix&, const zhematrix&)"
<< std::endl
<< "These two matrises can not make a summation." << std::endl
<< "Your input was (" << matA.M << "x" << matA.N << ") + ("
<< matB.M << "x" << matB.N << ")." << std::endl;
exit(1);
}
#endif//CPPL_DEBUG
zgematrix newmat(matB);
for(long i=0; i<matA.M; i++){
for(long j=max(0,i-matA.KL); j<min(matA.N,i+matA.KU+1); j++){
newmat(i,j)+=matA(i,j);
}
}
return _(newmat);
}
//=============================================================================
/*! zgbmatrix-zhematrix operator */
inline _zgematrix operator-(const zgbmatrix& matA, const zhematrix& matB)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator-(const zgbmatrix&, const zhematrix&)"
<< std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if(matA.N!=matB.N || matA.M!=matB.M){
std::cerr << "[ERROR] operator+(const zgbmatrix&, const zhematrix&)"
<< std::endl
<< "These two matrises can not make a summation." << std::endl
<< "Your input was (" << matA.M << "x" << matA.N << ") + ("
<< matB.M << "x" << matB.N << ")." << std::endl;
exit(1);
}
#endif//CPPL_DEBUG
zgematrix newmat(-matB);
for(long i=0; i<matA.M; i++){
for(long j=max(0,i-matA.KL); j<min(matA.N,i+matA.KU+1); j++){
newmat(i,j)-=matA(i,j);
}
}
return _(newmat);
}
//=============================================================================
/*! zgbmatrix*zhematrix operator */
inline _zgematrix operator*(const zgbmatrix& matA, const zhematrix& matB)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator*(const zgbmatrix&, const zhematrix&)"
<< std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if(matA.N!=matB.M){
std::cerr << "[ERROR] operator*(const zgbmatrix&, const zhematrix&)"
<< 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();
for(long c=0; c<matB.VOL; c++){
for(long i=max(0,matB.Indx[c]-(matA.KU+1));
i<min(matA.M,matB.Indx[c]+matA.KL); i++){
newmat(i,matB.Jndx[c]) += matA(i,matB.Indx[c])*matB.Array[c];
}
}
return _(newmat);
}