CPPLapack
 All Classes Files Functions Variables Friends
zgematrix-zgsmatrix.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! zgematrix+zgsmatrix operator */
00003 inline _zgematrix operator+(const zgematrix& matA, const zgsmatrix& 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   zgematrix newmat(matA);
00015   for(size_t c=0; c<matB.data.size(); c++){
00016     const zcomponent& z =matB.data[c];
00017     newmat(z.i,z.j) += z.v;
00018   }
00019   
00020   return _(newmat);
00021 }
00022 
00023 //=============================================================================
00024 /*! zgematrix-zgsmatrix operator */
00025 inline _zgematrix operator-(const zgematrix& matA, const zgsmatrix& matB)
00026 {VERBOSE_REPORT;
00027 #ifdef  CPPL_DEBUG
00028   if(matA.m!=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.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
00032     exit(1);
00033   }
00034 #endif//CPPL_DEBUG
00035 
00036   zgematrix newmat(matA);
00037   for(size_t c=0; c<matB.data.size(); c++){
00038     const zcomponent& z =matB.data[c];
00039     newmat(z.i,z.j) -= z.v;
00040   }
00041   
00042   return _(newmat);
00043 }
00044 
00045 //=============================================================================
00046 /*! zgematrix*zgsmatrix operator */
00047 inline _zgematrix operator*(const zgematrix& matA, const zgsmatrix& 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.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
00054     exit(1);
00055   }
00056 #endif//CPPL_DEBUG
00057   
00058   zgematrix newmat(matA.m, matB.n);
00059   newmat.zero();
00060   
00061   for(size_t c=0; c<matB.data.size(); c++){
00062     const zcomponent& z =matB.data[c];
00063     for(long i=0; i<matA.m; i++){
00064       newmat(i,z.j) += matA(i,z.i)*z.v;
00065     }
00066   }
00067   
00068   return _(newmat);
00069 }
 All Classes Files Functions Variables Friends