8#define LOOKUP_TABLES_OFF 1
9#undef LOOKUP_TABLES_OFF
18template <MathSize (*Fct)(const MathSize),
int IndexDigits = 3,
int Precision = 1>
21#ifndef LOOKUP_TABLES_OFF
25 using ValuesArray = array<MathSize, pow_int<IndexDigits>(10) * pow_int<Precision>(10)>;
38 for (
size_t i = 0; i < values.size(); ++i)
40 const auto value = i /
static_cast<MathSize
>(pow_int<Precision>(10));
41 values[i] = Fct(value);
48#ifndef LOOKUP_TABLES_OFF
53 ~LookupTable() =
default;
54 LookupTable(LookupTable&& rhs)
noexcept =
delete;
55 LookupTable(
const LookupTable& rhs)
noexcept =
delete;
56 LookupTable& operator=(LookupTable&& rhs)
noexcept =
delete;
57 LookupTable& operator=(
const LookupTable& rhs)
noexcept =
delete;
63 [[nodiscard]]
constexpr MathSize
operator()(
const MathSize value)
const
65#ifndef LOOKUP_TABLES_OFF
66 return values_.at(
static_cast<size_t>(value * pow_int<Precision>(10)));
A table initialized using the given function ranging over the number of digits and precision.
Definition LookupTable.h:20
constexpr MathSize operator()(const MathSize value) const
Get result of function lookup table was initialized with for given value.
Definition LookupTable.h:63
constexpr ValuesArray makeValues()
Call function with range of values with given precision.
Definition LookupTable.h:34
array< MathSize, pow_int< IndexDigits >(10) *pow_int< Precision >(10)> ValuesArray
Array with enough space for function called with specific number of digits and precision.
Definition LookupTable.h:25
const ValuesArray values_
Array of values from calling function.
Definition LookupTable.h:29