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