15 #include <type_traits>
23 namespace seqan3::detail
29 template <
typename index_type>
31 requires (std::integral<index_type> || simd_index<index_type>)
33 struct column_index_type : detail::strong_type<index_type, column_index_type<index_type>>
36 using detail::strong_type<index_type, column_index_type<index_type>>::strong_type;
43 template <std::
signed_
integral index_type>
45 column_index_type(index_type) -> column_index_type<std::ptrdiff_t>;
48 template <std::
unsigned_
integral index_type>
49 column_index_type(index_type) -> column_index_type<size_t>;
52 template <simd_index index_type>
53 column_index_type(index_type) -> column_index_type<index_type>;
60 template <
typename index_type>
62 requires (std::integral<index_type> || simd_index<index_type>)
64 struct row_index_type : detail::strong_type<index_type, row_index_type<index_type>>
67 using detail::strong_type<index_type, row_index_type<index_type>>::strong_type;
74 template <std::
signed_
integral index_type>
76 row_index_type(index_type) -> row_index_type<std::ptrdiff_t>;
79 template <std::
unsigned_
integral index_type>
80 row_index_type(index_type) -> row_index_type<size_t>;
83 template <simd_index index_type>
84 row_index_type(index_type) -> row_index_type<index_type>;
91 template <
typename index_t>
93 requires (std::integral<index_t> || simd_index<index_t>)
100 constexpr matrix_index() =
default;
101 constexpr matrix_index(matrix_index
const &) =
default;
102 constexpr matrix_index(matrix_index &&) =
default;
103 constexpr matrix_index & operator=(matrix_index
const &) =
default;
104 constexpr matrix_index & operator=(matrix_index &&) =
default;
105 ~matrix_index() =
default;
111 constexpr matrix_index(row_index_type<index_t>
const row_idx, column_index_type<index_t>
const col_idx) noexcept :
132 template <seqan3::arithmetic scalar_index_t>
133 constexpr matrix_index(row_index_type<scalar_index_t>
const row_idx,
134 column_index_type<scalar_index_t>
const col_idx) noexcept
136 requires simd_index<index_t>
139 : row{simd::fill<index_t>(
static_cast<typename simd_traits<index_t>::scalar_type
>(row_idx.get()))},
140 col{simd::fill<index_t>(
static_cast<typename simd_traits<index_t>::scalar_type
>(col_idx.get()))}
146 template <std::
integral other_index_t>
148 requires (!std::same_as<other_index_t, index_t>)
150 explicit constexpr matrix_index(matrix_index<other_index_t> other) noexcept
151 : row{
static_cast<index_t
>(other.row)}, col{
static_cast<index_t
>(other.col)}
156 template <std::
integral first_index_t, std::
integral second_index_t>
159 return std::pair{
static_cast<first_index_t
>(col),
static_cast<second_index_t
>(row)};
170 matrix_index() -> matrix_index<std::ptrdiff_t>;
174 template <std::
integral row_index_t, std::
integral col_index_t>
176 requires std::common_with<row_index_t, col_index_t>
178 matrix_index(row_index_type<row_index_t>, column_index_type<col_index_t>) ->
179 matrix_index<std::common_type_t<row_index_t, col_index_t>>;
182 template <simd_index index_t>
183 matrix_index(row_index_type<index_t>, column_index_type<index_t>) -> matrix_index<index_t>;
188 using matrix_coordinate = matrix_index<size_t>;
194 template <simd_index index_t>
195 using simd_matrix_coordinate = matrix_index<index_t>;
199 using matrix_offset = matrix_index<std::ptrdiff_t>;