//=============================================================================
/*! 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.N){
std::cerr << "[ERROR] operator+(zgbmatrix&, zhematrix&)" << std::endl
<< "These two matrises can not make a summation." << std::endl
<< "Your input was (" << matA.M << "x" << matA.N << ") + ("
<< matB.N << "x" << matB.N << ")." << std::endl;
exit(1);
}
#endif//CPPL_DEBUG
zgematrix newmat(matB.N,matB.N);
for(long i=0; i<matA.M; i++){
for(long j=0; j<matB.N; j++){
newmat(i,j) =matB(i,j);
}
for(long j=std::max(long(0),i-matA.KL); j<std::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.N){
std::cerr << "[ERROR] operator+(zgbmatrix&, zhematrix&)" << std::endl
<< "These two matrises can not make a summation." << std::endl
<< "Your input was (" << matA.M << "x" << matA.N << ") + ("
<< matB.N << "x" << matB.N << ")." << std::endl;
exit(1);
}
#endif//CPPL_DEBUG
zgematrix newmat(matB.N,matB.N);
for(long i=0; i<matA.M; i++){
for(long j=0; j<matB.N; j++){
newmat(i,j) =-matB(i,j);
}
for(long j=std::max(long(0),i-matA.KL); j<std::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){
std::cerr << "[ERROR] operator*(zgbmatrix&, zhematrix&)" << std::endl
<< "These two matrises can not make a product." << std::endl
<< "Your input was (" << matA.M << "x" << matA.N << ") * ("
<< matB.N << "x" << matB.N << ")." << std::endl;
exit(1);
}
#endif//CPPL_DEBUG
zgematrix newmat( matA.M, matB.N );
newmat.zero();
for(long i=0; i<newmat.m; i++){
for(long j=0; j<newmat.n; j++){
for(long k=std::max(long(0),i-matA.KL); k<std::min(matA.N,i+matA.KU+1); k++){
newmat(i,j)+=matA(i,k)*matB(k,j);
}
}
}
return _(newmat);
}