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 matA.destroy();
00030 matB.destroy();
00031 return _(newmat);
00032 }
00033
00034
00036 inline _zgematrix operator-(const _zssmatrix& matA, const _zgbmatrix& matB)
00037 {
00038 #ifdef CPPL_VERBOSE
00039 std::cerr << "# [MARK] operator-(const _zssmatrix&, const _zgbmatrix&)"
00040 << std::endl;
00041 #endif//CPPL_VERBOSE
00042
00043 #ifdef CPPL_DEBUG
00044 if(matA.N!=matB.N || matA.M!=matB.M){
00045 std::cerr << "[ERROR] operator+(const _zssmatrix&, const _zgbmatrix&)"
00046 << std::endl
00047 << "These two matrises can not make a summation." << std::endl
00048 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00049 << matB.M << "x" << matB.N << ")." << std::endl;
00050 exit(1);
00051 }
00052 #endif//CPPL_DEBUG
00053
00054 zgematrix newmat(matA);
00055
00056 for(long i=0; i<matB.M; i++){
00057 for(long j=max(0,i-matB.KL); j<min(matB.N,i+matB.KU+1); j++){
00058 newmat(i,j)-=matB(i,j);
00059 }
00060 }
00061
00062 matA.destroy();
00063 matB.destroy();
00064 return _(newmat);
00065 }
00066
00067
00069 inline _zgematrix operator*(const _zssmatrix& matA, const _zgbmatrix& matB)
00070 {
00071 #ifdef CPPL_VERBOSE
00072 std::cerr << "# [MARK] operator*(const _zssmatrix&, const _zgbmatrix&)"
00073 << std::endl;
00074 #endif//CPPL_VERBOSE
00075
00076 #ifdef CPPL_DEBUG
00077 if(matA.N!=matB.M){
00078 std::cerr << "[ERROR] operator*(const _zssmatrix&, const _zgbmatrix&)"
00079 << std::endl
00080 << "These two matrises can not make a product." << std::endl
00081 << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00082 << matB.M << "x" << matB.N << ")." << std::endl;
00083 exit(1);
00084 }
00085 #endif//CPPL_DEBUG
00086
00087 zgematrix newmat( matA.M, matB.N );
00088 newmat.zero();
00089
00090 for(long c=0; c<matA.VOL; c++){
00091 for(long k=max(0,matA.Jndx[c]-matB.KU);
00092 k<min(matB.M,matA.Jndx[c]+matB.KL+1); k++){
00093 newmat(matA.Indx[c],k) += matA.Array[c]*matB(matA.Jndx[c],k);
00094 }
00095 }
00096
00097 matA.destroy();
00098 matB.destroy();
00099 return _(newmat);
00100 }