00001
00003 inline zhematrix& zhematrix::operator=(const _zhematrix& mat)
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] zhematrix::operator=(const _zhematrix&)"
00007 << std::endl;
00008 #endif//CPPL_VERBOSE
00009
00010 shallow_copy(mat);
00011 return *this;
00012 }
00013
00017
00018
00020 inline zhematrix& zhematrix::operator+=(const _zhematrix& mat)
00021 {
00022 #ifdef CPPL_VERBOSE
00023 std::cerr << "# [MARK] zhematrix::operator+=(const _zhematrix&)"
00024 << std::endl;
00025 #endif//CPPL_VERBOSE
00026
00027 #ifdef CPPL_DEBUG
00028 if(N!=mat.N){
00029 std::cerr << "[ERROR] zhematrix::operator+=(_zhematrix&)" << std::endl
00030 << "These two matrises can not make a summation." << std::endl
00031 << "Your input was (" << N << "x" << N << ") += ("
00032 << mat.N << "x" << mat.N << ")." << std::endl;
00033 exit(1);
00034 }
00035 #endif//CPPL_DEBUG
00036
00037 for(long i=0; i<N; i++){ for(long j=0; j<=i; j++){
00038 Array[i+N*j]+=mat.Array[i+N*j];
00039 }}
00040
00041 mat.destroy();
00042 return *this;
00043 }
00044
00045
00047 inline zhematrix& zhematrix::operator-=(const _zhematrix& mat)
00048 {
00049 #ifdef CPPL_VERBOSE
00050 std::cerr << "# [MARK] zhematrix::operator-=(const _zhematrix&)"
00051 << std::endl;
00052 #endif//CPPL_VERBOSE
00053
00054 #ifdef CPPL_DEBUG
00055 if(N!=mat.N){
00056 std::cerr << "[ERROR] zhematrix::operator-=(_zhematrix&)" << std::endl
00057 << "These two matrises can not make a sutraction." << std::endl
00058 << "Your input was (" << N << "x" << N << ") -= ("
00059 << mat.N << "x" << mat.N << ")." << std::endl;
00060 exit(1);
00061 }
00062 #endif//CPPL_DEBUG
00063
00064 for(long i=0; i<N; i++){ for(long j=0; j<=i; j++){
00065 Array[i+N*j]-=mat.Array[i+N*j];
00066 }}
00067
00068 mat.destroy();
00069 return *this;
00070 }
00071
00075
00076
00078 inline _zhematrix operator+(const zhematrix& matA, const _zhematrix& matB)
00079 {
00080 #ifdef CPPL_VERBOSE
00081 std::cerr << "# [MARK] operator+(const zhematrix&, const _zhematrix&)"
00082 << std::endl;
00083 #endif//CPPL_VERBOSE
00084
00085 #ifdef CPPL_DEBUG
00086 if(matA.N!=matB.N){
00087 std::cerr << "[ERROR] operator+(zhematrix&, _zhematrix&)" << std::endl
00088 << "These two matrises can not make a summation." << std::endl
00089 << "Your input was (" << matA.N << "x" << matA.N << ") + ("
00090 << matB.N << "x" << matB.N << ")." << std::endl;
00091 exit(1);
00092 }
00093 #endif//CPPL_DEBUG
00094
00095 for(long i=0; i<matA.N; i++){ for(long j=0; j<=i; j++){
00096 matB.Array[i+matA.N*j]+=matA.Array[i+matA.N*j];
00097 }}
00098
00099 return matB;
00100 }
00101
00102
00104 inline _zhematrix operator-(const zhematrix& matA, const _zhematrix& matB)
00105 {
00106 #ifdef CPPL_VERBOSE
00107 std::cerr << "# [MARK] operator-(const zhematrix&, const _zhematrix&)"
00108 << std::endl;
00109 #endif//CPPL_VERBOSE
00110
00111 #ifdef CPPL_DEBUG
00112 if(matA.N!=matB.N){
00113 std::cerr << "[ERROR] operator-(zhematrix&, _zhematrix&)" << std::endl
00114 << "These two matrises can not make a subtraction." << std::endl
00115 << "Your input was (" << matA.N << "x" << matA.N << ") - ("
00116 << matB.N << "x" << matB.N << ")." << std::endl;
00117 exit(1);
00118 }
00119 #endif//CPPL_DEBUG
00120
00121 for(long i=0; i<matA.N; i++){ for(long j=0; j<=i; j++){
00122 matB.Array[i] =matA.Array[i]-matB.Array[i];
00123 }}
00124
00125 return matB;
00126 }
00127
00128
00130 inline _zgematrix operator*(const zhematrix& matA, const _zhematrix& matB)
00131 {
00132 #ifdef CPPL_VERBOSE
00133 std::cerr << "# [MARK] operator*(const zhematrix&, const _zhematrix&)"
00134 << std::endl;
00135 #endif//CPPL_VERBOSE
00136
00137 #ifdef CPPL_DEBUG
00138 if(matA.N!=matB.N){
00139 std::cerr << "[ERROR] operator*(zhematrix&, _zhematrix&)" << std::endl
00140 << "These two matrises can not make a product." << std::endl
00141 << "Your input was (" << matA.N << "x" << matA.N << ") * ("
00142 << matB.N << "x" << matB.N << ")." << std::endl;
00143 exit(1);
00144 }
00145 #endif//CPPL_DEBUG
00146
00147 matB.complete();
00148 zgematrix newmat( matA.N, matB.N );
00149
00150 zhemm_( 'L', 'L', matA.N, matB.N, std::complex<double>(1.0,0.0),
00151 matA.Array, matA.N, matB.Array, matB.N,
00152 std::complex<double>(0.0,0.0), newmat.array, newmat.m );
00153
00154 matB.destroy();
00155 return _(newmat);
00156 }