CPPLapack
 All Classes Files Functions Variables Friends
_zgbmatrix-_zssmatrix.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! _zgbmatrix+_zhematrix operator */
00003 inline _zgematrix operator+(const _zgbmatrix& matA, const _zhematrix& 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   zgematrix newmat(matB);
00015   
00016   for(long i=0; i<matA.m; i++){
00017     for(long j=max(0,i-matA.kl); j<min(matA.n,i+matA.ku+1); j++){
00018       newmat(i,j)+=matA(i,j);
00019     }
00020   }
00021   
00022   matA.destroy();
00023   matB.destroy();
00024   return _(newmat);
00025 }
00026 
00027 //=============================================================================
00028 /*! _zgbmatrix-_zhematrix operator */
00029 inline _zgematrix operator-(const _zgbmatrix& matA, const _zhematrix& matB)
00030 {VERBOSE_REPORT;
00031 #ifdef  CPPL_DEBUG
00032   if(matA.n!=matB.n || matA.m!=matB.m){
00033     ERROR_REPORT;
00034     std::cerr << "These two matrises can not make a summation." << std::endl
00035               << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00036     exit(1);
00037   }
00038 #endif//CPPL_DEBUG
00039   
00040   zgematrix newmat(-matB);
00041   
00042   for(long i=0; i<matA.m; i++){
00043     for(long j=max(0,i-matA.kl); j<min(matA.n,i+matA.ku+1); j++){
00044       newmat(i,j)-=matA(i,j);
00045     }
00046   }
00047   
00048   matA.destroy();
00049   matB.destroy();
00050   return _(newmat);
00051 }
00052 
00053 //=============================================================================
00054 /*! _zgbmatrix*_zhematrix operator */
00055 inline _zgematrix operator*(const _zgbmatrix& matA, const _zhematrix& matB)
00056 {VERBOSE_REPORT;
00057 #ifdef  CPPL_DEBUG
00058   if(matA.n!=matB.m){
00059     ERROR_REPORT;
00060     std::cerr << "These two matrises can not make a product." << std::endl
00061               << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
00062     exit(1);
00063   }
00064 #endif//CPPL_DEBUG
00065   
00066   zgematrix newmat( matA.m, matB.n );
00067   newmat.zero();
00068   
00069   for(long c=0; c<matB.vol; c++){
00070     for(long i=max(0,matB.indx[c]-(matA.ku+1));
00071         i<min(matA.m,matB.indx[c]+matA.kl); i++){
00072       newmat(i,matB.jndx[c]) += matA(i,matB.indx[c])*matB.array[c];
00073     }
00074   }
00075   
00076   matA.destroy();
00077   matB.destroy();
00078   return _(newmat);
00079 }
 All Classes Files Functions Variables Friends