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