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