23 namespace seqan3::detail
63 template <simd_concept simd_score_t, semialphabet alphabet_t,
typename alignment_t>
65 requires (seqan3::alphabet_size<alphabet_t> > 1) &&
66 (std::same_as<alignment_t, align_cfg::method_local> ||
67 std::same_as<alignment_t, align_cfg::method_global>)
69 class simd_match_mismatch_scoring_scheme
75 constexpr simd_match_mismatch_scoring_scheme() =
default;
78 constexpr simd_match_mismatch_scoring_scheme(simd_match_mismatch_scoring_scheme
const &) =
default;
80 constexpr simd_match_mismatch_scoring_scheme(simd_match_mismatch_scoring_scheme &&) =
default;
82 constexpr simd_match_mismatch_scoring_scheme & operator=(simd_match_mismatch_scoring_scheme
const &) =
default;
84 constexpr simd_match_mismatch_scoring_scheme & operator=(simd_match_mismatch_scoring_scheme &&) =
default;
86 ~simd_match_mismatch_scoring_scheme() =
default;
89 template <
typename scoring_scheme_t>
93 constexpr
explicit simd_match_mismatch_scoring_scheme(scoring_scheme_t
const & scoring_scheme)
95 initialise_from_scalar_scoring_scheme(scoring_scheme);
99 template <
typename scoring_scheme_t>
103 constexpr simd_match_mismatch_scoring_scheme & operator=(scoring_scheme_t
const & scoring_scheme)
105 initialise_from_scalar_scoring_scheme(scoring_scheme);
139 constexpr simd_score_t score(simd_score_t
const & lhs, simd_score_t
const & rhs)
const noexcept
141 typename simd_traits<simd_score_t>::mask_type mask;
144 if constexpr (std::same_as<alignment_t, align_cfg::method_global>)
145 mask = (lhs ^ rhs) <= simd::fill<simd_score_t>(0);
147 mask = (lhs ^ rhs) == simd::fill<simd_score_t>(0);
149 return mask ? match_score : mismatch_score;
154 constexpr
auto padding_match_score() noexcept
156 return match_score[0];
175 template <
typename scoring_scheme_t>
176 constexpr
void initialise_from_scalar_scoring_scheme(scoring_scheme_t
const & scoring_scheme)
178 using score_t = decltype(std::declval<scoring_scheme_t const &>().score(alphabet_t{}, alphabet_t{}));
179 using simd_scalar_t =
typename simd_traits<simd_score_t>::scalar_type;
187 if constexpr (
sizeof(simd_scalar_t) <
sizeof(score_t))
193 "for the selected scalar type of the simd type."};
197 match_score = simd::fill<simd_score_t>(
static_cast<simd_scalar_t
>(scalar_match_score));
198 mismatch_score = simd::fill<simd_score_t>(
static_cast<simd_scalar_t
>(scalar_mismatch_score));
201 simd_score_t match_score;
202 simd_score_t mismatch_score;