Index related functions — xtensor documentation (original) (raw)
- Mathematical functions
- Index related functions
- View page source
Defined in xtensor/core/xoperation.hpp
template<class T>
inline auto xt::where(const T &condition)
return vector of indices where condition is true (equivalent to nonzero(condition))
Parameters:
condition – input array
Returns:
vector of index_types where condition is not equal to zero
template<class T>
inline auto xt::nonzero(const T &arr)
return vector of indices where T is not zero
Parameters:
arr – input array
Returns:
vector of vectors, one for each dimension of arr, containing the indices of the non-zero elements in that dimension
template<layout_type L = ::xt::layout_type::row_major, class T>
inline auto xt::argwhere(const T &arr)
return vector of indices where arr is not zero
Template Parameters:
L – the traversal order
Parameters:
arr – input array
Returns:
vector of index_types where arr is not equal to zero (use [xt::from_indices](xtensor.html#namespacext%5F1ade2d67c70b0ec6af8294f4b7f201a722) to convert)
template<class T>
inline auto xt::from_indices(const std::vector<T> &idx)
Converts std::vector<index_type> (returned e.g.
from [xt::argwhere](#group%5F%5Flogical%5F%5Foperators%5F1ga8e8213a0ec55abe31dc046b6a03379d7)) to xtensor.
Parameters:
idx – vector of indices
Returns:
[xt::xtensor](xtensor.html#namespacext%5F1a29d0a2d76c0f69cf43aa3b4f55a7a26d)<typename index_type::value_type, 2> (e.g. [xt::xtensor](xtensor.html#namespacext%5F1a29d0a2d76c0f69cf43aa3b4f55a7a26d)<size_t, 2>)