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