< Summary

Class:Towel.Mathematics.MathematicsSyntax
Assembly:Towel
File(s):File 1: /home/runner/work/Towel/Towel/Sources/Towel/Mathematics/MathematicsSyntax.cs
Covered lines:0
Uncovered lines:8
Coverable lines:8
Total lines:83
Line coverage:0% (0 of 8)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
File 1: Σ(...)100%10%
File 1: Σ(...)100%10%
File 1: Σ(...)100%10%
File 1: Σ(...)100%10%
File 1: Π(...)100%10%
File 1: Π(...)100%10%
File 1: Π(...)100%10%
File 1: Π(...)100%10%

File(s)

/home/runner/work/Towel/Towel/Sources/Towel/Mathematics/MathematicsSyntax.cs

#LineLine coverage
 1namespace Towel.Mathematics;
 2
 3/// <summary>Contains static methods for mathematics syntax.</summary>
 4public static class MathematicsSyntax
 5{
 6  #region Summation: Σ
 7
 8  /// <summary>Adds two values [<paramref name="a"/> + <paramref name="b"/>].</summary>
 9  /// <typeparam name="TA">The type of the left operand.</typeparam>
 10  /// <typeparam name="TB">The type of the right operand.</typeparam>
 11  /// <typeparam name="TC">The type of the return.</typeparam>
 12  /// <param name="a">The left operand.</param>
 13  /// <param name="b">The right operand.</param>
 14  /// <returns>The result of the addition [<paramref name="a"/> + <paramref name="b"/>].</returns>
 15  public static TC Σ<TA, TB, TC>(TA a, TB b) =>
 016    Addition<TA, TB, TC>(a, b);
 17
 18  /// <summary>Adds two values [<paramref name="a"/> + <paramref name="b"/>].</summary>
 19  /// <typeparam name="T">The numeric type of the operation.</typeparam>
 20  /// <param name="a">The left operand.</param>
 21  /// <param name="b">The right operand.</param>
 22  /// <returns>The result of the addition [<paramref name="a"/> + <paramref name="b"/>].</returns>
 23  public static T Σ<T>(T a, T b) =>
 024    Addition<T, T, T>(a, b);
 25
 26  /// <summary>Adds multiple values [<paramref name="a"/> + <paramref name="b"/> + <paramref name="c"/> + ...].</summary
 27  /// <typeparam name="T">The type of the operation.</typeparam>
 28  /// <param name="a">The first operand of the addition.</param>
 29  /// <param name="b">The second operand of the addition.</param>
 30  /// <param name="c">The third operand of the addition.</param>
 31  /// <param name="d">The remaining operands of the addition.</param>
 32  /// <returns>The result of the addition [<paramref name="a"/> + <paramref name="b"/> + <paramref name="c"/> + ...].</r
 33  public static T Σ<T>(T a, T b, T c, params T[] d) =>
 034    Addition<T>(step => { step(a); step(b); step(c); d.ToStepper()(step); });
 35
 36  /// <summary>Adds multiple values [step1 + step2 + step3 + ...].</summary>
 37  /// <typeparam name="T">The type of the operation.</typeparam>
 38  /// <param name="stepper">The stepper of the values to add.</param>
 39  /// <returns>The result of the addition [step1 + step2 + step3 + ...].</returns>
 40  public static T Σ<T>(Action<Action<T>> stepper) =>
 041    Addition(stepper);
 42
 43  #endregion
 44
 45  #region Product: Π
 46
 47  /// <summary>Multiplies two values [<paramref name="a"/> * <paramref name="b"/>].</summary>
 48  /// <typeparam name="TA">The type of the left operand.</typeparam>
 49  /// <typeparam name="TB">The type of the right operand.</typeparam>
 50  /// <typeparam name="TC">The type of the return.</typeparam>
 51  /// <param name="a">The left operand.</param>
 52  /// <param name="b">The right operand.</param>
 53  /// <returns>The result of the multiplication [<paramref name="a"/> * <paramref name="b"/>].</returns>
 54  public static TC Π<TA, TB, TC>(TA a, TB b) =>
 055    Multiplication<TA, TB, TC>(a, b);
 56
 57  /// <summary>Multiplies two values [<paramref name="a"/> * <paramref name="b"/>].</summary>
 58  /// <typeparam name="T">The type of the operation.</typeparam>
 59  /// <param name="a">The left operand.</param>
 60  /// <param name="b">The right operand.</param>
 61  /// <returns>The result of the multiplication [<paramref name="a"/> * <paramref name="b"/>].</returns>
 62  public static T Π<T>(T a, T b) =>
 063    Multiplication<T, T, T>(a, b);
 64
 65  /// <summary>Multiplies multiple values [<paramref name="a"/> * <paramref name="b"/> * <paramref name="c"/> * ...].</s
 66  /// <typeparam name="T">The type of the operation.</typeparam>
 67  /// <param name="a">The first operand.</param>
 68  /// <param name="b">The second operand.</param>
 69  /// <param name="c">The third operand.</param>
 70  /// <param name="d">The remaining values.</param>
 71  /// <returns>The result of the multiplication [<paramref name="a"/> * <paramref name="b"/> * <paramref name="c"/> * ..
 72  public static T Π<T>(T a, T b, T c, params T[] d) =>
 073    Multiplication(a, b, c, d);
 74
 75  /// <summary>Multiplies multiple numeric values [step1 * step2 * step3 * ...].</summary>
 76  /// <typeparam name="T">The type of the operation.</typeparam>
 77  /// <param name="stepper">The stepper containing the values.</param>
 78  /// <returns>The result of the multiplication [step1 * step2 * step3 * ...].</returns>
 79  public static T Π<T>(Action<Action<T>> stepper) =>
 080    Multiplication(stepper);
 81
 82  #endregion
 83}