Skip to content

Expose Euclid integer utilities in expressions, scripts and autocomplete - #309

Draft
PawelTroka wants to merge 1 commit into
masterfrom
feature/euclid-utilities-125-20261030
Draft

PawelTroka wants to merge 1 commit into
masterfrom
feature/euclid-utilities-125-20261030

Conversation

@PawelTroka

@PawelTroka PawelTroka commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Problem

Fixes #125.

Math.NET's integer utilities are already shipped, but the useful Euclid.* API is unavailable by that name in TSL and absent from the application's completion/reference catalog. Reimplementing the algorithms would duplicate the pinned dependency.

Change

  • Expose the existing MathNet.Numerics.Euclid class through the shared TSL preamble used by desktop, web API and portable execution.
  • Add reflection-based completion and 16 authored reference entries covering 12 method families / 37 overloads: GCD, LCM, extended GCD, modulus/remainder, parity, perfect squares, powers of two and binary size helpers.
  • Correct reflected out/ref/in argument insertion and typed captions. Extended GCD completion now inserts out x,out y; the same fix repairs four existing read<T> / readln<T> signatures.
  • Document exact integer script output, BigInteger use, real-calculator conversion, overload selection and the pinned library's overflow/collection edge cases.

Examples:

Euclid.GreatestCommonDivisor(-84,30)  // 6
Euclid.Modulus(-7,3)                // 2
Euclid.PowerOfTwo((integer)40)      // 1099511627776

integer u,v;
integer d = Euclid.ExtendedGreatestCommonDivisor(240,46,out u,out v);
write(240*u+46*v);                  // 2

Existing gcd/nwd/lcm/nww behavior remains intact. No new dependency or numerical wrapper implementation.

Validation

  • The original 33 new execution cases all fail on master with missing Euclid (CS0103); the final expanded fixture passes 34/34.
  • Complete portable Engine suite on the final commit: 1,472 passed, zero failed/skipped.
  • Actual production reflection / insertion execution harness: 16/16 passed, including reproducing the prior missing-out CS1620 errors.
  • Python reference authoring: 63/63 passed; deterministic regeneration matches the committed XML.
  • Windows Core.Tests cross-build: passed, zero errors, six existing compiler warnings. Restore with vulnerability auditing succeeded.
  • 1,216 unaffected base reference articles remain byte-identical; four existing scripting signatures are corrected and 16 Euclid entries are added.
  • git diff --check passed.

Local execution was Linux x64 with SDK 10.0.402. Native Windows evaluator/completion execution and full runtime-catalog validation remain CI gates; cross-building is not native Windows acceptance.

The uploaded tree 361a4cc2935f75ed8bb3627ef72afe9249d82b08 exactly matches the tested local commit 44f87104843d3ff1e9f0459b3a3eeece74c40960.

Reference and compatibility

The existing pinned Math.NET 5.0.0 Euclid implementation defines arithmetic and error behavior. The documentation explicitly describes inherited edge cases, including fixed-width overflow and collection GCD with a leading zero.

Runtime inventory was extended using the actual compiled production reflection source, starting from the authenticated successful master reference artifact. Native Reference-Validate independently verifies the full catalog in CI.

Existing work

Reviewed the 78 open issues, seven original open PRs, all closed PR titles and relevant recent bodies; refreshed the open list immediately before publication. None covers #125. This is separate from the Mono autocomplete window/layout work in #299 and from the new secant-root/translation PRs.

Independently based on master fe1aba49b5f9538355ffaaa3d1683f69a23d2d9c. Draft pending native CI; no merge performed.

Combined integration verification

Applied #304, #307, #308, #309 and #310 together in a separate local checkout; all five patches applied cleanly. The combined portable Engine suite passed 1,565/1,565 tests, with no failures or skips, and the combined Windows Desktop.Tests cross-build completed with zero errors (seven existing package/compiler warnings). Native Windows execution remains a CI gate. Each PR still targets master independently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider exposing MathNet.Numerics.Euclid

1 participant