| 1440 | } |
| 1441 | |
| 1442 | AccuracyResult measure_atan2() { |
| 1443 | AccuracyResult r = {}; |
| 1444 | const int N = 5; // Spot testing: 5×5 = 25 samples (was 20×20 = 400) |
| 1445 | const float lo = -7.0f; |
| 1446 | const float hi = 7.0f; |
| 1447 | float sumErr = 0; |
| 1448 | int count = 0; |
| 1449 | for (int iy = 0; iy < N; ++iy) { |
| 1450 | float y = lo + (hi - lo) * iy / (N - 1); |
| 1451 | for (int ix = 0; ix < N; ++ix) { |
| 1452 | float x = lo + (hi - lo) * ix / (N - 1); |
| 1453 | if (fl::fabsf(x) < 0.1f && fl::fabsf(y) < 0.1f) continue; |
| 1454 | float ref = fl::atan2f(y, x); |
| 1455 | float got = s16x16::atan2(s16x16(y), s16x16(x)).to_float(); |
| 1456 | float err = fl::fabsf(got - ref); |
| 1457 | sumErr += err; |
| 1458 | ++count; |
| 1459 | if (err > r.maxErr) { |
| 1460 | r.maxErr = err; |
| 1461 | r.worstInput = y; |
| 1462 | r.worstInput2 = x; |
| 1463 | } |
| 1464 | } |
| 1465 | } |
| 1466 | r.avgErr = count > 0 ? sumErr / count : 0; |
| 1467 | r.nSamples = count; |
| 1468 | return r; |
| 1469 | } |
| 1470 | |
| 1471 | AccuracyResult measure_asin() { |
| 1472 | AccuracyResult r = {}; |