10#ifndef XTENSOR_XSET_OPERATION_HPP
11#define XTENSOR_XSET_OPERATION_HPP
17#include <xtl/xsequence.hpp>
19#include "xfunction.hpp"
22#include "xstrided_view.hpp"
23#include "xstrides.hpp"
32 template <
bool lvalue>
36 static auto make(E&& e)
38 return [&e](
const auto& t)
40 return std::find(e.begin(), e.end(), t) != e.end();
46 struct lambda_isin<false>
49 static auto make(E&& e)
51 return [e](
const auto& t)
53 return std::find(e.begin(), e.end(), t) != e.end();
70 template <
class E,
class T>
90 template <class E, class F, class = typename std::enable_if_t<has_iterator_interface<F>::value>>
93 auto lambda = detail::lambda_isin<std::is_lvalue_reference<F>::value>::make(std::forward<F>(
test_elements
109 template <class E, class I, class = typename std::enable_if_t<is_iterator<I>::value>>
129 template <
class E,
class T>
132 XTENSOR_ASSERT(element.dimension() == 1ul);
133 return isin(std::forward<E>(element), std::forward<std::initializer_list<T>>(
test_elements));
146 template <class E, class F, class = typename std::enable_if_t<has_iterator_interface<F>::value>>
149 XTENSOR_ASSERT(element.dimension() == 1ul);
165 template <class E, class I, class = typename std::enable_if_t<is_iterator<I>::value>>
168 XTENSOR_ASSERT(element.dimension() == 1ul);
170 std::forward<E>(element),
185 template <
class E1,
class E2>
188 XTENSOR_ASSERT(std::is_sorted(
a.cbegin(),
a.cend()));
194 for (
size_t i = 0;
i <
v.size(); ++
i)
196 out(
i) =
static_cast<std::size_t
>(std::lower_bound(
a.cbegin(),
a.cend(),
v(
i)) -
a.cbegin());
201 for (
size_t i = 0;
i <
v.size(); ++
i)
203 out(
i) =
static_cast<std::size_t
>(std::upper_bound(
a.cbegin(),
a.cend(),
v(
i)) -
a.cbegin());
auto in1d(E &&element, std::initializer_list< T > test_elements) noexcept
in1d
auto isin(E &&element, std::initializer_list< T > test_elements) noexcept
isin
standard mathematical functions for xexpressions
auto make_lambda_xfunction(F &&lambda, E &&... args)
Create a xfunction from a lambda.
auto searchsorted(E1 &&a, E2 &&v, bool right=true)
Find indices where elements should be inserted to maintain order.