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