55template <std::ranges::view urng_t, simd::simd_concept simd_t>
56class view_to_simd :
public std::ranges::view_interface<view_to_simd<urng_t, simd_t>>
59 static_assert(std::ranges::forward_range<urng_t>,
"The underlying range must model forward_range.");
60 static_assert(std::ranges::input_range<std::ranges::range_value_t<urng_t>>,
61 "Expects the value type of the underlying range to be an input_range.");
62 static_assert(std::default_initializable<std::ranges::iterator_t<std::ranges::range_value_t<urng_t>>>,
63 "Expects the inner range iterator to be default initializable.");
64 static_assert(std::default_initializable<std::ranges::sentinel_t<std::ranges::range_value_t<urng_t>>>,
65 "Expects the inner range sentinel to be default initializable.");
67 "Expects semi-alphabet as value type of the inner range.");
84 std::ranges::contiguous_range<inner_range_type>
85 && std::sized_sentinel_for<std::ranges::iterator_t<inner_range_type>, std::ranges::sentinel_t<inner_range_type>>
125 throw std::invalid_argument{
"The size of the underlying range must be less than or equal to the size of "
126 "the given simd type!"};
130 template <
typename other_urng_t>
131 requires (!std::same_as<std::remove_cvref_t<other_urng_t>,
view_to_simd>)
132 && (!std::same_as<other_urng_t, urng_t>) && std::ranges::viewable_range<other_urng_t>
153 return std::default_sentinel;
167 return std::ranges::empty(
rng);
181 [](
auto &
lhs,
auto &
rhs)
183 return std::ranges::size(
lhs) < std::ranges::size(
rhs);
203template <std::ranges::view urng_t, simd::simd_concept simd_t>
243 cached_sentinel[
seq_id] = std::ranges::end(*
it);
253 auto sentinel_it = std::ranges::next(cached_iter[0], cached_sentinel[0]);
257 cached_sentinel[
seq_id] = cached_sentinel[0];
261 final_chunk = all_iterators_reached_sentinel();
274 assert(this_view !=
nullptr);
275 return std::span{this_view->cached_simd_chunks[current_chunk_pos].
begin(),
276 (current_chunk_pos == final_chunk_pos) ? final_chunk_size :
chunk_size};
288 if (current_chunk_pos == final_chunk_pos)
291 current_chunk_pos = 0;
319 constexpr bool operator==(std::default_sentinel_t
const &)
const noexcept
331 constexpr bool operator!=(std::default_sentinel_t
const &)
const noexcept
399 return (
vec == simd::fill<simd_t>(
static_cast<uint8_t
>(~0))) ? this_view->padding_simd_vector :
vec;
454 if (cached_iter[
idx] == cached_sentinel[
idx])
477 template <
typename array_t>
497 at_end = final_chunk;
539 matrix[pos] = simd::fill<max_simd_type>(~0);
548 final_chunk = all_iterators_reached_sentinel();
554 split_into_sub_matrices(std::move(
matrix));
561 at_end = final_chunk;
567 this_view->cached_simd_chunks[0][
i] = convert_single_column();
569 final_chunk = all_iterators_reached_sentinel();
586 uint8_t current_chunk_pos{0};
588 bool final_chunk{
true};
605template <simd::simd_concept simd_t>
630 template <std::ranges::range urng_t>
633 static_assert(std::ranges::forward_range<urng_t>,
634 "The underlying range in views::to_simd must model std::ranges::forward_range.");
635 static_assert(std::ranges::viewable_range<urng_t>,
636 "The underlying range in views::to_simd must model std::ranges::viewable_range.");
637 static_assert(std::ranges::input_range<std::ranges::range_value_t<urng_t>>,
638 "The value type of the underlying range must model std::ranges::input_range.");
640 "The value type of the inner ranges must model seqan3::semialphabet.");
649 template <std::ranges::range urng_t>
652 static_assert(std::ranges::forward_range<urng_t>,
653 "The underlying range in views::to_simd must model std::ranges::forward_range.");
654 static_assert(std::ranges::viewable_range<urng_t>,
655 "The underlying range in views::to_simd must model std::ranges::viewable_range.");
656 static_assert(std::ranges::input_range<std::ranges::range_value_t<urng_t>>,
657 "The value type of the underlying range must model std::ranges::input_range.");
659 "The value type of the inner ranges must model seqan3::semialphabet.");
665 template <std::ranges::range urng_t>
668 return me(std::forward<urng_t>(urange));
778template <simd::simd_concept simd_t>
Provides seqan3::detail::adaptor_from_functor.
Provides algorithms to modify seqan3::simd::simd_type.
Core alphabet concept and free function/type trait wrappers.
Template for range adaptor closure objects that store arguments and wrap a proto-adaptor.
Definition adaptor_from_functor.hpp:54
Defines the requirements of a matrix (e.g. score matrices, trace matrices).
Definition matrix_concept.hpp:52
Iterator that transposes the underlying range of ranges and transforms that to SIMD types.
Definition to_simd.hpp:205
auto unpack(max_simd_type const &row) const
Unpacks one row of the transposed byte matrix using simd instructions.
Definition to_simd.hpp:354
ptrdiff_t difference_type
The difference type.
Definition to_simd.hpp:213
constexpr void update_final_chunk_position(array_t const &iterators_before_update) noexcept
Updates the end of the final chunk and sets the index of the final chunk.
Definition to_simd.hpp:478
constexpr void split_into_sub_matrices(std::array< max_simd_type, simd_traits< max_simd_type >::length > matrix) const
Unpacks the matrix of simd types and caches the respective chunk entries.
Definition to_simd.hpp:395
constexpr iterator_type & operator=(iterator_type &&)=default
Defaulted.
void pointer
The pointer type.
Definition to_simd.hpp:212
constexpr value_type operator++(int)
Advances the iterator to the next chunk and returns the previous pointed-to value.
Definition to_simd.hpp:307
friend constexpr bool operator!=(std::default_sentinel_t const &, iterator_type const &rhs) noexcept
Returns true if iterator did not reach the end yet, otherwise false.
Definition to_simd.hpp:337
constexpr bool all_iterators_reached_sentinel() const noexcept
Checks if all sequence iterators reached the end.
Definition to_simd.hpp:428
constexpr simd_t convert_single_column() noexcept
Convert a single column into a simd vector.
Definition to_simd.hpp:449
constexpr bool operator!=(std::default_sentinel_t const &) const noexcept
Returns true if iterator did not reach the end yet, otherwise false.
Definition to_simd.hpp:331
~iterator_type()=default
Defaulted.
constexpr iterator_type(iterator_type &&)=default
Defaulted.
constexpr void underflow()
Fetches the next available chunk(s).
Definition to_simd.hpp:494
constexpr iterator_type()=default
Defaulted.
constexpr reference operator*() const noexcept
Returns a reference to the current chunk of simd vectors.
Definition to_simd.hpp:272
constexpr iterator_type(view_to_simd &this_view)
Construction from the associated range.
Definition to_simd.hpp:236
friend constexpr bool operator==(std::default_sentinel_t const &, iterator_type const &rhs) noexcept
Returns true if iterator reached the end, otherwise false.
Definition to_simd.hpp:325
constexpr iterator_type & operator=(iterator_type const &)=default
Defaulted.
constexpr bool operator==(std::default_sentinel_t const &) const noexcept
Returns true if iterator reached the end, otherwise false.
Definition to_simd.hpp:319
constexpr iterator_type & operator++()
Advances the iterator to the next chunk.
Definition to_simd.hpp:284
constexpr iterator_type(iterator_type const &)=default
Defaulted.
constexpr void underflow()
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition to_simd.hpp:558
Transforms a range of ranges into chunks of seqan3::simd vectors.
Definition to_simd.hpp:57
constexpr iterator_type begin() noexcept
The iterator to begin of this range.
Definition to_simd.hpp:142
static constexpr uint8_t chunk_size
The size of one chunk. Equals the number of elements in the simd vector.
Definition to_simd.hpp:89
scalar_type padding_value
The padding value used to fill the corresponding simd vector element.
Definition to_simd.hpp:193
constexpr std::default_sentinel_t end() noexcept
A sentinel representing the end of this range.
Definition to_simd.hpp:151
constexpr bool empty() const noexcept
Checks whether the range is empty.
Definition to_simd.hpp:161
static constexpr bool fast_load
Check if fast load is enabled.
Definition to_simd.hpp:83
static constexpr uint8_t total_chunks
The total number of chunks that can be cached.
Definition to_simd.hpp:93
constexpr size_t size() const noexcept
Returns the size of this range.
Definition to_simd.hpp:177
constexpr void end() const noexcept=delete
Const iteration is disabled.
static constexpr uint8_t chunks_per_load
The number of chunks that can be gathered with a single load.
Definition to_simd.hpp:91
simd_t padding_simd_vector
A cached simd vector with the padding symbol.
Definition to_simd.hpp:192
static constexpr auto alphabet_size
The alphabet size.
Definition to_simd.hpp:95
std::ranges::range_reference_t< urng_t > inner_range_type
The inner range type.
Definition to_simd.hpp:72
constexpr view_to_simd()=default
Defaulted.
urng_t urng
The underlying range.
Definition to_simd.hpp:190
std::array< chunk_type, total_chunks > cached_simd_chunks
The cached chunks of transformed simd vectors.
Definition to_simd.hpp:191
constexpr void begin() const noexcept=delete
Const iteration is disabled.
simd_type_t< uint8_t, simd_traits< simd_t >::max_length > max_simd_type
The SIMD type with maximal number of lanes for the current arch.
Definition to_simd.hpp:76
typename simd_traits< simd_t >::scalar_type scalar_type
Definition to_simd.hpp:74
constexpr view_to_simd(other_urng_t &&urng, scalar_type const padding_value=alphabet_size)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition to_simd.hpp:133
Provides various transformation traits used by the range module.
@ row
The corresponding alignment coordinate will be incrementable/decrementable in the row index.
decltype(seqan3::to_rank(std::declval< semi_alphabet_type >())) alphabet_rank_t
The rank_type of the semi-alphabet; defined as the return type of seqan3::to_rank....
Definition alphabet/concept.hpp:164
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition alphabet/concept.hpp:152
constexpr auto to_simd
A view that transforms a range of ranges into chunks of seqan3::simd vectors.
Definition to_simd.hpp:779
constexpr void transpose(std::array< simd_t, simd_traits< simd_t >::length > &matrix)
Transposes the given simd vector matrix.
Definition algorithm.hpp:420
typename simd_type< scalar_t, length, simd_backend >::type simd_type_t
Helper type of seqan3::simd::simd_type.
Definition simd.hpp:56
seqan::stl::views::zip zip
A view adaptor that takes several views and returns tuple-like values from every i-th element of each...
Definition zip.hpp:24
The basis for seqan3::alphabet, but requires only rank interface (not char).
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
The SeqAn namespace for views.
Definition char_strictly_to.hpp:19
constexpr auto const & get(configuration< configs_t... > const &config) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition configuration.hpp:412
SeqAn specific customisations in the standard namespace.
Provides seqan3::simd::simd_type.
Provides seqan3::simd::simd_traits.
views::to_simd's range adaptor closure object type.
Definition to_simd.hpp:607
typename simd_traits< simd_t >::scalar_type padding_t
The type of a padding value.
Definition to_simd.hpp:609
constexpr auto operator()(urng_t &&urange) const noexcept
Call the view's constructor with the underlying std::ranges::viewable_range as argument.
Definition to_simd.hpp:650
constexpr auto operator()(urng_t &&urange, padding_t const padding_value) const noexcept
Call the view's constructor with the underlying std::ranges::viewable_range as argument.
Definition to_simd.hpp:631
constexpr friend auto operator|(urng_t &&urange, to_simd_fn const &me)
Overloaded bit-operator to allow chaining with other ranges.
Definition to_simd.hpp:666
constexpr auto operator()() const noexcept
Returns a range adaptor object.
Definition to_simd.hpp:620
constexpr auto operator()(padding_t const padding_value) const noexcept
Returns a range adaptor closure object with the given parameter.
Definition to_simd.hpp:614
seqan3::simd::simd_traits is the trait class that provides uniform interface to the properties of sim...
Definition simd_traits.hpp:38
Provides type traits for working with templates.
Provides seqan3::views::type_reduce.
Provides seqan3::simd::simd_concept.
Provides seqan3::views::zip.