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 if(Array!=mat.Array){
00011 copy(mat);
00012 }
00013 return *this;
00014 }
00015
00019
00020
00022 inline zgematrix& zgematrix::operator+=(const zgematrix& mat)
00023 {
00024 #ifdef CPPL_VERBOSE
00025 std::cerr << "# [MARK] zgematrix::operator+=(const zgematrix&)"
00026 << std::endl;
00027 #endif//CPPL_VERBOSE
00028
00029 #ifdef CPPL_DEBUG
00030 if(N!=mat.N || M!=mat.M){
00031 std::cerr << "[ERROR] zgematrix::operator+=(zgematrix&)" << std::endl
00032 << "These two matrises can not make a summation." << std::endl
00033 << "Your input was (" << M << "x" << N << ") += ("
00034 << mat.M << "x" << mat.N << ")." << std::endl;
00035 exit(1);
00036 }
00037 #endif//CPPL_DEBUG
00038
00039 for(long i=0; i<M*N; i++){ Array[i]+=mat.Array[i]; }
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 return *this;
00064 }
00065
00066
00068 inline zgematrix& zgematrix::operator*=(const zgematrix& mat)
00069 {
00070 #ifdef CPPL_VERBOSE
00071 std::cerr << "# [MARK] zgematrix::operator*=(const zgematrix&)"
00072 << std::endl;
00073 #endif//CPPL_VERBOSE
00074
00075 #ifdef CPPL_DEBUG
00076 if(N!=mat.M){
00077 std::cerr << "[ERROR] zgematrix::operator*=(zgematrix&)" << std::endl
00078 << "These two matrises can not make a product." << std::endl
00079 << "Your input was (" << M << "x" << N << ") *= ("
00080 << mat.M << "x" << mat.N << ")." << std::endl;
00081 exit(1);
00082 }
00083 #endif//CPPL_DEBUG
00084
00085 zgematrix newmat( M, mat.N );
00086 zgemm_( 'N', 'N', M, mat.N, N, std::complex<double>(1.0,0.0), Array, M,
00087 mat.Array, mat.M, std::complex<double>(0.0,0.0), newmat.array, M );
00088
00089 swap(*this,newmat);
00090 return *this;
00091 }
00092
00096
00097
00099 inline _zgematrix operator+(const zgematrix& matA, const zgematrix& matB)
00100 {
00101 #ifdef CPPL_VERBOSE
00102 std::cerr << "# [MARK] operator+(const zgematrix&, const zgematrix&)"
00103 << std::endl;
00104 #endif//CPPL_VERBOSE
00105
00106 #ifdef CPPL_DEBUG
00107 if(matA.N!=matB.N || matA.M!=matB.M){
00108 std::cerr << "[ERROR] operator+(zgematrix&, zgematrix&)" << std::endl
00109 << "These two matrises can not make a summation." << std::endl
00110 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00111 << matB.M << "x" << matB.N << ")." << std::endl;
00112 exit(1);
00113 }
00114 #endif//CPPL_DEBUG
00115
00116 zgematrix newmat(matA.M,matA.N);
00117 for(long i=0; i<newmat.m*newmat.n; i++){
00118 newmat.Array[i] =matA.Array[i]+matB.Array[i];
00119 }
00120
00121 return _(newmat);
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 zgematrix newmat(matA.M,matA.N);
00144 for(long i=0; i<newmat.m*newmat.n; i++){
00145 newmat.Array[i] =matA.Array[i]-matB.Array[i];
00146 }
00147
00148 return _(newmat);
00149 }
00150
00151
00153 inline _zgematrix operator*(const zgematrix& matA, const zgematrix& matB)
00154 {
00155 #ifdef CPPL_VERBOSE
00156 std::cerr << "# [MARK] operator*(const zgematrix&, const zgematrix&)"
00157 << std::endl;
00158 #endif//CPPL_VERBOSE
00159
00160 #ifdef CPPL_DEBUG
00161 if(matA.N!=matB.M){
00162 std::cerr << "[ERROR] operator*(zgematrix&, zgematrix&)" << std::endl
00163 << "These two matrises can not make a product." << std::endl
00164 << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00165 << matB.M << "x" << matB.N << ")." << std::endl;
00166 exit(1);
00167 }
00168 #endif//CPPL_DEBUG
00169
00170 zgematrix newmat( matA.M, matB.N );
00171 zgemm_( 'N', 'N', matA.M, matB.N, matA.N, std::complex<double>(1.0,0.0),
00172 matA.Array, matA.M, matB.Array, matB.M,
00173 std::complex<double>(0.0,0.0), newmat.array, matA.M );
00174
00175 return _(newmat);
00176 }