00001
00003 inline _zhematrix operator+(const _zhematrix& matA, const _zhematrix& matB)
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] operator+(const _zhematrix&, const _zhematrix&)"
00007 << std::endl;
00008 #endif//CPPL_VERBOSE
00009
00010 #ifdef CPPL_DEBUG
00011 if(matA.N!=matB.N){
00012 std::cerr << "[ERROR] operator+(_zhematrix&, _zhematrix&)" << std::endl
00013 << "These two matrises can not make a summation." << std::endl
00014 << "Your input was (" << matA.N << "x" << matA.N << ") + ("
00015 << matB.N << "x" << matB.N << ")." << std::endl;
00016 exit(1);
00017 }
00018 #endif//CPPL_DEBUG
00019
00020 for(long i=0; i<matA.N; i++){
00021 for(long j=0; j<matA.N; j++){
00022 matA.Array[i+matA.N*j]+=matB.Array[i+matA.N*j];
00023 }
00024 }
00025
00026 matB.destroy();
00027 return matA;
00028 }
00029
00030
00032 inline _zhematrix operator-(const _zhematrix& matA, const _zhematrix& matB)
00033 {
00034 #ifdef CPPL_VERBOSE
00035 std::cerr << "# [MARK] operator-(const _zhematrix&, const _zhematrix&)"
00036 << std::endl;
00037 #endif//CPPL_VERBOSE
00038
00039 #ifdef CPPL_DEBUG
00040 if(matA.N!=matB.N){
00041 std::cerr << "[ERROR] operator-(_zhematrix&, _zhematrix&)" << std::endl
00042 << "These two matrises can not make a subtraction." << std::endl
00043 << "Your input was (" << matA.N << "x" << matA.N << ") - ("
00044 << matB.N << "x" << matB.N << ")." << std::endl;
00045 exit(1);
00046 }
00047 #endif//CPPL_DEBUG
00048
00049 for(long i=0; i<matA.N; i++){
00050 for(long j=0; j<matA.N; j++){
00051 matA.Array[i+matA.N*j]-=matB.Array[i+matA.N*j];
00052 }
00053 }
00054
00055 matB.destroy();
00056 return matA;
00057 }
00058
00059
00061 inline _zgematrix operator*(const _zhematrix& matA, const _zhematrix& matB)
00062 {
00063 #ifdef CPPL_VERBOSE
00064 std::cerr << "# [MARK] operator*(const _zhematrix&, const _zhematrix&)"
00065 << std::endl;
00066 #endif//CPPL_VERBOSE
00067
00068 #ifdef CPPL_DEBUG
00069 if(matA.N!=matB.N){
00070 std::cerr << "[ERROR] operator*(_zhematrix&, zhematrix&)" << std::endl
00071 << "These two matrises can not make a product." << std::endl
00072 << "Your input was (" << matA.N << "x" << matA.N << ") * ("
00073 << matB.N << "x" << matB.N << ")." << std::endl;
00074 exit(1);
00075 }
00076 #endif//CPPL_DEBUG
00077
00078 matB.complete();
00079 zgematrix newmat( matA.N, matB.N );
00080
00081 zhemm_( 'L', 'L', matA.N, matB.N, std::complex<double>(1.0,0.0),
00082 matA.Array, matA.N, matB.Array, matB.N,
00083 std::complex<double>(0.0,0.0), newmat.array, newmat.m );
00084
00085 matA.destroy();
00086 matB.destroy();
00087 return _(newmat);
00088 }