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