CPPLapack
 All Classes Files Functions Variables Friends
_dgbmatrix-_dgsmatrix.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! _dgbmatrix+_dgsmatrix operator */
00003 inline _dgematrix operator+(const _dgbmatrix& matA, const _dgsmatrix& matB)
00004 {VERBOSE_REPORT;
00005 #ifdef  CPPL_DEBUG
00006   if(matA.n!=matB.n || matA.m!=matB.m){
00007     ERROR_REPORT;
00008     std::cerr << "These two matrises can not make a summation." << std::endl
00009               << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00010     exit(1);
00011   }
00012 #endif//CPPL_DEBUG
00013   
00014   dgematrix newmat( matB.to_dgematrix() );
00015   for(long i=0; i<matA.m; i++){
00016     for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
00017       newmat(i,j)+=matA(i,j);
00018     }
00019   }
00020   
00021   matA.destroy();
00022   matB.destroy();
00023   return _(newmat);
00024 }
00025 
00026 //=============================================================================
00027 /*! _dgbmatrix-_dgsmatrix operator */
00028 inline _dgematrix operator-(const _dgbmatrix& matA, const _dgsmatrix& matB)
00029 {VERBOSE_REPORT;
00030 #ifdef  CPPL_DEBUG
00031   if(matA.n!=matB.n || matA.m!=matB.m){
00032     ERROR_REPORT;
00033     std::cerr << "These two matrises can not make a summation." << std::endl
00034               << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00035     exit(1);
00036   }
00037 #endif//CPPL_DEBUG
00038   
00039   dgematrix newmat( (-matB).to_dgematrix() );
00040   for(long i=0; i<matA.m; i++){
00041     for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
00042       newmat(i,j)-=matA(i,j);
00043     }
00044   }
00045   
00046   matA.destroy();
00047   matB.destroy();
00048   return _(newmat);
00049 }
00050 
00051 //=============================================================================
00052 /*! _dgbmatrix*_dgsmatrix operator */
00053 inline _dgematrix operator*(const _dgbmatrix& matA, const _dgsmatrix& matB)
00054 {VERBOSE_REPORT;
00055 #ifdef  CPPL_DEBUG
00056   if(matA.n!=matB.m){
00057     ERROR_REPORT;
00058     std::cerr << "These two matrises can not make a product." << std::endl
00059               << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
00060     exit(1);
00061   }
00062 #endif//CPPL_DEBUG
00063   
00064   dgematrix newmat( matA.m, matB.n );
00065   newmat.zero();
00066   for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
00067     for(long i=std::max(long(0),long(it->i)-(matA.ku+1)); i<std::min(matA.m,long(it->i)+matA.kl); i++){
00068       newmat(i,it->j) += matA(i,it->i)*it->v;
00069     }
00070   }
00071   
00072   matA.destroy();
00073   matB.destroy();
00074   return _(newmat);
00075 }
 All Classes Files Functions Variables Friends