00001
00003 inline dgematrix& dgematrix::operator=(const _dsymatrix& mat)
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] dgematrix::operator=(const _dsymatrix&)"
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 dgematrix& dgematrix::operator+=(const _dsymatrix& mat)
00030 {
00031 #ifdef CPPL_VERBOSE
00032 std::cerr << "# [MARK] dgematrix::operator+=(const _dsymatrix&)"
00033 << std::endl;
00034 #endif//CPPL_VERBOSE
00035
00036 #ifdef CPPL_DEBUG
00037 if(N!=mat.N || M!=mat.N){
00038 std::cerr << "[ERROR] dgematrix::operator+=(_dsymatrix&)" << 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++){
00047 for(long j=0; j<N; j++){
00048 operator()(i,j) += mat(i,j);
00049 }
00050 }
00051
00052 mat.destroy();
00053 return *this;
00054 }
00055
00056
00058 inline dgematrix& dgematrix::operator-=(const _dsymatrix& mat)
00059 {
00060 #ifdef CPPL_VERBOSE
00061 std::cerr << "# [MARK] dgematrix::operator-=(const _dsymatrix&)"
00062 << std::endl;
00063 #endif//CPPL_VERBOSE
00064
00065 #ifdef CPPL_DEBUG
00066 if(N!=mat.N || M!=mat.N){
00067 std::cerr << "[ERROR] dgematrix::operator-=(_dsymatrix&)" << std::endl
00068 << "These two matrises can not make a sutraction." << std::endl
00069 << "Your input was (" << M << "x" << N << ") -= ("
00070 << mat.N << "x" << mat.N << ")." << std::endl;
00071 exit(1);
00072 }
00073 #endif//CPPL_DEBUG
00074
00075 for(long i=0; i<M;i++){
00076 for(long j=0; j<N; j++){
00077 operator()(i,j) -= mat(i,j);
00078 }
00079 }
00080
00081 mat.destroy();
00082 return *this;
00083 }
00084
00085
00087 inline dgematrix& dgematrix::operator*=(const _dsymatrix& mat)
00088 {
00089 #ifdef CPPL_VERBOSE
00090 std::cerr << "# [MARK] dgematrix::operator*=(const _dsymatrix&)"
00091 << std::endl;
00092 #endif//CPPL_VERBOSE
00093
00094 #ifdef CPPL_DEBUG
00095 if(N!=mat.N){
00096 std::cerr << "[ERROR] dgematrix::operator*=(_dsymatrix&)" << std::endl
00097 << "These two matrises can not make a product." << std::endl
00098 << "Your input was (" << M << "x" << N << ") *= ("
00099 << mat.N << "x" << mat.N << ")." << std::endl;
00100 exit(1);
00101 }
00102 #endif//CPPL_DEBUG
00103
00104 dgematrix newmat( M, mat.N );
00105 dsymm_( 'R', 'L', mat.N, N, 1.0, mat.Array, mat.N,
00106 Array, M, 0.0, newmat.Array, newmat.M );
00107
00108 swap(*this,newmat);
00109 mat.destroy();
00110 return *this;
00111 }
00112
00116
00117
00119 inline _dgematrix operator+(const dgematrix& matA, const _dsymatrix& matB)
00120 {
00121 #ifdef CPPL_VERBOSE
00122 std::cerr << "# [MARK] operator+(const dgematrix&, const _dsymatrix&)"
00123 << std::endl;
00124 #endif//CPPL_VERBOSE
00125
00126 #ifdef CPPL_DEBUG
00127 if(matA.N!=matB.N || matA.M!=matB.N){
00128 std::cerr << "[ERROR] operator+(dgematrix&, _dgematrix&)" << std::endl
00129 << "These two matrises can not make a summation." << std::endl
00130 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00131 << matB.N << "x" << matB.N << ")." << std::endl;
00132 exit(1);
00133 }
00134 #endif//CPPL_DEBUG
00135
00136 dgematrix newmat(matA);
00137 for(long i=0; i<matA.M; i++){
00138 for(long j=0; j<matA.N; j++){
00139 newmat(i,j) += matB(i,j);
00140 }
00141 }
00142
00143 matB.destroy();
00144 return _(newmat);
00145 }
00146
00147
00149 inline _dgematrix operator-(const dgematrix& matA, const _dsymatrix& matB)
00150 {
00151 #ifdef CPPL_VERBOSE
00152 std::cerr << "# [MARK] operator-(const dgematrix&, const _dsymatrix&)"
00153 << std::endl;
00154 #endif//CPPL_VERBOSE
00155
00156 #ifdef CPPL_DEBUG
00157 if(matA.N!=matB.N || matA.M!=matB.N){
00158 std::cerr << "[ERROR] operator-(dgematrix&, _dgematrix&)" << std::endl
00159 << "These two matrises can not make a subtraction." << std::endl
00160 << "Your input was (" << matA.M << "x" << matA.N << ") - ("
00161 << matB.N << "x" << matB.N << ")." << std::endl;
00162 exit(1);
00163 }
00164 #endif//CPPL_DEBUG
00165
00166 dgematrix newmat(matA);
00167 for(long i=0; i<matA.M; i++){
00168 for(long j=0; j<matA.N; j++){
00169 newmat(i,j) -= matB(i,j);
00170 }
00171 }
00172
00173 matB.destroy();
00174 return _(newmat);
00175 }
00176
00177
00179 inline _dgematrix operator*(const dgematrix& matA, const _dsymatrix& matB)
00180 {
00181 #ifdef CPPL_VERBOSE
00182 std::cerr << "# [MARK] operator*(const dgematrix&, const _dsymatrix&)"
00183 << std::endl;
00184 #endif//CPPL_VERBOSE
00185
00186 #ifdef CPPL_DEBUG
00187 if(matA.N!=matB.N){
00188 std::cerr << "[ERROR] operator*(dgematrix&, _dgematrix&)" << std::endl
00189 << "These two matrises can not make a product." << std::endl
00190 << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00191 << matB.N << "x" << matB.N << ")." << std::endl;
00192 exit(1);
00193 }
00194 #endif//CPPL_DEBUG
00195
00196 dgematrix newmat( matA.N, matB.N );
00197 dsymm_( 'R', 'L', matB.N, matA.N, 1.0, matB.Array, matB.N,
00198 matA.Array, matA.M, 0.0, newmat.Array, newmat.M );
00199
00200 matB.destroy();
00201 return _(newmat);
00202 }