| 33 | |
| 34 | template <typename DataT> |
| 35 | struct SelectImpl |
| 36 | { |
| 37 | DataT m_value, m_epsilon; |
| 38 | SelectImpl(DataT const& value, DataT const& epsilon) |
| 39 | : m_value(value), m_epsilon(epsilon) |
| 40 | {} |
| 41 | |
| 42 | DataT operator()(DataT const& predicate, |
| 43 | DataT const& iftrue, |
| 44 | DataT const& iffalse) const noexcept |
| 45 | { |
| 46 | bool istrue = std::fabs(predicate - m_value) < m_epsilon; |
| 47 | return istrue ? iftrue : iffalse; |
| 48 | } |
| 49 | void operator()(DataT const& predicate, |
| 50 | DataT const& iftrue, |
| 51 | DataT const& iffalse, |
| 52 | DataT const& dy, |
| 53 | DataT& dpredicate, |
| 54 | DataT& diftrue, |
| 55 | DataT& diffalse) const noexcept |
| 56 | { |
| 57 | bool istrue = std::fabs(predicate - m_value) < m_epsilon; |
| 58 | diftrue = istrue ? dy : El::TypeTraits<DataT>::Zero(); |
| 59 | diffalse = istrue ? El::TypeTraits<DataT>::Zero() : dy; |
| 60 | dpredicate = El::TypeTraits<DataT>::Zero(); |
| 61 | } |
| 62 | }; |
| 63 | |
| 64 | template <typename DataT> |
| 65 | struct SelectImplIfTrue |
no outgoing calls
no test coverage detected