| 1834 | |
| 1835 | template <typename T> |
| 1836 | AccuracyResult measure_pow_t(float exponent, float baseLo, float baseHi) { |
| 1837 | AccuracyResult r = {}; |
| 1838 | const int N = 10; // Spot testing: 10 key points adequate for base range coverage (was 50) |
| 1839 | constexpr int intBits = T::INT_BITS; |
| 1840 | const float maxRange = static_cast<float>((1 << (intBits - 1)) - 1); |
| 1841 | float sumErr = 0; |
| 1842 | int count = 0; |
| 1843 | for (int i = 0; i < N; ++i) { |
| 1844 | float base = baseLo + (baseHi - baseLo) * i / (N - 1); |
| 1845 | float ref = fl::powf(base, exponent); |
| 1846 | if (ref > maxRange || ref < 0.0f) continue; |
| 1847 | float got = T::pow(T(base), T(exponent)).to_float(); |
| 1848 | float err = fl::fabsf(got - ref); |
| 1849 | sumErr += err; |
| 1850 | ++count; |
| 1851 | if (err > r.maxErr) { r.maxErr = err; r.worstInput = base; } |
| 1852 | } |
| 1853 | r.avgErr = count > 0 ? sumErr / count : 0; |
| 1854 | r.nSamples = count; |
| 1855 | return r; |
| 1856 | } |
| 1857 | |
| 1858 | template <typename T> |
| 1859 | AccuracyResult measure_smoothstep_t() { |