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