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