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