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