CPPLapack
 All Classes Files Functions Variables Friends
zhsmatrix-zhsmatrix.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! zhsmatrix=zhsmatrix operator */
00003 inline zhsmatrix& zhsmatrix::operator=(const zhsmatrix& mat)
00004 {VERBOSE_REPORT;
00005   if(&data!=&mat.data){ // if it is NOT self substitution
00006     copy(mat);
00007   }
00008   return *this;
00009 }
00010 
00011 ///////////////////////////////////////////////////////////////////////////////
00012 ///////////////////////////////////////////////////////////////////////////////
00013 ///////////////////////////////////////////////////////////////////////////////
00014 
00015 //=============================================================================
00016 /*! zhsmatrix+=zhsmatrix operator */
00017 inline zhsmatrix& zhsmatrix::operator+=(const zhsmatrix& mat)
00018 {VERBOSE_REPORT;
00019 #ifdef  CPPL_DEBUG
00020   if(n!=mat.n){
00021     ERROR_REPORT;
00022     std::cerr << "These two matrises can not make a summation." << std::endl
00023               << "Your input was (" << n << "x" << n << ") += (" << mat.n << "x" << mat.n << ")." << std::endl;
00024     exit(1);
00025   }
00026 #endif//CPPL_DEBUG
00027   
00028   for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
00029     (*this)(it->i,it->j) +=it->v;
00030   }
00031   
00032   return *this;
00033 }
00034 
00035 //=============================================================================
00036 /*! zhsmatrix-=zhsmatrix operator */
00037 inline zhsmatrix& zhsmatrix::operator-=(const zhsmatrix& mat)
00038 {VERBOSE_REPORT;
00039 #ifdef  CPPL_DEBUG
00040   if(n!=mat.n){
00041     ERROR_REPORT;
00042     std::cerr << "These two matrises can not make a sutraction." << std::endl
00043               << "Your input was (" << n << "x" << n << ") -= (" << mat.n << "x" << mat.n << ")." << std::endl;
00044     exit(1);
00045   }
00046 #endif//CPPL_DEBUG
00047   
00048   for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
00049     (*this)(it->i,it->j) -=it->v;
00050   }
00051   
00052   return *this;
00053 }
00054 
00055 ///////////////////////////////////////////////////////////////////////////////
00056 ///////////////////////////////////////////////////////////////////////////////
00057 ///////////////////////////////////////////////////////////////////////////////
00058 
00059 //=============================================================================
00060 /*! zhsmatrix+zhsmatrix operator */
00061 inline _zhsmatrix operator+(const zhsmatrix& matA, const zhsmatrix& matB)
00062 {VERBOSE_REPORT;
00063 #ifdef  CPPL_DEBUG
00064   if(matA.n!=matB.n){
00065     ERROR_REPORT;
00066     std::cerr << "These two matrises can not make a summation." << std::endl
00067               << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
00068     exit(1);
00069   }
00070 #endif//CPPL_DEBUG
00071   
00072   zhsmatrix newmat(matA);
00073   
00074   for(std::vector<zcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
00075     newmat(it->i,it->j) +=it->v;
00076   }
00077   
00078   return _(newmat);
00079 }
00080 
00081 //=============================================================================
00082 /*! zhsmatrix-zhsmatrix operator */
00083 inline _zhsmatrix operator-(const zhsmatrix& matA, const zhsmatrix& matB)
00084 {VERBOSE_REPORT;
00085 #ifdef  CPPL_DEBUG
00086   if(matA.n!=matB.n){
00087     ERROR_REPORT;
00088     std::cerr << "These two matrises can not make a subtraction." << std::endl
00089               << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
00090     exit(1);
00091   }
00092 #endif//CPPL_DEBUG
00093   
00094   zhsmatrix newmat(matA);
00095   
00096   for(std::vector<zcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
00097     newmat(it->i,it->j) -=it->v;
00098   }
00099   
00100   return _(newmat);
00101 }
00102 
00103 //=============================================================================
00104 /*! zhsmatrix*zhsmatrix operator */
00105 /*
00106 inline _zgsmatrix operator*(const zhsmatrix& matA, const zhsmatrix& matB)
00107 {VERBOSE_REPORT;
00108 #ifdef  CPPL_DEBUG
00109   if(matA.n!=matB.n){
00110     ERROR_REPORT;
00111     std::cerr << "These two matrises can not make a product." << std::endl
00112               << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
00113     exit(1);
00114   }
00115 #endif//CPPL_DEBUG
00116   
00117   zhsmatrix newmat( matA.n, 0 );
00118   
00119   for(long c=0; c<matA.vol; c++){
00120     long k(matA.jndx[c]);
00121     std::vector< std::pair<long,long> >::iterator p;
00122     for(p=matB.Col[k].begin(); p!=matB.Col[k].end(); p++){
00123       newmat(matA.indx[c],p->first) +=matA.array[c]*matB.array[p->second];
00124     }
00125   }
00126   
00127   return _(newmat);
00128 }
00129 */
 All Classes Files Functions Variables Friends