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

Function measure_smoothstep

tests/fl/math/fixed_point.cpp:1567–1583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1565}
1566
1567AccuracyResult measure_smoothstep() {
1568 AccuracyResult r = {};
1569 const int N = 10; // Spot testing: 10 key points adequate for [-0.5, 1.5] range (was 50)
1570 float sumErr = 0;
1571 for (int i = 0; i < N; ++i) {
1572 float x = -0.5f + 2.0f * i / (N - 1);
1573 float t = x < 0.0f ? 0.0f : (x > 1.0f ? 1.0f : x);
1574 float ref = t * t * (3.0f - 2.0f * t);
1575 float got = s16x16::smoothstep(s16x16(0.0f), s16x16(1.0f), s16x16(x)).to_float();
1576 float err = fl::fabsf(got - ref);
1577 sumErr += err;
1578 if (err > r.maxErr) { r.maxErr = err; r.worstInput = x; }
1579 }
1580 r.avgErr = sumErr / N;
1581 r.nSamples = N;
1582 return r;
1583}
1584
1585void print_row(const char *name, const AccuracyResult &r) {
1586 fl::printf("%s: maxErr=%.6f avgErr=%.6f worstInput=%.4f\n",

Callers 1

FL_TEST_FILEFunction · 0.85

Calls 4

smoothstepFunction · 0.85
fabsfFunction · 0.85
s16x16Class · 0.50
to_floatMethod · 0.45

Tested by

no test coverage detected