Go to the documentation of this file.00001
00002
00003 inline _dgematrix operator+(const dsymatrix& matA, const dgsmatrix& matB)
00004 {VERBOSE_REPORT;
00005 #ifdef CPPL_DEBUG
00006 if(matA.n!=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.n << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00010 exit(1);
00011 }
00012 #endif//CPPL_DEBUG
00013
00014 dgematrix newmat( matA.to_dgematrix() );
00015 for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
00016 newmat(it->i,it->j) += it->v;
00017 }
00018
00019 return _(newmat);
00020 }
00021
00022
00023
00024 inline _dgematrix operator-(const dsymatrix& matA, const dgsmatrix& matB)
00025 {VERBOSE_REPORT;
00026 #ifdef CPPL_DEBUG
00027 if(matA.n!=matB.m || matA.n!=matB.n){
00028 ERROR_REPORT;
00029 std::cerr << "These two matrises can not make a subtraction." << std::endl
00030 << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
00031 exit(1);
00032 }
00033 #endif//CPPL_DEBUG
00034
00035 dgematrix newmat( matA.to_dgematrix() );
00036 for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
00037 newmat(it->i,it->j) -= it->v;
00038 }
00039
00040 return _(newmat);
00041 }
00042
00043
00044
00045 inline _dgematrix operator*(const dsymatrix& matA, const dgsmatrix& matB)
00046 {VERBOSE_REPORT;
00047 #ifdef CPPL_DEBUG
00048 if(matA.n!=matB.m){
00049 ERROR_REPORT;
00050 std::cerr << "These two matrises can not make a product." << std::endl
00051 << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
00052 exit(1);
00053 }
00054 #endif//CPPL_DEBUG
00055
00056 dgematrix newmat(matA.n, matB.n);
00057 newmat.zero();
00058 for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
00059 for(long i=0; i<matA.n; i++){
00060 newmat(i,it->j) += matB(i,it->i)*it->v;
00061 }
00062 }
00063
00064 return _(newmat);
00065 }