Classes | |
class | op_find |
Functions | |
template<typename T1 > | |
static u32 | op_find::helper (Mat< u32 > &indices, const Base< typename T1::elem_type, T1 > &X) |
template<typename T1 , typename op_type > | |
static u32 | op_find::helper (Mat< u32 > &indices, const mtOp< u32, T1, op_type > &X, const typename arma_op_rel_only< op_type >::result junk1=0, const typename arma_not_cx< typename T1::elem_type >::result junk2=0) |
template<typename T1 , typename op_type > | |
static u32 | op_find::helper (Mat< u32 > &indices, const mtOp< u32, T1, op_type > &X, const typename arma_op_rel_only< op_type >::result junk1=0, const typename arma_cx_only< typename T1::elem_type >::result junk2=0) |
template<typename T1 , typename T2 , typename glue_type > | |
static u32 | op_find::helper (Mat< u32 > &indices, const mtGlue< u32, T1, T2, glue_type > &X, const typename arma_glue_rel_only< glue_type >::result junk1=0, const typename arma_not_cx< typename T1::elem_type >::result junk2=0, const typename arma_not_cx< typename T2::elem_type >::result junk3=0) |
template<typename T1 , typename T2 , typename glue_type > | |
static u32 | op_find::helper (Mat< u32 > &indices, const mtGlue< u32, T1, T2, glue_type > &X, const typename arma_glue_rel_only< glue_type >::result junk1=0, const typename arma_cx_only< typename T1::elem_type >::result junk2=0, const typename arma_cx_only< typename T2::elem_type >::result junk3=0) |
template<typename T1 > | |
static void | op_find::apply (Mat< u32 > &out, const mtOp< u32, T1, op_find > &X) |
u32 op_find::helper | ( | Mat< u32 > & | indices, | |
const Base< typename T1::elem_type, T1 > & | X | |||
) | [inline, static, inherited] |
Definition at line 28 of file op_find_meat.hpp.
References Base< elem_type, derived >::get_ref(), Mat< eT >::memptr(), and Mat< eT >::set_size().
Referenced by apply().
00032 { 00033 arma_extra_debug_sigprint(); 00034 00035 typedef typename T1::elem_type eT; 00036 00037 const Proxy<T1> P(X.get_ref()); 00038 00039 const u32 n_elem = P.n_elem; 00040 00041 indices.set_size(n_elem, 1); 00042 00043 u32* indices_mem = indices.memptr(); 00044 u32 n_nz = 0; 00045 00046 for(u32 i=0; i<n_elem; ++i) 00047 { 00048 if(P[i] != eT(0)) 00049 { 00050 indices_mem[n_nz] = i; 00051 ++n_nz; 00052 } 00053 } 00054 00055 return n_nz; 00056 }
u32 op_find::helper | ( | Mat< u32 > & | indices, | |
const mtOp< u32, T1, op_type > & | X, | |||
const typename arma_op_rel_only< op_type >::result | junk1 = 0 , |
|||
const typename arma_not_cx< typename T1::elem_type >::result | junk2 = 0 | |||
) | [inline, static, inherited] |
Definition at line 64 of file op_find_meat.hpp.
References mtOp< out_eT, T1, op_type >::aux, mtOp< out_eT, T1, op_type >::m, Mat< eT >::memptr(), and Mat< eT >::set_size().
00070 { 00071 arma_extra_debug_sigprint(); 00072 00073 typedef typename T1::elem_type eT; 00074 00075 const eT val = X.aux; 00076 00077 const Proxy<T1> P(X.m); 00078 00079 const u32 n_elem = P.n_elem; 00080 00081 indices.set_size(n_elem, 1); 00082 00083 u32* indices_mem = indices.memptr(); 00084 u32 n_nz = 0; 00085 00086 for(u32 i=0; i<n_elem; ++i) 00087 { 00088 const eT tmp = P[i]; 00089 00090 bool not_zero; 00091 00092 if(is_same_type<op_type, op_rel_lt_pre >::value == true) { not_zero = (val < tmp); } 00093 else if(is_same_type<op_type, op_rel_lt_post >::value == true) { not_zero = (tmp < val); } 00094 else if(is_same_type<op_type, op_rel_gt_pre >::value == true) { not_zero = (val > tmp); } 00095 else if(is_same_type<op_type, op_rel_gt_post >::value == true) { not_zero = (tmp > val); } 00096 else if(is_same_type<op_type, op_rel_lteq_pre >::value == true) { not_zero = (val <= tmp); } 00097 else if(is_same_type<op_type, op_rel_lteq_post>::value == true) { not_zero = (tmp <= val); } 00098 else if(is_same_type<op_type, op_rel_gteq_pre >::value == true) { not_zero = (val >= tmp); } 00099 else if(is_same_type<op_type, op_rel_gteq_post>::value == true) { not_zero = (tmp >= val); } 00100 else if(is_same_type<op_type, op_rel_eq >::value == true) { not_zero = (tmp == val); } 00101 else if(is_same_type<op_type, op_rel_noteq >::value == true) { not_zero = (tmp != val); } 00102 else not_zero = false; 00103 00104 if(not_zero == true) 00105 { 00106 indices_mem[n_nz] = i; 00107 ++n_nz; 00108 } 00109 } 00110 00111 return n_nz; 00112 }
u32 op_find::helper | ( | Mat< u32 > & | indices, | |
const mtOp< u32, T1, op_type > & | X, | |||
const typename arma_op_rel_only< op_type >::result | junk1 = 0 , |
|||
const typename arma_cx_only< typename T1::elem_type >::result | junk2 = 0 | |||
) | [inline, static, inherited] |
Definition at line 120 of file op_find_meat.hpp.
References mtOp< out_eT, T1, op_type >::aux, mtOp< out_eT, T1, op_type >::m, Mat< eT >::memptr(), and Mat< eT >::set_size().
00126 { 00127 arma_extra_debug_sigprint(); 00128 00129 typedef typename T1::elem_type eT; 00130 00131 const eT val = X.aux; 00132 00133 const Proxy<T1> P(X.m); 00134 00135 const u32 n_elem = P.n_elem; 00136 00137 indices.set_size(n_elem, 1); 00138 00139 u32* indices_mem = indices.memptr(); 00140 u32 n_nz = 0; 00141 00142 for(u32 i=0; i<n_elem; ++i) 00143 { 00144 const eT tmp = P[i]; 00145 00146 bool not_zero; 00147 00148 if(is_same_type<op_type, op_rel_eq >::value == true) { not_zero = (tmp == val); } 00149 else if(is_same_type<op_type, op_rel_noteq>::value == true) { not_zero = (tmp != val); } 00150 else not_zero = false; 00151 00152 if(not_zero == true) 00153 { 00154 indices_mem[n_nz] = i; 00155 ++n_nz; 00156 } 00157 } 00158 00159 return n_nz; 00160 }
u32 op_find::helper | ( | Mat< u32 > & | indices, | |
const mtGlue< u32, T1, T2, glue_type > & | X, | |||
const typename arma_glue_rel_only< glue_type >::result | junk1 = 0 , |
|||
const typename arma_not_cx< typename T1::elem_type >::result | junk2 = 0 , |
|||
const typename arma_not_cx< typename T2::elem_type >::result | junk3 = 0 | |||
) | [inline, static, inherited] |
Definition at line 168 of file op_find_meat.hpp.
References mtGlue< out_eT, T1, T2, glue_type >::A, mtGlue< out_eT, T1, T2, glue_type >::B, Mat< eT >::memptr(), and Mat< eT >::set_size().
00175 { 00176 arma_extra_debug_sigprint(); 00177 00178 typedef typename T1::elem_type eT1; 00179 typedef typename T2::elem_type eT2; 00180 00181 const Proxy<T1> A(X.A); 00182 const Proxy<T2> B(X.B); 00183 00184 arma_debug_assert_same_size(A, B, "relational operator"); 00185 00186 const u32 n_elem = A.n_elem; 00187 00188 indices.set_size(n_elem, 1); 00189 00190 u32* indices_mem = indices.memptr(); 00191 u32 n_nz = 0; 00192 00193 for(u32 i=0; i<n_elem; ++i) 00194 { 00195 const eT1 tmp1 = A[i]; 00196 const eT1 tmp2 = B[i]; 00197 00198 bool not_zero; 00199 00200 if(is_same_type<glue_type, glue_rel_lt >::value == true) { not_zero = (tmp1 < tmp2); } 00201 else if(is_same_type<glue_type, glue_rel_gt >::value == true) { not_zero = (tmp1 > tmp2); } 00202 else if(is_same_type<glue_type, glue_rel_lteq >::value == true) { not_zero = (tmp1 <= tmp2); } 00203 else if(is_same_type<glue_type, glue_rel_gteq >::value == true) { not_zero = (tmp1 >= tmp2); } 00204 else if(is_same_type<glue_type, glue_rel_eq >::value == true) { not_zero = (tmp1 == tmp2); } 00205 else if(is_same_type<glue_type, glue_rel_noteq >::value == true) { not_zero = (tmp1 != tmp2); } 00206 else not_zero = false; 00207 00208 if(not_zero == true) 00209 { 00210 indices_mem[n_nz] = i; 00211 ++n_nz; 00212 } 00213 } 00214 00215 return n_nz; 00216 }
u32 op_find::helper | ( | Mat< u32 > & | indices, | |
const mtGlue< u32, T1, T2, glue_type > & | X, | |||
const typename arma_glue_rel_only< glue_type >::result | junk1 = 0 , |
|||
const typename arma_cx_only< typename T1::elem_type >::result | junk2 = 0 , |
|||
const typename arma_cx_only< typename T2::elem_type >::result | junk3 = 0 | |||
) | [inline, static, inherited] |
Definition at line 224 of file op_find_meat.hpp.
References mtGlue< out_eT, T1, T2, glue_type >::A, mtGlue< out_eT, T1, T2, glue_type >::B, Mat< eT >::memptr(), and Mat< eT >::set_size().
00231 { 00232 arma_extra_debug_sigprint(); 00233 00234 const Proxy<T1> A(X.A); 00235 const Proxy<T2> B(X.B); 00236 00237 arma_debug_assert_same_size(A, B, "relational operator"); 00238 00239 const u32 n_elem = A.n_elem; 00240 00241 indices.set_size(n_elem, 1); 00242 00243 u32* indices_mem = indices.memptr(); 00244 u32 n_nz = 0; 00245 00246 for(u32 i=0; i<n_elem; ++i) 00247 { 00248 bool not_zero; 00249 00250 if(is_same_type<glue_type, glue_rel_eq >::value == true) { not_zero = (A[i] == B[i]); } 00251 else if(is_same_type<glue_type, glue_rel_noteq >::value == true) { not_zero = (A[i] != B[i]); } 00252 else not_zero = false; 00253 00254 if(not_zero == true) 00255 { 00256 indices_mem[n_nz] = i; 00257 ++n_nz; 00258 } 00259 } 00260 00261 return n_nz; 00262 }
void op_find::apply | ( | Mat< u32 > & | out, | |
const mtOp< u32, T1, op_find > & | X | |||
) | [inline, static, inherited] |
Definition at line 269 of file op_find_meat.hpp.
References mtOp< out_eT, T1, op_type >::aux_u32_a, mtOp< out_eT, T1, op_type >::aux_u32_b, helper(), mtOp< out_eT, T1, op_type >::m, Mat< eT >::reset(), and Mat< eT >::rows().
00270 { 00271 arma_extra_debug_sigprint(); 00272 00273 const u32 k = X.aux_u32_a; 00274 const u32 type = X.aux_u32_b; 00275 00276 Mat<u32> indices; 00277 const u32 n_nz = op_find::helper(indices, X.m); 00278 00279 if(n_nz > 0) 00280 { 00281 if(type == 0) // "first" 00282 { 00283 out = (k > 0 && k <= n_nz) ? indices.rows(0, k-1 ) : indices.rows(0, n_nz-1); 00284 } 00285 else // "last" 00286 { 00287 out = (k > 0 && k <= n_nz) ? indices.rows(n_nz-k, n_nz-1) : indices.rows(0, n_nz-1); 00288 } 00289 } 00290 else 00291 { 00292 out.reset(); 00293 } 00294 }