00001
00003 inline _zgematrix operator+(const zssmatrix& matA, const zhematrix& matB)
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] operator+(const zssmatrix&, const zhematrix&)"
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 zssmatrix&, const zhematrix&)"
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 zgematrix 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 return _(newmat);
00027 }
00028
00029
00031 inline _zgematrix operator-(const zssmatrix& matA, const zhematrix& matB)
00032 {
00033 #ifdef CPPL_VERBOSE
00034 std::cerr << "# [MARK] operator-(const zssmatrix&, const zhematrix&)"
00035 << std::endl;
00036 #endif//CPPL_VERBOSE
00037
00038 #ifdef CPPL_DEBUG
00039 if(matA.M!=matB.N || matA.N!=matB.N){
00040 std::cerr << "[ERROR] operator-(const zssmatrix&, const zhematrix&)"
00041 << std::endl
00042 << "These two matrises can not make a subtraction." << std::endl
00043 << "Your input was (" << matA.M << "x" << matA.N << ") - ("
00044 << matB.N << "x" << matB.N << ")." << std::endl;
00045 exit(1);
00046 }
00047 #endif//CPPL_DEBUG
00048
00050 zgematrix newmat(-matB);
00051
00053 for(long c=0; c<matA.VOL; c++){
00054 newmat(matA.Indx[c],matA.Jndx[c]) += matA.Array[c];
00055 }
00056
00057 return _(newmat);
00058 }
00059
00060
00062 inline _zgematrix operator*(const zssmatrix& matA, const zhematrix& matB)
00063 {
00064 #ifdef CPPL_VERBOSE
00065 std::cerr << "# [MARK] operator*(const zssmatrix&, const zhematrix&)"
00066 << std::endl;
00067 #endif//CPPL_VERBOSE
00068
00069 #ifdef CPPL_DEBUG
00070 if(matA.N!=matB.N){
00071 std::cerr << "[ERROR] operator*(const zssmatrix&, const zhematrix&)"
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 zgematrix 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 return _(newmat);
00090 }