Classes | |
class | glue_minus |
Class for the minus operation, where the result is always a dense matrix. More... | |
class | glue_minus_diag |
Class for the minus operation, where one of the operands is a diagonal matrix. More... | |
Functions | |
template<typename eT > | |
static void | glue_minus::apply (Mat< eT > &out, const Mat< eT > &A, const Mat< eT > &B) |
Immediate out = A-B. | |
template<typename eT > | |
static void | glue_minus::apply (Mat< eT > &out, const Mat< eT > &A, const Mat< eT > &B, const Mat< eT > &C) |
Immediate out = A-B-C. | |
template<typename eT > | |
static void | glue_minus::apply (Mat< eT > &out, const Glue< Mat< eT >, Mat< eT >, glue_minus > &X) |
Immediate out = A-B (operands obtained from Glue). | |
template<typename eT > | |
static void | glue_minus::apply (Mat< eT > &out, const Glue< Glue< Mat< eT >, Mat< eT >, glue_minus >, Mat< eT >, glue_minus > &X) |
Immediate out = A-B-C (operands obtained from Glue). | |
template<typename T1 , typename T2 > | |
static void | glue_minus::apply (Mat< typename T1::elem_type > &out, const Glue< T1, T2, glue_minus > &X) |
Immediate out = A-B-...-Z (operands obtained from Glue). | |
template<typename eT > | |
static void | glue_minus::apply_inplace (Mat< eT > &out, const Mat< eT > &B) |
Immediate out -= B. | |
template<typename T1 , typename op_type > | |
static void | glue_minus::apply_inplace (Mat< typename T1::elem_type > &out, const Op< T1, op_type > &X) |
template<typename T1 , typename T2 , typename glue_type > | |
static void | glue_minus::apply_inplace (Mat< typename T1::elem_type > &out, const Glue< T1, T2, glue_type > &X) |
template<typename eT1 , typename eT2 > | |
static void | glue_minus::apply_mixed (Mat< typename promote_type< eT1, eT2 >::result > &out, const Mat< eT1 > &X, const Mat< eT2 > &Y) |
template<typename T1 , typename T2 > | |
static void | glue_minus_diag::apply (Mat< typename T1::elem_type > &out, const T1 &A, const Op< T2, op_diagmat > &B) |
template<typename T1 , typename T2 > | |
static void | glue_minus_diag::apply (Mat< typename T1::elem_type > &out, const Op< T1, op_diagmat > &A, const T2 &B) |
template<typename T1 , typename T2 > | |
static void | glue_minus_diag::apply (Mat< typename T1::elem_type > &out, const Op< T1, op_diagmat > &A, const Op< T2, op_diagmat > &B) |
template<typename T1 , typename T2 > | |
static void | glue_minus_diag::apply (Mat< typename T1::elem_type > &out, const Glue< T1, Op< T2, op_diagmat >, glue_minus_diag > &X) |
template<typename T1 , typename T2 > | |
static void | glue_minus_diag::apply (Mat< typename T1::elem_type > &out, const Glue< Op< T1, op_diagmat >, T2, glue_minus_diag > &X) |
template<typename T1 , typename T2 > | |
static void | glue_minus_diag::apply (Mat< typename T1::elem_type > &out, const Glue< Op< T1, op_diagmat >, Op< T2, op_diagmat >, glue_minus_diag > &X) |
void glue_minus::apply | ( | Mat< eT > & | out, | |
const Mat< eT > & | A, | |||
const Mat< eT > & | B | |||
) | [inline, static, inherited] |
Immediate out = A-B.
Definition at line 24 of file glue_minus_meat.hpp.
References Mat< eT >::mem, Mat< eT >::memptr(), Mat< eT >::n_cols, Mat< eT >::n_elem, Mat< eT >::n_rows, and Mat< eT >::set_size().
Referenced by apply(), apply_inplace(), and apply_mixed().
00025 { 00026 arma_extra_debug_sigprint(); 00027 00028 arma_debug_assert_same_size(A, B, "matrix subtraction"); 00029 00030 // no aliasing problem 00031 out.set_size(A.n_rows,A.n_cols); 00032 00033 eT* out_mem = out.memptr(); 00034 const eT* A_mem = A.mem; 00035 const eT* B_mem = B.mem; 00036 00037 const u32 n_elem = A.n_elem; 00038 00039 for(u32 i=0; i<n_elem; ++i) 00040 { 00041 out_mem[i] = A_mem[i] - B_mem[i]; 00042 } 00043 00044 }
void glue_minus::apply | ( | Mat< eT > & | out, | |
const Mat< eT > & | A, | |||
const Mat< eT > & | B, | |||
const Mat< eT > & | C | |||
) | [inline, static, inherited] |
Immediate out = A-B-C.
Definition at line 52 of file glue_minus_meat.hpp.
References Mat< eT >::mem, Mat< eT >::memptr(), Mat< eT >::n_cols, Mat< eT >::n_elem, Mat< eT >::n_rows, and Mat< eT >::set_size().
00053 { 00054 arma_extra_debug_sigprint(); 00055 00056 arma_debug_assert_same_size(A, B, "matrix subtraction"); 00057 arma_debug_assert_same_size(A, C, "matrix subtraction"); 00058 00059 // no aliasing problem 00060 out.set_size(A.n_rows, A.n_cols); 00061 00062 eT* out_mem = out.memptr(); 00063 const eT* A_mem = A.mem; 00064 const eT* B_mem = B.mem; 00065 const eT* C_mem = C.mem; 00066 00067 const u32 n_elem = A.n_elem; 00068 00069 for(u32 i=0; i<n_elem; ++i) 00070 { 00071 out_mem[i] = A_mem[i] - B_mem[i] - C_mem[i]; 00072 } 00073 00074 }
void glue_minus::apply | ( | Mat< eT > & | out, | |
const Glue< Mat< eT >, Mat< eT >, glue_minus > & | X | |||
) | [inline, static, inherited] |
Immediate out = A-B (operands obtained from Glue).
Definition at line 82 of file glue_minus_meat.hpp.
References apply().
00083 { 00084 glue_minus::apply(out, X.A, X.B); 00085 }
void glue_minus::apply | ( | Mat< eT > & | out, | |
const Glue< Glue< Mat< eT >, Mat< eT >, glue_minus >, Mat< eT >, glue_minus > & | X | |||
) | [inline, static, inherited] |
Immediate out = A-B-C (operands obtained from Glue).
Definition at line 93 of file glue_minus_meat.hpp.
References apply().
00094 { 00095 glue_minus::apply(out, X.A.A, X.A.B, X.B); 00096 }
void glue_minus::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< T1, T2, glue_minus > & | X | |||
) | [inline, static, inherited] |
Immediate out = A-B-...-Z (operands obtained from Glue).
Definition at line 104 of file glue_minus_meat.hpp.
References Glue< T1, T2, glue_type >::A, apply(), Glue< T1, T2, glue_type >::B, and Mat< eT >::set_size().
00105 { 00106 arma_extra_debug_sigprint(); 00107 00108 typedef typename T1::elem_type eT; 00109 00110 const u32 N_mat = 1 + depth_lhs< glue_minus, Glue<T1,T2,glue_minus> >::num; 00111 arma_extra_debug_print( arma_boost::format("N_mat = %d") % N_mat ); 00112 00113 00114 if(N_mat == 2) 00115 { 00116 const unwrap<T1> tmp1(X.A); 00117 const unwrap<T2> tmp2(X.B); 00118 00119 glue_minus::apply(out, tmp1.M, tmp2.M); 00120 } 00121 else 00122 { 00123 const Mat<eT>* ptrs[N_mat]; 00124 bool del[N_mat]; 00125 00126 mat_ptrs<glue_minus, Glue<T1,T2,glue_minus> >::get_ptrs(ptrs, del, X); 00127 //mat_ptrs_outcheck<glue_minus, Glue<T1,T2,glue_minus> >::get_ptrs(ptrs, del, X, &out); 00128 00129 for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format("ptrs[%d] = %x") % i % ptrs[i] ); 00130 for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format(" del[%d] = %d") % i % del[i] ); 00131 00132 const Mat<eT>& tmp_mat = *(ptrs[0]); 00133 00134 for(u32 i=1; i<N_mat; ++i) 00135 { 00136 arma_debug_assert_same_size(tmp_mat, *(ptrs[i]), "matrix subtraction"); 00137 } 00138 00139 const u32 n_rows = ptrs[0]->n_rows; 00140 const u32 n_cols = ptrs[0]->n_cols; 00141 00142 // no aliasing problem 00143 out.set_size(n_rows,n_cols); 00144 00145 const u32 n_elem = ptrs[0]->n_elem; 00146 00147 for(u32 j=0; j<n_elem; ++j) 00148 { 00149 eT acc = ptrs[0]->mem[j]; 00150 00151 for(u32 i=1; i<N_mat; ++i) 00152 { 00153 acc -= ptrs[i]->mem[j]; 00154 } 00155 00156 out[j] = acc; 00157 } 00158 00159 for(u32 i=0; i<N_mat; ++i) 00160 { 00161 if(del[i] == true) 00162 { 00163 arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ); 00164 delete ptrs[i]; 00165 } 00166 } 00167 00168 } 00169 }
void glue_minus::apply_inplace | ( | Mat< eT > & | out, | |
const Mat< eT > & | B | |||
) | [inline, static, inherited] |
Immediate out -= B.
Definition at line 176 of file glue_minus_meat.hpp.
References Mat< eT >::mem, Mat< eT >::memptr(), and Mat< eT >::n_elem.
Referenced by Mat< eT >::operator-=().
00177 { 00178 arma_extra_debug_sigprint(); 00179 00180 arma_debug_assert_same_size(out, B, "matrix subtraction"); 00181 00182 eT* out_mem = out.memptr(); 00183 const eT* B_mem = B.mem; 00184 00185 const u32 n_elem = out.n_elem; 00186 00187 for(u32 i=0; i<n_elem; ++i) 00188 { 00189 out_mem[i] -= B_mem[i]; 00190 } 00191 00192 }
void glue_minus::apply_inplace | ( | Mat< typename T1::elem_type > & | out, | |
const Op< T1, op_type > & | X | |||
) | [inline, static, inherited] |
Definition at line 199 of file glue_minus_meat.hpp.
References apply().
00200 { 00201 arma_extra_debug_sigprint(); 00202 00203 typedef typename T1::elem_type eT; 00204 00205 const Mat<eT> tmp(X); 00206 glue_minus::apply(out, out, tmp); 00207 }
void glue_minus::apply_inplace | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< T1, T2, glue_type > & | X | |||
) | [inline, static, inherited] |
Definition at line 214 of file glue_minus_meat.hpp.
00215 { 00216 arma_extra_debug_sigprint(); 00217 00218 typedef typename T1::elem_type eT; 00219 00220 out = out - X; 00221 }
void glue_minus::apply_mixed | ( | Mat< typename promote_type< eT1, eT2 >::result > & | out, | |
const Mat< eT1 > & | X, | |||
const Mat< eT2 > & | Y | |||
) | [inline, static, inherited] |
Definition at line 231 of file glue_minus_meat.hpp.
References apply(), Mat< eT >::mem, Mat< eT >::n_cols, and Mat< eT >::n_rows.
Referenced by operator-().
00232 { 00233 arma_extra_debug_sigprint(); 00234 00235 typedef typename promote_type<eT1,eT2>::result out_eT; 00236 00237 arma_debug_assert_same_size(X,Y, "matrix subtraction"); 00238 00239 out.set_size(X.n_rows, X.n_cols); 00240 00241 out_eT* out_mem = out.memptr(); 00242 const eT1* X_mem = X.mem; 00243 const eT2* Y_mem = Y.mem; 00244 00245 const u32 n_elem = out.n_elem; 00246 00247 for(u32 i=0; i<n_elem; ++i) 00248 { 00249 out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) - upgrade_val<eT1,eT2>::apply(Y_mem[i]); 00250 } 00251 }
void glue_minus_diag::apply | ( | Mat< typename T1::elem_type > & | out, | |
const T1 & | A, | |||
const Op< T2, op_diagmat > & | B | |||
) | [inline, static, inherited] |
Definition at line 262 of file glue_minus_meat.hpp.
References Mat< eT >::at(), Mat< eT >::is_square(), Op< T1, op_type >::m, Mat< eT >::n_cols, Mat< eT >::n_rows, and Mat< eT >::set_size().
Referenced by glue_minus_diag::apply().
00263 { 00264 arma_extra_debug_sigprint(); 00265 00266 isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check(); 00267 00268 const unwrap<T1> tmp1(A_orig); 00269 const unwrap<T2> tmp2(B_orig.m); 00270 00271 typedef typename T1::elem_type eT; 00272 00273 const Mat<eT>& A = tmp1.M; 00274 const Mat<eT>& B = tmp2.M; 00275 00276 arma_debug_check( !B.is_square(), "glue_minus_diag::apply(): matrices must be square" ); 00277 arma_debug_assert_same_size(A, B, "matrix subtraction"); 00278 00279 00280 // no aliasing problem 00281 out.set_size(A.n_rows, A.n_cols); 00282 00283 for(u32 col=0; col<A.n_cols; ++col) 00284 { 00285 for(u32 row=0; row<A.n_rows; ++row) 00286 { 00287 if(col != row) 00288 { 00289 out.at(row,col) = A.at(row,col); 00290 } 00291 else 00292 { 00293 out.at(row,col) = A.at(row,col) - B.at(row,col); 00294 } 00295 } 00296 } 00297 00298 }
void glue_minus_diag::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Op< T1, op_diagmat > & | A, | |||
const T2 & | B | |||
) | [inline, static, inherited] |
Definition at line 305 of file glue_minus_meat.hpp.
References Mat< eT >::at(), Mat< eT >::is_square(), Op< T1, op_type >::m, Mat< eT >::n_cols, Mat< eT >::n_rows, and Mat< eT >::set_size().
00306 { 00307 arma_extra_debug_sigprint(); 00308 00309 isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check(); 00310 00311 const unwrap<T1> tmp1(A_orig.m); 00312 const unwrap<T2> tmp2(B_orig); 00313 00314 typedef typename T1::elem_type eT; 00315 00316 const Mat<eT>& A = tmp1.M; 00317 const Mat<eT>& B = tmp2.M; 00318 00319 arma_debug_check( !A.is_square(), "glue_minus_diag::apply(): matrices must be square" ); 00320 arma_debug_assert_same_size(A, B, "matrix subtraction"); 00321 00322 00323 // no aliasing problem 00324 out.set_size(A.n_rows, A.n_cols); 00325 00326 for(u32 col=0; col<A.n_cols; ++col) 00327 { 00328 for(u32 row=0; row<A.n_rows; ++row) 00329 { 00330 if(col != row) 00331 { 00332 out.at(row,col) = -B.at(row,col); 00333 } 00334 else 00335 { 00336 out.at(row,col) = A.at(row,col) - B.at(row,col); 00337 } 00338 } 00339 } 00340 00341 }
void glue_minus_diag::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Op< T1, op_diagmat > & | A, | |||
const Op< T2, op_diagmat > & | B | |||
) | [inline, static, inherited] |
Definition at line 348 of file glue_minus_meat.hpp.
References Mat< eT >::at(), Mat< eT >::is_square(), Op< T1, op_type >::m, Mat< eT >::n_cols, Mat< eT >::n_rows, and Mat< eT >::zeros().
00349 { 00350 arma_extra_debug_sigprint(); 00351 00352 isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check(); 00353 00354 const unwrap<T1> tmp1(A_orig.m); 00355 const unwrap<T2> tmp2(B_orig.m); 00356 00357 typedef typename T1::elem_type eT; 00358 00359 const Mat<eT>& A = tmp1.M; 00360 const Mat<eT>& B = tmp2.M; 00361 00362 arma_debug_check( !A.is_square(), "glue_minus_diag::apply(): matrices must be square" ); 00363 arma_debug_assert_same_size(A, B, "matrix subtraction"); 00364 00365 00366 if( (&out != &A) && (&out != &B) ) 00367 { 00368 out.zeros(A.n_rows, A.n_cols); 00369 00370 for(u32 i=0; i<A.n_rows; ++i) 00371 { 00372 out.at(i,i) = A.at(i,i) - B.at(i,i); 00373 } 00374 } 00375 else 00376 { 00377 for(u32 col=0; col<A.n_cols; ++col) 00378 { 00379 for(u32 row=0; row<A.n_rows; ++row) 00380 { 00381 if(col != row) 00382 { 00383 out.at(row,col) = 0.0; 00384 } 00385 else 00386 { 00387 out.at(row,col) = A.at(row,col) - B.at(row,col); 00388 } 00389 } 00390 } 00391 } 00392 00393 }
void glue_minus_diag::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< T1, Op< T2, op_diagmat >, glue_minus_diag > & | X | |||
) | [inline, static, inherited] |
Definition at line 400 of file glue_minus_meat.hpp.
References glue_minus_diag::apply().
00401 { 00402 glue_minus_diag::apply(out, X.A, X.B); 00403 }
void glue_minus_diag::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< Op< T1, op_diagmat >, T2, glue_minus_diag > & | X | |||
) | [inline, static, inherited] |
Definition at line 410 of file glue_minus_meat.hpp.
References glue_minus_diag::apply().
00411 { 00412 glue_minus_diag::apply(out, X.A, X.B); 00413 }
void glue_minus_diag::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< Op< T1, op_diagmat >, Op< T2, op_diagmat >, glue_minus_diag > & | X | |||
) | [inline, static, inherited] |
Definition at line 420 of file glue_minus_meat.hpp.
References glue_minus_diag::apply().
00421 { 00422 glue_minus_diag::apply(out, X.A, X.B); 00423 }