| 1857 | |
| 1858 | template <typename T> |
| 1859 | AccuracyResult measure_smoothstep_t() { |
| 1860 | AccuracyResult r = {}; |
| 1861 | const int N = 10; // Spot testing: 10 key points adequate for [-0.5, 1.5] range (was 50) |
| 1862 | float sumErr = 0; |
| 1863 | for (int i = 0; i < N; ++i) { |
| 1864 | float x = -0.5f + 2.0f * i / (N - 1); |
| 1865 | float t = x < 0.0f ? 0.0f : (x > 1.0f ? 1.0f : x); |
| 1866 | float ref = t * t * (3.0f - 2.0f * t); |
| 1867 | float got = T::smoothstep(T(0.0f), T(1.0f), T(x)).to_float(); |
| 1868 | float err = fl::fabsf(got - ref); |
| 1869 | sumErr += err; |
| 1870 | if (err > r.maxErr) { r.maxErr = err; r.worstInput = x; } |
| 1871 | } |
| 1872 | r.avgErr = sumErr / N; |
| 1873 | r.nSamples = N; |
| 1874 | return r; |
| 1875 | } |
| 1876 | |
| 1877 | template <typename T> |
| 1878 | void run_type_accuracy(const char* name) { |
nothing calls this directly
no test coverage detected