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