MCPcopy Create free account
hub / github.com/FastLED/FastLED / measure_pow_t

Function measure_pow_t

tests/fl/math/fixed_point.cpp:1836–1856  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1834
1835template <typename T>
1836AccuracyResult measure_pow_t(float exponent, float baseLo, float baseHi) {
1837 AccuracyResult r = {};
1838 const int N = 10; // Spot testing: 10 key points adequate for base range coverage (was 50)
1839 constexpr int intBits = T::INT_BITS;
1840 const float maxRange = static_cast<float>((1 << (intBits - 1)) - 1);
1841 float sumErr = 0;
1842 int count = 0;
1843 for (int i = 0; i < N; ++i) {
1844 float base = baseLo + (baseHi - baseLo) * i / (N - 1);
1845 float ref = fl::powf(base, exponent);
1846 if (ref > maxRange || ref < 0.0f) continue;
1847 float got = T::pow(T(base), T(exponent)).to_float();
1848 float err = fl::fabsf(got - ref);
1849 sumErr += err;
1850 ++count;
1851 if (err > r.maxErr) { r.maxErr = err; r.worstInput = base; }
1852 }
1853 r.avgErr = count > 0 ? sumErr / count : 0;
1854 r.nSamples = count;
1855 return r;
1856}
1857
1858template <typename T>
1859AccuracyResult measure_smoothstep_t() {

Callers

nothing calls this directly

Calls 5

powfFunction · 0.85
TEnum · 0.85
fabsfFunction · 0.85
powFunction · 0.50
to_floatMethod · 0.45

Tested by

no test coverage detected