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

Function measure_sqrt_accuracy

tests/fl/math/fixed_point.cpp:1509–1526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1507}
1508
1509AccuracyResult measure_sqrt_accuracy() {
1510 AccuracyResult r = {};
1511 const int N = 10; // Spot testing: 10 key points adequate for range coverage (was 50)
1512 const float lo = 0.001f;
1513 const float hi = 32000.0f;
1514 float sumErr = 0;
1515 for (int i = 0; i < N; ++i) {
1516 float x = lo + (hi - lo) * i / (N - 1);
1517 float ref = fl::sqrtf(x);
1518 float got = s16x16::sqrt(s16x16(x)).to_float();
1519 float err = fl::fabsf(got - ref);
1520 sumErr += err;
1521 if (err > r.maxErr) { r.maxErr = err; r.worstInput = x; }
1522 }
1523 r.avgErr = sumErr / N;
1524 r.nSamples = N;
1525 return r;
1526}
1527
1528AccuracyResult measure_rsqrt() {
1529 AccuracyResult r = {};

Callers 1

FL_TEST_FILEFunction · 0.85

Calls 5

sqrtfFunction · 0.85
sqrtFunction · 0.85
fabsfFunction · 0.85
s16x16Class · 0.50
to_floatMethod · 0.45

Tested by

no test coverage detected