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