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