00001
00003 inline _dgematrix operator+(const dssmatrix& matA, const _dgematrix& matB)
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] operator+(const dssmatrix&, const _dgematrix&)"
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 dssmatrix&, const _dgematrix&)"
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<matA.VOL; c++){
00022 matB(matA.Indx[c],matA.Jndx[c]) += matA.Array[c];
00023 }
00024
00025 return matB;
00026 }
00027
00028
00030 inline _dgematrix operator-(const dssmatrix& matA, const _dgematrix& matB)
00031 {
00032 #ifdef CPPL_VERBOSE
00033 std::cerr << "# [MARK] operator-(const dssmatrix&, const _dgematrix&)"
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 dssmatrix&, const _dgematrix&)"
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<matB.M*matB.N; i++){
00050 matB.Array[i]=-matB.Array[i];
00051 }
00052
00054 for(long c=0; c<matA.VOL; c++){
00055 matB(matA.Indx[c],matA.Jndx[c]) += matA.Array[c];
00056 }
00057
00058 return matB;
00059 }
00060
00061
00063 inline _dgematrix operator*(const dssmatrix& matA, const _dgematrix& matB)
00064 {
00065 #ifdef CPPL_VERBOSE
00066 std::cerr << "# [MARK] operator*(const dssmatrix&, const _dgematrix&)"
00067 << std::endl;
00068 #endif//CPPL_VERBOSE
00069
00070 #ifdef CPPL_DEBUG
00071 if(matA.N!=matB.M){
00072 std::cerr << "[ERROR] operator*(const dssmatrix&, const _dgematrix&)"
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<matA.VOL; c++){
00085 for(long j=0; j<matB.N; j++){
00086 newmat(matA.Indx[c],j) += matA.Array[c]*matB(matA.Jndx[c],j);
00087 }
00088 }
00089
00090 matB.destroy();
00091 return _(newmat);
00092 }