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