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

Function measure_smoothstep_t

tests/fl/math/fixed_point.cpp:1859–1875  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1857
1858template <typename T>
1859AccuracyResult measure_smoothstep_t() {
1860 AccuracyResult r = {};
1861 const int N = 10; // Spot testing: 10 key points adequate for [-0.5, 1.5] range (was 50)
1862 float sumErr = 0;
1863 for (int i = 0; i < N; ++i) {
1864 float x = -0.5f + 2.0f * i / (N - 1);
1865 float t = x < 0.0f ? 0.0f : (x > 1.0f ? 1.0f : x);
1866 float ref = t * t * (3.0f - 2.0f * t);
1867 float got = T::smoothstep(T(0.0f), T(1.0f), T(x)).to_float();
1868 float err = fl::fabsf(got - ref);
1869 sumErr += err;
1870 if (err > r.maxErr) { r.maxErr = err; r.worstInput = x; }
1871 }
1872 r.avgErr = sumErr / N;
1873 r.nSamples = N;
1874 return r;
1875}
1876
1877template <typename T>
1878void run_type_accuracy(const char* name) {

Callers

nothing calls this directly

Calls 4

smoothstepFunction · 0.85
TEnum · 0.85
fabsfFunction · 0.85
to_floatMethod · 0.45

Tested by

no test coverage detected