31template <
typename FloatType>
37template <
typename FloatType>
39 size_t numPointsToUse)
41 initialise (functionToApproximate, numPointsToUse);
45template <
typename FloatType>
47 size_t numPointsToUse)
51 for (
size_t i = 0;
i < numPointsToUse; ++
i)
53 auto value = functionToApproximate (
i);
60 data.getReference (
static_cast<int> (
i)) =
value;
66template <
typename FloatType>
70 data.getReference (guardIndex) =
data.getUnchecked (guardIndex - 1);
73template <
typename FloatType>
75 FloatType minInputValueToUse,
76 FloatType maxInputValueToUse,
79 jassert (maxInputValueToUse > minInputValueToUse);
82 maxInputValue = maxInputValueToUse;
83 scaler = FloatType (numPoints - 1) / (maxInputValueToUse - minInputValueToUse);
84 offset = -minInputValueToUse * scaler;
86 const auto initFn = [functionToApproximate, minInputValueToUse, maxInputValueToUse, numPoints] (
size_t i)
88 return functionToApproximate (
90 minInputValueToUse, maxInputValueToUse,
91 jmap (FloatType (
i), FloatType (0), FloatType (numPoints - 1), minInputValueToUse, maxInputValueToUse))
95 lookupTable.initialise (initFn, numPoints);
99template <
typename FloatType>
104 size_t numTestPoints)
108 if (numTestPoints == 0)
109 numTestPoints = 100 * numPoints;
115 for (
size_t i = 0;
i < numTestPoints; ++
i)
118 auto approximatedOutputValue = transform.
processSample (inputValue);
119 auto referenceOutputValue = functionToApproximate (inputValue);
128template <
typename FloatType>
131 static const auto eps = std::numeric_limits<double>::min();
133 auto absX = std::abs (
x);
134 auto absY = std::abs (
y);
135 auto absDiff = std::abs (
x -
y);
140 return absDiff / absY;
145 return absDiff / std::min (absX, absY);
Type jmax(const Type a, const Type b)
Definition MathsFunctions.h:48
#define noexcept
Definition DistrhoDefines.h:72
size_t getGuardIndex() const noexcept
Definition juce_LookupTable.h:149
static size_t getRequiredBufferSize(size_t numPointsToUse) noexcept
Definition juce_LookupTable.h:148
void prepare() noexcept
Definition juce_LookupTable.cpp:67
void initialise(const std::function< FloatType(size_t)> &functionToApproximate, size_t numPointsToUse)
Definition juce_LookupTable.cpp:46
Array< FloatType > data
Definition juce_LookupTable.h:145
LookupTable()
Definition juce_LookupTable.cpp:32
int y
Definition inflate.c:1588
register unsigned i
Definition inflate.c:1575
unsigned x[BMAX+1]
Definition inflate.c:1586
static PuglViewHint int value
Definition pugl.h:1708
Definition juce_AudioBlock.h:29
Definition carla_juce.cpp:31
constexpr Type jmap(Type value0To1, Type targetRangeMin, Type targetRangeMax)
Definition juce_MathsFunctions.h:120
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Definition juce_MathsFunctions.h:262