CPPLapack
 All Classes Files Functions Variables Friends
zgematrix-zgbmatrix.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! zgematrix+=zgbmatrix operator */
00003 inline zgematrix& zgematrix::operator+=(const zgbmatrix& mat)
00004 {VERBOSE_REPORT;
00005 #ifdef  CPPL_DEBUG
00006   if(n!=mat.n || m!=mat.m){
00007     ERROR_REPORT;
00008     std::cerr << "These two matrises can not make a summation." << std::endl
00009               << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
00010     exit(1);
00011   }
00012 #endif//CPPL_DEBUG
00013   
00014   for(long i=0; i<mat.m; i++){
00015     for(long j=std::max(long(0),i-mat.kl); j<std::min(n,i+mat.ku+1); j++){
00016       operator()(i,j)+=mat(i,j);
00017     }
00018   }
00019   
00020   return *this;
00021 }
00022 
00023 //=============================================================================
00024 /*! zgematrix-=zgbmatrix operator */
00025 inline zgematrix& zgematrix::operator-=(const zgbmatrix& mat)
00026 {VERBOSE_REPORT;
00027 #ifdef  CPPL_DEBUG
00028   if(n!=mat.n || m!=mat.m){
00029     ERROR_REPORT;
00030     std::cerr << "These two matrises can not make a subtraction." << std::endl
00031               << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
00032     exit(1);
00033   }
00034 #endif//CPPL_DEBUG
00035   
00036   for(long i=0; i<mat.m; i++){
00037     for(long j=std::max(long(0),i-mat.kl); j<std::min(n,i+mat.ku+1); j++){
00038       operator()(i,j)-=mat(i,j);
00039     }
00040   }
00041   
00042   return *this;
00043 }
00044 //=============================================================================
00045 /*! zgematrix*=zgbmatrix operator */
00046 inline zgematrix& zgematrix::operator*=(const zgbmatrix& mat)
00047 {VERBOSE_REPORT;
00048 #ifdef  CPPL_DEBUG
00049   if(n!=mat.m){
00050     ERROR_REPORT;
00051     std::cerr << "These two matrises can not make a product." << std::endl
00052               << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
00053     exit(1);
00054   }
00055 #endif//CPPL_DEBUG
00056   zgematrix newmat(m,mat.n);
00057   newmat.zero();
00058   
00059   for(long i=0; i<newmat.m; i++){
00060     for(long j=0; j<newmat.n; j++){
00061       for(long k=std::max(long(0),j-mat.ku); k<std::min(mat.m,j+mat.kl+1); k++){
00062         newmat(i,j)+=operator()(i,k)*mat(k,j);
00063       }
00064     }
00065   }
00066   
00067   swap(*this,newmat);
00068   return *this;
00069 }
00070 
00071 ///////////////////////////////////////////////////////////////////////////////
00072 ///////////////////////////////////////////////////////////////////////////////
00073 ///////////////////////////////////////////////////////////////////////////////
00074 
00075 //=============================================================================
00076 /*! zgematrix+zgbmatrix operator */
00077 inline _zgematrix operator+(const zgematrix& matA, const zgbmatrix& matB)
00078 {VERBOSE_REPORT;
00079 #ifdef  CPPL_DEBUG
00080   if(matA.n!=matB.n || matA.m!=matB.m){
00081     ERROR_REPORT;
00082     std::cerr << "These two matrises can not make a summation." << std::endl
00083               << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00084     exit(1);
00085   }
00086 #endif//CPPL_DEBUG
00087   
00088   zgematrix newmat(matA);
00089   
00090   for(long i=0; i<matB.m; i++){
00091     for(long j=std::max(long(0),i-matB.kl); j<std::min(matB.n,i+matB.ku+1); j++){
00092       newmat(i,j)+=matB(i,j);
00093     }
00094   }
00095   
00096   return _(newmat);
00097 }
00098 
00099 //=============================================================================
00100 /*! zgematrix-zgbmatrix operator */
00101 inline _zgematrix operator-(const zgematrix& matA, const zgbmatrix& matB)
00102 {VERBOSE_REPORT;
00103 #ifdef  CPPL_DEBUG
00104   if(matA.n!=matB.n || matA.m!=matB.m){
00105     ERROR_REPORT;
00106     std::cerr << "These two matrises can not make a summation." << std::endl
00107               << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00108     exit(1);
00109   }
00110 #endif//CPPL_DEBUG
00111   
00112   zgematrix newmat(matA);
00113   
00114   for(long i=0; i<matB.m; i++){
00115     for(long j=std::max(long(0),i-matB.kl); j<std::min(matB.n,i+matB.ku+1); j++){
00116       newmat(i,j)-=matB(i,j);
00117     }
00118   }
00119   
00120   return _(newmat);
00121 }
00122 
00123 //=============================================================================
00124 /*! zgematrix*zgbmatrix operator */
00125 inline _zgematrix operator*(const zgematrix& matA, const zgbmatrix& matB)
00126 {VERBOSE_REPORT;
00127 #ifdef  CPPL_DEBUG
00128   if(matA.n!=matB.m){
00129     ERROR_REPORT;
00130     std::cerr << "These two matrises can not make a product." << std::endl
00131               << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
00132     exit(1);
00133   }
00134 #endif//CPPL_DEBUG
00135   
00136   zgematrix newmat( matA.m, matB.n );
00137   newmat.zero();
00138   
00139   for(long i=0; i<newmat.m; i++){
00140     for(long j=0; j<newmat.n; j++){
00141       for(long k=std::max(long(0),j-matB.ku); k<std::min(matB.m,j+matB.kl+1); k++){
00142         newmat(i,j)+=matA(i,k)*matB(k,j);
00143       }
00144     }
00145   }
00146   
00147   return _(newmat);
00148 }
 All Classes Files Functions Variables Friends