find_idx#
Finds values in an operator based on a selection operator and returns the indices where the value is. Users can define their own custom comparator function or choose from a built-in set of common comparators. The indices meeting the selection criteria are returned in a_out, while the number of elements found are in num_found. It’s important that a_out is sized large enough to store all elements found or the behavior is undefined.
-
template<typename OpA, typename SelectType>
__MATX_INLINE__ auto matx::find_idx(const OpA &a, SelectType sel)# Reduce indices that meet a certain criteria
Finds all indices of values meeting the criteria specified in SelectOp, and saves them out to an output operator. This function is different from the MatX IF operator in that this performs a reduction on the input, whereas IF is only for element-wise output. Output tensor must be large enough to hold unique entries. To be safe, this can be the same size as the input, but if something is known about the data to indicate not as many entries are needed, the output can be smaller.
- Template Parameters:
SelectType – Type of select functor
InputOperator – Input type
- Parameters:
a – Input tensor
sel – Select functor
Examples#
// Find indices with values greater than 0.5
TestType thresh = (TestType)0.5;
(mtie(t1o, num_found) = find_idx(t1, GT{thresh})).run(exec);