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