#include <eve/module/core.hpp>
#include <tts/tts.hpp>
template<typename T>
void how_to_keep_track_of_index();
int main()
{
how_to_keep_track_of_index();
{
i32s expected {0, 1, 2, 3};
TTS_EXPECT(
eve::all(expected == actual));
}
{
f64s expected {0.0, 1.0, 2.0, 3.0};
TTS_EXPECT(
eve::all(expected == actual));
}
{
static_assert(!iota_supports<eve::logical<i32s>>);
static_assert(!iota_supports<eve::logical<int>>);
}
{
TTS_EXPECT(
eve::all(actual0 == i32s {0, 1, 0, 0}));
TTS_EXPECT(
eve::all(actual1 == i32s {0, 1, 5, 5}));
const auto m = eve::logical<i32s> {true, true, false, false};
TTS_EXPECT(
eve::all(actual2 == i32s {0, 1, 0, 0}));
TTS_EXPECT(
eve::all(actual3 == i32s {0, 1, 5, 5}));
}
}
#include <eve/module/algo.hpp>
void
how_to_keep_track_of_index()
{
{
std::vector<int> v;
v.resize(10);
eve::views::iota(0), v, [](
eve::like<int> auto idx) {
return idx + idx; });
TTS_EQUAL(v, std::vector<int>({0, 2, 4, 6, 8, 10, 12, 14, 16, 18}));
}
{
std::vector<int> v(5u, 1);
v,
[](auto input_idx)
{
auto [input, idx] = input_idx;
return input << idx;
});
TTS_EQUAL(v, std::vector<int>({1, 2, 4, 8, 16}));
}
{
std::vector<int> v(5u, 1);
{
auto [elements_it, index_it] = it;
elements <<= idxs;
});
TTS_EQUAL(v, std::vector<int>({1, 2, 4, 8, 16}));
}
}
Specifies semantic compatibility between wrapper/wrapped types.
Definition product_type.hpp:107
Specifies that a type is a Conditional Expression using relative mask.
Definition conditional.hpp:52
constexpr auto for_each
a basic for_each algorithm.
Definition for_each.hpp:73
constexpr auto transform_to
SIMD version of std::transform.
Definition transform.hpp:112
constexpr auto iota
all numbers from 0 to size() - 1. equivalent to T{ [](int i, int) {return i; } }
Definition iota.hpp:69
constexpr callable_all_ all
Computes a bool value which is true if and only if all elements of x are not zero.
Definition all.hpp:58
constexpr callable_store_ store
Callable object computing //! description NOT FOUND.
Definition store.hpp:73
SIMD register cardinal type.
Definition cardinal.hpp:15
auto else_(V const &v) const
Extends a conditional expression with an alternative value.
Definition conditional.hpp:111
Extensible wrapper for SIMD conditional.
Definition compress_copy_scalar.hpp:16
constexpr auto else_(V const &v) const
Extends a conditional expression with an alternative value.
Definition conditional.hpp:317
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition conditional.hpp:332
Wrapper for SIMD registers.
Definition wide.hpp:86