Files
QWERTYkez.Mensura/QWERTYkez.Mensura/Units/XXXXXXXX.Gen.cs
melekhin ba77411c4a pogon...
2026-05-29 16:45:24 +07:00

1681 lines
76 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//using System.Globalization;
//using System.Runtime.Serialization;
//namespace QWERTYkez.Mensura.Units;
//[JsonConverter(typeof(XXXXXXXXXXXXXXConverter))]
//public readonly partial record struct XXXXXXXXXXXXXX
//{
// [JsonInclude, DataMember, JsonPropertyName("v")] // для JSON / EF на случай сбоев, если пробелма с _Value
// internal double _Value { get => _Value; init => _Value = value; }
// internal readonly double _Value;
// internal XXXXXXXXXXXXXX(double value) => _Value = value;
// public override int GetHashCode() => _Value.GetHashCode();
// public int CompareTo(XXXXXXXXXXXXXX? other) => _Value.CompareTo(other is null ? 0d : other._Value._Value);
// public int CompareTo(XXXXXXXXXXXXXX other) => _Value.CompareTo(other._Value);
// public bool Equals(XXXXXXXXXXXXXX? other) => _Value.Equals(other?._Value);
// [JsonIgnore, IgnoreDataMember] public bool IsPositive => _Value >= 0;
// [JsonIgnore, IgnoreDataMember] public bool IsGreaterThanZero => _Value > 0;
// [JsonIgnore, IgnoreDataMember] public bool IsNegative => _Value < 0;
// [JsonIgnore, IgnoreDataMember] public bool IsZero => _Value == 0;
// public static XXXXXXXXXXXXXX Zero { get; } = new(0d);
// public static XXXXXXXXXXXXXX Min { get; } = new(double.MinValue);
// public static XXXXXXXXXXXXXX Max { get; } = new(double.MaxValue);
// public static XXXXXXXXXXXXXX NegativeInfinity { get; } = new(double.NegativeInfinity);
// public static XXXXXXXXXXXXXX PositiveInfinity { get; } = new(double.PositiveInfinity);
// public static bool operator ==(XXXXXXXXXXXXXX? T1, XXXXXXXXXXXXXX? T2) => (T1 is null ? 0d : T1._Value._Value) == (T2 is null ? 0d : T2._Value._Value);
// public static bool operator !=(XXXXXXXXXXXXXX? T1, XXXXXXXXXXXXXX? T2) => (T1 is null ? 0d : T1._Value._Value) != (T2 is null ? 0d : T2._Value._Value);
// public static bool operator <(XXXXXXXXXXXXXX? T1, XXXXXXXXXXXXXX? T2) => (T1 is null ? 0d : T1._Value._Value) < (T2 is null ? 0d : T2._Value._Value);
// public static bool operator <=(XXXXXXXXXXXXXX? T1, XXXXXXXXXXXXXX? T2) => (T1 is null ? 0d : T1._Value._Value) <= (T2 is null ? 0d : T2._Value._Value);
// public static bool operator >(XXXXXXXXXXXXXX? T1, XXXXXXXXXXXXXX? T2) => (T1 is null ? 0d : T1._Value._Value) > (T2 is null ? 0d : T2._Value._Value);
// public static bool operator >=(XXXXXXXXXXXXXX? T1, XXXXXXXXXXXXXX? T2) => (T1 is null ? 0d : T1._Value._Value) >= (T2 is null ? 0d : T2._Value._Value);
// public static XXXXXXXXXXXXXX operator +(XXXXXXXXXXXXXX T2) => new(+T2._Value);
// public static XXXXXXXXXXXXXX operator +(XXXXXXXXXXXXXX T1, XXXXXXXXXXXXXX T2) => new(T1._Value + T2._Value);
// public static XXXXXXXXXXXXXX operator -(XXXXXXXXXXXXXX T2) => new(-T2._Value);
// public static XXXXXXXXXXXXXX operator -(XXXXXXXXXXXXXX T1, XXXXXXXXXXXXXX T2) => new(T1._Value - T2._Value);
// // double
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, double T2) => new(T1._Value * T2);
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, double? T2) => T1 * (T2 ?? 0d);
// public static XXXXXXXXXXXXXX operator *(double T1, XXXXXXXXXXXXXX T2) => new(T1 * T2._Value);
// public static XXXXXXXXXXXXXX operator *(double? T1, XXXXXXXXXXXXXX T2) => (T1 ?? 0d) * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, double T2) => new(T1._Value / T2);
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, double? T2) => T1 / (T2 ?? 0d);
// public static double operator /(XXXXXXXXXXXXXX T1, XXXXXXXXXXXXXX T2) => T1._Value / T2._Value;
// // sbyte
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, sbyte T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, sbyte? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(sbyte T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(sbyte? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, sbyte T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, sbyte? T2) => T1 / T2.ToDouble();
// // short
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, short T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, short? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(short T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(short? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, short T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, short? T2) => T1 / T2.ToDouble();
// // int
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, int T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, int? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(int T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(int? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, int T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, int? T2) => T1 / T2.ToDouble();
// // long
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, long T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, long? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(long T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(long? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, long T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, long? T2) => T1 / T2.ToDouble();
// // byte
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, byte T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, byte? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(byte T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(byte? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, byte T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, byte? T2) => T1 / T2.ToDouble();
// // ushort
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, ushort T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, ushort? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(ushort T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(ushort? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, ushort T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, ushort? T2) => T1 / T2.ToDouble();
// // uint
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, uint T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, uint? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(uint T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(uint? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, uint T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, uint? T2) => T1 / T2.ToDouble();
// // ulong
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, ulong T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, ulong? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(ulong T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(ulong? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, ulong T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, ulong? T2) => T1 / T2.ToDouble();
// // nint
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, nint T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, nint? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(nint T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(nint? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, nint T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, nint? T2) => T1 / T2.ToDouble();
// // nuint
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, nuint T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, nuint? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(nuint T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(nuint? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, nuint T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, nuint? T2) => T1 / T2.ToDouble();
// // float
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, float T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, float? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(float T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(float? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, float T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, float? T2) => T1 / T2.ToDouble();
// // decimal
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, decimal T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, decimal? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(decimal T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(decimal? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, decimal T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, decimal? T2) => T1 / T2.ToDouble();
//#if NET7_0_OR_GREATER
// // Int128
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, Int128 T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, Int128? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(Int128 T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(Int128? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, Int128 T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, Int128? T2) => T1 / T2.ToDouble();
// // UInt128
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, UInt128 T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, UInt128? T2) => T1 * T2.ToDouble();
// public static XXXXXXXXXXXXXX operator *(UInt128 T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator *(UInt128? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, UInt128 T2) => T1 / T2.ToDouble();
// public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, UInt128? T2) => T1 / T2.ToDouble();
//#endif
// public static explicit operator XXXXXXXXXXXXXX(double val) => new(val);
// public static explicit operator double(XXXXXXXXXXXXXX unit) => unit._Value;
// public XXXXXXXXXXXXXX Abs() => new(Math.Abs(_Value));
// /// <summary>C^2 = this^2 + B^2</summary> <returns>C = (this^2 + B^2).Sqrt(2)</returns>
// public XXXXXXXXXXXXXX HypFromLeg(XXXXXXXXXXXXXX B) => new(Math.Sqrt(_Value * _Value + B._Value * B._Value));
// /// <summary>C^2 = this^2 + B^2</summary> <returns>C = (this^2 + B^2).Sqrt(2)</returns>
// public XXXXXXXXXXXXXX HypFromLeg(XXXXXXXXXXXXXX? B)
// {
// double b = B is null ? 0d : B._Value._Value;
// return new(Math.Sqrt(_Value * _Value + b * b));
// }
// /// <summary>C^2 = this^2 + B^2</summary> <returns>B = (C^2 - this^2).Sqrt(2)</returns>
// public XXXXXXXXXXXXXX LegFromHyp(XXXXXXXXXXXXXX C) => new(Math.Sqrt(C._Value * C._Value - _Value * _Value));
// /// <summary>C^2 = this^2 + B^2</summary> <returns>B = (C^2 - this^2).Sqrt(2)</returns>
// public XXXXXXXXXXXXXX LegFromHyp(XXXXXXXXXXXXXX? C)
// {
// double c = C is null ? 0d : C._Value._Value;
// return new(Math.Sqrt(c * c - _Value * _Value));
// }
// /// <summary>this^2 = A^2 + B^2</summary> <returns>B = (this^2 - A^2).Sqrt(2)</returns>
// public XXXXXXXXXXXXXX LegFromLeg(XXXXXXXXXXXXXX A) => new(Math.Sqrt(_Value * _Value - A._Value * A._Value));
// /// <summary>this^2 = A^2 + B^2</summary> <returns>B = (this^2 - A^2).Sqrt(2)</returns>
// public XXXXXXXXXXXXXX LegFromLeg(XXXXXXXXXXXXXX? A)
// {
// double a = A is null ? 0d : A._Value._Value;
// return new(Math.Sqrt(_Value * _Value - a * a));
// }
//}
//public static class XXXXXXXXXXXXXXExtension
//{
// internal static double ToDouble(this XXXXXXXXXXXXXX? unit) => unit is null ? 0d : unit._Value._Value;
// public static XXXXXXXXXXXXXX MetricSum(this IEnumerable<XXXXXXXXXXXXXX> units) => new() { _Value = units?.Sum(m => m._Value) ?? 0d };
// public static XXXXXXXXXXXXXX MetricAverage(this IEnumerable<XXXXXXXXXXXXXX> units) => new() { _Value = units?.Average(m => m._Value) ?? double.NaN };
// public static XXXXXXXXXXXXXX MetricMax(this IEnumerable<XXXXXXXXXXXXXX> units) => new() { _Value = units?.Max(m => m._Value) ?? double.MinValue };
// public static XXXXXXXXXXXXXX MetricMin(this IEnumerable<XXXXXXXXXXXXXX> units) => new() { _Value = units?.Min(m => m._Value) ?? double.MaxValue };
// public static XXXXXXXXXXXXXX MetricSum(this IEnumerable<XXXXXXXXXXXXXX?> units) => new() { _Value = units?.Sum(m => m.ToDouble()) ?? 0d };
// public static XXXXXXXXXXXXXX MetricAverage(this IEnumerable<XXXXXXXXXXXXXX?> units) => new() { _Value = units?.Average(m => m.ToDouble()) ?? double.NaN };
// public static XXXXXXXXXXXXXX MetricMax(this IEnumerable<XXXXXXXXXXXXXX?> units) => new() { _Value = units?.Max(m => m.ToDouble()) ?? double.MinValue };
// public static XXXXXXXXXXXXXX MetricMin(this IEnumerable<XXXXXXXXXXXXXX?> units) => new() { _Value = units?.Min(m => m.ToDouble()) ?? double.MaxValue };
// internal static void MultiplyCore(ReadOnlySpan<XXXXXXXXXXXXXX> source, double value, Span<XXXXXXXXXXXXXX> destination)
// {
// int len = source.Length;
// ReadOnlySpan<double> srcDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(source);
// Span<double> dstDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(destination);
// var vectorized_Value = new Vector<double>(value);
// int vectorSize = Vector<double>.Count;
// int i = 0;
// ref double srcRef = ref MemoryMarshal.GetReference(srcDouble);
// ref double dstRef = ref MemoryMarshal.GetReference(dstDouble);
// int SIMDEnd = len - (len % vectorSize);
// for (; i < SIMDEnd; i += vectorSize)
// {
// ref double currentSrc = ref Unsafe.Add(ref srcRef, i);
// ReadOnlySpan<double> srcWindow = MemoryMarshal.CreateReadOnlySpan(ref currentSrc, vectorSize);
// var vector = new Vector<double>(srcWindow);
// var multiplied = vector * vectorized_Value;
// ref double currentDst = ref Unsafe.Add(ref dstRef, i);
// Span<double> dstWindow = MemoryMarshal.CreateSpan(ref currentDst, vectorSize);
// multiplied.CopyTo(dstWindow);
// }
// for (; i < len; i++)
// {
// Unsafe.Add(ref dstRef, i) = Unsafe.Add(ref srcRef, i) * value;
// }
// }
// internal static void DivideCore(ReadOnlySpan<XXXXXXXXXXXXXX> source, double divisor, Span<XXXXXXXXXXXXXX> destination)
// {
// // 1. Проверка на ноль
// if (divisor == 0d || double.IsNaN(divisor))
// throw new DivideByZeroException("Делитель не может быть равен нулю.");
// int len = source.Length;
// ReadOnlySpan<double> srcDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(source);
// Span<double> dstDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(destination);
// var vectorized_Value = new Vector<double>(divisor);
// int vectorSize = Vector<double>.Count;
// int i = 0;
// ref double srcRef = ref MemoryMarshal.GetReference(srcDouble);
// ref double dstRef = ref MemoryMarshal.GetReference(dstDouble);
// int SIMDEnd = len - (len % vectorSize);
// for (; i < SIMDEnd; i += vectorSize)
// {
// ref double currentSrc = ref Unsafe.Add(ref srcRef, i);
// ReadOnlySpan<double> srcWindow = MemoryMarshal.CreateReadOnlySpan(ref currentSrc, vectorSize);
// var vector = new Vector<double>(srcWindow);
// var multiplied = vector / vectorized_Value;
// ref double currentDst = ref Unsafe.Add(ref dstRef, i);
// Span<double> dstWindow = MemoryMarshal.CreateSpan(ref currentDst, vectorSize);
// multiplied.CopyTo(dstWindow);
// }
// for (; i < len; i++)
// {
// Unsafe.Add(ref dstRef, i) = Unsafe.Add(ref srcRef, i) / divisor;
// }
// }
// internal static void DivideCore(double dividend, ReadOnlySpan<XXXXXXXXXXXXXX> source, Span<XXXXXXXXXXXXXX> destination)
// {
// int len = source.Length;
// ReadOnlySpan<double> srcDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(source);
// Span<double> dstDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(destination);
// var vectorized_Value = new Vector<double>(dividend);
// var zeroVector = Vector<double>.Zero; // Вектор из нулей для сравнения
// int vectorSize = Vector<double>.Count;
// int i = 0;
// ref double srcRef = ref MemoryMarshal.GetReference(srcDouble);
// ref double dstRef = ref MemoryMarshal.GetReference(dstDouble);
// int SIMDEnd = len - (len % vectorSize);
// for (; i < SIMDEnd; i += vectorSize)
// {
// ref double currentSrc = ref Unsafe.Add(ref srcRef, i);
// ReadOnlySpan<double> srcWindow = MemoryMarshal.CreateReadOnlySpan(ref currentSrc, vectorSize);
// var vector = new Vector<double>(srcWindow);
// // БЫСТРАЯ ПРОВЕРКА: Есть ли хотя бы один 0.0 в текущем векторе?
// if (Vector.EqualsAny(vector, zeroVector))
// {
// throw new DivideByZeroException($"Обнаружен делитель, равный нулю, в районе индексов {i}..{i + vectorSize - 1}.");
// }
// var multiplied = vectorized_Value / vector;
// ref double currentDst = ref Unsafe.Add(ref dstRef, i);
// Span<double> dstWindow = MemoryMarshal.CreateSpan(ref currentDst, vectorSize);
// multiplied.CopyTo(dstWindow);
// }
// // Хвостовой цикл
// for (; i < len; i++)
// {
// double divisor = Unsafe.Add(ref srcRef, i);
// if (divisor == 0.0)
// {
// throw new DivideByZeroException($"Обнаружен делитель, равный нулю, в индексе {i}.");
// }
// Unsafe.Add(ref dstRef, i) = dividend / divisor;
// }
// }
// internal static void PlusCore(ReadOnlySpan<XXXXXXXXXXXXXX> source, double summand, Span<XXXXXXXXXXXXXX> destination)
// {
// int len = source.Length;
// ReadOnlySpan<double> srcDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(source);
// Span<double> dstDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(destination);
// var vectorized_Value = new Vector<double>(summand);
// int vectorSize = Vector<double>.Count;
// int i = 0;
// ref double srcRef = ref MemoryMarshal.GetReference(srcDouble);
// ref double dstRef = ref MemoryMarshal.GetReference(dstDouble);
// int SIMDEnd = len - (len % vectorSize);
// for (; i < SIMDEnd; i += vectorSize)
// {
// ref double currentSrc = ref Unsafe.Add(ref srcRef, i);
// ReadOnlySpan<double> srcWindow = MemoryMarshal.CreateReadOnlySpan(ref currentSrc, vectorSize);
// var vector = new Vector<double>(srcWindow);
// var multiplied = vector + vectorized_Value;
// ref double currentDst = ref Unsafe.Add(ref dstRef, i);
// Span<double> dstWindow = MemoryMarshal.CreateSpan(ref currentDst, vectorSize);
// multiplied.CopyTo(dstWindow);
// }
// for (; i < len; i++)
// {
// Unsafe.Add(ref dstRef, i) = Unsafe.Add(ref srcRef, i) + summand;
// }
// }
// internal static void MinusCore(ReadOnlySpan<XXXXXXXXXXXXXX> source, double subtrahend, Span<XXXXXXXXXXXXXX> destination)
// {
// int len = source.Length;
// ReadOnlySpan<double> srcDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(source);
// Span<double> dstDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(destination);
// var vectorized_Value = new Vector<double>(subtrahend);
// int vectorSize = Vector<double>.Count;
// int i = 0;
// ref double srcRef = ref MemoryMarshal.GetReference(srcDouble);
// ref double dstRef = ref MemoryMarshal.GetReference(dstDouble);
// int SIMDEnd = len - (len % vectorSize);
// for (; i < SIMDEnd; i += vectorSize)
// {
// ref double currentSrc = ref Unsafe.Add(ref srcRef, i);
// ReadOnlySpan<double> srcWindow = MemoryMarshal.CreateReadOnlySpan(ref currentSrc, vectorSize);
// var vector = new Vector<double>(srcWindow);
// var multiplied = vector - vectorized_Value;
// ref double currentDst = ref Unsafe.Add(ref dstRef, i);
// Span<double> dstWindow = MemoryMarshal.CreateSpan(ref currentDst, vectorSize);
// multiplied.CopyTo(dstWindow);
// }
// for (; i < len; i++)
// {
// Unsafe.Add(ref dstRef, i) = Unsafe.Add(ref srcRef, i) - subtrahend;
// }
// }
// internal static void MinusCore(double minuend, ReadOnlySpan<XXXXXXXXXXXXXX> source, Span<XXXXXXXXXXXXXX> destination)
// {
// int len = source.Length;
// ReadOnlySpan<double> srcDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(source);
// Span<double> dstDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(destination);
// var vectorized_Value = new Vector<double>(minuend);
// int vectorSize = Vector<double>.Count;
// int i = 0;
// ref double srcRef = ref MemoryMarshal.GetReference(srcDouble);
// ref double dstRef = ref MemoryMarshal.GetReference(dstDouble);
// int SIMDEnd = len - (len % vectorSize);
// for (; i < SIMDEnd; i += vectorSize)
// {
// ref double currentSrc = ref Unsafe.Add(ref srcRef, i);
// ReadOnlySpan<double> srcWindow = MemoryMarshal.CreateReadOnlySpan(ref currentSrc, vectorSize);
// var vector = new Vector<double>(srcWindow);
// var multiplied = vectorized_Value - vector;
// ref double currentDst = ref Unsafe.Add(ref dstRef, i);
// Span<double> dstWindow = MemoryMarshal.CreateSpan(ref currentDst, vectorSize);
// multiplied.CopyTo(dstWindow);
// }
// for (; i < len; i++)
// {
// Unsafe.Add(ref dstRef, i) = minuend - Unsafe.Add(ref srcRef, i);
// }
// }
// [MethodImpl(MethodImplOptions.AggressiveOptimization)]
// internal static void PowCore(ReadOnlySpan<XXXXXXXXXXXXXX> source, int power, Span<XXXXXXXXXXXXXX> destination)
// {
// int len = source.Length;
// ReadOnlySpan<double> srcDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(source);
// Span<double> dstDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(destination);
// int vectorSize = Vector<double>.Count;
// int i = 0;
// ref double srcRef = ref MemoryMarshal.GetReference(srcDouble);
// ref double dstRef = ref MemoryMarshal.GetReference(dstDouble);
// int SIMDEnd = len - (len % vectorSize);
// for (; i < SIMDEnd; i += vectorSize)
// {
// var vector = new Vector<double>(MemoryMarshal.CreateReadOnlySpan(ref Unsafe.Add(ref srcRef, i), vectorSize));
// var resultVector = VectorPow(vector, power);
// resultVector.CopyTo(MemoryMarshal.CreateSpan(ref Unsafe.Add(ref dstRef, i), vectorSize));
// }
// // Приватный SIMD-метод быстрого возведения в степень
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// static Vector<double> VectorPow(Vector<double> baseVector, int exp)
// {
// if (exp == 0) return Vector<double>.One;
// if (exp == 1) return baseVector;
// if (exp < 0)
// {
// baseVector = Vector<double>.One / baseVector;
// exp = -exp; // Внимание: может переполниться при int.Min_Value, но для степеней это редчайший кейс
// }
// var result = Vector<double>.One;
// var currentBase = baseVector;
// while (exp > 0)
// {
// if ((exp & 1) == 1)
// {
// result *= currentBase;
// }
// currentBase *= currentBase;
// exp >>= 1;
// }
// return result;
// }
// for (; i < len; i++)
// Unsafe.Add(ref dstRef, i) = Math.Pow(Unsafe.Add(ref srcRef, i), power);
// }
// [MethodImpl(MethodImplOptions.AggressiveOptimization)]
// internal static unsafe void PowCore(ReadOnlySpan<XXXXXXXXXXXXXX> source, double power, Span<XXXXXXXXXXXXXX> destination)
// {
// int len = source.Length;
// if (len == 0) return;
// fixed (double* pSrc = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(source))
// fixed (double* pDst = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(destination))
// {
// double* pCurrentSrc = pSrc;
// double* pCurrentDst = pDst;
// double* pEnd = pSrc + len;
// while (pCurrentSrc <= pEnd - 4)
// {
// pCurrentDst[0] = Math.Pow(pCurrentSrc[0], power);
// pCurrentDst[1] = Math.Pow(pCurrentSrc[1], power);
// pCurrentDst[2] = Math.Pow(pCurrentSrc[2], power);
// pCurrentDst[3] = Math.Pow(pCurrentSrc[3], power);
// pCurrentSrc += 4;
// pCurrentDst += 4;
// }
// while (pCurrentSrc < pEnd)
// {
// *pCurrentDst = Math.Pow(*pCurrentSrc, power);
// pCurrentSrc++;
// pCurrentDst++;
// }
// }
// }
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// internal static void SqrtCore(ReadOnlySpan<XXXXXXXXXXXXXX> source, Span<XXXXXXXXXXXXXX> destination)
// {
// int len = source.Length;
// ReadOnlySpan<double> srcDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(source);
// Span<double> dstDouble = MemoryMarshal.Cast<XXXXXXXXXXXXXX, double>(destination);
// int vectorSize = Vector<double>.Count;
// int i = 0;
// ref double srcRef = ref MemoryMarshal.GetReference(srcDouble);
// ref double dstRef = ref MemoryMarshal.GetReference(dstDouble);
// int SIMDEnd = len - (len % vectorSize);
// for (; i < SIMDEnd; i += vectorSize)
// {
// ref double currentSrc = ref Unsafe.Add(ref srcRef, i);
// ReadOnlySpan<double> srcWindow = MemoryMarshal.CreateReadOnlySpan(ref currentSrc, vectorSize);
// var vector = new Vector<double>(srcWindow);
// var multiplied = Vector.SquareRoot(vector);
// ref double currentDst = ref Unsafe.Add(ref dstRef, i);
// Span<double> dstWindow = MemoryMarshal.CreateSpan(ref currentDst, vectorSize);
// multiplied.CopyTo(dstWindow);
// }
// for (; i < len; i++)
// {
// Unsafe.Add(ref dstRef, i) = Math.Sqrt(Unsafe.Add(ref srcRef, i));
// }
// }
// // ==========================================
// // === MULTIPLY ===
// // ==========================================
// public static XXXXXXXXXXXXXX[] Multiply(this XXXXXXXXXXXXXX[] units, double multiplicator)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// MultiplyCore(units, multiplicator, result);
// return result;
// }
// public static XXXXXXXXXXXXXX[] Multiply(this double multiplicator, XXXXXXXXXXXXXX[] units)
// => units.Multiply(multiplicator);
// public static XXXXXXXXXXXXXX?[] Multiply(this XXXXXXXXXXXXXX?[] units, double multiplicator)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = (XXXXXXXXXXXXXX?[])units.Clone();
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value * multiplicator);
// }
// return result;
// }
// public static XXXXXXXXXXXXXX?[] Multiply(this double multiplicator, XXXXXXXXXXXXXX?[] units)
// => units.Multiply(multiplicator);
// // === ReadOnlySpan ===
// public static Span<XXXXXXXXXXXXXX> Multiply(this ReadOnlySpan<XXXXXXXXXXXXXX> units, double multiplicator)
// {
// if (units.Length == 0) return [];
// Span<XXXXXXXXXXXXXX> result = new XXXXXXXXXXXXXX[units.Length];
// MultiplyCore(units, multiplicator, result);
// return result;
// }
// public static Span<XXXXXXXXXXXXXX> Multiply(this double multiplicator, ReadOnlySpan<XXXXXXXXXXXXXX> units)
// => units.Multiply(multiplicator);
// public static Span<XXXXXXXXXXXXXX?> Multiply(this ReadOnlySpan<XXXXXXXXXXXXXX?> units, double multiplicator)
// {
// if (units.Length == 0) return [];
// Span<XXXXXXXXXXXXXX?> result = new XXXXXXXXXXXXXX?[units.Length];
// units.CopyTo(result);
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value * multiplicator);
// }
// return result;
// }
// public static Span<XXXXXXXXXXXXXX?> Multiply(this double multiplicator, ReadOnlySpan<XXXXXXXXXXXXXX?> units)
// => units.Multiply(multiplicator);
// // === List<Length> ===
// public static List<XXXXXXXXXXXXXX> Multiply(this List<XXXXXXXXXXXXXX> units, double multiplicator)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX>(len);
// result.SetCountUnsafe(len);
// MultiplyCore(CollectionsMarshal.AsSpan(units), multiplicator, CollectionsMarshal.AsSpan(result));
// return result;
// }
// public static List<XXXXXXXXXXXXXX> Multiply(this double multiplicator, List<XXXXXXXXXXXXXX> units)
// => units.Multiply(multiplicator);
// public static List<XXXXXXXXXXXXXX?> Multiply(this List<XXXXXXXXXXXXXX?> units, double multiplicator)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX?>(units);
// Span<XXXXXXXXXXXXXX?> dstSpan = CollectionsMarshal.AsSpan(result);
// for (int i = 0; i < len; i++)
// {
// ref var item = ref dstSpan[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value * multiplicator);
// }
// return result;
// }
// public static List<XXXXXXXXXXXXXX?> Multiply(this double multiplicator, List<XXXXXXXXXXXXXX?> units)
// => units.Multiply(multiplicator);
// // === ICollection<Length> ===
// public static Tcoll Multiply<Tcoll>(this ICollection<XXXXXXXXXXXXXX> units, double multiplicator)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item._Value * multiplicator));
// return tColl;
// }
// public static Tcoll Multiply<Tcoll>(this double multiplicator, ICollection<XXXXXXXXXXXXXX> units)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX>, new() => Multiply<Tcoll>(units, multiplicator);
// public static Tcoll Multiply<Tcoll>(this ICollection<XXXXXXXXXXXXXX?> units, double multiplicator)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX?>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item.Has_Value ? item._Value._Value * multiplicator : 0d));
// return tColl;
// }
// public static Tcoll Multiply<Tcoll>(this double multiplicator, ICollection<XXXXXXXXXXXXXX?> units)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX?>, new() => Multiply<Tcoll>(units, multiplicator);
// // === IEnumerable<Length> ===
// public static IEnumerable<XXXXXXXXXXXXXX> Multiply(this IEnumerable<XXXXXXXXXXXXXX> units, double multiplicator)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return new XXXXXXXXXXXXXX(item._Value * multiplicator);
// }
// public static IEnumerable<XXXXXXXXXXXXXX> Multiply(this double multiplicator, IEnumerable<XXXXXXXXXXXXXX> units)
// => units.Multiply(multiplicator);
// public static IEnumerable<XXXXXXXXXXXXXX?> Multiply(this IEnumerable<XXXXXXXXXXXXXX?> units, double multiplicator)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return item.Has_Value
// ? new XXXXXXXXXXXXXX(item._Value._Value * multiplicator) : null;
// }
// public static IEnumerable<XXXXXXXXXXXXXX?> Multiply(this double multiplicator, IEnumerable<XXXXXXXXXXXXXX?> units)
// => units.Multiply(multiplicator);
// // ==========================================
// // === DIVIDE ===
// // ==========================================
// public static XXXXXXXXXXXXXX[] Divide(this XXXXXXXXXXXXXX[] units, double divisor)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// if (divisor == 0 || double.IsNaN(divisor))
// throw new ArgumentException("Делитель не может быть 0 или NaN.", nameof(divisor));
// var result = new XXXXXXXXXXXXXX[units.Length];
// DivideCore(units, divisor, result);
// return result;
// }
// public static XXXXXXXXXXXXXX[] Divide(this double dividend, XXXXXXXXXXXXXX[] units)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// DivideCore(dividend, units, result); // Вызов зеркального ядра (число / массив)
// return result;
// }
// public static XXXXXXXXXXXXXX?[] Divide(this XXXXXXXXXXXXXX?[] units, double divisor)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// if (divisor == 0 || double.IsNaN(divisor)) throw new ArgumentException("Делитель не может быть 0 или NaN.", nameof(divisor));
// var result = (XXXXXXXXXXXXXX?[])units.Clone();
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value / divisor);
// }
// return result;
// }
// public static XXXXXXXXXXXXXX?[] Divide(this double dividend, XXXXXXXXXXXXXX?[] units)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = (XXXXXXXXXXXXXX?[])units.Clone();
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(dividend / item._Value._Value);
// }
// return result;
// }
// // === ReadOnlySpan ===
// public static Span<XXXXXXXXXXXXXX> Divide(this ReadOnlySpan<XXXXXXXXXXXXXX> units, double divisor)
// {
// if (units.Length == 0) return [];
// if (divisor == 0 || double.IsNaN(divisor)) throw new ArgumentException("Делитель не может быть 0 или NaN.", nameof(divisor));
// var result = new XXXXXXXXXXXXXX[units.Length];
// DivideCore(units, divisor, result);
// return result;
// }
// public static Span<XXXXXXXXXXXXXX> Divide(this double dividend, ReadOnlySpan<XXXXXXXXXXXXXX> units)
// {
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// DivideCore(dividend, units, result);
// return result;
// }
// public static Span<XXXXXXXXXXXXXX?> Divide(this ReadOnlySpan<XXXXXXXXXXXXXX?> units, double divisor)
// {
// if (units.Length == 0) return [];
// if (divisor == 0 || double.IsNaN(divisor))
// throw new ArgumentException("Делитель не может быть 0 или NaN.", nameof(divisor));
// Span<XXXXXXXXXXXXXX?> result = new XXXXXXXXXXXXXX?[units.Length];
// units.CopyTo(result);
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value / divisor);
// }
// return result;
// }
// public static Span<XXXXXXXXXXXXXX?> Divide(this double dividend, ReadOnlySpan<XXXXXXXXXXXXXX?> units)
// {
// if (units.Length == 0) return [];
// Span<XXXXXXXXXXXXXX?> result = new XXXXXXXXXXXXXX?[units.Length];
// units.CopyTo(result);
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(dividend / item._Value._Value);
// }
// return result;
// }
// // === List<Length> ===
// public static List<XXXXXXXXXXXXXX> Divide(this List<XXXXXXXXXXXXXX> units, double divisor)
// {
// if (units is null) return null!;
// if (divisor == 0 || double.IsNaN(divisor)) throw new ArgumentException("Делитель не может быть 0 или NaN.", nameof(divisor));
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX>(len);
// result.SetCountUnsafe(len);
// DivideCore(CollectionsMarshal.AsSpan(units), divisor, CollectionsMarshal.AsSpan(result));
// return result;
// }
// public static List<XXXXXXXXXXXXXX> Divide(this double dividend, List<XXXXXXXXXXXXXX> units)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX>(len);
// result.SetCountUnsafe(len);
// DivideCore(dividend, CollectionsMarshal.AsSpan(units), CollectionsMarshal.AsSpan(result));
// return result;
// }
// public static List<XXXXXXXXXXXXXX?> Divide(this List<XXXXXXXXXXXXXX?> units, double divisor)
// {
// if (units is null) return null!;
// if (divisor == 0 || double.IsNaN(divisor)) throw new ArgumentException("Делитель не может быть 0 или NaN.", nameof(divisor));
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX?>(units);
// Span<XXXXXXXXXXXXXX?> dstSpan = CollectionsMarshal.AsSpan(result);
// for (int i = 0; i < len; i++)
// {
// ref var item = ref dstSpan[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value / divisor);
// }
// return result;
// }
// public static List<XXXXXXXXXXXXXX?> Divide(this double dividend, List<XXXXXXXXXXXXXX?> units)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX?>(units);
// Span<XXXXXXXXXXXXXX?> dstSpan = CollectionsMarshal.AsSpan(result);
// for (int i = 0; i < len; i++)
// {
// ref var item = ref dstSpan[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(dividend / item._Value._Value);
// }
// return result;
// }
// // === ICollection<Length> ===
// public static Tcoll Divide<Tcoll>(this ICollection<XXXXXXXXXXXXXX> units, double divisor)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item._Value / divisor));
// return tColl;
// }
// public static Tcoll Divide<Tcoll>(this double dividend, ICollection<XXXXXXXXXXXXXX> units)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(dividend / item._Value));
// return tColl;
// }
// public static Tcoll Divide<Tcoll>(this ICollection<XXXXXXXXXXXXXX?> units, double divisor)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX?>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item.Has_Value ? item._Value._Value / divisor : 0d));
// return tColl;
// }
// public static Tcoll Divide<Tcoll>(this double dividend, ICollection<XXXXXXXXXXXXXX?> units)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX?>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item.Has_Value ? dividend / item._Value._Value : 0d));
// return tColl;
// }
// // === IEnumerable<Length> ===
// public static IEnumerable<XXXXXXXXXXXXXX> Divide(this IEnumerable<XXXXXXXXXXXXXX> units, double divisor)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return new XXXXXXXXXXXXXX(item._Value * divisor);
// }
// public static IEnumerable<XXXXXXXXXXXXXX> Divide(this double dividend, IEnumerable<XXXXXXXXXXXXXX> units)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return new XXXXXXXXXXXXXX(dividend / item._Value);
// }
// public static IEnumerable<XXXXXXXXXXXXXX?> Divide(this IEnumerable<XXXXXXXXXXXXXX?> units, double divisor)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return item.Has_Value
// ? new XXXXXXXXXXXXXX(item._Value._Value * divisor) : null;
// }
// public static IEnumerable<XXXXXXXXXXXXXX?> Divide(this double dividend, IEnumerable<XXXXXXXXXXXXXX?> units)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return item.Has_Value
// ? new XXXXXXXXXXXXXX(dividend / item._Value._Value) : null;
// }
// // ==========================================
// // === PLUS ===
// // ==========================================
// public static XXXXXXXXXXXXXX[] Plus(this XXXXXXXXXXXXXX[] units, double summand)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// PlusCore(units, summand, result);
// return result;
// }
// public static XXXXXXXXXXXXXX[] Plus(this double summand, XXXXXXXXXXXXXX[] units)
// => units.Plus(summand);
// public static XXXXXXXXXXXXXX?[] Plus(this XXXXXXXXXXXXXX?[] units, double summand)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = (XXXXXXXXXXXXXX?[])units.Clone();
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value + summand);
// }
// return result;
// }
// public static XXXXXXXXXXXXXX?[] Plus(this double summand, XXXXXXXXXXXXXX?[] units)
// => units.Plus(summand);
// // === ReadOnlySpan ===
// public static Span<XXXXXXXXXXXXXX> Plus(this ReadOnlySpan<XXXXXXXXXXXXXX> units, double summand)
// {
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// PlusCore(units, summand, result);
// return result;
// }
// public static Span<XXXXXXXXXXXXXX> Plus(this double summand, ReadOnlySpan<XXXXXXXXXXXXXX> units)
// => units.Plus(summand);
// public static Span<XXXXXXXXXXXXXX?> Plus(this ReadOnlySpan<XXXXXXXXXXXXXX?> units, double summand)
// {
// if (units.Length == 0) return [];
// Span<XXXXXXXXXXXXXX?> result = new XXXXXXXXXXXXXX?[units.Length];
// units.CopyTo(result);
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value + summand);
// }
// return result;
// }
// public static Span<XXXXXXXXXXXXXX?> Plus(this double summand, ReadOnlySpan<XXXXXXXXXXXXXX?> units)
// => units.Multiply(summand);
// // === List<Length> ===
// public static List<XXXXXXXXXXXXXX> Plus(this List<XXXXXXXXXXXXXX> units, double summand)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX>(len);
// result.SetCountUnsafe(len);
// PlusCore(CollectionsMarshal.AsSpan(units), summand, CollectionsMarshal.AsSpan(result));
// return result;
// }
// public static List<XXXXXXXXXXXXXX> Plus(this double summand, List<XXXXXXXXXXXXXX> units)
// => units.Plus(summand);
// public static List<XXXXXXXXXXXXXX?> Plus(this List<XXXXXXXXXXXXXX?> units, double summand)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX?>(units);
// Span<XXXXXXXXXXXXXX?> dstSpan = CollectionsMarshal.AsSpan(result);
// for (int i = 0; i < len; i++)
// {
// ref var item = ref dstSpan[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value + summand);
// }
// return result;
// }
// public static List<XXXXXXXXXXXXXX?> Plus(this double summand, List<XXXXXXXXXXXXXX?> units)
// => units.Plus(summand);
// // === ICollection<Length> ===
// public static Tcoll Plus<Tcoll>(this ICollection<XXXXXXXXXXXXXX> units, double summand)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item._Value + summand));
// return tColl;
// }
// public static Tcoll Plus<Tcoll>(this double summand, ICollection<XXXXXXXXXXXXXX> units)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX>, new() => Plus<Tcoll>(units, summand);
// public static Tcoll Plus<Tcoll>(this ICollection<XXXXXXXXXXXXXX?> units, double summand)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX?>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item.Has_Value ? item._Value._Value + summand : 0d));
// return tColl;
// }
// public static Tcoll Plus<Tcoll>(this double summand, ICollection<XXXXXXXXXXXXXX?> units)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX?>, new() => Plus<Tcoll>(units, summand);
// // === IEnumerable<Length> ===
// public static IEnumerable<XXXXXXXXXXXXXX> Plus(this IEnumerable<XXXXXXXXXXXXXX> units, double summand)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return new XXXXXXXXXXXXXX(item._Value + summand);
// }
// public static IEnumerable<XXXXXXXXXXXXXX> Plus(this double summand, IEnumerable<XXXXXXXXXXXXXX> units)
// => units.Plus(summand);
// public static IEnumerable<XXXXXXXXXXXXXX?> Plus(this IEnumerable<XXXXXXXXXXXXXX?> units, double summand)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return item.Has_Value
// ? new XXXXXXXXXXXXXX(item._Value._Value + summand) : null;
// }
// public static IEnumerable<XXXXXXXXXXXXXX?> Plus(this double summand, IEnumerable<XXXXXXXXXXXXXX?> units)
// => units.Plus(summand);
// // ==========================================
// // === MINUS ===
// // ==========================================
// public static XXXXXXXXXXXXXX[] Minus(this XXXXXXXXXXXXXX[] units, double subtrahend)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// MinusCore(units, subtrahend, result);
// return result;
// }
// public static XXXXXXXXXXXXXX[] Minus(this double minuend, XXXXXXXXXXXXXX[] units)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// MinusCore(minuend, units, result); // Вызов зеркального ядра (число - массив)
// return result;
// }
// public static XXXXXXXXXXXXXX?[] Minus(this XXXXXXXXXXXXXX?[] units, double subtrahend)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = (XXXXXXXXXXXXXX?[])units.Clone();
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value - subtrahend);
// }
// return result;
// }
// public static XXXXXXXXXXXXXX?[] Minus(this double minuend, XXXXXXXXXXXXXX?[] units)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = (XXXXXXXXXXXXXX?[])units.Clone();
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(minuend - item._Value._Value);
// }
// return result;
// }
// // === ReadOnlySpan ===
// public static Span<XXXXXXXXXXXXXX> Minus(this ReadOnlySpan<XXXXXXXXXXXXXX> units, double subtrahend)
// {
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// MinusCore(units, subtrahend, result);
// return result;
// }
// public static Span<XXXXXXXXXXXXXX> Minus(this double minuend, ReadOnlySpan<XXXXXXXXXXXXXX> units)
// {
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// MinusCore(minuend, units, result);
// return result;
// }
// public static Span<XXXXXXXXXXXXXX?> Minus(this ReadOnlySpan<XXXXXXXXXXXXXX?> units, double subtrahend)
// {
// if (units.Length == 0) return [];
// Span<XXXXXXXXXXXXXX?> result = new XXXXXXXXXXXXXX?[units.Length];
// units.CopyTo(result);
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value - subtrahend);
// }
// return result;
// }
// public static Span<XXXXXXXXXXXXXX?> Minus(this double minuend, ReadOnlySpan<XXXXXXXXXXXXXX?> units)
// {
// if (units.Length == 0) return [];
// Span<XXXXXXXXXXXXXX?> result = new XXXXXXXXXXXXXX?[units.Length];
// units.CopyTo(result);
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(minuend - item._Value._Value);
// }
// return result;
// }
// // === List<Length> ===
// public static List<XXXXXXXXXXXXXX> Minus(this List<XXXXXXXXXXXXXX> units, double subtrahend)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX>(len);
// result.SetCountUnsafe(len);
// MinusCore(CollectionsMarshal.AsSpan(units), subtrahend, CollectionsMarshal.AsSpan(result));
// return result;
// }
// public static List<XXXXXXXXXXXXXX> Minus(this double minuend, List<XXXXXXXXXXXXXX> units)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX>(len);
// result.SetCountUnsafe(len);
// MinusCore(minuend, CollectionsMarshal.AsSpan(units), CollectionsMarshal.AsSpan(result));
// return result;
// }
// public static List<XXXXXXXXXXXXXX?> Minus(this List<XXXXXXXXXXXXXX?> units, double subtrahend)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX?>(units);
// Span<XXXXXXXXXXXXXX?> dstSpan = CollectionsMarshal.AsSpan(result);
// for (int i = 0; i < len; i++)
// {
// ref var item = ref dstSpan[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value - subtrahend);
// }
// return result;
// }
// public static List<XXXXXXXXXXXXXX?> Minus(this double minuend, List<XXXXXXXXXXXXXX?> units)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX?>(units);
// Span<XXXXXXXXXXXXXX?> dstSpan = CollectionsMarshal.AsSpan(result);
// for (int i = 0; i < len; i++)
// {
// ref var item = ref dstSpan[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(minuend - item._Value._Value);
// }
// return result;
// }
// // === ICollection<Length> ===
// public static Tcoll Minus<Tcoll>(this ICollection<XXXXXXXXXXXXXX> units, double subtrahend)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item._Value - subtrahend));
// return tColl;
// }
// public static Tcoll Minus<Tcoll>(this double minuend, ICollection<XXXXXXXXXXXXXX> units)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(minuend - item._Value));
// return tColl;
// }
// public static Tcoll Minus<Tcoll>(this ICollection<XXXXXXXXXXXXXX?> units, double subtrahend)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX?>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item.Has_Value ? item._Value._Value - subtrahend : 0d));
// return tColl;
// }
// public static Tcoll Minus<Tcoll>(this double minuend, ICollection<XXXXXXXXXXXXXX?> units)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX?>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item.Has_Value ? minuend - item._Value._Value : 0d));
// return tColl;
// }
// // === IEnumerable<Length> ===
// public static IEnumerable<XXXXXXXXXXXXXX> Minus(this IEnumerable<XXXXXXXXXXXXXX> units, double subtrahend)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return new XXXXXXXXXXXXXX(item._Value - subtrahend);
// }
// public static IEnumerable<XXXXXXXXXXXXXX> Minus(this double minuend, IEnumerable<XXXXXXXXXXXXXX> units)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return new XXXXXXXXXXXXXX(minuend - item._Value);
// }
// public static IEnumerable<XXXXXXXXXXXXXX?> Minus(this IEnumerable<XXXXXXXXXXXXXX?> units, double subtrahend)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return item.Has_Value
// ? new XXXXXXXXXXXXXX(item._Value._Value - subtrahend) : null;
// }
// public static IEnumerable<XXXXXXXXXXXXXX?> Minus(this double minuend, IEnumerable<XXXXXXXXXXXXXX?> units)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return item.Has_Value
// ? new XXXXXXXXXXXXXX(minuend - item._Value._Value) : null;
// }
// // ==========================================
// // ЦЕЛАЯ СТЕПЕНЬ (int power)
// // ==========================================
// public static XXXXXXXXXXXXXX[] Pow(this XXXXXXXXXXXXXX[] units, int power)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// PowCore(units, power, result);
// return result;
// }
// public static XXXXXXXXXXXXXX?[] Pow(this XXXXXXXXXXXXXX?[] units, int power)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = (XXXXXXXXXXXXXX?[])units.Clone();
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value)
// {
// // Используем тот же быстрый QuickPow, что и в ядре, чтобы не вызывать тяжелый Math.Pow
// item = new XXXXXXXXXXXXXX(item._Value._Value.QuickPow(power));
// }
// }
// return result;
// }
// // === ReadOnlySpan ===
// public static Span<XXXXXXXXXXXXXX> Pow(this ReadOnlySpan<XXXXXXXXXXXXXX> units, int power)
// {
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// PowCore(units, power, result);
// return result;
// }
// public static Span<XXXXXXXXXXXXXX?> Pow(this ReadOnlySpan<XXXXXXXXXXXXXX?> units, int power)
// {
// int len = units.Length;
// if (len == 0) return [];
// Span<XXXXXXXXXXXXXX?> result = new XXXXXXXXXXXXXX?[units.Length];
// units.CopyTo(result);
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value.QuickPow(power));
// }
// return result;
// }
// // === List<Length> ===
// public static List<XXXXXXXXXXXXXX> Pow(this List<XXXXXXXXXXXXXX> units, int power)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX>(len);
// result.SetCountUnsafe(len);
// PowCore(CollectionsMarshal.AsSpan(units), power, CollectionsMarshal.AsSpan(result));
// return result;
// }
// public static List<XXXXXXXXXXXXXX?> Pow(this List<XXXXXXXXXXXXXX?> units, int power)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX?>(units);
// Span<XXXXXXXXXXXXXX?> dstSpan = CollectionsMarshal.AsSpan(result);
// for (int i = 0; i < len; i++)
// {
// ref var item = ref dstSpan[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(item._Value._Value.QuickPow(power));
// }
// return result;
// }
// // === ICollection<Length> ===
// public static Tcoll Pow<Tcoll>(this ICollection<XXXXXXXXXXXXXX> units, int power)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item._Value.QuickPow(power)));
// return tColl;
// }
// public static Tcoll Pow<Tcoll>(this ICollection<XXXXXXXXXXXXXX?> units, int power)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX?>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item.Has_Value ? item._Value._Value.QuickPow(power) : 0d));
// return tColl;
// }
// // === IEnumerable<Length> ===
// public static IEnumerable<XXXXXXXXXXXXXX> Pow(this IEnumerable<XXXXXXXXXXXXXX> units, int power)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return new XXXXXXXXXXXXXX(item._Value.QuickPow(power));
// }
// public static IEnumerable<XXXXXXXXXXXXXX?> Pow(this IEnumerable<XXXXXXXXXXXXXX?> units, int power)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return item.Has_Value
// ? new XXXXXXXXXXXXXX(item._Value._Value.QuickPow(power)) : null;
// }
// // ==========================================
// // ДРОБНАЯ СТЕПЕНЬ (double power)
// // ==========================================
// public static XXXXXXXXXXXXXX[] Pow(this XXXXXXXXXXXXXX[] units, double power)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// PowCore(units, power, result);
// return result;
// }
// public static XXXXXXXXXXXXXX?[] Pow(this XXXXXXXXXXXXXX?[] units, double power)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = (XXXXXXXXXXXXXX?[])units.Clone();
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value)
// {
// item = new XXXXXXXXXXXXXX(Math.Pow(item._Value._Value, power));
// }
// }
// return result;
// }
// // === ReadOnlySpan ===
// public static Span<XXXXXXXXXXXXXX> Pow(this ReadOnlySpan<XXXXXXXXXXXXXX> units, double power)
// {
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// PowCore(units, power, result);
// return result;
// }
// public static Span<XXXXXXXXXXXXXX?> Pow(this ReadOnlySpan<XXXXXXXXXXXXXX?> units, double power)
// {
// int len = units.Length;
// if (len == 0) return [];
// Span<XXXXXXXXXXXXXX?> result = new XXXXXXXXXXXXXX?[units.Length];
// units.CopyTo(result);
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(Math.Pow(item._Value._Value, power));
// }
// return result;
// }
// // === List<Length> ===
// public static List<XXXXXXXXXXXXXX> Pow(this List<XXXXXXXXXXXXXX> units, double power)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX>(len);
// result.SetCountUnsafe(len);
// PowCore(CollectionsMarshal.AsSpan(units), power, CollectionsMarshal.AsSpan(result));
// return result;
// }
// public static List<XXXXXXXXXXXXXX?> Pow(this List<XXXXXXXXXXXXXX?> units, double power)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX?>(units);
// Span<XXXXXXXXXXXXXX?> dstSpan = CollectionsMarshal.AsSpan(result);
// for (int i = 0; i < len; i++)
// {
// ref var item = ref dstSpan[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(Math.Pow(item._Value._Value, power));
// }
// return result;
// }
// // === ICollection<Length> ===
// public static Tcoll Pow<Tcoll>(this ICollection<XXXXXXXXXXXXXX> units, double power)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(Math.Pow(item._Value, power)));
// return tColl;
// }
// public static Tcoll Pow<Tcoll>(this ICollection<XXXXXXXXXXXXXX?> units, double power)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX?>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item.Has_Value ? Math.Pow(item._Value._Value, power) : 0d));
// return tColl;
// }
// // === IEnumerable<Length> ===
// public static IEnumerable<XXXXXXXXXXXXXX> Pow(this IEnumerable<XXXXXXXXXXXXXX> units, double power)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return new XXXXXXXXXXXXXX(Math.Pow(item._Value, power));
// }
// public static IEnumerable<XXXXXXXXXXXXXX?> Pow(this IEnumerable<XXXXXXXXXXXXXX?> units, double power)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return item.Has_Value
// ? new XXXXXXXXXXXXXX(Math.Pow(item._Value._Value, power)) : null;
// }
// // ==========================================
// // КВАДРАТНЫЙ КОРЕНЬ (Sqrt)
// // ==========================================
// public static XXXXXXXXXXXXXX[] Sqrt(this XXXXXXXXXXXXXX[] units)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// SqrtCore(units, result);
// return result;
// }
// public static XXXXXXXXXXXXXX?[] Sqrt(this XXXXXXXXXXXXXX?[] units)
// {
// if (units is null) return null!;
// if (units.Length == 0) return [];
// var result = (XXXXXXXXXXXXXX?[])units.Clone();
// int len = result.Length;
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value)
// {
// item = new XXXXXXXXXXXXXX(Math.Sqrt(item._Value._Value));
// }
// }
// return result;
// }
// // === ReadOnlySpan ===
// public static Span<XXXXXXXXXXXXXX> Sqrt(this ReadOnlySpan<XXXXXXXXXXXXXX> units)
// {
// if (units.Length == 0) return [];
// var result = new XXXXXXXXXXXXXX[units.Length];
// SqrtCore(units, result);
// return result;
// }
// public static Span<XXXXXXXXXXXXXX?> Sqrt(this ReadOnlySpan<XXXXXXXXXXXXXX?> units)
// {
// int len = units.Length;
// if (len == 0) return [];
// Span<XXXXXXXXXXXXXX?> result = new XXXXXXXXXXXXXX?[units.Length];
// units.CopyTo(result);
// for (int i = 0; i < len; i++)
// {
// ref var item = ref result[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(Math.Sqrt(item._Value._Value));
// }
// return result;
// }
// // === List<Length> ===
// public static List<XXXXXXXXXXXXXX> Sqrt(this List<XXXXXXXXXXXXXX> units)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX>(len);
// result.SetCountUnsafe(len);
// SqrtCore(CollectionsMarshal.AsSpan(units), CollectionsMarshal.AsSpan(result));
// return result;
// }
// public static List<XXXXXXXXXXXXXX?> Sqrt(this List<XXXXXXXXXXXXXX?> units)
// {
// if (units is null) return null!;
// int len = units.Count;
// if (len == 0) return [];
// var result = new List<XXXXXXXXXXXXXX?>(units);
// Span<XXXXXXXXXXXXXX?> dstSpan = CollectionsMarshal.AsSpan(result);
// for (int i = 0; i < len; i++)
// {
// ref var item = ref dstSpan[i];
// if (item.Has_Value) item = new XXXXXXXXXXXXXX(Math.Sqrt(item._Value._Value));
// }
// return result;
// }
// // === ICollection<Length> ===
// public static Tcoll Pow<Tcoll>(this ICollection<XXXXXXXXXXXXXX> units)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(Math.Sqrt(item._Value)));
// return tColl;
// }
// public static Tcoll Pow<Tcoll>(this ICollection<XXXXXXXXXXXXXX?> units)
// where Tcoll : class, ICollection<XXXXXXXXXXXXXX?>, new()
// {
// ArgumentNullException.ThrowIfNull(units);
// var tColl = new Tcoll();
// if (tColl is List<XXXXXXXXXXXXXX> list)
// list.Capacity = units.Count;
// foreach (var item in units)
// tColl.Add(new XXXXXXXXXXXXXX(item.Has_Value ? Math.Sqrt(item._Value._Value) : 0d));
// return tColl;
// }
// // === IEnumerable<Length> ===
// public static IEnumerable<XXXXXXXXXXXXXX> Pow(this IEnumerable<XXXXXXXXXXXXXX> units)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return new XXXXXXXXXXXXXX(Math.Sqrt(item._Value));
// }
// public static IEnumerable<XXXXXXXXXXXXXX?> Pow(this IEnumerable<XXXXXXXXXXXXXX?> units)
// {
// ArgumentNullException.ThrowIfNull(units);
// foreach (var item in units)
// yield return item.Has_Value
// ? new XXXXXXXXXXXXXX(Math.Sqrt(item._Value._Value)) : null;
// }
//}
//public class XXXXXXXXXXXXXXConverter : JsonConverter<XXXXXXXXXXXXXX>
//{
// // Используем инвариантную культуру, чтобы разделителем всегда была точка (10.5, а не 10,5)
// private static readonly CultureInfo Culture = CultureInfo.InvariantCulture;
// public override XXXXXXXXXXXXXX Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
// {
// double double_Value;
// if (reader.TokenType == JsonTokenType.String)
// {
// // Безопасно парсим double из строки с поддержкой точки как разделителя
// if (!double.TryParse(reader.GetString(), NumberStyles.Float, Culture, out double_Value))
// {
// throw new JsonException($"Не удалось преобразовать строковое значение в double для метрики {nameof(XXXXXXXXXXXXXX)}.");
// }
// }
// else
// {
// // Прямое быстрое чтение числа из JSON
// double_Value = reader.GetDouble();
// }
// return new(double_Value);
// }
// public override void Write(Utf8JsonWriter writer, XXXXXXXXXXXXXX value, JsonSerializerOptions options)
// {
// // Записываем число напрямую в байтовый буфер без выделения памяти под строки
// writer.WriteNumberValue(value._Value);
// }
// public override void WriteAsPropertyName(Utf8JsonWriter writer, XXXXXXXXXXXXXX value, JsonSerializerOptions options)
// {
// // Ключи JSON-объектов всегда должны быть строками.
// // Форматируем double в строку с точкой, чтобы другие сервисы экосистемы прочитали её корректно.
// // Формат "R" (Round-trip) гарантирует, что число не потеряет точность при обратном парсинге.
// writer.WritePropertyName(value._Value.ToString("R", Culture));
// }
// public override XXXXXXXXXXXXXX ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
// {
// string propertyName = reader.GetString()!;
// if (!double.TryParse(propertyName, NumberStyles.Float, Culture, out double double_Value))
// {
// throw new JsonException($"Невалидное числовое значение в ключе свойства JSON: '{propertyName}' для метрики {nameof(XXXXXXXXXXXXXX)}.");
// }
// return new(double_Value);
// }
//}