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