Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Sources/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed
[Tests/UnitTests/Algebra/SolveTest/SpuriousSystemRowTest.cs]
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n

[Tests/UnitTests/Convenience/DocCommentPlacementTest.cs]
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n

[Tests/UnitTests/Common/LambdaArrowSyntaxTest.cs]
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n

Expand Down
28 changes: 14 additions & 14 deletions Sources/AngouriMath/Convenience/MathS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6036,20 +6036,6 @@ public sealed record NewtonSetting
/// </summary>
public static Setting<EDecimal> PrecisionErrorZeroRange { get; } = EDecimal.Create(1, -16);

/// <summary>
/// The tolerance within which downcasting rounds a number onto a nearby integer.
/// </summary>
/// <remarks>
/// This is <see cref="PrecisionErrorZeroRange"/> whenever a caller has set it,
/// but its default of 1e-16 is far too coarse to be applied blindly: numbers are
/// evaluated to <see cref="DecimalPrecisionContext"/> digits, 100 by default, so
/// 1e-16 sits nowhere near the noise floor. Applying it destroyed every legitimate
/// small value -- <c>1e-20</c> parsed to zero and <c>e^(-40)</c> evaluated to zero.
/// Residuals genuinely left over by exact cancellation, such as the one from
/// <c>sin(pi)</c>, land around 1e-99, so half the working digits separates the two
/// cases with room to spare. Never looser than the setting's own default, so that
/// lowering the precision cannot silently widen the tolerance.
/// </remarks>
/// <summary>
/// <see cref="DowncastingTolerance"/> as a double, for the cheap check in front of
/// the exact one: the conversion of the decimal costs more than the check.
Expand All @@ -6067,6 +6053,20 @@ internal static double DowncastingToleranceAsDouble
}
}

/// <summary>
/// The tolerance within which downcasting rounds a number onto a nearby integer.
/// </summary>
/// <remarks>
/// This is <see cref="PrecisionErrorZeroRange"/> whenever a caller has set it,
/// but its default of 1e-16 is far too coarse to be applied blindly: numbers are
/// evaluated to <see cref="DecimalPrecisionContext"/> digits, 100 by default, so
/// 1e-16 sits nowhere near the noise floor. Applying it destroyed every legitimate
/// small value -- <c>1e-20</c> parsed to zero and <c>e^(-40)</c> evaluated to zero.
/// Residuals genuinely left over by exact cancellation, such as the one from
/// <c>sin(pi)</c>, land around 1e-99, so half the working digits separates the two
/// cases with room to spare. Never looser than the setting's own default, so that
/// lowering the precision cannot silently widen the tolerance.
/// </remarks>
internal static EDecimal DowncastingTolerance
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1382,10 +1382,6 @@ private Entity Leftover(List<Entity> operands, bool[] used)
return rest ?? (OverSum ? Entity.Number.Integer.Zero : Entity.Number.Integer.One);
}

/// <summary>
/// Shared across one <see cref="Match"/> call so the bound is on the whole search and
/// not on each branch of it, which is the difference between a bound and a suggestion.
/// </summary>
/// <summary>Choosing which operands the parts claim is the whole of what it does.</summary>
internal override bool IsDeterministic => false;

Expand Down Expand Up @@ -1439,6 +1435,10 @@ private Entity Combine(Entity left, Entity right)
private bool IsIdentity(Entity operand)
=> operand.Equals(OverSum ? Entity.Number.Integer.Zero : Entity.Number.Integer.One);

/// <summary>
/// Shared across one <see cref="Match"/> call so the bound is on the whole search and
/// not on each branch of it, which is the difference between a bound and a suggestion.
/// </summary>
private sealed class Budget
{
private int left;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@ internal Soundness Soundness
/// </summary>
internal IReadOnlyList<MatchedRule> RulesByPriority => byPriority;

/// <summary>One rewrite at this node only, leaving children alone.</summary>
/// <summary>
/// These rules as <see cref="RewriteRule"/> values, so that a set written as data can
/// appear in the registry beside the sets written as a <c>switch</c>.
Expand Down Expand Up @@ -695,6 +694,7 @@ internal IReadOnlyList<RewriteRule> AsAddressable()
return built;
}

/// <summary>One rewrite at this node only, leaving children alone.</summary>
internal Entity ApplyHere(Entity expr)
{
// The rules this node's type can possibly match, rather than all of them. See the
Expand Down
6 changes: 4 additions & 2 deletions Sources/AngouriMath/Core/Transformations/RewriteRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,16 @@ public static class RewriteRules
/// Opens a trigonometric function of a multiplied angle.
/// </summary>
/// <remarks>
/// <para>
/// Written out, <c>sin(4x)</c> is far longer than it started, which is why the
/// simplifier offers the result as a candidate rather than taking it.
/// </remarks>
/// <remarks>
/// </para>
/// <para>
/// <b>Run by the matcher rather than by the <c>switch</c></b> —
/// <see cref="Matching.MatchedRules.ExpandMultipleAngle"/>. See the note on
/// <see cref="CollapseMultipleFractions"/> for what that costs and why the <c>switch</c>
/// stays.
/// </para>
/// </remarks>
public static RewriteRuleSet ExpandMultipleAngle { get; } = new(
nameof(ExpandMultipleAngle),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ public static Transformation FactorizationAtLevel(int level)
/// Offered on its own as well as inside <see cref="FactorizationAtLevel"/>, because it is
/// the one step of factorisation whose answer a caller might want without the rest.
/// </para>
/// </remarks>
/// <remarks>
/// <para>
/// Held in a nested class rather than in a static field of this one, and that is not a
/// style choice. <see cref="Factorization"/> is declared <i>above</i> this and calls
/// <see cref="FactorizationAtLevel"/> in its own initialiser, which reads this — and a
/// static field initialiser runs in declaration order, so it would read <see langword="null"/>
/// and fail as a <c>TypeInitializationException</c> from somewhere else entirely. A nested
/// type initialises on first use instead, whatever order the fields are written in.
/// </para>
/// </remarks>
public static Transformation NumericContentExtraction => Held.Instance;

Expand Down Expand Up @@ -307,15 +307,15 @@ public static Transformation RuleBasedFactorizationAtLevel(int level)
/// and anything whose answer is not a product — a refusal leaves the expression exactly as
/// the rules left it, so nothing that factored before can stop factoring.
/// </para>
/// </remarks>
/// <remarks>
/// <para>
/// Held in a nested class rather than in a static field of this one. Static field
/// initialisers run in declaration order, and <see cref="Factorization"/> — declared
/// above — is eager, so a field here would still be <see langword="null"/> when its
/// pipeline is built. That surfaces as <c>ArgumentNullException(nameof(next))</c> from a
/// combinator rather than as anything naming the real cause, and this file has had that
/// failure before. A nested type is initialised on first touch, whatever order this
/// one's members are written in.
/// </para>
/// </remarks>
public static Transformation PolynomialFactorization => PolynomialFactorizationHolder.Instance;

Expand Down Expand Up @@ -575,8 +575,6 @@ public static Transformation EqualitySaturation(WorkBudget budget, CostModel cos
/// in the library calls this — like <see cref="Canonicalization"/> it is offered, not
/// applied.
/// </para>
/// </remarks>
/// <remarks>
/// <para>
/// <b>Built on <see cref="Canonicalization"/> rather than beside it.</b> The graph does
/// not sort a commutative operand pair: the rules that do build their replacement in code,
Expand Down
Loading
Loading