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 matB.destroy();
00027 return _(newmat);
00028 }
00029
00030
00032 inline _zgematrix operator-(const zssmatrix& matA, const _zhematrix& matB)
00033 {
00034 #ifdef CPPL_VERBOSE
00035 std::cerr << "# [MARK] operator-(const zssmatrix&, const _zhematrix&)"
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 zssmatrix&, const _zhematrix&)"
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
00051 zgematrix newmat(-matB);
00052
00054 for(long c=0; c<matA.VOL; c++){
00055 newmat(matA.Indx[c],matA.Jndx[c]) += matA.Array[c];
00056 }
00057
00058 matB.destroy();
00059 return _(newmat);
00060 }
00061
00062
00064 inline _zgematrix operator*(const zssmatrix& matA, const _zhematrix& matB)
00065 {
00066 #ifdef CPPL_VERBOSE
00067 std::cerr << "# [MARK] operator*(const zssmatrix&, const _zhematrix&)"
00068 << std::endl;
00069 #endif//CPPL_VERBOSE
00070
00071 #ifdef CPPL_DEBUG
00072 if(matA.N!=matB.N){
00073 std::cerr << "[ERROR] operator*(const zssmatrix&, const _zhematrix&)"
00074 << std::endl
00075 << "These two matrises can not make a product." << std::endl
00076 << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00077 << matB.N << "x" << matB.N << ")." << std::endl;
00078 exit(1);
00079 }
00080 #endif//CPPL_DEBUG
00081
00082 zgematrix newmat(matA.M, matB.N);
00083 newmat.zero();
00084
00085 for(long c=0; c<matA.VOL; c++){
00086 for(long i=0; i<matB.N; i++){
00087 newmat(matA.Indx[c],i) += matA.Array[c]*matB(matA.Jndx[c],i);
00088 }
00089 }
00090
00091 matB.destroy();
00092 return _(newmat);
00093 }