00001
00003 inline zgematrix& zgematrix::operator=(const _zhematrix& mat)
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] zgematrix::operator=(const _zhematrix&)"
00007 << std::endl;
00008 #endif//CPPL_VERBOSE
00009
00010 clear();
00011 mat.complete();
00012
00013 M =mat.N;
00014 N =mat.N;
00015 Array =mat.Array;
00016 Darray =mat.Darray;
00017
00018 mat.Array=NULL;
00019 mat.Darray=NULL;
00020 return *this;
00021 }
00022
00026
00027
00029 inline zgematrix& zgematrix::operator+=(const _zhematrix& mat)
00030 {
00031 #ifdef CPPL_VERBOSE
00032 std::cerr << "# [MARK] zgematrix::operator+=(const _zhematrix&)"
00033 << std::endl;
00034 #endif//CPPL_VERBOSE
00035
00036 #ifdef CPPL_DEBUG
00037 if(N!=mat.N || M!=mat.N){
00038 std::cerr << "[ERROR] zgematrix::operator+=(_zhematrix&)" << std::endl
00039 << "These two matrises can not make a summation." << std::endl
00040 << "Your input was (" << M << "x" << N << ") += ("
00041 << mat.N << "x" << mat.N << ")." << std::endl;
00042 exit(1);
00043 }
00044 #endif//CPPL_DEBUG
00045
00046 for(long i=0; i<M; i++){ for(long j=0; j<N; j++){
00047 operator()(i,j) +=mat(i,j);
00048 }}
00049
00050 mat.destroy();
00051 return *this;
00052 }
00053
00054
00056 inline zgematrix& zgematrix::operator-=(const _zhematrix& mat)
00057 {
00058 #ifdef CPPL_VERBOSE
00059 std::cerr << "# [MARK] zgematrix::operator-=(const _zhematrix&)"
00060 << std::endl;
00061 #endif//CPPL_VERBOSE
00062
00063 #ifdef CPPL_DEBUG
00064 if(N!=mat.N || M!=mat.N){
00065 std::cerr << "[ERROR] zgematrix::operator-=(_zhematrix&)" << std::endl
00066 << "These two matrises can not make a sutraction." << std::endl
00067 << "Your input was (" << M << "x" << N << ") -= ("
00068 << mat.N << "x" << mat.N << ")." << std::endl;
00069 exit(1);
00070 }
00071 #endif//CPPL_DEBUG
00072
00073 for(long i=0; i<M; i++){ for(long j=0; j<N; j++){
00074 operator()(i,j) -=mat(i,j);
00075 }}
00076
00077 mat.destroy();
00078 return *this;
00079 }
00080
00081
00083 inline zgematrix& zgematrix::operator*=(const _zhematrix& mat)
00084 {
00085 #ifdef CPPL_VERBOSE
00086 std::cerr << "# [MARK] zgematrix::operator*=(const _zhematrix&)"
00087 << std::endl;
00088 #endif//CPPL_VERBOSE
00089
00090 #ifdef CPPL_DEBUG
00091 if(N!=mat.N){
00092 std::cerr << "[ERROR] zgematrix::operator*=(_zhematrix&)" << std::endl
00093 << "These two matrises can not make a product." << std::endl
00094 << "Your input was (" << M << "x" << N << ") *= ("
00095 << mat.N << "x" << mat.N << ")." << std::endl;
00096 exit(1);
00097 }
00098 #endif//CPPL_DEBUG
00099
00100 zgematrix newmat( M, mat.N );
00101
00102 zhemm_( 'R', 'L', mat.N, N, std::complex<double>(1.0,0.0), mat.Array, mat.N,
00103 Array, M, std::complex<double>(0.0,0.0), newmat.array, newmat.m );
00104
00105 swap(*this,newmat);
00106 mat.destroy();
00107 return *this;
00108 }
00109
00113
00114
00116 inline _zgematrix operator+(const zgematrix& matA, const _zhematrix& matB)
00117 {
00118 #ifdef CPPL_VERBOSE
00119 std::cerr << "# [MARK] operator+(const zgematrix&, const _zhematrix&)"
00120 << std::endl;
00121 #endif//CPPL_VERBOSE
00122
00123 #ifdef CPPL_DEBUG
00124 if(matA.N!=matB.N || matA.M!=matB.N){
00125 std::cerr << "[ERROR] operator+(zgematrix&, _zgematrix&)" << std::endl
00126 << "These two matrises can not make a summation." << std::endl
00127 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00128 << matB.N << "x" << matB.N << ")." << std::endl;
00129 exit(1);
00130 }
00131 #endif//CPPL_DEBUG
00132
00133 zgematrix newmat(matA);
00134 for(long i=0; i<matA.M; i++){ for(long j=0; j<matA.N; j++){
00135 newmat(i,j) +=matB(i,j);
00136 }}
00137
00138 matB.destroy();
00139 return _(newmat);
00140 }
00141
00142
00144 inline _zgematrix operator-(const zgematrix& matA, const _zhematrix& matB)
00145 {
00146 #ifdef CPPL_VERBOSE
00147 std::cerr << "# [MARK] operator-(const zgematrix&, const _zhematrix&)"
00148 << std::endl;
00149 #endif//CPPL_VERBOSE
00150
00151 #ifdef CPPL_DEBUG
00152 if(matA.N!=matB.N || matA.M!=matB.N){
00153 std::cerr << "[ERROR] operator-(zgematrix&, _zgematrix&)" << std::endl
00154 << "These two matrises can not make a subtraction." << std::endl
00155 << "Your input was (" << matA.M << "x" << matA.N << ") - ("
00156 << matB.N << "x" << matB.N << ")." << std::endl;
00157 exit(1);
00158 }
00159 #endif//CPPL_DEBUG
00160
00161 zgematrix newmat(matA);
00162 for(long i=0; i<matA.M; i++){ for(long j=0; j<matA.N; j++){
00163 newmat(i,j) -=matB(i,j);
00164 }}
00165
00166 matB.destroy();
00167 return _(newmat);
00168 }
00169
00170
00172 inline _zgematrix operator*(const zgematrix& matA, const _zhematrix& matB)
00173 {
00174 #ifdef CPPL_VERBOSE
00175 std::cerr << "# [MARK] operator*(const zgematrix&, const _zhematrix&)"
00176 << std::endl;
00177 #endif//CPPL_VERBOSE
00178
00179 #ifdef CPPL_DEBUG
00180 if(matA.N!=matB.N){
00181 std::cerr << "[ERROR] operator*(zgematrix&, _zgematrix&)" << std::endl
00182 << "These two matrises can not make a product." << std::endl
00183 << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00184 << matB.N << "x" << matB.N << ")." << std::endl;
00185 exit(1);
00186 }
00187 #endif//CPPL_DEBUG
00188
00189 zgematrix newmat( matA.N, matB.N );
00190
00191 zhemm_( 'R', 'L', matB.N, matA.N, std::complex<double>(1.0,0.0),
00192 matB.Array, matB.N, matA.Array, matA.M,
00193 std::complex<double>(0.0,0.0), newmat.array, newmat.m );
00194
00195 matB.destroy();
00196 return _(newmat);
00197 }