/ concept-collection / fastandaccurate
concept-collection / fastandaccurate
fastandaccurate / test / expected.ts
85 lines · 3.9 KBBlameHistoryRaw
1// What the shipped solvers must achieve, shared by both test suites
2// (test/solver-test.ts through numbl, test/matlab-test.ts in real
3// MATLAB). Keyed by the solver's source directory rather than its id, so
4// that manifest entries sharing one solver.m — mfs and mfs-mat, and
5// likewise nystrom-dlp — are held to the same expectation whichever
6// runtime executes them.
8/** Best relMax the solver must reach somewhere in its full sweep. */
9export const MUST_REACH: Record<string, Record<string, number>> = {
10 // On flower-15 the MFS charge curve, a fixed 0.3 outside a boundary
11 // whose curvature radius is 0.014, self-intersects and puts charges
12 // inside the domain; the floor is only a sanity check that the solver
13 // still returns something, and MUST_NOT_REACH below is the real test.
14 mfs: {
15 "disk-easy": 1e-12,
16 "star-medium": 1e-12,
17 "star-hard": 1e-4,
18 "flower-15": 1e-2,
19 // Convex geometry and charges far from every target: MFS is the best
20 // method on the corner instance, so this floor is a real requirement.
21 "square-corners": 1e-11,
22 // Charges 0.3 out and targets 0.005 in: the charge curve overshoots
23 // the sources, as on star-hard, and the near-boundary targets cost
24 // nothing extra because the representation is smooth up to it.
25 "star-nearfield": 1e-4,
26 },
27 // WebGPU has no f64, and the MFS is conditioning-limited, so these
28 // floors are six to nine orders looser than the same method's on the CPU.
29 // That is the finding, not a defect; MUST_NOT_REACH below holds it in
30 // place.
31 "mfs-gpu": {
32 "disk-easy": 1e-6,
33 "star-medium": 1e-6,
34 "star-hard": 1e-2,
35 "flower-15": 1e-2,
36 "square-corners": 1e-5,
37 "star-nearfield": 1e-2,
38 },
39 "nystrom-dlp": {
40 "disk-easy": 1e-10,
41 "star-medium": 1e-10,
42 "star-hard": 1e-8,
43 "flower-15": 1e-6,
44 // Loose because the numbl sweep stops at 1536 nodes, where the target
45 // 0.005 inside a corner is still at 1e-3; the MATLAB twin, whose list
46 // runs to 4096, gets to 7e-9 and passes the same floor.
47 "square-corners": 1e-2,
48 // Looser still: uncorrected quadrature at a target 0.005 from a
49 // boundary resolved at h = 0.0059 (1536 nodes) is worth about 1e-2,
50 // and the MATLAB twin at 4096 only reaches 7e-6.
51 "star-nearfield": 5e-2,
52 },
53 // chunkie's default quadrature tolerances cap it near 1e-11, and its
54 // sweep is checked on the extreme instances only.
55 "chunkie-dlp": {
56 "disk-easy": 1e-10,
57 "star-hard": 1e-9,
58 "flower-15": 1e-9,
59 "square-corners": 1e-8,
60 // The instance chunkie exists to win: its corrected near-field
61 // quadrature has to hold the same accuracy at a target 0.005 from the
62 // boundary that it reaches in the bulk.
63 "star-nearfield": 1e-9,
64 },
65};
67/** Accuracy the solver must NOT reach. MFS is required to do badly on
68 * both hard instances, for the two different reasons they exist: on
69 * star-hard its charge curve lies beyond the data's singularities, and on
70 * flower-15 the fixed offset self-intersects and puts charges inside the
71 * domain. If either suddenly reached high accuracy, the instance would no
72 * longer be testing what the spec says it tests. */
73export const MUST_NOT_REACH: Record<string, Record<string, number>> = {
74 mfs: { "star-hard": 1e-8, "flower-15": 1e-8 },
75 // star-nearfield exists to measure near-field evaluation, and the plain
76 // trapezoid rule has none: if this solver ever reached high accuracy at
77 // a target 0.005 inside the boundary, either it acquired a near-field
78 // correction or the instance stopped placing its targets there.
79 "nystrom-dlp": { "star-nearfield": 1e-8 },
80 // Single precision is what caps mfs-gpu on the two instances where the
81 // method itself would otherwise reach 1e-13. If it ever got past this,
82 // it stopped computing in f32 and the pair with mfs stopped measuring
83 // what it claims to measure.
84 "mfs-gpu": { "disk-easy": 1e-9, "star-medium": 1e-9 },
85};