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