Repository navigation
Widen Mod to (m, n, d?): Mod(m, n, d) is d + Mod(m − d, n) - #658
Closed
enumeratio wants to merge 1 commit into
Closed
enumeratio wants to merge 1 commit into
enumeratio wants to merge 1 commit into
Conversation
…ue in [d, d + n), under evaluate() and .N(); the compile targets, enclosure, measurement, limit and derivative code decline the three-operand form; Epsil writes it as a call; add tests. Fix cortex-js#548
Member
|
Landed in f42a02d, with fixes made while landing (see the commit message). Thanks! |
arnog
added a commit
that referenced
this pull request
Nov 23, 2026
…(m, n, d), the optional combinatorics library, PiecewiseExpand - #657: @cortex-js/compute-engine/runtime exports sysHelpers, the stateless helpers that compiled code calls as _SYS.<name> (#527 item 1). - #658: Mod(m, n, d) is d + Mod(m - d, n), in [d, d + n) (#548). Every compile target declines the three-operand form; the derivative, limit, enclosure and measurement code leave it unevaluated. Fixed on landing: .N() reads exact operands exactly as the two-operand Mod does (exact cancellation of d, a symbol with an exact value near a jump, a dividend past the range of a double, no second evaluation of an impure operand); exact radicals stay exact; the type is real only for real operands. - #659: the optional combinatorics entry, loadCombinatorics(ce, { areas }), with about 350 permutation and 195 integer-partition statistics checked against FindStat (#531). Fixed on landing: the report of a re-load, a skipped head declared once the engine's definition is removed, the CI comment, string nodes without source offsets in compiled.ts, the synonym head LargestCycleLength removed (LongestCycleLength stays), one compiler decline test per area, and notes on list literals and time limits. - #660: PiecewiseExpand rewrites Abs, Sign, Min, Max and Heaviside into a Which (#516). Fixed on landing: an argument declared complex or number is not split; the arm limit is checked before the product is built; Max() and Min() with no operand; exact conditions between radicals; an impure expression is returned unchanged; the lazy-operator list and the search ranking test. - Issues CE-1734, CE-1735, CE-1736 filed from the decline census of #638. Co-authored-by: enumeratio <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mod(m, n, d)is the representative ofmmodulonin[d, d + n), as in Mathematica'sMod[m, n, d]. It was anunexpected-argumenterror. This is option 2 of #548.Evaluation. The signature is
(real, real, real?) -> real, and the value isd + Mod(m − d, n)underevaluate()and.N(), through the two-operand handler (so the exact-rational, float and zero-modulus rules apply as before):Mod(7, 3, 1)1Mod(9, 3, 1)3Mod(-1, 3, 1)2Mod(10, 4, -1)2Mod(7/2, 2, 1/2)3/2Mod(7.5, 3, 1)1.5Mod(x, 3, 1)The
typehandler takesdinto account (Mod(n, 3, 1/2)isrational, notinteger), andsgnmakes no claim for the three-operand form.Declined routes. The JavaScript, GLSL and interval targets and the bigint mode already refuse a
Modwith three operands (Mod with 3 operands), socompile()falls back to the interpreter and gives its value. Tests pin this for each. Python is not a built-in target here. The enclosure lowering,Enclosurearithmetic and the map-exact proof already check for two operands. Three places did not, and now decline:D(Mod(u, c, d), x)staysD(...)(it was the opaqueApply(Derivative(Mod, 1, 0, 0), …)), and is0when nothing depends onx;Mod(7 ± 0.1, 3, 1)stays unevaluated (the sawtooth rule ignoresd);.N(), which treats every element near a jump for the three-operand form.The limit code already requires two operands, so
Limitof a three-operandModstays unevaluated.LaTeX. The infix
\bmodserializer already falls back to the function form for other than two operands, so the offset is kept:\mathrm{Mod}(2x, 3, 1), which parses back to the same expression.\operatorname{mod}(7, 3, 1)parses toMod(7, 3, 1).Epsil. The infix
%is for exactly two operands:7 % 3 % 1parses asMod(Mod(7, 3), 1), soMod(m, n, d)is written as a call,Mod(7, 3, 1), which parses back to the same expression. The round-trip corpus gains the two-operand, literal-offset and symbolic-offset cases.No
evaluateModhook is added; this keeps to the #527 item 3 separation.OPERATORS.jsonandlibrary.mdare updated by hand for the signature and an example.Tests.
item-548-mod-offset.test.ts: exact, rational and float cases underevaluate()and.N(), the interval property over a grid, symbolic operands, the type, broadcast, each declined route (compile throws withfallback: false, and withfallback: trueruns to the interpreter's value), LaTeX and Epsil. The two-operandModtests (arithmetic, compile-mod-fast-path, derivatives, enclosure, measurement, jump and limit suites) pass unchanged.Fixes #548