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