* Full oracle-based check for a solvable linear Diophantine equation: (b) * every substituted parameter tuple satisfies the equation, and (c) every * brute-force point in a box is reachable by SOME parameter assignment.
( a: bigint[], c: bigint, bruteBound: bigint = BRUTE_BOUND )
| 210 | * brute-force point in a box is reachable by SOME parameter assignment. |
| 211 | */ |
| 212 | function expectFullLinearFamily( |
| 213 | a: bigint[], |
| 214 | c: bigint, |
| 215 | bruteBound: bigint = BRUTE_BOUND |
| 216 | ): LinearSolution { |
| 217 | const sol = solveLinearDiophantine(a, c); |
| 218 | expect(sol).not.toBeNull(); |
| 219 | const s = sol as LinearSolution; |
| 220 | |
| 221 | for (const t of cartesianRange(s.nParams, -PARAM_CHECK_RANGE, PARAM_CHECK_RANGE)) { |
| 222 | expect(linearSatisfies(a, c, substitute(s, t))).toBe(true); |
| 223 | } |
| 224 | |
| 225 | const bf = bruteForceLinear(a, c, bruteBound); |
| 226 | expect(bf.length).toBeGreaterThan(0); |
| 227 | for (const x of bf) { |
| 228 | const t = invertParams(s, x); |
| 229 | expect(t).not.toBeNull(); |
| 230 | expect(linearSatisfies(a, c, substitute(s, t as bigint[]))).toBe(true); |
| 231 | } |
| 232 | return s; |
| 233 | } |
| 234 | |
| 235 | function expectNoLinearSolution(a: bigint[], c: bigint) { |
| 236 | expect(solveLinearDiophantine(a, c)).toBeNull(); |
no test coverage detected