CPPLapack
 All Classes Files Functions Variables Friends
dgematrix-dgbmatrix.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! dgematrix+=dgbmatrix operator */
00003 inline dgematrix& dgematrix::operator+=(const dgbmatrix& 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 /*! dgematrix-=dgbmatrix operator */
00025 inline dgematrix& dgematrix::operator-=(const dgbmatrix& 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 //=============================================================================
00046 /*! dgematrix*=dgbmatrix operator */
00047 inline dgematrix& dgematrix::operator*=(const dgbmatrix& mat)
00048 {VERBOSE_REPORT;
00049 #ifdef  CPPL_DEBUG
00050   if(n!=mat.m){
00051     ERROR_REPORT;
00052     std::cerr << "These two matrises can not make a product." << std::endl
00053               << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
00054     exit(1);
00055   }
00056 #endif//CPPL_DEBUG
00057   dgematrix newmat(m,mat.n);
00058   newmat.zero();
00059   
00060   for(long i=0; i<newmat.m; i++){
00061     for(long j=0; j<newmat.n; j++){
00062       for(long k=std::max(long(0),j-mat.ku); k<std::min(mat.m,j+mat.kl+1); k++){
00063         newmat(i,j)+=operator()(i,k)*mat(k,j);
00064       }
00065     }
00066   }
00067   
00068   swap(*this,newmat);
00069   return *this;
00070 }
00071 
00072 ///////////////////////////////////////////////////////////////////////////////
00073 ///////////////////////////////////////////////////////////////////////////////
00074 ///////////////////////////////////////////////////////////////////////////////
00075 
00076 //=============================================================================
00077 /*! dgematrix+dgbmatrix operator */
00078 inline _dgematrix operator+(const dgematrix& matA, const dgbmatrix& matB)
00079 {VERBOSE_REPORT;
00080 #ifdef  CPPL_DEBUG
00081   if(matA.n!=matB.n || matA.m!=matB.m){
00082     ERROR_REPORT;
00083     std::cerr << "These two matrises can not make a summation." << std::endl
00084               << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00085     exit(1);
00086   }
00087 #endif//CPPL_DEBUG
00088   
00089   dgematrix newmat(matA);
00090   
00091   for(long i=0; i<matB.m; i++){
00092     for(long j=std::max(long(0),i-matB.kl); j<std::min(matB.n,i+matB.ku+1); j++){
00093       newmat(i,j)+=matB(i,j);
00094     }
00095   }
00096   
00097   return _(newmat);
00098 }
00099 
00100 //=============================================================================
00101 /*! dgematrix-dgbmatrix operator */
00102 inline _dgematrix operator-(const dgematrix& matA, const dgbmatrix& matB)
00103 {VERBOSE_REPORT;
00104 #ifdef  CPPL_DEBUG
00105   if(matA.n!=matB.n || matA.m!=matB.m){
00106     ERROR_REPORT;
00107     std::cerr << "These two matrises can not make a summation." << std::endl
00108               << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00109     exit(1);
00110   }
00111 #endif//CPPL_DEBUG
00112   
00113   dgematrix newmat(matA);
00114   
00115   for(long i=0; i<matB.m; i++){
00116     for(long j=std::max(long(0),i-matB.kl); j<std::min(matB.n,i+matB.ku+1); j++){
00117       newmat(i,j)-=matB(i,j);
00118     }
00119   }
00120   
00121   return _(newmat);
00122 }
00123 
00124 //=============================================================================
00125 /*! dgematrix*dgbmatrix operator */
00126 inline _dgematrix operator*(const dgematrix& matA, const dgbmatrix& matB)
00127 {VERBOSE_REPORT;
00128 #ifdef  CPPL_DEBUG
00129   if(matA.n!=matB.m){
00130     ERROR_REPORT;
00131     std::cerr << "These two matrises can not make a product." << std::endl
00132               << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
00133     exit(1);
00134   }
00135 #endif//CPPL_DEBUG
00136   
00137   dgematrix newmat( matA.m, matB.n );
00138   newmat.zero();
00139   
00140   for(long i=0; i<newmat.m; i++){
00141     for(long j=0; j<newmat.n; j++){
00142       for(long k=std::max(long(0),j-matB.ku); k<std::min(matB.m,j+matB.kl+1); k++){
00143         newmat(i,j)+=matA(i,k)*matB(k,j);
00144       }
00145     }
00146   }
00147   
00148   return _(newmat);
00149 }
 All Classes Files Functions Variables Friends