31 template <
typename word_t,
typename score_t,
bool is_semi_global,
bool use_max_errors>
32 class edit_distance_score_matrix_full
38 typename align_config_t,
40 friend class edit_distance_unbanded;
45 edit_distance_score_matrix_full() =
default;
46 edit_distance_score_matrix_full(edit_distance_score_matrix_full
const &) =
default;
47 edit_distance_score_matrix_full(edit_distance_score_matrix_full &&) =
default;
48 edit_distance_score_matrix_full & operator=(edit_distance_score_matrix_full
const &) =
default;
49 edit_distance_score_matrix_full & operator=(edit_distance_score_matrix_full &&) =
default;
50 ~edit_distance_score_matrix_full() =
default;
56 edit_distance_score_matrix_full(
size_t const rows_size)
57 : rows_size{rows_size}, columns{}
63 using word_type = word_t;
66 static constexpr
auto word_size = sizeof_bits<word_type>;
69 using score_type = score_t;
85 void reserve(
size_t const new_capacity)
87 columns.reserve(new_capacity);
98 template <
typename score_type>
99 static size_t max_rows(word_type
const score_mask,
unsigned const last_block,
100 score_type
const score, score_type
const max_errors) noexcept
102 size_t const offset = score_mask == 0u ? 0u : bit_scan_reverse(score_mask) + 1u;
103 size_t const active_row = word_size * last_block + offset;
104 return active_row + (score <= max_errors);
112 static score_type score_delta_of_word(word_type
const & vp, word_type
const & vn) noexcept
121 entry_type at(
size_t const row,
size_t const col)
const noexcept
123 assert(row < rows());
124 assert(col < cols());
126 column_type
const & column = columns[col];
127 if constexpr(use_max_errors)
128 if (!(row < column.max_rows))
131 score_type score = is_semi_global ? 0u :
static_cast<score_type
>(col);
133 size_t current_row = 1u;
134 size_t word_idx = 0u;
136 for (; current_row + word_size <= row; ++word_idx, current_row += word_size)
137 score += score_delta_of_word(column.vp[word_idx], column.vn[word_idx]);
139 if (row >= current_row)
141 word_type
const mask = (1u << (row - current_row + 1u)) - 1u;
142 score += score_delta_of_word(column.vp[word_idx] & mask, column.vn[word_idx] & mask);
149 size_t rows() const noexcept
155 size_t cols() const noexcept
157 return columns.size();
162 struct max_errors_state
170 struct score_matrix_state
180 enable_state_t<true, score_matrix_state>,
181 enable_state_t<use_max_errors, max_errors_state>
190 requires !use_max_errors
193 column_type column{};
194 column.vp = std::move(vp);
195 column.vn = std::move(vn);
197 columns.push_back(std::move(column));
207 requires use_max_errors
210 column_type column{};
211 column.vp = std::move(vp);
212 column.vn = std::move(vn);
213 column.max_rows = max_rows;
215 columns.push_back(std::move(column));
Forwards for seqan3::edit_distance_unbanded related types.
Specifies the requirements of a Range type that is either a std::ranges::View or an lvalue-reference...
Definition: aligned_sequence_concept.hpp:35
Provides utility functions for bit twiddling.