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