00001
00003 inline _zgematrix operator+(const zssmatrix& matA, const _zgbmatrix& matB)
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] operator+(const zssmatrix&, const _zgbmatrix&)"
00007 << std::endl;
00008 #endif//CPPL_VERBOSE
00009
00010 #ifdef CPPL_DEBUG
00011 if(matA.N!=matB.N || matA.M!=matB.M){
00012 std::cerr << "[ERROR] operator+(const zssmatrix&, const zgbmatrix&)"
00013 << std::endl
00014 << "These two matrises can not make a summation." << std::endl
00015 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00016 << matB.M << "x" << matB.N << ")." << std::endl;
00017 exit(1);
00018 }
00019 #endif//CPPL_DEBUG
00020
00021 zgematrix newmat(matA);
00022
00023 for(long i=0; i<matB.M; i++){
00024 for(long j=max(0,i-matB.KL); j<min(matB.N,i+matB.KU+1); j++){
00025 newmat(i,j)+=matB(i,j);
00026 }
00027 }
00028
00029 matB.destroy();
00030 return _(newmat);
00031 }
00032
00033
00035 inline _zgematrix operator-(const zssmatrix& matA, const _zgbmatrix& matB)
00036 {
00037 #ifdef CPPL_VERBOSE
00038 std::cerr << "# [MARK] operator-(const zssmatrix&, const _zgbmatrix&)"
00039 << std::endl;
00040 #endif//CPPL_VERBOSE
00041
00042 #ifdef CPPL_DEBUG
00043 if(matA.N!=matB.N || matA.M!=matB.M){
00044 std::cerr << "[ERROR] operator+(const zssmatrix&, const _zgbmatrix&)"
00045 << std::endl
00046 << "These two matrises can not make a summation." << std::endl
00047 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00048 << matB.M << "x" << matB.N << ")." << std::endl;
00049 exit(1);
00050 }
00051 #endif//CPPL_DEBUG
00052
00053 zgematrix newmat(matA);
00054
00055 for(long i=0; i<matB.M; i++){
00056 for(long j=max(0,i-matB.KL); j<min(matB.N,i+matB.KU+1); j++){
00057 newmat(i,j)-=matB(i,j);
00058 }
00059 }
00060
00061 matB.destroy();
00062 return _(newmat);
00063 }
00064
00065
00067 inline _zgematrix operator*(const zssmatrix& matA, const _zgbmatrix& matB)
00068 {
00069 #ifdef CPPL_VERBOSE
00070 std::cerr << "# [MARK] operator*(const zssmatrix&, const _zgbmatrix&)"
00071 << std::endl;
00072 #endif//CPPL_VERBOSE
00073
00074 #ifdef CPPL_DEBUG
00075 if(matA.N!=matB.M){
00076 std::cerr << "[ERROR] operator*(const zssmatrix&, const _zgbmatrix&)"
00077 << std::endl
00078 << "These two matrises can not make a product." << std::endl
00079 << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00080 << matB.M << "x" << matB.N << ")." << std::endl;
00081 exit(1);
00082 }
00083 #endif//CPPL_DEBUG
00084
00085 zgematrix newmat( matA.M, matB.N );
00086 newmat.zero();
00087
00088 for(long c=0; c<matA.VOL; c++){
00089 for(long k=max(0,matA.Jndx[c]-matB.KU);
00090 k<min(matB.M,matA.Jndx[c]+matB.KL+1); k++){
00091 newmat(matA.Indx[c],k) += matA.Array[c]*matB(matA.Jndx[c],k);
00092 }
00093 }
00094
00095 matB.destroy();
00096 return _(newmat);
00097 }