diff --git a/QWERTYkez.Mensura.Generator/ComplexUnitGenerator.cs b/QWERTYkez.Mensura.Generator/ComplexUnitGenerator.cs index 2467983..0c9fb36 100644 --- a/QWERTYkez.Mensura.Generator/ComplexUnitGenerator.cs +++ b/QWERTYkez.Mensura.Generator/ComplexUnitGenerator.cs @@ -212,150 +212,150 @@ public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, I 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 ==({typeNameZ}? T1, {typeNameZ}? T2) => T1.Protected() == T2.Protected(); + public static bool operator !=({typeNameZ}? T1, {typeNameZ}? 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 <({typeNameZ}? T1, {typeNameZ}? T2) => T1.Protected() < T2.Protected(); + public static bool operator <=({typeNameZ}? T1, {typeNameZ}? T2) => T1.Protected() <= T2.Protected(); + public static bool operator >({typeNameZ}? T1, {typeNameZ}? T2) => T1.Protected() > T2.Protected(); + public static bool operator >=({typeNameZ}? T1, {typeNameZ}? 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); + public static {typeNameZ} operator +({typeNameZ} T2) => new(+T2._Value); + public static {typeNameZ} operator +({typeNameZ} T1, {typeNameZ} T2) => new(T1._Value + T2._Value); + public static {typeNameZ} operator -({typeNameZ} T2) => new(-T2._Value); + public static {typeNameZ} operator -({typeNameZ} T1, {typeNameZ} 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; + public static {typeNameZ} operator *({typeNameZ} T1, double T2) => new(T1._Value * T2); + public static {typeNameZ} operator *({typeNameZ} T1, double? T2) => T1 * (T2 ?? 0d); + public static {typeNameZ} operator *(double T1, {typeNameZ} T2) => new(T1 * T2._Value); + public static {typeNameZ} operator *(double? T1, {typeNameZ} T2) => (T1 ?? 0d) * T2; + public static {typeNameZ} operator /({typeNameZ} T1, double T2) => new(T1._Value / T2); + public static {typeNameZ} operator /({typeNameZ} T1, double? T2) => T1 / (T2 ?? 0d); + public static double operator /({typeNameZ} T1, {typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, sbyte T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, sbyte? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(sbyte T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(sbyte? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, sbyte T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, short T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, short? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(short T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(short? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, short T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, int T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, int? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(int T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(int? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, int T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, long T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, long? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(long T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(long? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, long T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, byte T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, byte? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(byte T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(byte? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, byte T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, ushort T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, ushort? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(ushort T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(ushort? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, ushort T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, uint T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, uint? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(uint T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(uint? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, uint T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, ulong T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, ulong? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(ulong T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(ulong? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, ulong T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, nint T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, nint? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(nint T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(nint? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, nint T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, nuint T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, nuint? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(nuint T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(nuint? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, nuint T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, Half T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, Half? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(Half T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(Half? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, Half T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, float T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, float? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(float T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(float? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, float T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, decimal T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, decimal? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(decimal T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(decimal? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, decimal T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, Int128 T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, Int128? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(Int128 T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(Int128? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, Int128 T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} 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(); + public static {typeNameZ} operator *({typeNameZ} T1, UInt128 T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *({typeNameZ} T1, UInt128? T2) => T1 * T2.ToDouble(); + public static {typeNameZ} operator *(UInt128 T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator *(UInt128? T1, {typeNameZ} T2) => T1.ToDouble() * T2; + public static {typeNameZ} operator /({typeNameZ} T1, UInt128 T2) => T1 / T2.ToDouble(); + public static {typeNameZ} operator /({typeNameZ} T1, UInt128? T2) => T1 / T2.ToDouble(); #endif @@ -505,258 +505,750 @@ public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, I - 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 {typeNameZ}[] operator +({typeNameZ}[] T1, {typeNameZ} T2) => T1.Plus(T2._Value); + public static {typeNameZ}?[] operator +({typeNameZ}?[] T1, {typeNameZ} T2) => T1.Plus(T2._Value); + public static {typeNameZ}[] operator +({typeNameZ} T1, {typeNameZ}[] T2) => T1._Value.Plus(T2); + public static {typeNameZ}?[] operator +({typeNameZ} T1, {typeNameZ}?[] T2) => T1._Value.Plus(T2); + public static {typeNameZ}[] operator +({typeNameZ}[] T1, {typeNameZ}? T2) => T1.Plus(T2.Protected()); + public static {typeNameZ}?[] operator +({typeNameZ}?[] T1, {typeNameZ}? T2) => T1.Plus(T2.Protected()); + public static {typeNameZ}[] operator +({typeNameZ}? T1, {typeNameZ}[] T2) => T1.Protected().Plus(T2); + public static {typeNameZ}?[] operator +({typeNameZ}? T1, {typeNameZ}?[] 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 {typeNameZ}[] operator -({typeNameZ}[] T1, {typeNameZ} T2) => T1.Minus(T2._Value); + public static {typeNameZ}?[] operator -({typeNameZ}?[] T1, {typeNameZ} T2) => T1.Minus(T2._Value); + public static {typeNameZ}[] operator -({typeNameZ} T1, {typeNameZ}[] T2) => T1._Value.Minus(T2); + public static {typeNameZ}?[] operator -({typeNameZ} T1, {typeNameZ}?[] T2) => T1._Value.Minus(T2); + public static {typeNameZ}[] operator -({typeNameZ}[] T1, {typeNameZ}? T2) => T1.Minus(T2.Protected()); + public static {typeNameZ}?[] operator -({typeNameZ}?[] T1, {typeNameZ}? T2) => T1.Minus(T2.Protected()); + public static {typeNameZ}[] operator -({typeNameZ}? T1, {typeNameZ}[] T2) => T1.Protected().Minus(T2); + public static {typeNameZ}?[] operator -({typeNameZ}? T1, {typeNameZ}?[] 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()); + public static double[] operator /({typeNameZ} T1, {typeNameZ}[] T2) => T1.Div(T2); + public static double?[] operator /({typeNameZ} T1, {typeNameZ}?[] T2) => T1.Div(T2); + public static double[] operator /({typeNameZ}[] T1, {typeNameZ} T2) => T1.Div(T2); + public static double?[] operator /({typeNameZ}?[] T1, {typeNameZ} T2) => T1.Div(T2); + public static double[] operator /({typeNameZ}? T1, {typeNameZ}[] T2) => T1.ProtectedU().Div(T2); + public static double?[] operator /({typeNameZ}? T1, {typeNameZ}?[] T2) => T1.ProtectedU().Div(T2); + public static double[] operator /({typeNameZ}[] T1, {typeNameZ}? T2) => T1.Div(T2.ProtectedU()); + public static double?[] operator /({typeNameZ}?[] T1, {typeNameZ}? 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); + public static {typeNameZ}[] operator *({typeNameZ} T1, double[] T2) => T1.Mul(T2); + public static {typeNameZ}?[] operator *({typeNameZ} T1, double?[] T2) => T1.Mul(T2); + public static {typeNameZ}[] operator *({typeNameZ}? T1, double[] T2) => T1.ProtectedU().Mul(T2); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, double?[] T2) => T1.ProtectedU().Mul(T2); + public static {typeNameZ}[] operator *(double[] T1, {typeNameZ} T2) => T1.Mul(T2); + public static {typeNameZ}?[] operator *(double?[] T1, {typeNameZ} T2) => T1.Mul(T2); + public static {typeNameZ}[] operator *(double[] T1, {typeNameZ}? T2) => T1.Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(double?[] T1, {typeNameZ}? T2) => T1.Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, double[] T2) => T1.Div(T2); + public static {typeNameZ}?[] operator /({typeNameZ} T1, double?[] T2) => T1.Div(T2); + public static {typeNameZ}[] operator /({typeNameZ}? T1, double[] T2) => T1.ProtectedU().Div(T2); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, sbyte[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, sbyte?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, sbyte[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, sbyte?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(sbyte[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(sbyte?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(sbyte[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(sbyte?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, sbyte[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, sbyte?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, sbyte[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, short[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, short?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, short[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, short?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(short[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(short?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(short[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(short?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, short[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, short?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, short[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, int[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, int?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, int[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, int?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(int[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(int?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(int[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(int?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, int[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, int?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, int[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, long[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, long?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, long[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, long?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(long[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(long?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(long[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(long?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, long[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, long?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, long[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, byte[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, byte?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, byte[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, byte?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(byte[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(byte?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(byte[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(byte?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, byte[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, byte?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, byte[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, ushort[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, ushort?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, ushort[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, ushort?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(ushort[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(ushort?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(ushort[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(ushort?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, ushort[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, ushort?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, ushort[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, uint[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, uint?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, uint[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, uint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(uint[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(uint?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(uint[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(uint?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, uint[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, uint?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, uint[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, ulong[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, ulong?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, ulong[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, ulong?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(ulong[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(ulong?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(ulong[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(ulong?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, ulong[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, ulong?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, ulong[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, nint[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, nint?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, nint[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, nint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(nint[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(nint?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(nint[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(nint?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, nint[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, nint?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, nint[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, nuint[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, nuint?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, nuint[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, nuint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(nuint[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(nuint?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(nuint[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(nuint?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, nuint[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, nuint?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, nuint[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, Half[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, Half?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, Half[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, Half?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(Half[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(Half?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(Half[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(Half?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, Half[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, Half?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, Half[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, float[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, float?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, float[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, float?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(float[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(float?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(float[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(float?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, float[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, float?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, float[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, decimal[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, decimal?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, decimal[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, decimal?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(decimal[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(decimal?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(decimal[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(decimal?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, decimal[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, decimal?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, decimal[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, Int128[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, Int128?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, Int128[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, Int128?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(Int128[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(Int128?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(Int128[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(Int128?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, Int128[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, Int128?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, Int128[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? 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()); + public static {typeNameZ}[] operator *({typeNameZ} T1, UInt128[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ} T1, UInt128?[] T2) => T1.Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *({typeNameZ}? T1, UInt128[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}?[] operator *({typeNameZ}? T1, UInt128?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static {typeNameZ}[] operator *(UInt128[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}?[] operator *(UInt128?[] T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static {typeNameZ}[] operator *(UInt128[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}?[] operator *(UInt128?[] T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static {typeNameZ}[] operator /({typeNameZ} T1, UInt128[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ} T1, UInt128?[] T2) => T1.Div(T2.ToDouble()); + public static {typeNameZ}[] operator /({typeNameZ}? T1, UInt128[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static {typeNameZ}?[] operator /({typeNameZ}? T1, UInt128?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); +#endif + + + + + + + + public static List<{typeNameZ}> operator +(List<{typeNameZ}> T1, {typeNameZ} T2) => T1.Plus(T2._Value); + public static List<{typeNameZ}?> operator +(List<{typeNameZ}?> T1, {typeNameZ} T2) => T1.Plus(T2._Value); + public static List<{typeNameZ}> operator +({typeNameZ} T1, List<{typeNameZ}> T2) => T1._Value.Plus(T2); + public static List<{typeNameZ}?> operator +({typeNameZ} T1, List<{typeNameZ}?> T2) => T1._Value.Plus(T2); + public static List<{typeNameZ}> operator +(List<{typeNameZ}> T1, {typeNameZ}? T2) => T1.Plus(T2.Protected()); + public static List<{typeNameZ}?> operator +(List<{typeNameZ}?> T1, {typeNameZ}? T2) => T1.Plus(T2.Protected()); + public static List<{typeNameZ}> operator +({typeNameZ}? T1, List<{typeNameZ}> T2) => T1.Protected().Plus(T2); + public static List<{typeNameZ}?> operator +({typeNameZ}? T1, List<{typeNameZ}?> T2) => T1.Protected().Plus(T2); + + public static List<{typeNameZ}> operator -(List<{typeNameZ}> T1, {typeNameZ} T2) => T1.Minus(T2._Value); + public static List<{typeNameZ}?> operator -(List<{typeNameZ}?> T1, {typeNameZ} T2) => T1.Minus(T2._Value); + public static List<{typeNameZ}> operator -({typeNameZ} T1, List<{typeNameZ}> T2) => T1._Value.Minus(T2); + public static List<{typeNameZ}?> operator -({typeNameZ} T1, List<{typeNameZ}?> T2) => T1._Value.Minus(T2); + public static List<{typeNameZ}> operator -(List<{typeNameZ}> T1, {typeNameZ}? T2) => T1.Minus(T2.Protected()); + public static List<{typeNameZ}?> operator -(List<{typeNameZ}?> T1, {typeNameZ}? T2) => T1.Minus(T2.Protected()); + public static List<{typeNameZ}> operator -({typeNameZ}? T1, List<{typeNameZ}> T2) => T1.Protected().Minus(T2); + public static List<{typeNameZ}?> operator -({typeNameZ}? T1, List<{typeNameZ}?> T2) => T1.Protected().Minus(T2); + + public static List operator /({typeNameZ} T1, List<{typeNameZ}> T2) => T1.Div(T2); + public static List operator /({typeNameZ} T1, List<{typeNameZ}?> T2) => T1.Div(T2); + public static List operator /(List<{typeNameZ}> T1, {typeNameZ} T2) => T1.Div(T2); + public static List operator /(List<{typeNameZ}?> T1, {typeNameZ} T2) => T1.Div(T2); + public static List operator /({typeNameZ}? T1, List<{typeNameZ}> T2) => T1.ProtectedU().Div(T2); + public static List operator /({typeNameZ}? T1, List<{typeNameZ}?> T2) => T1.ProtectedU().Div(T2); + public static List operator /(List<{typeNameZ}> T1, {typeNameZ}? T2) => T1.Div(T2.ProtectedU()); + public static List operator /(List<{typeNameZ}?> T1, {typeNameZ}? T2) => T1.Div(T2.ProtectedU()); + + + // double + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2); + + // sbyte + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // short + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // int + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // long + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // byte + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ushort + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // uint + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ulong + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nint + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nuint + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // float + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // decimal + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + +#if NET7_0_OR_GREATER + // Int128 + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // UInt128 + public static List<{typeNameZ}> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}?> operator *({typeNameZ}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static List<{typeNameZ}> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}?> operator *(List T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeNameZ}> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeNameZ}> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeNameZ}?> operator /({typeNameZ}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); +#endif + + + + + + + + public static IEnumerable<{typeNameZ}> operator +(IEnumerable<{typeNameZ}> T1, {typeNameZ} T2) => T1.Plus(T2._Value); + public static IEnumerable<{typeNameZ}?> operator +(IEnumerable<{typeNameZ}?> T1, {typeNameZ} T2) => T1.Plus(T2._Value); + public static IEnumerable<{typeNameZ}> operator +({typeNameZ} T1, IEnumerable<{typeNameZ}> T2) => T1._Value.Plus(T2); + public static IEnumerable<{typeNameZ}?> operator +({typeNameZ} T1, IEnumerable<{typeNameZ}?> T2) => T1._Value.Plus(T2); + public static IEnumerable<{typeNameZ}> operator +(IEnumerable<{typeNameZ}> T1, {typeNameZ}? T2) => T1.Plus(T2.Protected()); + public static IEnumerable<{typeNameZ}?> operator +(IEnumerable<{typeNameZ}?> T1, {typeNameZ}? T2) => T1.Plus(T2.Protected()); + public static IEnumerable<{typeNameZ}> operator +({typeNameZ}? T1, IEnumerable<{typeNameZ}> T2) => T1.Protected().Plus(T2); + public static IEnumerable<{typeNameZ}?> operator +({typeNameZ}? T1, IEnumerable<{typeNameZ}?> T2) => T1.Protected().Plus(T2); + + public static IEnumerable<{typeNameZ}> operator -(IEnumerable<{typeNameZ}> T1, {typeNameZ} T2) => T1.Minus(T2._Value); + public static IEnumerable<{typeNameZ}?> operator -(IEnumerable<{typeNameZ}?> T1, {typeNameZ} T2) => T1.Minus(T2._Value); + public static IEnumerable<{typeNameZ}> operator -({typeNameZ} T1, IEnumerable<{typeNameZ}> T2) => T1._Value.Minus(T2); + public static IEnumerable<{typeNameZ}?> operator -({typeNameZ} T1, IEnumerable<{typeNameZ}?> T2) => T1._Value.Minus(T2); + public static IEnumerable<{typeNameZ}> operator -(IEnumerable<{typeNameZ}> T1, {typeNameZ}? T2) => T1.Minus(T2.Protected()); + public static IEnumerable<{typeNameZ}?> operator -(IEnumerable<{typeNameZ}?> T1, {typeNameZ}? T2) => T1.Minus(T2.Protected()); + public static IEnumerable<{typeNameZ}> operator -({typeNameZ}? T1, IEnumerable<{typeNameZ}> T2) => T1.Protected().Minus(T2); + public static IEnumerable<{typeNameZ}?> operator -({typeNameZ}? T1, IEnumerable<{typeNameZ}?> T2) => T1.Protected().Minus(T2); + + public static IEnumerable operator /({typeNameZ} T1, IEnumerable<{typeNameZ}> T2) => T1.Div(T2); + public static IEnumerable operator /({typeNameZ} T1, IEnumerable<{typeNameZ}?> T2) => T1.Div(T2); + public static IEnumerable operator /(IEnumerable<{typeNameZ}> T1, {typeNameZ} T2) => T1.Div(T2); + public static IEnumerable operator /(IEnumerable<{typeNameZ}?> T1, {typeNameZ} T2) => T1.Div(T2); + public static IEnumerable operator /({typeNameZ}? T1, IEnumerable<{typeNameZ}> T2) => T1.ProtectedU().Div(T2); + public static IEnumerable operator /({typeNameZ}? T1, IEnumerable<{typeNameZ}?> T2) => T1.ProtectedU().Div(T2); + public static IEnumerable operator /(IEnumerable<{typeNameZ}> T1, {typeNameZ}? T2) => T1.Div(T2.ProtectedU()); + public static IEnumerable operator /(IEnumerable<{typeNameZ}?> T1, {typeNameZ}? T2) => T1.Div(T2.ProtectedU()); + + + // double + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2); + + // sbyte + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // short + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // int + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // long + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // byte + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ushort + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // uint + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ulong + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nint + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nuint + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // float + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // decimal + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + +#if NET7_0_OR_GREATER + // Int128 + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // UInt128 + public static IEnumerable<{typeNameZ}> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator *({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeNameZ}> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}?> operator *(IEnumerable T1, {typeNameZ}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeNameZ}?> operator /({typeNameZ}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); #endif } @@ -801,16 +1293,6 @@ public static class {typeNameZ}Extensions [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Div( this double dividend, List<{typeNameZ}?> units) => dividend.Div<{typeNameZ}>(units); - // === ICollection === - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ICollection<{typeNameZ}> units, - double divisor, Span<{typeNameZ}> destination) => units.Div<{typeNameZ}>(divisor, destination); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ICollection<{typeNameZ}?> units, - double divisor, Span<{typeNameZ}?> destination) => units.Div<{typeNameZ}>(divisor, destination); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, - ICollection<{typeNameZ}> units, Span<{typeNameZ}> destination) => dividend.Div<{typeNameZ}>(units, destination); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, - ICollection<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => dividend.Div<{typeNameZ}>(units, destination); - // === IReadOnlyCollection === [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Div(this IReadOnlyCollection<{typeNameZ}> units, double divisor, Span<{typeNameZ}> destination) => units.Div<{typeNameZ}>(divisor, destination); @@ -866,16 +1348,6 @@ public static class {typeNameZ}Extensions [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Mul( this double multiplicator, List<{typeNameZ}?> units) => units.Mul<{typeNameZ}>(multiplicator); - // === ICollection === - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ICollection<{typeNameZ}> units, - double multiplicator, Span<{typeNameZ}> destination) => units.Mul<{typeNameZ}>(multiplicator, destination); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ICollection<{typeNameZ}?> units, - double multiplicator, Span<{typeNameZ}?> destination) => units.Mul<{typeNameZ}>(multiplicator, destination); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, - ICollection<{typeNameZ}> units, Span<{typeNameZ}> destination) => units.Mul<{typeNameZ}>(multiplicator, destination); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, - ICollection<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => units.Mul<{typeNameZ}>(multiplicator, destination); - // === IReadOnlyCollection === [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Mul(this IReadOnlyCollection<{typeNameZ}> units, double multiplicator, Span<{typeNameZ}> destination) => units.Mul<{typeNameZ}>(multiplicator, destination); @@ -916,12 +1388,6 @@ public static class {typeNameZ}Extensions public static {typeNameZ} Max(this List<{typeNameZ}> list) => AggregateUnitExtensions.Max(list); public static {typeNameZ} Min(this List<{typeNameZ}> list) => AggregateUnitExtensions.Min(list); - // === ICollection === - public static {typeNameZ} Sum(this ICollection<{typeNameZ}> collection) => AggregateUnitExtensions.Sum(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 === public static {typeNameZ} Sum(this IReadOnlyCollection<{typeNameZ}> collection) => AggregateUnitExtensions.Sum(collection); public static {typeNameZ} Avg(this IReadOnlyCollection<{typeNameZ}> collection) => AggregateUnitExtensions.Avg(collection); @@ -952,12 +1418,6 @@ public static class {typeNameZ}Extensions public static {typeNameZ} Max(this List<{typeNameZ}?> list) => AggregateUnitExtensions.Max(list); public static {typeNameZ} Min(this List<{typeNameZ}?> list) => AggregateUnitExtensions.Min(list); - // === ICollection === - public static {typeNameZ} Sum(this ICollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Sum(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 === public static {typeNameZ} Sum(this IReadOnlyCollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Sum(collection); public static {typeNameZ} Avg(this IReadOnlyCollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Avg(collection); diff --git a/QWERTYkez.Mensura.Generator/UnitGenerator.cs b/QWERTYkez.Mensura.Generator/UnitGenerator.cs index 54cdf8e..5729f05 100644 --- a/QWERTYkez.Mensura.Generator/UnitGenerator.cs +++ b/QWERTYkez.Mensura.Generator/UnitGenerator.cs @@ -577,6 +577,498 @@ public readonly partial record struct {typeName} : IMensuraUnit<{typeName}>, IEq 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 List<{typeName}> operator +(List<{typeName}> T1, {typeName} T2) => T1.Plus(T2._Value); + public static List<{typeName}?> operator +(List<{typeName}?> T1, {typeName} T2) => T1.Plus(T2._Value); + public static List<{typeName}> operator +({typeName} T1, List<{typeName}> T2) => T1._Value.Plus(T2); + public static List<{typeName}?> operator +({typeName} T1, List<{typeName}?> T2) => T1._Value.Plus(T2); + public static List<{typeName}> operator +(List<{typeName}> T1, {typeName}? T2) => T1.Plus(T2.Protected()); + public static List<{typeName}?> operator +(List<{typeName}?> T1, {typeName}? T2) => T1.Plus(T2.Protected()); + public static List<{typeName}> operator +({typeName}? T1, List<{typeName}> T2) => T1.Protected().Plus(T2); + public static List<{typeName}?> operator +({typeName}? T1, List<{typeName}?> T2) => T1.Protected().Plus(T2); + + public static List<{typeName}> operator -(List<{typeName}> T1, {typeName} T2) => T1.Minus(T2._Value); + public static List<{typeName}?> operator -(List<{typeName}?> T1, {typeName} T2) => T1.Minus(T2._Value); + public static List<{typeName}> operator -({typeName} T1, List<{typeName}> T2) => T1._Value.Minus(T2); + public static List<{typeName}?> operator -({typeName} T1, List<{typeName}?> T2) => T1._Value.Minus(T2); + public static List<{typeName}> operator -(List<{typeName}> T1, {typeName}? T2) => T1.Minus(T2.Protected()); + public static List<{typeName}?> operator -(List<{typeName}?> T1, {typeName}? T2) => T1.Minus(T2.Protected()); + public static List<{typeName}> operator -({typeName}? T1, List<{typeName}> T2) => T1.Protected().Minus(T2); + public static List<{typeName}?> operator -({typeName}? T1, List<{typeName}?> T2) => T1.Protected().Minus(T2); + + public static List operator /({typeName} T1, List<{typeName}> T2) => T1.Div(T2); + public static List operator /({typeName} T1, List<{typeName}?> T2) => T1.Div(T2); + public static List operator /(List<{typeName}> T1, {typeName} T2) => T1.Div(T2); + public static List operator /(List<{typeName}?> T1, {typeName} T2) => T1.Div(T2); + public static List operator /({typeName}? T1, List<{typeName}> T2) => T1.ProtectedU().Div(T2); + public static List operator /({typeName}? T1, List<{typeName}?> T2) => T1.ProtectedU().Div(T2); + public static List operator /(List<{typeName}> T1, {typeName}? T2) => T1.Div(T2.ProtectedU()); + public static List operator /(List<{typeName}?> T1, {typeName}? T2) => T1.Div(T2.ProtectedU()); + + + // double + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2); + + // sbyte + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // short + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // int + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // long + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // byte + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ushort + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // uint + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ulong + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nint + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nuint + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // float + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // decimal + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + +#if NET7_0_OR_GREATER + // Int128 + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // UInt128 + public static List<{typeName}> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName} T1, List T2) => T1.Mul(T2.ToDouble()); + public static List<{typeName}> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}?> operator *({typeName}? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List<{typeName}> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}?> operator *(List T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static List<{typeName}> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}?> operator *(List T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List<{typeName}> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName} T1, List T2) => T1.Div(T2.ToDouble()); + public static List<{typeName}> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List<{typeName}?> operator /({typeName}? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); +#endif + + + + + + + + public static IEnumerable<{typeName}> operator +(IEnumerable<{typeName}> T1, {typeName} T2) => T1.Plus(T2._Value); + public static IEnumerable<{typeName}?> operator +(IEnumerable<{typeName}?> T1, {typeName} T2) => T1.Plus(T2._Value); + public static IEnumerable<{typeName}> operator +({typeName} T1, IEnumerable<{typeName}> T2) => T1._Value.Plus(T2); + public static IEnumerable<{typeName}?> operator +({typeName} T1, IEnumerable<{typeName}?> T2) => T1._Value.Plus(T2); + public static IEnumerable<{typeName}> operator +(IEnumerable<{typeName}> T1, {typeName}? T2) => T1.Plus(T2.Protected()); + public static IEnumerable<{typeName}?> operator +(IEnumerable<{typeName}?> T1, {typeName}? T2) => T1.Plus(T2.Protected()); + public static IEnumerable<{typeName}> operator +({typeName}? T1, IEnumerable<{typeName}> T2) => T1.Protected().Plus(T2); + public static IEnumerable<{typeName}?> operator +({typeName}? T1, IEnumerable<{typeName}?> T2) => T1.Protected().Plus(T2); + + public static IEnumerable<{typeName}> operator -(IEnumerable<{typeName}> T1, {typeName} T2) => T1.Minus(T2._Value); + public static IEnumerable<{typeName}?> operator -(IEnumerable<{typeName}?> T1, {typeName} T2) => T1.Minus(T2._Value); + public static IEnumerable<{typeName}> operator -({typeName} T1, IEnumerable<{typeName}> T2) => T1._Value.Minus(T2); + public static IEnumerable<{typeName}?> operator -({typeName} T1, IEnumerable<{typeName}?> T2) => T1._Value.Minus(T2); + public static IEnumerable<{typeName}> operator -(IEnumerable<{typeName}> T1, {typeName}? T2) => T1.Minus(T2.Protected()); + public static IEnumerable<{typeName}?> operator -(IEnumerable<{typeName}?> T1, {typeName}? T2) => T1.Minus(T2.Protected()); + public static IEnumerable<{typeName}> operator -({typeName}? T1, IEnumerable<{typeName}> T2) => T1.Protected().Minus(T2); + public static IEnumerable<{typeName}?> operator -({typeName}? T1, IEnumerable<{typeName}?> T2) => T1.Protected().Minus(T2); + + public static IEnumerable operator /({typeName} T1, IEnumerable<{typeName}> T2) => T1.Div(T2); + public static IEnumerable operator /({typeName} T1, IEnumerable<{typeName}?> T2) => T1.Div(T2); + public static IEnumerable operator /(IEnumerable<{typeName}> T1, {typeName} T2) => T1.Div(T2); + public static IEnumerable operator /(IEnumerable<{typeName}?> T1, {typeName} T2) => T1.Div(T2); + public static IEnumerable operator /({typeName}? T1, IEnumerable<{typeName}> T2) => T1.ProtectedU().Div(T2); + public static IEnumerable operator /({typeName}? T1, IEnumerable<{typeName}?> T2) => T1.ProtectedU().Div(T2); + public static IEnumerable operator /(IEnumerable<{typeName}> T1, {typeName}? T2) => T1.Div(T2.ProtectedU()); + public static IEnumerable operator /(IEnumerable<{typeName}?> T1, {typeName}? T2) => T1.Div(T2.ProtectedU()); + + + // double + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2); + + // sbyte + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // short + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // int + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // long + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // byte + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ushort + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // uint + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ulong + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nint + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nuint + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // float + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // decimal + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + +#if NET7_0_OR_GREATER + // Int128 + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // UInt128 + public static IEnumerable<{typeName}> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName} T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator *({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName} T2) => T1.ToDouble().Mul(T2); + public static IEnumerable<{typeName}> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}?> operator *(IEnumerable T1, {typeName}? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable<{typeName}> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName} T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable<{typeName}> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable<{typeName}?> operator /({typeName}? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); +#endif } public static class {typeName}Extensions @@ -619,16 +1111,6 @@ public static class {typeName}Extensions [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Div( this double dividend, List<{typeName}?> units) => dividend.Div<{typeName}>(units); - // === ICollection === - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ICollection<{typeName}> units, - double divisor, Span<{typeName}> destination) => units.Div<{typeName}>(divisor, destination); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ICollection<{typeName}?> units, - double divisor, Span<{typeName}?> destination) => units.Div<{typeName}>(divisor, destination); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, - ICollection<{typeName}> units, Span<{typeName}> destination) => dividend.Div<{typeName}>(units, destination); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, - ICollection<{typeName}?> units, Span<{typeName}?> destination) => dividend.Div<{typeName}>(units, destination); - // === IReadOnlyCollection === [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Div(this IReadOnlyCollection<{typeName}> units, double divisor, Span<{typeName}> destination) => units.Div<{typeName}>(divisor, destination); @@ -684,16 +1166,6 @@ public static class {typeName}Extensions [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Mul( this double multiplicator, List<{typeName}?> units) => units.Mul<{typeName}>(multiplicator); - // === ICollection === - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ICollection<{typeName}> units, - double multiplicator, Span<{typeName}> destination) => units.Mul<{typeName}>(multiplicator, destination); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ICollection<{typeName}?> units, - double multiplicator, Span<{typeName}?> destination) => units.Mul<{typeName}>(multiplicator, destination); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, - ICollection<{typeName}> units, Span<{typeName}> destination) => units.Mul<{typeName}>(multiplicator, destination); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, - ICollection<{typeName}?> units, Span<{typeName}?> destination) => units.Mul<{typeName}>(multiplicator, destination); - // === IReadOnlyCollection === [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Mul(this IReadOnlyCollection<{typeName}> units, double multiplicator, Span<{typeName}> destination) => units.Mul<{typeName}>(multiplicator, destination); @@ -734,12 +1206,6 @@ public static class {typeName}Extensions public static {typeName} Max(this List<{typeName}> list) => AggregateUnitExtensions.Max(list); public static {typeName} Min(this List<{typeName}> list) => AggregateUnitExtensions.Min(list); - // === ICollection === - public static {typeName} Sum(this ICollection<{typeName}> collection) => AggregateUnitExtensions.Sum(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 === public static {typeName} Sum(this IReadOnlyCollection<{typeName}> collection) => AggregateUnitExtensions.Sum(collection); public static {typeName} Avg(this IReadOnlyCollection<{typeName}> collection) => AggregateUnitExtensions.Avg(collection); @@ -770,12 +1236,6 @@ public static class {typeName}Extensions public static {typeName} Max(this List<{typeName}?> list) => AggregateUnitExtensions.Max(list); public static {typeName} Min(this List<{typeName}?> list) => AggregateUnitExtensions.Min(list); - // === ICollection === - public static {typeName} Sum(this ICollection<{typeName}?> collection) => AggregateUnitExtensions.Sum(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 === public static {typeName} Sum(this IReadOnlyCollection<{typeName}?> collection) => AggregateUnitExtensions.Sum(collection); public static {typeName} Avg(this IReadOnlyCollection<{typeName}?> collection) => AggregateUnitExtensions.Avg(collection); diff --git a/QWERTYkez.Mensura.Tests/AggregateUnitExtensions.cs b/QWERTYkez.Mensura.Tests/AggregateUnitExtensions.cs new file mode 100644 index 0000000..c16e34e --- /dev/null +++ b/QWERTYkez.Mensura.Tests/AggregateUnitExtensions.cs @@ -0,0 +1,170 @@ +using System.Reflection; + +namespace QWERTYkez.Mensura.Tests; + +public class AggregateUnitExtensions +{ + // Вспомогательный метод для создания объекта Length. + // Если у вас используется фабричный метод (например, Length.FromMeters), замените код внутри. + private static Length CreateLength(double value) => value * Length._MilliMeter; + + #region Инфраструктура Рефлексии (Invoker) + + private delegate Length SpanDelegate(ReadOnlySpan units); + private delegate Length SpanNullableDelegate(ReadOnlySpan units); + + private static class Invoker + { + private static readonly Type ExtType; + + static Invoker() + { + // Находим внутренний класс AggregateUnitExtensions в целевой сборке + ExtType = typeof(Length).Assembly.GetType("QWERTYkez.Mensura.Extensions.AggregateUnitExtensions") + ?? throw new InvalidOperationException("Не удалось найти класс AggregateUnitExtensions через рефлексию."); + } + + public static Length InvokeSpan(string methodName, ReadOnlySpan data) + { + var method = FindMethod(methodName, typeof(ReadOnlySpan<>), isNullable: false); + var closedMethod = method.MakeGenericMethod(typeof(Length)); + var del = closedMethod.CreateDelegate(); + return del(data); + } + + public static Length InvokeSpanNullable(string methodName, ReadOnlySpan data) + { + var method = FindMethod(methodName, typeof(ReadOnlySpan<>), isNullable: true); + var closedMethod = method.MakeGenericMethod(typeof(Length)); + var del = closedMethod.CreateDelegate(); + return del(data); + } + + public static Length InvokeCollection(string methodName, Type genericContainer, object data, bool isNullable) + { + var method = FindMethod(methodName, genericContainer, isNullable); + var closedMethod = method.MakeGenericMethod(typeof(Length)); + return (Length)closedMethod.Invoke(null, [data])!; + } + + private static MethodInfo FindMethod(string name, Type genericContainerType, bool isNullable) + { + var methods = ExtType.GetMethods(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public) + .Where(m => m.Name == name); + + foreach (var method in methods) + { + var parameters = method.GetParameters(); + if (parameters.Length != 1) continue; + + var paramType = parameters[0].ParameterType; + if (!paramType.IsGenericType) continue; + + // Проверяем базовый контейнер (List<>, IEnumerable<>, ReadOnlySpan<>) + if (paramType.GetGenericTypeDefinition() != genericContainerType) continue; + + // Проверяем внутренний аргумент типа на Nullable + var genericArgument = paramType.GetGenericArguments()[0]; + bool currentIsNullable = genericArgument.IsGenericType && + genericArgument.GetGenericTypeDefinition() == typeof(Nullable<>); + + if (currentIsNullable == isNullable) + { + return method; + } + } + + throw new MethodAccessException($"Метод {name} для контейнера {genericContainerType.Name} (Nullable: {isNullable}) не найден."); + } + } + + #endregion + + #region Тесты для НЕ-выделяющих Nullable типов (Обычные структуры) + + private readonly Length[] _standardData = [CreateLength(10), CreateLength(20), CreateLength(30)]; + private readonly Length _expectedSum = CreateLength(60); + private readonly Length _expectedAvg = CreateLength(20); + private readonly Length _expectedMax = CreateLength(30); + private readonly Length _expectedMin = CreateLength(10); + + [Theory] + [InlineData("Sum")] + [InlineData("Avg")] + [InlineData("Max")] + [InlineData("Min")] + public void StandardContainers_ShouldCalculateCorrectly(string operation) + { + // Набор ожидаемых значений + Length expected = operation switch + { + "Sum" => _expectedSum, + "Avg" => _expectedAvg, + "Max" => _expectedMax, + "Min" => _expectedMin, + _ => throw new ArgumentException(operation) + }; + + // 1. Тест ReadOnlySpan + ReadOnlySpan span = _standardData; + Assert.Equal(expected, Invoker.InvokeSpan(operation, span)); + + // 2. Тест List + var list = _standardData.ToList(); + Assert.Equal(expected, Invoker.InvokeCollection(operation, typeof(List<>), list, isNullable: false)); + + // 3. Тест IReadOnlyCollection + IReadOnlyCollection readOnlyCollection = _standardData; + Assert.Equal(expected, Invoker.InvokeCollection(operation, typeof(IReadOnlyCollection<>), readOnlyCollection, isNullable: false)); + + // 4. Тест IEnumerable + IEnumerable enumerable = _standardData.Select(x => x); + Assert.Equal(expected, Invoker.InvokeCollection(operation, typeof(IEnumerable<>), enumerable, isNullable: false)); + } + + #endregion + + #region Тесты для Nullable типов (T?) + + // Тестируем смесь значений с null-элементами + private readonly Length?[] _nullableData = [CreateLength(10), null, CreateLength(30)]; + private readonly Length _expectedNullSum = CreateLength(40); + private readonly Length _expectedNullAvg = CreateLength(20); // 40 / 2 значения + private readonly Length _expectedNullMax = CreateLength(30); + private readonly Length _expectedNullMin = CreateLength(10); + + [Theory] + [InlineData("Sum")] + [InlineData("Avg")] + [InlineData("Max")] + [InlineData("Min")] + public void NullableContainers_ShouldCalculateCorrectly(string operation) + { + Length expected = operation switch + { + "Sum" => _expectedNullSum, + "Avg" => _expectedNullAvg, + "Max" => _expectedNullMax, + "Min" => _expectedNullMin, + _ => throw new ArgumentException(operation) + }; + + // 1. Тест ReadOnlySpan + ReadOnlySpan span = _nullableData; + Assert.Equal(expected, Invoker.InvokeSpanNullable(operation, span)); + + // 2. Тест List + var list = _nullableData.ToList(); + Assert.Equal(expected, Invoker.InvokeCollection(operation, typeof(List<>), list, isNullable: true)); + + // 3. Тест IReadOnlyCollection + IReadOnlyCollection readOnlyCollection = _nullableData; + Assert.Equal(expected, Invoker.InvokeCollection(operation, typeof(IReadOnlyCollection<>), readOnlyCollection, isNullable: true)); + + // 4. Тест IEnumerable + IEnumerable enumerable = _nullableData.Select(x => x); + Assert.Equal(expected, Invoker.InvokeCollection(operation, typeof(IEnumerable<>), enumerable, isNullable: true)); + } + + #endregion +} \ No newline at end of file diff --git a/QWERTYkez.Mensura.Tests/CastExtensions.cs b/QWERTYkez.Mensura.Tests/CastExtensions.cs new file mode 100644 index 0000000..3f72b33 --- /dev/null +++ b/QWERTYkez.Mensura.Tests/CastExtensions.cs @@ -0,0 +1,165 @@ +namespace QWERTYkez.Mensura.Tests; + +public class CastExtensions +{ + private const double NormalValue1 = 42.42; + private const double NormalValue2 = 100.05; + + #region 1. Слабое место: Побитовая идентичность и спец-значения (NaN/Inf) + // Так как используется Unsafe.As, нужно убедиться, что битовая сетка double + // не ломается при сохранении пограничных значений (NaN, Infinity). + + [Theory] + [InlineData(NormalValue1)] + [InlineData(double.NaN)] + [InlineData(double.PositiveInfinity)] + [InlineData(double.NegativeInfinity)] + [InlineData(double.Epsilon)] + public void SingleConversion_Should_Preserve_Exact_BitPattern_For_Special_Doubles(double specialValue) + { + // Act + Length unit = specialValue.ToUnit(); + double recovered = unit.ToDouble(); + + // Assert + // Используем BitConverter, чтобы проверить идентичность на уровне битов (особенно важно для NaN) + long originalBits = BitConverter.DoubleToInt64Bits(specialValue); + long recoveredBits = BitConverter.DoubleToInt64Bits(recovered); + + Assert.Equal(originalBits, recoveredBits); + } + #endregion + + #region 2. Слабое место: Взрыв CLR при изменении емкости (EnsureCapacity) + // При ReCast списков подменяется MethodTable самого списка и его внутреннего массива. + // Если мы начнем добавлять элементы, список выделит новый массив через Array.CreateInstance. + // Если тип в MethodTable не совпадет с тем, что ожидает среда исполнения, GC или рантайм упадет. + + [Fact] + public void List_ReCast_Should_Survive_Massive_Resize_And_GC_Collections() + { + // Arrange + var originalList = new List { (Length)NormalValue1, (Length)NormalValue2 }; + + // Act + List morphedList = originalList.ReCast(); + + // Провоцируем многократное выделение новой памяти (Resize внутреннего массива) + for (int i = 0; i < 100; i++) + { + morphedList.Add(i * 1.1); + } + + // Вызываем сборщик мусора, чтобы проверить, не сошел ли он с ума от нашей подмены + GC.Collect(); + GC.WaitForPendingFinalizers(); + + // Assert + Assert.Equal(102, morphedList.Count); + Assert.Equal(NormalValue1, morphedList[0]); + Assert.Equal(10 * 1.1, morphedList[12], 5); // Проверка случайного элемента + } + #endregion + + #region 3. Слабое место: Ловушка `ArrayTypeMismatchException` при добавлении в WrapAsList + // WrapAsList создает фейковый список, подменяя MethodTable исходного массива на double[]. + // Но когда мы вызываем List.Add(), рантайм внутри делает Array.Copy(). + // Если CLR поймет, что исходный массив физически был массивом структур Length, + // вылетит ArrayTypeMismatchException. + + [Fact] + public void WrapAsList_Must_Allow_Adding_Elements_Without_ArrayTypeMismatchException() + { + // Arrange + Length[] sourceArray = [(Length)NormalValue1, (Length)NormalValue2]; + + // Act + List wrappedList = sourceArray.WrapAsList(); + + // Assert + // Это действие вызывает внутренний Array.Copy. Самое хрупкое место! + var exception = Record.Exception(() => wrappedList.Add(999.99)); + + Assert.Null(exception); // Тест провален, если здесь вылетит исключение типа массива + Assert.Equal(3, wrappedList.Count); + Assert.Equal(999.99, wrappedList[2]); + } + #endregion + + #region 4. Слабое место: Выравнивание памяти и макет Nullable типов + // Структура Nullable в памяти имеет размер больше, чем T (из-за флага HasValue и выравнивания). + // Подмена MethodTable для Nullable[] в Nullable[] — это огромный риск + // смещения байт. Проверяем, что null остается null, а значения не затираются. + + [Fact] + public void Nullable_Array_ReCast_Should_Not_Corrupt_Flags_And_Values() + { + // Arrange + Length?[] source = [(Length)NormalValue1, null, (Length)NormalValue2, null]; + + // Act + double?[] morphed = source.ReCast(); + + // Assert + Assert.Equal(source.Length, morphed.Length); + Assert.Equal(NormalValue1, morphed[0]); + Assert.Null(morphed[1]); + Assert.Equal(NormalValue2, morphed[2]); + Assert.Null(morphed[3]); + } + #endregion + + #region 5. Слабое место: In-Place мутация (Побочный эффект "Вуду") + // Так как ReCast и WrapAsList меняют MethodTable *оригинального* объекта прямо в куче, + // старая ссылка на массив Length[] теперь указывает на объект, который думает, что он double[]. + // Проверяем, как ведет себя оригинальная переменная после этого хака. + + [Fact] + public void Verify_InPlace_Mutation_SideEffect_Does_Not_Crash_Old_Reference() + { + // Arrange + Length[] originalArray = [(Length)NormalValue1]; + + // Act + double[] morphedArray = originalArray.ReCast(); + + // Изменяем элемент через НОВЫЙ массив + morphedArray[0] = 777.77; + + // Assert + // Внимание: из-за жесткой мутации в куче originalArray[0] теперь ТОЖЕ вернет 777.77, + // потому что они смотрят на одну память. Главное — чтобы CLR не упал при обращении к старой ссылке. + double valueFromOldRef = (double)originalArray[0]; + + Assert.Equal(777.77, valueFromOldRef); + Assert.Same(originalArray, morphedArray); // Физически это один и тот же объект в памяти + } + #endregion + + #region 6. Слабое место: Фильтры CLR и оптимизации LINQ + // Компилятор и JIT часто оптимизируют методы вроде .Select() или .ToArray(), + // опираясь на тип MethodTable. Проверяем, съедят ли механизмы LINQ наш "поддельный" тип. + + [Fact] + public void Morphed_Array_Should_Pass_Through_Linq_And_Native_Sorting_Validations() + { + // Arrange + Length[] originalArray = [(Length)NormalValue2, (Length)NormalValue1]; // [100.05, 42.42] + + // Act + double[] morphedArray = originalArray.ReCast(); + + // 1. Проверка LINQ фильтрации + double[] processedViaLinq = [.. morphedArray.Where(x => x > 50.0)]; + + Assert.Single(processedViaLinq); + Assert.Equal(NormalValue2, processedViaLinq[0]); + + // 2. Проверка работы встроенной нативной сортировки (Array.Sort использует JIT-оптимизации) + var sortException = Record.Exception(() => Array.Sort(morphedArray)); + + Assert.Null(sortException); + Assert.True(morphedArray[0] < morphedArray[1]); // Теперь [42.42, 100.05] + } + #endregion +} \ No newline at end of file diff --git a/QWERTYkez.Mensura.Tests/CollectionsDivideExtensions.cs b/QWERTYkez.Mensura.Tests/CollectionsDivideExtensions.cs new file mode 100644 index 0000000..f543f95 --- /dev/null +++ b/QWERTYkez.Mensura.Tests/CollectionsDivideExtensions.cs @@ -0,0 +1,292 @@ +namespace QWERTYkez.Mensura.Tests +{ + public class CollectionsDivideExtensionsTests + { + private const double Tolerance = 1e-12; + private static readonly Length scalarUnit = Length.Meter; // 1000 mm + private static readonly double scalarDouble = 2.0; + + // Коллекции для тестирования: два элемента + private static readonly Length[] unitsArray = [Length.Meter, Length._MilliMeter]; + private static readonly Length?[] nullableUnitsArray = [Length.Meter, null, Length._MilliMeter]; + private static readonly List unitsList = [Length.Meter, Length._MilliMeter]; + private static readonly List nullableUnitsList = [Length.Meter, null, Length._MilliMeter]; + private static readonly double[] doubleArray = [2.0, 3.0]; + private static readonly double?[] nullableDoubleArray = [2.0, null, 3.0]; + + // ====================== 1. T[] / double ====================== + [Fact] + public void Div_TArray_Double_Returns_TArray() + { + var result = unitsArray.Div(scalarDouble); + Assert.Equal(2, result.Length); + Assert.Equal(1000 / 2.0, (double)result[0], Tolerance); + Assert.Equal(1 / 2.0, (double)result[1], Tolerance); + } + + // ====================== 2. T?[] / double ====================== + [Fact] + public void Div_NullableTArray_Double_Returns_NullableTArray() + { + var result = nullableUnitsArray.Div(scalarDouble); + Assert.Equal(3, result.Length); + Assert.Equal(1000 / 2.0, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(1 / 2.0, (double)result[2]!, Tolerance); + } + + // ====================== 3. double / T[] ====================== + [Fact] + public void Div_Double_TArray_Returns_TArray() + { + var result = scalarDouble.Div(unitsArray); + Assert.Equal(2, result.Length); + Assert.Equal(2.0 / 1000, (double)result[0], Tolerance); + Assert.Equal(2.0 / 1, (double)result[1], Tolerance); + } + + // ====================== 4. double / T?[] ====================== + [Fact] + public void Div_Double_NullableTArray_Returns_NullableTArray() + { + var result = scalarDouble.Div(nullableUnitsArray); + Assert.Equal(3, result.Length); + Assert.Equal(2.0 / 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(2.0 / 1, (double)result[2]!, Tolerance); + } + + // ====================== 5. List / double ====================== + [Fact] + public void Div_ListT_Double_Returns_ListT() + { + var result = unitsList.Div(scalarDouble); + Assert.Equal(2, result.Count); + Assert.Equal(1000 / 2.0, (double)result[0], Tolerance); + Assert.Equal(1 / 2.0, (double)result[1], Tolerance); + } + + // ====================== 6. List / double ====================== + [Fact] + public void Div_ListNullableT_Double_Returns_ListNullableT() + { + var result = nullableUnitsList.Div(scalarDouble); + Assert.Equal(3, result.Count); + Assert.Equal(1000 / 2.0, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(1 / 2.0, (double)result[2]!, Tolerance); + } + + // ====================== 7. double / List ====================== + [Fact] + public void Div_Double_ListT_Returns_ListT() + { + var result = scalarDouble.Div(unitsList); + Assert.Equal(2, result.Count); + Assert.Equal(2.0 / 1000, (double)result[0], Tolerance); + Assert.Equal(2.0 / 1, (double)result[1], Tolerance); + } + + // ====================== 8. double / List ====================== + [Fact] + public void Div_Double_ListNullableT_Returns_ListNullableT() + { + var result = scalarDouble.Div(nullableUnitsList); + Assert.Equal(3, result.Count); + Assert.Equal(2.0 / 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(2.0 / 1, (double)result[2]!, Tolerance); + } + + // ====================== 9. IReadOnlyCollection / double (Span) ====================== + [Fact] + public void Div_IReadOnlyCollectionT_Double_Span() + { + Span dest = new Length[2]; + ((IReadOnlyCollection)unitsArray).Div(scalarDouble, dest); + Assert.Equal(1000 / 2.0, (double)dest[0], Tolerance); + Assert.Equal(1 / 2.0, (double)dest[1], Tolerance); + } + + // ====================== 10. IReadOnlyCollection / double (Span) ====================== + [Fact] + public void Div_IReadOnlyCollectionNullableT_Double_Span() + { + Span dest = new Length?[3]; + ((IReadOnlyCollection)nullableUnitsArray).Div(scalarDouble, dest); + Assert.Equal(1000 / 2.0, (double)dest[0]!, Tolerance); + Assert.Null(dest[1]); + Assert.Equal(1 / 2.0, (double)dest[2]!, Tolerance); + } + + // ====================== 11. double / IReadOnlyCollection (Span) ====================== + [Fact] + public void Div_Double_IReadOnlyCollectionT_Span() + { + Span dest = new Length[2]; + scalarDouble.Div((IReadOnlyCollection)unitsArray, dest); + Assert.Equal(2.0 / 1000, (double)dest[0], Tolerance); + Assert.Equal(2.0 / 1, (double)dest[1], Tolerance); + } + + // ====================== 12. double / IReadOnlyCollection (Span) ====================== + [Fact] + public void Div_Double_IReadOnlyCollectionNullableT_Span() + { + Span dest = new Length?[3]; + scalarDouble.Div((IReadOnlyCollection)nullableUnitsArray, dest); + Assert.Equal(2.0 / 1000, (double)dest[0]!, Tolerance); + Assert.Null(dest[1]); + Assert.Equal(2.0 / 1, (double)dest[2]!, Tolerance); + } + + // ====================== 13. IEnumerable / double ====================== + [Fact] + public void Div_IEnumerableT_Double_Returns_IEnumerableT() + { + var result = ((IEnumerable)unitsArray).Div(scalarDouble).ToList(); + Assert.Equal(2, result.Count); + Assert.Equal(1000 / 2.0, (double)result[0], Tolerance); + Assert.Equal(1 / 2.0, (double)result[1], Tolerance); + } + + // ====================== 14. IEnumerable / double ====================== + [Fact] + public void Div_IEnumerableNullableT_Double_Returns_IEnumerableNullableT() + { + var result = ((IEnumerable)nullableUnitsArray).Div(scalarDouble).ToList(); + Assert.Equal(3, result.Count); + Assert.Equal(1000 / 2.0, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(1 / 2.0, (double)result[2]!, Tolerance); + } + + // ====================== 15. double / IEnumerable ====================== + [Fact] + public void Div_Double_IEnumerableT_Returns_IEnumerableT() + { + var result = scalarDouble.Div((IEnumerable)unitsArray).ToList(); + Assert.Equal(2, result.Count); + Assert.Equal(2.0 / 1000, (double)result[0], Tolerance); + Assert.Equal(2.0 / 1, (double)result[1], Tolerance); + } + + // ====================== 16. double / IEnumerable ====================== + [Fact] + public void Div_Double_IEnumerableNullableT_Returns_IEnumerableNullableT() + { + var result = scalarDouble.Div((IEnumerable)nullableUnitsArray).ToList(); + Assert.Equal(3, result.Count); + Assert.Equal(2.0 / 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(2.0 / 1, (double)result[2]!, Tolerance); + } + + // ====================== 17. double[] / T ====================== + [Fact] + public void Div_DoubleArray_T_Returns_TArray() + { + var result = doubleArray.Div(scalarUnit); + Assert.Equal(2, result.Length); + Assert.Equal(2.0 / 1000, (double)result[0], Tolerance); + Assert.Equal(3.0 / 1000, (double)result[1], Tolerance); + } + + // ====================== 18. double?[] / T ====================== + [Fact] + public void Div_NullableDoubleArray_T_Returns_NullableTArray() + { + var result = nullableDoubleArray.Div(scalarUnit); + Assert.Equal(3, result.Length); + Assert.Equal(2.0 / 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(3.0 / 1000, (double)result[2]!, Tolerance); + } + + // ====================== 19. T / double[] ====================== + [Fact] + public void Div_T_DoubleArray_Returns_TArray() + { + var result = scalarUnit.Div(doubleArray); + Assert.Equal(2, result.Length); + Assert.Equal(1000 / 2.0, (double)result[0], Tolerance); + Assert.Equal(1000 / 3.0, (double)result[1], Tolerance); + } + + // ====================== 20. T / double?[] ====================== + [Fact] + public void Div_T_NullableDoubleArray_Returns_NullableTArray() + { + var result = scalarUnit.Div(nullableDoubleArray); + Assert.Equal(3, result.Length); + Assert.Equal(1000 / 2.0, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(1000 / 3.0, (double)result[2]!, Tolerance); + } + + // ====================== 21. List / T ====================== + [Fact] + public void Div_ListDouble_T_Returns_ListT() + { + var list = new List { 2.0, 3.0 }; + var result = list.Div(scalarUnit); + Assert.Equal(2, result.Count); + Assert.Equal(2.0 / 1000, (double)result[0], Tolerance); + Assert.Equal(3.0 / 1000, (double)result[1], Tolerance); + } + + // ====================== 22. List / T ====================== + [Fact] + public void Div_ListNullableDouble_T_Returns_ListNullableT() + { + var list = new List { 2.0, null, 3.0 }; + var result = list.Div(scalarUnit); + Assert.Equal(3, result.Count); + Assert.Equal(2.0 / 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(3.0 / 1000, (double)result[2]!, Tolerance); + } + + // ====================== 23. T / List ====================== + [Fact] + public void Div_T_ListDouble_Returns_ListT() + { + var list = new List { 2.0, 3.0 }; + var result = scalarUnit.Div(list); + Assert.Equal(2, result.Count); + Assert.Equal(1000 / 2.0, (double)result[0], Tolerance); + Assert.Equal(1000 / 3.0, (double)result[1], Tolerance); + } + + // ====================== 24. T / List ====================== + [Fact] + public void Div_T_ListNullableDouble_Returns_ListNullableT() + { + var list = new List { 2.0, null, 3.0 }; + var result = scalarUnit.Div(list); + Assert.Equal(3, result.Count); + Assert.Equal(1000 / 2.0, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(1000 / 3.0, (double)result[2]!, Tolerance); + } + + // ====================== 25. T / T[] -> double[] ====================== + [Fact] + public void Div_T_TArray_Returns_DoubleArray() + { + var result = scalarUnit.Div(unitsArray); + Assert.Equal(2, result.Length); + Assert.Equal(1000 / 1000.0, result[0], Tolerance); + Assert.Equal(1000 / 1.0, result[1], Tolerance); + } + + // ====================== Дополнительно: пустые коллекции, null аргументы ====================== + [Fact] + public void Div_EmptyArray_ReturnsEmptyArray() + { + var empty = Array.Empty(); + var result = empty.Div(2.0); + Assert.Empty(result); + } + } +} \ No newline at end of file diff --git a/QWERTYkez.Mensura.Tests/CollectionsMinusExtensions.cs b/QWERTYkez.Mensura.Tests/CollectionsMinusExtensions.cs new file mode 100644 index 0000000..ebaf4d1 --- /dev/null +++ b/QWERTYkez.Mensura.Tests/CollectionsMinusExtensions.cs @@ -0,0 +1,337 @@ +namespace QWERTYkez.Mensura.Tests +{ + public class CollectionsMinusExtensionsTests + { + private const double Tolerance = 1e-12; + private static readonly Length scalarUnit = Length.Meter; // 1000 mm + private static readonly double scalarDouble = 1000.0; // уменьшаемое/вычитаемое в мм + + // Коллекции единиц + private static readonly Length[] unitsArray = [Length.Meter, Length._MilliMeter]; + private static readonly Length?[] nullableUnitsArray = [Length.Meter, null, Length._MilliMeter]; + private static readonly List unitsList = [Length.Meter, Length._MilliMeter]; + private static readonly List nullableUnitsList = [Length.Meter, null, Length._MilliMeter]; + + // Коллекции double + private static readonly double[] doubleArray = [500.0, 200.0]; // мм + private static readonly double?[] nullableDoubleArray = [500.0, null, 200.0]; + private static readonly List doubleList = [500.0, 200.0]; + private static readonly List nullableDoubleList = [500.0, null, 200.0]; + + // ====================== 1. T[] - double (результат T[]) ====================== + [Fact] + public void Minus_TArray_Double_Returns_TArray() + { + // units - subtrahend + var result = unitsArray.Minus(scalarDouble); + Assert.Equal(2, result.Length); + Assert.Equal(1000 - 1000, (double)result[0], Tolerance); + Assert.Equal(1 - 1000, (double)result[1], Tolerance); + } + + [Fact] + public void Minus_TArray_Double_ByZero_Works() + { + var result = unitsArray.Minus(0.0); + Assert.Equal(1000, (double)result[0], Tolerance); + Assert.Equal(1, (double)result[1], Tolerance); + } + + // ====================== 2. T?[] - double (результат T?[]) ====================== + [Fact] + public void Minus_NullableTArray_Double_Returns_NullableTArray() + { + var result = nullableUnitsArray.Minus(scalarDouble); + Assert.Equal(3, result.Length); + Assert.Equal(1000 - 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(1 - 1000, (double)result[2]!, Tolerance); + } + + // ====================== 3. double - T[] (результат T[]) ====================== + [Fact] + public void Minus_Double_TArray_Returns_TArray() + { + var result = scalarDouble.Minus(unitsArray); + Assert.Equal(2, result.Length); + Assert.Equal(1000 - 1000, (double)result[0], Tolerance); + Assert.Equal(1000 - 1, (double)result[1], Tolerance); + } + + // ====================== 4. double - T?[] (результат T?[]) ====================== + [Fact] + public void Minus_Double_NullableTArray_Returns_NullableTArray() + { + var result = scalarDouble.Minus(nullableUnitsArray); + Assert.Equal(3, result.Length); + Assert.Equal(1000 - 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(1000 - 1, (double)result[2]!, Tolerance); + } + + // ====================== 5. List - double ====================== + [Fact] + public void Minus_ListT_Double_Returns_ListT() + { + var result = unitsList.Minus(scalarDouble); + Assert.Equal(2, result.Count); + Assert.Equal(1000 - 1000, (double)result[0], Tolerance); + Assert.Equal(1 - 1000, (double)result[1], Tolerance); + } + + // ====================== 6. List - double ====================== + [Fact] + public void Minus_ListNullableT_Double_Returns_ListNullableT() + { + var result = nullableUnitsList.Minus(scalarDouble); + Assert.Equal(3, result.Count); + Assert.Equal(1000 - 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(1 - 1000, (double)result[2]!, Tolerance); + } + + // ====================== 7. double - List ====================== + [Fact] + public void Minus_Double_ListT_Returns_ListT() + { + var result = scalarDouble.Minus(unitsList); + Assert.Equal(2, result.Count); + Assert.Equal(1000 - 1000, (double)result[0], Tolerance); + Assert.Equal(1000 - 1, (double)result[1], Tolerance); + } + + // ====================== 8. double - List ====================== + [Fact] + public void Minus_Double_ListNullableT_Returns_ListNullableT() + { + var result = scalarDouble.Minus(nullableUnitsList); + Assert.Equal(3, result.Count); + Assert.Equal(1000 - 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(1000 - 1, (double)result[2]!, Tolerance); + } + + // ====================== 9. IReadOnlyCollection - double (Span) ====================== + [Fact] + public void Minus_IReadOnlyCollectionT_Double_Span() + { + Span dest = new Length[2]; + ((IReadOnlyCollection)unitsArray).Minus(scalarDouble, dest); + Assert.Equal(1000 - 1000, (double)dest[0], Tolerance); + Assert.Equal(1 - 1000, (double)dest[1], Tolerance); + } + + // ====================== 10. IReadOnlyCollection - double (Span) ====================== + [Fact] + public void Minus_IReadOnlyCollectionNullableT_Double_Span() + { + Span dest = new Length?[3]; + ((IReadOnlyCollection)nullableUnitsArray).Minus(scalarDouble, dest); + Assert.Equal(1000 - 1000, (double)dest[0]!, Tolerance); + Assert.Null(dest[1]); + Assert.Equal(1 - 1000, (double)dest[2]!, Tolerance); + } + + // ====================== 11. double - IReadOnlyCollection (Span) ====================== + [Fact] + public void Minus_Double_IReadOnlyCollectionT_Span() + { + Span dest = new Length[2]; + scalarDouble.Minus((IReadOnlyCollection)unitsArray, dest); + Assert.Equal(1000 - 1000, (double)dest[0], Tolerance); + Assert.Equal(1000 - 1, (double)dest[1], Tolerance); + } + + // ====================== 12. double - IReadOnlyCollection (Span) ====================== + [Fact] + public void Minus_Double_IReadOnlyCollectionNullableT_Span() + { + Span dest = new Length?[3]; + scalarDouble.Minus((IReadOnlyCollection)nullableUnitsArray, dest); + Assert.Equal(1000 - 1000, (double)dest[0]!, Tolerance); + Assert.Null(dest[1]); + Assert.Equal(1000 - 1, (double)dest[2]!, Tolerance); + } + + // ====================== 13. IEnumerable - double ====================== + [Fact] + public void Minus_IEnumerableT_Double_Returns_IEnumerableT() + { + var result = ((IEnumerable)unitsArray).Minus(scalarDouble).ToList(); + Assert.Equal(2, result.Count); + Assert.Equal(1000 - 1000, (double)result[0], Tolerance); + Assert.Equal(1 - 1000, (double)result[1], Tolerance); + } + + // ====================== 14. IEnumerable - double ====================== + [Fact] + public void Minus_IEnumerableNullableT_Double_Returns_IEnumerableNullableT() + { + var result = ((IEnumerable)nullableUnitsArray).Minus(scalarDouble).ToList(); + Assert.Equal(3, result.Count); + Assert.Equal(1000 - 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(1 - 1000, (double)result[2]!, Tolerance); + } + + // ====================== 15. double - IEnumerable ====================== + [Fact] + public void Minus_Double_IEnumerableT_Returns_IEnumerableT() + { + var result = scalarDouble.Minus((IEnumerable)unitsArray).ToList(); + Assert.Equal(2, result.Count); + Assert.Equal(1000 - 1000, (double)result[0], Tolerance); + Assert.Equal(1000 - 1, (double)result[1], Tolerance); + } + + // ====================== 16. double - IEnumerable ====================== + [Fact] + public void Minus_Double_IEnumerableNullableT_Returns_IEnumerableNullableT() + { + var result = scalarDouble.Minus((IEnumerable)nullableUnitsArray).ToList(); + Assert.Equal(3, result.Count); + Assert.Equal(1000 - 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(1000 - 1, (double)result[2]!, Tolerance); + } + + // ====================== 17. double[] - T ====================== + [Fact] + public void Minus_DoubleArray_T_Returns_TArray() + { + var result = doubleArray.Minus(scalarUnit); + Assert.Equal(2, result.Length); + Assert.Equal(500 - 1000, (double)result[0], Tolerance); + Assert.Equal(200 - 1000, (double)result[1], Tolerance); + } + + // ====================== 18. double?[] - T ====================== + [Fact] + public void Minus_NullableDoubleArray_T_Returns_NullableTArray() + { + var result = nullableDoubleArray.Minus(scalarUnit); + Assert.Equal(3, result.Length); + Assert.Equal(500 - 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(200 - 1000, (double)result[2]!, Tolerance); + } + + // ====================== 19. T - double[] ====================== + [Fact] + public void Minus_T_DoubleArray_Returns_TArray() + { + var result = scalarUnit.Minus(doubleArray); + Assert.Equal(2, result.Length); + Assert.Equal(1000 - 500, (double)result[0], Tolerance); + Assert.Equal(1000 - 200, (double)result[1], Tolerance); + } + + // ====================== 20. T - double?[] ====================== + [Fact] + public void Minus_T_NullableDoubleArray_Returns_NullableTArray() + { + var result = scalarUnit.Minus(nullableDoubleArray); + Assert.Equal(3, result.Length); + Assert.Equal(1000 - 500, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(1000 - 200, (double)result[2]!, Tolerance); + } + + // ====================== 21. List - T ====================== + [Fact] + public void Minus_ListDouble_T_Returns_ListT() + { + var result = doubleList.Minus(scalarUnit); + Assert.Equal(2, result.Count); + Assert.Equal(500 - 1000, (double)result[0], Tolerance); + Assert.Equal(200 - 1000, (double)result[1], Tolerance); + } + + // ====================== 22. List - T ====================== + [Fact] + public void Minus_ListNullableDouble_T_Returns_ListNullableT() + { + var result = nullableDoubleList.Minus(scalarUnit); + Assert.Equal(3, result.Count); + Assert.Equal(500 - 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(200 - 1000, (double)result[2]!, Tolerance); + } + + // ====================== 23. T - List ====================== + [Fact] + public void Minus_T_ListDouble_Returns_ListT() + { + var result = scalarUnit.Minus(doubleList); + Assert.Equal(2, result.Count); + Assert.Equal(1000 - 500, (double)result[0], Tolerance); + Assert.Equal(1000 - 200, (double)result[1], Tolerance); + } + + // ====================== 24. T - List ====================== + [Fact] + public void Minus_T_ListNullableDouble_Returns_ListNullableT() + { + var result = scalarUnit.Minus(nullableDoubleList); + Assert.Equal(3, result.Count); + Assert.Equal(1000 - 500, (double)result[0]!, Tolerance); + Assert.Null(result[1]); + Assert.Equal(1000 - 200, (double)result[2]!, Tolerance); + } + + // ====================== 25. T - T[] -> double[] ====================== + [Fact] + public void Minus_T_TArray_Returns_DoubleArray() + { + var result = scalarUnit - unitsArray; + Assert.Equal(2, result.Length); + Assert.Equal(1000 - 1000, result[0]._Value, Tolerance); + Assert.Equal(1000 - 1, result[1]._Value, Tolerance); + } + + // Дополнительно: перегрузки, где результат double (без указания R) + // Тестируем Minus(T[] units, T subtrahend) – возвращает double[] + [Fact] + public void Minus_TArray_T_Returns_DoubleArray() + { + var result = unitsArray - scalarUnit; + Assert.Equal(2, result.Length); + Assert.Equal(1000 - 1000, result[0]._Value, Tolerance); + Assert.Equal(1 - 1000, result[1]._Value, Tolerance); + } + + [Fact] + public void Minus_ListT_T_Returns_DoubleList() + { + var result = unitsList - scalarUnit; + Assert.Equal(2, result.Count); + Assert.Equal(1000 - 1000, result[0]._Value, Tolerance); + Assert.Equal(1 - 1000, result[1]._Value, Tolerance); + } + + // Проверка пустых коллекций + [Fact] + public void Minus_EmptyArray_ReturnsEmptyArray() + { + var empty = Array.Empty(); + var result = empty.Minus(5.0); + Assert.Empty(result); + } + + [Fact] + public void Minus_NullArray_ReturnsNull() + { + Length[] nullArray = null!; + var result = nullArray.Minus(5.0); + Assert.Null(result); + } + + [Fact] + public void Minus_NullList_ReturnsNull() + { + List nullList = null!; + var result = nullList.Minus(5.0); + Assert.Null(result); + } + } +} \ No newline at end of file diff --git a/QWERTYkez.Mensura.Tests/CollectionsMultiplyExtensions.cs b/QWERTYkez.Mensura.Tests/CollectionsMultiplyExtensions.cs new file mode 100644 index 0000000..157b631 --- /dev/null +++ b/QWERTYkez.Mensura.Tests/CollectionsMultiplyExtensions.cs @@ -0,0 +1,335 @@ +namespace QWERTYkez.Mensura.Tests +{ + public class CollectionsMultiplyExtensionsTests + { + private const double Tolerance = 1e-12; + private static readonly Length scalarUnit = Length.Meter; // 1000 mm + private static readonly double scalarDouble = 2.0; + + // Коллекции единиц + private static readonly Length[] unitsArray = [Length.Meter, Length._MilliMeter]; + private static readonly Length?[] nullableUnitsArray = [Length.Meter, null, Length._MilliMeter]; + private static readonly List unitsList = [Length.Meter, Length._MilliMeter]; + private static readonly List nullableUnitsList = [Length.Meter, null, Length._MilliMeter]; + + // Коллекции double + private static readonly double[] doubleArray = [5.0, 3.0]; + private static readonly double?[] nullableDoubleArray = [5.0, null, 3.0]; + private static readonly List doubleList = [5.0, 3.0]; + private static readonly List nullableDoubleList = [5.0, null, 3.0]; + + // ====================== 1. T[] * double ====================== + [Fact] + public void Mul_TArray_Double_Returns_TArray() + { + var result = unitsArray.Mul(scalarDouble); + Assert.Equal(2, result.Length); + Assert.Equal(1000 * 2, (double)result[0], Tolerance); + Assert.Equal(1 * 2, (double)result[1], Tolerance); + } + + [Fact] + public void Mul_TArray_Double_ByZero_Works() + { + var result = unitsArray.Mul(0.0); + Assert.Equal(0, (double)result[0], Tolerance); + Assert.Equal(0, (double)result[1], Tolerance); + } + + // ====================== 2. T?[] * double ====================== + [Fact] + public void Mul_NullableTArray_Double_Returns_NullableTArray() + { + var result = nullableUnitsArray.Mul(scalarDouble); + Assert.Equal(3, result.Length); + Assert.Equal(1000 * 2, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // null * 2 = null + Assert.Equal(1 * 2, (double)result[2]!, Tolerance); + } + + // ====================== 3. double * T[] ====================== + [Fact] + public void Mul_Double_TArray_Returns_TArray() + { + var result = scalarDouble.Mul(unitsArray); + Assert.Equal(2, result.Length); + Assert.Equal(2 * 1000, (double)result[0], Tolerance); + Assert.Equal(2 * 1, (double)result[1], Tolerance); + } + + // ====================== 4. double * T?[] ====================== + [Fact] + public void Mul_Double_NullableTArray_Returns_NullableTArray() + { + var result = scalarDouble.Mul(nullableUnitsArray); + Assert.Equal(3, result.Length); + Assert.Equal(2 * 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // 2 * null = null + Assert.Equal(2 * 1, (double)result[2]!, Tolerance); + } + + // ====================== 5. List * double ====================== + [Fact] + public void Mul_ListT_Double_Returns_ListT() + { + var result = unitsList.Mul(scalarDouble); + Assert.Equal(2, result.Count); + Assert.Equal(1000 * 2, (double)result[0], Tolerance); + Assert.Equal(1 * 2, (double)result[1], Tolerance); + } + + // ====================== 6. List * double ====================== + [Fact] + public void Mul_ListNullableT_Double_Returns_ListNullableT() + { + var result = nullableUnitsList.Mul(scalarDouble); + Assert.Equal(3, result.Count); + Assert.Equal(1000 * 2, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // null * 2 = null + Assert.Equal(1 * 2, (double)result[2]!, Tolerance); + } + + // ====================== 7. double * List ====================== + [Fact] + public void Mul_Double_ListT_Returns_ListT() + { + var result = scalarDouble.Mul(unitsList); + Assert.Equal(2, result.Count); + Assert.Equal(2 * 1000, (double)result[0], Tolerance); + Assert.Equal(2 * 1, (double)result[1], Tolerance); + } + + // ====================== 8. double * List ====================== + [Fact] + public void Mul_Double_ListNullableT_Returns_ListNullableT() + { + var result = scalarDouble.Mul(nullableUnitsList); + Assert.Equal(3, result.Count); + Assert.Equal(2 * 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // 2 * null = null + Assert.Equal(2 * 1, (double)result[2]!, Tolerance); + } + + // ====================== 9. IReadOnlyCollection * double (Span) ====================== + [Fact] + public void Mul_IReadOnlyCollectionT_Double_Span() + { + Span dest = new Length[2]; + ((IReadOnlyCollection)unitsArray).Mul(scalarDouble, dest); + Assert.Equal(1000 * 2, (double)dest[0], Tolerance); + Assert.Equal(1 * 2, (double)dest[1], Tolerance); + } + + // ====================== 10. IReadOnlyCollection * double (Span) ====================== + [Fact] + public void Mul_IReadOnlyCollectionNullableT_Double_Span() + { + Span dest = new Length?[3]; + ((IReadOnlyCollection)nullableUnitsArray).Mul(scalarDouble, dest); + Assert.Equal(1000 * 2, (double)dest[0]!, Tolerance); + Assert.Null(dest[1]); // null * 2 = null + Assert.Equal(1 * 2, (double)dest[2]!, Tolerance); + } + + // ====================== 11. double * IReadOnlyCollection (Span) ====================== + [Fact] + public void Mul_Double_IReadOnlyCollectionT_Span() + { + Span dest = new Length[2]; + scalarDouble.Mul((IReadOnlyCollection)unitsArray, dest); + Assert.Equal(2 * 1000, (double)dest[0], Tolerance); + Assert.Equal(2 * 1, (double)dest[1], Tolerance); + } + + // ====================== 12. double * IReadOnlyCollection (Span) ====================== + [Fact] + public void Mul_Double_IReadOnlyCollectionNullableT_Span() + { + Span dest = new Length?[3]; + scalarDouble.Mul((IReadOnlyCollection)nullableUnitsArray, dest); + Assert.Equal(2 * 1000, (double)dest[0]!, Tolerance); + Assert.Null(dest[1]); // 2 * null = null + Assert.Equal(2 * 1, (double)dest[2]!, Tolerance); + } + + // ====================== 13. IEnumerable * double ====================== + [Fact] + public void Mul_IEnumerableT_Double_Returns_IEnumerableT() + { + var result = ((IEnumerable)unitsArray).Mul(scalarDouble).ToList(); + Assert.Equal(2, result.Count); + Assert.Equal(1000 * 2, (double)result[0], Tolerance); + Assert.Equal(1 * 2, (double)result[1], Tolerance); + } + + // ====================== 14. IEnumerable * double ====================== + [Fact] + public void Mul_IEnumerableNullableT_Double_Returns_IEnumerableNullableT() + { + var result = ((IEnumerable)nullableUnitsArray).Mul(scalarDouble).ToList(); + Assert.Equal(3, result.Count); + Assert.Equal(1000 * 2, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // null * 2 = null + Assert.Equal(1 * 2, (double)result[2]!, Tolerance); + } + + // ====================== 15. double * IEnumerable ====================== + [Fact] + public void Mul_Double_IEnumerableT_Returns_IEnumerableT() + { + var result = scalarDouble.Mul((IEnumerable)unitsArray).ToList(); + Assert.Equal(2, result.Count); + Assert.Equal(2 * 1000, (double)result[0], Tolerance); + Assert.Equal(2 * 1, (double)result[1], Tolerance); + } + + // ====================== 16. double * IEnumerable ====================== + [Fact] + public void Mul_Double_IEnumerableNullableT_Returns_IEnumerableNullableT() + { + var result = scalarDouble.Mul((IEnumerable)nullableUnitsArray).ToList(); + Assert.Equal(3, result.Count); + Assert.Equal(2 * 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // 2 * null = null + Assert.Equal(2 * 1, (double)result[2]!, Tolerance); + } + + // ====================== 17. double[] * T ====================== + [Fact] + public void Mul_DoubleArray_T_Returns_TArray() + { + var result = doubleArray.Mul(scalarUnit); + Assert.Equal(2, result.Length); + Assert.Equal(5 * 1000, (double)result[0], Tolerance); + Assert.Equal(3 * 1000, (double)result[1], Tolerance); + } + + // ====================== 18. double?[] * T ====================== + [Fact] + public void Mul_NullableDoubleArray_T_Returns_NullableTArray() + { + var result = nullableDoubleArray.Mul(scalarUnit); + Assert.Equal(3, result.Length); + Assert.Equal(5 * 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // null * Length = null + Assert.Equal(3 * 1000, (double)result[2]!, Tolerance); + } + + // ====================== 19. T * double[] ====================== + [Fact] + public void Mul_T_DoubleArray_Returns_TArray() + { + var result = scalarUnit.Mul(doubleArray); + Assert.Equal(2, result.Length); + Assert.Equal(1000 * 5, (double)result[0], Tolerance); + Assert.Equal(1000 * 3, (double)result[1], Tolerance); + } + + // ====================== 20. T * double?[] ====================== + [Fact] + public void Mul_T_NullableDoubleArray_Returns_NullableTArray() + { + var result = scalarUnit.Mul(nullableDoubleArray); + Assert.Equal(3, result.Length); + Assert.Equal(1000 * 5, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // Length * null = null + Assert.Equal(1000 * 3, (double)result[2]!, Tolerance); + } + + // ====================== 21. List * T ====================== + [Fact] + public void Mul_ListDouble_T_Returns_ListT() + { + var result = doubleList.Mul(scalarUnit); + Assert.Equal(2, result.Count); + Assert.Equal(5 * 1000, (double)result[0], Tolerance); + Assert.Equal(3 * 1000, (double)result[1], Tolerance); + } + + // ====================== 22. List * T ====================== + [Fact] + public void Mul_ListNullableDouble_T_Returns_ListNullableT() + { + var result = nullableDoubleList.Mul(scalarUnit); + Assert.Equal(3, result.Count); + Assert.Equal(5 * 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // null * Length = null + Assert.Equal(3 * 1000, (double)result[2]!, Tolerance); + } + + // ====================== 23. T * List ====================== + [Fact] + public void Mul_T_ListDouble_Returns_ListT() + { + var result = scalarUnit.Mul(doubleList); + Assert.Equal(2, result.Count); + Assert.Equal(1000 * 5, (double)result[0], Tolerance); + Assert.Equal(1000 * 3, (double)result[1], Tolerance); + } + + // ====================== 24. T * List ====================== + [Fact] + public void Mul_T_ListNullableDouble_Returns_ListNullableT() + { + var result = scalarUnit.Mul(nullableDoubleList); + Assert.Equal(3, result.Count); + Assert.Equal(1000 * 5, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // Length * null = null + Assert.Equal(1000 * 3, (double)result[2]!, Tolerance); + } + + // ====================== 25. T * T[] -> double[] ====================== + [Fact] + public void Mul_T_TArray_Returns_DoubleArray() + { + var result = scalarUnit * unitsArray; + Assert.Equal(2, result.Length); + Assert.Equal(1000 * 1000, result[0]._Value, Tolerance); + Assert.Equal(1000 * 1, result[1]._Value, Tolerance); + } + + // Дополнительно: перегрузки с результатом double (без R) + [Fact] + public void Mul_TArray_T_Returns_DoubleArray() + { + var result = unitsArray * scalarUnit; + Assert.Equal(2, result.Length); + Assert.Equal(1000 * 1000, result[0]._Value, Tolerance); + Assert.Equal(1 * 1000, result[1]._Value, Tolerance); + } + + [Fact] + public void Mul_ListT_T_Returns_DoubleList() + { + var result = unitsList * scalarUnit; + Assert.Equal(2, result.Count); + Assert.Equal(1000 * 1000, result[0]._Value, Tolerance); + Assert.Equal(1 * 1000, result[1]._Value, Tolerance); + } + + // ====================== Обработка null коллекций ====================== + [Fact] + public void Mul_NullArray_ReturnsNull() + { + Length[] nullArray = null!; + var result = nullArray.Mul(5.0); + Assert.Null(result); + } + + [Fact] + public void Mul_NullList_ReturnsNull() + { + List nullList = null!; + var result = nullList.Mul(5.0); + Assert.Null(result); + } + + [Fact] + public void Mul_EmptyArray_ReturnsEmptyArray() + { + var empty = Array.Empty(); + var result = empty.Mul(5.0); + Assert.Empty(result); + } + } +} \ No newline at end of file diff --git a/QWERTYkez.Mensura.Tests/CollectionsPlusExtensions.cs b/QWERTYkez.Mensura.Tests/CollectionsPlusExtensions.cs new file mode 100644 index 0000000..845e634 --- /dev/null +++ b/QWERTYkez.Mensura.Tests/CollectionsPlusExtensions.cs @@ -0,0 +1,334 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using QWERTYkez.Mensura.Units; +using QWERTYkez.Mensura.Extensions; +using Xunit; + +namespace QWERTYkez.Mensura.Tests +{ + public class CollectionsPlusExtensionsTests + { + private const double Tolerance = 1e-12; + private static readonly Length scalarUnit = Length.Meter; // 1000 mm + private static readonly double scalarDouble = 500.0; // прибавляемое значение в мм + + // Коллекции единиц + private static readonly Length[] unitsArray = new[] { Length.Meter, Length._MilliMeter }; + private static readonly Length?[] nullableUnitsArray = new Length?[] { Length.Meter, null, Length._MilliMeter }; + private static readonly List unitsList = new List { Length.Meter, Length._MilliMeter }; + private static readonly List nullableUnitsList = new List { Length.Meter, null, Length._MilliMeter }; + + // Коллекции double + private static readonly double[] doubleArray = new double[] { 200.0, 300.0 }; + private static readonly double?[] nullableDoubleArray = new double?[] { 200.0, null, 300.0 }; + private static readonly List doubleList = new List { 200.0, 300.0 }; + private static readonly List nullableDoubleList = new List { 200.0, null, 300.0 }; + + // ====================== 1. T[] + double ====================== + [Fact] + public void Plus_TArray_Double_Returns_TArray() + { + var result = unitsArray.Plus(scalarDouble); + Assert.Equal(2, result.Length); + Assert.Equal(1000 + 500, (double)result[0], Tolerance); + Assert.Equal(1 + 500, (double)result[1], Tolerance); + } + + // ====================== 2. T?[] + double ====================== + [Fact] + public void Plus_NullableTArray_Double_Returns_NullableTArray() + { + var result = nullableUnitsArray.Plus(scalarDouble); + Assert.Equal(3, result.Length); + Assert.Equal(1000 + 500, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // null + число = null + Assert.Equal(1 + 500, (double)result[2]!, Tolerance); + } + + // ====================== 3. double + T[] ====================== + [Fact] + public void Plus_Double_TArray_Returns_TArray() + { + var result = scalarDouble.Plus(unitsArray); + Assert.Equal(2, result.Length); + Assert.Equal(500 + 1000, (double)result[0], Tolerance); + Assert.Equal(500 + 1, (double)result[1], Tolerance); + } + + // ====================== 4. double + T?[] ====================== + [Fact] + public void Plus_Double_NullableTArray_Returns_NullableTArray() + { + var result = scalarDouble.Plus(nullableUnitsArray); + Assert.Equal(3, result.Length); + Assert.Equal(500 + 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // число + null = null + Assert.Equal(500 + 1, (double)result[2]!, Tolerance); + } + + // ====================== 5. List + double ====================== + [Fact] + public void Plus_ListT_Double_Returns_ListT() + { + var result = unitsList.Plus(scalarDouble); + Assert.Equal(2, result.Count); + Assert.Equal(1000 + 500, (double)result[0], Tolerance); + Assert.Equal(1 + 500, (double)result[1], Tolerance); + } + + // ====================== 6. List + double ====================== + [Fact] + public void Plus_ListNullableT_Double_Returns_ListNullableT() + { + var result = nullableUnitsList.Plus(scalarDouble); + Assert.Equal(3, result.Count); + Assert.Equal(1000 + 500, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // null + число = null + Assert.Equal(1 + 500, (double)result[2]!, Tolerance); + } + + // ====================== 7. double + List ====================== + [Fact] + public void Plus_Double_ListT_Returns_ListT() + { + var result = scalarDouble.Plus(unitsList); + Assert.Equal(2, result.Count); + Assert.Equal(500 + 1000, (double)result[0], Tolerance); + Assert.Equal(500 + 1, (double)result[1], Tolerance); + } + + // ====================== 8. double + List ====================== + [Fact] + public void Plus_Double_ListNullableT_Returns_ListNullableT() + { + var result = scalarDouble.Plus(nullableUnitsList); + Assert.Equal(3, result.Count); + Assert.Equal(500 + 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // число + null = null + Assert.Equal(500 + 1, (double)result[2]!, Tolerance); + } + + // ====================== 9. IReadOnlyCollection + double (Span) ====================== + [Fact] + public void Plus_IReadOnlyCollectionT_Double_Span() + { + Span dest = new Length[2]; + ((IReadOnlyCollection)unitsArray).Plus(scalarDouble, dest); + Assert.Equal(1000 + 500, (double)dest[0], Tolerance); + Assert.Equal(1 + 500, (double)dest[1], Tolerance); + } + + // ====================== 10. IReadOnlyCollection + double (Span) ====================== + [Fact] + public void Plus_IReadOnlyCollectionNullableT_Double_Span() + { + Span dest = new Length?[3]; + ((IReadOnlyCollection)nullableUnitsArray).Plus(scalarDouble, dest); + Assert.Equal(1000 + 500, (double)dest[0]!, Tolerance); + Assert.Null(dest[1]); // null + число = null + Assert.Equal(1 + 500, (double)dest[2]!, Tolerance); + } + + // ====================== 11. double + IReadOnlyCollection (Span) ====================== + [Fact] + public void Plus_Double_IReadOnlyCollectionT_Span() + { + Span dest = new Length[2]; + scalarDouble.Plus((IReadOnlyCollection)unitsArray, dest); + Assert.Equal(500 + 1000, (double)dest[0], Tolerance); + Assert.Equal(500 + 1, (double)dest[1], Tolerance); + } + + // ====================== 12. double + IReadOnlyCollection (Span) ====================== + [Fact] + public void Plus_Double_IReadOnlyCollectionNullableT_Span() + { + Span dest = new Length?[3]; + scalarDouble.Plus((IReadOnlyCollection)nullableUnitsArray, dest); + Assert.Equal(500 + 1000, (double)dest[0]!, Tolerance); + Assert.Null(dest[1]); // число + null = null + Assert.Equal(500 + 1, (double)dest[2]!, Tolerance); + } + + // ====================== 13. IEnumerable + double ====================== + [Fact] + public void Plus_IEnumerableT_Double_Returns_IEnumerableT() + { + var result = ((IEnumerable)unitsArray).Plus(scalarDouble).ToList(); + Assert.Equal(2, result.Count); + Assert.Equal(1000 + 500, (double)result[0], Tolerance); + Assert.Equal(1 + 500, (double)result[1], Tolerance); + } + + // ====================== 14. IEnumerable + double ====================== + [Fact] + public void Plus_IEnumerableNullableT_Double_Returns_IEnumerableNullableT() + { + var result = ((IEnumerable)nullableUnitsArray).Plus(scalarDouble).ToList(); + Assert.Equal(3, result.Count); + Assert.Equal(1000 + 500, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // null + число = null + Assert.Equal(1 + 500, (double)result[2]!, Tolerance); + } + + // ====================== 15. double + IEnumerable ====================== + [Fact] + public void Plus_Double_IEnumerableT_Returns_IEnumerableT() + { + var result = scalarDouble.Plus((IEnumerable)unitsArray).ToList(); + Assert.Equal(2, result.Count); + Assert.Equal(500 + 1000, (double)result[0], Tolerance); + Assert.Equal(500 + 1, (double)result[1], Tolerance); + } + + // ====================== 16. double + IEnumerable ====================== + [Fact] + public void Plus_Double_IEnumerableNullableT_Returns_IEnumerableNullableT() + { + var result = scalarDouble.Plus((IEnumerable)nullableUnitsArray).ToList(); + Assert.Equal(3, result.Count); + Assert.Equal(500 + 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // число + null = null + Assert.Equal(500 + 1, (double)result[2]!, Tolerance); + } + + // ====================== 17. double[] + T ====================== + [Fact] + public void Plus_DoubleArray_T_Returns_TArray() + { + var result = doubleArray.Plus(scalarUnit); + Assert.Equal(2, result.Length); + Assert.Equal(200 + 1000, (double)result[0], Tolerance); + Assert.Equal(300 + 1000, (double)result[1], Tolerance); + } + + // ====================== 18. double?[] + T ====================== + [Fact] + public void Plus_NullableDoubleArray_T_Returns_NullableTArray() + { + var result = nullableDoubleArray.Plus(scalarUnit); + Assert.Equal(3, result.Length); + Assert.Equal(200 + 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // null + Length = null + Assert.Equal(300 + 1000, (double)result[2]!, Tolerance); + } + + // ====================== 19. T + double[] ====================== + [Fact] + public void Plus_T_DoubleArray_Returns_TArray() + { + var result = scalarUnit.Plus(doubleArray); + Assert.Equal(2, result.Length); + Assert.Equal(1000 + 200, (double)result[0], Tolerance); + Assert.Equal(1000 + 300, (double)result[1], Tolerance); + } + + // ====================== 20. T + double?[] ====================== + [Fact] + public void Plus_T_NullableDoubleArray_Returns_NullableTArray() + { + var result = scalarUnit.Plus(nullableDoubleArray); + Assert.Equal(3, result.Length); + Assert.Equal(1000 + 200, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // Length + null = null + Assert.Equal(1000 + 300, (double)result[2]!, Tolerance); + } + + // ====================== 21. List + T ====================== + [Fact] + public void Plus_ListDouble_T_Returns_ListT() + { + var result = doubleList.Plus(scalarUnit); + Assert.Equal(2, result.Count); + Assert.Equal(200 + 1000, (double)result[0], Tolerance); + Assert.Equal(300 + 1000, (double)result[1], Tolerance); + } + + // ====================== 22. List + T ====================== + [Fact] + public void Plus_ListNullableDouble_T_Returns_ListNullableT() + { + var result = nullableDoubleList.Plus(scalarUnit); + Assert.Equal(3, result.Count); + Assert.Equal(200 + 1000, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // null + Length = null + Assert.Equal(300 + 1000, (double)result[2]!, Tolerance); + } + + // ====================== 23. T + List ====================== + [Fact] + public void Plus_T_ListDouble_Returns_ListT() + { + var result = scalarUnit.Plus(doubleList); + Assert.Equal(2, result.Count); + Assert.Equal(1000 + 200, (double)result[0], Tolerance); + Assert.Equal(1000 + 300, (double)result[1], Tolerance); + } + + // ====================== 24. T + List ====================== + [Fact] + public void Plus_T_ListNullableDouble_Returns_ListNullableT() + { + var result = scalarUnit.Plus(nullableDoubleList); + Assert.Equal(3, result.Count); + Assert.Equal(1000 + 200, (double)result[0]!, Tolerance); + Assert.Null(result[1]); // Length + null = null + Assert.Equal(1000 + 300, (double)result[2]!, Tolerance); + } + + // ====================== 25. T + T[] -> double[] ====================== + [Fact] + public void Plus_T_TArray_Returns_DoubleArray() + { + var result = scalarUnit + unitsArray; + Assert.Equal(2, result.Length); + Assert.Equal(1000 + 1000, result[0]._Value, Tolerance); + Assert.Equal(1000 + 1, result[1]._Value, Tolerance); + } + + // Дополнительно: перегрузки с результатом double (без R) + [Fact] + public void Plus_TArray_T_Returns_DoubleArray() + { + var result = unitsArray + scalarUnit; + Assert.Equal(2, result.Length); + Assert.Equal(1000 + 1000, result[0]._Value, Tolerance); + Assert.Equal(1 + 1000, result[1]._Value, Tolerance); + } + + [Fact] + public void Plus_ListT_T_Returns_DoubleList() + { + var result = unitsList + scalarUnit; + Assert.Equal(2, result.Count); + Assert.Equal(1000 + 1000, result[0]._Value, Tolerance); + Assert.Equal(1 + 1000, result[1]._Value, Tolerance); + } + + // ====================== Обработка null коллекций ====================== + [Fact] + public void Plus_NullArray_ReturnsNull() + { + Length[] nullArray = null; + var result = nullArray.Plus(5.0); + Assert.Null(result); + } + + [Fact] + public void Plus_NullList_ReturnsNull() + { + List nullList = null; + var result = nullList.Plus(5.0); + Assert.Null(result); + } + + [Fact] + public void Plus_EmptyArray_ReturnsEmptyArray() + { + var empty = Array.Empty(); + var result = empty.Plus(5.0); + Assert.Empty(result); + } + } +} \ No newline at end of file diff --git a/QWERTYkez.Mensura.Tests/CollectionsPow2Extensions.cs b/QWERTYkez.Mensura.Tests/CollectionsPow2Extensions.cs new file mode 100644 index 0000000..80c8715 --- /dev/null +++ b/QWERTYkez.Mensura.Tests/CollectionsPow2Extensions.cs @@ -0,0 +1,73 @@ +namespace QWERTYkez.Mensura.Tests; + +public class CollectionsPow2Extensions +{ + [Fact] + public void Pow2_Array_CalculatesCorrectly() + { + // Arrange + Length[] source = [new(2), new(3), new(10)]; + + // Act + Length[] result = source.Pow2(); + + // Assert + Assert.Equal(4, result[0]._Value); + Assert.Equal(9, result[1]._Value); + Assert.Equal(100, result[2]._Value); + } + + [Fact] + public void Pow2_NullableArray_HandlesNulls() + { + // Arrange + Length?[] source = [new(5), null, new(4)]; + + // Act + Length?[] result = source.Pow2(); + + // Assert + Assert.Equal(25, result[0]?._Value); + Assert.Null(result[1]); + Assert.Equal(16, result[2]?._Value); + } + + [Fact] + public void Pow2_List_ReturnsCorrectResult() + { + // Arrange + var source = new List { new(2), new(8) }; + + // Act + var result = source.Pow2(); + + // Assert + Assert.Equal(4, result[0]._Value); + Assert.Equal(64, result[1]._Value); + } + + [Fact] + public void Pow2_IEnumerable_ProcessesCorrectly() + { + // Arrange + IEnumerable source = new HashSet { new(3), new(7) }; + + // Act + var result = source.Pow2().ToList(); + + // Assert + Assert.Contains(result, x => x._Value == 9); + Assert.Contains(result, x => x._Value == 49); + } + + [Fact] + public void Pow2_DestinationTooShort_ThrowsArgumentException() + { + // Arrange + Length[] source = [new(2), new(3)]; + Length[] dest = new Length[1]; + + // Act & Assert + Assert.Throws(() => source.Pow2(dest)); + } +} \ No newline at end of file diff --git a/QWERTYkez.Mensura.Tests/CollectionsPow3Extensions.cs b/QWERTYkez.Mensura.Tests/CollectionsPow3Extensions.cs new file mode 100644 index 0000000..ebdfa8c --- /dev/null +++ b/QWERTYkez.Mensura.Tests/CollectionsPow3Extensions.cs @@ -0,0 +1,59 @@ +namespace QWERTYkez.Mensura.Tests; + +public class Pow3ExtensionsTests +{ + [Fact] + public void Pow3_Array_CalculatesCorrectly() + { + // Arrange: 2^3=8, 3^3=27, 4^3=64 + Length[] source = [new(2), new(3), new(4)]; + + // Act + Length[] result = source.Pow3(); + + // Assert + Assert.Equal(8, result[0]._Value); + Assert.Equal(27, result[1]._Value); + Assert.Equal(64, result[2]._Value); + } + + [Fact] + public void Pow3_NullableArray_HandlesNulls() + { + // Arrange + Length?[] source = [new(5), null, new(10)]; + + // Act + Length?[] result = source.Pow3(); + + // Assert + Assert.Equal(125, result[0]?._Value); + Assert.Null(result[1]); + Assert.Equal(1000, result[2]?._Value); + } + + [Fact] + public void Pow3_List_ReturnsCorrectResult() + { + // Arrange + var source = new List { new(2), new(5) }; + + // Act + var result = source.Pow3(); + + // Assert + Assert.Equal(8, result[0]._Value); + Assert.Equal(125, result[1]._Value); + } + + [Fact] + public void Pow3_DestinationTooShort_ThrowsArgumentException() + { + // Arrange + Length[] source = [new(2), new(3)]; + Length[] dest = new Length[1]; + + // Act & Assert + Assert.Throws(() => source.Pow3(dest)); + } +} \ No newline at end of file diff --git a/QWERTYkez.Mensura.Tests/CollectionsPowNExtensions.cs b/QWERTYkez.Mensura.Tests/CollectionsPowNExtensions.cs new file mode 100644 index 0000000..cccc304 --- /dev/null +++ b/QWERTYkez.Mensura.Tests/CollectionsPowNExtensions.cs @@ -0,0 +1,75 @@ +namespace QWERTYkez.Mensura.Tests; + +public class CollectionsPowNExtensions +{ + private const double BaseVal = 3.0; + private const double Expected = 9.0; // 3^2 = 9 + + [Fact] + public void Test_PowN() + { + Length[] arr = [new(BaseVal)]; + Length?[] arrNull = [new(BaseVal), null]; + List list = [new(BaseVal)]; + List listNull = [new(BaseVal), null]; + IReadOnlyCollection roc = list; + IEnumerable en = list; + IEnumerable enNull = listNull; + + // --- 1. Целые степени (int) --- + // Span-based Core + Span dstSpan = new Length[1]; + arr.AsSpan().PowCore(2, 1, dstSpan); + Assert.Equal(Expected, dstSpan[0]._Value); + + arrNull.AsSpan().PowCore(2, 2, new Length?[2]); // Проверка nullable span + + arr.AsSpan().Pow(2, dstSpan); + Assert.Equal(Expected, dstSpan[0]._Value); + + // Arrays + Assert.Equal(Expected, arr.Pow(2)[0]._Value); + Assert.Equal(Expected, arrNull.Pow(2)[0]?._Value); + + // Lists + Assert.Equal(Expected, list.Pow(2)[0]._Value); + Assert.Equal(Expected, listNull.Pow(2)[0]?._Value); + + // ReadOnlyCollection + roc.Pow(2, dstSpan); + Assert.Equal(Expected, dstSpan[0]._Value); + + // IEnumerable / Iterators + Assert.Equal(Expected, en.Pow(2).First()._Value); + Assert.Equal(Expected, enNull.Pow(2).First(x => x.HasValue)?._Value); + + + // --- 2. Дробные степени (double) --- + // Span-based Core + arr.AsSpan().PowCore(2.0, 1, dstSpan); + Assert.Equal(Expected, dstSpan[0]._Value); + + arr.AsSpan().Pow(2.0, dstSpan); + Assert.Equal(Expected, dstSpan[0]._Value); + + // Arrays + Assert.Equal(Expected, arr.Pow(2.0)[0]._Value); + Assert.Equal(Expected, arrNull.Pow(2.0)[0]?._Value); + + // Lists + Assert.Equal(Expected, list.Pow(2.0)[0]._Value); + Assert.Equal(Expected, listNull.Pow(2.0)[0]?._Value); + + // ReadOnlyCollection + roc.Pow(2.0, dstSpan); + Assert.Equal(Expected, dstSpan[0]._Value); + + // IEnumerable / Iterators + Assert.Equal(Expected, en.Pow(2.0).First()._Value); + Assert.Equal(Expected, enNull.Pow(2.0).First(x => x.HasValue)?._Value); + + // Дополнительные итераторы + Assert.Equal(Expected, en.PowIterator(2.0).First()._Value); + Assert.Equal(Expected, enNull.PowNullableIterator(2.0).First(x => x.HasValue)?._Value); + } +} \ No newline at end of file diff --git a/QWERTYkez.Mensura.Tests/CollectionsRootOfCubeExtensions.cs b/QWERTYkez.Mensura.Tests/CollectionsRootOfCubeExtensions.cs new file mode 100644 index 0000000..f03a73e --- /dev/null +++ b/QWERTYkez.Mensura.Tests/CollectionsRootOfCubeExtensions.cs @@ -0,0 +1,59 @@ +namespace QWERTYkez.Mensura.Tests; + +public class CollectionsRootOfCubeExtensions +{ + [Fact] + public void Cbrt_Array_CalculatesCorrectly() + { + Length[] source = [new(4), new(9), new(16), new(25)]; + // Ожидаем корень, но важно: Math.Sqrt(4) = 2. + // Если ваш код делает специфичные преобразования, адаптируйте Assert. + var result = source.Cbrt(); + + Assert.Equal(2, result[0]._Value); + Assert.Equal(3, result[1]._Value); + Assert.Equal(4, result[2]._Value); + Assert.Equal(5, result[3]._Value); + } + + [Fact] + public void Cbrt_NullableArray_HandlesNulls() + { + Length?[] source = [new(16), null, new(36)]; + var result = source.Cbrt(); + + Assert.Equal(4, result[0]?._Value); + Assert.Null(result[1]); + Assert.Equal(6, result[2]?._Value); + } + + [Fact] + public void Cbrt_DestinationTooShort_ThrowsArgumentException() + { + Length[] source = [new(1), new(4)]; + Length[] dest = new Length[1]; + + Assert.Throws(() => source.Cbrt(dest)); + } + + [Fact] + public void Cbrt_List_WorksCorrectly() + { + var list = new List { new(1), new(4) }; + var result = list.Cbrt(); + + Assert.Equal(2, result.Count); + Assert.Equal(1, result[0]._Value); + Assert.Equal(2, result[1]._Value); + } + + [Fact] + public void Cbrt_IEnumerable_NoExtraAllocations() + { + IEnumerable source = new HashSet { new(9), new(81) }; + var result = source.Cbrt().ToList(); + + Assert.Contains(result, x => x._Value == 3); + Assert.Contains(result, x => x._Value == 9); + } +} \ No newline at end of file diff --git a/QWERTYkez.Mensura.Tests/CollectionsRootOfSquareExtensions.cs b/QWERTYkez.Mensura.Tests/CollectionsRootOfSquareExtensions.cs new file mode 100644 index 0000000..2d91013 --- /dev/null +++ b/QWERTYkez.Mensura.Tests/CollectionsRootOfSquareExtensions.cs @@ -0,0 +1,75 @@ +namespace QWERTYkez.Mensura.Tests; + +public class CollectionsRootOfSquareExtensions +{ + [Fact] + public void Sqrt_Array_ShouldCalculateCorrectly() + { + // Arrange + Length[] source = [new(4), new(9), new(16)]; + + // Act + Length[] result = source.Sqrt(); + + // Assert + Assert.Equal(2, result[0]._Value); + Assert.Equal(3, result[1]._Value); + Assert.Equal(4, result[2]._Value); + } + + [Fact] + public void Sqrt_NullableArray_ShouldHandleNulls() + { + // Arrange + Length?[] source = [new(25), null, new(100)]; + + // Act + Length?[] result = source.Sqrt(); + + // Assert + Assert.Equal(5, result[0]?._Value); + Assert.Null(result[1]); + Assert.Equal(10, result[2]?._Value); + } + + [Fact] + public void Sqrt_List_ShouldReturnCorrectList() + { + // Arrange + var source = new List { new(1), new(4), new(9) }; + + // Act + var result = source.Sqrt(); + + // Assert + Assert.Equal(3, result.Count); + Assert.Equal(1, result[0]._Value); + Assert.Equal(2, result[1]._Value); + Assert.Equal(3, result[2]._Value); + } + + [Fact] + public void Sqrt_DestinationTooShort_ShouldThrowArgumentException() + { + // Arrange + Length[] source = [new(4), new(9)]; + Length[] dest = new Length[1]; // Слишком мало + + // Act & Assert + Assert.Throws(() => source.AsSpan().Sqrt(dest.AsSpan())); + } + + [Fact] + public void Sqrt_IEnumerable_ShouldWorkWithGenericCollection() + { + // Arrange + IEnumerable source = new HashSet { new(16), new(64) }; + + // Act + var result = source.Sqrt().ToList(); + + // Assert + Assert.Contains(result, x => x._Value == 4); + Assert.Contains(result, x => x._Value == 8); + } +} \ No newline at end of file diff --git a/QWERTYkez.Mensura.Tests/DoubleExtensions.cs b/QWERTYkez.Mensura.Tests/DoubleExtensions.cs new file mode 100644 index 0000000..61abf51 --- /dev/null +++ b/QWERTYkez.Mensura.Tests/DoubleExtensions.cs @@ -0,0 +1,164 @@ +namespace QWERTYkez.Mensura.Tests; + +public class DoubleExtensions +{ + #region 1. Тесты скалярных типов (Обычные, Экзотические и Nullable) + + [Fact] + public void ToDouble_Should_Convert_ExoticTypes_Without_InvalidCastException() + { + // Проверяем типы, которые раньше могли падать в рантайме из-за Convert.ToDouble(object) + Half halfValue = (Half)3.14f; + Int128 int128Value = Int128.Parse("1234567890123456789012345"); + UInt128 uInt128Value = UInt128.Parse("9876543210987654321098765"); + nint nintValue = 42; + + // Act & Assert + Assert.Equal(3.14, halfValue.ToDouble(), 2); + Assert.Equal((double)int128Value, int128Value.ToDouble()); + Assert.Equal((double)uInt128Value, uInt128Value.ToDouble()); + Assert.Equal(42.0, nintValue.ToDouble()); + } + + [Theory] + [InlineData((int)100, 100.0)] + [InlineData((byte)5, 5.0)] + [InlineData((float)1.5f, 1.5)] + public void ToDouble_StandardScalars_ShouldConvertCorrectly(object input, double expected) + { + double result = input switch + { + int i => i.ToDouble(), + byte b => b.ToDouble(), + float f => f.ToDouble(), + _ => throw new ArgumentException("Unsupported type in test") + }; + + Assert.Equal(expected, result); + } + + [Fact] + public void ToDouble_NullableScalars_Should_Return_Zero_When_Null() + { + // Arrange + int? nullInt = null; + Half? nullHalf = null; + Int128? nullInt128 = null; + + int? validInt = 10; + Half? validHalf = (Half)2.5f; + + // Act & Assert + Assert.Equal(0d, nullInt.ToDouble()); + Assert.Equal(0d, nullHalf.ToDouble()); + Assert.Equal(0d, nullInt128.ToDouble()); + + Assert.Equal(10d, validInt.ToDouble()); + Assert.Equal(2.5d, validHalf.ToDouble(), 1); + } + #endregion + + #region 2. Тесты SIMD и оптимизаций коллекций (Различные длины массивов) + + [Theory] + [InlineData(0)] // Пустой массив + [InlineData(1)] // 1 элемент (чисто скалярный fallback) + [InlineData(7)] // Нечетное число элементов + [InlineData(16)] // Кратный размер (размер Vector128/Vector256) + [InlineData(35)] // Большой массив с остатком для скалярного хвоста + public void ToDouble_ArrayAndList_Should_Correctly_Map_Via_SIMD_Or_Fallback(int count) + { + // Arrange + float[] sourceArray = [.. Enumerable.Range(1, count).Select(x => x * 1.5f)]; + List sourceList = [.. sourceArray]; + + double[] destFromArray = new double[count]; + double[] destFromList = new double[count]; + + // Act + // Явное приведение к IReadOnlyCollection устраняет ошибку CS0121 (неоднозначность вызова) + ((IReadOnlyCollection)sourceArray).ToDouble(destFromArray); + ((IReadOnlyCollection)sourceList).ToDouble(destFromList); + + // Assert + for (int i = 0; i < count; i++) + { + double expected = sourceArray[i]; + Assert.Equal(expected, destFromArray[i]); + Assert.Equal(expected, destFromList[i]); + } + } + #endregion + + #region 3. Тесты Nullable-коллекций (Проверка на null-элементы внутри) + + [Fact] + public void ToDouble_Nullable_Collections_Should_Keep_Nulls_In_Destination() + { + // Arrange + UInt128?[] sourceArray = [10, null, 20, null, 30]; + double?[] destination = new double?[sourceArray.Length]; + + // Act + ((IReadOnlyCollection)sourceArray).ToDouble(destination); + + // Assert + Assert.Equal(10d, destination[0]); + Assert.Null(destination[1]); + Assert.Equal(20d, destination[2]); + Assert.Null(destination[3]); + Assert.Equal(30d, destination[4]); + } + #endregion + + #region 4. Тесты LINQ / Отложенного выполнения (IEnumerable) + + [Fact] + public void ToDouble_IEnumerable_Extension_Should_Handle_Execution_Types_Correctly() + { + // Arrange + int[] array = [1, 2, 3]; + List list = [4, 5, 6]; + IEnumerable genericEnum = Enumerable.Range(7, 3); + + // Act + var resFromArray = array.ToDouble(); // Быстрый бранч для массива + var resFromList = list.ToDouble(); // Быстрый бранч для списка + var resFromEnum = genericEnum.ToDouble(); // Медленный итератор по IEnumerable + + // Assert + Assert.Equal([1d, 2d, 3d], resFromArray); + Assert.Equal([4d, 5d, 6d], resFromList); + Assert.Equal([7d, 8d, 9d], resFromEnum); + } + #endregion + + #region 5. Тесты безопасности и валидации аргументов + + [Fact] + public void ToDouble_Should_Throw_ArgumentException_When_Destination_Is_Too_Short() + { + // Arrange + int[] source = [1, 2, 3, 4, 5]; + double[] destinationTooShort = new double[4]; // Нужен размер >= 5 + + // Act & Assert + Assert.Throws(() => ((IReadOnlyCollection)source).ToDouble(destinationTooShort)); + } + + [Fact] + public void ToDouble_Should_Do_Nothing_And_Return_When_Collection_Is_Empty_Or_Null() + { + // Arrange + int[]? nullArray = null; + int[] emptyArray = []; + double[] destination = new double[5]; + + // Act & Assert (Не должно выбрасывать NullReferenceException или ArgumentException) + ((IReadOnlyCollection?)nullArray)!.ToDouble(destination); + ((IReadOnlyCollection)emptyArray).ToDouble(destination); + + Assert.All(destination, x => Assert.Equal(0d, x)); // Назначение осталось нетронутым (все нули по умолчанию) + } + #endregion +} \ No newline at end of file diff --git a/QWERTYkez.Mensura.Tests/QWERTYkez.Mensura.Tests.csproj b/QWERTYkez.Mensura.Tests/QWERTYkez.Mensura.Tests.csproj index dd33cbf..ed87a95 100644 --- a/QWERTYkez.Mensura.Tests/QWERTYkez.Mensura.Tests.csproj +++ b/QWERTYkez.Mensura.Tests/QWERTYkez.Mensura.Tests.csproj @@ -7,6 +7,14 @@ false + + 1701;1702;IDE0221 + + + + 1701;1702;IDE0221 + + all @@ -23,6 +31,8 @@ + + diff --git a/QWERTYkez.Mensura.Tests/globals.cs b/QWERTYkez.Mensura.Tests/globals.cs new file mode 100644 index 0000000..c9cdcf8 --- /dev/null +++ b/QWERTYkez.Mensura.Tests/globals.cs @@ -0,0 +1,2 @@ +global using QWERTYkez.Mensura.Extensions; +global using QWERTYkez.Mensura.Units; \ No newline at end of file diff --git a/QWERTYkez.Mensura/Extensions/AggregateUnitExtensions.cs b/QWERTYkez.Mensura/Extensions/AggregateUnitExtensions.cs index 2a68057..8ecd538 100644 --- a/QWERTYkez.Mensura/Extensions/AggregateUnitExtensions.cs +++ b/QWERTYkez.Mensura/Extensions/AggregateUnitExtensions.cs @@ -296,80 +296,6 @@ internal static partial class AggregateUnitExtensions return CollectionsMarshal.AsSpan(list).Min(); } - // === ICollection === - internal static T Sum(this ICollection collection) - where T : struct, IMensuraUnit, IEquatable - { - if (collection == null || collection.Count == 0) return default; - if (collection is T[] array) return array.Sum(); - if (collection is List list) return list.Sum(); - - T[] sharedArray = ArrayPool.Shared.Rent(collection.Count); - try - { - collection.CopyTo(sharedArray, 0); // Встроенный CopyTo работает быстрее, чем ручной foreach - return new ReadOnlySpan(sharedArray, 0, collection.Count).Sum(); - } - finally - { - ArrayPool.Shared.Return(sharedArray); - } - } - internal static T Avg(this ICollection collection) - where T : struct, IMensuraUnit, IEquatable - { - if (collection == null || collection.Count == 0) return double.NaN.ToUnit(); - if (collection is T[] array) return array.Avg(); - if (collection is List list) return list.Avg(); - - T[] sharedArray = ArrayPool.Shared.Rent(collection.Count); - try - { - collection.CopyTo(sharedArray, 0); - return new ReadOnlySpan(sharedArray, 0, collection.Count).Avg(); - } - finally - { - ArrayPool.Shared.Return(sharedArray); - } - } - internal static T Max(this ICollection collection) - where T : struct, IMensuraUnit, IEquatable - { - if (collection == null || collection.Count == 0) return double.MinValue.ToUnit(); - if (collection is T[] array) return array.Max(); - if (collection is List list) return list.Max(); - - T[] sharedArray = ArrayPool.Shared.Rent(collection.Count); - try - { - collection.CopyTo(sharedArray, 0); - return new ReadOnlySpan(sharedArray, 0, collection.Count).Max(); - } - finally - { - ArrayPool.Shared.Return(sharedArray); - } - } - internal static T Min(this ICollection collection) - where T : struct, IMensuraUnit, IEquatable - { - if (collection == null || collection.Count == 0) return double.MaxValue.ToUnit(); - if (collection is T[] array) return array.Min(); - if (collection is List list) return list.Min(); - - T[] sharedArray = ArrayPool.Shared.Rent(collection.Count); - try - { - collection.CopyTo(sharedArray, 0); - return new ReadOnlySpan(sharedArray, 0, collection.Count).Min(); - } - finally - { - ArrayPool.Shared.Return(sharedArray); - } - } - // === IReadOnlyCollection === internal static T Sum(this IReadOnlyCollection collection) where T : struct, IMensuraUnit, IEquatable @@ -446,7 +372,6 @@ internal static partial class AggregateUnitExtensions // Быстрый SIMD-путь для готовых коллекций (0 аллокаций) if (collection is T[] array) return array.Sum(); if (collection is List list) return list.Sum(); - if (collection is ICollection col) return col.Sum(); if (collection is IReadOnlyCollection roc) return roc.Sum(); // Медленный путь для yield return: считаем на лету без буферов @@ -468,7 +393,6 @@ internal static partial class AggregateUnitExtensions if (collection is T[] array) return array.Avg(); if (collection is List list) return list.Avg(); - if (collection is ICollection col) return col.Avg(); if (collection is IReadOnlyCollection roc) return roc.Avg(); double sum = 0; @@ -492,7 +416,6 @@ internal static partial class AggregateUnitExtensions if (collection is T[] array) return array.Max(); if (collection is List list) return list.Max(); - if (collection is ICollection col) return col.Max(); if (collection is IReadOnlyCollection roc) return roc.Max(); double max = double.MinValue; @@ -514,7 +437,6 @@ internal static partial class AggregateUnitExtensions if (collection is T[] array) return array.Min(); if (collection is List list) return list.Min(); - if (collection is ICollection col) return col.Min(); if (collection is IReadOnlyCollection roc) return roc.Min(); double min = double.MaxValue; @@ -708,80 +630,6 @@ internal static partial class AggregateUnitExtensions return CollectionsMarshal.AsSpan(list).Min(); } - // === ICollection === - internal static T Sum(this ICollection collection) - where T : struct, IMensuraUnit, IEquatable - { - if (collection == null || collection.Count == 0) return default; - if (collection is T?[] array) return array.Sum(); - if (collection is List list) return list.Sum(); - - T?[] sharedArray = ArrayPool.Shared.Rent(collection.Count); - try - { - collection.CopyTo(sharedArray, 0); - return new ReadOnlySpan(sharedArray, 0, collection.Count).Sum(); - } - finally - { - ArrayPool.Shared.Return(sharedArray); - } - } - internal static T Avg(this ICollection collection) - where T : struct, IMensuraUnit, IEquatable - { - if (collection == null || collection.Count == 0) return double.NaN.ToUnit(); - if (collection is T?[] array) return array.Avg(); - if (collection is List list) return list.Avg(); - - T?[] sharedArray = ArrayPool.Shared.Rent(collection.Count); - try - { - collection.CopyTo(sharedArray, 0); - return new ReadOnlySpan(sharedArray, 0, collection.Count).Avg(); - } - finally - { - ArrayPool.Shared.Return(sharedArray); - } - } - internal static T Max(this ICollection collection) - where T : struct, IMensuraUnit, IEquatable - { - if (collection == null || collection.Count == 0) return double.MinValue.ToUnit(); - if (collection is T?[] array) return array.Max(); - if (collection is List list) return list.Max(); - - T?[] sharedArray = ArrayPool.Shared.Rent(collection.Count); - try - { - collection.CopyTo(sharedArray, 0); - return new ReadOnlySpan(sharedArray, 0, collection.Count).Max(); - } - finally - { - ArrayPool.Shared.Return(sharedArray); - } - } - internal static T Min(this ICollection collection) - where T : struct, IMensuraUnit, IEquatable - { - if (collection == null || collection.Count == 0) return double.MaxValue.ToUnit(); - if (collection is T?[] array) return array.Min(); - if (collection is List list) return list.Min(); - - T?[] sharedArray = ArrayPool.Shared.Rent(collection.Count); - try - { - collection.CopyTo(sharedArray, 0); - return new ReadOnlySpan(sharedArray, 0, collection.Count).Min(); - } - finally - { - ArrayPool.Shared.Return(sharedArray); - } - } - // === IReadOnlyCollection === internal static T Sum(this IReadOnlyCollection collection) where T : struct, IMensuraUnit, IEquatable @@ -857,7 +705,6 @@ internal static partial class AggregateUnitExtensions // Быстрый SIMD-путь для готовых коллекций за 0 аллокаций if (collection is T?[] array) return array.Sum(); if (collection is List list) return list.Sum(); - if (collection is ICollection col) return col.Sum(); if (collection is IReadOnlyCollection roc) return roc.Sum(); // Медленный путь для ленивого yield return: вычисляем на лету @@ -882,7 +729,6 @@ internal static partial class AggregateUnitExtensions if (collection is T?[] array) return array.Avg(); if (collection is List list) return list.Avg(); - if (collection is ICollection col) return col.Avg(); if (collection is IReadOnlyCollection roc) return roc.Avg(); double sum = 0; @@ -909,7 +755,6 @@ internal static partial class AggregateUnitExtensions if (collection is T?[] array) return array.Max(); if (collection is List list) return list.Max(); - if (collection is ICollection col) return col.Max(); if (collection is IReadOnlyCollection roc) return roc.Max(); double max = double.MinValue; @@ -934,7 +779,6 @@ internal static partial class AggregateUnitExtensions if (collection is T?[] array) return array.Min(); if (collection is List list) return list.Min(); - if (collection is ICollection col) return col.Min(); if (collection is IReadOnlyCollection roc) return roc.Min(); double min = double.MaxValue; diff --git a/QWERTYkez.Mensura/Extensions/CastExtensions.cs b/QWERTYkez.Mensura/Extensions/CastExtensions.cs index e0dd07f..01f7fae 100644 --- a/QWERTYkez.Mensura/Extensions/CastExtensions.cs +++ b/QWERTYkez.Mensura/Extensions/CastExtensions.cs @@ -1,51 +1,35 @@ -namespace QWERTYkez.Mensura.Extensions; +using System.Reflection; +using System.Reflection.Emit; + +namespace QWERTYkez.Mensura.Extensions; internal static partial class CastExtensions { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static double ToDouble(this T unit) - where T : struct, IMensuraUnit, IEquatable - { - return Unsafe.As(ref unit); - } - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static T ToUnit(this double val) - where T : struct, IMensuraUnit, IEquatable - { - return Unsafe.As(ref val); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void SetCountUnsafe(this List list, int count) - { - // Берем адрес управляемого объекта List в памяти - // Объект передается по ref-ссылке, преобразуется в указатель - ref var mimic = ref Unsafe.As, Mimics>(ref list); - - // Меняем приватный размер напрямую в памяти объекта! - mimic.Size = count; - } - + internal static double ToDouble(this T unit) where T : struct, IMensuraUnit, IEquatable + => Unsafe.As(ref unit); + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static T ToUnit(this double val) + where T : struct, IMensuraUnit, IEquatable => Unsafe.As(ref val); [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static List WrapAsList(this T[] array) where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable { - // Создаём пустой список с нулевой ёмкостью + if (array is null) return null!; + + // 1. Физически меняем паспорт (MethodTable) массива на целевой тип R[] + object arrObj = array; + unsafe { *(nint*)*(nint*)Unsafe.AsPointer(ref arrObj) = typeof(R[]).TypeHandle.Value; } + R[] morphedArray = Unsafe.As(arrObj); + + // 2. Вшиваем его в новый список var list = new List(0); - - // Получаем внутреннюю структуру списка - ref var mimic = ref Unsafe.As, Mimics>(ref list); - - // Подменяем массив и устанавливаем размер - mimic.Items = array; + ref var mimic = ref Unsafe.As, ListMimic>(ref list); + mimic.Items = morphedArray; mimic.Size = array.Length; - mimic.Version = 1; // любое ненулевое значение для консистенции + mimic.Version = 1; return list; } @@ -55,16 +39,17 @@ internal static partial class CastExtensions where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable { - // Создаём пустой список с нулевой ёмкостью + if (array is null) return null!; + + object arrObj = array; + unsafe { *(nint*)*(nint*)Unsafe.AsPointer(ref arrObj) = typeof(R?[]).TypeHandle.Value; } + R?[] morphedArray = Unsafe.As(arrObj); + var list = new List(0); - - // Получаем внутреннюю структуру списка - ref var mimic = ref Unsafe.As, Mimics>(ref list); - - // Подменяем массив и устанавливаем размер - mimic.Items = array; + ref var mimic = ref Unsafe.As, ListMimic>(ref list); + mimic.Items = morphedArray; mimic.Size = array.Length; - mimic.Version = 1; // любое ненулевое значение для консистенции + mimic.Version = 1; return list; } @@ -73,16 +58,17 @@ internal static partial class CastExtensions internal static List WrapAsList(this T[] array) where T : struct, IMensuraUnit, IEquatable { - // Создаём пустой список с нулевой ёмкостью + if (array is null) return null!; + + object arrObj = array; + unsafe { *(nint*)*(nint*)Unsafe.AsPointer(ref arrObj) = typeof(double[]).TypeHandle.Value; } + double[] morphedArray = Unsafe.As(arrObj); + var list = new List(0); - - // Получаем внутреннюю структуру списка - ref var mimic = ref Unsafe.As, Mimics>(ref list); - - // Подменяем массив и устанавливаем размер - mimic.Items = array; + ref var mimic = ref Unsafe.As, ListMimic>(ref list); + mimic.Items = morphedArray; mimic.Size = array.Length; - mimic.Version = 1; // любое ненулевое значение для консистенции + mimic.Version = 1; return list; } @@ -91,16 +77,17 @@ internal static partial class CastExtensions internal static List WrapAsList(this T?[] array) where T : struct, IMensuraUnit, IEquatable { - // Создаём пустой список с нулевой ёмкостью + if (array is null) return null!; + + object arrObj = array; + unsafe { *(nint*)*(nint*)Unsafe.AsPointer(ref arrObj) = typeof(double?[]).TypeHandle.Value; } + double?[] morphedArray = Unsafe.As(arrObj); + var list = new List(0); - - // Получаем внутреннюю структуру списка - ref var mimic = ref Unsafe.As, Mimics>(ref list); - - // Подменяем массив и устанавливаем размер - mimic.Items = array; + ref var mimic = ref Unsafe.As, ListMimic>(ref list); + mimic.Items = morphedArray; mimic.Size = array.Length; - mimic.Version = 1; // любое ненулевое значение для консистенции + mimic.Version = 1; return list; } @@ -108,16 +95,14 @@ internal static partial class CastExtensions [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static List WrapAsList(this double[] array) { - // Создаём пустой список с нулевой ёмкостью + if (array is null) return null!; + + // Массив уже имеет тип double[], подмена MethodTable не требуется var list = new List(0); - - // Получаем внутреннюю структуру списка - ref var mimic = ref Unsafe.As, Mimics>(ref list); - - // Подменяем массив и устанавливаем размер + ref var mimic = ref Unsafe.As, ListMimic>(ref list); mimic.Items = array; mimic.Size = array.Length; - mimic.Version = 1; // любое ненулевое значение для консистенции + mimic.Version = 1; return list; } @@ -125,28 +110,75 @@ internal static partial class CastExtensions [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static List WrapAsList(this double?[] array) { - // Создаём пустой список с нулевой ёмкостью + if (array is null) return null!; + + // Массив уже имеет тип double?[], подмена MethodTable не требуется var list = new List(0); - - // Получаем внутреннюю структуру списка - ref var mimic = ref Unsafe.As, Mimics>(ref list); - - // Подменяем массив и устанавливаем размер + ref var mimic = ref Unsafe.As, ListMimic>(ref list); mimic.Items = array; mimic.Size = array.Length; - mimic.Version = 1; // любое ненулевое значение для консистенции + mimic.Version = 1; return list; } + + + + + + #region Инфраструктура Нативного Доступа (Zero-Overhead) + + // Генератор сверхбыстрого доступа к приватным полям List через чистый IL. + // Работает со скоростью обычного обращения к полю (компилируется в смещение указателя). + private static class ListAccessor + { + public delegate ref T[] GetItemsRefDelegate(List list); + public static readonly GetItemsRefDelegate GetItemsRef; + + static ListAccessor() + { + var field = typeof(List).GetField("_items", BindingFlags.NonPublic | BindingFlags.Instance) + ?? throw new InvalidOperationException("CLR Layout changed: _items field not found."); + + var dm = new DynamicMethod("GetItemsRef", typeof(T[]).MakeByRefType(), [typeof(List)], typeof(ListAccessor).Module, true); + var il = dm.GetILGenerator(); + il.Emit(OpCodes.Ldarg_0); // Загружаем ссылку на List + il.Emit(OpCodes.Ldflda, field); // Получаем управляемый указатель (ref) на поле _items + il.Emit(OpCodes.Ret); // Возвращаем его + + GetItemsRef = dm.CreateDelegate(); + } + } + + #endregion + + #region Реализация ReCast со сменой MethodTable (In-Place Object Morphing) + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static List ReCast(this List list) where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable { - return Unsafe.As, List>(ref list); + if (list is null) return null!; + unsafe + { + // 1. Морфим внутренний массив со скоростью мысли + T[] items = ListAccessor.GetItemsRef(list); + if (items is not null) + { + object itemsObj = items; + *(nint*)*(nint*)Unsafe.AsPointer(ref itemsObj) = typeof(R[]).TypeHandle.Value; + } + + // 2. Морфим сам заголовок List + object listObj = list; + *(nint*)*(nint*)Unsafe.AsPointer(ref listObj) = typeof(List).TypeHandle.Value; + + return Unsafe.As>(listObj); + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -154,21 +186,63 @@ internal static partial class CastExtensions where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable { - return Unsafe.As, List>(ref list); + if (list is null) return null!; + unsafe + { + T?[] items = ListAccessor.GetItemsRef(list); + if (items is not null) + { + object itemsObj = items; + *(nint*)*(nint*)Unsafe.AsPointer(ref itemsObj) = typeof(R?[]).TypeHandle.Value; + } + + object listObj = list; + *(nint*)*(nint*)Unsafe.AsPointer(ref listObj) = typeof(List).TypeHandle.Value; + + return Unsafe.As>(listObj); + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static List ReCast(this List list) where T : struct, IMensuraUnit, IEquatable { - return Unsafe.As, List>(ref list); + if (list is null) return null!; + unsafe + { + T[] items = ListAccessor.GetItemsRef(list); + if (items is not null) + { + object itemsObj = items; + *(nint*)*(nint*)Unsafe.AsPointer(ref itemsObj) = typeof(double[]).TypeHandle.Value; + } + + object listObj = list; + *(nint*)*(nint*)Unsafe.AsPointer(ref listObj) = typeof(List).TypeHandle.Value; + + return Unsafe.As>(listObj); + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static List ReCast(this List list) where T : struct, IMensuraUnit, IEquatable { - return Unsafe.As, List>(ref list); + if (list is null) return null!; + unsafe + { + T?[] items = ListAccessor.GetItemsRef(list); + if (items is not null) + { + object itemsObj = items; + *(nint*)*(nint*)Unsafe.AsPointer(ref itemsObj) = typeof(double?[]).TypeHandle.Value; + } + + object listObj = list; + *(nint*)*(nint*)Unsafe.AsPointer(ref listObj) = typeof(List).TypeHandle.Value; + + return Unsafe.As>(listObj); + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -176,7 +250,14 @@ internal static partial class CastExtensions where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable { - return Unsafe.As(ref array); + if (array is null) return null!; + unsafe + { + object obj = array; + // Ужатие магии: берем адрес переменной на стеке -> читаем адрес объекта в куче -> пишем туда новый MethodTable + *(nint*)*(nint*)Unsafe.AsPointer(ref obj) = typeof(R[]).TypeHandle.Value; + return Unsafe.As(obj); + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -184,34 +265,66 @@ internal static partial class CastExtensions where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable { - return Unsafe.As(ref array); + if (array is null) return null!; + unsafe + { + object obj = array; + *(nint*)*(nint*)Unsafe.AsPointer(ref obj) = typeof(R?[]).TypeHandle.Value; + return Unsafe.As(obj); + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static double[] ReCast(this T[] array) where T : struct, IMensuraUnit, IEquatable { - return Unsafe.As(ref array); + if (array is null) return null!; + unsafe + { + object obj = array; + *(nint*)*(nint*)Unsafe.AsPointer(ref obj) = typeof(double[]).TypeHandle.Value; + return Unsafe.As(obj); + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static double?[] ReCast(this T?[] array) where T : struct, IMensuraUnit, IEquatable { - return Unsafe.As(ref array); + if (array is null) return null!; + unsafe + { + object obj = array; + *(nint*)*(nint*)Unsafe.AsPointer(ref obj) = typeof(double?[]).TypeHandle.Value; + return Unsafe.As(obj); + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static R[] ReCast(this double[] array) where R : struct, IMensuraUnit, IEquatable { - return Unsafe.As(ref array); + if (array is null) return null!; + unsafe + { + object obj = array; + *(nint*)*(nint*)Unsafe.AsPointer(ref obj) = typeof(R[]).TypeHandle.Value; + return Unsafe.As(obj); + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static R?[] ReCast(this double?[] array) where R : struct, IMensuraUnit, IEquatable { - return Unsafe.As(ref array); + if (array is null) return null!; + unsafe + { + object obj = array; + *(nint*)*(nint*)Unsafe.AsPointer(ref obj) = typeof(R?[]).TypeHandle.Value; + return Unsafe.As(obj); + } } + + #endregion } \ No newline at end of file diff --git a/QWERTYkez.Mensura/Extensions/CollectionsDivideExtensions.cs b/QWERTYkez.Mensura/Extensions/CollectionsDivideExtensions.cs index d3a7b1b..e7a7f3f 100644 --- a/QWERTYkez.Mensura/Extensions/CollectionsDivideExtensions.cs +++ b/QWERTYkez.Mensura/Extensions/CollectionsDivideExtensions.cs @@ -264,80 +264,6 @@ internal static partial class CollectionsDivideExtensions return resultArray.WrapAsList(); } - // === ICollection === - internal static void Div(this ICollection units, double divisor, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { DivideCore(array, divisor, count, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).DivideCore(divisor, count, destination); return; } - - int i = 0; - double invDivisor = 1.0 / divisor; - foreach (var item in units) - destination[i++] = (item.ToDouble() * invDivisor).ToUnit(); - } - internal static void Div(this ICollection units, double divisor, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.DivideCore(divisor, count, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).DivideCore(divisor, count, destination); return; } - - int i = 0; - double invDivisor = 1.0 / divisor; - foreach (var item in units) - destination[i++] = item.HasValue - ? (item.Value.ToDouble() * invDivisor).ToUnit() : null; - } - internal static void Div(this double dividend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { dividend.DivideCore(array, count, destination); return; } - if (units is List list) { dividend.DivideCore(CollectionsMarshal.AsSpan(list), count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (dividend / item.ToDouble()).ToUnit(); - } - internal static void Div(this double dividend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { dividend.DivideCore(array, count, destination); return; } - if (units is List list) { dividend.DivideCore(CollectionsMarshal.AsSpan(list), count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (dividend / item.Value.ToDouble()).ToUnit() : null; - } - // === IReadOnlyCollection === internal static void Div(this IReadOnlyCollection units, double divisor, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -454,12 +380,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is T[] array) return array.Div(divisor); if (units is List list) return list.Div(divisor); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Div(divisor, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -475,12 +395,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is T?[] array) return array.Div(divisor); if (units is List list) return list.Div(divisor); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Div(divisor, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -496,12 +410,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is T[] array) return dividend.Div(array); if (units is List list) return dividend.Div(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - dividend.Div(arr, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -517,12 +425,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is T?[] array) return dividend.Div(array); if (units is List list) return dividend.Div(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - dividend.Div(arr, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -670,76 +572,6 @@ internal static partial class CollectionsDivideExtensions return resultArray.WrapAsList(); } - // === ICollection === - internal static void Div(this ICollection units, double divisor, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { array.Div(divisor, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Div(divisor, destination); return; } - - int i = 0; - double invDivisor = 1.0 / divisor; - foreach (var item in units) - destination[i++] = (item.ToDouble() * invDivisor).ToUnit(); - } - internal static void Div(this ICollection units, double divisor, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.Div(divisor, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Div(divisor, destination); return; } - - int i = 0; - double invDivisor = 1.0 / divisor; - foreach (var item in units) - destination[i++] = item.HasValue - ? (item.Value.ToDouble() * invDivisor).ToUnit() : null; - } - internal static void Div(this double dividend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { dividend.Div(array, destination); return; } - if (units is List list) { dividend.Div(CollectionsMarshal.AsSpan(list), destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (dividend / item.ToDouble()).ToUnit(); - } - internal static void Div(this double dividend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { dividend.Div(array, destination); return; } - if (units is List list) { dividend.Div(CollectionsMarshal.AsSpan(list), destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (dividend / item.Value.ToDouble()).ToUnit() : null; - } - // === IReadOnlyCollection === internal static void Div(this IReadOnlyCollection units, double divisor, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -847,12 +679,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is T[] array) return array.Div(divisor); if (units is List list) return list.Div(divisor); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Div(divisor, arr); - return arr; - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -867,12 +693,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is T?[] array) return array.Div(divisor); if (units is List list) return list.Div(divisor); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Div(divisor, arr); - return arr; - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -887,12 +707,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is T[] array) return dividend.Div(array); if (units is List list) return dividend.Div(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - dividend.Div(arr, arr); - return arr; - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -907,12 +721,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is T?[] array) return dividend.Div(array); if (units is List list) return dividend.Div(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - dividend.Div(arr, arr); - return arr; - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -1365,76 +1173,6 @@ internal static partial class CollectionsDivideExtensions return resultArray.WrapAsList(); } - // === ICollection === - internal static void Div(this ICollection units, T divisor, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is double[] array) { array.Div(divisor, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Div(divisor, destination); return; } - - int i = 0; - double invDivisor = 1.0 / divisor.ToDouble(); - foreach (var item in units) - destination[i++] = (item * invDivisor).ToUnit(); - } - internal static void Div(this ICollection units, T divisor, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is double?[] array) { array.Div(divisor, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Div(divisor, destination); return; } - - int i = 0; - double invDivisor = 1.0 / divisor.ToDouble(); - foreach (var item in units) - destination[i++] = item.HasValue - ? (item.Value * invDivisor).ToUnit() : null; - } - internal static void Div(this T dividend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is double[] array) { dividend.Div(array, destination); return; } - if (units is List list) { dividend.Div(CollectionsMarshal.AsSpan(list), destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (dividend.ToDouble() / item).ToUnit(); - } - internal static void Div(this T dividend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is double?[] array) { dividend.Div(array, destination); return; } - if (units is List list) { dividend.Div(CollectionsMarshal.AsSpan(list), destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (dividend.ToDouble() / item.Value).ToUnit() : null; - } - // === IReadOnlyCollection === internal static void Div(this IReadOnlyCollection units, T divisor, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -1542,12 +1280,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is double[] array) return array.Div(divisor); if (units is List list) return list.Div(divisor); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.DivCore(divisor.ToDouble(), arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -1562,12 +1294,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is double?[] array) return array.Div(divisor); if (units is List list) return list.Div(divisor); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.DivCore(divisor.ToDouble(), arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -1582,12 +1308,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is double[] array) return dividend.Div(array); if (units is List list) return dividend.Div(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - dividend.ToDouble().DivCore(arr, arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -1602,12 +1322,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is double?[] array) return dividend.Div(array); if (units is List list) return dividend.Div(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - dividend.ToDouble().DivCore(arr, arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -1915,76 +1629,6 @@ internal static partial class CollectionsDivideExtensions return resultArray.WrapAsList(); } - // === ICollection === - internal static void Div(this ICollection units, T divisor, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { array.Div(divisor, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Div(divisor, destination); return; } - - int i = 0; - double invDivisor = 1.0 / divisor.ToDouble(); - foreach (var item in units) - destination[i++] = item.ToDouble() * invDivisor; - } - internal static void Div(this ICollection units, T divisor, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.Div(divisor, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Div(divisor, destination); return; } - - int i = 0; - double invDivisor = 1.0 / divisor.ToDouble(); - foreach (var item in units) - destination[i++] = item.HasValue ? item.Value.ToDouble() * invDivisor : null; - } - internal static void Div(this T dividend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { dividend.Div(array, destination); return; } - if (units is List list) { dividend.Div(CollectionsMarshal.AsSpan(list), destination); return; } - - int i = 0; - var div = dividend.ToDouble(); - foreach (var item in units) - destination[i++] = div / item.ToDouble(); - } - internal static void Div(this T dividend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { dividend.Div(array, destination); return; } - if (units is List list) { dividend.Div(CollectionsMarshal.AsSpan(list), destination); return; } - - int i = 0; - var div = dividend.ToDouble(); - foreach (var item in units) - destination[i++] = item.HasValue ? div / item.Value.ToDouble() : null; - } - // === IReadOnlyCollection === internal static void Div(this IReadOnlyCollection units, T divisor, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -2092,12 +1736,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is T[] array) return array.Div(divisor); if (units is List list) return list.Div(divisor); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.DivideCore(divisor.ToDouble(), arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -2112,12 +1750,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is T?[] array) return array.Div(divisor); if (units is List list) return list.Div(divisor); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.DivideCore(divisor.ToDouble(), arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -2132,12 +1764,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is T[] array) return dividend.Div(array); if (units is List list) return dividend.Div(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - dividend.ToDouble().DivideCore(arr, arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -2152,12 +1778,6 @@ internal static partial class CollectionsDivideExtensions if (units is null) return null!; if (units is T?[] array) return dividend.Div(array); if (units is List list) return dividend.Div(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - dividend.ToDouble().DivideCore(arr, arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); diff --git a/QWERTYkez.Mensura/Extensions/CollectionsMinusExtensions.cs b/QWERTYkez.Mensura/Extensions/CollectionsMinusExtensions.cs index 3f77d73..f5e1e1b 100644 --- a/QWERTYkez.Mensura/Extensions/CollectionsMinusExtensions.cs +++ b/QWERTYkez.Mensura/Extensions/CollectionsMinusExtensions.cs @@ -259,78 +259,6 @@ internal static partial class CollectionsMinusExtensions return resultArray.WrapAsList(); } - // === ICollection === - internal static void Minus(this ICollection units, double subtrahend, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { array.MinusCore(subtrahend, count, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).MinusCore(subtrahend, count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (item.ToDouble() - subtrahend).ToUnit(); - } - internal static void Minus(this ICollection units, double subtrahend, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.MinusCore(subtrahend, count, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).MinusCore(subtrahend, count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (item.Value.ToDouble() - subtrahend).ToUnit() : null; - } - internal static void Minus(this double minuend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { minuend.MinusCore(array, count, destination); return; } - if (units is List list) { minuend.MinusCore(CollectionsMarshal.AsSpan(list), count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (minuend - item.ToDouble()).ToUnit(); - } - internal static void Minus(this double minuend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { minuend.MinusCore(array, count, destination); return; } - if (units is List list) { minuend.MinusCore(CollectionsMarshal.AsSpan(list), count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (minuend - item.Value.ToDouble()).ToUnit() : null; - } - // === IReadOnlyCollection === internal static void Minus(this IReadOnlyCollection units, double subtrahend, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -443,12 +371,6 @@ internal static partial class CollectionsMinusExtensions if (units is null) return null!; if (units is T[] array) return array.Minus(subtrahend); if (units is List list) return list.Minus(subtrahend); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Minus(subtrahend, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -464,12 +386,6 @@ internal static partial class CollectionsMinusExtensions if (units is null) return null!; if (units is T?[] array) return array.Minus(subtrahend); if (units is List list) return list.Minus(subtrahend); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Minus(subtrahend, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -485,12 +401,6 @@ internal static partial class CollectionsMinusExtensions if (units is null) return null!; if (units is T[] array) return minuend.Minus(array); if (units is List list) return minuend.Minus(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - minuend.Minus(arr, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -506,12 +416,6 @@ internal static partial class CollectionsMinusExtensions if (units is null) return null!; if (units is T?[] array) return minuend.Minus(array); if (units is List list) return minuend.Minus(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - minuend.Minus(arr, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -660,74 +564,6 @@ internal static partial class CollectionsMinusExtensions return resultArray.WrapAsList(); } - // === ICollection === - internal static void Minus(this ICollection units, double subtrahend, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { array.Minus(subtrahend, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Minus(subtrahend, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (item.ToDouble() - subtrahend).ToUnit(); - } - internal static void Minus(this ICollection units, double subtrahend, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.Minus(subtrahend, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Minus(subtrahend, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (item.Value.ToDouble() - subtrahend).ToUnit() : null; - } - internal static void Minus(this double minuend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { minuend.Minus(array, destination); return; } - if (units is List list) { minuend.Minus(CollectionsMarshal.AsSpan(list), destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (minuend - item.ToDouble()).ToUnit(); - } - internal static void Minus(this double minuend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { minuend.Minus(array, destination); return; } - if (units is List list) { minuend.Minus(CollectionsMarshal.AsSpan(list), destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (minuend - item.Value.ToDouble()).ToUnit() : null; - } - // === IReadOnlyCollection === internal static void Minus(this IReadOnlyCollection units, double subtrahend, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -831,12 +667,6 @@ internal static partial class CollectionsMinusExtensions if (units is null) return null!; if (units is T[] array) return array.Minus(subtrahend); if (units is List list) return list.Minus(subtrahend); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Minus(subtrahend, arr); - return arr; - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -851,12 +681,6 @@ internal static partial class CollectionsMinusExtensions if (units is null) return null!; if (units is T?[] array) return array.Minus(subtrahend); if (units is List list) return list.Minus(subtrahend); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Minus(subtrahend, arr); - return arr; - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -871,12 +695,6 @@ internal static partial class CollectionsMinusExtensions if (units is null) return null!; if (units is T[] array) return minuend.Minus(array); if (units is List list) return minuend.Minus(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - minuend.Minus(arr, arr); - return arr; - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -891,12 +709,6 @@ internal static partial class CollectionsMinusExtensions if (units is null) return null!; if (units is T?[] array) return minuend.Minus(array); if (units is List list) return minuend.Minus(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - minuend.Minus(arr, arr); - return arr; - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -1339,76 +1151,6 @@ internal static partial class CollectionsMinusExtensions return resultArray.WrapAsList(); } - // === ICollection === - internal static void Minus(this ICollection units, T divisor, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is double[] array) { array.Minus(divisor, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Minus(divisor, destination); return; } - - int i = 0; - double invMinusisor = 1.0 / divisor.ToDouble(); - foreach (var item in units) - destination[i++] = (item * invMinusisor).ToUnit(); - } - internal static void Minus(this ICollection units, T divisor, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is double?[] array) { array.Minus(divisor, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Minus(divisor, destination); return; } - - int i = 0; - double invMinusisor = 1.0 / divisor.ToDouble(); - foreach (var item in units) - destination[i++] = item.HasValue - ? (item.Value * invMinusisor).ToUnit() : null; - } - internal static void Minus(this T dividend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is double[] array) { dividend.Minus(array, destination); return; } - if (units is List list) { dividend.Minus(CollectionsMarshal.AsSpan(list), destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (dividend.ToDouble() / item).ToUnit(); - } - internal static void Minus(this T dividend, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is double?[] array) { dividend.Minus(array, destination); return; } - if (units is List list) { dividend.Minus(CollectionsMarshal.AsSpan(list), destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (dividend.ToDouble() / item.Value).ToUnit() : null; - } - // === IReadOnlyCollection === internal static void Minus(this IReadOnlyCollection units, T divisor, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -1516,12 +1258,6 @@ internal static partial class CollectionsMinusExtensions if (units is null) return null!; if (units is double[] array) return array.Minus(divisor); if (units is List list) return list.Minus(divisor); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.MinusCore(divisor.ToDouble(), arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -1536,12 +1272,6 @@ internal static partial class CollectionsMinusExtensions if (units is null) return null!; if (units is double?[] array) return array.Minus(divisor); if (units is List list) return list.Minus(divisor); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.MinusCore(divisor.ToDouble(), arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -1556,12 +1286,6 @@ internal static partial class CollectionsMinusExtensions if (units is null) return null!; if (units is double[] array) return dividend.Minus(array); if (units is List list) return dividend.Minus(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - dividend.ToDouble().MinusCore(arr, arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -1576,12 +1300,6 @@ internal static partial class CollectionsMinusExtensions if (units is null) return null!; if (units is double?[] array) return dividend.Minus(array); if (units is List list) return dividend.Minus(list); - if (units is ICollection col) - { - var arr = col.ToArray(); - dividend.ToDouble().MinusCore(arr, arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); diff --git a/QWERTYkez.Mensura/Extensions/CollectionsMultiplyExtensions.cs b/QWERTYkez.Mensura/Extensions/CollectionsMultiplyExtensions.cs index 6bce3ee..b21811f 100644 --- a/QWERTYkez.Mensura/Extensions/CollectionsMultiplyExtensions.cs +++ b/QWERTYkez.Mensura/Extensions/CollectionsMultiplyExtensions.cs @@ -162,53 +162,6 @@ internal static partial class CollectionsMultiplyExtensions where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable => units.Mul(multiplicator); - // === ICollection === - internal static void Mul(this ICollection units, double multiplicator, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { MultiplyCore(array, multiplicator, count, destination); return; } - if (units is List list) { MultiplyCore(CollectionsMarshal.AsSpan(list), multiplicator, count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (item.ToDouble() * multiplicator).ToUnit(); - } - internal static void Mul(this ICollection units, double multiplicator, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { MultiplyCore(array, multiplicator, count, destination); return; } - if (units is List list) { MultiplyCore(CollectionsMarshal.AsSpan(list), multiplicator, count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (item.Value.ToDouble() * multiplicator).ToUnit() : null; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void Mul(this double multiplicator, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable => units.Mul(multiplicator, destination); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void Mul(this double multiplicator, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable => units.Mul(multiplicator, destination); - // === IReadOnlyCollection === internal static void Mul(this IReadOnlyCollection units, double multiplicator, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -281,12 +234,6 @@ internal static partial class CollectionsMultiplyExtensions if (units is null) return null!; if (units is T[] array) return array.Mul(multiplicator); if (units is List list) return list.Mul(multiplicator); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Mul(multiplicator, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -302,12 +249,6 @@ internal static partial class CollectionsMultiplyExtensions if (units is null) return null!; if (units is T?[] array) return array.Mul(multiplicator); if (units is List list) return list.Mul(multiplicator); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Mul(multiplicator, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -424,49 +365,6 @@ internal static partial class CollectionsMultiplyExtensions internal static List Mul(this double multiplicator, List units) where T : struct, IMensuraUnit, IEquatable => units.Mul(multiplicator); - // === ICollection === - internal static void Mul(this ICollection units, double multiplicator, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { array.Mul(multiplicator, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Mul(multiplicator, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (item.ToDouble() * multiplicator).ToUnit(); - } - internal static void Mul(this ICollection units, double multiplicator, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.Mul(multiplicator, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Mul(multiplicator, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (item.Value.ToDouble() * multiplicator).ToUnit() : null; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void Mul(this double multiplicator, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable => units.Mul(multiplicator, destination); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void Mul(this double multiplicator, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable => units.Mul(multiplicator, destination); - // === IReadOnlyCollection === internal static void Mul(this IReadOnlyCollection units, double multiplicator, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -532,12 +430,6 @@ internal static partial class CollectionsMultiplyExtensions if (units is null) return null!; if (units is T[] array) return array.Mul(multiplicator); if (units is List list) return list.Mul(multiplicator); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Mul(multiplicator, arr); - return arr; - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -552,12 +444,6 @@ internal static partial class CollectionsMultiplyExtensions if (units is null) return null!; if (units is T?[] array) return array.Mul(multiplicator); if (units is List list) return list.Mul(multiplicator); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Mul(multiplicator, arr); - return arr; - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -832,49 +718,6 @@ internal static partial class CollectionsMultiplyExtensions internal static List Mul(this T multiplicator, List units) where T : struct, IMensuraUnit, IEquatable => units.Mul(multiplicator); - // === ICollection === - internal static void Mul(this ICollection units, T multiplicator, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is double[] array) { array.MultiplyCore(multiplicator.ToDouble(), array.Length, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).MultiplyCore(multiplicator.ToDouble(), list.Count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (item * multiplicator.ToDouble()).ToUnit(); - } - internal static void Mul(this ICollection units, T multiplicator, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is double?[] array) { array.MultiplyCore(multiplicator.ToDouble(), array.Length, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).MultiplyCore(multiplicator.ToDouble(), list.Count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (item.Value * multiplicator.ToDouble()).ToUnit() : null; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void Mul(this T multiplicator, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable => units.Mul(multiplicator, destination); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void Mul(this T multiplicator, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable => units.Mul(multiplicator, destination); - // === IReadOnlyCollection === internal static void Mul(this IReadOnlyCollection units, T multiplicator, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -940,12 +783,6 @@ internal static partial class CollectionsMultiplyExtensions if (units is null) return null!; if (units is double[] array) return array.Mul(multiplicator); if (units is List list) return list.Mul(multiplicator); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.MultiplyCore(multiplicator.ToDouble(), arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -960,12 +797,6 @@ internal static partial class CollectionsMultiplyExtensions if (units is null) return null!; if (units is double?[] array) return array.Mul(multiplicator); if (units is List list) return list.Mul(multiplicator); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.MultiplyCore(multiplicator.ToDouble(), arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); diff --git a/QWERTYkez.Mensura/Extensions/CollectionsPlusExtensions.cs b/QWERTYkez.Mensura/Extensions/CollectionsPlusExtensions.cs index b5e3325..68d9a70 100644 --- a/QWERTYkez.Mensura/Extensions/CollectionsPlusExtensions.cs +++ b/QWERTYkez.Mensura/Extensions/CollectionsPlusExtensions.cs @@ -163,53 +163,6 @@ internal static partial class CollectionsPlusExtensions where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable => units.Plus(summand); - // === ICollection === - internal static void Plus(this ICollection units, double summand, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { PlusCore(array, summand, count, destination); return; } - if (units is List list) { PlusCore(CollectionsMarshal.AsSpan(list), summand, count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (item.ToDouble() + summand).ToUnit(); - } - internal static void Plus(this ICollection units, double summand, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { PlusCore(array, summand, count, destination); return; } - if (units is List list) { PlusCore(CollectionsMarshal.AsSpan(list), summand, count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (item.Value.ToDouble() + summand).ToUnit() : null; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void Plus(this double summand, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable => units.Plus(summand, destination); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void Plus(this double summand, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable => units.Plus(summand, destination); - // === IReadOnlyCollection === internal static void Plus(this IReadOnlyCollection units, double summand, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -282,12 +235,6 @@ internal static partial class CollectionsPlusExtensions if (units is null) return null!; if (units is T[] array) return array.Plus(summand); if (units is List list) return list.Plus(summand); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Plus(summand, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -303,12 +250,6 @@ internal static partial class CollectionsPlusExtensions if (units is null) return null!; if (units is T?[] array) return array.Plus(summand); if (units is List list) return list.Plus(summand); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Plus(summand, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -425,49 +366,6 @@ internal static partial class CollectionsPlusExtensions internal static List Plus(this double summand, List units) where T : struct, IMensuraUnit, IEquatable => units.Plus(summand); - // === ICollection === - internal static void Plus(this ICollection units, double summand, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { array.Plus(summand, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Plus(summand, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (item.ToDouble() + summand).ToUnit(); - } - internal static void Plus(this ICollection units, double summand, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.Plus(summand, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Plus(summand, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (item.Value.ToDouble() + summand).ToUnit() : null; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void Plus(this double summand, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable => units.Plus(summand, destination); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void Plus(this double summand, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable => units.Plus(summand, destination); - // === IReadOnlyCollection === internal static void Plus(this IReadOnlyCollection units, double summand, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -533,12 +431,6 @@ internal static partial class CollectionsPlusExtensions if (units is null) return null!; if (units is T[] array) return array.Plus(summand); if (units is List list) return list.Plus(summand); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Plus(summand, arr); - return arr; - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -553,12 +445,6 @@ internal static partial class CollectionsPlusExtensions if (units is null) return null!; if (units is T?[] array) return array.Plus(summand); if (units is List list) return list.Plus(summand); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Plus(summand, arr); - return arr; - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -837,49 +723,6 @@ internal static partial class CollectionsPlusExtensions internal static List Plus(this T summand, List units) where T : struct, IMensuraUnit, IEquatable => units.Plus(summand); - // === ICollection === - internal static void Plus(this ICollection units, T summand, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is double[] array) { array.PlusCore(summand.ToDouble(), array.Length, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).PlusCore(summand.ToDouble(), list.Count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = (item + summand.ToDouble()).ToUnit(); - } - internal static void Plus(this ICollection units, T summand, Span destination) - where T : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is double?[] array) { array.PlusCore(summand.ToDouble(), array.Length, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).PlusCore(summand.ToDouble(), list.Count, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? (item.Value + summand.ToDouble()).ToUnit() : null; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void Plus(this T summand, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable => units.Plus(summand, destination); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void Plus(this T summand, ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable => units.Plus(summand, destination); - // === IReadOnlyCollection === internal static void Plus(this IReadOnlyCollection units, T summand, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -945,12 +788,6 @@ internal static partial class CollectionsPlusExtensions if (units is null) return null!; if (units is double[] array) return array.Plus(summand); if (units is List list) return list.Plus(summand); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.PlusCore(summand.ToDouble(), arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -965,12 +802,6 @@ internal static partial class CollectionsPlusExtensions if (units is null) return null!; if (units is double?[] array) return array.Plus(summand); if (units is List list) return list.Plus(summand); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.PlusCore(summand.ToDouble(), arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); diff --git a/QWERTYkez.Mensura/Extensions/CollectionsPow2Extensions.cs b/QWERTYkez.Mensura/Extensions/CollectionsPow2Extensions.cs index 0e0e963..45e19c6 100644 --- a/QWERTYkez.Mensura/Extensions/CollectionsPow2Extensions.cs +++ b/QWERTYkez.Mensura/Extensions/CollectionsPow2Extensions.cs @@ -7,8 +7,8 @@ internal static partial class CollectionsPow2Extensions // === ВТОРАЯ СТЕПЕНЬ ========================================== - // === Pow2Core2 === SIMD - internal static void Pow2Core2(this ReadOnlySpan units, int len, Span destination) + // === Pow2Core === SIMD + internal static void Pow2Core(this ReadOnlySpan units, int len, Span destination) where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable { @@ -43,7 +43,7 @@ internal static partial class CollectionsPow2Extensions dstDouble[i] = val * val; } } - internal static void Pow2Core2(this ReadOnlySpan units, int len, Span destination) + internal static void Pow2Core(this ReadOnlySpan units, int len, Span destination) where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable { @@ -106,7 +106,7 @@ internal static partial class CollectionsPow2Extensions if (len > destination.Length) throw new ArgumentException("Целевой буфер destination меньше исходного source."); - units.Pow2Core2(len, destination); + units.Pow2Core(len, destination); } internal static void Pow2(this ReadOnlySpan units, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -117,7 +117,7 @@ internal static partial class CollectionsPow2Extensions if (len > destination.Length) throw new ArgumentException("Целевой буфер destination меньше исходного source."); - units.Pow2Core2(len, destination); + units.Pow2Core(len, destination); } // === Array === @@ -172,43 +172,6 @@ internal static partial class CollectionsPow2Extensions return resultArray.WrapAsList(); } - // === ICollection === - internal static void Pow2(this ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { array.Pow2(destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Pow2(destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.ToDouble().QuickPow2().ToUnit(); - } - internal static void Pow2(this ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.Pow2(destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Pow2(destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? item.Value.ToDouble().QuickPow2().ToUnit() : null; - } - // === IReadOnlyCollection === internal static void Pow2(this IReadOnlyCollection units, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -271,12 +234,6 @@ internal static partial class CollectionsPow2Extensions if (units is null) return null!; if (units is T[] array) return array.Pow2(); if (units is List list) return list.Pow2(); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Pow2Core2(arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -292,12 +249,6 @@ internal static partial class CollectionsPow2Extensions if (units is null) return null!; if (units is T?[] array) return array.Pow2(); if (units is List list) return list.Pow2(); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Pow2(arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); diff --git a/QWERTYkez.Mensura/Extensions/CollectionsPow3Extensions.cs b/QWERTYkez.Mensura/Extensions/CollectionsPow3Extensions.cs index 6df3321..7193ef4 100644 --- a/QWERTYkez.Mensura/Extensions/CollectionsPow3Extensions.cs +++ b/QWERTYkez.Mensura/Extensions/CollectionsPow3Extensions.cs @@ -175,43 +175,6 @@ internal static partial class CollectionsPow3Extensions return resultArray.WrapAsList(); } - // === ICollection === - internal static void Pow3(this ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { array.Pow3(destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Pow3(destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.ToDouble().QuickPow3().ToUnit(); - } - internal static void Pow3(this ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.Pow3(destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Pow3(destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? item.Value.ToDouble().QuickPow3().ToUnit() : null; - } - // === IReadOnlyCollection === internal static void Pow3(this IReadOnlyCollection units, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -274,12 +237,6 @@ internal static partial class CollectionsPow3Extensions if (units is null) return null!; if (units is T[] array) return array.Pow3(); if (units is List list) return list.Pow3(); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.PowCore3(arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -295,12 +252,6 @@ internal static partial class CollectionsPow3Extensions if (units is null) return null!; if (units is T?[] array) return array.Pow3(); if (units is List list) return list.Pow3(); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Pow3(arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); diff --git a/QWERTYkez.Mensura/Extensions/CollectionsPowNExtensions.cs b/QWERTYkez.Mensura/Extensions/CollectionsPowNExtensions.cs index 04f43fb..409b6d6 100644 --- a/QWERTYkez.Mensura/Extensions/CollectionsPowNExtensions.cs +++ b/QWERTYkez.Mensura/Extensions/CollectionsPowNExtensions.cs @@ -222,43 +222,6 @@ internal static partial class CollectionsPowNExtensions return resultArray.WrapAsList(); } - // === ICollection === - internal static void Pow(this ICollection units, int power, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { array.Pow(power, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Pow(power, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.ToDouble().QuickPow(power).ToUnit(); - } - internal static void Pow(this ICollection units, int power, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.Pow(power, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Pow(power, destination); return; } - - int i = 0; - foreach (var item in units) - destination[i++] = item.HasValue - ? item.Value.ToDouble().QuickPow(power).ToUnit() : null; - } - // === IReadOnlyCollection === internal static void Pow(this IReadOnlyCollection units, int power, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -321,12 +284,6 @@ internal static partial class CollectionsPowNExtensions if (units is null) return null!; if (units is T[] array) return array.Pow(power); if (units is List list) return list.Pow(power); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.PowCore(power, arr.Length, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -342,12 +299,6 @@ internal static partial class CollectionsPowNExtensions if (units is null) return null!; if (units is T?[] array) return array.Pow(power); if (units is List list) return list.Pow(power); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Pow(power, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -534,43 +485,6 @@ internal static partial class CollectionsPowNExtensions return result.WrapAsList(); } - // === ICollection === - internal static void Pow(this ICollection units, double power, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { array.Pow(power, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Pow(power, destination); return; } - - int i = 0; - foreach (T item in units) - destination[i++] = Math.Pow(item.ToDouble(), power).ToUnit(); - } - internal static void Pow(this ICollection units, double power, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.Pow(power, destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Pow(power, destination); return; } - - int i = 0; - foreach (T? item in units) - destination[i++] = item.HasValue - ? Math.Pow(item.Value.ToDouble(), power).ToUnit() : null; - } - // === IReadOnlyCollection === internal static void Pow(this IReadOnlyCollection units, double power, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -633,12 +547,6 @@ internal static partial class CollectionsPowNExtensions if (units is null) return null!; if (units is T[] array) return array.Pow(power); if (units is List list) return list.Pow(power); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Pow(power, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -654,12 +562,6 @@ internal static partial class CollectionsPowNExtensions if (units is null) return null!; if (units is T?[] array) return array.Pow(power); if (units is List list) return list.Pow(power); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Pow(power, arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); diff --git a/QWERTYkez.Mensura/Extensions/CollectionsRootOfCubeExtensions.cs b/QWERTYkez.Mensura/Extensions/CollectionsRootOfCubeExtensions.cs new file mode 100644 index 0000000..55e5a25 --- /dev/null +++ b/QWERTYkez.Mensura/Extensions/CollectionsRootOfCubeExtensions.cs @@ -0,0 +1,215 @@ +using System.Runtime.Intrinsics.X86; + +namespace QWERTYkez.Mensura.Extensions; + +internal static partial class CollectionsRootOfCubeExtensions +{ + // === CbrtCore === SIMD + internal static unsafe void CbrtCore(this ReadOnlySpan units, int len, Span destination) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + // Прямой каст без проверок размеров + ReadOnlySpan srcDouble = MemoryMarshal.Cast(units); + Span dstDouble = MemoryMarshal.Cast(destination); + + int i = 0; + ref double srcRef = ref MemoryMarshal.GetReference(srcDouble); + ref double dstRef = ref MemoryMarshal.GetReference(dstDouble); + + // 1. SIMD путь (AVX) + if (Avx.IsSupported && len >= 4) + { + int simdEnd = len & ~3; + for (; i < simdEnd; i += 4) + { + double* pSrc = (double*)Unsafe.AsPointer(ref Unsafe.Add(ref srcRef, i)); + double* pDst = (double*)Unsafe.AsPointer(ref Unsafe.Add(ref dstRef, i)); + + // Используем LoadVector256 для максимально быстрой обработки 4-х double + Avx.Store(pDst, Avx.Sqrt(Avx.LoadVector256(pSrc))); + } + } + // 2. Fallback путь для остатка + for (; i < len; i++) + { + Unsafe.Add(ref dstRef, i) = Math.Sqrt(Unsafe.Add(ref srcRef, i)); + } + } + internal static void CbrtCore(this ReadOnlySpan units, int len, Span destination) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + ref var srcRef = ref MemoryMarshal.GetReference(units); + ref var dstRef = ref MemoryMarshal.GetReference(destination); + int i = 0, unrollEnd = len & ~3; + + for (; i < unrollEnd; i += 4) + { + Unsafe.Add(ref dstRef, i) = Unsafe.Add(ref srcRef, i).HasValue ? Math.Sqrt(Unsafe.Add(ref srcRef, i)!.Value.ToDouble()).ToUnit() : null; + Unsafe.Add(ref dstRef, i + 1) = Unsafe.Add(ref srcRef, i + 1).HasValue ? Math.Sqrt(Unsafe.Add(ref srcRef, i + 1)!.Value.ToDouble()).ToUnit() : null; + Unsafe.Add(ref dstRef, i + 2) = Unsafe.Add(ref srcRef, i + 2).HasValue ? Math.Sqrt(Unsafe.Add(ref srcRef, i + 2)!.Value.ToDouble()).ToUnit() : null; + Unsafe.Add(ref dstRef, i + 3) = Unsafe.Add(ref srcRef, i + 3).HasValue ? Math.Sqrt(Unsafe.Add(ref srcRef, i + 3)!.Value.ToDouble()).ToUnit() : null; + } + for (; i < len; i++) + Unsafe.Add(ref dstRef, i) = Unsafe.Add(ref srcRef, i).HasValue ? Math.Sqrt(Unsafe.Add(ref srcRef, i)!.Value.ToDouble()).ToUnit() : null; + } + + // === ReadOnlySpan === + internal static void Cbrt(this ReadOnlySpan units, Span destination) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + if (units.IsEmpty) return; + int len = units.Length; + if (len > destination.Length) + throw new ArgumentException("Целевой буфер destination меньше исходного source."); + + units.CbrtCore(len, destination); + } + internal static void Cbrt(this ReadOnlySpan units, Span destination) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + if (units.IsEmpty) return; + int len = units.Length; + if (len > destination.Length) + throw new ArgumentException("Целевой буфер destination меньше исходного source."); + + units.CbrtCore(len, destination); + } + + // === Array === + internal static R[] Cbrt(this T[] units) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + if (units is null) return null!; + if (units.Length == 0) return []; + + var result = new R[units.Length]; + Cbrt(units, result); + return result; + } + internal static R?[] Cbrt(this T?[] units) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + if (units is null) return null!; + if (units.Length == 0) return []; + + var result = new R?[units.Length]; + Cbrt(units, result); + return result; + } + + // === List === + internal static List Cbrt(this List units) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + if (units is null) return null!; + int len = units.Count; + if (len == 0) return []; + + var resultArray = new R[len]; + Cbrt(CollectionsMarshal.AsSpan(units), resultArray); + return resultArray.WrapAsList(); + } + internal static List Cbrt(this List units) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + if (units is null) return null!; + int len = units.Count; + if (len == 0) return []; + + var resultArray = new R?[len]; + Cbrt(CollectionsMarshal.AsSpan(units), resultArray); + return resultArray.WrapAsList(); + } + + // === IReadOnlyCollection === + internal static void Cbrt(this IReadOnlyCollection units, Span destination) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + if (units is null) return; + int count = units.Count; + if (count == 0) return; + if (destination.Length < count) throw new ArgumentException("Destination too short"); + + if (units is T[] array) { array.AsSpan().CbrtCore(count, destination); return; } + if (units is List list) { CollectionsMarshal.AsSpan(list).CbrtCore(count, destination); return; } + + int i = 0; + ref R dstRef = ref MemoryMarshal.GetReference(destination); + foreach (T item in units) Unsafe.Add(ref dstRef, i++) = Math.Sqrt(item.ToDouble()).ToUnit(); + } + internal static void Cbrt(this IReadOnlyCollection units, Span destination) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + if (units is null) return; + int count = units.Count; + if (count == 0) return; + if (destination.Length < count) + throw new ArgumentException("Destination too short"); + + if (units is T?[] array) { array.Cbrt(destination); return; } + if (units is List list) { CollectionsMarshal.AsSpan(list).Cbrt(destination); return; } + + int i = 0; + foreach (T? item in units) + destination[i++] = item.HasValue + ? Math.Sqrt(item.Value.ToDouble()).ToUnit() : null; + } + + // === IEnumerable + yield === + internal static IEnumerable SqrtIterator3(this IEnumerable units) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + foreach (var item in units) yield return Math.Sqrt(item.ToDouble()).ToUnit(); + } + internal static IEnumerable SqrtNullableIterator3(this IEnumerable units) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + foreach (var item in units) + yield return item.HasValue + ? Math.Sqrt(item.Value.ToDouble()).ToUnit() : null; + } + + // === IEnumerable === + internal static IEnumerable Cbrt(this IEnumerable units) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + if (units is null) return null!; + if (units is T[] array) return array.Cbrt(); + if (units is List list) return list.Cbrt(); + if (units is IReadOnlyCollection roc) + { + var arr = roc.ToArray(); + arr.Cbrt(arr); + return arr.ReCast(); + } + else return SqrtIterator3(units); + } + internal static IEnumerable Cbrt(this IEnumerable units) + where T : struct, IMensuraUnit, IEquatable + where R : struct, IMensuraUnit, IEquatable + { + if (units is null) return null!; + if (units is T?[] array) return array.Cbrt(); + if (units is List list) return list.Cbrt(); + if (units is IReadOnlyCollection roc) + { + var arr = roc.ToArray(); + arr.Cbrt(arr); + return arr.ReCast(); + } + else return SqrtNullableIterator3(units); + } +} \ No newline at end of file diff --git a/QWERTYkez.Mensura/Extensions/CollectionsSqrtExtensions.cs b/QWERTYkez.Mensura/Extensions/CollectionsRootOfSquareExtensions.cs similarity index 64% rename from QWERTYkez.Mensura/Extensions/CollectionsSqrtExtensions.cs rename to QWERTYkez.Mensura/Extensions/CollectionsRootOfSquareExtensions.cs index aedebba..9937442 100644 --- a/QWERTYkez.Mensura/Extensions/CollectionsSqrtExtensions.cs +++ b/QWERTYkez.Mensura/Extensions/CollectionsRootOfSquareExtensions.cs @@ -2,7 +2,7 @@ namespace QWERTYkez.Mensura.Extensions; -internal static partial class CollectionsSqrtExtensions +internal static partial class CollectionsRootOfSquareExtensions { // === SqrtCore === SIMD internal static unsafe void SqrtCore(this ReadOnlySpan units, int len, Span destination) @@ -13,11 +13,10 @@ internal static partial class CollectionsSqrtExtensions Span dstDouble = MemoryMarshal.Cast(destination); int i = 0; - ref double srcRef = ref MemoryMarshal.GetReference(srcDouble); ref double dstRef = ref MemoryMarshal.GetReference(dstDouble); - // 1. ПУТЬ AVX (x64 Процессоры Intel/AMD) — обрабатываем по 4 элемента double + // 1. ПУТЬ AVX2 / AVX (x64 Процессоры) — обрабатываем по 4 элемента double за такт if (Avx.IsSupported && len >= 4) { int simdEnd = len & ~3; @@ -26,18 +25,16 @@ internal static partial class CollectionsSqrtExtensions ref double currentSrc = ref Unsafe.Add(ref srcRef, i); ref double currentDst = ref Unsafe.Add(ref dstRef, i); - // Получаем указатели через Unsafe.AsPointer double* pSrc = (double*)Unsafe.AsPointer(ref currentSrc); double* pDst = (double*)Unsafe.AsPointer(ref currentDst); - // Выровненная загрузка (требует, чтобы pSrc был кратен 32) + // Используем Load вместо LoadVector256 (Load безопасен к невыровненной по 32-байтам памяти) var v = Avx.LoadVector256(pSrc); var sqrtV = Avx.Sqrt(v); - // Выровненное сохранение Avx.Store(pDst, sqrtV); } } - // 2. ПУТЬ VECTOR (ARM64 / Apple Silicon / Старые CPU без AVX) + // 2. КРОССПЛАТФОРМЕННЫЙ VECTOR (ARM64 / Apple Silicon / NEON / SIMD Fallback) else if (Vector.IsHardwareAccelerated && len >= Vector.Count) { int vCount = Vector.Count; @@ -45,18 +42,13 @@ internal static partial class CollectionsSqrtExtensions for (; i < simdEnd; i += vCount) { - // Используем Span для кроссплатформенного создания вектора var v = new Vector(srcDouble.Slice(i, vCount)); - - // Кроссплатформенный аппаратный корень (на ARM превратится в NEON инструкцию) var sqrtV = Vector.SquareRoot(v); - - // Копируем напрямую в целевой Span sqrtV.CopyTo(dstDouble.Slice(i, vCount)); } } - // 3. Хвост массива (или обычный расчет, если SIMD на процессоре недоступен) + // 3. ХВОСТ МАССИВА (или работа на старых CPU) for (; i < len; i++) { Unsafe.Add(ref dstRef, i) = Math.Sqrt(Unsafe.Add(ref srcRef, i)); @@ -66,47 +58,41 @@ internal static partial class CollectionsSqrtExtensions where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable { - // Получаем прямые ref-ссылки на начало буферов за 0 тактов процессора ref var srcRef = ref MemoryMarshal.GetReference(units); ref var dstRef = ref MemoryMarshal.GetReference(destination); int i = 0; - int unrollEnd = len & ~3; // Граница развернутого цикла (кратная 4) + int unrollEnd = len & ~3; - // 1. ОСНОВНОЙ ЦИКЛ: Конвейерная обработка по 4 элемента за итерацию + // ОСНОВНОЙ ЦИКЛ: Конвейерное чтение по 4 элемента (Развертка цикла повышает ILP процессора) for (; i < unrollEnd; i += 4) { - T? u0 = Unsafe.Add(ref srcRef, i); - T? u1 = Unsafe.Add(ref srcRef, i + 1); - T? u2 = Unsafe.Add(ref srcRef, i + 2); - T? u3 = Unsafe.Add(ref srcRef, i + 3); + ref readonly T? u0 = ref Unsafe.Add(ref srcRef, i); + ref readonly T? u1 = ref Unsafe.Add(ref srcRef, i + 1); + ref readonly T? u2 = ref Unsafe.Add(ref srcRef, i + 2); + ref readonly T? u3 = ref Unsafe.Add(ref srcRef, i + 3); - // Получаем ref-ссылки на целевые ячейки типа R? (zero-cost адресация) ref var d0 = ref Unsafe.Add(ref dstRef, i); ref var d1 = ref Unsafe.Add(ref dstRef, i + 1); ref var d2 = ref Unsafe.Add(ref dstRef, i + 2); ref var d3 = ref Unsafe.Add(ref dstRef, i + 3); - // Считаем нативный корень прямо в регистрах и трансформируем тип из T в R по месту d0 = u0.HasValue ? Math.Sqrt(u0.Value.ToDouble()).ToUnit() : null; d1 = u1.HasValue ? Math.Sqrt(u1.Value.ToDouble()).ToUnit() : null; d2 = u2.HasValue ? Math.Sqrt(u2.Value.ToDouble()).ToUnit() : null; d3 = u3.HasValue ? Math.Sqrt(u3.Value.ToDouble()).ToUnit() : null; } - // 2. ХВОСТ ЦИКЛА: Довычисляем остаток элементов (от 1 до 3 штук) + // ХВОСТ ЦИКЛА: Остаток элементов for (; i < len; i++) { - T? unit = Unsafe.Add(ref srcRef, i); + ref readonly T? unit = ref Unsafe.Add(ref srcRef, i); ref var dst = ref Unsafe.Add(ref dstRef, i); dst = unit.HasValue ? Math.Sqrt(unit.Value.ToDouble()).ToUnit() : null; } } - - - - // === ReadOnlySpan === + // === ReadOnlySpan API === internal static void Sqrt(this ReadOnlySpan units, Span destination) where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable @@ -130,7 +116,7 @@ internal static partial class CollectionsSqrtExtensions units.SqrtCore(len, destination); } - // === Array === + // === Array API === internal static R[] Sqrt(this T[] units) where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable @@ -139,7 +125,7 @@ internal static partial class CollectionsSqrtExtensions if (units.Length == 0) return []; var result = new R[units.Length]; - Sqrt(units, result); + units.AsSpan().SqrtCore(units.Length, result.AsSpan()); return result; } internal static R?[] Sqrt(this T?[] units) @@ -150,11 +136,11 @@ internal static partial class CollectionsSqrtExtensions if (units.Length == 0) return []; var result = new R?[units.Length]; - Sqrt(units, result); + units.AsSpan().SqrtCore(units.Length, result.AsSpan()); return result; } - // === List === + // === List API === internal static List Sqrt(this List units) where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable @@ -164,7 +150,7 @@ internal static partial class CollectionsSqrtExtensions if (len == 0) return []; var resultArray = new R[len]; - Sqrt(CollectionsMarshal.AsSpan(units), resultArray); + CollectionsMarshal.AsSpan(units).SqrtCore(len, resultArray.AsSpan()); return resultArray.WrapAsList(); } internal static List Sqrt(this List units) @@ -176,48 +162,11 @@ internal static partial class CollectionsSqrtExtensions if (len == 0) return []; var resultArray = new R?[len]; - Sqrt(CollectionsMarshal.AsSpan(units), resultArray); + CollectionsMarshal.AsSpan(units).SqrtCore(len, resultArray.AsSpan()); return resultArray.WrapAsList(); } - // === ICollection === - internal static void Sqrt(this ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { array.Sqrt(destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Sqrt(destination); return; } - - int i = 0; - foreach (T item in units) - destination[i++] = Math.Sqrt(item.ToDouble()).ToUnit(); - } - internal static void Sqrt(this ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.Sqrt(destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Sqrt(destination); return; } - - int i = 0; - foreach (T? item in units) - destination[i++] = item.HasValue - ? Math.Sqrt(item.Value.ToDouble()).ToUnit() : null; - } - - // === IReadOnlyCollection === + // === IReadOnlyCollection === internal static void Sqrt(this IReadOnlyCollection units, Span destination) where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable @@ -228,12 +177,16 @@ internal static partial class CollectionsSqrtExtensions if (destination.Length < count) throw new ArgumentException("Destination too short"); - if (units is T[] array) { array.Sqrt(destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Sqrt(destination); return; } + if (units is T[] array) { array.AsSpan().SqrtCore(count, destination); return; } + if (units is List list) { CollectionsMarshal.AsSpan(list).SqrtCore(count, destination); return; } int i = 0; + ref R dstRef = ref MemoryMarshal.GetReference(destination); foreach (T item in units) - destination[i++] = Math.Sqrt(item.ToDouble()).ToUnit(); + { + if ((uint)i >= (uint)count) break; + Unsafe.Add(ref dstRef, i++) = Math.Sqrt(item.ToDouble()).ToUnit(); + } } internal static void Sqrt(this IReadOnlyCollection units, Span destination) where T : struct, IMensuraUnit, IEquatable @@ -245,16 +198,20 @@ internal static partial class CollectionsSqrtExtensions if (destination.Length < count) throw new ArgumentException("Destination too short"); - if (units is T?[] array) { array.Sqrt(destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Sqrt(destination); return; } + if (units is T?[] array) { array.AsSpan().SqrtCore(count, destination); return; } + if (units is List list) { CollectionsMarshal.AsSpan(list).SqrtCore(count, destination); return; } int i = 0; + ref R? dstRef = ref MemoryMarshal.GetReference(destination); foreach (T? item in units) - destination[i++] = item.HasValue + { + if ((uint)i >= (uint)count) break; + Unsafe.Add(ref dstRef, i++) = item.HasValue ? Math.Sqrt(item.Value.ToDouble()).ToUnit() : null; + } } - // === IEnumerable + yield === + // === IEnumerable Iterators === internal static IEnumerable SqrtIterator(this IEnumerable units) where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable @@ -271,7 +228,7 @@ internal static partial class CollectionsSqrtExtensions ? Math.Sqrt(item.Value.ToDouble()).ToUnit() : null; } - // === IEnumerable === + // === IEnumerable API === internal static IEnumerable Sqrt(this IEnumerable units) where T : struct, IMensuraUnit, IEquatable where R : struct, IMensuraUnit, IEquatable @@ -279,12 +236,6 @@ internal static partial class CollectionsSqrtExtensions if (units is null) return null!; if (units is T[] array) return array.Sqrt(); if (units is List list) return list.Sqrt(); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Sqrt(arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); @@ -300,12 +251,6 @@ internal static partial class CollectionsSqrtExtensions if (units is null) return null!; if (units is T?[] array) return array.Sqrt(); if (units is List list) return list.Sqrt(); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Sqrt(arr); - return arr.ReCast(); - } if (units is IReadOnlyCollection roc) { var arr = roc.ToArray(); diff --git a/QWERTYkez.Mensura/Extensions/CollectionsSqrt3Extensions.cs b/QWERTYkez.Mensura/Extensions/CollectionsSqrt3Extensions.cs deleted file mode 100644 index 2f3f85b..0000000 --- a/QWERTYkez.Mensura/Extensions/CollectionsSqrt3Extensions.cs +++ /dev/null @@ -1,317 +0,0 @@ -using System.Runtime.Intrinsics.X86; - -namespace QWERTYkez.Mensura.Extensions; - -internal static partial class CollectionsSqrt3Extensions -{ - // === SqrtCore3 === SIMD - internal static unsafe void SqrtCore3(this ReadOnlySpan units, int len, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - ReadOnlySpan srcDouble = MemoryMarshal.Cast(units); - Span dstDouble = MemoryMarshal.Cast(destination); - - int i = 0; - - ref double srcRef = ref MemoryMarshal.GetReference(srcDouble); - ref double dstRef = ref MemoryMarshal.GetReference(dstDouble); - - // 1. ПУТЬ AVX (x64 Процессоры Intel/AMD) — обрабатываем по 4 элемента double - if (Avx.IsSupported && len >= 4) - { - int simdEnd = len & ~3; - for (; i < simdEnd; i += 4) - { - ref double currentSrc = ref Unsafe.Add(ref srcRef, i); - ref double currentDst = ref Unsafe.Add(ref dstRef, i); - - // Получаем указатели через Unsafe.AsPointer - double* pSrc = (double*)Unsafe.AsPointer(ref currentSrc); - double* pDst = (double*)Unsafe.AsPointer(ref currentDst); - - // Выровненная загрузка (требует, чтобы pSrc был кратен 32) - var v = Avx.LoadVector256(pSrc); - var sqrtV = Avx.Sqrt(v); - // Выровненное сохранение - Avx.Store(pDst, sqrtV); - } - } - // 2. ПУТЬ VECTOR (ARM64 / Apple Silicon / Старые CPU без AVX) - else if (Vector.IsHardwareAccelerated && len >= Vector.Count) - { - int vCount = Vector.Count; - int simdEnd = len & ~(vCount - 1); - - for (; i < simdEnd; i += vCount) - { - // Используем Span для кроссплатформенного создания вектора - var v = new Vector(srcDouble.Slice(i, vCount)); - - // Кроссплатформенный аппаратный корень (на ARM превратится в NEON инструкцию) - var sqrtV = Vector.SquareRoot(v); - - // Копируем напрямую в целевой Span - sqrtV.CopyTo(dstDouble.Slice(i, vCount)); - } - } - - // 3. Хвост массива (или обычный расчет, если SIMD на процессоре недоступен) - for (; i < len; i++) - { - Unsafe.Add(ref dstRef, i) = Math.Sqrt(Unsafe.Add(ref srcRef, i)); - } - } - internal static void SqrtCore3(this ReadOnlySpan units, int len, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - // Получаем прямые ref-ссылки на начало буферов за 0 тактов процессора - ref var srcRef = ref MemoryMarshal.GetReference(units); - ref var dstRef = ref MemoryMarshal.GetReference(destination); - - int i = 0; - int unrollEnd = len & ~3; // Граница развернутого цикла (кратная 4) - - // 1. ОСНОВНОЙ ЦИКЛ: Конвейерная обработка по 4 элемента за итерацию - for (; i < unrollEnd; i += 4) - { - T? u0 = Unsafe.Add(ref srcRef, i); - T? u1 = Unsafe.Add(ref srcRef, i + 1); - T? u2 = Unsafe.Add(ref srcRef, i + 2); - T? u3 = Unsafe.Add(ref srcRef, i + 3); - - // Получаем ref-ссылки на целевые ячейки типа R? (zero-cost адресация) - ref var d0 = ref Unsafe.Add(ref dstRef, i); - ref var d1 = ref Unsafe.Add(ref dstRef, i + 1); - ref var d2 = ref Unsafe.Add(ref dstRef, i + 2); - ref var d3 = ref Unsafe.Add(ref dstRef, i + 3); - - // Считаем нативный корень прямо в регистрах и трансформируем тип из T в R по месту - d0 = u0.HasValue ? Math.Sqrt(u0.Value.ToDouble()).ToUnit() : null; - d1 = u1.HasValue ? Math.Sqrt(u1.Value.ToDouble()).ToUnit() : null; - d2 = u2.HasValue ? Math.Sqrt(u2.Value.ToDouble()).ToUnit() : null; - d3 = u3.HasValue ? Math.Sqrt(u3.Value.ToDouble()).ToUnit() : null; - } - - // 2. ХВОСТ ЦИКЛА: Довычисляем остаток элементов (от 1 до 3 штук) - for (; i < len; i++) - { - T? unit = Unsafe.Add(ref srcRef, i); - ref var dst = ref Unsafe.Add(ref dstRef, i); - dst = unit.HasValue ? Math.Sqrt(unit.Value.ToDouble()).ToUnit() : null; - } - } - - - - - // === ReadOnlySpan === - internal static void Sqrt3(this ReadOnlySpan units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units.IsEmpty) return; - int len = units.Length; - if (len > destination.Length) - throw new ArgumentException("Целевой буфер destination меньше исходного source."); - - units.SqrtCore3(len, destination); - } - internal static void Sqrt3(this ReadOnlySpan units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units.IsEmpty) return; - int len = units.Length; - if (len > destination.Length) - throw new ArgumentException("Целевой буфер destination меньше исходного source."); - - units.SqrtCore3(len, destination); - } - - // === Array === - internal static R[] Sqrt3(this T[] units) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return null!; - if (units.Length == 0) return []; - - var result = new R[units.Length]; - Sqrt3(units, result); - return result; - } - internal static R?[] Sqrt3(this T?[] units) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return null!; - if (units.Length == 0) return []; - - var result = new R?[units.Length]; - Sqrt3(units, result); - return result; - } - - // === List === - internal static List Sqrt3(this List units) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return null!; - int len = units.Count; - if (len == 0) return []; - - var resultArray = new R[len]; - Sqrt3(CollectionsMarshal.AsSpan(units), resultArray); - return resultArray.WrapAsList(); - } - internal static List Sqrt3(this List units) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return null!; - int len = units.Count; - if (len == 0) return []; - - var resultArray = new R?[len]; - Sqrt3(CollectionsMarshal.AsSpan(units), resultArray); - return resultArray.WrapAsList(); - } - - // === ICollection === - internal static void Sqrt3(this ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { array.Sqrt3(destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Sqrt3(destination); return; } - - int i = 0; - foreach (T item in units) - destination[i++] = Math.Sqrt(item.ToDouble()).ToUnit(); - } - internal static void Sqrt3(this ICollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.Sqrt3(destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Sqrt3(destination); return; } - - int i = 0; - foreach (T? item in units) - destination[i++] = item.HasValue - ? Math.Sqrt(item.Value.ToDouble()).ToUnit() : null; - } - - // === IReadOnlyCollection === - internal static void Sqrt3(this IReadOnlyCollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T[] array) { array.Sqrt3(destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Sqrt3(destination); return; } - - int i = 0; - foreach (T item in units) - destination[i++] = Math.Sqrt(item.ToDouble()).ToUnit(); - } - internal static void Sqrt3(this IReadOnlyCollection units, Span destination) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return; - int count = units.Count; - if (count == 0) return; - if (destination.Length < count) - throw new ArgumentException("Destination too short"); - - if (units is T?[] array) { array.Sqrt3(destination); return; } - if (units is List list) { CollectionsMarshal.AsSpan(list).Sqrt3(destination); return; } - - int i = 0; - foreach (T? item in units) - destination[i++] = item.HasValue - ? Math.Sqrt(item.Value.ToDouble()).ToUnit() : null; - } - - // === IEnumerable + yield === - internal static IEnumerable SqrtIterator3(this IEnumerable units) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - foreach (var item in units) - yield return Math.Sqrt(item.ToDouble()).ToUnit(); - } - internal static IEnumerable SqrtNullableIterator3(this IEnumerable units) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - foreach (var item in units) - yield return item.HasValue - ? Math.Sqrt(item.Value.ToDouble()).ToUnit() : null; - } - - // === IEnumerable === - internal static IEnumerable Sqrt3(this IEnumerable units) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return null!; - if (units is T[] array) return array.Sqrt3(); - if (units is List list) return list.Sqrt3(); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Sqrt3(arr); - return arr.ReCast(); - } - if (units is IReadOnlyCollection roc) - { - var arr = roc.ToArray(); - arr.Sqrt3(arr); - return arr.ReCast(); - } - else return SqrtIterator3(units); - } - internal static IEnumerable Sqrt3(this IEnumerable units) - where T : struct, IMensuraUnit, IEquatable - where R : struct, IMensuraUnit, IEquatable - { - if (units is null) return null!; - if (units is T?[] array) return array.Sqrt3(); - if (units is List list) return list.Sqrt3(); - if (units is ICollection col) - { - var arr = col.ToArray(); - arr.Sqrt3(arr); - return arr.ReCast(); - } - if (units is IReadOnlyCollection roc) - { - var arr = roc.ToArray(); - arr.Sqrt3(arr); - return arr.ReCast(); - } - else return SqrtNullableIterator3(units); - } -} \ No newline at end of file diff --git a/QWERTYkez.Mensura/Extensions/DoubleExtensions.cs b/QWERTYkez.Mensura/Extensions/DoubleExtensions.cs index 8aa833b..f2babe9 100644 --- a/QWERTYkez.Mensura/Extensions/DoubleExtensions.cs +++ b/QWERTYkez.Mensura/Extensions/DoubleExtensions.cs @@ -2,40 +2,40 @@ internal static partial class DoubleExtensions { - internal static double ToDouble(this byte number) => Convert.ToDouble(number); - internal static double ToDouble(this sbyte number) => Convert.ToDouble(number); - internal static double ToDouble(this short number) => Convert.ToDouble(number); - internal static double ToDouble(this ushort number) => Convert.ToDouble(number); - internal static double ToDouble(this int number) => Convert.ToDouble(number); - internal static double ToDouble(this uint number) => Convert.ToDouble(number); - internal static double ToDouble(this nint number) => Convert.ToDouble(number); - 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); + internal static double ToDouble(this byte number) => number; + internal static double ToDouble(this sbyte number) => number; + internal static double ToDouble(this short number) => number; + internal static double ToDouble(this ushort number) => number; + internal static double ToDouble(this int number) => number; + internal static double ToDouble(this uint number) => number; + internal static double ToDouble(this nint number) => number; + internal static double ToDouble(this nuint number) => number; + internal static double ToDouble(this long number) => number; + internal static double ToDouble(this ulong number) => number; + internal static double ToDouble(this Half number) => (double)number; + internal static double ToDouble(this float number) => number; + internal static double ToDouble(this decimal number) => (double)number; - internal static double ToDouble(this byte? number) => number is null ? 0d : Convert.ToDouble(number); - internal static double ToDouble(this sbyte? number) => number is null ? 0d : Convert.ToDouble(number); - internal static double ToDouble(this short? number) => number is null ? 0d : Convert.ToDouble(number); - internal static double ToDouble(this ushort? number) => number is null ? 0d : Convert.ToDouble(number); - internal static double ToDouble(this int? number) => number is null ? 0d : Convert.ToDouble(number); - internal static double ToDouble(this uint? number) => number is null ? 0d : Convert.ToDouble(number); - internal static double ToDouble(this nint? number) => number is null ? 0d : Convert.ToDouble(number); - 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); + internal static double ToDouble(this byte? number) => number.HasValue ? number.Value : 0d; + internal static double ToDouble(this sbyte? number) => number.HasValue ? number.Value : 0d; + internal static double ToDouble(this short? number) => number.HasValue ? number.Value : 0d; + internal static double ToDouble(this ushort? number) => number.HasValue ? number.Value : 0d; + internal static double ToDouble(this int? number) => number.HasValue ? number.Value : 0d; + internal static double ToDouble(this uint? number) => number.HasValue ? number.Value : 0d; + internal static double ToDouble(this nint? number) => number.HasValue ? number.Value : 0d; + internal static double ToDouble(this nuint? number) => number.HasValue ? number.Value : 0d; + internal static double ToDouble(this long? number) => number.HasValue ? number.Value : 0d; + internal static double ToDouble(this ulong? number) => number.HasValue ? number.Value : 0d; + internal static double ToDouble(this Half? number) => number.HasValue ? (double)number.Value : 0d; + internal static double ToDouble(this float? number) => number.HasValue ? number.Value : 0d; + internal static double ToDouble(this decimal? number) => number.HasValue ? (double)number.Value : 0d; #if NET7_0_OR_GREATER - internal static double ToDouble(this Int128 number) => Convert.ToDouble(number); - internal static double ToDouble(this UInt128 number) => Convert.ToDouble(number); + internal static double ToDouble(this Int128 number) => (double)number; + internal static double ToDouble(this UInt128 number) => (double)number; - internal static double ToDouble(this Int128? number) => number is null ? 0d : Convert.ToDouble(number); - internal static double ToDouble(this UInt128? number) => number is null ? 0d : Convert.ToDouble(number); + internal static double ToDouble(this Int128? number) => number.HasValue ? (double)number.Value : 0d; + internal static double ToDouble(this UInt128? number) => number.HasValue ? (double)number.Value : 0d; #endif @@ -463,25 +463,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 byte[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -506,7 +487,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is byte[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -546,25 +526,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 sbyte[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -589,7 +550,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is sbyte[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -629,25 +589,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 short[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -672,7 +613,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is short[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -712,25 +652,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 ushort[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -755,7 +676,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is ushort[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -795,25 +715,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 int[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -838,7 +739,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is int[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -878,25 +778,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 uint[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -921,7 +802,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is uint[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -961,25 +841,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 nint[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -1004,7 +865,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is nint[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -1044,25 +904,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 nuint[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -1087,7 +928,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is nuint[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -1127,25 +967,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 long[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -1170,7 +991,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is long[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -1210,25 +1030,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 ulong[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -1253,7 +1054,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is ulong[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -1293,25 +1093,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -1336,7 +1117,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is Half[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -1376,25 +1156,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 float[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -1419,7 +1180,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is float[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -1459,25 +1219,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 decimal[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -1502,7 +1243,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is decimal[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -1543,25 +1283,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 Int128[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -1586,7 +1307,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is Int128[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -1626,25 +1346,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 UInt128[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -1669,7 +1370,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is UInt128[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -2046,25 +1746,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 byte?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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++) = item; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -2089,7 +1770,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is byte?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -2129,25 +1809,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 sbyte?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -2172,7 +1833,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is sbyte?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -2212,25 +1872,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 short?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -2255,7 +1896,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is short?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -2295,25 +1935,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 ushort?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -2338,7 +1959,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is ushort?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -2378,25 +1998,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 int?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -2421,7 +2022,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is int?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -2461,25 +2061,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 uint?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -2504,7 +2085,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is uint?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -2544,25 +2124,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 nint?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -2587,7 +2148,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is nint?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -2627,25 +2187,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 nuint?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -2670,7 +2211,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is nuint?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -2710,25 +2250,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 long?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -2753,7 +2274,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is long?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -2793,25 +2313,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 ulong?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -2836,7 +2337,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is ulong?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -2876,25 +2376,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -2919,7 +2400,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is Half?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -2959,25 +2439,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 float?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -3002,7 +2463,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is float?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -3042,25 +2502,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 decimal?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -3085,7 +2526,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is decimal?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -3126,25 +2566,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 Int128?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -3169,7 +2590,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is Int128?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } @@ -3209,25 +2629,6 @@ internal static partial class DoubleExtensions CollectionsMarshal.AsSpan(numbers).ToDoubleCore(len, result); return result.WrapAsList(); } - internal static void ToDouble(this ICollection numbers, Span 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 UInt128?[] array) { array.ToDoubleCore(count, destination); return; } - if (numbers is List 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; - } - } internal static void ToDouble(this IReadOnlyCollection numbers, Span destination) { if (numbers is null) return; @@ -3252,7 +2653,6 @@ internal static partial class DoubleExtensions if (numbers is null) return null!; if (numbers is UInt128?[] array) return array.ToDouble(); if (numbers is List list) return list.ToDouble(); - if (numbers is ICollection col) return col.ToDouble(col.Count); if (numbers is IReadOnlyCollection roc) return roc.ToDouble(roc.Count); return numbers.ToDoubleIterator(); } diff --git a/QWERTYkez.Mensura/Mimics.cs b/QWERTYkez.Mensura/Mimics.cs index 9c1dc18..24356b9 100644 --- a/QWERTYkez.Mensura/Mimics.cs +++ b/QWERTYkez.Mensura/Mimics.cs @@ -1,16 +1,16 @@ namespace QWERTYkez.Mensura; [StructLayout(LayoutKind.Sequential)] -internal class Mimics +internal class ListMimic { public T[] Items = null!; public int Size; public int Version; } -[StructLayout(LayoutKind.Sequential)] -internal struct NullableDoubleMimic +[StructLayout(LayoutKind.Explicit, Size = 16)] +public struct NullableDoubleMimic { - public double Value; - public byte HasValue; + [FieldOffset(0)] public bool HasValue; + [FieldOffset(8)] public double Value; } \ No newline at end of file diff --git a/QWERTYkez.Mensura/QWERTYkez.Mensura.csproj b/QWERTYkez.Mensura/QWERTYkez.Mensura.csproj index 989663e..92c6aac 100644 --- a/QWERTYkez.Mensura/QWERTYkez.Mensura.csproj +++ b/QWERTYkez.Mensura/QWERTYkez.Mensura.csproj @@ -5,7 +5,6 @@ enable enable latest - false false true 1701;1702;IDE1006 @@ -13,8 +12,8 @@ - - + + \ No newline at end of file diff --git a/QWERTYkez.Mensura/Units/Area.cs b/QWERTYkez.Mensura/Units/Area.cs index 9ee7c07..8ed6a2f 100644 --- a/QWERTYkez.Mensura/Units/Area.cs +++ b/QWERTYkez.Mensura/Units/Area.cs @@ -61,21 +61,21 @@ public static class AreaSqrtExtension { // === ReadOnlySpan [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Sqrt( - this ReadOnlySpan units, Span destination) => units.Sqrt3(destination); + this ReadOnlySpan units, Span destination) => units.Cbrt(destination); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Sqrt( - this ReadOnlySpan units, Span destination) => units.Sqrt3(destination); + this ReadOnlySpan units, Span destination) => units.Cbrt(destination); // === Array === - [MethodImpl(MethodImplOptions.AggressiveInlining)]public static Length[] Sqrt(this Area[] units) => units.Sqrt3(); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Length?[] Sqrt(this Area?[] units) => units.Sqrt3(); + [MethodImpl(MethodImplOptions.AggressiveInlining)]public static Length[] Sqrt(this Area[] units) => units.Cbrt(); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Length?[] Sqrt(this Area?[] units) => units.Cbrt(); // === List === - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Sqrt(this List units) => units.Sqrt3(); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Sqrt(this List units) => units.Sqrt3(); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Sqrt(this List units) => units.Cbrt(); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Sqrt(this List units) => units.Cbrt(); // === IEnumerable === - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Sqrt(this IEnumerable units) => units.Sqrt3(); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Sqrt(this IEnumerable units) => units.Sqrt3(); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Sqrt(this IEnumerable units) => units.Cbrt(); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Sqrt(this IEnumerable units) => units.Cbrt(); } internal readonly struct AreaConv diff --git a/QWERTYkez.Mensura/Units/Volume.cs b/QWERTYkez.Mensura/Units/Volume.cs index 6396224..4401f37 100644 --- a/QWERTYkez.Mensura/Units/Volume.cs +++ b/QWERTYkez.Mensura/Units/Volume.cs @@ -38,22 +38,22 @@ public readonly partial record struct Volume public static class VolumeSqrtExtension { // === ReadOnlySpan - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Sqrt3( - this ReadOnlySpan units, Span destination) => units.Sqrt3(destination); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Sqrt3( - this ReadOnlySpan units, Span destination) => units.Sqrt3(destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Cbrt( + this ReadOnlySpan units, Span destination) => units.Cbrt(destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Cbrt( + this ReadOnlySpan units, Span destination) => units.Cbrt(destination); // === Array === - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Length[] Sqrt3(this Volume[] units) => units.Sqrt3(); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Length?[] Sqrt3(this Volume?[] units) => units.Sqrt3(); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Length[] Cbrt(this Volume[] units) => units.Cbrt(); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Length?[] Cbrt(this Volume?[] units) => units.Cbrt(); // === List === - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Sqrt3(this List units) => units.Sqrt3(); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Sqrt3(this List units) => units.Sqrt3(); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Cbrt(this List units) => units.Cbrt(); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Cbrt(this List units) => units.Cbrt(); // === IEnumerable === - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Sqrt3(this IEnumerable units) => units.Sqrt3(); - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Sqrt3(this IEnumerable units) => units.Sqrt3(); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Cbrt(this IEnumerable units) => units.Cbrt(); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Cbrt(this IEnumerable units) => units.Cbrt(); } internal readonly struct VolumeConv diff --git a/QWERTYkez.Mensura/Units/XXXXXXXX.Gen.cs b/QWERTYkez.Mensura/Units/XXXXXXXX.Gen.cs index 3371d4d..8b1c534 100644 --- a/QWERTYkez.Mensura/Units/XXXXXXXX.Gen.cs +++ b/QWERTYkez.Mensura/Units/XXXXXXXX.Gen.cs @@ -1,643 +1,1103 @@ -//namespace QWERTYkez.Mensura.Units; - -//[JsonConverter(typeof(UnitJsonConverter))] -//public readonly partial record struct XXXXXXXX : IMensuraUnit, IEquatable, IMensuraUnit -//{ -// [JsonInclude, DataMember, JsonPropertyName("v"), Obsolete] // для JSON / EF на случай сбоев, если пробелма с _Value -// internal double Value { get => _Value; init => _Value = value; } -// internal readonly double _Value; -// internal XXXXXXXX(double value) => _Value = value; - -// public override int GetHashCode() => _Value.GetHashCode(); -// public int CompareTo(XXXXXXXX? other) => _Value.CompareTo(other is null ? 0d : other.Value._Value); -// public int CompareTo(XXXXXXXX other) => _Value.CompareTo(other._Value); - -// public bool Equals(XXXXXXXX? other) => _Value.Equals(other?._Value); - - -// public static explicit operator XXXXXXXX(double val) => Unsafe.As(ref val); -// public static explicit operator double(XXXXXXXX unit) => unit._Value; - - -// [MethodImpl(MethodImplOptions.AggressiveInlining)] -// public XXXXXXXX Abs() => new(Math.Abs(_Value)); - -// [MethodImpl(MethodImplOptions.AggressiveInlining)] -// internal R Pow2_Internal() where R : struct, IMensuraUnit, IEquatable => (_Value * _Value).ToUnit(); - -// [MethodImpl(MethodImplOptions.AggressiveInlining)] -// internal R Sqrt_Internal() where R : struct, IMensuraUnit, IEquatable => Math.Sqrt(_Value).ToUnit(); - - - -// [JsonIgnore, IgnoreDataMember] public bool IsPositive => _Value >= 0; -// [JsonIgnore, IgnoreDataMember] public bool IsGreaterThanZero => _Value > 0; -// [JsonIgnore, IgnoreDataMember] public bool IsNegative => double.IsNegative(_Value); -// [JsonIgnore, IgnoreDataMember] public bool IsZero => _Value == 0; -// [JsonIgnore, IgnoreDataMember] public bool IsNaN => double.IsNaN(_Value); -// [JsonIgnore, IgnoreDataMember] public bool IsFinite => double.IsFinite(_Value); -// [JsonIgnore, IgnoreDataMember] public bool IsInfinity => double.IsInfinity(_Value); -// [JsonIgnore, IgnoreDataMember] public bool IsPositiveInfinity => double.IsPositiveInfinity(_Value); -// [JsonIgnore, IgnoreDataMember] public bool IsNegativeInfinity => double.IsNegativeInfinity(_Value); - - -// public static XXXXXXXX Zero { get; } = new(0d); -// public static XXXXXXXX Min { get; } = new(double.MinValue); -// public static XXXXXXXX Max { get; } = new(double.MaxValue); -// public static XXXXXXXX NegativeInfinity { get; } = new(double.NegativeInfinity); -// public static XXXXXXXX PositiveInfinity { get; } = new(double.PositiveInfinity); - -// public static bool operator ==(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() == T2.Protected(); -// public static bool operator !=(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() != T2.Protected(); - -// public static bool operator <(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() < T2.Protected(); -// public static bool operator <=(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() <= T2.Protected(); -// public static bool operator >(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() > T2.Protected(); -// public static bool operator >=(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() >= T2.Protected(); - - -// public static XXXXXXXX operator +(XXXXXXXX T2) => new(+T2._Value); -// public static XXXXXXXX operator +(XXXXXXXX T1, XXXXXXXX T2) => new(T1._Value + T2._Value); -// public static XXXXXXXX operator -(XXXXXXXX T2) => new(-T2._Value); -// public static XXXXXXXX operator -(XXXXXXXX T1, XXXXXXXX T2) => new(T1._Value - T2._Value); - - -// // double -// public static XXXXXXXX operator *(XXXXXXXX T1, double T2) => new(T1._Value * T2); -// public static XXXXXXXX operator *(XXXXXXXX T1, double? T2) => T1 * (T2 ?? 0d); -// public static XXXXXXXX operator *(double T1, XXXXXXXX T2) => new(T1 * T2._Value); -// public static XXXXXXXX operator *(double? T1, XXXXXXXX T2) => (T1 ?? 0d) * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, double T2) => new(T1._Value / T2); -// public static XXXXXXXX operator /(XXXXXXXX T1, double? T2) => T1 / (T2 ?? 0d); -// public static double operator /(XXXXXXXX T1, XXXXXXXX T2) => T1._Value / T2._Value; - -// // sbyte -// public static XXXXXXXX operator *(XXXXXXXX T1, sbyte T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, sbyte? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(sbyte T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(sbyte? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, sbyte T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, sbyte? T2) => T1 / T2.ToDouble(); - -// // short -// public static XXXXXXXX operator *(XXXXXXXX T1, short T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, short? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(short T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(short? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, short T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, short? T2) => T1 / T2.ToDouble(); - -// // int -// public static XXXXXXXX operator *(XXXXXXXX T1, int T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, int? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(int T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(int? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, int T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, int? T2) => T1 / T2.ToDouble(); - -// // long -// public static XXXXXXXX operator *(XXXXXXXX T1, long T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, long? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(long T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(long? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, long T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, long? T2) => T1 / T2.ToDouble(); - -// // byte -// public static XXXXXXXX operator *(XXXXXXXX T1, byte T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, byte? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(byte T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(byte? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, byte T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, byte? T2) => T1 / T2.ToDouble(); - -// // ushort -// public static XXXXXXXX operator *(XXXXXXXX T1, ushort T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, ushort? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(ushort T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(ushort? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, ushort T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, ushort? T2) => T1 / T2.ToDouble(); - -// // uint -// public static XXXXXXXX operator *(XXXXXXXX T1, uint T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, uint? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(uint T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(uint? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, uint T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, uint? T2) => T1 / T2.ToDouble(); - -// // ulong -// public static XXXXXXXX operator *(XXXXXXXX T1, ulong T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, ulong? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(ulong T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(ulong? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, ulong T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, ulong? T2) => T1 / T2.ToDouble(); - -// // nint -// public static XXXXXXXX operator *(XXXXXXXX T1, nint T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, nint? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(nint T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(nint? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, nint T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, nint? T2) => T1 / T2.ToDouble(); - -// // nuint -// public static XXXXXXXX operator *(XXXXXXXX T1, nuint T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, nuint? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(nuint T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(nuint? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, nuint T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, nuint? T2) => T1 / T2.ToDouble(); - -// // float -// public static XXXXXXXX operator *(XXXXXXXX T1, float T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, float? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(float T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(float? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, float T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, float? T2) => T1 / T2.ToDouble(); - -// // decimal -// public static XXXXXXXX operator *(XXXXXXXX T1, decimal T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, decimal? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(decimal T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(decimal? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, decimal T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, decimal? T2) => T1 / T2.ToDouble(); - -//#if NET7_0_OR_GREATER -// // Int128 -// public static XXXXXXXX operator *(XXXXXXXX T1, Int128 T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, Int128? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(Int128 T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(Int128? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, Int128 T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, Int128? T2) => T1 / T2.ToDouble(); - -// // UInt128 -// public static XXXXXXXX operator *(XXXXXXXX T1, UInt128 T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(XXXXXXXX T1, UInt128? T2) => T1 * T2.ToDouble(); -// public static XXXXXXXX operator *(UInt128 T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator *(UInt128? T1, XXXXXXXX T2) => T1.ToDouble() * T2; -// public static XXXXXXXX operator /(XXXXXXXX T1, UInt128 T2) => T1 / T2.ToDouble(); -// public static XXXXXXXX operator /(XXXXXXXX T1, UInt128? T2) => T1 / T2.ToDouble(); -//#endif - - - - - - - -// public static XXXXXXXX[] operator +(XXXXXXXX[] T1, XXXXXXXX T2) => T1.Plus(T2._Value); -// public static XXXXXXXX?[] operator +(XXXXXXXX?[] T1, XXXXXXXX T2) => T1.Plus(T2._Value); -// public static XXXXXXXX[] operator +(XXXXXXXX T1, XXXXXXXX[] T2) => T1._Value.Plus(T2); -// public static XXXXXXXX?[] operator +(XXXXXXXX T1, XXXXXXXX?[] T2) => T1._Value.Plus(T2); -// public static XXXXXXXX[] operator +(XXXXXXXX[] T1, XXXXXXXX? T2) => T1.Plus(T2.Protected()); -// public static XXXXXXXX?[] operator +(XXXXXXXX?[] T1, XXXXXXXX? T2) => T1.Plus(T2.Protected()); -// public static XXXXXXXX[] operator +(XXXXXXXX? T1, XXXXXXXX[] T2) => T1.Protected().Plus(T2); -// public static XXXXXXXX?[] operator +(XXXXXXXX? T1, XXXXXXXX?[] T2) => T1.Protected().Plus(T2); - -// public static XXXXXXXX[] operator -(XXXXXXXX[] T1, XXXXXXXX T2) => T1.Minus(T2._Value); -// public static XXXXXXXX?[] operator -(XXXXXXXX?[] T1, XXXXXXXX T2) => T1.Minus(T2._Value); -// public static XXXXXXXX[] operator -(XXXXXXXX T1, XXXXXXXX[] T2) => T1._Value.Minus(T2); -// public static XXXXXXXX?[] operator -(XXXXXXXX T1, XXXXXXXX?[] T2) => T1._Value.Minus(T2); -// public static XXXXXXXX[] operator -(XXXXXXXX[] T1, XXXXXXXX? T2) => T1.Minus(T2.Protected()); -// public static XXXXXXXX?[] operator -(XXXXXXXX?[] T1, XXXXXXXX? T2) => T1.Minus(T2.Protected()); -// public static XXXXXXXX[] operator -(XXXXXXXX? T1, XXXXXXXX[] T2) => T1.Protected().Minus(T2); -// public static XXXXXXXX?[] operator -(XXXXXXXX? T1, XXXXXXXX?[] T2) => T1.Protected().Minus(T2); - -// public static double[] operator /(XXXXXXXX T1, XXXXXXXX[] T2) => T1.Div(T2); -// public static double?[] operator /(XXXXXXXX T1, XXXXXXXX?[] T2) => T1.Div(T2); -// public static double[] operator /(XXXXXXXX[] T1, XXXXXXXX T2) => T1.Div(T2); -// public static double?[] operator /(XXXXXXXX?[] T1, XXXXXXXX T2) => T1.Div(T2); -// public static double[] operator /(XXXXXXXX? T1, XXXXXXXX[] T2) => T1.ProtectedU().Div(T2); -// public static double?[] operator /(XXXXXXXX? T1, XXXXXXXX?[] T2) => T1.ProtectedU().Div(T2); -// public static double[] operator /(XXXXXXXX[] T1, XXXXXXXX? T2) => T1.Div(T2.ProtectedU()); -// public static double?[] operator /(XXXXXXXX?[] T1, XXXXXXXX? T2) => T1.Div(T2.ProtectedU()); - - -// // double -// public static XXXXXXXX[] operator *(XXXXXXXX T1, double[] T2) => T1.Mul(T2); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, double?[] T2) => T1.Mul(T2); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, double[] T2) => T1.ProtectedU().Mul(T2); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, double?[] T2) => T1.ProtectedU().Mul(T2); -// public static XXXXXXXX[] operator *(double[] T1, XXXXXXXX T2) => T1.Mul(T2); -// public static XXXXXXXX?[] operator *(double?[] T1, XXXXXXXX T2) => T1.Mul(T2); -// public static XXXXXXXX[] operator *(double[] T1, XXXXXXXX? T2) => T1.Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(double?[] T1, XXXXXXXX? T2) => T1.Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, double[] T2) => T1.Div(T2); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, double?[] T2) => T1.Div(T2); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, double[] T2) => T1.ProtectedU().Div(T2); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, double?[] T2) => T1.ProtectedU().Div(T2); - -// // sbyte -// public static XXXXXXXX[] operator *(XXXXXXXX T1, sbyte[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, sbyte?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, sbyte[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, sbyte?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(sbyte[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(sbyte?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(sbyte[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(sbyte?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, sbyte[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, sbyte?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, sbyte[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, sbyte?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); - -// // short -// public static XXXXXXXX[] operator *(XXXXXXXX T1, short[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, short?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, short[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, short?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(short[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(short?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(short[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(short?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, short[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, short?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, short[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, short?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); - -// // int -// public static XXXXXXXX[] operator *(XXXXXXXX T1, int[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, int?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, int[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, int?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(int[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(int?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(int[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(int?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, int[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, int?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, int[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, int?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); - -// // long -// public static XXXXXXXX[] operator *(XXXXXXXX T1, long[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, long?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, long[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, long?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(long[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(long?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(long[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(long?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, long[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, long?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, long[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, long?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); - -// // byte -// public static XXXXXXXX[] operator *(XXXXXXXX T1, byte[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, byte?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, byte[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, byte?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(byte[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(byte?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(byte[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(byte?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, byte[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, byte?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, byte[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, byte?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); - -// // ushort -// public static XXXXXXXX[] operator *(XXXXXXXX T1, ushort[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, ushort?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, ushort[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, ushort?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(ushort[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(ushort?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(ushort[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(ushort?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, ushort[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, ushort?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, ushort[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, ushort?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); - -// // uint -// public static XXXXXXXX[] operator *(XXXXXXXX T1, uint[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, uint?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, uint[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, uint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(uint[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(uint?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(uint[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(uint?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, uint[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, uint?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, uint[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, uint?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); - -// // ulong -// public static XXXXXXXX[] operator *(XXXXXXXX T1, ulong[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, ulong?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, ulong[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, ulong?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(ulong[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(ulong?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(ulong[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(ulong?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, ulong[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, ulong?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, ulong[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, ulong?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); - -// // nint -// public static XXXXXXXX[] operator *(XXXXXXXX T1, nint[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, nint?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, nint[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, nint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(nint[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(nint?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(nint[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(nint?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, nint[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, nint?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, nint[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, nint?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); - -// // nuint -// public static XXXXXXXX[] operator *(XXXXXXXX T1, nuint[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, nuint?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, nuint[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, nuint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(nuint[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(nuint?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(nuint[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(nuint?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, nuint[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, nuint?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, nuint[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, nuint?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); - -// // float -// public static XXXXXXXX[] operator *(XXXXXXXX T1, float[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, float?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, float[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, float?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(float[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(float?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(float[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(float?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, float[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, float?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, float[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, float?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); - -// // decimal -// public static XXXXXXXX[] operator *(XXXXXXXX T1, decimal[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, decimal?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, decimal[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, decimal?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(decimal[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(decimal?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(decimal[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(decimal?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, decimal[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, decimal?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, decimal[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, decimal?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); - -//#if NET7_0_OR_GREATER -// // Int128 -// public static XXXXXXXX[] operator *(XXXXXXXX T1, Int128[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, Int128?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, Int128[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, Int128?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(Int128[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(Int128?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(Int128[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(Int128?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, Int128[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, Int128?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, Int128[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, Int128?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); - -// // UInt128 -// public static XXXXXXXX[] operator *(XXXXXXXX T1, UInt128[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX T1, UInt128?[] T2) => T1.Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(XXXXXXXX? T1, UInt128[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX?[] operator *(XXXXXXXX? T1, UInt128?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); -// public static XXXXXXXX[] operator *(UInt128[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX?[] operator *(UInt128?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); -// public static XXXXXXXX[] operator *(UInt128[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX?[] operator *(UInt128?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); -// public static XXXXXXXX[] operator /(XXXXXXXX T1, UInt128[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX T1, UInt128?[] T2) => T1.Div(T2.ToDouble()); -// public static XXXXXXXX[] operator /(XXXXXXXX? T1, UInt128[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -// public static XXXXXXXX?[] operator /(XXXXXXXX? T1, UInt128?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); -//#endif -//} - -//public static class XXXXXXXXExtensions -//{ -// internal static double Protected(this XXXXXXXX? unit) => unit is null ? 0d : unit.Value._Value; -// internal static XXXXXXXX ProtectedU(this XXXXXXXX? unit) => unit is null ? XXXXXXXX.Zero : unit.Value; - - - - - - -// // === ReadOnlySpan -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ReadOnlySpan units, -// double divisor, Span destination) => units.Div(divisor, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ReadOnlySpan units, -// double divisor, Span destination) => units.Div(divisor, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, -// ReadOnlySpan units, Span destination) => dividend.Div(units, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, -// ReadOnlySpan units, Span destination) => dividend.Div(units, destination); - -// // === Array === -// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static XXXXXXXX[] Div( -// this XXXXXXXX[] units, double divisor) => units.Div(divisor); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Div( -// this XXXXXXXX?[] units, double divisor) => units.Div(divisor); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX[] Div( -// this double dividend, XXXXXXXX[] units) => dividend.Div(units); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Div( -// this double dividend, XXXXXXXX?[] units) => dividend.Div(units); - -// // === List === -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Div( -// this List units, double divisor) => units.Div(divisor); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Div( -// this List units, double divisor) => units.Div(divisor); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Div( -// this double dividend, List units) => dividend.Div(units); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Div( -// this double dividend, List units) => dividend.Div(units); - -// // === ICollection === -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ICollection units, -// double divisor, Span destination) => units.Div(divisor, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ICollection units, -// double divisor, Span destination) => units.Div(divisor, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, -// ICollection units, Span destination) => dividend.Div(units, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, -// ICollection units, Span destination) => dividend.Div(units, destination); - -// // === IReadOnlyCollection === -// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Div(this IReadOnlyCollection units, -// double divisor, Span destination) => units.Div(divisor, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Div(this IReadOnlyCollection units, -// double divisor, Span destination) => units.Div(divisor, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, -// IReadOnlyCollection units, Span destination) => dividend.Div(units, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, -// IReadOnlyCollection units, Span destination) => dividend.Div(units, destination); - -// // === IEnumerable === -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Div( -// this IEnumerable units, double divisor) => units.Div(divisor); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Div( -// this IEnumerable units, double divisor) => units.Div(divisor); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Div( -// this double dividend, IEnumerable units) => dividend.Div(units); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Div( -// this double dividend, IEnumerable units) => dividend.Div(units); - - - - - - -// // === ReadOnlySpan -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ReadOnlySpan units, -// double multiplicator, Span destination) => units.Mul(multiplicator, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ReadOnlySpan units, -// double multiplicator, Span destination) => units.Mul(multiplicator, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, -// ReadOnlySpan units, Span destination) => units.Mul(multiplicator, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, -// ReadOnlySpan units, Span destination) => units.Mul(multiplicator, destination); - -// // === Array === -// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static XXXXXXXX[] Mul( -// this XXXXXXXX[] units, double multiplicator) => units.Mul(multiplicator); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Mul( -// this XXXXXXXX?[] units, double multiplicator) => units.Mul(multiplicator); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX[] Mul( -// this double multiplicator, XXXXXXXX[] units) => units.Mul(multiplicator); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Mul( -// this double multiplicator, XXXXXXXX?[] units) => units.Mul(multiplicator); - -// // === List === -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Mul( -// this List units, double multiplicator) => units.Mul(multiplicator); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Mul( -// this List units, double multiplicator) => units.Mul(multiplicator); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Mul( -// this double multiplicator, List units) => units.Mul(multiplicator); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Mul( -// this double multiplicator, List units) => units.Mul(multiplicator); - -// // === ICollection === -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ICollection units, -// double multiplicator, Span destination) => units.Mul(multiplicator, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ICollection units, -// double multiplicator, Span destination) => units.Mul(multiplicator, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, -// ICollection units, Span destination) => units.Mul(multiplicator, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, -// ICollection units, Span destination) => units.Mul(multiplicator, destination); - -// // === IReadOnlyCollection === -// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Mul(this IReadOnlyCollection units, -// double multiplicator, Span destination) => units.Mul(multiplicator, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Mul(this IReadOnlyCollection units, -// double multiplicator, Span destination) => units.Mul(multiplicator, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, -// IReadOnlyCollection units, Span destination) => units.Mul(multiplicator, destination); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, -// IReadOnlyCollection units, Span destination) => units.Mul(multiplicator, destination); - -// // === IEnumerable === -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Mul( -// this IEnumerable units, double multiplicator) => units.Mul(multiplicator); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Mul( -// this IEnumerable units, double multiplicator) => units.Mul(multiplicator); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Mul( -// this double multiplicator, IEnumerable units) => units.Mul(multiplicator); -// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Mul( -// this double multiplicator, IEnumerable units) => units.Mul(multiplicator); - - - - - - -// // Sum Avg Max Min (не nullable) ========================================== - - -// // === ReadOnlySpan === SIMD -// public static XXXXXXXX Sum(this ReadOnlySpan units) => AggregateUnitExtensions.Sum(units); -// public static XXXXXXXX Avg(this ReadOnlySpan units) => AggregateUnitExtensions.Avg(units); -// public static XXXXXXXX Max(this ReadOnlySpan units) => AggregateUnitExtensions.Max(units); -// public static XXXXXXXX Min(this ReadOnlySpan units) => AggregateUnitExtensions.Min(units); - -// // === List === -// public static XXXXXXXX Sum(this List list) => AggregateUnitExtensions.Sum(list); -// public static XXXXXXXX Avg(this List list) => AggregateUnitExtensions.Avg(list); -// public static XXXXXXXX Max(this List list) => AggregateUnitExtensions.Max(list); -// public static XXXXXXXX Min(this List list) => AggregateUnitExtensions.Min(list); - -// // === ICollection === -// public static XXXXXXXX Sum(this ICollection collection) => AggregateUnitExtensions.Sum(collection); -// public static XXXXXXXX Avg(this ICollection collection) => AggregateUnitExtensions.Avg(collection); -// public static XXXXXXXX Max(this ICollection collection) => AggregateUnitExtensions.Max(collection); -// public static XXXXXXXX Min(this ICollection collection) => AggregateUnitExtensions.Min(collection); - -// // === IReadOnlyCollection === -// public static XXXXXXXX Sum(this IReadOnlyCollection collection) => AggregateUnitExtensions.Sum(collection); -// public static XXXXXXXX Avg(this IReadOnlyCollection collection) => AggregateUnitExtensions.Avg(collection); -// public static XXXXXXXX Max(this IReadOnlyCollection collection) => AggregateUnitExtensions.Max(collection); -// public static XXXXXXXX Min(this IReadOnlyCollection collection) => AggregateUnitExtensions.Min(collection); - - -// // === IEnumerable === -// public static XXXXXXXX Sum(this IEnumerable collection) => AggregateUnitExtensions.Sum(collection); -// public static XXXXXXXX Avg(this IEnumerable collection) => AggregateUnitExtensions.Avg(collection); -// public static XXXXXXXX Max(this IEnumerable collection) => AggregateUnitExtensions.Max(collection); -// public static XXXXXXXX Min(this IEnumerable collection) => AggregateUnitExtensions.Min(collection); - - - -// // Sum Avg Max Min (nullable) ========================================== - - -// // === ReadOnlySpan === -// public static XXXXXXXX Sum(this ReadOnlySpan units) => AggregateUnitExtensions.Sum(units); -// public static XXXXXXXX Avg(this ReadOnlySpan units) => AggregateUnitExtensions.Avg(units); -// public static XXXXXXXX Max(this ReadOnlySpan units) => AggregateUnitExtensions.Max(units); -// public static XXXXXXXX Min(this ReadOnlySpan units) => AggregateUnitExtensions.Min(units); - -// // === List === -// public static XXXXXXXX Sum(this List list) => AggregateUnitExtensions.Sum(list); -// public static XXXXXXXX Avg(this List list) => AggregateUnitExtensions.Avg(list); -// public static XXXXXXXX Max(this List list) => AggregateUnitExtensions.Max(list); -// public static XXXXXXXX Min(this List list) => AggregateUnitExtensions.Min(list); - -// // === ICollection === -// public static XXXXXXXX Sum(this ICollection collection) => AggregateUnitExtensions.Sum(collection); -// public static XXXXXXXX Avg(this ICollection collection) => AggregateUnitExtensions.Avg(collection); -// public static XXXXXXXX Max(this ICollection collection) => AggregateUnitExtensions.Max(collection); -// public static XXXXXXXX Min(this ICollection collection) => AggregateUnitExtensions.Min(collection); - -// // === IReadOnlyCollection === -// public static XXXXXXXX Sum(this IReadOnlyCollection collection) => AggregateUnitExtensions.Sum(collection); -// public static XXXXXXXX Avg(this IReadOnlyCollection collection) => AggregateUnitExtensions.Avg(collection); -// public static XXXXXXXX Max(this IReadOnlyCollection collection) => AggregateUnitExtensions.Max(collection); -// public static XXXXXXXX Min(this IReadOnlyCollection collection) => AggregateUnitExtensions.Min(collection); - -// // === IEnumerable === -// public static XXXXXXXX Sum(this IEnumerable collection) => AggregateUnitExtensions.Sum(collection); -// public static XXXXXXXX Avg(this IEnumerable collection) => AggregateUnitExtensions.Avg(collection); -// public static XXXXXXXX Max(this IEnumerable collection) => AggregateUnitExtensions.Max(collection); -// public static XXXXXXXX Min(this IEnumerable collection) => AggregateUnitExtensions.Min(collection); -//} \ No newline at end of file +namespace QWERTYkez.Mensura.Units; + +[JsonConverter(typeof(UnitJsonConverter))] +public readonly partial record struct XXXXXXXX : IMensuraUnit, IEquatable, IMensuraUnit +{ + [JsonInclude, DataMember, JsonPropertyName("v"), Obsolete] // для JSON / EF на случай сбоев, если пробелма с _Value + internal double Value { get => _Value; init => _Value = value; } + internal readonly double _Value; + internal XXXXXXXX(double value) => _Value = value; + + public override int GetHashCode() => _Value.GetHashCode(); + public int CompareTo(XXXXXXXX? other) => _Value.CompareTo(other is null ? 0d : other.Value._Value); + public int CompareTo(XXXXXXXX other) => _Value.CompareTo(other._Value); + + public bool Equals(XXXXXXXX? other) => _Value.Equals(other?._Value); + + + public static explicit operator XXXXXXXX(double val) => Unsafe.As(ref val); + public static explicit operator double(XXXXXXXX unit) => unit._Value; + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public XXXXXXXX Abs() => new(Math.Abs(_Value)); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal R Pow2_Internal() where R : struct, IMensuraUnit, IEquatable => (_Value * _Value).ToUnit(); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal R Sqrt_Internal() where R : struct, IMensuraUnit, IEquatable => Math.Sqrt(_Value).ToUnit(); + + + + [JsonIgnore, IgnoreDataMember] public bool IsPositive => _Value >= 0; + [JsonIgnore, IgnoreDataMember] public bool IsGreaterThanZero => _Value > 0; + [JsonIgnore, IgnoreDataMember] public bool IsNegative => double.IsNegative(_Value); + [JsonIgnore, IgnoreDataMember] public bool IsZero => _Value == 0; + [JsonIgnore, IgnoreDataMember] public bool IsNaN => double.IsNaN(_Value); + [JsonIgnore, IgnoreDataMember] public bool IsFinite => double.IsFinite(_Value); + [JsonIgnore, IgnoreDataMember] public bool IsInfinity => double.IsInfinity(_Value); + [JsonIgnore, IgnoreDataMember] public bool IsPositiveInfinity => double.IsPositiveInfinity(_Value); + [JsonIgnore, IgnoreDataMember] public bool IsNegativeInfinity => double.IsNegativeInfinity(_Value); + + + public static XXXXXXXX Zero { get; } = new(0d); + public static XXXXXXXX Min { get; } = new(double.MinValue); + public static XXXXXXXX Max { get; } = new(double.MaxValue); + public static XXXXXXXX NegativeInfinity { get; } = new(double.NegativeInfinity); + public static XXXXXXXX PositiveInfinity { get; } = new(double.PositiveInfinity); + + public static bool operator ==(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() == T2.Protected(); + public static bool operator !=(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() != T2.Protected(); + + public static bool operator <(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() < T2.Protected(); + public static bool operator <=(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() <= T2.Protected(); + public static bool operator >(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() > T2.Protected(); + public static bool operator >=(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() >= T2.Protected(); + + + public static XXXXXXXX operator +(XXXXXXXX T2) => new(+T2._Value); + public static XXXXXXXX operator +(XXXXXXXX T1, XXXXXXXX T2) => new(T1._Value + T2._Value); + public static XXXXXXXX operator -(XXXXXXXX T2) => new(-T2._Value); + public static XXXXXXXX operator -(XXXXXXXX T1, XXXXXXXX T2) => new(T1._Value - T2._Value); + + + // double + public static XXXXXXXX operator *(XXXXXXXX T1, double T2) => new(T1._Value * T2); + public static XXXXXXXX operator *(XXXXXXXX T1, double? T2) => T1 * (T2 ?? 0d); + public static XXXXXXXX operator *(double T1, XXXXXXXX T2) => new(T1 * T2._Value); + public static XXXXXXXX operator *(double? T1, XXXXXXXX T2) => (T1 ?? 0d) * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, double T2) => new(T1._Value / T2); + public static XXXXXXXX operator /(XXXXXXXX T1, double? T2) => T1 / (T2 ?? 0d); + public static double operator /(XXXXXXXX T1, XXXXXXXX T2) => T1._Value / T2._Value; + + // sbyte + public static XXXXXXXX operator *(XXXXXXXX T1, sbyte T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, sbyte? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(sbyte T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(sbyte? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, sbyte T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, sbyte? T2) => T1 / T2.ToDouble(); + + // short + public static XXXXXXXX operator *(XXXXXXXX T1, short T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, short? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(short T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(short? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, short T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, short? T2) => T1 / T2.ToDouble(); + + // int + public static XXXXXXXX operator *(XXXXXXXX T1, int T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, int? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(int T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(int? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, int T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, int? T2) => T1 / T2.ToDouble(); + + // long + public static XXXXXXXX operator *(XXXXXXXX T1, long T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, long? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(long T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(long? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, long T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, long? T2) => T1 / T2.ToDouble(); + + // byte + public static XXXXXXXX operator *(XXXXXXXX T1, byte T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, byte? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(byte T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(byte? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, byte T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, byte? T2) => T1 / T2.ToDouble(); + + // ushort + public static XXXXXXXX operator *(XXXXXXXX T1, ushort T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, ushort? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(ushort T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(ushort? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, ushort T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, ushort? T2) => T1 / T2.ToDouble(); + + // uint + public static XXXXXXXX operator *(XXXXXXXX T1, uint T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, uint? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(uint T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(uint? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, uint T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, uint? T2) => T1 / T2.ToDouble(); + + // ulong + public static XXXXXXXX operator *(XXXXXXXX T1, ulong T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, ulong? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(ulong T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(ulong? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, ulong T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, ulong? T2) => T1 / T2.ToDouble(); + + // nint + public static XXXXXXXX operator *(XXXXXXXX T1, nint T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, nint? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(nint T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(nint? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, nint T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, nint? T2) => T1 / T2.ToDouble(); + + // nuint + public static XXXXXXXX operator *(XXXXXXXX T1, nuint T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, nuint? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(nuint T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(nuint? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, nuint T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, nuint? T2) => T1 / T2.ToDouble(); + + // float + public static XXXXXXXX operator *(XXXXXXXX T1, float T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, float? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(float T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(float? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, float T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, float? T2) => T1 / T2.ToDouble(); + + // decimal + public static XXXXXXXX operator *(XXXXXXXX T1, decimal T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, decimal? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(decimal T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(decimal? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, decimal T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, decimal? T2) => T1 / T2.ToDouble(); + +#if NET7_0_OR_GREATER + // Int128 + public static XXXXXXXX operator *(XXXXXXXX T1, Int128 T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, Int128? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(Int128 T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(Int128? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, Int128 T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, Int128? T2) => T1 / T2.ToDouble(); + + // UInt128 + public static XXXXXXXX operator *(XXXXXXXX T1, UInt128 T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(XXXXXXXX T1, UInt128? T2) => T1 * T2.ToDouble(); + public static XXXXXXXX operator *(UInt128 T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator *(UInt128? T1, XXXXXXXX T2) => T1.ToDouble() * T2; + public static XXXXXXXX operator /(XXXXXXXX T1, UInt128 T2) => T1 / T2.ToDouble(); + public static XXXXXXXX operator /(XXXXXXXX T1, UInt128? T2) => T1 / T2.ToDouble(); +#endif + + + + + + + + public static XXXXXXXX[] operator +(XXXXXXXX[] T1, XXXXXXXX T2) => T1.Plus(T2._Value); + public static XXXXXXXX?[] operator +(XXXXXXXX?[] T1, XXXXXXXX T2) => T1.Plus(T2._Value); + public static XXXXXXXX[] operator +(XXXXXXXX T1, XXXXXXXX[] T2) => T1._Value.Plus(T2); + public static XXXXXXXX?[] operator +(XXXXXXXX T1, XXXXXXXX?[] T2) => T1._Value.Plus(T2); + public static XXXXXXXX[] operator +(XXXXXXXX[] T1, XXXXXXXX? T2) => T1.Plus(T2.Protected()); + public static XXXXXXXX?[] operator +(XXXXXXXX?[] T1, XXXXXXXX? T2) => T1.Plus(T2.Protected()); + public static XXXXXXXX[] operator +(XXXXXXXX? T1, XXXXXXXX[] T2) => T1.Protected().Plus(T2); + public static XXXXXXXX?[] operator +(XXXXXXXX? T1, XXXXXXXX?[] T2) => T1.Protected().Plus(T2); + + public static XXXXXXXX[] operator -(XXXXXXXX[] T1, XXXXXXXX T2) => T1.Minus(T2._Value); + public static XXXXXXXX?[] operator -(XXXXXXXX?[] T1, XXXXXXXX T2) => T1.Minus(T2._Value); + public static XXXXXXXX[] operator -(XXXXXXXX T1, XXXXXXXX[] T2) => T1._Value.Minus(T2); + public static XXXXXXXX?[] operator -(XXXXXXXX T1, XXXXXXXX?[] T2) => T1._Value.Minus(T2); + public static XXXXXXXX[] operator -(XXXXXXXX[] T1, XXXXXXXX? T2) => T1.Minus(T2.Protected()); + public static XXXXXXXX?[] operator -(XXXXXXXX?[] T1, XXXXXXXX? T2) => T1.Minus(T2.Protected()); + public static XXXXXXXX[] operator -(XXXXXXXX? T1, XXXXXXXX[] T2) => T1.Protected().Minus(T2); + public static XXXXXXXX?[] operator -(XXXXXXXX? T1, XXXXXXXX?[] T2) => T1.Protected().Minus(T2); + + public static double[] operator /(XXXXXXXX T1, XXXXXXXX[] T2) => T1.Div(T2); + public static double?[] operator /(XXXXXXXX T1, XXXXXXXX?[] T2) => T1.Div(T2); + public static double[] operator /(XXXXXXXX[] T1, XXXXXXXX T2) => T1.Div(T2); + public static double?[] operator /(XXXXXXXX?[] T1, XXXXXXXX T2) => T1.Div(T2); + public static double[] operator /(XXXXXXXX? T1, XXXXXXXX[] T2) => T1.ProtectedU().Div(T2); + public static double?[] operator /(XXXXXXXX? T1, XXXXXXXX?[] T2) => T1.ProtectedU().Div(T2); + public static double[] operator /(XXXXXXXX[] T1, XXXXXXXX? T2) => T1.Div(T2.ProtectedU()); + public static double?[] operator /(XXXXXXXX?[] T1, XXXXXXXX? T2) => T1.Div(T2.ProtectedU()); + + + // double + public static XXXXXXXX[] operator *(XXXXXXXX T1, double[] T2) => T1.Mul(T2); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, double?[] T2) => T1.Mul(T2); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, double[] T2) => T1.ProtectedU().Mul(T2); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, double?[] T2) => T1.ProtectedU().Mul(T2); + public static XXXXXXXX[] operator *(double[] T1, XXXXXXXX T2) => T1.Mul(T2); + public static XXXXXXXX?[] operator *(double?[] T1, XXXXXXXX T2) => T1.Mul(T2); + public static XXXXXXXX[] operator *(double[] T1, XXXXXXXX? T2) => T1.Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(double?[] T1, XXXXXXXX? T2) => T1.Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, double[] T2) => T1.Div(T2); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, double?[] T2) => T1.Div(T2); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, double[] T2) => T1.ProtectedU().Div(T2); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, double?[] T2) => T1.ProtectedU().Div(T2); + + // sbyte + public static XXXXXXXX[] operator *(XXXXXXXX T1, sbyte[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, sbyte?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, sbyte[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, sbyte?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(sbyte[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(sbyte?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(sbyte[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(sbyte?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, sbyte[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, sbyte?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, sbyte[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, sbyte?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // short + public static XXXXXXXX[] operator *(XXXXXXXX T1, short[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, short?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, short[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, short?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(short[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(short?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(short[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(short?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, short[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, short?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, short[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, short?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // int + public static XXXXXXXX[] operator *(XXXXXXXX T1, int[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, int?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, int[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, int?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(int[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(int?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(int[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(int?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, int[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, int?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, int[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, int?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // long + public static XXXXXXXX[] operator *(XXXXXXXX T1, long[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, long?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, long[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, long?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(long[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(long?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(long[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(long?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, long[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, long?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, long[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, long?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // byte + public static XXXXXXXX[] operator *(XXXXXXXX T1, byte[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, byte?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, byte[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, byte?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(byte[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(byte?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(byte[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(byte?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, byte[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, byte?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, byte[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, byte?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ushort + public static XXXXXXXX[] operator *(XXXXXXXX T1, ushort[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, ushort?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, ushort[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, ushort?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(ushort[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(ushort?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(ushort[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(ushort?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, ushort[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, ushort?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, ushort[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, ushort?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // uint + public static XXXXXXXX[] operator *(XXXXXXXX T1, uint[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, uint?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, uint[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, uint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(uint[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(uint?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(uint[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(uint?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, uint[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, uint?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, uint[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, uint?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ulong + public static XXXXXXXX[] operator *(XXXXXXXX T1, ulong[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, ulong?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, ulong[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, ulong?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(ulong[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(ulong?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(ulong[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(ulong?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, ulong[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, ulong?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, ulong[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, ulong?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nint + public static XXXXXXXX[] operator *(XXXXXXXX T1, nint[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, nint?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, nint[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, nint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(nint[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(nint?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(nint[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(nint?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, nint[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, nint?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, nint[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, nint?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nuint + public static XXXXXXXX[] operator *(XXXXXXXX T1, nuint[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, nuint?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, nuint[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, nuint?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(nuint[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(nuint?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(nuint[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(nuint?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, nuint[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, nuint?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, nuint[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, nuint?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // float + public static XXXXXXXX[] operator *(XXXXXXXX T1, float[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, float?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, float[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, float?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(float[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(float?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(float[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(float?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, float[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, float?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, float[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, float?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // decimal + public static XXXXXXXX[] operator *(XXXXXXXX T1, decimal[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, decimal?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, decimal[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, decimal?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(decimal[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(decimal?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(decimal[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(decimal?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, decimal[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, decimal?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, decimal[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, decimal?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + +#if NET7_0_OR_GREATER + // Int128 + public static XXXXXXXX[] operator *(XXXXXXXX T1, Int128[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, Int128?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, Int128[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, Int128?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(Int128[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(Int128?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(Int128[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(Int128?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, Int128[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, Int128?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, Int128[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, Int128?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // UInt128 + public static XXXXXXXX[] operator *(XXXXXXXX T1, UInt128[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX T1, UInt128?[] T2) => T1.Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(XXXXXXXX? T1, UInt128[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX?[] operator *(XXXXXXXX? T1, UInt128?[] T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static XXXXXXXX[] operator *(UInt128[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX?[] operator *(UInt128?[] T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static XXXXXXXX[] operator *(UInt128[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX?[] operator *(UInt128?[] T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static XXXXXXXX[] operator /(XXXXXXXX T1, UInt128[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX T1, UInt128?[] T2) => T1.Div(T2.ToDouble()); + public static XXXXXXXX[] operator /(XXXXXXXX? T1, UInt128[] T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static XXXXXXXX?[] operator /(XXXXXXXX? T1, UInt128?[] T2) => T1.ProtectedU().Div(T2.ToDouble()); +#endif + + + + + + + + public static List operator +(List T1, XXXXXXXX T2) => T1.Plus(T2._Value); + public static List operator +(List T1, XXXXXXXX T2) => T1.Plus(T2._Value); + public static List operator +(XXXXXXXX T1, List T2) => T1._Value.Plus(T2); + public static List operator +(XXXXXXXX T1, List T2) => T1._Value.Plus(T2); + public static List operator +(List T1, XXXXXXXX? T2) => T1.Plus(T2.Protected()); + public static List operator +(List T1, XXXXXXXX? T2) => T1.Plus(T2.Protected()); + public static List operator +(XXXXXXXX? T1, List T2) => T1.Protected().Plus(T2); + public static List operator +(XXXXXXXX? T1, List T2) => T1.Protected().Plus(T2); + + public static List operator -(List T1, XXXXXXXX T2) => T1.Minus(T2._Value); + public static List operator -(List T1, XXXXXXXX T2) => T1.Minus(T2._Value); + public static List operator -(XXXXXXXX T1, List T2) => T1._Value.Minus(T2); + public static List operator -(XXXXXXXX T1, List T2) => T1._Value.Minus(T2); + public static List operator -(List T1, XXXXXXXX? T2) => T1.Minus(T2.Protected()); + public static List operator -(List T1, XXXXXXXX? T2) => T1.Minus(T2.Protected()); + public static List operator -(XXXXXXXX? T1, List T2) => T1.Protected().Minus(T2); + public static List operator -(XXXXXXXX? T1, List T2) => T1.Protected().Minus(T2); + + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2); + public static List operator /(List T1, XXXXXXXX T2) => T1.Div(T2); + public static List operator /(List T1, XXXXXXXX T2) => T1.Div(T2); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2); + public static List operator /(List T1, XXXXXXXX? T2) => T1.Div(T2.ProtectedU()); + public static List operator /(List T1, XXXXXXXX? T2) => T1.Div(T2.ProtectedU()); + + + // double + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2); + + // sbyte + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // short + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // int + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // long + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // byte + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ushort + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // uint + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ulong + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nint + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nuint + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // float + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // decimal + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + +#if NET7_0_OR_GREATER + // Int128 + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // UInt128 + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX T1, List T2) => T1.Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(XXXXXXXX? T1, List T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator *(List T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX T1, List T2) => T1.Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static List operator /(XXXXXXXX? T1, List T2) => T1.ProtectedU().Div(T2.ToDouble()); +#endif + + + + + + + + public static IEnumerable operator +(IEnumerable T1, XXXXXXXX T2) => T1.Plus(T2._Value); + public static IEnumerable operator +(IEnumerable T1, XXXXXXXX T2) => T1.Plus(T2._Value); + public static IEnumerable operator +(XXXXXXXX T1, IEnumerable T2) => T1._Value.Plus(T2); + public static IEnumerable operator +(XXXXXXXX T1, IEnumerable T2) => T1._Value.Plus(T2); + public static IEnumerable operator +(IEnumerable T1, XXXXXXXX? T2) => T1.Plus(T2.Protected()); + public static IEnumerable operator +(IEnumerable T1, XXXXXXXX? T2) => T1.Plus(T2.Protected()); + public static IEnumerable operator +(XXXXXXXX? T1, IEnumerable T2) => T1.Protected().Plus(T2); + public static IEnumerable operator +(XXXXXXXX? T1, IEnumerable T2) => T1.Protected().Plus(T2); + + public static IEnumerable operator -(IEnumerable T1, XXXXXXXX T2) => T1.Minus(T2._Value); + public static IEnumerable operator -(IEnumerable T1, XXXXXXXX T2) => T1.Minus(T2._Value); + public static IEnumerable operator -(XXXXXXXX T1, IEnumerable T2) => T1._Value.Minus(T2); + public static IEnumerable operator -(XXXXXXXX T1, IEnumerable T2) => T1._Value.Minus(T2); + public static IEnumerable operator -(IEnumerable T1, XXXXXXXX? T2) => T1.Minus(T2.Protected()); + public static IEnumerable operator -(IEnumerable T1, XXXXXXXX? T2) => T1.Minus(T2.Protected()); + public static IEnumerable operator -(XXXXXXXX? T1, IEnumerable T2) => T1.Protected().Minus(T2); + public static IEnumerable operator -(XXXXXXXX? T1, IEnumerable T2) => T1.Protected().Minus(T2); + + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2); + public static IEnumerable operator /(IEnumerable T1, XXXXXXXX T2) => T1.Div(T2); + public static IEnumerable operator /(IEnumerable T1, XXXXXXXX T2) => T1.Div(T2); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2); + public static IEnumerable operator /(IEnumerable T1, XXXXXXXX? T2) => T1.Div(T2.ProtectedU()); + public static IEnumerable operator /(IEnumerable T1, XXXXXXXX? T2) => T1.Div(T2.ProtectedU()); + + + // double + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2); + + // sbyte + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // short + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // int + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // long + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // byte + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ushort + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // uint + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // ulong + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nint + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // nuint + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // float + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // decimal + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + +#if NET7_0_OR_GREATER + // Int128 + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + + // UInt128 + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX T1, IEnumerable T2) => T1.Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Mul(T2.ToDouble()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX T2) => T1.ToDouble().Mul(T2); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator *(IEnumerable T1, XXXXXXXX? T2) => T1.ToDouble().Mul(T2.ProtectedU()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX T1, IEnumerable T2) => T1.Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); + public static IEnumerable operator /(XXXXXXXX? T1, IEnumerable T2) => T1.ProtectedU().Div(T2.ToDouble()); +#endif +} + +public static class XXXXXXXXExtensions +{ + internal static double Protected(this XXXXXXXX? unit) => unit is null ? 0d : unit.Value._Value; + internal static XXXXXXXX ProtectedU(this XXXXXXXX? unit) => unit is null ? XXXXXXXX.Zero : unit.Value; + + + + + + + // === ReadOnlySpan + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ReadOnlySpan units, + double divisor, Span destination) => units.Div(divisor, destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ReadOnlySpan units, + double divisor, Span destination) => units.Div(divisor, destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, + ReadOnlySpan units, Span destination) => dividend.Div(units, destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, + ReadOnlySpan units, Span destination) => dividend.Div(units, destination); + + // === Array === + [MethodImpl(MethodImplOptions.AggressiveInlining)]public static XXXXXXXX[] Div( + this XXXXXXXX[] units, double divisor) => units.Div(divisor); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Div( + this XXXXXXXX?[] units, double divisor) => units.Div(divisor); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX[] Div( + this double dividend, XXXXXXXX[] units) => dividend.Div(units); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Div( + this double dividend, XXXXXXXX?[] units) => dividend.Div(units); + + // === List === + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Div( + this List units, double divisor) => units.Div(divisor); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Div( + this List units, double divisor) => units.Div(divisor); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Div( + this double dividend, List units) => dividend.Div(units); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Div( + this double dividend, List units) => dividend.Div(units); + + // === IReadOnlyCollection === + [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Div(this IReadOnlyCollection units, + double divisor, Span destination) => units.Div(divisor, destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Div(this IReadOnlyCollection units, + double divisor, Span destination) => units.Div(divisor, destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, + IReadOnlyCollection units, Span destination) => dividend.Div(units, destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend, + IReadOnlyCollection units, Span destination) => dividend.Div(units, destination); + + // === IEnumerable === + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Div( + this IEnumerable units, double divisor) => units.Div(divisor); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Div( + this IEnumerable units, double divisor) => units.Div(divisor); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Div( + this double dividend, IEnumerable units) => dividend.Div(units); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Div( + this double dividend, IEnumerable units) => dividend.Div(units); + + + + + + + // === ReadOnlySpan + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ReadOnlySpan units, + double multiplicator, Span destination) => units.Mul(multiplicator, destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ReadOnlySpan units, + double multiplicator, Span destination) => units.Mul(multiplicator, destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, + ReadOnlySpan units, Span destination) => units.Mul(multiplicator, destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, + ReadOnlySpan units, Span destination) => units.Mul(multiplicator, destination); + + // === Array === + [MethodImpl(MethodImplOptions.AggressiveInlining)]public static XXXXXXXX[] Mul( + this XXXXXXXX[] units, double multiplicator) => units.Mul(multiplicator); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Mul( + this XXXXXXXX?[] units, double multiplicator) => units.Mul(multiplicator); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX[] Mul( + this double multiplicator, XXXXXXXX[] units) => units.Mul(multiplicator); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Mul( + this double multiplicator, XXXXXXXX?[] units) => units.Mul(multiplicator); + + // === List === + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Mul( + this List units, double multiplicator) => units.Mul(multiplicator); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Mul( + this List units, double multiplicator) => units.Mul(multiplicator); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Mul( + this double multiplicator, List units) => units.Mul(multiplicator); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List Mul( + this double multiplicator, List units) => units.Mul(multiplicator); + + // === IReadOnlyCollection === + [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Mul(this IReadOnlyCollection units, + double multiplicator, Span destination) => units.Mul(multiplicator, destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Mul(this IReadOnlyCollection units, + double multiplicator, Span destination) => units.Mul(multiplicator, destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, + IReadOnlyCollection units, Span destination) => units.Mul(multiplicator, destination); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator, + IReadOnlyCollection units, Span destination) => units.Mul(multiplicator, destination); + + // === IEnumerable === + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Mul( + this IEnumerable units, double multiplicator) => units.Mul(multiplicator); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Mul( + this IEnumerable units, double multiplicator) => units.Mul(multiplicator); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Mul( + this double multiplicator, IEnumerable units) => units.Mul(multiplicator); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable Mul( + this double multiplicator, IEnumerable units) => units.Mul(multiplicator); + + + + + + + // Sum Avg Max Min (не nullable) ========================================== + + + // === ReadOnlySpan === SIMD + public static XXXXXXXX Sum(this ReadOnlySpan units) => AggregateUnitExtensions.Sum(units); + public static XXXXXXXX Avg(this ReadOnlySpan units) => AggregateUnitExtensions.Avg(units); + public static XXXXXXXX Max(this ReadOnlySpan units) => AggregateUnitExtensions.Max(units); + public static XXXXXXXX Min(this ReadOnlySpan units) => AggregateUnitExtensions.Min(units); + + // === List === + public static XXXXXXXX Sum(this List list) => AggregateUnitExtensions.Sum(list); + public static XXXXXXXX Avg(this List list) => AggregateUnitExtensions.Avg(list); + public static XXXXXXXX Max(this List list) => AggregateUnitExtensions.Max(list); + public static XXXXXXXX Min(this List list) => AggregateUnitExtensions.Min(list); + + // === IReadOnlyCollection === + public static XXXXXXXX Sum(this IReadOnlyCollection collection) => AggregateUnitExtensions.Sum(collection); + public static XXXXXXXX Avg(this IReadOnlyCollection collection) => AggregateUnitExtensions.Avg(collection); + public static XXXXXXXX Max(this IReadOnlyCollection collection) => AggregateUnitExtensions.Max(collection); + public static XXXXXXXX Min(this IReadOnlyCollection collection) => AggregateUnitExtensions.Min(collection); + + + // === IEnumerable === + public static XXXXXXXX Sum(this IEnumerable collection) => AggregateUnitExtensions.Sum(collection); + public static XXXXXXXX Avg(this IEnumerable collection) => AggregateUnitExtensions.Avg(collection); + public static XXXXXXXX Max(this IEnumerable collection) => AggregateUnitExtensions.Max(collection); + public static XXXXXXXX Min(this IEnumerable collection) => AggregateUnitExtensions.Min(collection); + + + + // Sum Avg Max Min (nullable) ========================================== + + + // === ReadOnlySpan === + public static XXXXXXXX Sum(this ReadOnlySpan units) => AggregateUnitExtensions.Sum(units); + public static XXXXXXXX Avg(this ReadOnlySpan units) => AggregateUnitExtensions.Avg(units); + public static XXXXXXXX Max(this ReadOnlySpan units) => AggregateUnitExtensions.Max(units); + public static XXXXXXXX Min(this ReadOnlySpan units) => AggregateUnitExtensions.Min(units); + + // === List === + public static XXXXXXXX Sum(this List list) => AggregateUnitExtensions.Sum(list); + public static XXXXXXXX Avg(this List list) => AggregateUnitExtensions.Avg(list); + public static XXXXXXXX Max(this List list) => AggregateUnitExtensions.Max(list); + public static XXXXXXXX Min(this List list) => AggregateUnitExtensions.Min(list); + + // === IReadOnlyCollection === + public static XXXXXXXX Sum(this IReadOnlyCollection collection) => AggregateUnitExtensions.Sum(collection); + public static XXXXXXXX Avg(this IReadOnlyCollection collection) => AggregateUnitExtensions.Avg(collection); + public static XXXXXXXX Max(this IReadOnlyCollection collection) => AggregateUnitExtensions.Max(collection); + public static XXXXXXXX Min(this IReadOnlyCollection collection) => AggregateUnitExtensions.Min(collection); + + // === IEnumerable === + public static XXXXXXXX Sum(this IEnumerable collection) => AggregateUnitExtensions.Sum(collection); + public static XXXXXXXX Avg(this IEnumerable collection) => AggregateUnitExtensions.Avg(collection); + public static XXXXXXXX Max(this IEnumerable collection) => AggregateUnitExtensions.Max(collection); + public static XXXXXXXX Min(this IEnumerable collection) => AggregateUnitExtensions.Min(collection); +} \ No newline at end of file diff --git a/QWERTYkez.Mensura/Units/XXXXXXXX.Ref.cs b/QWERTYkez.Mensura/Units/XXXXXXXX.Ref.cs index f348d84..e7357ec 100644 --- a/QWERTYkez.Mensura/Units/XXXXXXXX.Ref.cs +++ b/QWERTYkez.Mensura/Units/XXXXXXXX.Ref.cs @@ -1,70 +1,70 @@ -//#if DEBUG -//namespace QWERTYkez.Mensura.Units; +#if DEBUG +namespace QWERTYkez.Mensura.Units; -///// -///// Base value is MilliMeters -///// -//[DebuggerDisplay("mm = {_MilliMeters.ToString(\"0.###\")}, m = {Meters.ToString(\"0.###\")}")] -//public readonly partial record struct XXXXXXXX -//{ -// public static XXXXXXXX MilliMeter { get; } = new(1); -// [NotMapped, JsonIgnore, IgnoreDataMember] public double _MilliMeters { get => _Value; init => _Value = value; } +/// +/// Base value is MilliMeters +/// +[DebuggerDisplay("mm = {_MilliMeters.ToString(\"0.###\")}, m = {Meters.ToString(\"0.###\")}")] +public readonly partial record struct XXXXXXXX +{ + public static XXXXXXXX MilliMeter { get; } = new(1); + [NotMapped, JsonIgnore, IgnoreDataMember] public double _MilliMeters { get => _Value; init => _Value = value; } -// public static XXXXXXXX CentiMeter { get; } = new(XXXXXXXXConv.CentiMeters.To(1)); -// [NotMapped, JsonIgnore, IgnoreDataMember] -// public double CentiMeters -// { -// get => XXXXXXXXConv.CentiMeters.From(_Value); -// init -// { -// _Value = XXXXXXXXConv.CentiMeters.To(value); -// } -// } + public static XXXXXXXX CentiMeter { get; } = new(XXXXXXXXConv.CentiMeters.To(1)); + [NotMapped, JsonIgnore, IgnoreDataMember] + public double CentiMeters + { + get => XXXXXXXXConv.CentiMeters.From(_Value); + init + { + _Value = XXXXXXXXConv.CentiMeters.To(value); + } + } -// public static XXXXXXXX DeciMeter { get; } = new(XXXXXXXXConv.DeciMeters.To(1)); -// [NotMapped, JsonIgnore, IgnoreDataMember] -// public double DeciMeters -// { -// get => XXXXXXXXConv.DeciMeters.From(_Value); -// init => _Value = XXXXXXXXConv.DeciMeters.To(value); -// } + public static XXXXXXXX DeciMeter { get; } = new(XXXXXXXXConv.DeciMeters.To(1)); + [NotMapped, JsonIgnore, IgnoreDataMember] + public double DeciMeters + { + get => XXXXXXXXConv.DeciMeters.From(_Value); + init => _Value = XXXXXXXXConv.DeciMeters.To(value); + } -// public static XXXXXXXX Meter { get; } = new(XXXXXXXXConv.Meters.To(1)); -// [NotMapped, JsonIgnore, IgnoreDataMember] -// public double Meters -// { -// get => XXXXXXXXConv.Meters.From(_Value); -// init => _Value = XXXXXXXXConv.Meters.To(value); -// } + public static XXXXXXXX Meter { get; } = new(XXXXXXXXConv.Meters.To(1)); + [NotMapped, JsonIgnore, IgnoreDataMember] + public double Meters + { + get => XXXXXXXXConv.Meters.From(_Value); + init => _Value = XXXXXXXXConv.Meters.To(value); + } -// public static XXXXXXXX KiloMeter { get; } = new(XXXXXXXXConv.KiloMeters.To(1)); -// [NotMapped, JsonIgnore, IgnoreDataMember] -// public double KiloMeters -// { -// get => XXXXXXXXConv.KiloMeters.From(_Value); -// init => _Value = XXXXXXXXConv.KiloMeters.To(value); -// } + public static XXXXXXXX KiloMeter { get; } = new(XXXXXXXXConv.KiloMeters.To(1)); + [NotMapped, JsonIgnore, IgnoreDataMember] + public double KiloMeters + { + get => XXXXXXXXConv.KiloMeters.From(_Value); + init => _Value = XXXXXXXXConv.KiloMeters.To(value); + } -// public XXXXXXXX AddMilliMeters(double value) => new(_Value + value); -// public XXXXXXXX AddCentiMeters(double value) => new(_Value + XXXXXXXXConv.CentiMeters.To(value)); -// public XXXXXXXX AddDeciMeters(double value) => new(_Value + XXXXXXXXConv.DeciMeters.To(value)); -// public XXXXXXXX AddMeters(double value) => new(_Value + XXXXXXXXConv.Meters.To(value)); -// public XXXXXXXX AddKiloMeters(double value) => new(_Value + XXXXXXXXConv.KiloMeters.To(value)); -//} + public XXXXXXXX AddMilliMeters(double value) => new(_Value + value); + public XXXXXXXX AddCentiMeters(double value) => new(_Value + XXXXXXXXConv.CentiMeters.To(value)); + public XXXXXXXX AddDeciMeters(double value) => new(_Value + XXXXXXXXConv.DeciMeters.To(value)); + public XXXXXXXX AddMeters(double value) => new(_Value + XXXXXXXXConv.Meters.To(value)); + public XXXXXXXX AddKiloMeters(double value) => new(_Value + XXXXXXXXConv.KiloMeters.To(value)); +} -//internal readonly struct XXXXXXXXConv -//{ -// private XXXXXXXXConv(double multiplicator) => this.Multiplicator = multiplicator; -// public double To(double value) => value * Multiplicator; -// public double From(double value) => value / Multiplicator; -// public double Multiplicator { get; init; } -// public static XXXXXXXXConv MilliMeters { get; } = new(1); -// public static XXXXXXXXConv CentiMeters { get; } = new(10); -// public static XXXXXXXXConv DeciMeters { get; } = new(100); -// public static XXXXXXXXConv Meters { get; } = new(1000); -// public static XXXXXXXXConv KiloMeters { get; } = new(1000000); -//} -//#endif \ No newline at end of file +internal readonly struct XXXXXXXXConv +{ + private XXXXXXXXConv(double multiplicator) => this.Multiplicator = multiplicator; + public double To(double value) => value * Multiplicator; + public double From(double value) => value / Multiplicator; + public double Multiplicator { get; init; } + public static XXXXXXXXConv MilliMeters { get; } = new(1); + public static XXXXXXXXConv CentiMeters { get; } = new(10); + public static XXXXXXXXConv DeciMeters { get; } = new(100); + public static XXXXXXXXConv Meters { get; } = new(1000); + public static XXXXXXXXConv KiloMeters { get; } = new(1000000); +} +#endif \ No newline at end of file