SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
matrix_coordinate.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <concepts>
13#include <type_traits>
14
19
20namespace seqan3::detail
21{
26template <typename index_type>
27 requires (std::integral<index_type> || simd_index<index_type>)
28struct column_index_type : detail::strong_type<index_type, column_index_type<index_type>>
29{
31 using detail::strong_type<index_type, column_index_type<index_type>>::strong_type;
32};
33
39template <std::signed_integral index_type>
41
43template <std::unsigned_integral index_type>
45
47template <simd_index index_type>
50
55template <typename index_type>
56 requires (std::integral<index_type> || simd_index<index_type>)
57struct row_index_type : detail::strong_type<index_type, row_index_type<index_type>>
58{
60 using detail::strong_type<index_type, row_index_type<index_type>>::strong_type;
61};
62
68template <std::signed_integral index_type>
70
72template <std::unsigned_integral index_type>
74
76template <simd_index index_type>
79
84template <typename index_t>
85 requires (std::integral<index_t> || simd_index<index_t>)
87{
91 constexpr matrix_index() = default;
92 constexpr matrix_index(matrix_index const &) = default;
93 constexpr matrix_index(matrix_index &&) = default;
94 constexpr matrix_index & operator=(matrix_index const &) = default;
95 constexpr matrix_index & operator=(matrix_index &&) = default;
96 ~matrix_index() = default;
97
102 constexpr matrix_index(row_index_type<index_t> const row_idx, column_index_type<index_t> const col_idx) noexcept :
103 row{row_idx.get()},
104 col{col_idx.get()}
105 {}
106
123 template <seqan3::arithmetic scalar_index_t>
125 column_index_type<scalar_index_t> const col_idx) noexcept
126 requires simd_index<index_t>
127 // Note the explicit type conversion is necessary since the scalar type might be of smaller bit size.
128 :
129 row{simd::fill<index_t>(static_cast<typename simd_traits<index_t>::scalar_type>(row_idx.get()))},
130 col{simd::fill<index_t>(static_cast<typename simd_traits<index_t>::scalar_type>(col_idx.get()))}
131 {}
132
136 template <std::integral other_index_t>
137 requires (!std::same_as<other_index_t, index_t>)
138 explicit constexpr matrix_index(matrix_index<other_index_t> other) noexcept :
139 row{static_cast<index_t>(other.row)},
140 col{static_cast<index_t>(other.col)}
141 {}
143
145 template <std::integral first_index_t, std::integral second_index_t>
146 constexpr explicit operator std::pair<first_index_t, second_index_t>() const noexcept
147 {
148 return std::pair{static_cast<first_index_t>(col), static_cast<second_index_t>(row)};
149 }
150
151 index_t row{};
152 index_t col{};
153};
154
161
163template <std::integral row_index_t, std::integral col_index_t>
164 requires std::common_with<row_index_t, col_index_t>
167
169template <simd_index index_t>
172
176
181template <simd_index index_t>
183
187} // namespace seqan3::detail
Provides algorithms to modify seqan3::simd::simd_type.
CRTP base class to declare a strong typedef for a regular type to avoid ambiguous parameter settings ...
Definition strong_type.hpp:174
@ row
The corresponding alignment coordinate will be incrementable/decrementable in the row index.
Refines the seqan3::simd::simd_concept requiring the underlying scalar type to model std::integral.
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
Provides basic data structure for strong types.
A strong type for designated initialisation of the column index of a matrix.
Definition matrix_coordinate.hpp:29
column_index_type(index_type) -> column_index_type< std::ptrdiff_t >
Deduces an signed integral type to std::ptrdiff_t.
column_index_type(index_type) -> column_index_type< size_t >
Deduces an unsigned integral type to size_t.
column_index_type(index_type) -> column_index_type< index_type >
Deduces the template argument from a simd vector index type.
A representation of a location or offset within a two-dimensional matrix.
Definition matrix_coordinate.hpp:87
constexpr matrix_index(row_index_type< scalar_index_t > const row_idx, column_index_type< scalar_index_t > const col_idx) noexcept
Construction from strongly typed row index and column index over a scalar type when the index is a si...
Definition matrix_coordinate.hpp:124
index_t row
The row index.
Definition matrix_coordinate.hpp:151
matrix_index(row_index_type< row_index_t >, column_index_type< col_index_t >) -> matrix_index< std::common_type_t< row_index_t, col_index_t > >
Deduces the index type from the common type of both index types.
constexpr matrix_index(row_index_type< index_t > const row_idx, column_index_type< index_t > const col_idx) noexcept
Construction from strongly typed row index and column index.
Definition matrix_coordinate.hpp:102
matrix_index() -> matrix_index< std::ptrdiff_t >
Deduces the default index type to std::ptrdiff_t.
matrix_index(row_index_type< index_t >, column_index_type< index_t >) -> matrix_index< index_t >
Deduces the index type from the simd vector index type.
~matrix_index()=default
Defaulted.
constexpr matrix_index & operator=(matrix_index &&)=default
Defaulted.
constexpr matrix_index & operator=(matrix_index const &)=default
Defaulted.
constexpr matrix_index(matrix_index const &)=default
Defaulted.
constexpr matrix_index()=default
Defaulted.
index_t col
The column index.
Definition matrix_coordinate.hpp:152
constexpr matrix_index(matrix_index &&)=default
Defaulted.
constexpr matrix_index(matrix_index< other_index_t > other) noexcept
Construction from other matrix_index with different integral type.
Definition matrix_coordinate.hpp:138
A strong type for designated initialisation of the row index of a matrix.
Definition matrix_coordinate.hpp:58
row_index_type(index_type) -> row_index_type< std::ptrdiff_t >
Deduces an signed integral type to std::ptrdiff_t.
row_index_type(index_type) -> row_index_type< index_type >
Deduces the template argument from a simd vector index type.
row_index_type(index_type) -> row_index_type< size_t >
Deduces an unsigned integral type to size_t.
seqan3::simd::simd_traits is the trait class that provides uniform interface to the properties of sim...
Definition simd_traits.hpp:38
Provides concepts that do not have equivalents in C++20.
Provides seqan3::simd::simd_concept.
Hide me