WrapAsList debug
This commit is contained in:
@@ -205,6 +205,165 @@ public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, I
|
||||
[JsonIgnore, IgnoreDataMember] public bool IsNegativeInfinity => double.IsNegativeInfinity(_Value);
|
||||
|
||||
|
||||
public static {typeNameZ} Zero { get; } = new(0d);
|
||||
public static {typeNameZ} Min { get; } = new(double.MinValue);
|
||||
public static {typeNameZ} Max { get; } = new(double.MaxValue);
|
||||
public static {typeNameZ} NegativeInfinity { get; } = new(double.NegativeInfinity);
|
||||
public static {typeNameZ} PositiveInfinity { get; } = new(double.PositiveInfinity);
|
||||
|
||||
|
||||
public static bool operator ==({typeName}? T1, {typeName}? T2) => T1.Protected() == T2.Protected();
|
||||
public static bool operator !=({typeName}? T1, {typeName}? T2) => T1.Protected() != T2.Protected();
|
||||
|
||||
public static bool operator <({typeName}? T1, {typeName}? T2) => T1.Protected() < T2.Protected();
|
||||
public static bool operator <=({typeName}? T1, {typeName}? T2) => T1.Protected() <= T2.Protected();
|
||||
public static bool operator >({typeName}? T1, {typeName}? T2) => T1.Protected() > T2.Protected();
|
||||
public static bool operator >=({typeName}? T1, {typeName}? T2) => T1.Protected() >= T2.Protected();
|
||||
|
||||
|
||||
public static {typeName} operator +({typeName} T2) => new(+T2._Value);
|
||||
public static {typeName} operator +({typeName} T1, {typeName} T2) => new(T1._Value + T2._Value);
|
||||
public static {typeName} operator -({typeName} T2) => new(-T2._Value);
|
||||
public static {typeName} operator -({typeName} T1, {typeName} T2) => new(T1._Value - T2._Value);
|
||||
|
||||
|
||||
// double
|
||||
public static {typeName} operator *({typeName} T1, double T2) => new(T1._Value * T2);
|
||||
public static {typeName} operator *({typeName} T1, double? T2) => T1 * (T2 ?? 0d);
|
||||
public static {typeName} operator *(double T1, {typeName} T2) => new(T1 * T2._Value);
|
||||
public static {typeName} operator *(double? T1, {typeName} T2) => (T1 ?? 0d) * T2;
|
||||
public static {typeName} operator /({typeName} T1, double T2) => new(T1._Value / T2);
|
||||
public static {typeName} operator /({typeName} T1, double? T2) => T1 / (T2 ?? 0d);
|
||||
public static double operator /({typeName} T1, {typeName} T2) => T1._Value / T2._Value;
|
||||
|
||||
// sbyte
|
||||
public static {typeName} operator *({typeName} T1, sbyte T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, sbyte? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(sbyte T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(sbyte? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, sbyte T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, sbyte? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// short
|
||||
public static {typeName} operator *({typeName} T1, short T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, short? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(short T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(short? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, short T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, short? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// int
|
||||
public static {typeName} operator *({typeName} T1, int T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, int? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(int T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(int? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, int T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, int? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// long
|
||||
public static {typeName} operator *({typeName} T1, long T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, long? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(long T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(long? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, long T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, long? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// byte
|
||||
public static {typeName} operator *({typeName} T1, byte T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, byte? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(byte T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(byte? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, byte T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, byte? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// ushort
|
||||
public static {typeName} operator *({typeName} T1, ushort T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, ushort? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(ushort T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(ushort? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, ushort T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, ushort? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// uint
|
||||
public static {typeName} operator *({typeName} T1, uint T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, uint? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(uint T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(uint? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, uint T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, uint? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// ulong
|
||||
public static {typeName} operator *({typeName} T1, ulong T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, ulong? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(ulong T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(ulong? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, ulong T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, ulong? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// nint
|
||||
public static {typeName} operator *({typeName} T1, nint T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, nint? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(nint T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(nint? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, nint T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, nint? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// nuint
|
||||
public static {typeName} operator *({typeName} T1, nuint T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, nuint? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(nuint T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(nuint? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, nuint T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, nuint? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// Half
|
||||
public static {typeName} operator *({typeName} T1, Half T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, Half? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(Half T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(Half? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, Half T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, Half? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// float
|
||||
public static {typeName} operator *({typeName} T1, float T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, float? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(float T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(float? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, float T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, float? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// decimal
|
||||
public static {typeName} operator *({typeName} T1, decimal T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, decimal? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(decimal T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(decimal? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, decimal T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, decimal? T2) => T1 / T2.ToDouble();
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
// Int128
|
||||
public static {typeName} operator *({typeName} T1, Int128 T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, Int128? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(Int128 T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(Int128? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, Int128 T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, Int128? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// UInt128
|
||||
public static {typeName} operator *({typeName} T1, UInt128 T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, UInt128? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(UInt128 T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(UInt128? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, UInt128 T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, UInt128? T2) => T1 / T2.ToDouble();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static {typeNameA} operator *({typeNameZ} left, {typeNameB} right) => new(left._Value * right._Value);
|
||||
public static {typeNameA} operator *({typeNameZ}? left, {typeNameB} right) => new(left.Protected() * right._Value);
|
||||
public static {typeNameA} operator *({typeNameZ} left, {typeNameB}? right) => new(left._Value * right.Protected());
|
||||
@@ -339,11 +498,272 @@ public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, I
|
||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => new {typeNameB}(0d)));
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator /({typeNameZ}? dividend, IEnumerable<{typeNameA}?> units) =>
|
||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameB}?)null : new {typeNameB}(0d)));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static {typeName}[] operator +({typeName}[] T1, {typeName} T2) => T1.Plus(T2._Value);
|
||||
public static {typeName}?[] operator +({typeName}?[] T1, {typeName} T2) => T1.Plus(T2._Value);
|
||||
public static {typeName}[] operator +({typeName} T1, {typeName}[] T2) => T1._Value.Plus(T2);
|
||||
public static {typeName}?[] operator +({typeName} T1, {typeName}?[] T2) => T1._Value.Plus(T2);
|
||||
public static {typeName}[] operator +({typeName}[] T1, {typeName}? T2) => T1.Plus(T2.Protected());
|
||||
public static {typeName}?[] operator +({typeName}?[] T1, {typeName}? T2) => T1.Plus(T2.Protected());
|
||||
public static {typeName}[] operator +({typeName}? T1, {typeName}[] T2) => T1.Protected().Plus(T2);
|
||||
public static {typeName}?[] operator +({typeName}? T1, {typeName}?[] T2) => T1.Protected().Plus(T2);
|
||||
|
||||
public static {typeName}[] operator -({typeName}[] T1, {typeName} T2) => T1.Minus(T2._Value);
|
||||
public static {typeName}?[] operator -({typeName}?[] T1, {typeName} T2) => T1.Minus(T2._Value);
|
||||
public static {typeName}[] operator -({typeName} T1, {typeName}[] T2) => T1._Value.Minus(T2);
|
||||
public static {typeName}?[] operator -({typeName} T1, {typeName}?[] T2) => T1._Value.Minus(T2);
|
||||
public static {typeName}[] operator -({typeName}[] T1, {typeName}? T2) => T1.Minus(T2.Protected());
|
||||
public static {typeName}?[] operator -({typeName}?[] T1, {typeName}? T2) => T1.Minus(T2.Protected());
|
||||
public static {typeName}[] operator -({typeName}? T1, {typeName}[] T2) => T1.Protected().Minus(T2);
|
||||
public static {typeName}?[] operator -({typeName}? T1, {typeName}?[] T2) => T1.Protected().Minus(T2);
|
||||
|
||||
public static double[] operator /({typeName} T1, {typeName}[] T2) => T1.Div(T2);
|
||||
public static double?[] operator /({typeName} T1, {typeName}?[] T2) => T1.Div(T2);
|
||||
public static double[] operator /({typeName}[] T1, {typeName} T2) => T1.Div(T2);
|
||||
public static double?[] operator /({typeName}?[] T1, {typeName} T2) => T1.Div(T2);
|
||||
public static double[] operator /({typeName}? T1, {typeName}[] T2) => T1.ProtectedU().Div(T2);
|
||||
public static double?[] operator /({typeName}? T1, {typeName}?[] T2) => T1.ProtectedU().Div(T2);
|
||||
public static double[] operator /({typeName}[] T1, {typeName}? T2) => T1.Div(T2.ProtectedU());
|
||||
public static double?[] operator /({typeName}?[] T1, {typeName}? T2) => T1.Div(T2.ProtectedU());
|
||||
|
||||
|
||||
// double
|
||||
public static {typeName}[] operator *({typeName} T1, double[] T2) => T1.Mul(T2);
|
||||
public static {typeName}?[] operator *({typeName} T1, double?[] T2) => T1.Mul(T2);
|
||||
public static {typeName}[] operator *({typeName}? T1, double[] T2) => T1.ProtectedU().Mul(T2);
|
||||
public static {typeName}?[] operator *({typeName}? T1, double?[] T2) => T1.ProtectedU().Mul(T2);
|
||||
public static {typeName}[] operator *(double[] T1, {typeName} T2) => T1.Mul(T2);
|
||||
public static {typeName}?[] operator *(double?[] T1, {typeName} T2) => T1.Mul(T2);
|
||||
public static {typeName}[] operator *(double[] T1, {typeName}? T2) => T1.Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(double?[] T1, {typeName}? T2) => T1.Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, double[] T2) => T1.Div(T2);
|
||||
public static {typeName}?[] operator /({typeName} T1, double?[] T2) => T1.Div(T2);
|
||||
public static {typeName}[] operator /({typeName}? T1, double[] T2) => T1.ProtectedU().Div(T2);
|
||||
public static {typeName}?[] operator /({typeName}? T1, double?[] T2) => T1.ProtectedU().Div(T2);
|
||||
|
||||
// sbyte
|
||||
public static {typeName}[] operator *({typeName} T1, sbyte[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, sbyte?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, sbyte[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, sbyte?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(sbyte[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(sbyte?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(sbyte[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(sbyte?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, sbyte[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, sbyte?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, sbyte[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, sbyte?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// short
|
||||
public static {typeName}[] operator *({typeName} T1, short[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, short?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, short[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, short?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(short[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(short?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(short[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(short?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, short[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, short?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, short[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, short?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// int
|
||||
public static {typeName}[] operator *({typeName} T1, int[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, int?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, int[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, int?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(int[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(int?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(int[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(int?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, int[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, int?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, int[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, int?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// long
|
||||
public static {typeName}[] operator *({typeName} T1, long[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, long?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, long[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, long?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(long[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(long?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(long[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(long?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, long[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, long?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, long[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, long?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// byte
|
||||
public static {typeName}[] operator *({typeName} T1, byte[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, byte?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, byte[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, byte?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(byte[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(byte?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(byte[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(byte?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, byte[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, byte?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, byte[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, byte?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// ushort
|
||||
public static {typeName}[] operator *({typeName} T1, ushort[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, ushort?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, ushort[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, ushort?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(ushort[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(ushort?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(ushort[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(ushort?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, ushort[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, ushort?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, ushort[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, ushort?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// uint
|
||||
public static {typeName}[] operator *({typeName} T1, uint[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, uint?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, uint[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, uint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(uint[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(uint?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(uint[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(uint?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, uint[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, uint?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, uint[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, uint?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// ulong
|
||||
public static {typeName}[] operator *({typeName} T1, ulong[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, ulong?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, ulong[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, ulong?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(ulong[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(ulong?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(ulong[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(ulong?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, ulong[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, ulong?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, ulong[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, ulong?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// nint
|
||||
public static {typeName}[] operator *({typeName} T1, nint[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, nint?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, nint[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, nint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(nint[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(nint?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(nint[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(nint?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, nint[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, nint?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, nint[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, nint?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// nuint
|
||||
public static {typeName}[] operator *({typeName} T1, nuint[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, nuint?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, nuint[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, nuint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(nuint[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(nuint?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(nuint[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(nuint?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, nuint[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, nuint?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, nuint[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, nuint?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// Half
|
||||
public static {typeName}[] operator *({typeName} T1, Half[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, Half?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, Half[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, Half?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(Half[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(Half?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(Half[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(Half?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, Half[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, Half?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, Half[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, Half?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// float
|
||||
public static {typeName}[] operator *({typeName} T1, float[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, float?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, float[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, float?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(float[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(float?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(float[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(float?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, float[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, float?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, float[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, float?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// decimal
|
||||
public static {typeName}[] operator *({typeName} T1, decimal[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, decimal?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, decimal[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, decimal?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(decimal[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(decimal?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(decimal[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(decimal?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, decimal[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, decimal?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, decimal[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, decimal?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
// Int128
|
||||
public static {typeName}[] operator *({typeName} T1, Int128[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, Int128?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, Int128[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, Int128?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(Int128[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(Int128?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(Int128[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(Int128?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, Int128[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, Int128?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, Int128[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, Int128?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// UInt128
|
||||
public static {typeName}[] operator *({typeName} T1, UInt128[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, UInt128?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, UInt128[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, UInt128?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(UInt128[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(UInt128?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(UInt128[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(UInt128?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, UInt128[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, UInt128?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, UInt128[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, UInt128?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class {typeNameZ}Extensions
|
||||
{
|
||||
internal static double Protected(this {typeNameZ}? unit) => unit is null ? 0d : unit.Value._Value;
|
||||
internal static {typeNameZ} ProtectedU(this {typeNameZ}? unit) => unit is null ? {typeNameZ}.Zero : unit.Value;
|
||||
internal static double ToDouble(this {typeNameB}? unit) => unit?._Value ?? 0d;
|
||||
|
||||
|
||||
@@ -416,71 +836,6 @@ public static class {typeNameZ}Extensions
|
||||
|
||||
|
||||
|
||||
// === ReadOnlySpan
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ReadOnlySpan<{typeNameZ}> units,
|
||||
double subtrahend, Span<{typeNameZ}> destination) => units.Minus<{typeNameZ}>(subtrahend, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ReadOnlySpan<{typeNameZ}?> units,
|
||||
double subtrahend, Span<{typeNameZ}?> destination) => units.Minus<{typeNameZ}>(subtrahend, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||
ReadOnlySpan<{typeNameZ}> units, Span<{typeNameZ}> destination) => minuend.Minus<{typeNameZ}>(units, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||
ReadOnlySpan<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => minuend.Minus<{typeNameZ}>(units, destination);
|
||||
|
||||
// === Array ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static {typeNameZ}[] Minus(
|
||||
this {typeNameZ}[] units, double subtrahend) => units.Minus<{typeNameZ}>(subtrahend);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] Minus(
|
||||
this {typeNameZ}?[] units, double subtrahend) => units.Minus<{typeNameZ}>(subtrahend);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] Minus(
|
||||
this double minuend, {typeNameZ}[] units) => minuend.Minus<{typeNameZ}>(units);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] Minus(
|
||||
this double minuend, {typeNameZ}?[] units) => minuend.Minus<{typeNameZ}>(units);
|
||||
|
||||
// === List<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> Minus(
|
||||
this List<{typeNameZ}> units, double subtrahend) => units.Minus<{typeNameZ}>(subtrahend);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Minus(
|
||||
this List<{typeNameZ}?> units, double subtrahend) => units.Minus<{typeNameZ}>(subtrahend);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> Minus(
|
||||
this double minuend, List<{typeNameZ}> units) => minuend.Minus<{typeNameZ}>(units);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Minus(
|
||||
this double minuend, List<{typeNameZ}?> units) => minuend.Minus<{typeNameZ}>(units);
|
||||
|
||||
// === ICollection<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ICollection<{typeNameZ}> units,
|
||||
double subtrahend, Span<{typeNameZ}> destination) => units.Minus<{typeNameZ}>(subtrahend, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ICollection<{typeNameZ}?> units,
|
||||
double subtrahend, Span<{typeNameZ}?> destination) => units.Minus<{typeNameZ}>(subtrahend, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||
ICollection<{typeNameZ}> units, Span<{typeNameZ}> destination) => minuend.Minus<{typeNameZ}>(units, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||
ICollection<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => minuend.Minus<{typeNameZ}>(units, destination);
|
||||
|
||||
// === IReadOnlyCollection<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Minus(this IReadOnlyCollection<{typeNameZ}> units,
|
||||
double subtrahend, Span<{typeNameZ}> destination) => units.Minus<{typeNameZ}>(subtrahend, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Minus(this IReadOnlyCollection<{typeNameZ}?> units,
|
||||
double subtrahend, Span<{typeNameZ}?> destination) => units.Minus<{typeNameZ}>(subtrahend, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||
IReadOnlyCollection<{typeNameZ}> units, Span<{typeNameZ}> destination) => minuend.Minus<{typeNameZ}>(units, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||
IReadOnlyCollection<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => minuend.Minus<{typeNameZ}>(units, destination);
|
||||
|
||||
// === IEnumerable<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> Minus(
|
||||
this IEnumerable<{typeNameZ}> units, double subtrahend) => units.Minus<{typeNameZ}>(subtrahend);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> Minus(
|
||||
this IEnumerable<{typeNameZ}?> units, double subtrahend) => units.Minus<{typeNameZ}>(subtrahend);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> Minus(
|
||||
this double minuend, IEnumerable<{typeNameZ}> units) => minuend.Minus<{typeNameZ}>(units);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> Minus(
|
||||
this double minuend, IEnumerable<{typeNameZ}?> units) => minuend.Minus<{typeNameZ}>(units);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// === ReadOnlySpan
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ReadOnlySpan<{typeNameZ}> units,
|
||||
double multiplicator, Span<{typeNameZ}> destination) => units.Mul<{typeNameZ}>(multiplicator, destination);
|
||||
@@ -546,137 +901,72 @@ public static class {typeNameZ}Extensions
|
||||
|
||||
|
||||
|
||||
// === ReadOnlySpan
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ReadOnlySpan<{typeNameZ}> units,
|
||||
double summand, Span<{typeNameZ}> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ReadOnlySpan<{typeNameZ}?> units,
|
||||
double summand, Span<{typeNameZ}?> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||
ReadOnlySpan<{typeNameZ}> units, Span<{typeNameZ}> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||
ReadOnlySpan<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||
|
||||
// === Array ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static {typeNameZ}[] Plus(
|
||||
this {typeNameZ}[] units, double summand) => units.Plus<{typeNameZ}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] Plus(
|
||||
this {typeNameZ}?[] units, double summand) => units.Plus<{typeNameZ}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] Plus(
|
||||
this double summand, {typeNameZ}[] units) => units.Plus<{typeNameZ}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] Plus(
|
||||
this double summand, {typeNameZ}?[] units) => units.Plus<{typeNameZ}>(summand);
|
||||
|
||||
// === List<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> Plus(
|
||||
this List<{typeNameZ}> units, double summand) => units.Plus<{typeNameZ}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Plus(
|
||||
this List<{typeNameZ}?> units, double summand) => units.Plus<{typeNameZ}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> Plus(
|
||||
this double summand, List<{typeNameZ}> units) => units.Plus<{typeNameZ}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Plus(
|
||||
this double summand, List<{typeNameZ}?> units) => units.Plus<{typeNameZ}>(summand);
|
||||
|
||||
// === ICollection<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ICollection<{typeNameZ}> units,
|
||||
double summand, Span<{typeNameZ}> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ICollection<{typeNameZ}?> units,
|
||||
double summand, Span<{typeNameZ}?> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||
ICollection<{typeNameZ}> units, Span<{typeNameZ}> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||
ICollection<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||
|
||||
// === IReadOnlyCollection<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Plus(this IReadOnlyCollection<{typeNameZ}> units,
|
||||
double summand, Span<{typeNameZ}> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Plus(this IReadOnlyCollection<{typeNameZ}?> units,
|
||||
double summand, Span<{typeNameZ}?> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||
IReadOnlyCollection<{typeNameZ}> units, Span<{typeNameZ}> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||
IReadOnlyCollection<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||
|
||||
// === IEnumerable<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> Plus(
|
||||
this IEnumerable<{typeNameZ}> units, double summand) => units.Plus<{typeNameZ}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> Plus(
|
||||
this IEnumerable<{typeNameZ}?> units, double summand) => units.Plus<{typeNameZ}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> Plus(
|
||||
this double summand, IEnumerable<{typeNameZ}> units) => units.Plus<{typeNameZ}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> Plus(
|
||||
this double summand, IEnumerable<{typeNameZ}?> units) => units.Plus<{typeNameZ}>(summand);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Sum Average Max Min (не nullable) ==========================================
|
||||
// Sum Avg Max Min (не nullable) ==========================================
|
||||
|
||||
|
||||
// === ReadOnlySpan === SIMD
|
||||
public static {typeNameZ} Sum(this ReadOnlySpan<{typeNameZ}> units) => AggregateUnitExtensions.Sum(units);
|
||||
public static {typeNameZ} Average(this ReadOnlySpan<{typeNameZ}> units) => AggregateUnitExtensions.Average(units);
|
||||
public static {typeNameZ} Avg(this ReadOnlySpan<{typeNameZ}> units) => AggregateUnitExtensions.Avg(units);
|
||||
public static {typeNameZ} Max(this ReadOnlySpan<{typeNameZ}> units) => AggregateUnitExtensions.Max(units);
|
||||
public static {typeNameZ} Min(this ReadOnlySpan<{typeNameZ}> units) => AggregateUnitExtensions.Min(units);
|
||||
|
||||
// === List<T> ===
|
||||
public static {typeNameZ} Sum(this List<{typeNameZ}> list) => AggregateUnitExtensions.Sum(list);
|
||||
public static {typeNameZ} Average(this List<{typeNameZ}> list) => AggregateUnitExtensions.Average(list);
|
||||
public static {typeNameZ} Avg(this List<{typeNameZ}> list) => AggregateUnitExtensions.Avg(list);
|
||||
public static {typeNameZ} Max(this List<{typeNameZ}> list) => AggregateUnitExtensions.Max(list);
|
||||
public static {typeNameZ} Min(this List<{typeNameZ}> list) => AggregateUnitExtensions.Min(list);
|
||||
|
||||
// === ICollection<T> ===
|
||||
public static {typeNameZ} Sum(this ICollection<{typeNameZ}> collection) => AggregateUnitExtensions.Sum(collection);
|
||||
public static {typeNameZ} Average(this ICollection<{typeNameZ}> collection) => AggregateUnitExtensions.Average(collection);
|
||||
public static {typeNameZ} Avg(this ICollection<{typeNameZ}> collection) => AggregateUnitExtensions.Avg(collection);
|
||||
public static {typeNameZ} Max(this ICollection<{typeNameZ}> collection) => AggregateUnitExtensions.Max(collection);
|
||||
public static {typeNameZ} Min(this ICollection<{typeNameZ}> collection) => AggregateUnitExtensions.Min(collection);
|
||||
|
||||
// === IReadOnlyCollection<T> ===
|
||||
public static {typeNameZ} Sum(this IReadOnlyCollection<{typeNameZ}> collection) => AggregateUnitExtensions.Sum(collection);
|
||||
public static {typeNameZ} Average(this IReadOnlyCollection<{typeNameZ}> collection) => AggregateUnitExtensions.Average(collection);
|
||||
public static {typeNameZ} Avg(this IReadOnlyCollection<{typeNameZ}> collection) => AggregateUnitExtensions.Avg(collection);
|
||||
public static {typeNameZ} Max(this IReadOnlyCollection<{typeNameZ}> collection) => AggregateUnitExtensions.Max(collection);
|
||||
public static {typeNameZ} Min(this IReadOnlyCollection<{typeNameZ}> collection) => AggregateUnitExtensions.Min(collection);
|
||||
|
||||
|
||||
// === IEnumerable<T> ===
|
||||
public static {typeNameZ} Sum(this IEnumerable<{typeNameZ}> collection) => AggregateUnitExtensions.Sum(collection);
|
||||
public static {typeNameZ} Average(this IEnumerable<{typeNameZ}> collection) => AggregateUnitExtensions.Average(collection);
|
||||
public static {typeNameZ} Avg(this IEnumerable<{typeNameZ}> collection) => AggregateUnitExtensions.Avg(collection);
|
||||
public static {typeNameZ} Max(this IEnumerable<{typeNameZ}> collection) => AggregateUnitExtensions.Max(collection);
|
||||
public static {typeNameZ} Min(this IEnumerable<{typeNameZ}> collection) => AggregateUnitExtensions.Min(collection);
|
||||
|
||||
|
||||
|
||||
// Sum Average Max Min (nullable) ==========================================
|
||||
// Sum Avg Max Min (nullable) ==========================================
|
||||
|
||||
|
||||
// === ReadOnlySpan ===
|
||||
public static {typeNameZ} Sum(this ReadOnlySpan<{typeNameZ}?> units) => AggregateUnitExtensions.Sum(units);
|
||||
public static {typeNameZ} Average(this ReadOnlySpan<{typeNameZ}?> units) => AggregateUnitExtensions.Average(units);
|
||||
public static {typeNameZ} Avg(this ReadOnlySpan<{typeNameZ}?> units) => AggregateUnitExtensions.Avg(units);
|
||||
public static {typeNameZ} Max(this ReadOnlySpan<{typeNameZ}?> units) => AggregateUnitExtensions.Max(units);
|
||||
public static {typeNameZ} Min(this ReadOnlySpan<{typeNameZ}?> units) => AggregateUnitExtensions.Min(units);
|
||||
|
||||
// === List<T> ===
|
||||
public static {typeNameZ} Sum(this List<{typeNameZ}?> list) => AggregateUnitExtensions.Sum(list);
|
||||
public static {typeNameZ} Average(this List<{typeNameZ}?> list) => AggregateUnitExtensions.Average(list);
|
||||
public static {typeNameZ} Avg(this List<{typeNameZ}?> list) => AggregateUnitExtensions.Avg(list);
|
||||
public static {typeNameZ} Max(this List<{typeNameZ}?> list) => AggregateUnitExtensions.Max(list);
|
||||
public static {typeNameZ} Min(this List<{typeNameZ}?> list) => AggregateUnitExtensions.Min(list);
|
||||
|
||||
// === ICollection<T> ===
|
||||
public static {typeNameZ} Sum(this ICollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||
public static {typeNameZ} Average(this ICollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Average(collection);
|
||||
public static {typeNameZ} Avg(this ICollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Avg(collection);
|
||||
public static {typeNameZ} Max(this ICollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Max(collection);
|
||||
public static {typeNameZ} Min(this ICollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Min(collection);
|
||||
|
||||
// === IReadOnlyCollection<T> ===
|
||||
public static {typeNameZ} Sum(this IReadOnlyCollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||
public static {typeNameZ} Average(this IReadOnlyCollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Average(collection);
|
||||
public static {typeNameZ} Avg(this IReadOnlyCollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Avg(collection);
|
||||
public static {typeNameZ} Max(this IReadOnlyCollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Max(collection);
|
||||
public static {typeNameZ} Min(this IReadOnlyCollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Min(collection);
|
||||
|
||||
// === IEnumerable<T> ===
|
||||
public static {typeNameZ} Sum(this IEnumerable<{typeNameZ}?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||
public static {typeNameZ} Average(this IEnumerable<{typeNameZ}?> collection) => AggregateUnitExtensions.Average(collection);
|
||||
public static {typeNameZ} Avg(this IEnumerable<{typeNameZ}?> collection) => AggregateUnitExtensions.Avg(collection);
|
||||
public static {typeNameZ} Max(this IEnumerable<{typeNameZ}?> collection) => AggregateUnitExtensions.Max(collection);
|
||||
public static {typeNameZ} Min(this IEnumerable<{typeNameZ}?> collection) => AggregateUnitExtensions.Min(collection);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace G;
|
||||
namespace G;
|
||||
|
||||
[Generator]
|
||||
public class TestsGenerator : IIncrementalGenerator
|
||||
@@ -67,8 +61,7 @@ public class TestsGenerator : IIncrementalGenerator
|
||||
var typeName = type.Name;
|
||||
var propName = baseProp.Name;
|
||||
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_SystemTextJson_SerializeDeserialize()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_SystemTextJson_SerializeDeserialize()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var original = {typeName}.{propName};");
|
||||
sb.AppendLine($" var json = System.Text.Json.JsonSerializer.Serialize(original);");
|
||||
@@ -76,8 +69,7 @@ public class TestsGenerator : IIncrementalGenerator
|
||||
sb.AppendLine($" Assert.Equal((double)original, (double)deserialized, Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_NewtonsoftJson_SerializeDeserialize()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_NewtonsoftJson_SerializeDeserialize()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var original = {typeName}.{propName};");
|
||||
sb.AppendLine($" var json = Newtonsoft.Json.JsonConvert.SerializeObject(original);");
|
||||
@@ -198,8 +190,7 @@ public class TestsGenerator : IIncrementalGenerator
|
||||
expectedExpr = $"(double)left {op.OperatorSymbol} (double)right";
|
||||
}
|
||||
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {testName}()");
|
||||
sb.AppendLine($" [Fact] public void {testName}()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var left = {leftTypeName}.{leftProp};");
|
||||
sb.AppendLine($" var right = {rightTypeName}.{rightProp};");
|
||||
@@ -236,6 +227,8 @@ public class TestsGenerator : IIncrementalGenerator
|
||||
sb.AppendLine(" public class CollectionTests");
|
||||
sb.AppendLine(" {");
|
||||
sb.AppendLine(" private const double Tolerance = 1e-12;");
|
||||
sb.AppendLine(" private const double scalar = 9d;");
|
||||
sb.AppendLine(" private static double[] dArray = new double[] { 5d, 3d };");
|
||||
sb.AppendLine();
|
||||
|
||||
foreach (var type in types)
|
||||
@@ -247,15 +240,13 @@ public class TestsGenerator : IIncrementalGenerator
|
||||
string propName = baseProp.Name;
|
||||
|
||||
// Создаём массив из двух тестовых значений
|
||||
sb.AppendLine($" private {typeName}[] {typeName}_GetTestArray() => {typeName}.{propName}.Mul(new double[] {{ 5d, 3d }});");
|
||||
sb.AppendLine($" private {typeName}[] {typeName}_GetTestArray() => {typeName}.{propName} * dArray;");
|
||||
sb.AppendLine();
|
||||
|
||||
// ========== Multiply ==========
|
||||
// scalar * array
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Multiply_ScalarByArray_Works()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_Multiply_ScalarByArray_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var arr = {typeName}_GetTestArray();");
|
||||
sb.AppendLine($" var result = scalar.Mul(arr);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||
@@ -264,10 +255,8 @@ public class TestsGenerator : IIncrementalGenerator
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// array * scalar
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Multiply_ArrayByScalar_Works()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_Multiply_ArrayByScalar_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var arr = {typeName}_GetTestArray();");
|
||||
sb.AppendLine($" var result = arr.Mul(scalar);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||
@@ -276,273 +265,109 @@ public class TestsGenerator : IIncrementalGenerator
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// scalar * List
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Multiply_ScalarByList_Works()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_Multiply_ScalarByList_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var list = {typeName}_GetTestArray().ToList();");
|
||||
sb.AppendLine($" var result = scalar.Mul(list);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||
sb.AppendLine($" var count = result.Count;");
|
||||
sb.AppendLine($" Assert.Equal(2, count);");
|
||||
sb.AppendLine($" Assert.Equal(scalar * 5d, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(scalar * 3d, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// List * scalar
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Multiply_ListByScalar_Works()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_Multiply_ListByScalar_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var list = {typeName}_GetTestArray().ToList();");
|
||||
sb.AppendLine($" var result = list.Mul(scalar);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||
sb.AppendLine($" var count = result.Count;");
|
||||
sb.AppendLine($" Assert.Equal(2, count);");
|
||||
sb.AppendLine($" Assert.Equal(scalar * 5d, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(scalar * 3d, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// scalar * IEnumerable
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Multiply_ScalarByEnumerable_Works()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_Multiply_ScalarByEnumerable_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var enumerable = {typeName}_GetTestArray().AsEnumerable();");
|
||||
sb.AppendLine($" var result = scalar.Mul(enumerable);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(scalar * 5d, (double)result.ElementAt(0), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(scalar * 3d, (double)result.ElementAt(1), Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// IEnumerable * scalar
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Multiply_EnumerableByScalar_Works()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_Multiply_EnumerableByScalar_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var enumerable = {typeName}_GetTestArray().AsEnumerable();");
|
||||
sb.AppendLine($" var result = enumerable.Mul(scalar);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(scalar * 5d, (double)result.ElementAt(0), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(scalar * 3d, (double)result.ElementAt(1), Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
|
||||
// ========== Divide ==========
|
||||
// scalar / array
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Divide_ScalarByArray_Works()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_Divide_ScalarByArray_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var arr = {typeName}_GetTestArray();");
|
||||
sb.AppendLine($" var result = scalar.Div(arr);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(scalar / 5d, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(scalar / 3d, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// array / scalar
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Divide_ArrayByScalar_Works()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_Divide_ArrayByScalar_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var arr = {typeName}_GetTestArray();");
|
||||
sb.AppendLine($" var result = arr.Div(scalar);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(5d / scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(3d / scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// scalar / List
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Divide_ScalarByList_Works()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_Divide_ScalarByList_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var list = {typeName}_GetTestArray().ToList();");
|
||||
sb.AppendLine($" var result = scalar.Div(list);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" var count = result.Count;");
|
||||
sb.AppendLine($" Assert.Equal(2, count);");
|
||||
sb.AppendLine($" Assert.Equal(scalar / 5d, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(scalar / 3d, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// List / scalar
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Divide_ListByScalar_Works()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_Divide_ListByScalar_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var list = {typeName}_GetTestArray().ToList();");
|
||||
sb.AppendLine($" var result = list.Div(scalar);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" var count = result.Count;");
|
||||
sb.AppendLine($" Assert.Equal(2, count);");
|
||||
sb.AppendLine($" Assert.Equal(5d / scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(3d / scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// scalar / IEnumerable
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Divide_ScalarByEnumerable_Works()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_Divide_ScalarByEnumerable_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var enumerable = {typeName}_GetTestArray().AsEnumerable();");
|
||||
sb.AppendLine($" var result = scalar.Div(enumerable);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(scalar / 5d, (double)result.ElementAt(0), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(scalar / 3d, (double)result.ElementAt(1), Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// IEnumerable / scalar
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Divide_EnumerableByScalar_Works()");
|
||||
sb.AppendLine($" [Fact] public void {typeName}_Divide_EnumerableByScalar_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var enumerable = {typeName}_GetTestArray().AsEnumerable();");
|
||||
sb.AppendLine($" var result = enumerable.Div(scalar);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
|
||||
// ========== Plus ==========
|
||||
// scalar + array
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Plus_ScalarByArray_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var arr = {typeName}_GetTestArray();");
|
||||
sb.AppendLine($" var result = scalar.Plus(arr);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// array + scalar
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Plus_ArrayByScalar_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var arr = {typeName}_GetTestArray();");
|
||||
sb.AppendLine($" var result = arr.Plus(scalar);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// scalar + List
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Plus_ScalarByList_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var list = {typeName}_GetTestArray().ToList();");
|
||||
sb.AppendLine($" var result = scalar.Plus(list);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// List + scalar
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Plus_ListByScalar_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var list = {typeName}_GetTestArray().ToList();");
|
||||
sb.AppendLine($" var result = list.Plus(scalar);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// scalar + IEnumerable
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Plus_ScalarByEnumerable_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var enumerable = {typeName}_GetTestArray().AsEnumerable();");
|
||||
sb.AppendLine($" var result = scalar.Plus(enumerable);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// IEnumerable + scalar
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Plus_EnumerableByScalar_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var enumerable = {typeName}_GetTestArray().AsEnumerable();");
|
||||
sb.AppendLine($" var result = enumerable.Plus(scalar);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
|
||||
// ========== Minus ==========
|
||||
// scalar - array
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Minus_ScalarByArray_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var arr = {typeName}_GetTestArray();");
|
||||
sb.AppendLine($" var result = scalar.Minus(arr);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// array - scalar
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Minus_ArrayByScalar_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var arr = {typeName}_GetTestArray();");
|
||||
sb.AppendLine($" var result = arr.Minus(scalar);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// scalar - List
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Minus_ScalarByList_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var list = {typeName}_GetTestArray().ToList();");
|
||||
sb.AppendLine($" var result = scalar.Minus(list);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// List - scalar
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Minus_ListByScalar_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var list = {typeName}_GetTestArray().ToList();");
|
||||
sb.AppendLine($" var result = list.Minus(scalar);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[0], Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[1], Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// scalar - IEnumerable
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Minus_ScalarByEnumerable_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var enumerable = {typeName}_GetTestArray().AsEnumerable();");
|
||||
sb.AppendLine($" var result = scalar.Minus(enumerable);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
// IEnumerable - scalar
|
||||
sb.AppendLine($" [Fact]");
|
||||
sb.AppendLine($" public void {typeName}_Minus_EnumerableByScalar_Works()");
|
||||
sb.AppendLine($" {{");
|
||||
sb.AppendLine($" var scalar = 9d;");
|
||||
sb.AppendLine($" var enumerable = {typeName}_GetTestArray().AsEnumerable();");
|
||||
sb.AppendLine($" var result = enumerable.Minus(scalar);");
|
||||
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(5d / scalar, (double)result.ElementAt(0), Tolerance);");
|
||||
sb.AppendLine($" Assert.Equal(3d / scalar, (double)result.ElementAt(1), Tolerance);");
|
||||
sb.AppendLine($" }}");
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
@@ -276,6 +276,14 @@ public readonly partial record struct {typeName} : IMensuraUnit<{typeName}>, IEq
|
||||
public static {typeName} operator /({typeName} T1, nuint T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, nuint? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// Half
|
||||
public static {typeName} operator *({typeName} T1, Half T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, Half? T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *(Half T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator *(Half? T1, {typeName} T2) => T1.ToDouble() * T2;
|
||||
public static {typeName} operator /({typeName} T1, Half T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, Half? T2) => T1 / T2.ToDouble();
|
||||
|
||||
// float
|
||||
public static {typeName} operator *({typeName} T1, float T2) => T1 * T2.ToDouble();
|
||||
public static {typeName} operator *({typeName} T1, float? T2) => T1 * T2.ToDouble();
|
||||
@@ -309,11 +317,272 @@ public readonly partial record struct {typeName} : IMensuraUnit<{typeName}>, IEq
|
||||
public static {typeName} operator /({typeName} T1, UInt128 T2) => T1 / T2.ToDouble();
|
||||
public static {typeName} operator /({typeName} T1, UInt128? T2) => T1 / T2.ToDouble();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static {typeName}[] operator +({typeName}[] T1, {typeName} T2) => T1.Plus(T2._Value);
|
||||
public static {typeName}?[] operator +({typeName}?[] T1, {typeName} T2) => T1.Plus(T2._Value);
|
||||
public static {typeName}[] operator +({typeName} T1, {typeName}[] T2) => T1._Value.Plus(T2);
|
||||
public static {typeName}?[] operator +({typeName} T1, {typeName}?[] T2) => T1._Value.Plus(T2);
|
||||
public static {typeName}[] operator +({typeName}[] T1, {typeName}? T2) => T1.Plus(T2.Protected());
|
||||
public static {typeName}?[] operator +({typeName}?[] T1, {typeName}? T2) => T1.Plus(T2.Protected());
|
||||
public static {typeName}[] operator +({typeName}? T1, {typeName}[] T2) => T1.Protected().Plus(T2);
|
||||
public static {typeName}?[] operator +({typeName}? T1, {typeName}?[] T2) => T1.Protected().Plus(T2);
|
||||
|
||||
public static {typeName}[] operator -({typeName}[] T1, {typeName} T2) => T1.Minus(T2._Value);
|
||||
public static {typeName}?[] operator -({typeName}?[] T1, {typeName} T2) => T1.Minus(T2._Value);
|
||||
public static {typeName}[] operator -({typeName} T1, {typeName}[] T2) => T1._Value.Minus(T2);
|
||||
public static {typeName}?[] operator -({typeName} T1, {typeName}?[] T2) => T1._Value.Minus(T2);
|
||||
public static {typeName}[] operator -({typeName}[] T1, {typeName}? T2) => T1.Minus(T2.Protected());
|
||||
public static {typeName}?[] operator -({typeName}?[] T1, {typeName}? T2) => T1.Minus(T2.Protected());
|
||||
public static {typeName}[] operator -({typeName}? T1, {typeName}[] T2) => T1.Protected().Minus(T2);
|
||||
public static {typeName}?[] operator -({typeName}? T1, {typeName}?[] T2) => T1.Protected().Minus(T2);
|
||||
|
||||
public static double[] operator /({typeName} T1, {typeName}[] T2) => T1.Div(T2);
|
||||
public static double?[] operator /({typeName} T1, {typeName}?[] T2) => T1.Div(T2);
|
||||
public static double[] operator /({typeName}[] T1, {typeName} T2) => T1.Div(T2);
|
||||
public static double?[] operator /({typeName}?[] T1, {typeName} T2) => T1.Div(T2);
|
||||
public static double[] operator /({typeName}? T1, {typeName}[] T2) => T1.ProtectedU().Div(T2);
|
||||
public static double?[] operator /({typeName}? T1, {typeName}?[] T2) => T1.ProtectedU().Div(T2);
|
||||
public static double[] operator /({typeName}[] T1, {typeName}? T2) => T1.Div(T2.ProtectedU());
|
||||
public static double?[] operator /({typeName}?[] T1, {typeName}? T2) => T1.Div(T2.ProtectedU());
|
||||
|
||||
|
||||
// double
|
||||
public static {typeName}[] operator *({typeName} T1, double[] T2) => T1.Mul(T2);
|
||||
public static {typeName}?[] operator *({typeName} T1, double?[] T2) => T1.Mul(T2);
|
||||
public static {typeName}[] operator *({typeName}? T1, double[] T2) => T1.ProtectedU().Mul(T2);
|
||||
public static {typeName}?[] operator *({typeName}? T1, double?[] T2) => T1.ProtectedU().Mul(T2);
|
||||
public static {typeName}[] operator *(double[] T1, {typeName} T2) => T1.Mul(T2);
|
||||
public static {typeName}?[] operator *(double?[] T1, {typeName} T2) => T1.Mul(T2);
|
||||
public static {typeName}[] operator *(double[] T1, {typeName}? T2) => T1.Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(double?[] T1, {typeName}? T2) => T1.Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, double[] T2) => T1.Div(T2);
|
||||
public static {typeName}?[] operator /({typeName} T1, double?[] T2) => T1.Div(T2);
|
||||
public static {typeName}[] operator /({typeName}? T1, double[] T2) => T1.ProtectedU().Div(T2);
|
||||
public static {typeName}?[] operator /({typeName}? T1, double?[] T2) => T1.ProtectedU().Div(T2);
|
||||
|
||||
// sbyte
|
||||
public static {typeName}[] operator *({typeName} T1, sbyte[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, sbyte?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, sbyte[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, sbyte?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(sbyte[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(sbyte?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(sbyte[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(sbyte?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, sbyte[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, sbyte?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, sbyte[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, sbyte?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// short
|
||||
public static {typeName}[] operator *({typeName} T1, short[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, short?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, short[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, short?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(short[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(short?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(short[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(short?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, short[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, short?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, short[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, short?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// int
|
||||
public static {typeName}[] operator *({typeName} T1, int[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, int?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, int[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, int?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(int[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(int?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(int[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(int?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, int[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, int?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, int[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, int?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// long
|
||||
public static {typeName}[] operator *({typeName} T1, long[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, long?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, long[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, long?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(long[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(long?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(long[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(long?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, long[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, long?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, long[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, long?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// byte
|
||||
public static {typeName}[] operator *({typeName} T1, byte[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, byte?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, byte[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, byte?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(byte[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(byte?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(byte[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(byte?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, byte[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, byte?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, byte[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, byte?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// ushort
|
||||
public static {typeName}[] operator *({typeName} T1, ushort[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, ushort?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, ushort[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, ushort?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(ushort[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(ushort?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(ushort[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(ushort?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, ushort[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, ushort?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, ushort[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, ushort?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// uint
|
||||
public static {typeName}[] operator *({typeName} T1, uint[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, uint?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, uint[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, uint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(uint[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(uint?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(uint[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(uint?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, uint[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, uint?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, uint[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, uint?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// ulong
|
||||
public static {typeName}[] operator *({typeName} T1, ulong[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, ulong?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, ulong[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, ulong?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(ulong[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(ulong?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(ulong[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(ulong?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, ulong[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, ulong?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, ulong[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, ulong?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// nint
|
||||
public static {typeName}[] operator *({typeName} T1, nint[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, nint?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, nint[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, nint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(nint[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(nint?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(nint[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(nint?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, nint[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, nint?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, nint[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, nint?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// nuint
|
||||
public static {typeName}[] operator *({typeName} T1, nuint[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, nuint?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, nuint[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, nuint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(nuint[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(nuint?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(nuint[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(nuint?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, nuint[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, nuint?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, nuint[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, nuint?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// Half
|
||||
public static {typeName}[] operator *({typeName} T1, Half[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, Half?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, Half[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, Half?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(Half[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(Half?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(Half[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(Half?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, Half[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, Half?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, Half[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, Half?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// float
|
||||
public static {typeName}[] operator *({typeName} T1, float[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, float?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, float[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, float?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(float[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(float?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(float[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(float?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, float[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, float?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, float[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, float?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// decimal
|
||||
public static {typeName}[] operator *({typeName} T1, decimal[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, decimal?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, decimal[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, decimal?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(decimal[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(decimal?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(decimal[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(decimal?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, decimal[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, decimal?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, decimal[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, decimal?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
// Int128
|
||||
public static {typeName}[] operator *({typeName} T1, Int128[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, Int128?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, Int128[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, Int128?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(Int128[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(Int128?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(Int128[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(Int128?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, Int128[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, Int128?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, Int128[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, Int128?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
|
||||
// UInt128
|
||||
public static {typeName}[] operator *({typeName} T1, UInt128[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName} T1, UInt128?[] T2) => T1.Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *({typeName}? T1, UInt128[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}?[] operator *({typeName}? T1, UInt128?[] T2) => T1.ProtectedU().Mul(T2.ToDouble());
|
||||
public static {typeName}[] operator *(UInt128[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}?[] operator *(UInt128?[] T1, {typeName} T2) => T1.ToDouble().Mul(T2);
|
||||
public static {typeName}[] operator *(UInt128[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}?[] operator *(UInt128?[] T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU());
|
||||
public static {typeName}[] operator /({typeName} T1, UInt128[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName} T1, UInt128?[] T2) => T1.Div(T2.ToDouble());
|
||||
public static {typeName}[] operator /({typeName}? T1, UInt128[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
public static {typeName}?[] operator /({typeName}? T1, UInt128?[] T2) => T1.ProtectedU().Div(T2.ToDouble());
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class {typeName}Extensions
|
||||
{
|
||||
internal static double Protected(this {typeName}? unit) => unit is null ? 0d : unit.Value._Value;
|
||||
internal static {typeName} ProtectedU(this {typeName}? unit) => unit is null ? {typeName}.Zero : unit.Value;
|
||||
|
||||
|
||||
|
||||
@@ -385,71 +654,6 @@ public static class {typeName}Extensions
|
||||
|
||||
|
||||
|
||||
// === ReadOnlySpan
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ReadOnlySpan<{typeName}> units,
|
||||
double subtrahend, Span<{typeName}> destination) => units.Minus<{typeName}>(subtrahend, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ReadOnlySpan<{typeName}?> units,
|
||||
double subtrahend, Span<{typeName}?> destination) => units.Minus<{typeName}>(subtrahend, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||
ReadOnlySpan<{typeName}> units, Span<{typeName}> destination) => minuend.Minus<{typeName}>(units, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||
ReadOnlySpan<{typeName}?> units, Span<{typeName}?> destination) => minuend.Minus<{typeName}>(units, destination);
|
||||
|
||||
// === Array ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static {typeName}[] Minus(
|
||||
this {typeName}[] units, double subtrahend) => units.Minus<{typeName}>(subtrahend);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}?[] Minus(
|
||||
this {typeName}?[] units, double subtrahend) => units.Minus<{typeName}>(subtrahend);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}[] Minus(
|
||||
this double minuend, {typeName}[] units) => minuend.Minus<{typeName}>(units);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}?[] Minus(
|
||||
this double minuend, {typeName}?[] units) => minuend.Minus<{typeName}>(units);
|
||||
|
||||
// === List<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}> Minus(
|
||||
this List<{typeName}> units, double subtrahend) => units.Minus<{typeName}>(subtrahend);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Minus(
|
||||
this List<{typeName}?> units, double subtrahend) => units.Minus<{typeName}>(subtrahend);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}> Minus(
|
||||
this double minuend, List<{typeName}> units) => minuend.Minus<{typeName}>(units);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Minus(
|
||||
this double minuend, List<{typeName}?> units) => minuend.Minus<{typeName}>(units);
|
||||
|
||||
// === ICollection<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ICollection<{typeName}> units,
|
||||
double subtrahend, Span<{typeName}> destination) => units.Minus<{typeName}>(subtrahend, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ICollection<{typeName}?> units,
|
||||
double subtrahend, Span<{typeName}?> destination) => units.Minus<{typeName}>(subtrahend, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||
ICollection<{typeName}> units, Span<{typeName}> destination) => minuend.Minus<{typeName}>(units, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||
ICollection<{typeName}?> units, Span<{typeName}?> destination) => minuend.Minus<{typeName}>(units, destination);
|
||||
|
||||
// === IReadOnlyCollection<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Minus(this IReadOnlyCollection<{typeName}> units,
|
||||
double subtrahend, Span<{typeName}> destination) => units.Minus<{typeName}>(subtrahend, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Minus(this IReadOnlyCollection<{typeName}?> units,
|
||||
double subtrahend, Span<{typeName}?> destination) => units.Minus<{typeName}>(subtrahend, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||
IReadOnlyCollection<{typeName}> units, Span<{typeName}> destination) => minuend.Minus<{typeName}>(units, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||
IReadOnlyCollection<{typeName}?> units, Span<{typeName}?> destination) => minuend.Minus<{typeName}>(units, destination);
|
||||
|
||||
// === IEnumerable<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}> Minus(
|
||||
this IEnumerable<{typeName}> units, double subtrahend) => units.Minus<{typeName}>(subtrahend);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}?> Minus(
|
||||
this IEnumerable<{typeName}?> units, double subtrahend) => units.Minus<{typeName}>(subtrahend);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}> Minus(
|
||||
this double minuend, IEnumerable<{typeName}> units) => minuend.Minus<{typeName}>(units);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}?> Minus(
|
||||
this double minuend, IEnumerable<{typeName}?> units) => minuend.Minus<{typeName}>(units);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// === ReadOnlySpan
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ReadOnlySpan<{typeName}> units,
|
||||
double multiplicator, Span<{typeName}> destination) => units.Mul<{typeName}>(multiplicator, destination);
|
||||
@@ -515,137 +719,72 @@ public static class {typeName}Extensions
|
||||
|
||||
|
||||
|
||||
// === ReadOnlySpan
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ReadOnlySpan<{typeName}> units,
|
||||
double summand, Span<{typeName}> destination) => units.Plus<{typeName}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ReadOnlySpan<{typeName}?> units,
|
||||
double summand, Span<{typeName}?> destination) => units.Plus<{typeName}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||
ReadOnlySpan<{typeName}> units, Span<{typeName}> destination) => units.Plus<{typeName}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||
ReadOnlySpan<{typeName}?> units, Span<{typeName}?> destination) => units.Plus<{typeName}>(summand, destination);
|
||||
|
||||
// === Array ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static {typeName}[] Plus(
|
||||
this {typeName}[] units, double summand) => units.Plus<{typeName}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}?[] Plus(
|
||||
this {typeName}?[] units, double summand) => units.Plus<{typeName}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}[] Plus(
|
||||
this double summand, {typeName}[] units) => units.Plus<{typeName}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}?[] Plus(
|
||||
this double summand, {typeName}?[] units) => units.Plus<{typeName}>(summand);
|
||||
|
||||
// === List<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}> Plus(
|
||||
this List<{typeName}> units, double summand) => units.Plus<{typeName}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Plus(
|
||||
this List<{typeName}?> units, double summand) => units.Plus<{typeName}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}> Plus(
|
||||
this double summand, List<{typeName}> units) => units.Plus<{typeName}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Plus(
|
||||
this double summand, List<{typeName}?> units) => units.Plus<{typeName}>(summand);
|
||||
|
||||
// === ICollection<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ICollection<{typeName}> units,
|
||||
double summand, Span<{typeName}> destination) => units.Plus<{typeName}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ICollection<{typeName}?> units,
|
||||
double summand, Span<{typeName}?> destination) => units.Plus<{typeName}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||
ICollection<{typeName}> units, Span<{typeName}> destination) => units.Plus<{typeName}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||
ICollection<{typeName}?> units, Span<{typeName}?> destination) => units.Plus<{typeName}>(summand, destination);
|
||||
|
||||
// === IReadOnlyCollection<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Plus(this IReadOnlyCollection<{typeName}> units,
|
||||
double summand, Span<{typeName}> destination) => units.Plus<{typeName}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Plus(this IReadOnlyCollection<{typeName}?> units,
|
||||
double summand, Span<{typeName}?> destination) => units.Plus<{typeName}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||
IReadOnlyCollection<{typeName}> units, Span<{typeName}> destination) => units.Plus<{typeName}>(summand, destination);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||
IReadOnlyCollection<{typeName}?> units, Span<{typeName}?> destination) => units.Plus<{typeName}>(summand, destination);
|
||||
|
||||
// === IEnumerable<T> ===
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}> Plus(
|
||||
this IEnumerable<{typeName}> units, double summand) => units.Plus<{typeName}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}?> Plus(
|
||||
this IEnumerable<{typeName}?> units, double summand) => units.Plus<{typeName}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}> Plus(
|
||||
this double summand, IEnumerable<{typeName}> units) => units.Plus<{typeName}>(summand);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}?> Plus(
|
||||
this double summand, IEnumerable<{typeName}?> units) => units.Plus<{typeName}>(summand);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Sum Average Max Min (не nullable) ==========================================
|
||||
// Sum Avg Max Min (не nullable) ==========================================
|
||||
|
||||
|
||||
// === ReadOnlySpan === SIMD
|
||||
public static {typeName} Sum(this ReadOnlySpan<{typeName}> units) => AggregateUnitExtensions.Sum(units);
|
||||
public static {typeName} Average(this ReadOnlySpan<{typeName}> units) => AggregateUnitExtensions.Average(units);
|
||||
public static {typeName} Avg(this ReadOnlySpan<{typeName}> units) => AggregateUnitExtensions.Avg(units);
|
||||
public static {typeName} Max(this ReadOnlySpan<{typeName}> units) => AggregateUnitExtensions.Max(units);
|
||||
public static {typeName} Min(this ReadOnlySpan<{typeName}> units) => AggregateUnitExtensions.Min(units);
|
||||
|
||||
// === List<T> ===
|
||||
public static {typeName} Sum(this List<{typeName}> list) => AggregateUnitExtensions.Sum(list);
|
||||
public static {typeName} Average(this List<{typeName}> list) => AggregateUnitExtensions.Average(list);
|
||||
public static {typeName} Avg(this List<{typeName}> list) => AggregateUnitExtensions.Avg(list);
|
||||
public static {typeName} Max(this List<{typeName}> list) => AggregateUnitExtensions.Max(list);
|
||||
public static {typeName} Min(this List<{typeName}> list) => AggregateUnitExtensions.Min(list);
|
||||
|
||||
// === ICollection<T> ===
|
||||
public static {typeName} Sum(this ICollection<{typeName}> collection) => AggregateUnitExtensions.Sum(collection);
|
||||
public static {typeName} Average(this ICollection<{typeName}> collection) => AggregateUnitExtensions.Average(collection);
|
||||
public static {typeName} Avg(this ICollection<{typeName}> collection) => AggregateUnitExtensions.Avg(collection);
|
||||
public static {typeName} Max(this ICollection<{typeName}> collection) => AggregateUnitExtensions.Max(collection);
|
||||
public static {typeName} Min(this ICollection<{typeName}> collection) => AggregateUnitExtensions.Min(collection);
|
||||
|
||||
// === IReadOnlyCollection<T> ===
|
||||
public static {typeName} Sum(this IReadOnlyCollection<{typeName}> collection) => AggregateUnitExtensions.Sum(collection);
|
||||
public static {typeName} Average(this IReadOnlyCollection<{typeName}> collection) => AggregateUnitExtensions.Average(collection);
|
||||
public static {typeName} Avg(this IReadOnlyCollection<{typeName}> collection) => AggregateUnitExtensions.Avg(collection);
|
||||
public static {typeName} Max(this IReadOnlyCollection<{typeName}> collection) => AggregateUnitExtensions.Max(collection);
|
||||
public static {typeName} Min(this IReadOnlyCollection<{typeName}> collection) => AggregateUnitExtensions.Min(collection);
|
||||
|
||||
|
||||
// === IEnumerable<T> ===
|
||||
public static {typeName} Sum(this IEnumerable<{typeName}> collection) => AggregateUnitExtensions.Sum(collection);
|
||||
public static {typeName} Average(this IEnumerable<{typeName}> collection) => AggregateUnitExtensions.Average(collection);
|
||||
public static {typeName} Avg(this IEnumerable<{typeName}> collection) => AggregateUnitExtensions.Avg(collection);
|
||||
public static {typeName} Max(this IEnumerable<{typeName}> collection) => AggregateUnitExtensions.Max(collection);
|
||||
public static {typeName} Min(this IEnumerable<{typeName}> collection) => AggregateUnitExtensions.Min(collection);
|
||||
|
||||
|
||||
|
||||
// Sum Average Max Min (nullable) ==========================================
|
||||
// Sum Avg Max Min (nullable) ==========================================
|
||||
|
||||
|
||||
// === ReadOnlySpan ===
|
||||
public static {typeName} Sum(this ReadOnlySpan<{typeName}?> units) => AggregateUnitExtensions.Sum(units);
|
||||
public static {typeName} Average(this ReadOnlySpan<{typeName}?> units) => AggregateUnitExtensions.Average(units);
|
||||
public static {typeName} Avg(this ReadOnlySpan<{typeName}?> units) => AggregateUnitExtensions.Avg(units);
|
||||
public static {typeName} Max(this ReadOnlySpan<{typeName}?> units) => AggregateUnitExtensions.Max(units);
|
||||
public static {typeName} Min(this ReadOnlySpan<{typeName}?> units) => AggregateUnitExtensions.Min(units);
|
||||
|
||||
// === List<T> ===
|
||||
public static {typeName} Sum(this List<{typeName}?> list) => AggregateUnitExtensions.Sum(list);
|
||||
public static {typeName} Average(this List<{typeName}?> list) => AggregateUnitExtensions.Average(list);
|
||||
public static {typeName} Avg(this List<{typeName}?> list) => AggregateUnitExtensions.Avg(list);
|
||||
public static {typeName} Max(this List<{typeName}?> list) => AggregateUnitExtensions.Max(list);
|
||||
public static {typeName} Min(this List<{typeName}?> list) => AggregateUnitExtensions.Min(list);
|
||||
|
||||
// === ICollection<T> ===
|
||||
public static {typeName} Sum(this ICollection<{typeName}?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||
public static {typeName} Average(this ICollection<{typeName}?> collection) => AggregateUnitExtensions.Average(collection);
|
||||
public static {typeName} Avg(this ICollection<{typeName}?> collection) => AggregateUnitExtensions.Avg(collection);
|
||||
public static {typeName} Max(this ICollection<{typeName}?> collection) => AggregateUnitExtensions.Max(collection);
|
||||
public static {typeName} Min(this ICollection<{typeName}?> collection) => AggregateUnitExtensions.Min(collection);
|
||||
|
||||
// === IReadOnlyCollection<T> ===
|
||||
public static {typeName} Sum(this IReadOnlyCollection<{typeName}?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||
public static {typeName} Average(this IReadOnlyCollection<{typeName}?> collection) => AggregateUnitExtensions.Average(collection);
|
||||
public static {typeName} Avg(this IReadOnlyCollection<{typeName}?> collection) => AggregateUnitExtensions.Avg(collection);
|
||||
public static {typeName} Max(this IReadOnlyCollection<{typeName}?> collection) => AggregateUnitExtensions.Max(collection);
|
||||
public static {typeName} Min(this IReadOnlyCollection<{typeName}?> collection) => AggregateUnitExtensions.Min(collection);
|
||||
|
||||
// === IEnumerable<T> ===
|
||||
public static {typeName} Sum(this IEnumerable<{typeName}?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||
public static {typeName} Average(this IEnumerable<{typeName}?> collection) => AggregateUnitExtensions.Average(collection);
|
||||
public static {typeName} Avg(this IEnumerable<{typeName}?> collection) => AggregateUnitExtensions.Avg(collection);
|
||||
public static {typeName} Max(this IEnumerable<{typeName}?> collection) => AggregateUnitExtensions.Max(collection);
|
||||
public static {typeName} Min(this IEnumerable<{typeName}?> collection) => AggregateUnitExtensions.Min(collection);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace QWERTYkez.Mensura.Extensions;
|
||||
|
||||
internal static partial class AggregateUnitExtensions
|
||||
{
|
||||
// Sum Average Max Min (не nullable) ==========================================
|
||||
// Sum Avg Max Min (не nullable) ==========================================
|
||||
|
||||
|
||||
// === ReadOnlySpan === SIMD
|
||||
@@ -73,7 +73,7 @@ internal static partial class AggregateUnitExtensions
|
||||
|
||||
return Unsafe.As<double, T>(ref sum);
|
||||
}
|
||||
internal static T Average<T>(this ReadOnlySpan<T> units)
|
||||
internal static T Avg<T>(this ReadOnlySpan<T> units)
|
||||
where T : struct, IMensuraUnit, IEquatable<T>
|
||||
{
|
||||
// Если коллекция пустая, возвращаем структуру, содержащую double.NaN
|
||||
@@ -140,10 +140,10 @@ internal static partial class AggregateUnitExtensions
|
||||
}
|
||||
|
||||
// Находим среднее значение
|
||||
double average = sum / values.Length;
|
||||
double Avg = sum / values.Length;
|
||||
|
||||
// Упаковываем double обратно в структуру T (zero-cost)
|
||||
return Unsafe.As<double, T>(ref average);
|
||||
return Unsafe.As<double, T>(ref Avg);
|
||||
}
|
||||
internal static T Max<T>(this ReadOnlySpan<T> units)
|
||||
where T : struct, IMensuraUnit, IEquatable<T>
|
||||
@@ -280,10 +280,10 @@ internal static partial class AggregateUnitExtensions
|
||||
{
|
||||
return CollectionsMarshal.AsSpan(list).Sum();
|
||||
}
|
||||
internal static T Average<T>(this List<T> list)
|
||||
internal static T Avg<T>(this List<T> list)
|
||||
where T : struct, IMensuraUnit, IEquatable<T>
|
||||
{
|
||||
return CollectionsMarshal.AsSpan(list).Average();
|
||||
return CollectionsMarshal.AsSpan(list).Avg();
|
||||
}
|
||||
internal static T Max<T>(this List<T> list)
|
||||
where T : struct, IMensuraUnit, IEquatable<T>
|
||||
@@ -315,18 +315,18 @@ internal static partial class AggregateUnitExtensions
|
||||
ArrayPool<T>.Shared.Return(sharedArray);
|
||||
}
|
||||
}
|
||||
internal static T Average<T>(this ICollection<T> collection)
|
||||
internal static T Avg<T>(this ICollection<T> collection)
|
||||
where T : struct, IMensuraUnit, IEquatable<T>
|
||||
{
|
||||
if (collection == null || collection.Count == 0) return double.NaN.ToUnit<T>();
|
||||
if (collection is T[] array) return array.Average();
|
||||
if (collection is List<T> list) return list.Average();
|
||||
if (collection is T[] array) return array.Avg();
|
||||
if (collection is List<T> list) return list.Avg();
|
||||
|
||||
T[] sharedArray = ArrayPool<T>.Shared.Rent(collection.Count);
|
||||
try
|
||||
{
|
||||
collection.CopyTo(sharedArray, 0);
|
||||
return new ReadOnlySpan<T>(sharedArray, 0, collection.Count).Average();
|
||||
return new ReadOnlySpan<T>(sharedArray, 0, collection.Count).Avg();
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -387,19 +387,19 @@ internal static partial class AggregateUnitExtensions
|
||||
}
|
||||
finally { ArrayPool<T>.Shared.Return(sharedArray); }
|
||||
}
|
||||
internal static T Average<T>(this IReadOnlyCollection<T> collection)
|
||||
internal static T Avg<T>(this IReadOnlyCollection<T> collection)
|
||||
where T : struct, IMensuraUnit, IEquatable<T>
|
||||
{
|
||||
if (collection == null || collection.Count == 0) return double.NaN.ToUnit<T>();
|
||||
if (collection is T[] array) return array.Average();
|
||||
if (collection is List<T> list) return list.Average();
|
||||
if (collection is T[] array) return array.Avg();
|
||||
if (collection is List<T> list) return list.Avg();
|
||||
|
||||
T[] sharedArray = ArrayPool<T>.Shared.Rent(collection.Count);
|
||||
int index = 0;
|
||||
try
|
||||
{
|
||||
foreach (var item in collection) sharedArray[index++] = item;
|
||||
return new ReadOnlySpan<T>(sharedArray, 0, collection.Count).Average();
|
||||
return new ReadOnlySpan<T>(sharedArray, 0, collection.Count).Avg();
|
||||
}
|
||||
finally { ArrayPool<T>.Shared.Return(sharedArray); }
|
||||
}
|
||||
@@ -461,15 +461,15 @@ internal static partial class AggregateUnitExtensions
|
||||
|
||||
return hasElements ? sum.ToUnit<T>() : default;
|
||||
}
|
||||
internal static T Average<T>(this IEnumerable<T> collection)
|
||||
internal static T Avg<T>(this IEnumerable<T> collection)
|
||||
where T : struct, IMensuraUnit, IEquatable<T>
|
||||
{
|
||||
if (collection == null) return double.NaN.ToUnit<T>();
|
||||
|
||||
if (collection is T[] array) return array.Average();
|
||||
if (collection is List<T> list) return list.Average();
|
||||
if (collection is ICollection<T> col) return col.Average();
|
||||
if (collection is IReadOnlyCollection<T> roc) return roc.Average();
|
||||
if (collection is T[] array) return array.Avg();
|
||||
if (collection is List<T> list) return list.Avg();
|
||||
if (collection is ICollection<T> col) return col.Avg();
|
||||
if (collection is IReadOnlyCollection<T> roc) return roc.Avg();
|
||||
|
||||
double sum = 0;
|
||||
long count = 0;
|
||||
@@ -532,7 +532,7 @@ internal static partial class AggregateUnitExtensions
|
||||
|
||||
|
||||
|
||||
// Sum Average Max Min (nullable) ==========================================
|
||||
// Sum Avg Max Min (nullable) ==========================================
|
||||
|
||||
|
||||
// === ReadOnlySpan ===
|
||||
@@ -568,7 +568,7 @@ internal static partial class AggregateUnitExtensions
|
||||
ArrayPool<double>.Shared.Return(sharedArray);
|
||||
}
|
||||
}
|
||||
internal static T Average<T>(this ReadOnlySpan<T?> units)
|
||||
internal static T Avg<T>(this ReadOnlySpan<T?> units)
|
||||
where T : struct, IMensuraUnit, IEquatable<T>
|
||||
{
|
||||
if (units.IsEmpty)
|
||||
@@ -600,7 +600,7 @@ internal static partial class AggregateUnitExtensions
|
||||
var validValues = new ReadOnlySpan<double>(sharedArray, 0, validCount);
|
||||
ReadOnlySpan<T> validStructs = MemoryMarshal.Cast<double, T>(validValues);
|
||||
|
||||
return validStructs.Average(); // Наш SIMD метод
|
||||
return validStructs.Avg(); // Наш SIMD метод
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -692,10 +692,10 @@ internal static partial class AggregateUnitExtensions
|
||||
{
|
||||
return CollectionsMarshal.AsSpan(list).Sum();
|
||||
}
|
||||
internal static T Average<T>(this List<T?> list)
|
||||
internal static T Avg<T>(this List<T?> list)
|
||||
where T : struct, IMensuraUnit, IEquatable<T>
|
||||
{
|
||||
return CollectionsMarshal.AsSpan(list).Average();
|
||||
return CollectionsMarshal.AsSpan(list).Avg();
|
||||
}
|
||||
internal static T Max<T>(this List<T?> list)
|
||||
where T : struct, IMensuraUnit, IEquatable<T>
|
||||
@@ -727,18 +727,18 @@ internal static partial class AggregateUnitExtensions
|
||||
ArrayPool<T?>.Shared.Return(sharedArray);
|
||||
}
|
||||
}
|
||||
internal static T Average<T>(this ICollection<T?> collection)
|
||||
internal static T Avg<T>(this ICollection<T?> collection)
|
||||
where T : struct, IMensuraUnit, IEquatable<T>
|
||||
{
|
||||
if (collection == null || collection.Count == 0) return double.NaN.ToUnit<T>();
|
||||
if (collection is T?[] array) return array.Average();
|
||||
if (collection is List<T?> list) return list.Average();
|
||||
if (collection is T?[] array) return array.Avg();
|
||||
if (collection is List<T?> list) return list.Avg();
|
||||
|
||||
T?[] sharedArray = ArrayPool<T?>.Shared.Rent(collection.Count);
|
||||
try
|
||||
{
|
||||
collection.CopyTo(sharedArray, 0);
|
||||
return new ReadOnlySpan<T?>(sharedArray, 0, collection.Count).Average();
|
||||
return new ReadOnlySpan<T?>(sharedArray, 0, collection.Count).Avg();
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -799,19 +799,19 @@ internal static partial class AggregateUnitExtensions
|
||||
}
|
||||
finally { ArrayPool<T?>.Shared.Return(sharedArray); }
|
||||
}
|
||||
internal static T Average<T>(this IReadOnlyCollection<T?> collection)
|
||||
internal static T Avg<T>(this IReadOnlyCollection<T?> collection)
|
||||
where T : struct, IMensuraUnit, IEquatable<T>
|
||||
{
|
||||
if (collection == null || collection.Count == 0) return double.NaN.ToUnit<T>();
|
||||
if (collection is T?[] array) return array.Average();
|
||||
if (collection is List<T?> list) return list.Average();
|
||||
if (collection is T?[] array) return array.Avg();
|
||||
if (collection is List<T?> list) return list.Avg();
|
||||
|
||||
T?[] sharedArray = ArrayPool<T?>.Shared.Rent(collection.Count);
|
||||
int index = 0;
|
||||
try
|
||||
{
|
||||
foreach (var item in collection) sharedArray[index++] = item;
|
||||
return new ReadOnlySpan<T?>(sharedArray, 0, collection.Count).Average();
|
||||
return new ReadOnlySpan<T?>(sharedArray, 0, collection.Count).Avg();
|
||||
}
|
||||
finally { ArrayPool<T?>.Shared.Return(sharedArray); }
|
||||
}
|
||||
@@ -875,15 +875,15 @@ internal static partial class AggregateUnitExtensions
|
||||
|
||||
return hasElements ? sum.ToUnit<T>() : default;
|
||||
}
|
||||
internal static T Average<T>(this IEnumerable<T?> collection)
|
||||
internal static T Avg<T>(this IEnumerable<T?> collection)
|
||||
where T : struct, IMensuraUnit, IEquatable<T>
|
||||
{
|
||||
if (collection == null) return double.NaN.ToUnit<T>();
|
||||
|
||||
if (collection is T?[] array) return array.Average();
|
||||
if (collection is List<T?> list) return list.Average();
|
||||
if (collection is ICollection<T?> col) return col.Average();
|
||||
if (collection is IReadOnlyCollection<T?> roc) return roc.Average();
|
||||
if (collection is T?[] array) return array.Avg();
|
||||
if (collection is List<T?> list) return list.Avg();
|
||||
if (collection is ICollection<T?> col) return col.Avg();
|
||||
if (collection is IReadOnlyCollection<T?> roc) return roc.Avg();
|
||||
|
||||
double sum = 0;
|
||||
long count = 0;
|
||||
|
||||
@@ -12,6 +12,7 @@ public static partial class DoubleExtensions
|
||||
internal static double ToDouble(this nuint number) => Convert.ToDouble(number);
|
||||
internal static double ToDouble(this long number) => Convert.ToDouble(number);
|
||||
internal static double ToDouble(this ulong number) => Convert.ToDouble(number);
|
||||
internal static double ToDouble(this Half number) => Convert.ToDouble(number);
|
||||
internal static double ToDouble(this float number) => Convert.ToDouble(number);
|
||||
internal static double ToDouble(this decimal number) => Convert.ToDouble(number);
|
||||
|
||||
@@ -25,6 +26,7 @@ public static partial class DoubleExtensions
|
||||
internal static double ToDouble(this nuint? number) => number is null ? 0d : Convert.ToDouble(number);
|
||||
internal static double ToDouble(this long? number) => number is null ? 0d : Convert.ToDouble(number);
|
||||
internal static double ToDouble(this ulong? number) => number is null ? 0d : Convert.ToDouble(number);
|
||||
internal static double ToDouble(this Half? number) => number is null ? 0d : Convert.ToDouble(number);
|
||||
internal static double ToDouble(this float? number) => number is null ? 0d : Convert.ToDouble(number);
|
||||
internal static double ToDouble(this decimal? number) => number is null ? 0d : Convert.ToDouble(number);
|
||||
|
||||
@@ -59,6 +61,8 @@ public static partial class DoubleExtensions
|
||||
{ foreach (var number in numbers) yield return number; }
|
||||
internal static IEnumerable<double> ToDoubleIterator(this IEnumerable<ulong> numbers)
|
||||
{ foreach (var number in numbers) yield return number; }
|
||||
internal static IEnumerable<double> ToDoubleIterator(this IEnumerable<Half> numbers)
|
||||
{ foreach (var number in numbers) yield return (double)number; }
|
||||
internal static IEnumerable<double> ToDoubleIterator(this IEnumerable<float> numbers)
|
||||
{ foreach (var number in numbers) yield return number; }
|
||||
internal static IEnumerable<double> ToDoubleIterator(this IEnumerable<decimal> numbers)
|
||||
@@ -287,6 +291,37 @@ public static partial class DoubleExtensions
|
||||
for (; i < len; i++) Unsafe.Add(ref dstRef, i) = Unsafe.Add(ref srcRef, i);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static void ToDoubleCore(this ReadOnlySpan<Half> source, int len, Span<double> destination)
|
||||
{
|
||||
if (len <= 0) return;
|
||||
|
||||
ref Half srcRef = ref MemoryMarshal.GetReference(source);
|
||||
ref double dstRef = ref MemoryMarshal.GetReference(destination);
|
||||
|
||||
int i = 0;
|
||||
int unrollEnd = len & ~7; // Шаг по 8 элементов (8 * 8 байт double = 64 байта строки кэша)
|
||||
|
||||
// Основной конвейер
|
||||
for (; i < unrollEnd; i += 8)
|
||||
{
|
||||
Unsafe.Add(ref dstRef, i) = (double)Unsafe.Add(ref srcRef, i);
|
||||
Unsafe.Add(ref dstRef, i + 1) = (double)Unsafe.Add(ref srcRef, i + 1);
|
||||
Unsafe.Add(ref dstRef, i + 2) = (double)Unsafe.Add(ref srcRef, i + 2);
|
||||
Unsafe.Add(ref dstRef, i + 3) = (double)Unsafe.Add(ref srcRef, i + 3);
|
||||
Unsafe.Add(ref dstRef, i + 4) = (double)Unsafe.Add(ref srcRef, i + 4);
|
||||
Unsafe.Add(ref dstRef, i + 5) = (double)Unsafe.Add(ref srcRef, i + 5);
|
||||
Unsafe.Add(ref dstRef, i + 6) = (double)Unsafe.Add(ref srcRef, i + 6);
|
||||
Unsafe.Add(ref dstRef, i + 7) = (double)Unsafe.Add(ref srcRef, i + 7);
|
||||
}
|
||||
|
||||
// Остаток цикла
|
||||
for (; i < len; i++)
|
||||
{
|
||||
Unsafe.Add(ref dstRef, i) = (double)Unsafe.Add(ref srcRef, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ========================================================================
|
||||
// ГРУППА 4: Типы без SIMD и новые типы .NET 7 (decimal, nint, Int128, UInt128).
|
||||
@@ -1224,6 +1259,89 @@ public static partial class DoubleExtensions
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static double[] ToDouble(this IEnumerable<Half> source, int count)
|
||||
{
|
||||
if (count == 0) return [];
|
||||
int i = 0;
|
||||
double[] destination = new double[count];
|
||||
ref double dstRef = ref MemoryMarshal.GetArrayDataReference(destination);
|
||||
foreach (var item in source)
|
||||
{
|
||||
if ((uint)i >= (uint)count) break;
|
||||
Unsafe.Add(ref dstRef, i++) = (double)item;
|
||||
}
|
||||
return destination;
|
||||
}
|
||||
public static double[] ToDouble(this Half[] numbers)
|
||||
{
|
||||
if (numbers is null) return null!;
|
||||
int len = numbers.Length;
|
||||
if (len == 0) return [];
|
||||
|
||||
var result = new double[len];
|
||||
numbers.ToDoubleCore(len, result);
|
||||
return result;
|
||||
}
|
||||
public static List<double> ToDouble(this List<Half> numbers)
|
||||
{
|
||||
if (numbers is null) return null!;
|
||||
int len = numbers.Count;
|
||||
if (len == 0) return [];
|
||||
|
||||
var result = new double[len];
|
||||
CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result);
|
||||
return result.WrapAsList();
|
||||
}
|
||||
public static void ToDouble(this ICollection<Half> numbers, Span<double> destination)
|
||||
{
|
||||
if (numbers is null) return;
|
||||
int count = numbers.Count;
|
||||
if (count == 0) return;
|
||||
if (destination.Length < count)
|
||||
throw new ArgumentException("Destination too short");
|
||||
|
||||
if (numbers is Half[] array) { array.ToDoubleCore(count, destination); return; }
|
||||
if (numbers is List<Half> list) { CollectionsMarshal.AsSpan(list).ToDoubleCore(count, destination); return; }
|
||||
|
||||
int i = 0;
|
||||
ref double dstRef = ref MemoryMarshal.GetReference(destination);
|
||||
foreach (var item in numbers)
|
||||
{
|
||||
if ((uint)i >= (uint)count) break;
|
||||
Unsafe.Add(ref dstRef, i++) = (double)item;
|
||||
}
|
||||
}
|
||||
public static void ToDouble(this IReadOnlyCollection<Half> numbers, Span<double> destination)
|
||||
{
|
||||
if (numbers is null) return;
|
||||
int count = numbers.Count;
|
||||
if (count == 0) return;
|
||||
if (destination.Length < count)
|
||||
throw new ArgumentException("Destination too short");
|
||||
|
||||
if (numbers is Half[] array) { array.ToDoubleCore(count, destination); return; }
|
||||
if (numbers is List<Half> list) { CollectionsMarshal.AsSpan(list).ToDoubleCore(count, destination); return; }
|
||||
|
||||
int i = 0;
|
||||
ref double dstRef = ref MemoryMarshal.GetReference(destination);
|
||||
foreach (var item in numbers)
|
||||
{
|
||||
if ((uint)i >= (uint)count) break;
|
||||
Unsafe.Add(ref dstRef, i++) = (double)item;
|
||||
}
|
||||
}
|
||||
public static IEnumerable<double> ToDouble(this IEnumerable<Half> numbers)
|
||||
{
|
||||
if (numbers is null) return null!;
|
||||
if (numbers is Half[] array) return array.ToDouble();
|
||||
if (numbers is List<Half> list) return list.ToDouble();
|
||||
if (numbers is ICollection<Half> col) return col.ToDouble(col.Count);
|
||||
if (numbers is IReadOnlyCollection<Half> roc) return roc.ToDouble(roc.Count);
|
||||
return numbers.ToDoubleIterator();
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static double[] ToDouble(this IEnumerable<float> source, int count)
|
||||
{
|
||||
@@ -1580,6 +1698,8 @@ public static partial class DoubleExtensions
|
||||
{ foreach (var number in numbers) yield return number; }
|
||||
internal static IEnumerable<double?> ToDoubleIterator(this IEnumerable<ulong?> numbers)
|
||||
{ foreach (var number in numbers) yield return number; }
|
||||
internal static IEnumerable<double?> ToDoubleIterator(this IEnumerable<Half?> numbers)
|
||||
{ foreach (var number in numbers) yield return (double?)number; }
|
||||
internal static IEnumerable<double?> ToDoubleIterator(this IEnumerable<float?> numbers)
|
||||
{ foreach (var number in numbers) yield return number; }
|
||||
internal static IEnumerable<double?> ToDoubleIterator(this IEnumerable<decimal?> numbers)
|
||||
@@ -2722,6 +2842,89 @@ public static partial class DoubleExtensions
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static double?[] ToDouble(this IEnumerable<Half?> source, int count)
|
||||
{
|
||||
if (count == 0) return [];
|
||||
int i = 0;
|
||||
double?[] destination = new double?[count];
|
||||
ref double? dstRef = ref MemoryMarshal.GetArrayDataReference(destination);
|
||||
foreach (var item in source)
|
||||
{
|
||||
if ((uint)i >= (uint)count) break;
|
||||
Unsafe.Add(ref dstRef, i++) = (double?)item;
|
||||
}
|
||||
return destination;
|
||||
}
|
||||
public static double?[] ToDouble(this Half?[] numbers)
|
||||
{
|
||||
if (numbers is null) return null!;
|
||||
int len = numbers.Length;
|
||||
if (len == 0) return [];
|
||||
|
||||
var result = new double?[len];
|
||||
numbers.ToDoubleCore(len, result);
|
||||
return result;
|
||||
}
|
||||
public static List<double?> ToDouble(this List<Half?> numbers)
|
||||
{
|
||||
if (numbers is null) return null!;
|
||||
int len = numbers.Count;
|
||||
if (len == 0) return [];
|
||||
|
||||
var result = new double?[len];
|
||||
CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result);
|
||||
return result.WrapAsList();
|
||||
}
|
||||
public static void ToDouble(this ICollection<Half?> numbers, Span<double?> destination)
|
||||
{
|
||||
if (numbers is null) return;
|
||||
int count = numbers.Count;
|
||||
if (count == 0) return;
|
||||
if (destination.Length < count)
|
||||
throw new ArgumentException("Destination too short");
|
||||
|
||||
if (numbers is Half?[] array) { array.ToDoubleCore(count, destination); return; }
|
||||
if (numbers is List<Half?> list) { CollectionsMarshal.AsSpan(list).ToDoubleCore(count, destination); return; }
|
||||
|
||||
int i = 0;
|
||||
ref double? dstRef = ref MemoryMarshal.GetReference(destination);
|
||||
foreach (var item in numbers)
|
||||
{
|
||||
if ((uint)i >= (uint)count) break;
|
||||
Unsafe.Add(ref dstRef, i++) = (double?)item;
|
||||
}
|
||||
}
|
||||
public static void ToDouble(this IReadOnlyCollection<Half?> numbers, Span<double?> destination)
|
||||
{
|
||||
if (numbers is null) return;
|
||||
int count = numbers.Count;
|
||||
if (count == 0) return;
|
||||
if (destination.Length < count)
|
||||
throw new ArgumentException("Destination too short");
|
||||
|
||||
if (numbers is Half?[] array) { array.ToDoubleCore(count, destination); return; }
|
||||
if (numbers is List<Half?> list) { CollectionsMarshal.AsSpan(list).ToDoubleCore(count, destination); return; }
|
||||
|
||||
int i = 0;
|
||||
ref double? dstRef = ref MemoryMarshal.GetReference(destination);
|
||||
foreach (var item in numbers)
|
||||
{
|
||||
if ((uint)i >= (uint)count) break;
|
||||
Unsafe.Add(ref dstRef, i++) = (double?)item;
|
||||
}
|
||||
}
|
||||
public static IEnumerable<double?> ToDouble(this IEnumerable<Half?> numbers)
|
||||
{
|
||||
if (numbers is null) return null!;
|
||||
if (numbers is Half?[] array) return array.ToDouble();
|
||||
if (numbers is List<Half?> list) return list.ToDouble();
|
||||
if (numbers is ICollection<Half?> col) return col.ToDouble(col.Count);
|
||||
if (numbers is IReadOnlyCollection<Half?> roc) return roc.ToDouble(roc.Count);
|
||||
return numbers.ToDoubleIterator();
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static double?[] ToDouble(this IEnumerable<float?> source, int count)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
namespace QWERTYkez.Mensura;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal unsafe struct ListLayoutMimic<T>
|
||||
internal class ListLayoutMimic<T>
|
||||
{
|
||||
public T[] Items;
|
||||
public T[] Items = null!;
|
||||
public int Size;
|
||||
public int Version;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user