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