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