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& zgsmatrix::operator=(const _zgsmatrix& mat)
00004 {VERBOSE_REPORT;
00005   shallow_copy(mat);
00006   return *this;
00007 }
00008 
00009 ///////////////////////////////////////////////////////////////////////////////
00010 ///////////////////////////////////////////////////////////////////////////////
00011 ///////////////////////////////////////////////////////////////////////////////
00012 
00013 //=============================================================================
00014 /*! zgsmatrix+=_zgsmatrix operator */
00015 inline zgsmatrix& zgsmatrix::operator+=(const _zgsmatrix& mat)
00016 {VERBOSE_REPORT;
00017 #ifdef  CPPL_DEBUG
00018   if(n!=mat.n || m!=mat.m){
00019     ERROR_REPORT;
00020     std::cerr << "These two matrises can not make a summation." << std::endl
00021               << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
00022     exit(1);
00023   }
00024 #endif//CPPL_DEBUG
00025   
00026   for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
00027     (*this)(it->i,it->j) += it->v;
00028   }
00029   mat.destroy();
00030   return *this;
00031 }
00032 
00033 //=============================================================================
00034 /*! zgsmatrix-=_zgsmatrix operator */
00035 inline zgsmatrix& zgsmatrix::operator-=(const _zgsmatrix& mat)
00036 {VERBOSE_REPORT;
00037 #ifdef  CPPL_DEBUG
00038   if(n!=mat.n || m!=mat.m){
00039     ERROR_REPORT;
00040     std::cerr << "These two matrises can not make a sutraction." << std::endl
00041               << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
00042     exit(1);
00043   }
00044 #endif//CPPL_DEBUG
00045   
00046   for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
00047     (*this)(it->i,it->j) -= it->v;
00048   }
00049   mat.destroy();
00050   return *this;
00051 }
00052 
00053 //=============================================================================
00054 /*! zgsmatrix*=_zgsmatrix operator */
00055 inline zgsmatrix& zgsmatrix::operator*=(const _zgsmatrix& mat)
00056 {VERBOSE_REPORT;
00057 #ifdef  CPPL_DEBUG
00058   if(n!=mat.m){
00059     ERROR_REPORT;
00060     std::cerr << "These two matrises can not make a product." << std::endl
00061               << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
00062     exit(1);
00063   }
00064 #endif//CPPL_DEBUG
00065   
00066   zgsmatrix newmat( m, mat.n, 0 );
00067 
00068   for(std::vector<zcomponent>::const_iterator it=data.begin(); it!=data.end(); it++){
00069     long k(it->j);
00070     std::vector<uint32_t>::iterator p;
00071     for(p=mat.rows[k].begin(); p!=mat.rows[k].end(); p++){
00072       newmat(it->i,mat.data[*p].j) += it->v*mat.data[*p].v;
00073     }
00074   }
00075   
00076   swap(*this,newmat);
00077   mat.destroy();
00078   return *this;
00079 }
00080 
00081 ///////////////////////////////////////////////////////////////////////////////
00082 ///////////////////////////////////////////////////////////////////////////////
00083 ///////////////////////////////////////////////////////////////////////////////
00084 
00085 //=============================================================================
00086 /*! zgsmatrix+_zgsmatrix operator */
00087 inline _zgsmatrix operator+(const zgsmatrix& matA, const _zgsmatrix& matB)
00088 {VERBOSE_REPORT;
00089 #ifdef  CPPL_DEBUG
00090   if(matA.n!=matB.n || matA.m!=matB.m){
00091     ERROR_REPORT;
00092     std::cerr << "These two matrises can not make a summation." << std::endl
00093               << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00094     exit(1);
00095   }
00096 #endif//CPPL_DEBUG
00097 
00098   zgsmatrix newmat(matB);
00099   for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA.data.end(); it++){
00100     newmat(it->i,it->j) += it->v;
00101   }
00102   return _(newmat);
00103 }
00104 
00105 //=============================================================================
00106 /*! zgsmatrix-_zgsmatrix operator */
00107 inline _zgsmatrix operator-(const zgsmatrix& matA, const _zgsmatrix& matB)
00108 {VERBOSE_REPORT;
00109 #ifdef  CPPL_DEBUG
00110   if(matA.n!=matB.n || matA.m!=matB.m){
00111     ERROR_REPORT;
00112     std::cerr << "These two matrises can not make a subtraction." << std::endl
00113               << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
00114     exit(1);
00115   }
00116 #endif//CPPL_DEBUG
00117   
00118   zgsmatrix newmat(matB);
00119   newmat.chsign();
00120   for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA.data.end(); it++){
00121     newmat(it->i,it->j) += it->v;
00122   }
00123   return _(newmat);
00124 }
00125 
00126 //=============================================================================
00127 /*! zgsmatrix*_zgsmatrix operator */
00128 inline _zgsmatrix operator*(const zgsmatrix& matA, const _zgsmatrix& matB)
00129 {VERBOSE_REPORT;
00130 #ifdef  CPPL_DEBUG
00131   if(matA.n!=matB.m){
00132     ERROR_REPORT;
00133     std::cerr << "These two matrises can not make a product." << std::endl
00134               << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
00135     exit(1);
00136   }
00137 #endif//CPPL_DEBUG
00138 
00139   zgsmatrix newmat(matA.m, matB.n);
00140   
00141   for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA.data.end(); it++){
00142     long k(it->j);
00143     std::vector<uint32_t>::iterator p;
00144     for(p=matB.rows[k].begin(); p!=matB.rows[k].end(); p++){
00145       newmat(it->i,matB.data[*p].j) += it->v*matB.data[*p].v;
00146     }
00147   }
00148   
00149   matB.destroy();
00150   return _(newmat);
00151 }
 All Classes Files Functions Variables Friends