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   matB.destroy();
00026   return _(newmat);
00027 }
00028 
00029 //=============================================================================
00030 /*! _dsymatrix-_dgbmatrix operator */
00031 inline _dgematrix operator-(const _dsymatrix& matA, const _dgbmatrix& matB)
00032 {VERBOSE_REPORT;
00033 #ifdef  CPPL_DEBUG
00034   if(matA.n!=matB.n || matA.n!=matB.m){
00035     ERROR_REPORT;
00036     std::cerr << "These two matrises can not make a summation." << std::endl
00037               << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00038     exit(1);
00039   }
00040 #endif//CPPL_DEBUG
00041   
00042   dgematrix newmat(matA.n, matA.n);
00043   for(long i=0; i<matB.m; i++){
00044     for(long j=i; j<matA.n; j++){
00045       newmat(i,j) = newmat(j,i) = matA(i,j);
00046     }
00047     for(long j=std::max(long(0),i-matB.kl); j<std::min(matB.n,i+matB.ku+1); j++){
00048       newmat(i,j) -= matB(i,j);
00049     }
00050   }
00051 
00052   matA.destroy();
00053   matB.destroy();
00054   return _(newmat);
00055 }
00056 
00057 //=============================================================================
00058 /*! _dsymatrix*_dgbmatrix operator */
00059 inline _dgematrix operator*(const _dsymatrix& matA, const _dgbmatrix& matB)
00060 {VERBOSE_REPORT;
00061 #ifdef  CPPL_DEBUG
00062   if(matA.n!=matB.m){
00063     ERROR_REPORT;
00064     std::cerr << "These two matrises can not make a product." << std::endl
00065               << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
00066     exit(1);
00067   }
00068 #endif//CPPL_DEBUG
00069   
00070   dgematrix newmat( matA.n, 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),j-matB.ku); k<std::min(matB.m,j+matB.kl+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