MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / expectFullLinearFamily

Function expectFullLinearFamily

test/compute-engine/diophantine.test.ts:212–233  ·  view source on GitHub ↗

* 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
)

Source from the content-addressed store, hash-verified

210 * brute-force point in a box is reachable by SOME parameter assignment.
211 */
212function 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
235function expectNoLinearSolution(a: bigint[], c: bigint) {
236 expect(solveLinearDiophantine(a, c)).toBeNull();

Callers 1

Calls 6

solveLinearDiophantineFunction · 0.90
cartesianRangeFunction · 0.85
linearSatisfiesFunction · 0.85
bruteForceLinearFunction · 0.85
invertParamsFunction · 0.85
substituteFunction · 0.70

Tested by

no test coverage detected