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