//=============================================================================
/*! _zssmatrix+zgbmatrix operator */
inline _zgematrix operator+(const _zssmatrix& matA, const zgbmatrix& matB)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator+(const _zssmatrix&, const zgbmatrix&)"
<< std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if(matA.N!=matB.N || matA.M!=matB.M){
std::cerr << "[ERROR] operator+(const _zssmatrix&, const zgbmatrix&)"
<< 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(matA);
for(long i=0; i<matB.M; i++){
for(long j=max(0,i-matB.KL); j<min(matB.N,i+matB.KU+1); j++){
newmat(i,j)+=matB(i,j);
}
}
matA.destroy();
return _(newmat);
}
//=============================================================================
/*! _zssmatrix-zgbmatrix operator */
inline _zgematrix operator-(const _zssmatrix& matA, const zgbmatrix& matB)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator-(const _zssmatrix&, const zgbmatrix&)"
<< std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if(matA.N!=matB.N || matA.M!=matB.M){
std::cerr << "[ERROR] operator+(const _zssmatrix&, const zgbmatrix&)"
<< 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(matA);
for(long i=0; i<matB.M; i++){
for(long j=max(0,i-matB.KL); j<min(matB.N,i+matB.KU+1); j++){
newmat(i,j)-=matB(i,j);
}
}
matA.destroy();
return _(newmat);
}
//=============================================================================
/*! _zssmatrix*zgbmatrix operator */
inline _zgematrix operator*(const _zssmatrix& matA, const zgbmatrix& matB)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator*(const _zssmatrix&, const zgbmatrix&)"
<< std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if(matA.N!=matB.M){
std::cerr << "[ERROR] operator*(const _zssmatrix&, const zgbmatrix&)"
<< 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<matA.VOL; c++){
for(long k=max(0,matA.Jndx[c]-matB.KU);
k<min(matB.M,matA.Jndx[c]+matB.KL+1); k++){
newmat(matA.Indx[c],k) += matA.Array[c]*matB(matA.Jndx[c],k);
}
}
matA.destroy();
return _(newmat);
}