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

Function pellFamilyMembersInBox

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

* Applies the family-generation rule documented on `PellResult`: every class * rep times unit^t for `t` in `[-tRange, tRange]`, plus the global negation, * filtered down to the `|x|,|y| ≤ bound` box (to match a bounded * `bruteForcePell` oracle).

(
  classes: [bigint, bigint][],
  unit: [bigint, bigint],
  D: bigint,
  tRange: bigint,
  bound: bigint
)

Source from the content-addressed store, hash-verified

404 * `bruteForcePell` oracle).
405 */
406function pellFamilyMembersInBox(
407 classes: [bigint, bigint][],
408 unit: [bigint, bigint],
409 D: bigint,
410 tRange: bigint,
411 bound: bigint
412): [bigint, bigint][] {
413 const invUnit: [bigint, bigint] = [unit[0], -unit[1]];
414 const all: [bigint, bigint][] = [];
415 for (const cls of classes) {
416 all.push(cls);
417 let pos = cls;
418 for (let t = 1n; t <= tRange; t++) {
419 pos = pellMul(pos, unit, D);
420 all.push(pos);
421 }
422 let neg = cls;
423 for (let t = 1n; t <= tRange; t++) {
424 neg = pellMul(neg, invUnit, D);
425 all.push(neg);
426 }
427 }
428 const withNegation = all.concat(all.map(([x, y]) => [-x, -y] as [bigint, bigint]));
429 return dedupePairsLocal(withNegation).filter(
430 ([x, y]) => x <= bound && x >= -bound && y <= bound && y >= -bound
431 );
432}
433
434/**
435 * Cross-checks a `'family'` `solvePell` result against the independent

Callers 2

Calls 3

pellMulFunction · 0.85
dedupePairsLocalFunction · 0.85
mapMethod · 0.65

Tested by

no test coverage detected