//=============================================================================
/*! dgbmatrix+dgematrix operator */
inline _dgematrix operator+(const dgbmatrix& matA, const dgematrix& matB)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator+(const dgbmatrix&, const dgematrix&)"
<< std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if(matA.N!=matB.N || matA.M!=matB.M){
std::cerr << "[ERROR] operator+(dgbmatrix&, dgematrix&)" << 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
dgematrix 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);
}
//=============================================================================
/*! dgbmatrix-dgematrix operator */
inline _dgematrix operator-(const dgbmatrix& matA, const dgematrix& matB)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator-(const dgbmatrix&, const dgematrix&)"
<< std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if(matA.N!=matB.N || matA.M!=matB.M){
std::cerr << "[ERROR] operator+(dgbmatrix&, dgematrix&)" << 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
dgematrix 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);
}
//=============================================================================
/*! dgbmatrix*dgematrix operator */
inline _dgematrix operator*(const dgbmatrix& matA, const dgematrix& matB)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator*(const dgbmatrix&, const dgematrix&)"
<< std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if(matA.N!=matB.M){
std::cerr << "[ERROR] operator*(dgbmatrix&, dgematrix&)" << 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
dgematrix newmat( matA.M, matB.N );
newmat.zero();
long i, j, k;
#pragma omp parallel for private(j,k)
for(i=0; i<newmat.M; i++){
for(j=0; j<newmat.N; j++){
for(k=max(0,i-matA.KL); k<min(matA.N,i+matA.KU+1); k++){
newmat(i,j)+=matA(i,k)*matB(k,j);
}
}
}
return _(newmat);
}