HIBF 1.0.0-rc.1
Loading...
Searching...
No Matches
subtract_empty_bins.hpp
1// SPDX-FileCopyrightText: 2006-2026, Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2026, Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
5#pragma once
6
7#include <algorithm> // for clamp
8#include <cmath> // for ceil
9#include <cstddef> // for size_t
10
11#include <hibf/platform.hpp>
12
13namespace seqan::hibf
14{
15
22[[nodiscard]] constexpr size_t subtract_empty_bins(size_t const tmax, double const fraction) noexcept
23{
24 // There must be at least 2 technical bins available without empty bins.
25 // Otherwise, there would only ever be one technical bin available.
26 if (fraction == 0.0 || tmax <= 2u)
27 return tmax;
28
29 size_t const number_of_empty_bins = std::clamp<size_t>(std::ceil(tmax * fraction), 1, tmax - 2);
30 return tmax - number_of_empty_bins;
31}
32
33} // namespace seqan::hibf
T ceil(T... args)
constexpr size_t subtract_empty_bins(size_t const tmax, double const fraction) noexcept
Returns the number of technical bins available for use.
Definition subtract_empty_bins.hpp:22
T is_base_of_v
Provides platform and dependency checks.