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