Classes | |
class | glue_plus |
Class which implements the immediate addition matrices, with the result stored in 'Mat' (dense matrix). More... | |
class | glue_plus_diag |
Functions | |
template<typename eT > | |
static void | glue_plus::apply (Mat< eT > &out, const Mat< eT > &A, const Mat< eT > &B) |
template<typename eT > | |
static void | glue_plus::apply (Mat< eT > &out, const Mat< eT > &A, const Mat< eT > &B, const Mat< eT > &C) |
template<typename eT > | |
static void | glue_plus::apply (Mat< eT > &out, const Glue< Mat< eT >, Mat< eT >, glue_plus > &X) |
template<typename eT > | |
static void | glue_plus::apply (Mat< eT > &out, const Glue< Glue< Mat< eT >, Mat< eT >, glue_plus >, Mat< eT >, glue_plus > &X) |
template<typename T1 , typename T2 > | |
static void | glue_plus::apply (Mat< typename T1::elem_type > &out, const Glue< T1, T2, glue_plus > &X) |
template<typename eT > | |
static void | glue_plus::apply (Mat< eT > &out, const Glue< Mat< eT >, subview< eT >, glue_plus > &X) |
template<typename eT > | |
static void | glue_plus::apply (Mat< eT > &out, const Glue< subview< eT >, Mat< eT >, glue_plus > &X) |
template<typename eT > | |
static void | glue_plus::apply (Mat< eT > &out, const Glue< subview< eT >, subview< eT >, glue_plus > &X) |
template<typename eT > | |
static void | glue_plus::apply_inplace (Mat< eT > &out, const Mat< eT > &B) |
template<typename T1 , typename op_type > | |
static void | glue_plus::apply_inplace (Mat< typename T1::elem_type > &out, const Op< T1, op_type > &X) |
template<typename T1 > | |
static void | glue_plus::apply_inplace (Mat< typename T1::elem_type > &out, const Op< T1, op_square > &X) |
template<typename T1 , typename T2 , typename glue_type > | |
static void | glue_plus::apply_inplace (Mat< typename T1::elem_type > &out, const Glue< T1, T2, glue_type > &X) |
template<typename T1 , typename T2 > | |
static void | glue_plus::apply_inplace (Mat< typename T1::elem_type > &out, const Glue< T1, T2, glue_times > &X) |
template<typename T1 , typename T2 > | |
static void | glue_plus::apply (Mat< typename T1::elem_type > &out, const Glue< Glue< T1, Col< typename T1::elem_type >, glue_times_vec >, T2, glue_plus > &in) |
template<typename T1 , typename T2 > | |
static void | glue_plus::apply (Mat< typename T1::elem_type > &out, const Glue< Glue< Row< typename T1::elem_type >, T1, glue_times_vec >, T2, glue_plus > &in) |
template<typename T1 , typename T2 > | |
static void | glue_plus::apply (Mat< typename T1::elem_type > &out, const Glue< Op< T1, op_scalar_times >, Op< T2, op_scalar_times >, glue_plus > &in) |
template<typename T1 , typename T2 , typename T3 > | |
static void | glue_plus::apply (Mat< typename T1::elem_type > &out, const Glue< Glue< Op< T1, op_scalar_times >, Op< T2, op_scalar_times >, glue_plus >, Op< T3, op_scalar_times >, glue_plus > &in) |
template<typename T1 , typename T2 > | |
static void | glue_plus::apply (Mat< typename T1::elem_type > &out, const Glue< Op< T1, op_scalar_div_pre >, Op< T2, op_scalar_div_pre >, glue_plus > &in) |
template<typename T1 , typename T2 , typename T3 > | |
static void | glue_plus::apply (Mat< typename T1::elem_type > &out, const Glue< Glue< Op< T1, op_scalar_div_pre >, Op< T2, op_scalar_div_pre >, glue_plus >, Op< T3, op_scalar_div_pre >, glue_plus > &in) |
template<typename T1 , typename T2 > | |
static void | glue_plus::apply (Mat< typename T1::elem_type > &out, const Glue< Op< T1, op_scalar_div_post >, Op< T2, op_scalar_div_post >, glue_plus > &in) |
template<typename T1 , typename T2 , typename T3 > | |
static void | glue_plus::apply (Mat< typename T1::elem_type > &out, const Glue< Glue< Op< T1, op_scalar_div_post >, Op< T2, op_scalar_div_post >, glue_plus >, Op< T3, op_scalar_div_post >, glue_plus > &in) |
template<typename eT1 , typename eT2 > | |
static void | glue_plus::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_plus_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_plus_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_plus_diag::apply (Mat< typename T1::elem_type > &out, const Glue< T1, Op< T2, op_diagmat >, glue_plus_diag > &X) |
template<typename T1 , typename T2 > | |
static void | glue_plus_diag::apply (Mat< typename T1::elem_type > &out, const Glue< Op< T1, op_diagmat >, T2, glue_plus_diag > &X) |
template<typename T1 , typename T2 > | |
static void | glue_plus_diag::apply (Mat< typename T1::elem_type > &out, const Glue< Op< T1, op_diagmat >, Op< T2, op_diagmat >, glue_plus_diag > &X) |
void glue_plus::apply | ( | Mat< eT > & | out, | |
const Mat< eT > & | A, | |||
const Mat< eT > & | B | |||
) | [inline, static, inherited] |
Definition at line 24 of file glue_plus_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 addition"); 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 = out.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_plus::apply | ( | Mat< eT > & | out, | |
const Mat< eT > & | A, | |||
const Mat< eT > & | B, | |||
const Mat< eT > & | C | |||
) | [inline, static, inherited] |
Definition at line 51 of file glue_plus_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().
00052 { 00053 arma_extra_debug_sigprint(); 00054 00055 arma_debug_assert_same_size(A, B, "matrix addition"); 00056 arma_debug_assert_same_size(A, C, "matrix addition"); 00057 00058 // no aliasing problem 00059 out.set_size(A.n_rows, A.n_cols); 00060 00061 eT* out_mem = out.memptr(); 00062 const eT* A_mem = A.mem; 00063 const eT* B_mem = B.mem; 00064 const eT* C_mem = C.mem; 00065 00066 const u32 n_elem = A.n_elem; 00067 00068 for(u32 i=0; i<n_elem; ++i) 00069 { 00070 out_mem[i] = A_mem[i] + B_mem[i] + C_mem[i]; 00071 } 00072 00073 }
void glue_plus::apply | ( | Mat< eT > & | out, | |
const Glue< Mat< eT >, Mat< eT >, glue_plus > & | X | |||
) | [inline, static, inherited] |
Definition at line 80 of file glue_plus_meat.hpp.
References apply().
00081 { 00082 glue_plus::apply(out, X.A, X.B); 00083 }
void glue_plus::apply | ( | Mat< eT > & | out, | |
const Glue< Glue< Mat< eT >, Mat< eT >, glue_plus >, Mat< eT >, glue_plus > & | X | |||
) | [inline, static, inherited] |
Definition at line 90 of file glue_plus_meat.hpp.
References apply().
00091 { 00092 glue_plus::apply(out, X.A.A, X.A.B, X.B); 00093 }
void glue_plus::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< T1, T2, glue_plus > & | X | |||
) | [inline, static, inherited] |
Definition at line 100 of file glue_plus_meat.hpp.
References Glue< T1, T2, glue_type >::A, apply(), apply_inplace(), Glue< T1, T2, glue_type >::B, and Mat< eT >::set_size().
00101 { 00102 arma_extra_debug_sigprint(); 00103 00104 typedef typename T1::elem_type eT; 00105 00106 const u32 N_mat = 1 + depth_lhs< glue_plus, Glue<T1,T2,glue_plus> >::num; 00107 arma_extra_debug_print( arma_boost::format("N_mat = %d") % N_mat ); 00108 00109 if(N_mat == 2) 00110 { 00111 if(is_glue_times<T1>::value == true) 00112 { 00113 out = X.B; 00114 glue_plus::apply_inplace(out, X.A); 00115 } 00116 else 00117 if(is_glue_times<T2>::value == true) 00118 { 00119 out = X.A; 00120 glue_plus::apply_inplace(out, X.B); 00121 } 00122 else 00123 { 00124 const unwrap<T1> tmp1(X.A); 00125 const unwrap<T2> tmp2(X.B); 00126 00127 glue_plus::apply(out, tmp1.M, tmp2.M); 00128 } 00129 } 00130 else 00131 { 00132 const Mat<eT>* ptrs[N_mat]; 00133 bool del[N_mat]; 00134 00135 mat_ptrs<glue_plus, Glue<T1,T2,glue_plus> >::get_ptrs(ptrs, del, X); 00136 00137 for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format("ptrs[%d] = %x") % i % ptrs[i] ); 00138 for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format(" del[%d] = %d") % i % del[i] ); 00139 00140 const u32 n_rows = ptrs[0]->n_rows; 00141 const u32 n_cols = ptrs[0]->n_cols; 00142 00143 const Mat<eT>& tmp_mat = *(ptrs[0]); 00144 00145 for(u32 i=1; i<N_mat; ++i) 00146 { 00147 arma_debug_assert_same_size(tmp_mat, *(ptrs[i]), "matrix addition"); 00148 } 00149 00150 00151 // no aliasing problem 00152 out.set_size(n_rows, n_cols); 00153 00154 const u32 n_elem = ptrs[0]->n_elem; 00155 00156 for(u32 j=0; j<n_elem; ++j) 00157 { 00158 eT acc = ptrs[0]->mem[j]; 00159 00160 for(u32 i=1; i < N_mat; ++i) 00161 { 00162 acc += ptrs[i]->mem[j]; 00163 } 00164 00165 out[j] = acc; 00166 } 00167 00168 00169 for(u32 i=0; i<N_mat; ++i) 00170 { 00171 if(del[i] == true) 00172 { 00173 arma_extra_debug_print( arma_boost::format("delete mat_ptr[%d]") % i ); 00174 delete ptrs[i]; 00175 } 00176 } 00177 } 00178 }
void glue_plus::apply | ( | Mat< eT > & | out, | |
const Glue< Mat< eT >, subview< eT >, glue_plus > & | X | |||
) | [inline, static, inherited] |
Definition at line 196 of file glue_plus_meat.hpp.
References apply(), Mat< eT >::at(), Mat< eT >::n_cols, Mat< eT >::n_rows, and Mat< eT >::set_size().
00197 { 00198 arma_extra_debug_sigprint(); 00199 00200 const Mat<eT>& orig_A = X.A; 00201 const Mat<eT>& orig_B = X.B.m; 00202 00203 if( &out != &orig_B ) 00204 { 00205 //const u32 sub_B_n_rows = X.B.n_rows; 00206 //const u32 sub_B_n_cols = X.B.n_cols; 00207 00208 arma_debug_assert_same_size(X.A, X.B, "matrix addition"); 00209 00210 00211 out.set_size(orig_A.n_rows, orig_A.n_cols); 00212 00213 for(u32 col = 0; col<orig_A.n_cols; ++col) 00214 { 00215 const u32 B_col_mod = X.B.aux_col1 + col; 00216 00217 for(u32 row = 0; row<orig_A.n_rows; ++row) 00218 { 00219 const u32 B_row_mod = X.B.aux_row1 + row; 00220 00221 out.at(row,col) = orig_A.at(row, col) + orig_B.at(B_row_mod, B_col_mod); 00222 } 00223 00224 } 00225 00226 } 00227 else 00228 { 00229 const Mat<eT> processed_B(X.B); // create a matrix out of subview 00230 glue_plus::apply(out, orig_A, processed_B); 00231 } 00232 00233 }
void glue_plus::apply | ( | Mat< eT > & | out, | |
const Glue< subview< eT >, Mat< eT >, glue_plus > & | X | |||
) | [inline, static, inherited] |
Definition at line 244 of file glue_plus_meat.hpp.
References apply(), Mat< eT >::at(), and Mat< eT >::set_size().
00245 { 00246 arma_extra_debug_sigprint(); 00247 00248 const Mat<eT>& orig_A = X.A.m; 00249 00250 const unwrap_check< Mat<eT> > tmp(X.B, out); 00251 const Mat<eT>& orig_B = tmp.M; 00252 00253 if( &out != &orig_A ) 00254 { 00255 const u32 sub_A_n_rows = X.A.n_rows; 00256 const u32 sub_A_n_cols = X.A.n_cols; 00257 00258 arma_debug_assert_same_size(X.A, X.B, "matrix addition"); 00259 00260 out.set_size(sub_A_n_rows, sub_A_n_cols); 00261 00262 for(u32 col = 0; col<sub_A_n_cols; ++col) 00263 { 00264 const u32 A_col_mod = X.A.aux_col1 + col; 00265 00266 for(u32 row = 0; row<sub_A_n_rows; ++row) 00267 { 00268 const u32 A_row_mod = X.A.aux_row1 + row; 00269 00270 out.at(row,col) = orig_A.at(A_row_mod, A_col_mod) + orig_B.at(row, col); 00271 } 00272 00273 } 00274 } 00275 else 00276 { 00277 const Mat<eT> processed_A(X.A); 00278 glue_plus::apply(out, processed_A, orig_B); 00279 } 00280 00281 00282 }
void glue_plus::apply | ( | Mat< eT > & | out, | |
const Glue< subview< eT >, subview< eT >, glue_plus > & | X | |||
) | [inline, static, inherited] |
Definition at line 293 of file glue_plus_meat.hpp.
References apply(), Mat< eT >::at(), and Mat< eT >::set_size().
00294 { 00295 arma_extra_debug_sigprint(); 00296 00297 const Mat<eT>& orig_A = X.A.m; 00298 const Mat<eT>& orig_B = X.B.m; 00299 00300 if( (&out != &orig_A) && (&out != &orig_B) ) 00301 { 00302 const u32 sub_A_n_rows = X.A.n_rows; 00303 const u32 sub_A_n_cols = X.A.n_cols; 00304 00305 //const u32 sub_B_n_rows = X.B.n_rows; 00306 //const u32 sub_B_n_cols = X.B.n_cols; 00307 00308 arma_debug_assert_same_size(X.A, X.B, "matrix addition"); 00309 00310 out.set_size(sub_A_n_rows, sub_A_n_cols); 00311 00312 for(u32 col = 0; col<sub_A_n_cols; ++col) 00313 { 00314 const u32 A_col_mod = X.A.aux_col1 + col; 00315 const u32 B_col_mod = X.B.aux_col1 + col; 00316 00317 for(u32 row = 0; row<sub_A_n_rows; ++row) 00318 { 00319 const u32 A_row_mod = X.A.aux_row1 + row; 00320 const u32 B_row_mod = X.B.aux_row1 + row; 00321 00322 out.at(row,col) = orig_A.at(A_row_mod, A_col_mod) + orig_B.at(B_row_mod, B_col_mod); 00323 } 00324 00325 } 00326 } 00327 else 00328 { 00329 const Mat<eT> processed_A(X.A); 00330 const Mat<eT> processed_B(X.B); 00331 00332 glue_plus::apply(out, processed_A, processed_B); 00333 } 00334 }
void glue_plus::apply_inplace | ( | Mat< eT > & | out, | |
const Mat< eT > & | B | |||
) | [inline, static, inherited] |
Definition at line 339 of file glue_plus_meat.hpp.
References Mat< eT >::mem, Mat< eT >::memptr(), and Mat< eT >::n_elem.
Referenced by apply(), and Mat< eT >::operator+=().
00340 { 00341 arma_extra_debug_sigprint(); 00342 00343 arma_debug_assert_same_size(out, B, "matrix addition"); 00344 00345 00346 eT* out_mem = out.memptr(); 00347 const eT* B_mem = B.mem; 00348 00349 const u32 n_elem = B.n_elem; 00350 00351 for(u32 i=0; i<n_elem; ++i) 00352 { 00353 out_mem[i] += B_mem[i]; 00354 } 00355 00356 }
void glue_plus::apply_inplace | ( | Mat< typename T1::elem_type > & | out, | |
const Op< T1, op_type > & | X | |||
) | [inline, static, inherited] |
Definition at line 363 of file glue_plus_meat.hpp.
References apply().
00364 { 00365 arma_extra_debug_sigprint(); 00366 00367 typedef typename T1::elem_type eT; 00368 00369 const Mat<eT> tmp(X); 00370 glue_plus::apply(out, out, tmp); 00371 }
void glue_plus::apply_inplace | ( | Mat< typename T1::elem_type > & | out, | |
const Op< T1, op_square > & | X | |||
) | [inline, static, inherited] |
Definition at line 378 of file glue_plus_meat.hpp.
References Op< T1, op_type >::m, Mat< eT >::mem, Mat< eT >::memptr(), and Mat< eT >::n_elem.
00379 { 00380 arma_extra_debug_sigprint(); 00381 00382 typedef typename T1::elem_type eT; 00383 00384 const unwrap<T1> tmp(X.m); 00385 const Mat<eT>& B = tmp.M; 00386 00387 arma_debug_assert_same_size(out, B, "matrix addition"); 00388 00389 eT* out_mem = out.memptr(); 00390 const eT* B_mem = B.mem; 00391 00392 const u32 n_elem = out.n_elem; 00393 00394 for(u32 i=0; i<n_elem; ++i) 00395 { 00396 const eT tmp_val = B_mem[i]; 00397 out_mem[i] += tmp_val*tmp_val; 00398 } 00399 }
void glue_plus::apply_inplace | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< T1, T2, glue_type > & | X | |||
) | [inline, static, inherited] |
void glue_plus::apply_inplace | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< T1, T2, glue_times > & | X | |||
) | [inline, static, inherited] |
Definition at line 418 of file glue_plus_meat.hpp.
References Glue< T1, T2, glue_type >::A, apply(), Glue< T1, T2, glue_type >::B, Mat< eT >::n_cols, and Mat< eT >::n_rows.
00419 { 00420 arma_extra_debug_sigprint(); 00421 00422 typedef typename T1::elem_type eT; 00423 00424 const unwrap_check<T1> tmp1(X.A, out); 00425 const unwrap_check<T2> tmp2(X.B, out); 00426 00427 const Mat<eT>& A = tmp1.M; 00428 const Mat<eT>& B = tmp2.M; 00429 00430 arma_debug_assert_mul_size(A, B, "matrix multiplication"); 00431 arma_debug_assert_same_size(out.n_rows, out.n_cols, A.n_rows, B.n_cols, "matrix addition"); 00432 00433 gemm<false,false,false,true>::apply(out, A, B, eT(1), eT(1)); 00434 }
void glue_plus::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< Glue< T1, Col< typename T1::elem_type >, glue_times_vec >, T2, glue_plus > & | in | |||
) | [inline, static, inherited] |
Definition at line 448 of file glue_plus_meat.hpp.
References gemv< do_trans_A, use_alpha, use_beta >::apply(), Mat< eT >::mem, Mat< eT >::memptr(), Mat< eT >::n_cols, and Mat< eT >::n_rows.
00452 { 00453 arma_extra_debug_sigprint(); 00454 00455 typedef typename T1::elem_type eT; 00456 00457 const unwrap<T1> tmp1(in.A.A); 00458 const unwrap<T2> tmp2(in.B); 00459 00460 const Mat<eT>& A = tmp1.M; 00461 const Col<eT>& B = in.A.B; 00462 const Mat<eT>& C = tmp2.M; 00463 00464 arma_debug_assert_mul_size(A, B, "matrix multiplication"); 00465 arma_debug_assert_same_size(A.n_rows, B.n_cols, C.n_rows, C.n_cols, "matrix addition"); 00466 00467 if( (&out != &A) && (&out != &B) ) 00468 { 00469 out = C; 00470 gemv<false,false,true>::apply(out.memptr(), A, B.mem, eT(1), eT(1)); 00471 } 00472 else 00473 { 00474 const unwrap_check< Mat<eT> > tmpA(A,out); 00475 const unwrap_check< Col<eT> > tmpB(B,out); 00476 00477 const Mat<eT>& A_safe = tmpA.M; 00478 const Col<eT>& B_safe = tmpB.M; 00479 00480 out = C; 00481 gemv<false,false,true>::apply(out.memptr(), A_safe, B_safe.mem, eT(1), eT(1)); 00482 } 00483 00484 }
void glue_plus::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< Glue< Row< typename T1::elem_type >, T1, glue_times_vec >, T2, glue_plus > & | in | |||
) | [inline, static, inherited] |
Definition at line 492 of file glue_plus_meat.hpp.
References gemv< do_trans_A, use_alpha, use_beta >::apply(), Mat< eT >::mem, Mat< eT >::memptr(), Mat< eT >::n_cols, and Mat< eT >::n_rows.
00496 { 00497 arma_extra_debug_sigprint(); 00498 00499 typedef typename T1::elem_type eT; 00500 00501 const unwrap<T1> tmp1(in.A.B); 00502 const unwrap<T2> tmp2(in.B); 00503 00504 const Row<eT>& A = in.A.A; 00505 const Mat<eT>& B = tmp1.M; 00506 const Mat<eT>& C = tmp2.M; 00507 00508 arma_debug_assert_mul_size(A, B, "matrix multiplication"); 00509 arma_debug_assert_same_size(A.n_rows, B.n_cols, C.n_rows, C.n_cols, "matrix addition"); 00510 00511 if( (&out != &A) && (&out != &B) ) 00512 { 00513 out = C; 00514 gemv<true,false,true>::apply(out.memptr(), B, A.mem, eT(1), eT(1)); 00515 } 00516 else 00517 { 00518 const unwrap_check< Mat<eT> > tmpA(A,out); 00519 const unwrap_check< Mat<eT> > tmpB(B,out); 00520 00521 const Mat<eT>& A_safe = tmpA.M; 00522 const Mat<eT>& B_safe = tmpB.M; 00523 00524 out = C; 00525 gemv<true,false,true>::apply(out.memptr(), B_safe, A_safe.mem, eT(1), eT(1)); 00526 } 00527 00528 }
void glue_plus::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< Op< T1, op_scalar_times >, Op< T2, op_scalar_times >, glue_plus > & | in | |||
) | [inline, static, inherited] |
Definition at line 536 of file glue_plus_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().
00540 { 00541 arma_extra_debug_sigprint(); 00542 00543 typedef typename T1::elem_type eT; 00544 00545 const unwrap<T1> tmp1(in.A.m); 00546 const unwrap<T2> tmp2(in.B.m); 00547 00548 const Mat<eT>& A = tmp1.M; 00549 const Mat<eT>& B = tmp2.M; 00550 00551 arma_debug_assert_same_size(A, B, "matrix addition"); 00552 00553 out.set_size(A.n_rows, A.n_cols); 00554 00555 const eT k1 = in.A.aux; 00556 const eT k2 = in.B.aux; 00557 00558 eT* out_mem = out.memptr(); 00559 const eT* A_mem = A.mem; 00560 const eT* B_mem = B.mem; 00561 00562 const u32 local_n_elem = A.n_elem; 00563 00564 for(u32 i=0; i<local_n_elem; ++i) 00565 { 00566 out_mem[i] = k1*A_mem[i] + k2*B_mem[i]; 00567 } 00568 00569 }
void glue_plus::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< Glue< Op< T1, op_scalar_times >, Op< T2, op_scalar_times >, glue_plus >, Op< T3, op_scalar_times >, glue_plus > & | in | |||
) | [inline, static, inherited] |
Definition at line 577 of file glue_plus_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().
00581 { 00582 arma_extra_debug_sigprint(); 00583 00584 typedef typename T1::elem_type eT; 00585 00586 const unwrap<T1> tmp1(in.A.A.m); 00587 const unwrap<T2> tmp2(in.A.B.m); 00588 const unwrap<T3> tmp3(in.B.m); 00589 00590 const Mat<eT>& A = tmp1.M; 00591 const Mat<eT>& B = tmp2.M; 00592 const Mat<eT>& C = tmp3.M; 00593 00594 arma_debug_assert_same_size(A, B, "matrix addition"); 00595 arma_debug_assert_same_size(B, C, "matrix addition"); 00596 00597 out.set_size(A.n_rows, A.n_cols); 00598 00599 const eT k1 = in.A.A.aux; 00600 const eT k2 = in.A.B.aux; 00601 const eT k3 = in.B.aux; 00602 00603 eT* out_mem = out.memptr(); 00604 const eT* A_mem = A.mem; 00605 const eT* B_mem = B.mem; 00606 const eT* C_mem = C.mem; 00607 00608 const u32 local_n_elem = A.n_elem; 00609 00610 for(u32 i=0; i<local_n_elem; ++i) 00611 { 00612 out_mem[i] = k1*A_mem[i] + k2*B_mem[i] + k3*C_mem[i]; 00613 } 00614 00615 }
void glue_plus::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< Op< T1, op_scalar_div_pre >, Op< T2, op_scalar_div_pre >, glue_plus > & | in | |||
) | [inline, static, inherited] |
Definition at line 623 of file glue_plus_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().
00627 { 00628 arma_extra_debug_sigprint(); 00629 00630 typedef typename T1::elem_type eT; 00631 00632 const unwrap<T1> tmp1(in.A.m); 00633 const unwrap<T2> tmp2(in.B.m); 00634 00635 const Mat<eT>& A = tmp1.M; 00636 const Mat<eT>& B = tmp2.M; 00637 00638 arma_debug_assert_same_size(A, B, "matrix addition"); 00639 00640 out.set_size(A.n_rows, A.n_cols); 00641 00642 const eT k1 = in.A.aux; 00643 const eT k2 = in.B.aux; 00644 00645 eT* out_mem = out.memptr(); 00646 const eT* A_mem = A.mem; 00647 const eT* B_mem = B.mem; 00648 00649 const u32 local_n_elem = A.n_elem; 00650 00651 for(u32 i=0; i<local_n_elem; ++i) 00652 { 00653 out_mem[i] = k1/A_mem[i] + k2/B_mem[i]; 00654 } 00655 00656 }
void glue_plus::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< Glue< Op< T1, op_scalar_div_pre >, Op< T2, op_scalar_div_pre >, glue_plus >, Op< T3, op_scalar_div_pre >, glue_plus > & | in | |||
) | [inline, static, inherited] |
Definition at line 664 of file glue_plus_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().
00668 { 00669 arma_extra_debug_sigprint(); 00670 00671 typedef typename T1::elem_type eT; 00672 00673 const unwrap<T1> tmp1(in.A.A.m); 00674 const unwrap<T2> tmp2(in.A.B.m); 00675 const unwrap<T3> tmp3(in.B.m); 00676 00677 const Mat<eT>& A = tmp1.M; 00678 const Mat<eT>& B = tmp2.M; 00679 const Mat<eT>& C = tmp3.M; 00680 00681 arma_debug_assert_same_size(A, B, "matrix addition"); 00682 arma_debug_assert_same_size(B, C, "matrix addition"); 00683 00684 out.set_size(A.n_rows, A.n_cols); 00685 00686 const eT k1 = in.A.A.aux; 00687 const eT k2 = in.A.B.aux; 00688 const eT k3 = in.B.aux; 00689 00690 eT* out_mem = out.memptr(); 00691 const eT* A_mem = A.mem; 00692 const eT* B_mem = B.mem; 00693 const eT* C_mem = C.mem; 00694 00695 const u32 local_n_elem = A.n_elem; 00696 00697 for(u32 i=0; i<local_n_elem; ++i) 00698 { 00699 out_mem[i] = k1/A_mem[i] + k2/B_mem[i] + k3/C_mem[i]; 00700 } 00701 00702 }
void glue_plus::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< Op< T1, op_scalar_div_post >, Op< T2, op_scalar_div_post >, glue_plus > & | in | |||
) | [inline, static, inherited] |
Definition at line 710 of file glue_plus_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().
00714 { 00715 arma_extra_debug_sigprint(); 00716 00717 typedef typename T1::elem_type eT; 00718 00719 const unwrap<T1> tmp1(in.A.m); 00720 const unwrap<T2> tmp2(in.B.m); 00721 00722 const Mat<eT>& A = tmp1.M; 00723 const Mat<eT>& B = tmp2.M; 00724 00725 arma_debug_assert_same_size(A, B, "matrix addition"); 00726 00727 out.set_size(A.n_rows, A.n_cols); 00728 00729 const eT k1 = in.A.aux; 00730 const eT k2 = in.B.aux; 00731 00732 eT* out_mem = out.memptr(); 00733 const eT* A_mem = A.mem; 00734 const eT* B_mem = B.mem; 00735 00736 const u32 local_n_elem = A.n_elem; 00737 00738 for(u32 i=0; i<local_n_elem; ++i) 00739 { 00740 out_mem[i] = A_mem[i]/k1 + B_mem[i]/k2; 00741 } 00742 00743 }
void glue_plus::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< Glue< Op< T1, op_scalar_div_post >, Op< T2, op_scalar_div_post >, glue_plus >, Op< T3, op_scalar_div_post >, glue_plus > & | in | |||
) | [inline, static, inherited] |
Definition at line 751 of file glue_plus_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().
00755 { 00756 arma_extra_debug_sigprint(); 00757 00758 typedef typename T1::elem_type eT; 00759 00760 const unwrap<T1> tmp1(in.A.A.m); 00761 const unwrap<T2> tmp2(in.A.B.m); 00762 const unwrap<T3> tmp3(in.B.m); 00763 00764 const Mat<eT>& A = tmp1.M; 00765 const Mat<eT>& B = tmp2.M; 00766 const Mat<eT>& C = tmp3.M; 00767 00768 arma_debug_assert_same_size(A, B, "matrix addition"); 00769 arma_debug_assert_same_size(B, C, "matrix addition"); 00770 00771 out.set_size(A.n_rows, A.n_cols); 00772 00773 const eT k1 = in.A.A.aux; 00774 const eT k2 = in.A.B.aux; 00775 const eT k3 = in.B.aux; 00776 00777 eT* out_mem = out.memptr(); 00778 const eT* A_mem = A.mem; 00779 const eT* B_mem = B.mem; 00780 const eT* C_mem = C.mem; 00781 00782 const u32 local_n_elem = A.n_elem; 00783 00784 for(u32 i=0; i<local_n_elem; ++i) 00785 { 00786 out_mem[i] = A_mem[i]/k1 + B_mem[i]/k2 + C_mem[i]/k3; 00787 } 00788 00789 }
void glue_plus::apply_mixed | ( | Mat< typename promote_type< eT1, eT2 >::result > & | out, | |
const Mat< eT1 > & | X, | |||
const Mat< eT2 > & | Y | |||
) | [inline, static, inherited] |
Definition at line 799 of file glue_plus_meat.hpp.
References apply(), 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 operator+().
00800 { 00801 arma_extra_debug_sigprint(); 00802 00803 typedef typename promote_type<eT1,eT2>::result out_eT; 00804 00805 arma_debug_assert_same_size(X,Y, "matrix addition"); 00806 00807 out.set_size(X.n_rows, X.n_cols); 00808 00809 out_eT* out_mem = out.memptr(); 00810 const eT1* X_mem = X.mem; 00811 const eT2* Y_mem = Y.mem; 00812 00813 const u32 n_elem = out.n_elem; 00814 00815 for(u32 i=0; i<n_elem; ++i) 00816 { 00817 out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) + upgrade_val<eT1,eT2>::apply(Y_mem[i]); 00818 } 00819 }
void glue_plus_diag::apply | ( | Mat< typename T1::elem_type > & | out, | |
const T1 & | A, | |||
const Op< T2, op_diagmat > & | B | |||
) | [inline, static, inherited] |
Definition at line 830 of file glue_plus_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_plus_diag::apply().
00831 { 00832 arma_extra_debug_sigprint(); 00833 00834 isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check(); 00835 00836 typedef typename T1::elem_type eT; 00837 00838 const unwrap<T1> tmp1(A_orig); 00839 const unwrap<T2> tmp2(B_orig.m); 00840 00841 const Mat<eT>& A = tmp1.M; 00842 const Mat<eT>& B = tmp2.M; 00843 00844 arma_debug_check( !B.is_square(), "glue_plus_diag::apply(): matrices must be square" ); 00845 arma_debug_assert_same_size(A, B, "matrix addition"); 00846 00847 00848 // no aliasing problem 00849 out.set_size(A.n_rows, A.n_cols); 00850 00851 for(u32 col=0; col<A.n_cols; ++col) 00852 { 00853 for(u32 row=0; row<A.n_rows; ++row) 00854 { 00855 if(col != row) 00856 { 00857 out.at(row,col) = A.at(row,col); 00858 } 00859 else 00860 { 00861 out.at(row,col) = A.at(row,col) + B.at(row,col); 00862 } 00863 } 00864 } 00865 00866 }
void glue_plus_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 873 of file glue_plus_meat.hpp.
References Mat< eT >::at(), Mat< eT >::is_square(), Op< T1, op_type >::m, Mat< eT >::n_cols, Mat< eT >::n_rows, Mat< eT >::set_size(), and Mat< eT >::zeros().
00874 { 00875 arma_extra_debug_sigprint(); 00876 00877 isnt_same_type<typename T1::elem_type, typename T2::elem_type>::check(); 00878 00879 const unwrap<T1> tmp1(A_orig.m); 00880 const unwrap<T2> tmp2(B_orig.m); 00881 00882 typedef typename T1::elem_type eT; 00883 00884 const Mat<eT>& A = tmp1.M; 00885 const Mat<eT>& B = tmp2.M; 00886 00887 arma_debug_check( !A.is_square(), "glue_plus_diag::apply(): matrices must be square" ); 00888 arma_debug_assert_same_size(A, B, "matrix addition"); 00889 00890 00891 if( (&out != &A) && (&out != &B) ) 00892 { 00893 out.zeros(A.n_rows, A.n_cols); 00894 00895 for(u32 i=0; i<A.n_rows; ++i) 00896 { 00897 out.at(i,i) = A.at(i,i) + B.at(i,i); 00898 } 00899 } 00900 else 00901 { 00902 out.set_size(A.n_rows, A.n_cols); 00903 00904 for(u32 col=0; col<A.n_cols; ++col) 00905 { 00906 for(u32 row=0; row<A.n_rows; ++row) 00907 { 00908 if(col != row) 00909 { 00910 out.at(row,col) = 0.0; 00911 } 00912 else 00913 { 00914 out.at(row,col) = A.at(row,col) + B.at(row,col); 00915 } 00916 } 00917 } 00918 } 00919 00920 }
void glue_plus_diag::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< T1, Op< T2, op_diagmat >, glue_plus_diag > & | X | |||
) | [inline, static, inherited] |
Definition at line 927 of file glue_plus_meat.hpp.
References glue_plus_diag::apply().
00928 { 00929 glue_plus_diag::apply(out, X.A, X.B); 00930 }
void glue_plus_diag::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< Op< T1, op_diagmat >, T2, glue_plus_diag > & | X | |||
) | [inline, static, inherited] |
Definition at line 937 of file glue_plus_meat.hpp.
References glue_plus_diag::apply().
00938 { 00939 glue_plus_diag::apply(out, X.B, X.A); // NOTE: arguments are swapped 00940 }
void glue_plus_diag::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< Op< T1, op_diagmat >, Op< T2, op_diagmat >, glue_plus_diag > & | X | |||
) | [inline, static, inherited] |
Definition at line 947 of file glue_plus_meat.hpp.
References glue_plus_diag::apply().
00948 { 00949 glue_plus_diag::apply(out, X.A, X.B); 00950 }