CPPLapack
 All Classes Files Functions Variables Friends
dsymatrix-_dgsmatrix.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! dsymatrix+_dgsmatrix operator */
00003 inline _dgematrix operator+(const dsymatrix& matA, const _dgsmatrix& matB)
00004 {VERBOSE_REPORT;
00005 #ifdef  CPPL_DEBUG
00006   if(matA.n!=matB.m || 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.n << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00010     exit(1);
00011   }
00012 #endif//CPPL_DEBUG
00013   
00014   dgematrix newmat( matA.to_dgematrix() );
00015   for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
00016     newmat(it->i,it->j) += it->v;
00017   }
00018   
00019   matB.destroy();
00020   return _(newmat);
00021 }
00022 
00023 //=============================================================================
00024 /*! dsymatrix-_dgsmatrix operator */
00025 inline _dgematrix operator-(const dsymatrix& matA, const _dgsmatrix& matB)
00026 {VERBOSE_REPORT;
00027 #ifdef  CPPL_DEBUG
00028   if(matA.n!=matB.m || matA.n!=matB.n){
00029     ERROR_REPORT;
00030     std::cerr << "These two matrises can not make a subtraction." << std::endl
00031               << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
00032     exit(1);
00033   }
00034 #endif//CPPL_DEBUG
00035 
00036   dgematrix newmat( matA.to_dgematrix() );
00037   for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
00038     newmat(it->i,it->j) -= it->v;
00039   }
00040   
00041   matB.destroy();
00042   return _(newmat);
00043 }
00044 
00045 //=============================================================================
00046 /*! dsymatrix*_dgsmatrix operator */
00047 inline _dgematrix operator*(const dsymatrix& matA, const _dgsmatrix& matB)
00048 {VERBOSE_REPORT;
00049 #ifdef  CPPL_DEBUG
00050   if(matA.n!=matB.m){
00051     ERROR_REPORT;
00052     std::cerr << "These two matrises can not make a product." << std::endl
00053               << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
00054     exit(1);
00055   }
00056 #endif//CPPL_DEBUG
00057   
00058   dgematrix newmat(matA.n, matB.n);
00059   newmat.zero();
00060   for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
00061     for(long i=0; i<matA.n; i++){
00062       newmat(i,it->j) += matB(i,it->i)*it->v;
00063     }
00064   }
00065   
00066   matB.destroy();
00067   return _(newmat);
00068 }
 All Classes Files Functions Variables Friends