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