2#ifndef FS_LOOKUPTABLE_H
3#define FS_LOOKUPTABLE_H
6#define LOOKUP_TABLES_OFF 1
7#undef LOOKUP_TABLES_OFF
17template <MathSize (*Fct)(const MathSize),
int IndexDigits = 3,
int Precision = 1>
20#ifndef LOOKUP_TABLES_OFF
24 using ValuesArray = array<MathSize, pow_int<IndexDigits>(10) * pow_int<Precision>(10)>;
37 for (
size_t i = 0; i < values.size(); ++i)
39 const auto value = i /
static_cast<MathSize
>(pow_int<Precision>(10));
40 values[i] = Fct(value);
47#ifndef LOOKUP_TABLES_OFF
51 ~LookupTable() =
default;
52 LookupTable(LookupTable&& rhs)
noexcept =
delete;
53 LookupTable(
const LookupTable& rhs)
noexcept =
delete;
54 LookupTable& operator=(LookupTable&& rhs)
noexcept =
delete;
55 LookupTable& operator=(
const LookupTable& rhs)
noexcept =
delete;
61 [[nodiscard]]
constexpr MathSize
operator()(
const MathSize value)
const
63 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:19
const ValuesArray values_
Array of values from calling function.
Definition LookupTable.h:28
constexpr MathSize operator()(const MathSize value) const
Get result of function lookup table was initialized with for given value.
Definition LookupTable.h:61
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:24
constexpr ValuesArray makeValues()
Call function with range of values with given precision.
Definition LookupTable.h:33