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