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