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 if(Array!=mat.Array){
00011 copy(mat);
00012 }
00013 return *this;
00014 }
00015
00019
00020
00022 inline zhematrix& zhematrix::operator+=(const zhematrix& mat)
00023 {
00024 #ifdef CPPL_VERBOSE
00025 std::cerr << "# [MARK] zhematrix::operator+=(const zhematrix&)"
00026 << std::endl;
00027 #endif//CPPL_VERBOSE
00028
00029 #ifdef CPPL_DEBUG
00030 if(N!=mat.N){
00031 std::cerr << "[ERROR] zhematrix::operator+=(zhematrix&)" << std::endl
00032 << "These two matrises can not make a summation." << std::endl
00033 << "Your input was (" << N << "x" << N << ") += ("
00034 << mat.N << "x" << mat.N << ")." << std::endl;
00035 exit(1);
00036 }
00037 #endif//CPPL_DEBUG
00038
00039 for(long i=0; i<N; i++){ for(long j=0; j<=i; j++){
00040 operator()(i,j) +=mat(i,j);
00041 }}
00042
00043 return *this;
00044 }
00045
00046
00048 inline zhematrix& zhematrix::operator-=(const zhematrix& mat)
00049 {
00050 #ifdef CPPL_VERBOSE
00051 std::cerr << "# [MARK] zhematrix::operator-=(const zhematrix&)"
00052 << std::endl;
00053 #endif//CPPL_VERBOSE
00054
00055 #ifdef CPPL_DEBUG
00056 if(N!=mat.N){
00057 std::cerr << "[ERROR] zhematrix::operator-=(zhematrix&)" << std::endl
00058 << "These two matrises can not make a sutraction." << std::endl
00059 << "Your input was (" << N << "x" << N << ") -= ("
00060 << mat.N << "x" << mat.N << ")." << std::endl;
00061 exit(1);
00062 }
00063 #endif//CPPL_DEBUG
00064
00065 for(long i=0; i<N; i++){ for(long j=0; j<=i; j++){
00066 operator()(i,j) -=mat(i,j);
00067 }}
00068
00069 return *this;
00070 }
00071
00072
00074 inline _zhematrix operator+(const zhematrix& matA, const zhematrix& matB)
00075 {
00076 #ifdef CPPL_VERBOSE
00077 std::cerr << "# [MARK] operator+(const zhematrix&, const zhematrix&)"
00078 << std::endl;
00079 #endif//CPPL_VERBOSE
00080
00081 #ifdef CPPL_DEBUG
00082 if(matA.N!=matB.N){
00083 std::cerr << "[ERROR] operator+(zhematrix&, zhematrix&)" << std::endl
00084 << "These two matrises can not make a summation." << std::endl
00085 << "Your input was (" << matA.N << "x" << matA.N << ") + ("
00086 << matB.N << "x" << matB.N << ")." << std::endl;
00087 exit(1);
00088 }
00089 #endif//CPPL_DEBUG
00090
00091 long N = matA.N;
00092 zhematrix newmat(N);
00093 for(long i=0; i<N; i++){ for(long j=0; j<=i; j++){
00094 newmat.Array[i+N*j] = matA.Array[i+N*j] + matB.Array[i+N*j];
00095 }}
00096
00097 return _(newmat);
00098 }
00099
00100
00102 inline _zhematrix operator-(const zhematrix& matA, const zhematrix& matB)
00103 {
00104 #ifdef CPPL_VERBOSE
00105 std::cerr << "# [MARK] operator-(const zhematrix&, const zhematrix&)"
00106 << std::endl;
00107 #endif//CPPL_VERBOSE
00108
00109 #ifdef CPPL_DEBUG
00110 if(matA.N!=matB.N){
00111 std::cerr << "[ERROR] operator-(zhematrix&, zhematrix&)" << std::endl
00112 << "These two matrises can not make a subtraction." << std::endl
00113 << "Your input was (" << matA.N << "x" << matA.N << ") - ("
00114 << matB.N << "x" << matB.N << ")." << std::endl;
00115 exit(1);
00116 }
00117 #endif//CPPL_DEBUG
00118
00119 long N = matA.N;
00120 zhematrix newmat(N);
00121 for(long i=0; i<N; i++){ for(long j=0; j<=i; j++){
00122 newmat.Array[i+N*j] =matA.Array[i+N*j]-matB.Array[i+N*j];
00123 }}
00124
00125 return _(newmat);
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 return _(newmat);
00155 }