| 38 | return s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2; |
| 39 | } |
| 40 | function timeit(fn: () => void) { |
| 41 | let t = performance.now(); fn(); |
| 42 | const first = performance.now() - t; |
| 43 | const iters = Math.min(30, Math.max(1, Math.round(120 / Math.max(first, 0.01)))); |
| 44 | const times: number[] = []; |
| 45 | for (let i = 0; i < iters; i++) { t = performance.now(); fn(); times.push(performance.now() - t); } |
| 46 | return { timeMs: median(times), minMs: Math.min(...times) }; |
| 47 | } |
| 48 | const num = (b: any) => { const v = b.N(); return typeof v.re === 'number' ? v.re : Number(v.toString()); }; |
| 49 | // Sample points are scalars (univariate, substituted for x) or tuples matching |
| 50 | // the case's `verify.vars` (multivariate — all variables substituted at once). |