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