< Summary

Information
Class: FixedMathSharp.Geometry.FiniteAxisValueRoot
Assembly: FixedMathSharp
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Geometry/Wide/FiniteAxis/FiniteAxisValueRoot.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 48
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
CopyTo(...)100%11100%

File(s)

/home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Geometry/Wide/FiniteAxis/FiniteAxisValueRoot.cs

#LineLine coverage
 1//=======================================================================
 2// FiniteAxisValueRoot.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System;
 9
 10namespace FixedMathSharp.Geometry;
 11
 12/// <summary>
 13/// One ordinal-selected root in (0,1] of a degree-at-most-eight integer value
 14/// polynomial. Borrowed coefficients and cell storage outlive this view.
 15/// </summary>
 16internal ref struct FiniteAxisValueRoot
 17{
 18    internal ReadOnlySpan<ulong> Coefficients;
 19    internal ReadOnlySpan<sbyte> Signs;
 20    internal Span<ulong> LowerNumerator;
 21    internal int DenominatorShift;
 22    internal int Ordinal;
 23    internal bool IsRational;
 24
 25    /// <summary>Copies a root into independent storage and returns a view borrowing only the destinations.</summary>
 26    /// <remarks>
 27    /// The source must be a valid root. Destinations must be mutually disjoint
 28    /// and disjoint from source storage. Coefficient and sign capacities must
 29    /// hold the source polynomial spans; cell capacity must hold the active
 30    /// numerator and, for a nonrational root, its excluded upper endpoint.
 31    /// Polynomial destination tails are untouched; the cell tail is cleared.
 32    /// </remarks>
 33    internal static FiniteAxisValueRoot CopyTo(scoped FiniteAxisValueRoot source,
 34        Span<ulong> coefficients, Span<sbyte> signs, Span<ulong> cell)
 35    {
 40736        source.Coefficients.CopyTo(coefficients);
 40737        source.Signs.CopyTo(signs);
 40738        int words = WideArithmetic.GetActiveMagnitudeLength(source.LowerNumerator);
 40739        source.LowerNumerator[..words].CopyTo(cell);
 40740        cell[words..].Clear();
 40741        return new FiniteAxisValueRoot
 40742        {
 40743            Coefficients = coefficients[..source.Coefficients.Length], Signs = signs[..source.Signs.Length],
 40744            LowerNumerator = cell, DenominatorShift = source.DenominatorShift,
 40745            Ordinal = source.Ordinal, IsRational = source.IsRational
 40746        };
 47    }
 48}