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

Function measure_sin

tests/fl/math/fixed_point.cpp:1385–1402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1383};
1384
1385AccuracyResult measure_sin() {
1386 AccuracyResult r = {};
1387 const int N = 10; // Spot testing: 10 key points covers full cycle (was 100)
1388 const float lo = -6.2831853f;
1389 const float hi = 6.2831853f;
1390 float sumErr = 0;
1391 for (int i = 0; i < N; ++i) {
1392 float x = lo + (hi - lo) * i / (N - 1);
1393 float ref = fl::sinf(x);
1394 float got = s16x16::sin(s16x16(x)).to_float();
1395 float err = fl::fabsf(got - ref);
1396 sumErr += err;
1397 if (err > r.maxErr) { r.maxErr = err; r.worstInput = x; }
1398 }
1399 r.avgErr = sumErr / N;
1400 r.nSamples = N;
1401 return r;
1402}
1403
1404AccuracyResult measure_cos() {
1405 AccuracyResult r = {};

Callers 1

FL_TEST_FILEFunction · 0.85

Calls 5

sinfFunction · 0.85
fabsfFunction · 0.85
sinFunction · 0.50
s16x16Class · 0.50
to_floatMethod · 0.45

Tested by

no test coverage detected