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