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
5 changes: 3 additions & 2 deletions Sources/AngouriMath/Convenience/MathS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5166,10 +5166,11 @@ public static class Matrices
/// </summary>
public enum Direction
{
#pragma warning disable CS1591
/// <summary>Side by side, so the columns of the second follow the first.</summary>
Horizontal,

/// <summary>One above the other, so the rows of the second follow the first.</summary>
Vertical
#pragma warning restore CS1591
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace AngouriMath
{
partial record Entity
{
#pragma warning disable CS1591 // only while records' parameters cannot be documented
/// <summary>
/// A node of signum
/// </summary>
public sealed partial record Signumf(Entity Argument) : Function, IUnaryNode
{
/// <inheritdoc/>
public Entity NodeChild => Argument;

private Signumf New(Entity arg) =>
Expand All @@ -32,6 +32,7 @@ private Signumf New(Entity arg) =>
/// </summary>
public sealed partial record Absf(Entity Argument) : Function, IUnaryNode
{
/// <inheritdoc/>
public Entity NodeChild => Argument;

private Absf New(Entity arg) =>
Expand All @@ -41,6 +42,5 @@ private Absf New(Entity arg) =>
/// <inheritdoc/>
protected override Entity[] InitDirectChildren() => new[] { Argument };
}
#pragma warning restore CS1591 // only while records' parameters cannot be documented
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace AngouriMath
{
partial record Entity
{
#pragma warning disable CS1591 // only while records' parameters cannot be documented
/// <summary>
/// A node of arcsine
/// </summary>
public sealed partial record Arcsinf(Entity Argument) : TrigonometricFunction, IUnaryNode
{
/// <inheritdoc/>
public Entity NodeChild => Argument;

/// <summary>Reuse the cache by returning the same object if possible</summary>
Expand All @@ -32,6 +32,7 @@ public sealed partial record Arcsinf(Entity Argument) : TrigonometricFunction, I
/// </summary>
public sealed partial record Arccosf(Entity Argument) : TrigonometricFunction, IUnaryNode
{
/// <inheritdoc/>
public Entity NodeChild => Argument;

/// <summary>Reuse the cache by returning the same object if possible</summary>
Expand All @@ -47,6 +48,7 @@ public sealed partial record Arccosf(Entity Argument) : TrigonometricFunction, I
/// </summary>
public sealed partial record Arctanf(Entity Argument) : TrigonometricFunction, IUnaryNode
{
/// <inheritdoc/>
public Entity NodeChild => Argument;

/// <summary>Reuse the cache by returning the same object if possible</summary>
Expand All @@ -62,6 +64,7 @@ public sealed partial record Arctanf(Entity Argument) : TrigonometricFunction, I
/// </summary>
public sealed partial record Arccotanf(Entity Argument) : TrigonometricFunction, IUnaryNode
{
/// <inheritdoc/>
public Entity NodeChild => Argument;

/// <summary>Reuse the cache by returning the same object if possible</summary>
Expand All @@ -77,6 +80,7 @@ public sealed partial record Arccotanf(Entity Argument) : TrigonometricFunction,
/// </summary>
public sealed partial record Arcsecantf(Entity Argument) : TrigonometricFunction, IUnaryNode
{
/// <inheritdoc/>
public Entity NodeChild => Argument;

/// <summary>Reuse the cache by returning the same object if possible</summary>
Expand All @@ -92,6 +96,7 @@ public sealed partial record Arcsecantf(Entity Argument) : TrigonometricFunction
/// </summary>
public sealed partial record Arccosecantf(Entity Argument) : TrigonometricFunction, IUnaryNode
{
/// <inheritdoc/>
public Entity NodeChild => Argument;

/// <summary>Reuse the cache by returning the same object if possible</summary>
Expand All @@ -101,6 +106,5 @@ public sealed partial record Arccosecantf(Entity Argument) : TrigonometricFuncti
/// <inheritdoc/>
protected override Entity[] InitDirectChildren() => new[] { Argument };
}
#pragma warning restore CS1591 // only while records' parameters cannot be documented
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace AngouriMath
{
partial record Entity
{
#pragma warning disable CS1591 // only while records' parameters cannot be documented
/// <summary>
/// A node of derivative
/// </summary>
Expand Down Expand Up @@ -64,6 +63,5 @@ public override Entity Replace(Func<Entity, Entity> func) =>
/// <inheritdoc/>
protected override Entity[] InitDirectChildren() => new[] { Expression, Var, Destination };
}
#pragma warning restore CS1591 // only while records' parameters cannot be documented
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,55 +195,136 @@ public static bool TryParse(string source,
public System.Numerics.Complex ToNumerics() =>
new System.Numerics.Complex(RealPart.EDecimal.ToDouble(), ImaginaryPart.EDecimal.ToDouble());

#pragma warning disable CS1591
/// <summary>
/// Narrows to <see cref="System.Numerics.Complex"/>, which is
/// <see cref="ToNumerics"/> and loses precision the same way.
/// </summary>
public static explicit operator System.Numerics.Complex(Complex it)
=> it.ToNumerics();

/// <summary>Their sum.</summary>
public static Complex operator +(Complex a, Complex b) => OpSum(a, b);

/// <summary>Their difference.</summary>
public static Complex operator -(Complex a, Complex b) => OpSub(a, b);

/// <summary>Their product.</summary>
public static Complex operator *(Complex a, Complex b) => OpMul(a, b);

/// <summary>Their quotient.</summary>
public static Complex operator /(Complex a, Complex b) => OpDiv(a, b);

/// <summary>The operand itself; unary plus changes nothing.</summary>
public static Complex operator +(Complex a) => a;

/// <summary>Its negation.</summary>
public static Complex operator -(Complex a) => OpMul(Integer.MinusOne, a);

// The conversions below share one surprise, stated once here and referred to
// rather than repeated: where MathS.Settings.DowncastingEnabled is on, which is
// the default, an exact whole value arrives as an Integer and an exact ratio as
// a Rational. The declared type is Complex either way, so the difference shows
// up in the runtime type and in what the number prints as, not in the signature.

/// <summary>The number as a <see cref="Complex"/>.</summary>
public static implicit operator Complex(sbyte value) => (long)value;

/// <summary>The number as a <see cref="Complex"/>.</summary>
public static implicit operator Complex(byte value) => (ulong)value;

/// <summary>The number as a <see cref="Complex"/>.</summary>
public static implicit operator Complex(short value) => (long)value;

/// <summary>The number as a <see cref="Complex"/>.</summary>
public static implicit operator Complex(ushort value) => (ulong)value;

/// <summary>The number as a <see cref="Complex"/>.</summary>
public static implicit operator Complex(int value) => (long)value;

/// <summary>The number as a <see cref="Complex"/>.</summary>
public static implicit operator Complex(uint value) => (ulong)value;

/// <summary>
/// The number as a <see cref="Complex"/> — an <see cref="Integer"/> at runtime
/// while downcasting is enabled.
/// </summary>
public static implicit operator Complex(long value)
=> MathS.Settings.DowncastingEnabled
? Integer.Create(value)
: Create(value, 0);
/// <summary>
/// The number as a <see cref="Complex"/> — an <see cref="Integer"/> at runtime
/// while downcasting is enabled.
/// </summary>
public static implicit operator Complex(ulong value)
=> MathS.Settings.DowncastingEnabled
? Integer.Create(value)
: Create(value, 0);

/// <summary>
/// The integer as a <see cref="Complex"/> — an <see cref="Integer"/> at runtime
/// while downcasting is enabled.
/// </summary>
public static implicit operator Complex(EInteger value)
=> MathS.Settings.DowncastingEnabled
? Integer.Create(value)
: Create(value, 0);

/// <summary>
/// The ratio as a <see cref="Complex"/> — a <see cref="Rational"/> at runtime
/// while downcasting is enabled, and so still exact.
/// </summary>
public static implicit operator Complex(ERational value)
=> MathS.Settings.DowncastingEnabled
? Rational.Create(value)
: Create(value, 0);

/// <summary>The decimal as a <see cref="Complex"/> with no imaginary part.</summary>
public static implicit operator Complex(EDecimal value)
=> Create(value, 0);

/// <summary>
/// The value as a <see cref="Complex"/> with no imaginary part. It is read as the
/// binary <see langword="float"/> it is, so a literal such as <c>0.1f</c> arrives
/// as the value that literal actually holds and not as one tenth.
/// </summary>
public static implicit operator Complex(float value)
=> Create(EDecimal.FromSingle(value), 0);

/// <summary>
/// The value as a <see cref="Complex"/> with no imaginary part, read as the
/// binary <see langword="double"/> it is rather than as the decimal it was
/// written as.
/// </summary>
public static implicit operator Complex(double value)
=> Create(EDecimal.FromDouble(value), 0);

/// <summary>
/// The value as a <see cref="Complex"/> with no imaginary part. A
/// <see langword="decimal"/> is decimal already, so this one keeps the digits
/// that were written.
/// </summary>
public static implicit operator Complex(decimal value)
=> Create(EDecimal.FromDecimal(value), 0);

/// <summary>
/// The .NET complex number as this one, through its two
/// <see langword="double"/> parts and their precision.
/// </summary>
public static implicit operator Complex(System.Numerics.Complex value) =>
Create(EDecimal.FromDouble(value.Real), EDecimal.FromDouble(value.Imaginary));

/// <summary>The pair read as real and imaginary parts.</summary>
public static implicit operator Complex((int re, int im) v) => Create(v.re, v.im);

/// <summary>The pair read as real and imaginary parts.</summary>
public static implicit operator Complex((float re, float im) v) => Create(v.re, v.im);
public static implicit operator Complex((decimal re, decimal im) v) => Create(v.re, v.im);
public static implicit operator Complex((double re, double im) v) => Create(v.re, v.im);

#pragma warning restore CS1591
/// <summary>The pair read as real and imaginary parts.</summary>
public static implicit operator Complex((decimal re, decimal im) v) => Create(v.re, v.im);

/// <summary>The pair read as real and imaginary parts.</summary>
public static implicit operator Complex((double re, double im) v) => Create(v.re, v.im);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace AngouriMath
{
partial record Entity
{
#pragma warning disable CS1591 // only while records' parameters cannot be documented
/// <summary>
/// A node of exponential (power)
/// </summary>
Expand All @@ -22,8 +21,10 @@ private Powf New(Entity @base, Entity exponent) =>
ReferenceEquals(Base, @base) && ReferenceEquals(Exponent, exponent) ? this : new(@base, exponent);
internal override Priority Priority => Priority.Pow;

/// <inheritdoc/>
public Entity NodeFirstChild => Base;

/// <inheritdoc/>
public Entity NodeSecondChild => Exponent;

/// <inheritdoc/>
Expand All @@ -41,8 +42,10 @@ public sealed partial record Logf(Entity Base, Entity Antilogarithm) : Function,
private Logf New(Entity @base, Entity antilogarithm) =>
ReferenceEquals(Base, @base) && ReferenceEquals(Antilogarithm, antilogarithm) ? this : new(@base, antilogarithm);

/// <inheritdoc/>
public Entity NodeFirstChild => Base;

/// <inheritdoc/>
public Entity NodeSecondChild => Antilogarithm;

/// <inheritdoc/>
Expand All @@ -51,6 +54,5 @@ private Logf New(Entity @base, Entity antilogarithm) =>
protected override Entity[] InitDirectChildren() => new[] { Base, Antilogarithm };
}

#pragma warning restore CS1591 // only while records' parameters cannot be documented
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace AngouriMath
{
partial record Entity
{
#pragma warning disable CS1591 // only while records' parameters cannot be documented
/// <summary>
/// A node of factorial
/// </summary>
Expand All @@ -22,13 +21,13 @@ public sealed partial record Factorialf(Entity Argument) : Function, IUnaryNode
// This is still a function for pattern replacement
internal override Priority Priority => Priority.Factorial;

/// <inheritdoc/>
public Entity NodeChild => Argument;

/// <inheritdoc/>
public override Entity Replace(Func<Entity, Entity> func) => func(New(Argument.Replace(func)));
/// <inheritdoc/>
protected override Entity[] InitDirectChildren() => new[] { Argument };
}
#pragma warning restore CS1591 // only while records' parameters cannot be documented
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace AngouriMath
{
partial record Entity
{
#pragma warning disable CS1591 // only while records' parameters cannot be documented
/// <summary>
/// A node of floor: the greatest integer not above the argument.
/// </summary>
Expand All @@ -23,6 +22,7 @@ partial record Entity
/// </remarks>
public sealed partial record Floorf(Entity Argument) : Function, IUnaryNode
{
/// <inheritdoc/>
public Entity NodeChild => Argument;

private Floorf New(Entity arg) =>
Expand All @@ -42,6 +42,7 @@ private Floorf New(Entity arg) =>
/// </remarks>
public sealed partial record Ceilf(Entity Argument) : Function, IUnaryNode
{
/// <inheritdoc/>
public Entity NodeChild => Argument;

private Ceilf New(Entity arg) =>
Expand All @@ -51,6 +52,5 @@ private Ceilf New(Entity arg) =>
/// <inheritdoc/>
protected override Entity[] InitDirectChildren() => new[] { Argument };
}
#pragma warning restore CS1591 // only while records' parameters cannot be documented
}
}
Loading
Loading