Classes | |
class | glue_div |
Class which implements the immediate element-wise division of two or more matrices. More... | |
Functions | |
template<typename eT > | |
static void | glue_div::apply (Mat< eT > &out, const Mat< eT > &A, const Mat< eT > &B) |
template<typename eT > | |
static void | glue_div::apply (Mat< eT > &out, const Mat< eT > &A, const Mat< eT > &B, const Mat< eT > &C) |
template<typename eT > | |
static void | glue_div::apply (Mat< eT > &out, const Glue< Mat< eT >, Mat< eT >, glue_div > &X) |
template<typename eT > | |
static void | glue_div::apply (Mat< eT > &out, const Glue< Glue< Mat< eT >, Mat< eT >, glue_div >, Mat< eT >, glue_div > &X) |
template<typename T1 , typename T2 > | |
static void | glue_div::apply (Mat< typename T1::elem_type > &out, const Glue< T1, T2, glue_div > &X) |
template<typename eT > | |
static void | glue_div::apply_inplace (Mat< eT > &out, const Mat< eT > &B) |
template<typename T1 , typename op_type > | |
static void | glue_div::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_div::apply_inplace (Mat< typename T1::elem_type > &out, const Glue< T1, T2, glue_type > &X) |
template<typename eT1 , typename eT2 > | |
static void | glue_div::apply_mixed (Mat< typename promote_type< eT1, eT2 >::result > &out, const Mat< eT1 > &X, const Mat< eT2 > &Y) |
void glue_div::apply | ( | Mat< eT > & | out, | |
const Mat< eT > & | A, | |||
const Mat< eT > & | B | |||
) | [inline, static, inherited] |
Definition at line 23 of file glue_div_meat.hpp.
References Mat< eT >::mem, 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().
00024 { 00025 arma_extra_debug_sigprint(); 00026 00027 arma_debug_assert_same_size(A, B, "element-wise matrix division"); 00028 00029 // no aliasing problem 00030 out.set_size(A.n_rows, A.n_cols); 00031 00032 const u32 n_elem = A.n_elem; 00033 00034 for(u32 i=0; i<n_elem; ++i) 00035 { 00036 out[i] = A.mem[i] / B.mem[i]; 00037 } 00038 00039 }
void glue_div::apply | ( | Mat< eT > & | out, | |
const Mat< eT > & | A, | |||
const Mat< eT > & | B, | |||
const Mat< eT > & | C | |||
) | [inline, static, inherited] |
Definition at line 46 of file glue_div_meat.hpp.
References Mat< eT >::mem, Mat< eT >::n_cols, Mat< eT >::n_elem, Mat< eT >::n_rows, and Mat< eT >::set_size().
00047 { 00048 arma_extra_debug_sigprint(); 00049 00050 arma_debug_assert_same_size(A, B, "element-wise matrix division"); 00051 arma_debug_assert_same_size(A, C, "element-wise matrix division"); 00052 00053 // no aliasing problem 00054 out.set_size(A.n_rows, A.n_cols); 00055 00056 const u32 n_elem = A.n_elem; 00057 for(u32 i=0; i != n_elem; ++i) 00058 { 00059 out[i] = A.mem[i] / B.mem[i] / C.mem[i]; 00060 } 00061 00062 }
void glue_div::apply | ( | Mat< eT > & | out, | |
const Glue< Mat< eT >, Mat< eT >, glue_div > & | X | |||
) | [inline, static, inherited] |
Definition at line 69 of file glue_div_meat.hpp.
References apply().
00070 { 00071 glue_div::apply(out, X.A, X.B); 00072 }
void glue_div::apply | ( | Mat< eT > & | out, | |
const Glue< Glue< Mat< eT >, Mat< eT >, glue_div >, Mat< eT >, glue_div > & | X | |||
) | [inline, static, inherited] |
Definition at line 79 of file glue_div_meat.hpp.
References apply().
00080 { 00081 glue_div::apply(out, X.A.A, X.A.B, X.B); 00082 }
void glue_div::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< T1, T2, glue_div > & | X | |||
) | [inline, static, inherited] |
Definition at line 88 of file glue_div_meat.hpp.
References Glue< T1, T2, glue_type >::A, apply(), Glue< T1, T2, glue_type >::B, and Mat< eT >::set_size().
00089 { 00090 arma_extra_debug_sigprint(); 00091 00092 typedef typename T1::elem_type eT; 00093 00094 const u32 N_mat = 1 + depth_lhs< glue_div, Glue<T1,T2,glue_div> >::num; 00095 arma_extra_debug_print( arma_boost::format("N_mat = %d") % N_mat ); 00096 00097 if(N_mat == 2) 00098 { 00099 const unwrap<T1> tmp1(X.A); 00100 const unwrap<T2> tmp2(X.B); 00101 00102 glue_div::apply(out, tmp1.M, tmp2.M); 00103 } 00104 else 00105 { 00106 const Mat<eT>* ptrs[N_mat]; 00107 bool del[N_mat]; 00108 00109 mat_ptrs<glue_div, Glue<T1,T2,glue_div> >::get_ptrs(ptrs, del, X); 00110 //mat_ptrs_outcheck<glue_div, Glue<T1,T2,glue_div> >::get_ptrs(ptrs, del, X, &out); 00111 00112 for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format("ptrs[%d] = %x") % i % ptrs[i] ); 00113 for(u32 i=0; i<N_mat; ++i) arma_extra_debug_print( arma_boost::format(" del[%d] = %d") % i % del[i] ); 00114 00115 const Mat<eT>& tmp_mat = *(ptrs[0]); 00116 00117 for(u32 i=1; i<N_mat; ++i) 00118 { 00119 arma_debug_assert_same_size(tmp_mat, *(ptrs[i]), "element-wise matrix division"); 00120 } 00121 00122 00123 const u32 n_rows = ptrs[0]->n_rows; 00124 const u32 n_cols = ptrs[0]->n_cols; 00125 00126 // no aliasing problem 00127 out.set_size(n_rows,n_cols); 00128 00129 const u32 n_elem = ptrs[0]->n_elem; 00130 00131 for(u32 j=0; j<n_elem; ++j) 00132 { 00133 eT acc = ptrs[0]->mem[j]; 00134 00135 for(u32 i=1; i<N_mat; ++i) 00136 { 00137 acc /= ptrs[i]->mem[j]; 00138 } 00139 00140 out[j] = acc; 00141 } 00142 00143 00144 for(u32 i=0; i<N_mat; ++i) 00145 { 00146 if(del[i] == true) 00147 { 00148 arma_extra_debug_print( arma_boost::format("delete ptrs[%d]") % i ); 00149 delete ptrs[i]; 00150 } 00151 } 00152 00153 } 00154 }
void glue_div::apply_inplace | ( | Mat< eT > & | out, | |
const Mat< eT > & | B | |||
) | [inline, static, inherited] |
Definition at line 161 of file glue_div_meat.hpp.
References Mat< eT >::mem, and Mat< eT >::n_elem.
Referenced by Mat< eT >::operator/=().
00162 { 00163 arma_extra_debug_sigprint(); 00164 00165 arma_debug_assert_same_size(out, B, "element-wise matrix division"); 00166 00167 const u32 n_elem = out.n_elem; 00168 00169 for(u32 i=0; i<n_elem; ++i) 00170 { 00171 out[i] /= B.mem[i]; 00172 } 00173 00174 }
void glue_div::apply_inplace | ( | Mat< typename T1::elem_type > & | out, | |
const Op< T1, op_type > & | X | |||
) | [inline, static, inherited] |
Definition at line 181 of file glue_div_meat.hpp.
References apply().
00182 { 00183 arma_extra_debug_sigprint(); 00184 00185 typedef typename T1::elem_type eT; 00186 00187 const Mat<eT> tmp(X); 00188 glue_div::apply(out, out, tmp); 00189 }
void glue_div::apply_inplace | ( | Mat< typename T1::elem_type > & | out, | |
const Glue< T1, T2, glue_type > & | X | |||
) | [inline, static, inherited] |
Definition at line 196 of file glue_div_meat.hpp.
References apply().
00197 { 00198 arma_extra_debug_sigprint(); 00199 00200 typedef typename T1::elem_type eT; 00201 00202 const Mat<eT> tmp(X); 00203 glue_div::apply(out, X, out); 00204 }
void glue_div::apply_mixed | ( | Mat< typename promote_type< eT1, eT2 >::result > & | out, | |
const Mat< eT1 > & | X, | |||
const Mat< eT2 > & | Y | |||
) | [inline, static, inherited] |
Definition at line 214 of file glue_div_meat.hpp.
References apply(), Mat< eT >::mem, Mat< eT >::n_cols, and Mat< eT >::n_rows.
Referenced by operator/().
00215 { 00216 arma_extra_debug_sigprint(); 00217 00218 typedef typename promote_type<eT1,eT2>::result out_eT; 00219 00220 arma_debug_assert_same_size(X,Y, "element-wise matrix division"); 00221 00222 out.set_size(X.n_rows, X.n_cols); 00223 00224 out_eT* out_mem = out.memptr(); 00225 const eT1* X_mem = X.mem; 00226 const eT2* Y_mem = Y.mem; 00227 00228 const u32 n_elem = out.n_elem; 00229 00230 for(u32 i=0; i<n_elem; ++i) 00231 { 00232 out_mem[i] = upgrade_val<eT1,eT2>::apply(X_mem[i]) / upgrade_val<eT1,eT2>::apply(Y_mem[i]); 00233 } 00234 }