SeqAn3
The Modern C++ library for sequence analysis.
simd_algorithm.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2019, Knut Reinert & MPI für molekulare Genetik
4 // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5 // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6 // -----------------------------------------------------------------------------------------------------
7 
13 #pragma once
14 
15 #include <utility>
16 
19 
20 namespace seqan3::detail
21 {
22 
25 template <Simd simd_t, size_t... I>
26 constexpr simd_t fill_impl(typename simd_traits<simd_t>::scalar_type const scalar, std::index_sequence<I...>)
27 {
28  return simd_t{((void)I, scalar)...};
29 }
30 
33 template <Simd simd_t, typename scalar_t, scalar_t... I>
34 constexpr simd_t iota_impl(scalar_t const offset, std::integer_sequence<scalar_t, I...>)
35 {
36  return simd_t{static_cast<scalar_t>(offset + I)...};
37 }
38 
39 } // namespace seqan3::detail
40 
41 namespace seqan3
42 {
43 
44 inline namespace simd
45 {
46 
56 template <Simd simd_t>
57 constexpr simd_t fill(typename simd_traits<simd_t>::scalar_type const scalar)
58 {
59  constexpr size_t length = simd_traits<simd_t>::length;
60  return detail::fill_impl<simd_t>(scalar, std::make_index_sequence<length>{});
61 }
62 
72 template <Simd simd_t>
73 constexpr simd_t iota(typename simd_traits<simd_t>::scalar_type const offset)
74 {
75  constexpr size_t length = simd_traits<simd_t>::length;
76  using scalar_type = typename simd_traits<simd_t>::scalar_type;
77  return detail::iota_impl<simd_t>(offset, std::make_integer_sequence<scalar_type, length>{});
78 }
79 
80 } // inline namespace simd
81 
82 } // namespace seqan3
Provides seqan3::simd::Simd.
Provides seqan3::simd::simd_traits.
The main SeqAn3 namespace.
constexpr auto iota
Generates a sequence of elements by repeatedly incrementing an initial value.
Definition: ranges:647
::ranges::fill fill
Alias for ranges::fill. Assigns a value to the elements of a range.
Definition: algorithm:59
Definition: aligned_sequence_concept.hpp:35