diff --git a/include/armadillo_bits/op_find_meat.hpp b/include/armadillo_bits/op_find_meat.hpp index d3a4087b..4de74b66 100644 --- a/include/armadillo_bits/op_find_meat.hpp +++ b/include/armadillo_bits/op_find_meat.hpp @@ -324,24 +324,57 @@ op_find::helper uword* indices_mem = indices.memptr(); uword n_nz = 0; - for(uword i=0; i::use_at == false) && (Proxy::use_at == false)) { - const eT1 tmp1 = PA[i]; - const eT2 tmp2 = PB[i]; + for(uword i=0; i::yes) { not_zero = (tmp1 < tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 > tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 <= tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 >= tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 == tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 != tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 && tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 || tmp2); } + else { not_zero = false; } + + if(not_zero) { indices_mem[n_nz] = i; ++n_nz; } + } + } + else + { + const uword n_rows = A.get_n_rows(); + const uword n_cols = A.get_n_cols(); - bool not_zero; + uword i = 0; - if(is_same_type::yes) { not_zero = (tmp1 < tmp2); } - else if(is_same_type::yes) { not_zero = (tmp1 > tmp2); } - else if(is_same_type::yes) { not_zero = (tmp1 <= tmp2); } - else if(is_same_type::yes) { not_zero = (tmp1 >= tmp2); } - else if(is_same_type::yes) { not_zero = (tmp1 == tmp2); } - else if(is_same_type::yes) { not_zero = (tmp1 != tmp2); } - else if(is_same_type::yes) { not_zero = (tmp1 && tmp2); } - else if(is_same_type::yes) { not_zero = (tmp1 || tmp2); } - else { not_zero = false; } - - if(not_zero) { indices_mem[n_nz] = i; ++n_nz; } + for(uword col=0; col < n_cols; ++col) + for(uword row=0; row < n_rows; ++row) + { + const eT1 tmp1 = A.at(row,col); + const eT2 tmp2 = B.at(row,col); + + bool not_zero; + + if(is_same_type::yes) { not_zero = (tmp1 < tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 > tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 <= tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 >= tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 == tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 != tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 && tmp2); } + else if(is_same_type::yes) { not_zero = (tmp1 || tmp2); } + else { not_zero = false; } + + if(not_zero) { indices_mem[n_nz] = i; ++n_nz; } + + i++; + } } return n_nz; @@ -385,7 +418,7 @@ op_find::helper uword n_nz = 0; - if(Proxy::use_at == false) + if((Proxy::use_at == false) && (Proxy::use_at == false)) { for(uword i=0; i