Go to the documentation of this file.00001
00002
00003 inline dgematrix& dgematrix::operator=(const dgematrix& mat)
00004 {VERBOSE_REPORT;
00005 if(array!=mat.array){
00006 copy(mat);
00007 }
00008 return *this;
00009 }
00010
00011
00012
00013
00014
00015
00016
00017 inline dgematrix& dgematrix::operator+=(const dgematrix& mat)
00018 {VERBOSE_REPORT;
00019 #ifdef CPPL_DEBUG
00020 if(n!=mat.n || m!=mat.m){
00021 ERROR_REPORT;
00022 std::cerr << "These two matrises can not make a summation." << std::endl
00023 << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
00024 exit(1);
00025 }
00026 #endif//CPPL_DEBUG
00027
00028 for(long i=0; i<m*n; i++){ array[i]+=mat.array[i]; }
00029 return *this;
00030 }
00031
00032
00033
00034 inline dgematrix& dgematrix::operator-=(const dgematrix& mat)
00035 {VERBOSE_REPORT;
00036 #ifdef CPPL_DEBUG
00037 if(n!=mat.n || m!=mat.m){
00038 ERROR_REPORT;
00039 std::cerr << "These two matrises can not make a sutraction." << std::endl
00040 << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
00041 exit(1);
00042 }
00043 #endif//CPPL_DEBUG
00044
00045 for(long i=0; i<m*n; i++){ array[i]-=mat.array[i]; }
00046 return *this;
00047 }
00048
00049
00050
00051 inline dgematrix& dgematrix::operator*=(const dgematrix& mat)
00052 {VERBOSE_REPORT;
00053 #ifdef CPPL_DEBUG
00054 if(n!=mat.m){
00055 ERROR_REPORT;
00056 std::cerr << "These two matrises can not make a product." << std::endl
00057 << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
00058 exit(1);
00059 }
00060 #endif//CPPL_DEBUG
00061
00062 dgematrix newmat( m, mat.n );
00063 dgemm_( 'n', 'n', m, mat.n, n, 1.0, array, m,
00064 mat.array, mat.m, 0.0, newmat.array, m );
00065
00066 swap(*this,newmat);
00067 return *this;
00068 }
00069
00070
00071
00072
00073
00074
00075
00076 inline _dgematrix operator+(const dgematrix& matA, const dgematrix& matB)
00077 {VERBOSE_REPORT;
00078 #ifdef CPPL_DEBUG
00079 if(matA.n!=matB.n || matA.m!=matB.m){
00080 ERROR_REPORT;
00081 std::cerr << "These two matrises can not make a summation." << std::endl
00082 << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00083 exit(1);
00084 }
00085 #endif//CPPL_DEBUG
00086
00087 dgematrix newmat(matA.m,matA.n);
00088 for(long i=0; i<newmat.m*newmat.n; i++){
00089 newmat.array[i] =matA.array[i]+matB.array[i];
00090 }
00091
00092 return _(newmat);
00093 }
00094
00095
00096
00097 inline _dgematrix operator-(const dgematrix& matA, const dgematrix& matB)
00098 {VERBOSE_REPORT;
00099 #ifdef CPPL_DEBUG
00100 if(matA.n!=matB.n || matA.m!=matB.m){
00101 ERROR_REPORT;
00102 std::cerr << "These two matrises can not make a subtraction." << std::endl
00103 << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
00104 exit(1);
00105 }
00106 #endif//CPPL_DEBUG
00107
00108 dgematrix newmat(matA.m,matA.n);
00109 for(long i=0; i<newmat.m*newmat.n; i++){
00110 newmat.array[i] =matA.array[i]-matB.array[i];
00111 }
00112
00113 return _(newmat);
00114 }
00115
00116
00117
00118 inline _dgematrix operator*(const dgematrix& matA, const dgematrix& matB)
00119 {VERBOSE_REPORT;
00120 #ifdef CPPL_DEBUG
00121 if(matA.n!=matB.m){
00122 ERROR_REPORT;
00123 std::cerr << "These two matrises can not make a product." << std::endl
00124 << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
00125 exit(1);
00126 }
00127 #endif//CPPL_DEBUG
00128
00129 dgematrix newmat( matA.m, matB.n );
00130 dgemm_( 'n', 'n', matA.m, matB.n, matA.n, 1.0, matA.array, matA.m,
00131 matB.array, matB.m, 0.0, newmat.array, matA.m );
00132
00133 return _(newmat);
00134 }
00135
00136
00137
00138 inline _drovector operator%(const dgematrix& matA, const dgematrix& matB)
00139 {VERBOSE_REPORT;
00140 #ifdef CPPL_DEBUG
00141 if(matA.m!=matB.m || matA.n!=matB.n){
00142 ERROR_REPORT;
00143 std::cerr << "These two matrises can not make a product." << std::endl
00144 << "Your input was (" << matA.m << "x" << matA.n << ") % (" << matB.m << "x" << matB.n << ")." << std::endl;
00145 exit(1);
00146 }
00147 #endif//CPPL_DEBUG
00148
00149 drovector newvec( matA.n );
00150 newvec.zero();
00151 for(long j=0; j<matA.n; j++){
00152 for(long i=0; i<matA.m; i++){
00153 newvec(j) +=matA(i,j)*matB(i,j);
00154 }
00155 }
00156
00157 return _(newvec);
00158 }