CPPLapack
 All Classes Files Functions Variables Friends
Functions
_dgematrix-_dgsmatrix.hpp File Reference

Go to the source code of this file.

Functions

_dgematrix operator+ (const _dgematrix &matA, const _dgsmatrix &matB)
_dgematrix operator- (const _dgematrix &matA, const _dgsmatrix &matB)
_dgematrix operator* (const _dgematrix &matA, const _dgsmatrix &matB)

Function Documentation

_dgematrix operator+ ( const _dgematrix matA,
const _dgsmatrix matB 
) [inline]

_dgematrix+_dgsmatrix operator

Definition at line 3 of file _dgematrix-_dgsmatrix.hpp.

References _dgsmatrix::data, _dgsmatrix::destroy(), _dgsmatrix::m, _dgematrix::m, _dgematrix::n, and _dgsmatrix::n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.m!=matB.m || matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "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
  
  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
    matA(it->i,it->j) += it->v;
  }
  
  matB.destroy();
  return matA;
}
_dgematrix operator- ( const _dgematrix matA,
const _dgsmatrix matB 
) [inline]

_dgematrix-_dgsmatrix operator

Definition at line 24 of file _dgematrix-_dgsmatrix.hpp.

References _dgematrix::array, _dgsmatrix::data, _dgsmatrix::destroy(), i(), _dgsmatrix::m, _dgematrix::m, _dgematrix::n, and _dgsmatrix::n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.m!=matB.m || matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a subtraction." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  //// change sign ////
  for(long i=0; i<matA.m*matA.n; i++){
    matA.array[i]=-matA.array[i];
  }
  
  //// add ////
  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
    matA(it->i,it->j) += it->v;
  }
  
  matB.destroy();
  return matA;
}
_dgematrix operator* ( const _dgematrix matA,
const _dgsmatrix matB 
) [inline]

_dgematrix*_dgsmatrix operator

Definition at line 51 of file _dgematrix-_dgsmatrix.hpp.

References _(), _dgsmatrix::data, _dgematrix::destroy(), _dgsmatrix::destroy(), i(), _dgematrix::i, _dgsmatrix::m, _dgematrix::m, _dgematrix::n, _dgsmatrix::n, and dgematrix::zero().

{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.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat(matA.m, matB.n);
  newmat.zero();
  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
    for(long i=0; i<matA.m; i++){
      newmat(i,it->j) += matA(i,it->i)*it->v;
    }
  }
  
  matA.destroy();
  matB.destroy();
  return _(newmat);
}
 All Classes Files Functions Variables Friends