Tests
This commit is contained in:
@@ -1,10 +1,4 @@
|
|||||||
using Microsoft.CodeAnalysis;
|
namespace G;
|
||||||
using Microsoft.CodeAnalysis.CSharp;
|
|
||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
||||||
using Microsoft.CodeAnalysis.Text;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace G;
|
|
||||||
|
|
||||||
[Generator]
|
[Generator]
|
||||||
public class ComplexUnitGenerator : IIncrementalGenerator
|
public class ComplexUnitGenerator : IIncrementalGenerator
|
||||||
@@ -20,7 +14,7 @@ public class ComplexUnitGenerator : IIncrementalGenerator
|
|||||||
namespace QWERTYkez.Mensura
|
namespace QWERTYkez.Mensura
|
||||||
{
|
{
|
||||||
[System.AttributeUsage(System.AttributeTargets.Struct, AllowMultiple = false)]
|
[System.AttributeUsage(System.AttributeTargets.Struct, AllowMultiple = false)]
|
||||||
public sealed class ComplexUnitGeneratorAttribute : System.Attribute
|
internal sealed class ComplexUnitGeneratorAttribute : System.Attribute
|
||||||
{
|
{
|
||||||
public string TypeNameA { get; }
|
public string TypeNameA { get; }
|
||||||
public string TypeNameB { get; }
|
public string TypeNameB { get; }
|
||||||
@@ -49,12 +43,45 @@ namespace QWERTYkez.Mensura
|
|||||||
// 3. Регистрируем вывод для каждой найденной структуры
|
// 3. Регистрируем вывод для каждой найденной структуры
|
||||||
context.RegisterSourceOutput(structsProvider, (spc, structs) =>
|
context.RegisterSourceOutput(structsProvider, (spc, structs) =>
|
||||||
{
|
{
|
||||||
|
// Ваш оригинальный цикл генерации комплексных структур
|
||||||
foreach (var structInfo in structs)
|
foreach (var structInfo in structs)
|
||||||
{
|
{
|
||||||
string generatedCode = GeneratePartial(structInfo.TypeName, structInfo.Namespace,
|
string generatedCode = GeneratePartial(structInfo.TypeName, structInfo.Namespace,
|
||||||
structInfo.TypeNameA, structInfo.TypeNameB, structInfo.TypeNameZ);
|
structInfo.TypeNameA, structInfo.TypeNameB, structInfo.TypeNameZ);
|
||||||
spc.AddSource($"{structInfo.TypeName}.g.cs", SourceText.From(generatedCode, Encoding.UTF8));
|
spc.AddSource($"{structInfo.TypeName}.g.cs", SourceText.From(generatedCode, Encoding.UTF8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- ТОТ САМЫЙ КОД УСЛОВНОЙ ГЕНЕРАЦИИ БИНДЕРА ---
|
||||||
|
bool isMainAssembly = false;
|
||||||
|
var firstStruct = structs.FirstOrDefault();
|
||||||
|
if (firstStruct.TypeNameZ != null)
|
||||||
|
{
|
||||||
|
// Если пространство имен содержит "Tests", флаг останется false
|
||||||
|
if (firstStruct.Namespace.StartsWith("QWERTYkez.Mensura") && !firstStruct.Namespace.Contains("Tests"))
|
||||||
|
{
|
||||||
|
isMainAssembly = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Генерируем файл ТОЛЬКО для основного проекта
|
||||||
|
if (isMainAssembly)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine("namespace QWERTYkez.Mensura;");
|
||||||
|
sb.AppendLine("internal static partial class MensuraBinder");
|
||||||
|
sb.AppendLine("{");
|
||||||
|
sb.AppendLine(" [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]");
|
||||||
|
sb.AppendLine(" static partial void AddGeneratedComplexConverters(System.Collections.IList converters)");
|
||||||
|
sb.AppendLine(" {");
|
||||||
|
foreach (var structInfo in structs)
|
||||||
|
{
|
||||||
|
sb.AppendLine($" converters.Add(new QWERTYkez.Mensura.MensuraBinder.NewtonsoftRegistrar.NewtonsoftUnitConverter<QWERTYkez.Mensura.Units.{structInfo.TypeNameZ}>());");
|
||||||
|
}
|
||||||
|
sb.AppendLine(" }");
|
||||||
|
sb.AppendLine("}");
|
||||||
|
|
||||||
|
spc.AddSource(".ComplexUnits.MensuraBinder.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +176,7 @@ using System.Runtime.Serialization;
|
|||||||
|
|
||||||
namespace QWERTYkez.Mensura.Units;
|
namespace QWERTYkez.Mensura.Units;
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonConverter(typeof(NewtonsoftUnitConverter<{typeNameZ}>)), JsonConverter(typeof(UnitJsonConverter<{typeNameZ}>))]
|
[JsonConverter(typeof(UnitJsonConverter<{typeNameZ}>))]
|
||||||
public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, IEquatable<{typeNameZ}>, IMensuraUnit
|
public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, IEquatable<{typeNameZ}>, IMensuraUnit
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -202,13 +229,13 @@ public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, I
|
|||||||
|
|
||||||
// === Array ===
|
// === Array ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator
|
||||||
*({typeNameB}[] units, {typeNameZ} multiplicator) => units.Multiply<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
*({typeNameB}[] units, {typeNameZ} multiplicator) => units.Mul<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator
|
||||||
*({typeNameB}?[] units, {typeNameZ} multiplicator) => units.Multiply<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
*({typeNameB}?[] units, {typeNameZ} multiplicator) => units.Mul<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator
|
||||||
*({typeNameZ} multiplicator, {typeNameB}[] units) => units.Multiply<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
*({typeNameZ} multiplicator, {typeNameB}[] units) => units.Mul<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator
|
||||||
*({typeNameZ} multiplicator, {typeNameB}?[] units) => units.Multiply<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
*({typeNameZ} multiplicator, {typeNameB}?[] units) => units.Mul<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator *({typeNameB}[] units, {typeNameZ}? multiplicator) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator *({typeNameB}[] units, {typeNameZ}? multiplicator) =>
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new {typeNameA}[units.Length]);
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new {typeNameA}[units.Length]);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator *({typeNameB}?[] units, {typeNameZ}? multiplicator) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator *({typeNameB}?[] units, {typeNameZ}? multiplicator) =>
|
||||||
@@ -220,13 +247,13 @@ public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, I
|
|||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator
|
||||||
*(List<{typeNameB}> units, {typeNameZ} multiplicator) => units.Multiply<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
*(List<{typeNameB}> units, {typeNameZ} multiplicator) => units.Mul<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator
|
||||||
*(List<{typeNameB}?> units, {typeNameZ} multiplicator) => units.Multiply<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
*(List<{typeNameB}?> units, {typeNameZ} multiplicator) => units.Mul<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator
|
||||||
*({typeNameZ} multiplicator, List<{typeNameB}> units) => units.Multiply<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
*({typeNameZ} multiplicator, List<{typeNameB}> units) => units.Mul<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator
|
||||||
*({typeNameZ} multiplicator, List<{typeNameB}?> units) => units.Multiply<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
*({typeNameZ} multiplicator, List<{typeNameB}?> units) => units.Mul<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator *(List<{typeNameB}> units, {typeNameZ}? multiplicator) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator *(List<{typeNameB}> units, {typeNameZ}? multiplicator) =>
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<{typeNameA}>(units.Count));
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<{typeNameA}>(units.Count));
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator *(List<{typeNameB}?> units, {typeNameZ}? multiplicator) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator *(List<{typeNameB}?> units, {typeNameZ}? multiplicator) =>
|
||||||
@@ -238,13 +265,13 @@ public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, I
|
|||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator
|
||||||
*(IEnumerable<{typeNameB}> units, {typeNameZ} multiplicator) => units.Multiply<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
*(IEnumerable<{typeNameB}> units, {typeNameZ} multiplicator) => units.Mul<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator
|
||||||
*(IEnumerable<{typeNameB}?> units, {typeNameZ} multiplicator) => units.Multiply<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
*(IEnumerable<{typeNameB}?> units, {typeNameZ} multiplicator) => units.Mul<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator
|
||||||
*({typeNameZ} multiplicator, IEnumerable<{typeNameB}> units) => units.Multiply<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
*({typeNameZ} multiplicator, IEnumerable<{typeNameB}> units) => units.Mul<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator
|
||||||
*({typeNameZ} multiplicator, IEnumerable<{typeNameB}?> units) => units.Multiply<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
*({typeNameZ} multiplicator, IEnumerable<{typeNameB}?> units) => units.Mul<{typeNameB}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator *(IEnumerable<{typeNameB}> units, {typeNameZ}? multiplicator) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator *(IEnumerable<{typeNameB}> units, {typeNameZ}? multiplicator) =>
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => new {typeNameA}(0d)));
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => new {typeNameA}(0d)));
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator *(IEnumerable<{typeNameB}?> units, {typeNameZ}? multiplicator) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator *(IEnumerable<{typeNameB}?> units, {typeNameZ}? multiplicator) =>
|
||||||
@@ -261,13 +288,13 @@ public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, I
|
|||||||
|
|
||||||
// === Array ===
|
// === Array ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator
|
||||||
/({typeNameA}[] units, {typeNameZ} divisor) => units.Divide<{typeNameA}, {typeNameB}>(divisor._Value);
|
/({typeNameA}[] units, {typeNameZ} divisor) => units.Div<{typeNameA}, {typeNameB}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator
|
||||||
/({typeNameA}?[] units, {typeNameZ} divisor) => units.Divide<{typeNameA}, {typeNameB}>(divisor._Value);
|
/({typeNameA}?[] units, {typeNameZ} divisor) => units.Div<{typeNameA}, {typeNameB}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator
|
||||||
/({typeNameZ} dividend, {typeNameA}[] units) => dividend._Value.Divide<{typeNameA}, {typeNameB}>(units);
|
/({typeNameZ} dividend, {typeNameA}[] units) => dividend._Value.Div<{typeNameA}, {typeNameB}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator
|
||||||
/({typeNameZ} dividend, {typeNameA}?[] units) => dividend._Value.Divide<{typeNameA}, {typeNameB}>(units);
|
/({typeNameZ} dividend, {typeNameA}?[] units) => dividend._Value.Div<{typeNameA}, {typeNameB}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator /({typeNameA}[] units, {typeNameZ}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator /({typeNameA}[] units, {typeNameZ}? divisor) =>
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameB}[units.Length]);
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameB}[units.Length]);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator /({typeNameA}?[] units, {typeNameZ}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator /({typeNameA}?[] units, {typeNameZ}? divisor) =>
|
||||||
@@ -279,13 +306,13 @@ public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, I
|
|||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator
|
||||||
/(List<{typeNameA}> units, {typeNameZ} divisor) => units.Divide<{typeNameA}, {typeNameB}>(divisor._Value);
|
/(List<{typeNameA}> units, {typeNameZ} divisor) => units.Div<{typeNameA}, {typeNameB}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator
|
||||||
/(List<{typeNameA}?> units, {typeNameZ} divisor) => units.Divide<{typeNameA}, {typeNameB}>(divisor._Value);
|
/(List<{typeNameA}?> units, {typeNameZ} divisor) => units.Div<{typeNameA}, {typeNameB}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator
|
||||||
/({typeNameZ} dividend, List<{typeNameA}> units) => dividend._Value.Divide<{typeNameA}, {typeNameB}>(units);
|
/({typeNameZ} dividend, List<{typeNameA}> units) => dividend._Value.Div<{typeNameA}, {typeNameB}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator
|
||||||
/({typeNameZ} dividend, List<{typeNameA}?> units) => dividend._Value.Divide<{typeNameA}, {typeNameB}>(units);
|
/({typeNameZ} dividend, List<{typeNameA}?> units) => dividend._Value.Div<{typeNameA}, {typeNameB}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator /(List<{typeNameA}> units, {typeNameZ}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator /(List<{typeNameA}> units, {typeNameZ}? divisor) =>
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameB}>(units.Count));
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameB}>(units.Count));
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator /(List<{typeNameA}?> units, {typeNameZ}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator /(List<{typeNameA}?> units, {typeNameZ}? divisor) =>
|
||||||
@@ -297,13 +324,13 @@ public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, I
|
|||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator
|
||||||
/(IEnumerable<{typeNameA}> units, {typeNameZ} divisor) => units.Divide<{typeNameA}, {typeNameB}>(divisor._Value);
|
/(IEnumerable<{typeNameA}> units, {typeNameZ} divisor) => units.Div<{typeNameA}, {typeNameB}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator
|
||||||
/(IEnumerable<{typeNameA}?> units, {typeNameZ} divisor) => units.Divide<{typeNameA}, {typeNameB}>(divisor._Value);
|
/(IEnumerable<{typeNameA}?> units, {typeNameZ} divisor) => units.Div<{typeNameA}, {typeNameB}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator
|
||||||
/({typeNameZ} dividend, IEnumerable<{typeNameA}> units) => dividend._Value.Divide<{typeNameA}, {typeNameB}>(units);
|
/({typeNameZ} dividend, IEnumerable<{typeNameA}> units) => dividend._Value.Div<{typeNameA}, {typeNameB}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator
|
||||||
/({typeNameZ} dividend, IEnumerable<{typeNameA}?> units) => dividend._Value.Divide<{typeNameA}, {typeNameB}>(units);
|
/({typeNameZ} dividend, IEnumerable<{typeNameA}?> units) => dividend._Value.Div<{typeNameA}, {typeNameB}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator /(IEnumerable<{typeNameA}> units, {typeNameZ}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator /(IEnumerable<{typeNameA}> units, {typeNameZ}? divisor) =>
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameB}(0d)));
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameB}(0d)));
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator /(IEnumerable<{typeNameA}?> units, {typeNameZ}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator /(IEnumerable<{typeNameA}?> units, {typeNameZ}? divisor) =>
|
||||||
@@ -314,23 +341,357 @@ public readonly partial record struct {typeNameZ} : IMensuraUnit<{typeNameZ}>, I
|
|||||||
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameB}?)null : new {typeNameB}(0d)));
|
dividend.HasValue ? units / dividend.Value : (units is null ? null! : units.Select(u => u is null ? ({typeNameB}?)null : new {typeNameB}(0d)));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static class {typeNameZ}Extensions
|
public static class {typeNameZ}Extensions
|
||||||
{
|
{
|
||||||
public static double Protected(this {typeNameZ}? unit) => unit is null ? 0d : unit.Value._Value;
|
internal static double Protected(this {typeNameZ}? unit) => unit is null ? 0d : unit.Value._Value;
|
||||||
internal static double ToDouble(this {typeNameB}? unit) => unit?._Value ?? 0d;
|
internal static double ToDouble(this {typeNameB}? unit) => unit?._Value ?? 0d;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// === ReadOnlySpan
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ReadOnlySpan<{typeNameZ}> units,
|
||||||
|
double divisor, Span<{typeNameZ}> destination) => units.Div<{typeNameZ}>(divisor, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ReadOnlySpan<{typeNameZ}?> units,
|
||||||
|
double divisor, Span<{typeNameZ}?> destination) => units.Div<{typeNameZ}>(divisor, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
ReadOnlySpan<{typeNameZ}> units, Span<{typeNameZ}> destination) => dividend.Div<{typeNameZ}>(units, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
ReadOnlySpan<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => dividend.Div<{typeNameZ}>(units, destination);
|
||||||
|
|
||||||
|
// === Array ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static {typeNameZ}[] Div(
|
||||||
|
this {typeNameZ}[] units, double divisor) => units.Div<{typeNameZ}>(divisor);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] Div(
|
||||||
|
this {typeNameZ}?[] units, double divisor) => units.Div<{typeNameZ}>(divisor);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] Div(
|
||||||
|
this double dividend, {typeNameZ}[] units) => dividend.Div<{typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] Div(
|
||||||
|
this double dividend, {typeNameZ}?[] units) => dividend.Div<{typeNameZ}>(units);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> Div(
|
||||||
|
this List<{typeNameZ}> units, double divisor) => units.Div<{typeNameZ}>(divisor);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Div(
|
||||||
|
this List<{typeNameZ}?> units, double divisor) => units.Div<{typeNameZ}>(divisor);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> Div(
|
||||||
|
this double dividend, List<{typeNameZ}> units) => dividend.Div<{typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Div(
|
||||||
|
this double dividend, List<{typeNameZ}?> units) => dividend.Div<{typeNameZ}>(units);
|
||||||
|
|
||||||
|
// === ICollection<T> ===
|
||||||
|
[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<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Div(this IReadOnlyCollection<{typeNameZ}> units,
|
||||||
|
double divisor, Span<{typeNameZ}> destination) => units.Div<{typeNameZ}>(divisor, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Div(this IReadOnlyCollection<{typeNameZ}?> units,
|
||||||
|
double divisor, Span<{typeNameZ}?> destination) => units.Div<{typeNameZ}>(divisor, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
IReadOnlyCollection<{typeNameZ}> units, Span<{typeNameZ}> destination) => dividend.Div<{typeNameZ}>(units, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
IReadOnlyCollection<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => dividend.Div<{typeNameZ}>(units, destination);
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> Div(
|
||||||
|
this IEnumerable<{typeNameZ}> units, double divisor) => units.Div<{typeNameZ}>(divisor);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> Div(
|
||||||
|
this IEnumerable<{typeNameZ}?> units, double divisor) => units.Div<{typeNameZ}>(divisor);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> Div(
|
||||||
|
this double dividend, IEnumerable<{typeNameZ}> units) => dividend.Div<{typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> Div(
|
||||||
|
this double dividend, IEnumerable<{typeNameZ}?> units) => dividend.Div<{typeNameZ}>(units);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// === ReadOnlySpan
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ReadOnlySpan<{typeNameZ}> units,
|
||||||
|
double subtrahend, Span<{typeNameZ}> destination) => units.Minus<{typeNameZ}>(subtrahend, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ReadOnlySpan<{typeNameZ}?> units,
|
||||||
|
double subtrahend, Span<{typeNameZ}?> destination) => units.Minus<{typeNameZ}>(subtrahend, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
ReadOnlySpan<{typeNameZ}> units, Span<{typeNameZ}> destination) => minuend.Minus<{typeNameZ}>(units, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
ReadOnlySpan<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => minuend.Minus<{typeNameZ}>(units, destination);
|
||||||
|
|
||||||
|
// === Array ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static {typeNameZ}[] Minus(
|
||||||
|
this {typeNameZ}[] units, double subtrahend) => units.Minus<{typeNameZ}>(subtrahend);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] Minus(
|
||||||
|
this {typeNameZ}?[] units, double subtrahend) => units.Minus<{typeNameZ}>(subtrahend);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] Minus(
|
||||||
|
this double minuend, {typeNameZ}[] units) => minuend.Minus<{typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] Minus(
|
||||||
|
this double minuend, {typeNameZ}?[] units) => minuend.Minus<{typeNameZ}>(units);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> Minus(
|
||||||
|
this List<{typeNameZ}> units, double subtrahend) => units.Minus<{typeNameZ}>(subtrahend);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Minus(
|
||||||
|
this List<{typeNameZ}?> units, double subtrahend) => units.Minus<{typeNameZ}>(subtrahend);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> Minus(
|
||||||
|
this double minuend, List<{typeNameZ}> units) => minuend.Minus<{typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Minus(
|
||||||
|
this double minuend, List<{typeNameZ}?> units) => minuend.Minus<{typeNameZ}>(units);
|
||||||
|
|
||||||
|
// === ICollection<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ICollection<{typeNameZ}> units,
|
||||||
|
double subtrahend, Span<{typeNameZ}> destination) => units.Minus<{typeNameZ}>(subtrahend, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ICollection<{typeNameZ}?> units,
|
||||||
|
double subtrahend, Span<{typeNameZ}?> destination) => units.Minus<{typeNameZ}>(subtrahend, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
ICollection<{typeNameZ}> units, Span<{typeNameZ}> destination) => minuend.Minus<{typeNameZ}>(units, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
ICollection<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => minuend.Minus<{typeNameZ}>(units, destination);
|
||||||
|
|
||||||
|
// === IReadOnlyCollection<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Minus(this IReadOnlyCollection<{typeNameZ}> units,
|
||||||
|
double subtrahend, Span<{typeNameZ}> destination) => units.Minus<{typeNameZ}>(subtrahend, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Minus(this IReadOnlyCollection<{typeNameZ}?> units,
|
||||||
|
double subtrahend, Span<{typeNameZ}?> destination) => units.Minus<{typeNameZ}>(subtrahend, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
IReadOnlyCollection<{typeNameZ}> units, Span<{typeNameZ}> destination) => minuend.Minus<{typeNameZ}>(units, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
IReadOnlyCollection<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => minuend.Minus<{typeNameZ}>(units, destination);
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> Minus(
|
||||||
|
this IEnumerable<{typeNameZ}> units, double subtrahend) => units.Minus<{typeNameZ}>(subtrahend);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> Minus(
|
||||||
|
this IEnumerable<{typeNameZ}?> units, double subtrahend) => units.Minus<{typeNameZ}>(subtrahend);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> Minus(
|
||||||
|
this double minuend, IEnumerable<{typeNameZ}> units) => minuend.Minus<{typeNameZ}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> Minus(
|
||||||
|
this double minuend, IEnumerable<{typeNameZ}?> units) => minuend.Minus<{typeNameZ}>(units);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// === ReadOnlySpan
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ReadOnlySpan<{typeNameZ}> units,
|
||||||
|
double multiplicator, Span<{typeNameZ}> destination) => units.Mul<{typeNameZ}>(multiplicator, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ReadOnlySpan<{typeNameZ}?> units,
|
||||||
|
double multiplicator, Span<{typeNameZ}?> destination) => units.Mul<{typeNameZ}>(multiplicator, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
ReadOnlySpan<{typeNameZ}> units, Span<{typeNameZ}> destination) => units.Mul<{typeNameZ}>(multiplicator, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
ReadOnlySpan<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => units.Mul<{typeNameZ}>(multiplicator, destination);
|
||||||
|
|
||||||
|
// === Array ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static {typeNameZ}[] Mul(
|
||||||
|
this {typeNameZ}[] units, double multiplicator) => units.Mul<{typeNameZ}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] Mul(
|
||||||
|
this {typeNameZ}?[] units, double multiplicator) => units.Mul<{typeNameZ}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] Mul(
|
||||||
|
this double multiplicator, {typeNameZ}[] units) => units.Mul<{typeNameZ}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] Mul(
|
||||||
|
this double multiplicator, {typeNameZ}?[] units) => units.Mul<{typeNameZ}>(multiplicator);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> Mul(
|
||||||
|
this List<{typeNameZ}> units, double multiplicator) => units.Mul<{typeNameZ}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Mul(
|
||||||
|
this List<{typeNameZ}?> units, double multiplicator) => units.Mul<{typeNameZ}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> Mul(
|
||||||
|
this double multiplicator, List<{typeNameZ}> units) => units.Mul<{typeNameZ}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Mul(
|
||||||
|
this double multiplicator, List<{typeNameZ}?> units) => units.Mul<{typeNameZ}>(multiplicator);
|
||||||
|
|
||||||
|
// === ICollection<T> ===
|
||||||
|
[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<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Mul(this IReadOnlyCollection<{typeNameZ}> units,
|
||||||
|
double multiplicator, Span<{typeNameZ}> destination) => units.Mul<{typeNameZ}>(multiplicator, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Mul(this IReadOnlyCollection<{typeNameZ}?> units,
|
||||||
|
double multiplicator, Span<{typeNameZ}?> destination) => units.Mul<{typeNameZ}>(multiplicator, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
IReadOnlyCollection<{typeNameZ}> units, Span<{typeNameZ}> destination) => units.Mul<{typeNameZ}>(multiplicator, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
IReadOnlyCollection<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => units.Mul<{typeNameZ}>(multiplicator, destination);
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> Mul(
|
||||||
|
this IEnumerable<{typeNameZ}> units, double multiplicator) => units.Mul<{typeNameZ}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> Mul(
|
||||||
|
this IEnumerable<{typeNameZ}?> units, double multiplicator) => units.Mul<{typeNameZ}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> Mul(
|
||||||
|
this double multiplicator, IEnumerable<{typeNameZ}> units) => units.Mul<{typeNameZ}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> Mul(
|
||||||
|
this double multiplicator, IEnumerable<{typeNameZ}?> units) => units.Mul<{typeNameZ}>(multiplicator);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// === ReadOnlySpan
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ReadOnlySpan<{typeNameZ}> units,
|
||||||
|
double summand, Span<{typeNameZ}> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ReadOnlySpan<{typeNameZ}?> units,
|
||||||
|
double summand, Span<{typeNameZ}?> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
ReadOnlySpan<{typeNameZ}> units, Span<{typeNameZ}> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
ReadOnlySpan<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||||
|
|
||||||
|
// === Array ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static {typeNameZ}[] Plus(
|
||||||
|
this {typeNameZ}[] units, double summand) => units.Plus<{typeNameZ}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] Plus(
|
||||||
|
this {typeNameZ}?[] units, double summand) => units.Plus<{typeNameZ}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] Plus(
|
||||||
|
this double summand, {typeNameZ}[] units) => units.Plus<{typeNameZ}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] Plus(
|
||||||
|
this double summand, {typeNameZ}?[] units) => units.Plus<{typeNameZ}>(summand);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> Plus(
|
||||||
|
this List<{typeNameZ}> units, double summand) => units.Plus<{typeNameZ}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Plus(
|
||||||
|
this List<{typeNameZ}?> units, double summand) => units.Plus<{typeNameZ}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> Plus(
|
||||||
|
this double summand, List<{typeNameZ}> units) => units.Plus<{typeNameZ}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> Plus(
|
||||||
|
this double summand, List<{typeNameZ}?> units) => units.Plus<{typeNameZ}>(summand);
|
||||||
|
|
||||||
|
// === ICollection<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ICollection<{typeNameZ}> units,
|
||||||
|
double summand, Span<{typeNameZ}> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ICollection<{typeNameZ}?> units,
|
||||||
|
double summand, Span<{typeNameZ}?> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
ICollection<{typeNameZ}> units, Span<{typeNameZ}> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
ICollection<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||||
|
|
||||||
|
// === IReadOnlyCollection<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Plus(this IReadOnlyCollection<{typeNameZ}> units,
|
||||||
|
double summand, Span<{typeNameZ}> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Plus(this IReadOnlyCollection<{typeNameZ}?> units,
|
||||||
|
double summand, Span<{typeNameZ}?> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
IReadOnlyCollection<{typeNameZ}> units, Span<{typeNameZ}> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
IReadOnlyCollection<{typeNameZ}?> units, Span<{typeNameZ}?> destination) => units.Plus<{typeNameZ}>(summand, destination);
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> Plus(
|
||||||
|
this IEnumerable<{typeNameZ}> units, double summand) => units.Plus<{typeNameZ}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> Plus(
|
||||||
|
this IEnumerable<{typeNameZ}?> units, double summand) => units.Plus<{typeNameZ}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> Plus(
|
||||||
|
this double summand, IEnumerable<{typeNameZ}> units) => units.Plus<{typeNameZ}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> Plus(
|
||||||
|
this double summand, IEnumerable<{typeNameZ}?> units) => units.Plus<{typeNameZ}>(summand);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Sum Average Max Min (не nullable) ==========================================
|
||||||
|
|
||||||
|
|
||||||
|
// === ReadOnlySpan === SIMD
|
||||||
|
public static {typeNameZ} Sum(this ReadOnlySpan<{typeNameZ}> units) => AggregateUnitExtensions.Sum(units);
|
||||||
|
public static {typeNameZ} Average(this ReadOnlySpan<{typeNameZ}> units) => AggregateUnitExtensions.Average(units);
|
||||||
|
public static {typeNameZ} Max(this ReadOnlySpan<{typeNameZ}> units) => AggregateUnitExtensions.Max(units);
|
||||||
|
public static {typeNameZ} Min(this ReadOnlySpan<{typeNameZ}> units) => AggregateUnitExtensions.Min(units);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
public static {typeNameZ} Sum(this List<{typeNameZ}> list) => AggregateUnitExtensions.Sum(list);
|
||||||
|
public static {typeNameZ} Average(this List<{typeNameZ}> list) => AggregateUnitExtensions.Average(list);
|
||||||
|
public static {typeNameZ} Max(this List<{typeNameZ}> list) => AggregateUnitExtensions.Max(list);
|
||||||
|
public static {typeNameZ} Min(this List<{typeNameZ}> list) => AggregateUnitExtensions.Min(list);
|
||||||
|
|
||||||
|
// === ICollection<T> ===
|
||||||
|
public static {typeNameZ} Sum(this ICollection<{typeNameZ}> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
public static {typeNameZ} Average(this ICollection<{typeNameZ}> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
public static {typeNameZ} Max(this ICollection<{typeNameZ}> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
public static {typeNameZ} Min(this ICollection<{typeNameZ}> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
// === IReadOnlyCollection<T> ===
|
||||||
|
public static {typeNameZ} Sum(this IReadOnlyCollection<{typeNameZ}> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
public static {typeNameZ} Average(this IReadOnlyCollection<{typeNameZ}> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
public static {typeNameZ} Max(this IReadOnlyCollection<{typeNameZ}> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
public static {typeNameZ} Min(this IReadOnlyCollection<{typeNameZ}> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
public static {typeNameZ} Sum(this IEnumerable<{typeNameZ}> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
public static {typeNameZ} Average(this IEnumerable<{typeNameZ}> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
public static {typeNameZ} Max(this IEnumerable<{typeNameZ}> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
public static {typeNameZ} Min(this IEnumerable<{typeNameZ}> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Sum Average Max Min (nullable) ==========================================
|
||||||
|
|
||||||
|
|
||||||
|
// === ReadOnlySpan ===
|
||||||
|
public static {typeNameZ} Sum(this ReadOnlySpan<{typeNameZ}?> units) => AggregateUnitExtensions.Sum(units);
|
||||||
|
public static {typeNameZ} Average(this ReadOnlySpan<{typeNameZ}?> units) => AggregateUnitExtensions.Average(units);
|
||||||
|
public static {typeNameZ} Max(this ReadOnlySpan<{typeNameZ}?> units) => AggregateUnitExtensions.Max(units);
|
||||||
|
public static {typeNameZ} Min(this ReadOnlySpan<{typeNameZ}?> units) => AggregateUnitExtensions.Min(units);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
public static {typeNameZ} Sum(this List<{typeNameZ}?> list) => AggregateUnitExtensions.Sum(list);
|
||||||
|
public static {typeNameZ} Average(this List<{typeNameZ}?> list) => AggregateUnitExtensions.Average(list);
|
||||||
|
public static {typeNameZ} Max(this List<{typeNameZ}?> list) => AggregateUnitExtensions.Max(list);
|
||||||
|
public static {typeNameZ} Min(this List<{typeNameZ}?> list) => AggregateUnitExtensions.Min(list);
|
||||||
|
|
||||||
|
// === ICollection<T> ===
|
||||||
|
public static {typeNameZ} Sum(this ICollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
public static {typeNameZ} Average(this ICollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
public static {typeNameZ} Max(this ICollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
public static {typeNameZ} Min(this ICollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
// === IReadOnlyCollection<T> ===
|
||||||
|
public static {typeNameZ} Sum(this IReadOnlyCollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
public static {typeNameZ} Average(this IReadOnlyCollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
public static {typeNameZ} Max(this IReadOnlyCollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
public static {typeNameZ} Min(this IReadOnlyCollection<{typeNameZ}?> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
public static {typeNameZ} Sum(this IEnumerable<{typeNameZ}?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
public static {typeNameZ} Average(this IEnumerable<{typeNameZ}?> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
public static {typeNameZ} Max(this IEnumerable<{typeNameZ}?> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
public static {typeNameZ} Min(this IEnumerable<{typeNameZ}?> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly partial record struct {typeNameA}
|
public readonly partial record struct {typeNameA}
|
||||||
{
|
{
|
||||||
// === Array ===
|
// === Array ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator
|
||||||
/({typeNameZ}[] units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
/({typeNameZ}[] units, {typeNameA} divisor) => units.Div<{typeNameZ}, {typeNameB}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator
|
||||||
/({typeNameZ}?[] units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
/({typeNameZ}?[] units, {typeNameA} divisor) => units.Div<{typeNameZ}, {typeNameB}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator
|
||||||
/({typeNameA} dividend, {typeNameZ}[] units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
/({typeNameA} dividend, {typeNameZ}[] units) => dividend._Value.Div<{typeNameZ}, {typeNameB}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator
|
||||||
/({typeNameA} dividend, {typeNameZ}?[] units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
/({typeNameA} dividend, {typeNameZ}?[] units) => dividend._Value.Div<{typeNameZ}, {typeNameB}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator /({typeNameZ}[] units, {typeNameA}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}[] operator /({typeNameZ}[] units, {typeNameA}? divisor) =>
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameB}[units.Length]);
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameB}[units.Length]);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator /({typeNameZ}?[] units, {typeNameA}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameB}?[] operator /({typeNameZ}?[] units, {typeNameA}? divisor) =>
|
||||||
@@ -342,13 +703,13 @@ public readonly partial record struct {typeNameA}
|
|||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator
|
||||||
/(List<{typeNameZ}> units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
/(List<{typeNameZ}> units, {typeNameA} divisor) => units.Div<{typeNameZ}, {typeNameB}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator
|
||||||
/(List<{typeNameZ}?> units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
/(List<{typeNameZ}?> units, {typeNameA} divisor) => units.Div<{typeNameZ}, {typeNameB}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator
|
||||||
/({typeNameA} dividend, List<{typeNameZ}> units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
/({typeNameA} dividend, List<{typeNameZ}> units) => dividend._Value.Div<{typeNameZ}, {typeNameB}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator
|
||||||
/({typeNameA} dividend, List<{typeNameZ}?> units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
/({typeNameA} dividend, List<{typeNameZ}?> units) => dividend._Value.Div<{typeNameZ}, {typeNameB}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator /(List<{typeNameZ}> units, {typeNameA}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}> operator /(List<{typeNameZ}> units, {typeNameA}? divisor) =>
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameB}>(units.Count));
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameB}>(units.Count));
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator /(List<{typeNameZ}?> units, {typeNameA}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameB}?> operator /(List<{typeNameZ}?> units, {typeNameA}? divisor) =>
|
||||||
@@ -360,13 +721,13 @@ public readonly partial record struct {typeNameA}
|
|||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator
|
||||||
/(IEnumerable<{typeNameZ}> units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
/(IEnumerable<{typeNameZ}> units, {typeNameA} divisor) => units.Div<{typeNameZ}, {typeNameB}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator
|
||||||
/(IEnumerable<{typeNameZ}?> units, {typeNameA} divisor) => units.Divide<{typeNameZ}, {typeNameB}>(divisor._Value);
|
/(IEnumerable<{typeNameZ}?> units, {typeNameA} divisor) => units.Div<{typeNameZ}, {typeNameB}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator
|
||||||
/({typeNameA} dividend, IEnumerable<{typeNameZ}> units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
/({typeNameA} dividend, IEnumerable<{typeNameZ}> units) => dividend._Value.Div<{typeNameZ}, {typeNameB}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator
|
||||||
/({typeNameA} dividend, IEnumerable<{typeNameZ}?> units) => dividend._Value.Divide<{typeNameZ}, {typeNameB}>(units);
|
/({typeNameA} dividend, IEnumerable<{typeNameZ}?> units) => dividend._Value.Div<{typeNameZ}, {typeNameB}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator /(IEnumerable<{typeNameZ}> units, {typeNameA}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}> operator /(IEnumerable<{typeNameZ}> units, {typeNameA}? divisor) =>
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameB}(0d)));
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameB}(0d)));
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator /(IEnumerable<{typeNameZ}?> units, {typeNameA}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameB}?> operator /(IEnumerable<{typeNameZ}?> units, {typeNameA}? divisor) =>
|
||||||
@@ -386,13 +747,13 @@ public readonly partial record struct {typeNameA}
|
|||||||
|
|
||||||
// === Array ===
|
// === Array ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
||||||
/({typeNameB}[] units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
/({typeNameB}[] units, {typeNameA} divisor) => units.Div<{typeNameB}, {typeNameZ}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
||||||
/({typeNameB}?[] units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
/({typeNameB}?[] units, {typeNameA} divisor) => units.Div<{typeNameB}, {typeNameZ}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
||||||
/({typeNameA} dividend, {typeNameB}[] units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
/({typeNameA} dividend, {typeNameB}[] units) => dividend._Value.Div<{typeNameB}, {typeNameZ}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
||||||
/({typeNameA} dividend, {typeNameB}?[] units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
/({typeNameA} dividend, {typeNameB}?[] units) => dividend._Value.Div<{typeNameB}, {typeNameZ}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator /({typeNameB}[] units, {typeNameA}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator /({typeNameB}[] units, {typeNameA}? divisor) =>
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameZ}[units.Length]);
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameZ}[units.Length]);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator /({typeNameB}?[] units, {typeNameA}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator /({typeNameB}?[] units, {typeNameA}? divisor) =>
|
||||||
@@ -404,13 +765,13 @@ public readonly partial record struct {typeNameA}
|
|||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
||||||
/(List<{typeNameB}> units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
/(List<{typeNameB}> units, {typeNameA} divisor) => units.Div<{typeNameB}, {typeNameZ}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
||||||
/(List<{typeNameB}?> units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
/(List<{typeNameB}?> units, {typeNameA} divisor) => units.Div<{typeNameB}, {typeNameZ}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
||||||
/({typeNameA} dividend, List<{typeNameB}> units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
/({typeNameA} dividend, List<{typeNameB}> units) => dividend._Value.Div<{typeNameB}, {typeNameZ}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
||||||
/({typeNameA} dividend, List<{typeNameB}?> units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
/({typeNameA} dividend, List<{typeNameB}?> units) => dividend._Value.Div<{typeNameB}, {typeNameZ}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator /(List<{typeNameB}> units, {typeNameA}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator /(List<{typeNameB}> units, {typeNameA}? divisor) =>
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameZ}>(units.Count));
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameZ}>(units.Count));
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator /(List<{typeNameB}?> units, {typeNameA}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator /(List<{typeNameB}?> units, {typeNameA}? divisor) =>
|
||||||
@@ -422,13 +783,13 @@ public readonly partial record struct {typeNameA}
|
|||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
||||||
/(IEnumerable<{typeNameB}> units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
/(IEnumerable<{typeNameB}> units, {typeNameA} divisor) => units.Div<{typeNameB}, {typeNameZ}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
||||||
/(IEnumerable<{typeNameB}?> units, {typeNameA} divisor) => units.Divide<{typeNameB}, {typeNameZ}>(divisor._Value);
|
/(IEnumerable<{typeNameB}?> units, {typeNameA} divisor) => units.Div<{typeNameB}, {typeNameZ}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
||||||
/({typeNameA} dividend, IEnumerable<{typeNameB}> units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
/({typeNameA} dividend, IEnumerable<{typeNameB}> units) => dividend._Value.Div<{typeNameB}, {typeNameZ}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
||||||
/({typeNameA} dividend, IEnumerable<{typeNameB}?> units) => dividend._Value.Divide<{typeNameB}, {typeNameZ}>(units);
|
/({typeNameA} dividend, IEnumerable<{typeNameB}?> units) => dividend._Value.Div<{typeNameB}, {typeNameZ}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator /(IEnumerable<{typeNameB}> units, {typeNameA}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator /(IEnumerable<{typeNameB}> units, {typeNameA}? divisor) =>
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameZ}(0d)));
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameZ}(0d)));
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator /(IEnumerable<{typeNameB}?> units, {typeNameA}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator /(IEnumerable<{typeNameB}?> units, {typeNameA}? divisor) =>
|
||||||
@@ -449,13 +810,13 @@ public readonly partial record struct {typeNameB}
|
|||||||
|
|
||||||
// === Array ===
|
// === Array ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator
|
||||||
*({typeNameZ}[] units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
*({typeNameZ}[] units, {typeNameB} multiplicator) => units.Mul<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator
|
||||||
*({typeNameZ}?[] units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
*({typeNameZ}?[] units, {typeNameB} multiplicator) => units.Mul<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator
|
||||||
*({typeNameB} multiplicator, {typeNameZ}[] units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
*({typeNameB} multiplicator, {typeNameZ}[] units) => units.Mul<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator
|
||||||
*({typeNameB} multiplicator, {typeNameZ}?[] units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
*({typeNameB} multiplicator, {typeNameZ}?[] units) => units.Mul<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator *({typeNameZ}[] units, {typeNameB}? multiplicator) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}[] operator *({typeNameZ}[] units, {typeNameB}? multiplicator) =>
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new {typeNameA}[units.Length]);
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new {typeNameA}[units.Length]);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator *({typeNameZ}?[] units, {typeNameB}? multiplicator) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameA}?[] operator *({typeNameZ}?[] units, {typeNameB}? multiplicator) =>
|
||||||
@@ -467,13 +828,13 @@ public readonly partial record struct {typeNameB}
|
|||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator
|
||||||
*(List<{typeNameZ}> units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
*(List<{typeNameZ}> units, {typeNameB} multiplicator) => units.Mul<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator
|
||||||
*(List<{typeNameZ}?> units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
*(List<{typeNameZ}?> units, {typeNameB} multiplicator) => units.Mul<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator
|
||||||
*({typeNameB} multiplicator, List<{typeNameZ}> units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
*({typeNameB} multiplicator, List<{typeNameZ}> units) => units.Mul<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator
|
||||||
*({typeNameB} multiplicator, List<{typeNameZ}?> units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
*({typeNameB} multiplicator, List<{typeNameZ}?> units) => units.Mul<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator *(List<{typeNameZ}> units, {typeNameB}? multiplicator) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}> operator *(List<{typeNameZ}> units, {typeNameB}? multiplicator) =>
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<{typeNameA}>(units.Count));
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<{typeNameA}>(units.Count));
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator *(List<{typeNameZ}?> units, {typeNameB}? multiplicator) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameA}?> operator *(List<{typeNameZ}?> units, {typeNameB}? multiplicator) =>
|
||||||
@@ -485,13 +846,13 @@ public readonly partial record struct {typeNameB}
|
|||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator
|
||||||
*(IEnumerable<{typeNameZ}> units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
*(IEnumerable<{typeNameZ}> units, {typeNameB} multiplicator) => units.Mul<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator
|
||||||
*(IEnumerable<{typeNameZ}?> units, {typeNameB} multiplicator) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
*(IEnumerable<{typeNameZ}?> units, {typeNameB} multiplicator) => units.Mul<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator
|
||||||
*({typeNameB} multiplicator, IEnumerable<{typeNameZ}> units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
*({typeNameB} multiplicator, IEnumerable<{typeNameZ}> units) => units.Mul<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator
|
||||||
*({typeNameB} multiplicator, IEnumerable<{typeNameZ}?> units) => units.Multiply<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
*({typeNameB} multiplicator, IEnumerable<{typeNameZ}?> units) => units.Mul<{typeNameZ}, {typeNameA}>(multiplicator._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator *(IEnumerable<{typeNameZ}> units, {typeNameB}? multiplicator) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}> operator *(IEnumerable<{typeNameZ}> units, {typeNameB}? multiplicator) =>
|
||||||
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => new {typeNameA}(0d)));
|
multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => new {typeNameA}(0d)));
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator *(IEnumerable<{typeNameZ}?> units, {typeNameB}? multiplicator) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameA}?> operator *(IEnumerable<{typeNameZ}?> units, {typeNameB}? multiplicator) =>
|
||||||
@@ -511,13 +872,13 @@ public readonly partial record struct {typeNameB}
|
|||||||
|
|
||||||
// === Array ===
|
// === Array ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
||||||
/({typeNameA}[] units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
/({typeNameA}[] units, {typeNameB} divisor) => units.Div<{typeNameA}, {typeNameZ}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
||||||
/({typeNameA}?[] units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
/({typeNameA}?[] units, {typeNameB} divisor) => units.Div<{typeNameA}, {typeNameZ}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator
|
||||||
/({typeNameB} dividend, {typeNameA}[] units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
/({typeNameB} dividend, {typeNameA}[] units) => dividend._Value.Div<{typeNameA}, {typeNameZ}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator
|
||||||
/({typeNameB} dividend, {typeNameA}?[] units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
/({typeNameB} dividend, {typeNameA}?[] units) => dividend._Value.Div<{typeNameA}, {typeNameZ}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator /({typeNameA}[] units, {typeNameB}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}[] operator /({typeNameA}[] units, {typeNameB}? divisor) =>
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameZ}[units.Length]);
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new {typeNameZ}[units.Length]);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator /({typeNameA}?[] units, {typeNameB}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeNameZ}?[] operator /({typeNameA}?[] units, {typeNameB}? divisor) =>
|
||||||
@@ -529,13 +890,13 @@ public readonly partial record struct {typeNameB}
|
|||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
||||||
/(List<{typeNameA}> units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
/(List<{typeNameA}> units, {typeNameB} divisor) => units.Div<{typeNameA}, {typeNameZ}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
||||||
/(List<{typeNameA}?> units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
/(List<{typeNameA}?> units, {typeNameB} divisor) => units.Div<{typeNameA}, {typeNameZ}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator
|
||||||
/({typeNameB} dividend, List<{typeNameA}> units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
/({typeNameB} dividend, List<{typeNameA}> units) => dividend._Value.Div<{typeNameA}, {typeNameZ}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator
|
||||||
/({typeNameB} dividend, List<{typeNameA}?> units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
/({typeNameB} dividend, List<{typeNameA}?> units) => dividend._Value.Div<{typeNameA}, {typeNameZ}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator /(List<{typeNameA}> units, {typeNameB}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}> operator /(List<{typeNameA}> units, {typeNameB}? divisor) =>
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameZ}>(units.Count));
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<{typeNameZ}>(units.Count));
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator /(List<{typeNameA}?> units, {typeNameB}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeNameZ}?> operator /(List<{typeNameA}?> units, {typeNameB}? divisor) =>
|
||||||
@@ -547,13 +908,13 @@ public readonly partial record struct {typeNameB}
|
|||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
||||||
/(IEnumerable<{typeNameA}> units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
/(IEnumerable<{typeNameA}> units, {typeNameB} divisor) => units.Div<{typeNameA}, {typeNameZ}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
||||||
/(IEnumerable<{typeNameA}?> units, {typeNameB} divisor) => units.Divide<{typeNameA}, {typeNameZ}>(divisor._Value);
|
/(IEnumerable<{typeNameA}?> units, {typeNameB} divisor) => units.Div<{typeNameA}, {typeNameZ}>(divisor._Value);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator
|
||||||
/({typeNameB} dividend, IEnumerable<{typeNameA}> units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
/({typeNameB} dividend, IEnumerable<{typeNameA}> units) => dividend._Value.Div<{typeNameA}, {typeNameZ}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator
|
||||||
/({typeNameB} dividend, IEnumerable<{typeNameA}?> units) => dividend._Value.Divide<{typeNameA}, {typeNameZ}>(units);
|
/({typeNameB} dividend, IEnumerable<{typeNameA}?> units) => dividend._Value.Div<{typeNameA}, {typeNameZ}>(units);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator /(IEnumerable<{typeNameA}> units, {typeNameB}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}> operator /(IEnumerable<{typeNameA}> units, {typeNameB}? divisor) =>
|
||||||
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameZ}(0d)));
|
divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new {typeNameZ}(0d)));
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator /(IEnumerable<{typeNameA}?> units, {typeNameB}? divisor) =>
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeNameZ}?> operator /(IEnumerable<{typeNameA}?> units, {typeNameB}? divisor) =>
|
||||||
|
|||||||
@@ -1,11 +1,4 @@
|
|||||||
using Microsoft.CodeAnalysis;
|
namespace G
|
||||||
using Microsoft.CodeAnalysis.CSharp;
|
|
||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
||||||
using Microsoft.CodeAnalysis.Text;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace G
|
|
||||||
{
|
{
|
||||||
[Generator(LanguageNames.CSharp)]
|
[Generator(LanguageNames.CSharp)]
|
||||||
public class OperatorsGenerator : IIncrementalGenerator
|
public class OperatorsGenerator : IIncrementalGenerator
|
||||||
@@ -16,7 +9,7 @@ using System;
|
|||||||
namespace QWERTYkez.Mensura
|
namespace QWERTYkez.Mensura
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
|
||||||
public sealed class OperatorsGeneratorAttribute : Attribute
|
internal sealed class OperatorsGeneratorAttribute : Attribute
|
||||||
{
|
{
|
||||||
public string CoeffName { get; }
|
public string CoeffName { get; }
|
||||||
|
|
||||||
@@ -158,16 +151,16 @@ namespace {info.Namespace};
|
|||||||
|
|
||||||
public readonly partial record struct {info.LeftType}
|
public readonly partial record struct {info.LeftType}
|
||||||
{{
|
{{
|
||||||
public static {info.ReturnType}[] operator *({info.LeftType} left, {info.RightType}[] right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * left._Value)" : "left._Value")}.Multiply<{info.RightType}, {info.ReturnType}>(right);
|
public static {info.ReturnType}[] operator *({info.LeftType} left, {info.RightType}[] right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * left._Value)" : "left._Value")}.Mul<{info.RightType}, {info.ReturnType}>(right);
|
||||||
public static List<{info.ReturnType}> operator *({info.LeftType} left, List<{info.RightType}> right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * left._Value)" : "left._Value")}.Multiply<{info.RightType}, {info.ReturnType}>(right);
|
public static List<{info.ReturnType}> operator *({info.LeftType} left, List<{info.RightType}> right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * left._Value)" : "left._Value")}.Mul<{info.RightType}, {info.ReturnType}>(right);
|
||||||
public static IEnumerable<{info.ReturnType}> operator *({info.LeftType} left, IEnumerable<{info.RightType}> right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * left._Value)" : "left._Value")}.Multiply<{info.RightType}, {info.ReturnType}>(right);
|
public static IEnumerable<{info.ReturnType}> operator *({info.LeftType} left, IEnumerable<{info.RightType}> right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * left._Value)" : "left._Value")}.Mul<{info.RightType}, {info.ReturnType}>(right);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
public readonly partial record struct {info.RightType}
|
public readonly partial record struct {info.RightType}
|
||||||
{{
|
{{
|
||||||
public static {info.ReturnType}[] operator *({info.LeftType}[] left, {info.RightType} right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * right._Value)" : "right._Value")}.Multiply<{info.LeftType}, {info.ReturnType}>(left);
|
public static {info.ReturnType}[] operator *({info.LeftType}[] left, {info.RightType} right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * right._Value)" : "right._Value")}.Mul<{info.LeftType}, {info.ReturnType}>(left);
|
||||||
public static List<{info.ReturnType}> operator *(List<{info.LeftType}> left, {info.RightType} right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * right._Value)" : "right._Value")}.Multiply<{info.LeftType}, {info.ReturnType}>(left);
|
public static List<{info.ReturnType}> operator *(List<{info.LeftType}> left, {info.RightType} right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * right._Value)" : "right._Value")}.Mul<{info.LeftType}, {info.ReturnType}>(left);
|
||||||
public static IEnumerable<{info.ReturnType}> operator *(IEnumerable<{info.LeftType}> left, {info.RightType} right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * right._Value)" : "right._Value")}.Multiply<{info.LeftType}, {info.ReturnType}>(left);
|
public static IEnumerable<{info.ReturnType}> operator *(IEnumerable<{info.LeftType}> left, {info.RightType} right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * right._Value)" : "right._Value")}.Mul<{info.LeftType}, {info.ReturnType}>(left);
|
||||||
}}";
|
}}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,16 +174,16 @@ namespace {info.Namespace};
|
|||||||
|
|
||||||
public readonly partial record struct {info.LeftType}
|
public readonly partial record struct {info.LeftType}
|
||||||
{{
|
{{
|
||||||
public static {info.ReturnType}[] operator /({info.LeftType} left, {info.RightType}[] right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * left._Value)" : "left._Value")}.Divide<{info.RightType}, {info.ReturnType}>(right);
|
public static {info.ReturnType}[] operator /({info.LeftType} left, {info.RightType}[] right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * left._Value)" : "left._Value")}.Div<{info.RightType}, {info.ReturnType}>(right);
|
||||||
public static List<{info.ReturnType}> operator /({info.LeftType} left, List<{info.RightType}> right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * left._Value)" : "left._Value")}.Divide<{info.RightType}, {info.ReturnType}>(right);
|
public static List<{info.ReturnType}> operator /({info.LeftType} left, List<{info.RightType}> right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * left._Value)" : "left._Value")}.Div<{info.RightType}, {info.ReturnType}>(right);
|
||||||
public static IEnumerable<{info.ReturnType}> operator /({info.LeftType} left, IEnumerable<{info.RightType}> right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * left._Value)" : "left._Value")}.Divide<{info.RightType}, {info.ReturnType}>(right);
|
public static IEnumerable<{info.ReturnType}> operator /({info.LeftType} left, IEnumerable<{info.RightType}> right) => {(info.HasCoeff ? $"({info.CoeffType}.{info.CoeffName} * left._Value)" : "left._Value")}.Div<{info.RightType}, {info.ReturnType}>(right);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
public readonly partial record struct {info.RightType}
|
public readonly partial record struct {info.RightType}
|
||||||
{{
|
{{
|
||||||
public static {info.ReturnType}[] operator /({info.LeftType}[] left, {info.RightType} right) => {(info.HasCoeff ? $"left.Multiply<{info.LeftType}, {info.ReturnType}>({info.CoeffType}.{info.CoeffName} / right._Value)" : $"left.Divide<{info.LeftType}, {info.ReturnType}>(right._Value)")};
|
public static {info.ReturnType}[] operator /({info.LeftType}[] left, {info.RightType} right) => {(info.HasCoeff ? $"left.Mul<{info.LeftType}, {info.ReturnType}>({info.CoeffType}.{info.CoeffName} / right._Value)" : $"left.Div<{info.LeftType}, {info.ReturnType}>(right._Value)")};
|
||||||
public static List<{info.ReturnType}> operator /(List<{info.LeftType}> left, {info.RightType} right) => {(info.HasCoeff ? $"left.Multiply<{info.LeftType}, {info.ReturnType}>({info.CoeffType}.{info.CoeffName} / right._Value)" : $"left.Divide<{info.LeftType}, {info.ReturnType}>(right._Value)")};
|
public static List<{info.ReturnType}> operator /(List<{info.LeftType}> left, {info.RightType} right) => {(info.HasCoeff ? $"left.Mul<{info.LeftType}, {info.ReturnType}>({info.CoeffType}.{info.CoeffName} / right._Value)" : $"left.Div<{info.LeftType}, {info.ReturnType}>(right._Value)")};
|
||||||
public static IEnumerable<{info.ReturnType}> operator /(IEnumerable<{info.LeftType}> left, {info.RightType} right) => {(info.HasCoeff ? $"left.Multiply<{info.LeftType}, {info.ReturnType}>({info.CoeffType}.{info.CoeffName} / right._Value)" : $"left.Divide<{info.LeftType}, {info.ReturnType}>(right._Value)")};
|
public static IEnumerable<{info.ReturnType}> operator /(IEnumerable<{info.LeftType}> left, {info.RightType} right) => {(info.HasCoeff ? $"left.Mul<{info.LeftType}, {info.ReturnType}>({info.CoeffType}.{info.CoeffName} / right._Value)" : $"left.Div<{info.LeftType}, {info.ReturnType}>(right._Value)")};
|
||||||
}}";
|
}}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.Text;
|
using Microsoft.CodeAnalysis.Text;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -10,9 +9,6 @@ namespace G;
|
|||||||
[Generator]
|
[Generator]
|
||||||
public class TestsGenerator : IIncrementalGenerator
|
public class TestsGenerator : IIncrementalGenerator
|
||||||
{
|
{
|
||||||
private const string UnitAttributeFullName = "QWERTYkez.Mensura.UnitGeneratorAttribute";
|
|
||||||
private const string ComplexAttributeFullName = "QWERTYkez.Mensura.ComplexUnitGeneratorAttribute";
|
|
||||||
|
|
||||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||||
{
|
{
|
||||||
var compilationProvider = context.CompilationProvider;
|
var compilationProvider = context.CompilationProvider;
|
||||||
@@ -24,116 +20,575 @@ public class TestsGenerator : IIncrementalGenerator
|
|||||||
|
|
||||||
var mensuraAssembly = compilation.References
|
var mensuraAssembly = compilation.References
|
||||||
.Select(r => compilation.GetAssemblyOrModuleSymbol(r) as IAssemblySymbol)
|
.Select(r => compilation.GetAssemblyOrModuleSymbol(r) as IAssemblySymbol)
|
||||||
.FirstOrDefault(a => a?.Name == "QWERTYkez.Mensura" || a?.Name?.EndsWith(".Mensura") == true);
|
.FirstOrDefault(a => a?.Name == "QWERTYkez.Mensura");
|
||||||
|
|
||||||
if (mensuraAssembly == null)
|
if (mensuraAssembly == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var targetTypes = new List<INamedTypeSymbol>();
|
var unitTypes = CollectAllUnitTypes(mensuraAssembly.GlobalNamespace);
|
||||||
CollectTypesWithAttribute(mensuraAssembly.GlobalNamespace, targetTypes, UnitAttributeFullName);
|
if (unitTypes.Count == 0) return;
|
||||||
CollectTypesWithAttribute(mensuraAssembly.GlobalNamespace, targetTypes, ComplexAttributeFullName);
|
|
||||||
|
|
||||||
if (targetTypes.Count == 0)
|
// 1. Сериализация
|
||||||
return;
|
GenerateSerializationTests(spc, unitTypes);
|
||||||
|
|
||||||
foreach (var type in targetTypes)
|
// 2. Операторы (с атрибутом)
|
||||||
{
|
var operators = CollectOperatorsFromUnitTypes(unitTypes);
|
||||||
var unitProperties = GetStaticProperties(type);
|
if (operators.Length > 0)
|
||||||
if (unitProperties.Length == 0) continue;
|
GenerateOperatorTests(spc, operators);
|
||||||
var firstNonBase = unitProperties.FirstOrDefault(p => !p.Name.StartsWith("_"));
|
|
||||||
if (firstNonBase.Name == null) continue;
|
|
||||||
|
|
||||||
// Генерируем два файла
|
// 3. Коллекционные методы
|
||||||
GenerateSerializationTest(spc, type.Name, firstNonBase.Name, "SystemText", "System.Text.Json");
|
GenerateCollectionTests(spc, unitTypes);
|
||||||
GenerateSerializationTest(spc, type.Name, firstNonBase.Name, "Newtonsoft", "Newtonsoft.Json");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void GenerateSerializationTest(SourceProductionContext spc, string typeName, string unitName, string framework, string namespaceName)
|
// ========== 1. СЕРИАЛИЗАЦИЯ ==========
|
||||||
|
private static void GenerateSerializationTests(SourceProductionContext spc, List<INamedTypeSymbol> types)
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.AppendLine("// <auto-generated/>");
|
sb.AppendLine("// <auto-generated/>");
|
||||||
sb.AppendLine("#pragma warning disable");
|
sb.AppendLine("#pragma warning disable");
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
sb.AppendLine("using Xunit;");
|
sb.AppendLine("using Xunit;");
|
||||||
sb.AppendLine($"using {namespaceName};");
|
sb.AppendLine("using System.Text.Json;");
|
||||||
|
sb.AppendLine("using Newtonsoft.Json;");
|
||||||
sb.AppendLine("using QWERTYkez.Mensura.Units;");
|
sb.AppendLine("using QWERTYkez.Mensura.Units;");
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
sb.AppendLine($"namespace QWERTYkez.Mensura.Tests");
|
sb.AppendLine("namespace QWERTYkez.Mensura.Tests");
|
||||||
sb.AppendLine("{");
|
sb.AppendLine("{");
|
||||||
sb.AppendLine($" public class {typeName}Serialization_{framework}Tests");
|
sb.AppendLine(" public class SerializationTests");
|
||||||
sb.AppendLine(" {");
|
sb.AppendLine(" {");
|
||||||
sb.AppendLine($" private const double Tolerance = 1e-12;");
|
sb.AppendLine(" private const double Tolerance = 1e-12;");
|
||||||
sb.AppendLine($" private readonly {typeName} _testValue = {typeName}.{unitName};");
|
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
|
|
||||||
// Тест
|
foreach (var type in types)
|
||||||
sb.AppendLine(" [Fact]");
|
|
||||||
sb.AppendLine($" public void {framework}_SerializeDeserialize_ReturnsEqualValue()");
|
|
||||||
sb.AppendLine(" {");
|
|
||||||
if (framework == "SystemText")
|
|
||||||
{
|
{
|
||||||
sb.AppendLine(" var json = System.Text.Json.JsonSerializer.Serialize(_testValue);");
|
var baseProp = GetBaseUnitProperty(type);
|
||||||
|
if (baseProp == null) continue;
|
||||||
|
var typeName = type.Name;
|
||||||
|
var propName = baseProp.Name;
|
||||||
|
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_SystemTextJson_SerializeDeserialize()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var original = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var json = System.Text.Json.JsonSerializer.Serialize(original);");
|
||||||
sb.AppendLine($" var deserialized = System.Text.Json.JsonSerializer.Deserialize<{typeName}>(json);");
|
sb.AppendLine($" var deserialized = System.Text.Json.JsonSerializer.Deserialize<{typeName}>(json);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)original, (double)deserialized, Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_NewtonsoftJson_SerializeDeserialize()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var original = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var json = Newtonsoft.Json.JsonConvert.SerializeObject(original);");
|
||||||
|
sb.AppendLine($" var deserialized = Newtonsoft.Json.JsonConvert.DeserializeObject<{typeName}>(json);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)original, (double)deserialized, Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.AppendLine(" }");
|
||||||
|
sb.AppendLine("}");
|
||||||
|
spc.AddSource("SerializationTests.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== 2. ОПЕРАТОРЫ (только с атрибутом) ==========
|
||||||
|
private static ImmutableArray<OperatorInfo> CollectOperatorsFromUnitTypes(List<INamedTypeSymbol> unitTypes)
|
||||||
|
{
|
||||||
|
var result = new List<OperatorInfo>();
|
||||||
|
foreach (var containingType in unitTypes)
|
||||||
|
{
|
||||||
|
foreach (var member in containingType.GetMembers())
|
||||||
|
{
|
||||||
|
if (member is not IMethodSymbol method || method.MethodKind != MethodKind.UserDefinedOperator)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bool hasAttr = method.GetAttributes().Any(attr =>
|
||||||
|
attr.AttributeClass?.Name == "OperatorsGeneratorAttribute" ||
|
||||||
|
attr.AttributeClass?.ToString() == "QWERTYkez.Mensura.OperatorsGeneratorAttribute");
|
||||||
|
if (!hasAttr) continue;
|
||||||
|
|
||||||
|
string opSymbol = method.Name switch
|
||||||
|
{
|
||||||
|
"op_Multiply" => "*",
|
||||||
|
"op_Division" => "/",
|
||||||
|
_ => null
|
||||||
|
};
|
||||||
|
if (opSymbol == null) continue;
|
||||||
|
|
||||||
|
var pars = method.Parameters;
|
||||||
|
if (pars.Length != 2) continue;
|
||||||
|
|
||||||
|
var leftType = pars[0].Type as INamedTypeSymbol;
|
||||||
|
var rightType = pars[1].Type as INamedTypeSymbol;
|
||||||
|
var returnType = method.ReturnType as INamedTypeSymbol;
|
||||||
|
if (leftType == null || rightType == null || returnType == null) continue;
|
||||||
|
|
||||||
|
if (!unitTypes.Contains(leftType, SymbolEqualityComparer.Default) ||
|
||||||
|
!unitTypes.Contains(rightType, SymbolEqualityComparer.Default) ||
|
||||||
|
!unitTypes.Contains(returnType, SymbolEqualityComparer.Default))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string? coeffField = null;
|
||||||
|
foreach (var attr in method.GetAttributes())
|
||||||
|
{
|
||||||
|
if (attr.AttributeClass?.Name == "OperatorsGeneratorAttribute" ||
|
||||||
|
attr.AttributeClass?.ToString() == "QWERTYkez.Mensura.OperatorsGeneratorAttribute")
|
||||||
|
{
|
||||||
|
foreach (var arg in attr.ConstructorArguments)
|
||||||
|
{
|
||||||
|
if (arg.Value is string s)
|
||||||
|
{
|
||||||
|
coeffField = s;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Add(new OperatorInfo(opSymbol, leftType, rightType, returnType, coeffField, containingType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.ToImmutableArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void GenerateOperatorTests(SourceProductionContext spc, ImmutableArray<OperatorInfo> operators)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine("// <auto-generated/>");
|
||||||
|
sb.AppendLine("#pragma warning disable");
|
||||||
|
sb.AppendLine();
|
||||||
|
sb.AppendLine("using Xunit;");
|
||||||
|
sb.AppendLine("using QWERTYkez.Mensura.Units;");
|
||||||
|
sb.AppendLine("using System.Reflection;");
|
||||||
|
sb.AppendLine();
|
||||||
|
sb.AppendLine("namespace QWERTYkez.Mensura.Tests");
|
||||||
|
sb.AppendLine("{");
|
||||||
|
sb.AppendLine(" public class OperatorsTests");
|
||||||
|
sb.AppendLine(" {");
|
||||||
|
sb.AppendLine(" private const double Tolerance = 1e-12;");
|
||||||
|
sb.AppendLine();
|
||||||
|
|
||||||
|
foreach (var op in operators)
|
||||||
|
{
|
||||||
|
var leftBase = GetBaseUnitProperty(op.LeftType);
|
||||||
|
var rightBase = GetBaseUnitProperty(op.RightType);
|
||||||
|
if (leftBase == null || rightBase == null) continue;
|
||||||
|
|
||||||
|
string leftTypeName = op.LeftType.Name;
|
||||||
|
string rightTypeName = op.RightType.Name;
|
||||||
|
string returnTypeName = op.ReturnType.Name;
|
||||||
|
string leftProp = leftBase.Name;
|
||||||
|
string rightProp = rightBase.Name;
|
||||||
|
|
||||||
|
string testName = $"{op.OperatorSymbol}_{leftTypeName}_{rightTypeName}_Returns_{returnTypeName}"
|
||||||
|
.Replace("<", "_").Replace(">", "_").Replace(",", "_").Replace(" ", "")
|
||||||
|
.Replace("*", "Mul").Replace("/", "Div");
|
||||||
|
|
||||||
|
string expectedExpr;
|
||||||
|
if (op.CoefficientField != null)
|
||||||
|
{
|
||||||
|
expectedExpr = $@"(double)left {op.OperatorSymbol} (double)right * " +
|
||||||
|
$@"(double)typeof({op.ContainingType.Name}).GetField(""{op.CoefficientField}"", " +
|
||||||
|
$@"BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.AppendLine(" var json = Newtonsoft.Json.JsonConvert.SerializeObject(_testValue);");
|
expectedExpr = $"(double)left {op.OperatorSymbol} (double)right";
|
||||||
sb.AppendLine($" var deserialized = Newtonsoft.Json.JsonConvert.DeserializeObject<{typeName}>(json);");
|
|
||||||
}
|
}
|
||||||
sb.AppendLine(" Assert.Equal((double)_testValue, (double)deserialized, Tolerance);");
|
|
||||||
sb.AppendLine(" }");
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {testName}()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var left = {leftTypeName}.{leftProp};");
|
||||||
|
sb.AppendLine($" var right = {rightTypeName}.{rightProp};");
|
||||||
|
sb.AppendLine($" var result = left {op.OperatorSymbol} right;");
|
||||||
|
sb.AppendLine($" var expected = {expectedExpr};");
|
||||||
|
sb.AppendLine($" Assert.Equal(expected, (double)result, Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operators.Length == 0)
|
||||||
|
sb.AppendLine(" // No operators with [OperatorsGenerator] found");
|
||||||
|
|
||||||
sb.AppendLine(" }");
|
sb.AppendLine(" }");
|
||||||
sb.AppendLine("}");
|
sb.AppendLine("}");
|
||||||
|
spc.AddSource("OperatorsTests.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8));
|
||||||
spc.AddSource($"Serialize.{framework}.{typeName}.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CollectTypesWithAttribute(INamespaceSymbol ns, List<INamedTypeSymbol> results, string attributeFullName)
|
// ========== 3. КОЛЛЕКЦИОННЫЕ МЕТОДЫ ==========
|
||||||
|
private static void GenerateCollectionTests(SourceProductionContext spc, List<INamedTypeSymbol> types)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine("// <auto-generated/>");
|
||||||
|
sb.AppendLine("#pragma warning disable");
|
||||||
|
sb.AppendLine();
|
||||||
|
sb.AppendLine("using Xunit;");
|
||||||
|
sb.AppendLine("using QWERTYkez.Mensura.Units;");
|
||||||
|
sb.AppendLine("using QWERTYkez.Mensura.Extensions;");
|
||||||
|
sb.AppendLine("using System.Collections.Generic;");
|
||||||
|
sb.AppendLine("using System.Linq;");
|
||||||
|
sb.AppendLine();
|
||||||
|
sb.AppendLine("namespace QWERTYkez.Mensura.Tests");
|
||||||
|
sb.AppendLine("{");
|
||||||
|
sb.AppendLine(" public class CollectionTests");
|
||||||
|
sb.AppendLine(" {");
|
||||||
|
sb.AppendLine(" private const double Tolerance = 1e-12;");
|
||||||
|
sb.AppendLine();
|
||||||
|
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
var baseProp = GetBaseUnitProperty(type);
|
||||||
|
if (baseProp == null) continue;
|
||||||
|
|
||||||
|
string typeName = type.Name;
|
||||||
|
string propName = baseProp.Name;
|
||||||
|
|
||||||
|
// Создаём массив из двух тестовых значений
|
||||||
|
sb.AppendLine($" private {typeName}[] GetTestArray() => new[] {{ {typeName}.{propName}, {typeName}.{propName} }};");
|
||||||
|
sb.AppendLine();
|
||||||
|
|
||||||
|
// ========== Multiply ==========
|
||||||
|
// scalar * array
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Multiply_ScalarByArray_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var arr = GetTestArray();");
|
||||||
|
sb.AppendLine($" var result = scalar.Multiply(arr);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// array * scalar
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Multiply_ArrayByScalar_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var arr = GetTestArray();");
|
||||||
|
sb.AppendLine($" var result = arr.Multiply(scalar);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// scalar * List
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Multiply_ScalarByList_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var list = GetTestArray().ToList();");
|
||||||
|
sb.AppendLine($" var result = scalar.Multiply(list);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// List * scalar
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Multiply_ListByScalar_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var list = GetTestArray().ToList();");
|
||||||
|
sb.AppendLine($" var result = list.Multiply(scalar);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// scalar * IEnumerable
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Multiply_ScalarByEnumerable_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var enumerable = GetTestArray().AsEnumerable();");
|
||||||
|
sb.AppendLine($" var result = scalar.Multiply(enumerable);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// IEnumerable * scalar
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Multiply_EnumerableByScalar_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var enumerable = GetTestArray().AsEnumerable();");
|
||||||
|
sb.AppendLine($" var result = enumerable.Multiply(scalar);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar * (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
|
||||||
|
// ========== Divide ==========
|
||||||
|
// scalar / array
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Divide_ScalarByArray_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var arr = GetTestArray();");
|
||||||
|
sb.AppendLine($" var result = scalar.Divide(arr);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// array / scalar
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Divide_ArrayByScalar_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var arr = GetTestArray();");
|
||||||
|
sb.AppendLine($" var result = arr.Divide(scalar);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// scalar / List
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Divide_ScalarByList_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var list = GetTestArray().ToList();");
|
||||||
|
sb.AppendLine($" var result = scalar.Divide(list);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// List / scalar
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Divide_ListByScalar_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var list = GetTestArray().ToList();");
|
||||||
|
sb.AppendLine($" var result = list.Divide(scalar);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// scalar / IEnumerable
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Divide_ScalarByEnumerable_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var enumerable = GetTestArray().AsEnumerable();");
|
||||||
|
sb.AppendLine($" var result = scalar.Divide(enumerable);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// IEnumerable / scalar
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Divide_EnumerableByScalar_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var enumerable = GetTestArray().AsEnumerable();");
|
||||||
|
sb.AppendLine($" var result = enumerable.Divide(scalar);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar / (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
|
||||||
|
// ========== Plus ==========
|
||||||
|
// scalar + array
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Plus_ScalarByArray_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var arr = GetTestArray();");
|
||||||
|
sb.AppendLine($" var result = scalar.Plus(arr);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// array + scalar
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Plus_ArrayByScalar_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var arr = GetTestArray();");
|
||||||
|
sb.AppendLine($" var result = arr.Plus(scalar);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// scalar + List
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Plus_ScalarByList_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var list = GetTestArray().ToList();");
|
||||||
|
sb.AppendLine($" var result = scalar.Plus(list);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// List + scalar
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Plus_ListByScalar_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var list = GetTestArray().ToList();");
|
||||||
|
sb.AppendLine($" var result = list.Plus(scalar);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// scalar + IEnumerable
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Plus_ScalarByEnumerable_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var enumerable = GetTestArray().AsEnumerable();");
|
||||||
|
sb.AppendLine($" var result = scalar.Plus(enumerable);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// IEnumerable + scalar
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Plus_EnumerableByScalar_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var enumerable = GetTestArray().AsEnumerable();");
|
||||||
|
sb.AppendLine($" var result = enumerable.Plus(scalar);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar + (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
|
||||||
|
// ========== Minus ==========
|
||||||
|
// scalar - array
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Minus_ScalarByArray_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var arr = GetTestArray();");
|
||||||
|
sb.AppendLine($" var result = scalar.Minus(arr);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// array - scalar
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Minus_ArrayByScalar_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var arr = GetTestArray();");
|
||||||
|
sb.AppendLine($" var result = arr.Minus(scalar);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Length);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// scalar - List
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Minus_ScalarByList_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var list = GetTestArray().ToList();");
|
||||||
|
sb.AppendLine($" var result = scalar.Minus(list);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// List - scalar
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Minus_ListByScalar_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var list = GetTestArray().ToList();");
|
||||||
|
sb.AppendLine($" var result = list.Minus(scalar);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[0], Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result[1], Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// scalar - IEnumerable
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Minus_ScalarByEnumerable_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var enumerable = GetTestArray().AsEnumerable();");
|
||||||
|
sb.AppendLine($" var result = scalar.Minus(enumerable);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
// IEnumerable - scalar
|
||||||
|
sb.AppendLine($" [Fact]");
|
||||||
|
sb.AppendLine($" public void {typeName}_Minus_EnumerableByScalar_Works()");
|
||||||
|
sb.AppendLine($" {{");
|
||||||
|
sb.AppendLine($" var scalar = {typeName}.{propName};");
|
||||||
|
sb.AppendLine($" var enumerable = GetTestArray().AsEnumerable();");
|
||||||
|
sb.AppendLine($" var result = enumerable.Minus(scalar);");
|
||||||
|
sb.AppendLine($" Assert.Equal(2, result.Count());");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result.ElementAt(0), Tolerance);");
|
||||||
|
sb.AppendLine($" Assert.Equal((double)scalar - (double)scalar, (double)result.ElementAt(1), Tolerance);");
|
||||||
|
sb.AppendLine($" }}");
|
||||||
|
sb.AppendLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.AppendLine(" }");
|
||||||
|
sb.AppendLine("}");
|
||||||
|
spc.AddSource("CollectionTests.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== ВСПОМОГАТЕЛЬНЫЕ МЕТОДЫ ==========
|
||||||
|
private static List<INamedTypeSymbol> CollectAllUnitTypes(INamespaceSymbol root)
|
||||||
|
{
|
||||||
|
var result = new List<INamedTypeSymbol>();
|
||||||
|
CollectTypesRecursive(root, result, "QWERTYkez.Mensura.Units");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CollectTypesRecursive(INamespaceSymbol ns, List<INamedTypeSymbol> result, string targetNamespacePrefix)
|
||||||
|
{
|
||||||
|
var nsFullName = ns.ToString();
|
||||||
|
if (nsFullName.StartsWith(targetNamespacePrefix))
|
||||||
{
|
{
|
||||||
foreach (var type in ns.GetTypeMembers())
|
foreach (var type in ns.GetTypeMembers())
|
||||||
{
|
result.Add(type);
|
||||||
if (HasAttribute(type, attributeFullName))
|
|
||||||
results.Add(type);
|
|
||||||
}
|
}
|
||||||
foreach (var childNs in ns.GetNamespaceMembers())
|
foreach (var childNs in ns.GetNamespaceMembers())
|
||||||
{
|
CollectTypesRecursive(childNs, result, targetNamespacePrefix);
|
||||||
CollectTypesWithAttribute(childNs, results, attributeFullName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool HasAttribute(INamedTypeSymbol type, string attributeFullName)
|
private static IPropertySymbol? GetBaseUnitProperty(ITypeSymbol type)
|
||||||
{
|
{
|
||||||
foreach (var attr in type.GetAttributes())
|
|
||||||
{
|
|
||||||
if (attr.AttributeClass?.ToString() == attributeFullName)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ImmutableArray<UnitProperty> GetStaticProperties(INamedTypeSymbol type)
|
|
||||||
{
|
|
||||||
var props = new List<UnitProperty>();
|
|
||||||
foreach (var member in type.GetMembers())
|
foreach (var member in type.GetMembers())
|
||||||
{
|
{
|
||||||
if (member is IPropertySymbol prop && prop.IsStatic && prop.DeclaredAccessibility == Accessibility.Public)
|
if (member is IPropertySymbol prop && prop.IsStatic && prop.Name.StartsWith("_") && SymbolEqualityComparer.Default.Equals(prop.Type, type))
|
||||||
{
|
return prop;
|
||||||
var propName = prop.Name;
|
|
||||||
if (propName == "EqualityContract" || propName.StartsWith("<"))
|
|
||||||
continue;
|
|
||||||
props.Add(new UnitProperty(propName, prop.Type.ToString()));
|
|
||||||
}
|
}
|
||||||
}
|
return null;
|
||||||
return props.ToImmutableArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly struct UnitProperty
|
private readonly struct OperatorInfo(string symbol, ITypeSymbol left, ITypeSymbol right, ITypeSymbol ret, string? coeff, ITypeSymbol containing)
|
||||||
{
|
{
|
||||||
public string Name { get; }
|
public string OperatorSymbol { get; } = symbol;
|
||||||
public string Type { get; }
|
public ITypeSymbol LeftType { get; } = left;
|
||||||
public UnitProperty(string name, string type) => (Name, Type) = (name, type);
|
public ITypeSymbol RightType { get; } = right;
|
||||||
|
public ITypeSymbol ReturnType { get; } = ret;
|
||||||
|
public string? CoefficientField { get; } = coeff;
|
||||||
|
public ITypeSymbol ContainingType { get; } = containing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,4 @@
|
|||||||
using Microsoft.CodeAnalysis;
|
namespace G;
|
||||||
using Microsoft.CodeAnalysis.CSharp;
|
|
||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
||||||
using Microsoft.CodeAnalysis.Text;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace G;
|
|
||||||
|
|
||||||
[Generator]
|
[Generator]
|
||||||
public class UnitGenerator : IIncrementalGenerator
|
public class UnitGenerator : IIncrementalGenerator
|
||||||
@@ -20,7 +14,7 @@ public class UnitGenerator : IIncrementalGenerator
|
|||||||
namespace QWERTYkez.Mensura
|
namespace QWERTYkez.Mensura
|
||||||
{
|
{
|
||||||
[System.AttributeUsage(System.AttributeTargets.Struct, AllowMultiple = false)]
|
[System.AttributeUsage(System.AttributeTargets.Struct, AllowMultiple = false)]
|
||||||
public sealed class UnitGeneratorAttribute : System.Attribute { }
|
internal sealed class UnitGeneratorAttribute : System.Attribute { }
|
||||||
}";
|
}";
|
||||||
ctx.AddSource(".UnitGeneratorAttribute.g.cs", SourceText.From(attributeSource, Encoding.UTF8));
|
ctx.AddSource(".UnitGeneratorAttribute.g.cs", SourceText.From(attributeSource, Encoding.UTF8));
|
||||||
});
|
});
|
||||||
@@ -36,11 +30,44 @@ namespace QWERTYkez.Mensura
|
|||||||
|
|
||||||
context.RegisterSourceOutput(structsProvider, (spc, structs) =>
|
context.RegisterSourceOutput(structsProvider, (spc, structs) =>
|
||||||
{
|
{
|
||||||
|
// Сначала генерируем сами структуры (Ваш оригинальный код без изменений)
|
||||||
foreach (var structInfo in structs)
|
foreach (var structInfo in structs)
|
||||||
{
|
{
|
||||||
string generatedCode = GeneratePartial(structInfo);
|
string generatedCode = GeneratePartial(structInfo);
|
||||||
spc.AddSource($"{structInfo.TypeName}.g.cs", SourceText.From(generatedCode, Encoding.UTF8));
|
spc.AddSource($"{structInfo.TypeName}.g.cs", SourceText.From(generatedCode, Encoding.UTF8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- ТОТ САМЫЙ КОД УСЛОВНОЙ ГЕНЕРАЦИИ БИНДЕРА ---
|
||||||
|
bool isMainAssembly = false;
|
||||||
|
var firstStruct = structs.FirstOrDefault();
|
||||||
|
if (firstStruct.TypeName != null)
|
||||||
|
{
|
||||||
|
// Если пространство имен содержит "Tests", флаг останется false
|
||||||
|
if (firstStruct.Namespace.StartsWith("QWERTYkez.Mensura") && !firstStruct.Namespace.Contains("Tests"))
|
||||||
|
{
|
||||||
|
isMainAssembly = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Генерируем файл ТОЛЬКО для основного проекта
|
||||||
|
if (isMainAssembly)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine("namespace QWERTYkez.Mensura;");
|
||||||
|
sb.AppendLine("internal static partial class MensuraBinder");
|
||||||
|
sb.AppendLine("{");
|
||||||
|
sb.AppendLine(" [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]");
|
||||||
|
sb.AppendLine(" static partial void AddGeneratedConverters(System.Collections.IList converters)");
|
||||||
|
sb.AppendLine(" {");
|
||||||
|
foreach (var structInfo in structs)
|
||||||
|
{
|
||||||
|
sb.AppendLine($" converters.Add(new QWERTYkez.Mensura.MensuraBinder.NewtonsoftRegistrar.NewtonsoftUnitConverter<QWERTYkez.Mensura.Units.{structInfo.TypeName}>());");
|
||||||
|
}
|
||||||
|
sb.AppendLine(" }");
|
||||||
|
sb.AppendLine("}");
|
||||||
|
|
||||||
|
spc.AddSource(".Units.MensuraBinder.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +125,7 @@ using System.Runtime.Serialization;
|
|||||||
|
|
||||||
namespace QWERTYkez.Mensura.Units;
|
namespace QWERTYkez.Mensura.Units;
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonConverter(typeof(NewtonsoftUnitConverter<{typeName}>)), JsonConverter(typeof(UnitJsonConverter<{typeName}>))]
|
[JsonConverter(typeof(UnitJsonConverter<{typeName}>))]
|
||||||
public readonly partial record struct {typeName} : IMensuraUnit<{typeName}>, IEquatable<{typeName}>, IMensuraUnit
|
public readonly partial record struct {typeName} : IMensuraUnit<{typeName}>, IEquatable<{typeName}>, IMensuraUnit
|
||||||
{
|
{
|
||||||
[JsonInclude, DataMember, JsonPropertyName(""v""), Obsolete] // для JSON / EF на случай сбоев, если пробелма с _Value
|
[JsonInclude, DataMember, JsonPropertyName(""v""), Obsolete] // для JSON / EF на случай сбоев, если пробелма с _Value
|
||||||
@@ -286,7 +313,341 @@ public readonly partial record struct {typeName} : IMensuraUnit<{typeName}>, IEq
|
|||||||
|
|
||||||
public static class {typeName}Extensions
|
public static class {typeName}Extensions
|
||||||
{
|
{
|
||||||
public static double Protected(this {typeName}? unit) => unit is null ? 0d : unit.Value._Value;
|
internal static double Protected(this {typeName}? unit) => unit is null ? 0d : unit.Value._Value;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// === ReadOnlySpan
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ReadOnlySpan<{typeName}> units,
|
||||||
|
double divisor, Span<{typeName}> destination) => units.Div<{typeName}>(divisor, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ReadOnlySpan<{typeName}?> units,
|
||||||
|
double divisor, Span<{typeName}?> destination) => units.Div<{typeName}>(divisor, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
ReadOnlySpan<{typeName}> units, Span<{typeName}> destination) => dividend.Div<{typeName}>(units, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
ReadOnlySpan<{typeName}?> units, Span<{typeName}?> destination) => dividend.Div<{typeName}>(units, destination);
|
||||||
|
|
||||||
|
// === Array ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static {typeName}[] Div(
|
||||||
|
this {typeName}[] units, double divisor) => units.Div<{typeName}>(divisor);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}?[] Div(
|
||||||
|
this {typeName}?[] units, double divisor) => units.Div<{typeName}>(divisor);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}[] Div(
|
||||||
|
this double dividend, {typeName}[] units) => dividend.Div<{typeName}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}?[] Div(
|
||||||
|
this double dividend, {typeName}?[] units) => dividend.Div<{typeName}>(units);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}> Div(
|
||||||
|
this List<{typeName}> units, double divisor) => units.Div<{typeName}>(divisor);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Div(
|
||||||
|
this List<{typeName}?> units, double divisor) => units.Div<{typeName}>(divisor);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}> Div(
|
||||||
|
this double dividend, List<{typeName}> units) => dividend.Div<{typeName}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Div(
|
||||||
|
this double dividend, List<{typeName}?> units) => dividend.Div<{typeName}>(units);
|
||||||
|
|
||||||
|
// === ICollection<T> ===
|
||||||
|
[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<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Div(this IReadOnlyCollection<{typeName}> units,
|
||||||
|
double divisor, Span<{typeName}> destination) => units.Div<{typeName}>(divisor, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Div(this IReadOnlyCollection<{typeName}?> units,
|
||||||
|
double divisor, Span<{typeName}?> destination) => units.Div<{typeName}>(divisor, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
IReadOnlyCollection<{typeName}> units, Span<{typeName}> destination) => dividend.Div<{typeName}>(units, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
IReadOnlyCollection<{typeName}?> units, Span<{typeName}?> destination) => dividend.Div<{typeName}>(units, destination);
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}> Div(
|
||||||
|
this IEnumerable<{typeName}> units, double divisor) => units.Div<{typeName}>(divisor);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}?> Div(
|
||||||
|
this IEnumerable<{typeName}?> units, double divisor) => units.Div<{typeName}>(divisor);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}> Div(
|
||||||
|
this double dividend, IEnumerable<{typeName}> units) => dividend.Div<{typeName}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}?> Div(
|
||||||
|
this double dividend, IEnumerable<{typeName}?> units) => dividend.Div<{typeName}>(units);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// === ReadOnlySpan
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ReadOnlySpan<{typeName}> units,
|
||||||
|
double subtrahend, Span<{typeName}> destination) => units.Minus<{typeName}>(subtrahend, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ReadOnlySpan<{typeName}?> units,
|
||||||
|
double subtrahend, Span<{typeName}?> destination) => units.Minus<{typeName}>(subtrahend, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
ReadOnlySpan<{typeName}> units, Span<{typeName}> destination) => minuend.Minus<{typeName}>(units, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
ReadOnlySpan<{typeName}?> units, Span<{typeName}?> destination) => minuend.Minus<{typeName}>(units, destination);
|
||||||
|
|
||||||
|
// === Array ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static {typeName}[] Minus(
|
||||||
|
this {typeName}[] units, double subtrahend) => units.Minus<{typeName}>(subtrahend);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}?[] Minus(
|
||||||
|
this {typeName}?[] units, double subtrahend) => units.Minus<{typeName}>(subtrahend);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}[] Minus(
|
||||||
|
this double minuend, {typeName}[] units) => minuend.Minus<{typeName}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}?[] Minus(
|
||||||
|
this double minuend, {typeName}?[] units) => minuend.Minus<{typeName}>(units);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}> Minus(
|
||||||
|
this List<{typeName}> units, double subtrahend) => units.Minus<{typeName}>(subtrahend);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Minus(
|
||||||
|
this List<{typeName}?> units, double subtrahend) => units.Minus<{typeName}>(subtrahend);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}> Minus(
|
||||||
|
this double minuend, List<{typeName}> units) => minuend.Minus<{typeName}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Minus(
|
||||||
|
this double minuend, List<{typeName}?> units) => minuend.Minus<{typeName}>(units);
|
||||||
|
|
||||||
|
// === ICollection<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ICollection<{typeName}> units,
|
||||||
|
double subtrahend, Span<{typeName}> destination) => units.Minus<{typeName}>(subtrahend, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ICollection<{typeName}?> units,
|
||||||
|
double subtrahend, Span<{typeName}?> destination) => units.Minus<{typeName}>(subtrahend, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
ICollection<{typeName}> units, Span<{typeName}> destination) => minuend.Minus<{typeName}>(units, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
ICollection<{typeName}?> units, Span<{typeName}?> destination) => minuend.Minus<{typeName}>(units, destination);
|
||||||
|
|
||||||
|
// === IReadOnlyCollection<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Minus(this IReadOnlyCollection<{typeName}> units,
|
||||||
|
double subtrahend, Span<{typeName}> destination) => units.Minus<{typeName}>(subtrahend, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Minus(this IReadOnlyCollection<{typeName}?> units,
|
||||||
|
double subtrahend, Span<{typeName}?> destination) => units.Minus<{typeName}>(subtrahend, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
IReadOnlyCollection<{typeName}> units, Span<{typeName}> destination) => minuend.Minus<{typeName}>(units, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
IReadOnlyCollection<{typeName}?> units, Span<{typeName}?> destination) => minuend.Minus<{typeName}>(units, destination);
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}> Minus(
|
||||||
|
this IEnumerable<{typeName}> units, double subtrahend) => units.Minus<{typeName}>(subtrahend);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}?> Minus(
|
||||||
|
this IEnumerable<{typeName}?> units, double subtrahend) => units.Minus<{typeName}>(subtrahend);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}> Minus(
|
||||||
|
this double minuend, IEnumerable<{typeName}> units) => minuend.Minus<{typeName}>(units);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}?> Minus(
|
||||||
|
this double minuend, IEnumerable<{typeName}?> units) => minuend.Minus<{typeName}>(units);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// === ReadOnlySpan
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ReadOnlySpan<{typeName}> units,
|
||||||
|
double multiplicator, Span<{typeName}> destination) => units.Mul<{typeName}>(multiplicator, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ReadOnlySpan<{typeName}?> units,
|
||||||
|
double multiplicator, Span<{typeName}?> destination) => units.Mul<{typeName}>(multiplicator, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
ReadOnlySpan<{typeName}> units, Span<{typeName}> destination) => units.Mul<{typeName}>(multiplicator, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
ReadOnlySpan<{typeName}?> units, Span<{typeName}?> destination) => units.Mul<{typeName}>(multiplicator, destination);
|
||||||
|
|
||||||
|
// === Array ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static {typeName}[] Mul(
|
||||||
|
this {typeName}[] units, double multiplicator) => units.Mul<{typeName}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}?[] Mul(
|
||||||
|
this {typeName}?[] units, double multiplicator) => units.Mul<{typeName}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}[] Mul(
|
||||||
|
this double multiplicator, {typeName}[] units) => units.Mul<{typeName}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}?[] Mul(
|
||||||
|
this double multiplicator, {typeName}?[] units) => units.Mul<{typeName}>(multiplicator);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}> Mul(
|
||||||
|
this List<{typeName}> units, double multiplicator) => units.Mul<{typeName}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Mul(
|
||||||
|
this List<{typeName}?> units, double multiplicator) => units.Mul<{typeName}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}> Mul(
|
||||||
|
this double multiplicator, List<{typeName}> units) => units.Mul<{typeName}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Mul(
|
||||||
|
this double multiplicator, List<{typeName}?> units) => units.Mul<{typeName}>(multiplicator);
|
||||||
|
|
||||||
|
// === ICollection<T> ===
|
||||||
|
[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<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Mul(this IReadOnlyCollection<{typeName}> units,
|
||||||
|
double multiplicator, Span<{typeName}> destination) => units.Mul<{typeName}>(multiplicator, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Mul(this IReadOnlyCollection<{typeName}?> units,
|
||||||
|
double multiplicator, Span<{typeName}?> destination) => units.Mul<{typeName}>(multiplicator, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
IReadOnlyCollection<{typeName}> units, Span<{typeName}> destination) => units.Mul<{typeName}>(multiplicator, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
IReadOnlyCollection<{typeName}?> units, Span<{typeName}?> destination) => units.Mul<{typeName}>(multiplicator, destination);
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}> Mul(
|
||||||
|
this IEnumerable<{typeName}> units, double multiplicator) => units.Mul<{typeName}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}?> Mul(
|
||||||
|
this IEnumerable<{typeName}?> units, double multiplicator) => units.Mul<{typeName}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}> Mul(
|
||||||
|
this double multiplicator, IEnumerable<{typeName}> units) => units.Mul<{typeName}>(multiplicator);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}?> Mul(
|
||||||
|
this double multiplicator, IEnumerable<{typeName}?> units) => units.Mul<{typeName}>(multiplicator);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// === ReadOnlySpan
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ReadOnlySpan<{typeName}> units,
|
||||||
|
double summand, Span<{typeName}> destination) => units.Plus<{typeName}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ReadOnlySpan<{typeName}?> units,
|
||||||
|
double summand, Span<{typeName}?> destination) => units.Plus<{typeName}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
ReadOnlySpan<{typeName}> units, Span<{typeName}> destination) => units.Plus<{typeName}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
ReadOnlySpan<{typeName}?> units, Span<{typeName}?> destination) => units.Plus<{typeName}>(summand, destination);
|
||||||
|
|
||||||
|
// === Array ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static {typeName}[] Plus(
|
||||||
|
this {typeName}[] units, double summand) => units.Plus<{typeName}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}?[] Plus(
|
||||||
|
this {typeName}?[] units, double summand) => units.Plus<{typeName}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}[] Plus(
|
||||||
|
this double summand, {typeName}[] units) => units.Plus<{typeName}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static {typeName}?[] Plus(
|
||||||
|
this double summand, {typeName}?[] units) => units.Plus<{typeName}>(summand);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}> Plus(
|
||||||
|
this List<{typeName}> units, double summand) => units.Plus<{typeName}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Plus(
|
||||||
|
this List<{typeName}?> units, double summand) => units.Plus<{typeName}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}> Plus(
|
||||||
|
this double summand, List<{typeName}> units) => units.Plus<{typeName}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<{typeName}?> Plus(
|
||||||
|
this double summand, List<{typeName}?> units) => units.Plus<{typeName}>(summand);
|
||||||
|
|
||||||
|
// === ICollection<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ICollection<{typeName}> units,
|
||||||
|
double summand, Span<{typeName}> destination) => units.Plus<{typeName}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ICollection<{typeName}?> units,
|
||||||
|
double summand, Span<{typeName}?> destination) => units.Plus<{typeName}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
ICollection<{typeName}> units, Span<{typeName}> destination) => units.Plus<{typeName}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
ICollection<{typeName}?> units, Span<{typeName}?> destination) => units.Plus<{typeName}>(summand, destination);
|
||||||
|
|
||||||
|
// === IReadOnlyCollection<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Plus(this IReadOnlyCollection<{typeName}> units,
|
||||||
|
double summand, Span<{typeName}> destination) => units.Plus<{typeName}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Plus(this IReadOnlyCollection<{typeName}?> units,
|
||||||
|
double summand, Span<{typeName}?> destination) => units.Plus<{typeName}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
IReadOnlyCollection<{typeName}> units, Span<{typeName}> destination) => units.Plus<{typeName}>(summand, destination);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
IReadOnlyCollection<{typeName}?> units, Span<{typeName}?> destination) => units.Plus<{typeName}>(summand, destination);
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}> Plus(
|
||||||
|
this IEnumerable<{typeName}> units, double summand) => units.Plus<{typeName}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}?> Plus(
|
||||||
|
this IEnumerable<{typeName}?> units, double summand) => units.Plus<{typeName}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}> Plus(
|
||||||
|
this double summand, IEnumerable<{typeName}> units) => units.Plus<{typeName}>(summand);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<{typeName}?> Plus(
|
||||||
|
this double summand, IEnumerable<{typeName}?> units) => units.Plus<{typeName}>(summand);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Sum Average Max Min (не nullable) ==========================================
|
||||||
|
|
||||||
|
|
||||||
|
// === ReadOnlySpan === SIMD
|
||||||
|
public static {typeName} Sum(this ReadOnlySpan<{typeName}> units) => AggregateUnitExtensions.Sum(units);
|
||||||
|
public static {typeName} Average(this ReadOnlySpan<{typeName}> units) => AggregateUnitExtensions.Average(units);
|
||||||
|
public static {typeName} Max(this ReadOnlySpan<{typeName}> units) => AggregateUnitExtensions.Max(units);
|
||||||
|
public static {typeName} Min(this ReadOnlySpan<{typeName}> units) => AggregateUnitExtensions.Min(units);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
public static {typeName} Sum(this List<{typeName}> list) => AggregateUnitExtensions.Sum(list);
|
||||||
|
public static {typeName} Average(this List<{typeName}> list) => AggregateUnitExtensions.Average(list);
|
||||||
|
public static {typeName} Max(this List<{typeName}> list) => AggregateUnitExtensions.Max(list);
|
||||||
|
public static {typeName} Min(this List<{typeName}> list) => AggregateUnitExtensions.Min(list);
|
||||||
|
|
||||||
|
// === ICollection<T> ===
|
||||||
|
public static {typeName} Sum(this ICollection<{typeName}> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
public static {typeName} Average(this ICollection<{typeName}> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
public static {typeName} Max(this ICollection<{typeName}> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
public static {typeName} Min(this ICollection<{typeName}> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
// === IReadOnlyCollection<T> ===
|
||||||
|
public static {typeName} Sum(this IReadOnlyCollection<{typeName}> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
public static {typeName} Average(this IReadOnlyCollection<{typeName}> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
public static {typeName} Max(this IReadOnlyCollection<{typeName}> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
public static {typeName} Min(this IReadOnlyCollection<{typeName}> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
public static {typeName} Sum(this IEnumerable<{typeName}> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
public static {typeName} Average(this IEnumerable<{typeName}> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
public static {typeName} Max(this IEnumerable<{typeName}> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
public static {typeName} Min(this IEnumerable<{typeName}> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Sum Average Max Min (nullable) ==========================================
|
||||||
|
|
||||||
|
|
||||||
|
// === ReadOnlySpan ===
|
||||||
|
public static {typeName} Sum(this ReadOnlySpan<{typeName}?> units) => AggregateUnitExtensions.Sum(units);
|
||||||
|
public static {typeName} Average(this ReadOnlySpan<{typeName}?> units) => AggregateUnitExtensions.Average(units);
|
||||||
|
public static {typeName} Max(this ReadOnlySpan<{typeName}?> units) => AggregateUnitExtensions.Max(units);
|
||||||
|
public static {typeName} Min(this ReadOnlySpan<{typeName}?> units) => AggregateUnitExtensions.Min(units);
|
||||||
|
|
||||||
|
// === List<T> ===
|
||||||
|
public static {typeName} Sum(this List<{typeName}?> list) => AggregateUnitExtensions.Sum(list);
|
||||||
|
public static {typeName} Average(this List<{typeName}?> list) => AggregateUnitExtensions.Average(list);
|
||||||
|
public static {typeName} Max(this List<{typeName}?> list) => AggregateUnitExtensions.Max(list);
|
||||||
|
public static {typeName} Min(this List<{typeName}?> list) => AggregateUnitExtensions.Min(list);
|
||||||
|
|
||||||
|
// === ICollection<T> ===
|
||||||
|
public static {typeName} Sum(this ICollection<{typeName}?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
public static {typeName} Average(this ICollection<{typeName}?> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
public static {typeName} Max(this ICollection<{typeName}?> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
public static {typeName} Min(this ICollection<{typeName}?> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
// === IReadOnlyCollection<T> ===
|
||||||
|
public static {typeName} Sum(this IReadOnlyCollection<{typeName}?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
public static {typeName} Average(this IReadOnlyCollection<{typeName}?> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
public static {typeName} Max(this IReadOnlyCollection<{typeName}?> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
public static {typeName} Min(this IReadOnlyCollection<{typeName}?> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
// === IEnumerable<T> ===
|
||||||
|
public static {typeName} Sum(this IEnumerable<{typeName}?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
public static {typeName} Average(this IEnumerable<{typeName}?> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
public static {typeName} Max(this IEnumerable<{typeName}?> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
public static {typeName} Min(this IEnumerable<{typeName}?> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
}
|
}
|
||||||
";
|
";
|
||||||
return skeleton.Replace("{typeName}", typeName).Replace("{ns}", ns);
|
return skeleton.Replace("{typeName}", typeName).Replace("{ns}", ns);
|
||||||
|
|||||||
8
QWERTYkez.Mensura.Generator/globals.cs
Normal file
8
QWERTYkez.Mensura.Generator/globals.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
global using Microsoft.CodeAnalysis;
|
||||||
|
global using Microsoft.CodeAnalysis.CSharp;
|
||||||
|
global using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
global using Microsoft.CodeAnalysis.Text;
|
||||||
|
global using System.Collections.Immutable;
|
||||||
|
global using System.Collections.Generic;
|
||||||
|
global using System.Linq;
|
||||||
|
global using System.Text;
|
||||||
@@ -4,13 +4,13 @@ using System.Runtime.Intrinsics.X86;
|
|||||||
|
|
||||||
namespace QWERTYkez.Mensura.Extensions;
|
namespace QWERTYkez.Mensura.Extensions;
|
||||||
|
|
||||||
public static partial class AggregateUnitExtensions
|
internal static partial class AggregateUnitExtensions
|
||||||
{
|
{
|
||||||
// Sum Average Max Min (не nullable) ==========================================
|
// Sum Average Max Min (не nullable) ==========================================
|
||||||
|
|
||||||
|
|
||||||
// === ReadOnlySpan === SIMD
|
// === ReadOnlySpan === SIMD
|
||||||
public static T Sum<T>(this ReadOnlySpan<T> units)
|
internal static T Sum<T>(this ReadOnlySpan<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return default;
|
if (units.IsEmpty) return default;
|
||||||
@@ -73,7 +73,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
|
|
||||||
return Unsafe.As<double, T>(ref sum);
|
return Unsafe.As<double, T>(ref sum);
|
||||||
}
|
}
|
||||||
public static T Average<T>(this ReadOnlySpan<T> units)
|
internal static T Average<T>(this ReadOnlySpan<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
// Если коллекция пустая, возвращаем структуру, содержащую double.NaN
|
// Если коллекция пустая, возвращаем структуру, содержащую double.NaN
|
||||||
@@ -145,7 +145,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
// Упаковываем double обратно в структуру T (zero-cost)
|
// Упаковываем double обратно в структуру T (zero-cost)
|
||||||
return Unsafe.As<double, T>(ref average);
|
return Unsafe.As<double, T>(ref average);
|
||||||
}
|
}
|
||||||
public static T Max<T>(this ReadOnlySpan<T> units)
|
internal static T Max<T>(this ReadOnlySpan<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty)
|
if (units.IsEmpty)
|
||||||
@@ -209,7 +209,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
|
|
||||||
return Unsafe.As<double, T>(ref max);
|
return Unsafe.As<double, T>(ref max);
|
||||||
}
|
}
|
||||||
public static T Min<T>(this ReadOnlySpan<T> units)
|
internal static T Min<T>(this ReadOnlySpan<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty)
|
if (units.IsEmpty)
|
||||||
@@ -275,29 +275,29 @@ public static partial class AggregateUnitExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
public static T Sum<T>(this List<T> list)
|
internal static T Sum<T>(this List<T> list)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
return CollectionsMarshal.AsSpan(list).Sum();
|
return CollectionsMarshal.AsSpan(list).Sum();
|
||||||
}
|
}
|
||||||
public static T Average<T>(this List<T> list)
|
internal static T Average<T>(this List<T> list)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
return CollectionsMarshal.AsSpan(list).Average();
|
return CollectionsMarshal.AsSpan(list).Average();
|
||||||
}
|
}
|
||||||
public static T Max<T>(this List<T> list)
|
internal static T Max<T>(this List<T> list)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
return CollectionsMarshal.AsSpan(list).Max();
|
return CollectionsMarshal.AsSpan(list).Max();
|
||||||
}
|
}
|
||||||
public static T Min<T>(this List<T> list)
|
internal static T Min<T>(this List<T> list)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
return CollectionsMarshal.AsSpan(list).Min();
|
return CollectionsMarshal.AsSpan(list).Min();
|
||||||
}
|
}
|
||||||
|
|
||||||
// === ICollection<T> ===
|
// === ICollection<T> ===
|
||||||
public static T Sum<T>(this ICollection<T> collection)
|
internal static T Sum<T>(this ICollection<T> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return default;
|
if (collection == null || collection.Count == 0) return default;
|
||||||
@@ -315,7 +315,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
ArrayPool<T>.Shared.Return(sharedArray);
|
ArrayPool<T>.Shared.Return(sharedArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static T Average<T>(this ICollection<T> collection)
|
internal static T Average<T>(this ICollection<T> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return double.NaN.ToUnit<T>();
|
if (collection == null || collection.Count == 0) return double.NaN.ToUnit<T>();
|
||||||
@@ -333,7 +333,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
ArrayPool<T>.Shared.Return(sharedArray);
|
ArrayPool<T>.Shared.Return(sharedArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static T Max<T>(this ICollection<T> collection)
|
internal static T Max<T>(this ICollection<T> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return double.MinValue.ToUnit<T>();
|
if (collection == null || collection.Count == 0) return double.MinValue.ToUnit<T>();
|
||||||
@@ -351,7 +351,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
ArrayPool<T>.Shared.Return(sharedArray);
|
ArrayPool<T>.Shared.Return(sharedArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static T Min<T>(this ICollection<T> collection)
|
internal static T Min<T>(this ICollection<T> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return double.MaxValue.ToUnit<T>();
|
if (collection == null || collection.Count == 0) return double.MaxValue.ToUnit<T>();
|
||||||
@@ -371,7 +371,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IReadOnlyCollection<T> ===
|
// === IReadOnlyCollection<T> ===
|
||||||
public static T Sum<T>(this IReadOnlyCollection<T> collection)
|
internal static T Sum<T>(this IReadOnlyCollection<T> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return default;
|
if (collection == null || collection.Count == 0) return default;
|
||||||
@@ -387,7 +387,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
}
|
}
|
||||||
finally { ArrayPool<T>.Shared.Return(sharedArray); }
|
finally { ArrayPool<T>.Shared.Return(sharedArray); }
|
||||||
}
|
}
|
||||||
public static T Average<T>(this IReadOnlyCollection<T> collection)
|
internal static T Average<T>(this IReadOnlyCollection<T> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return double.NaN.ToUnit<T>();
|
if (collection == null || collection.Count == 0) return double.NaN.ToUnit<T>();
|
||||||
@@ -403,7 +403,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
}
|
}
|
||||||
finally { ArrayPool<T>.Shared.Return(sharedArray); }
|
finally { ArrayPool<T>.Shared.Return(sharedArray); }
|
||||||
}
|
}
|
||||||
public static T Max<T>(this IReadOnlyCollection<T> collection)
|
internal static T Max<T>(this IReadOnlyCollection<T> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return double.MinValue.ToUnit<T>();
|
if (collection == null || collection.Count == 0) return double.MinValue.ToUnit<T>();
|
||||||
@@ -419,7 +419,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
}
|
}
|
||||||
finally { ArrayPool<T>.Shared.Return(sharedArray); }
|
finally { ArrayPool<T>.Shared.Return(sharedArray); }
|
||||||
}
|
}
|
||||||
public static T Min<T>(this IReadOnlyCollection<T> collection)
|
internal static T Min<T>(this IReadOnlyCollection<T> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return double.MaxValue.ToUnit<T>();
|
if (collection == null || collection.Count == 0) return double.MaxValue.ToUnit<T>();
|
||||||
@@ -438,7 +438,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
|
|
||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
public static T Sum<T>(this IEnumerable<T> collection)
|
internal static T Sum<T>(this IEnumerable<T> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null) return default;
|
if (collection == null) return default;
|
||||||
@@ -461,7 +461,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
|
|
||||||
return hasElements ? sum.ToUnit<T>() : default;
|
return hasElements ? sum.ToUnit<T>() : default;
|
||||||
}
|
}
|
||||||
public static T Average<T>(this IEnumerable<T> collection)
|
internal static T Average<T>(this IEnumerable<T> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null) return double.NaN.ToUnit<T>();
|
if (collection == null) return double.NaN.ToUnit<T>();
|
||||||
@@ -485,7 +485,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
double avg = sum / count;
|
double avg = sum / count;
|
||||||
return avg.ToUnit<T>();
|
return avg.ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static T Max<T>(this IEnumerable<T> collection)
|
internal static T Max<T>(this IEnumerable<T> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null) return double.MinValue.ToUnit<T>();
|
if (collection == null) return double.MinValue.ToUnit<T>();
|
||||||
@@ -507,7 +507,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
|
|
||||||
return hasElements ? max.ToUnit<T>() : double.MinValue.ToUnit<T>();
|
return hasElements ? max.ToUnit<T>() : double.MinValue.ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static T Min<T>(this IEnumerable<T> collection)
|
internal static T Min<T>(this IEnumerable<T> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null) return double.MaxValue.ToUnit<T>();
|
if (collection == null) return double.MaxValue.ToUnit<T>();
|
||||||
@@ -536,7 +536,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
|
|
||||||
|
|
||||||
// === ReadOnlySpan ===
|
// === ReadOnlySpan ===
|
||||||
public static T Sum<T>(this ReadOnlySpan<T?> units)
|
internal static T Sum<T>(this ReadOnlySpan<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return default;
|
if (units.IsEmpty) return default;
|
||||||
@@ -568,7 +568,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
ArrayPool<double>.Shared.Return(sharedArray);
|
ArrayPool<double>.Shared.Return(sharedArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static T Average<T>(this ReadOnlySpan<T?> units)
|
internal static T Average<T>(this ReadOnlySpan<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty)
|
if (units.IsEmpty)
|
||||||
@@ -607,7 +607,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
ArrayPool<double>.Shared.Return(sharedArray);
|
ArrayPool<double>.Shared.Return(sharedArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static T Max<T>(this ReadOnlySpan<T?> units)
|
internal static T Max<T>(this ReadOnlySpan<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty)
|
if (units.IsEmpty)
|
||||||
@@ -646,7 +646,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
ArrayPool<double>.Shared.Return(sharedArray);
|
ArrayPool<double>.Shared.Return(sharedArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static T Min<T>(this ReadOnlySpan<T?> units)
|
internal static T Min<T>(this ReadOnlySpan<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty)
|
if (units.IsEmpty)
|
||||||
@@ -687,29 +687,29 @@ public static partial class AggregateUnitExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
public static T Sum<T>(this List<T?> list)
|
internal static T Sum<T>(this List<T?> list)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
return CollectionsMarshal.AsSpan(list).Sum();
|
return CollectionsMarshal.AsSpan(list).Sum();
|
||||||
}
|
}
|
||||||
public static T Average<T>(this List<T?> list)
|
internal static T Average<T>(this List<T?> list)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
return CollectionsMarshal.AsSpan(list).Average();
|
return CollectionsMarshal.AsSpan(list).Average();
|
||||||
}
|
}
|
||||||
public static T Max<T>(this List<T?> list)
|
internal static T Max<T>(this List<T?> list)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
return CollectionsMarshal.AsSpan(list).Max();
|
return CollectionsMarshal.AsSpan(list).Max();
|
||||||
}
|
}
|
||||||
public static T Min<T>(this List<T?> list)
|
internal static T Min<T>(this List<T?> list)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
return CollectionsMarshal.AsSpan(list).Min();
|
return CollectionsMarshal.AsSpan(list).Min();
|
||||||
}
|
}
|
||||||
|
|
||||||
// === ICollection<T> ===
|
// === ICollection<T> ===
|
||||||
public static T Sum<T>(this ICollection<T?> collection)
|
internal static T Sum<T>(this ICollection<T?> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return default;
|
if (collection == null || collection.Count == 0) return default;
|
||||||
@@ -727,7 +727,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
ArrayPool<T?>.Shared.Return(sharedArray);
|
ArrayPool<T?>.Shared.Return(sharedArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static T Average<T>(this ICollection<T?> collection)
|
internal static T Average<T>(this ICollection<T?> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return double.NaN.ToUnit<T>();
|
if (collection == null || collection.Count == 0) return double.NaN.ToUnit<T>();
|
||||||
@@ -745,7 +745,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
ArrayPool<T?>.Shared.Return(sharedArray);
|
ArrayPool<T?>.Shared.Return(sharedArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static T Max<T>(this ICollection<T?> collection)
|
internal static T Max<T>(this ICollection<T?> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return double.MinValue.ToUnit<T>();
|
if (collection == null || collection.Count == 0) return double.MinValue.ToUnit<T>();
|
||||||
@@ -763,7 +763,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
ArrayPool<T?>.Shared.Return(sharedArray);
|
ArrayPool<T?>.Shared.Return(sharedArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static T Min<T>(this ICollection<T?> collection)
|
internal static T Min<T>(this ICollection<T?> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return double.MaxValue.ToUnit<T>();
|
if (collection == null || collection.Count == 0) return double.MaxValue.ToUnit<T>();
|
||||||
@@ -783,7 +783,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IReadOnlyCollection<T> ===
|
// === IReadOnlyCollection<T> ===
|
||||||
public static T Sum<T>(this IReadOnlyCollection<T?> collection)
|
internal static T Sum<T>(this IReadOnlyCollection<T?> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return default;
|
if (collection == null || collection.Count == 0) return default;
|
||||||
@@ -799,7 +799,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
}
|
}
|
||||||
finally { ArrayPool<T?>.Shared.Return(sharedArray); }
|
finally { ArrayPool<T?>.Shared.Return(sharedArray); }
|
||||||
}
|
}
|
||||||
public static T Average<T>(this IReadOnlyCollection<T?> collection)
|
internal static T Average<T>(this IReadOnlyCollection<T?> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return double.NaN.ToUnit<T>();
|
if (collection == null || collection.Count == 0) return double.NaN.ToUnit<T>();
|
||||||
@@ -815,7 +815,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
}
|
}
|
||||||
finally { ArrayPool<T?>.Shared.Return(sharedArray); }
|
finally { ArrayPool<T?>.Shared.Return(sharedArray); }
|
||||||
}
|
}
|
||||||
public static T Max<T>(this IReadOnlyCollection<T?> collection)
|
internal static T Max<T>(this IReadOnlyCollection<T?> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return double.MinValue.ToUnit<T>();
|
if (collection == null || collection.Count == 0) return double.MinValue.ToUnit<T>();
|
||||||
@@ -831,7 +831,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
}
|
}
|
||||||
finally { ArrayPool<T?>.Shared.Return(sharedArray); }
|
finally { ArrayPool<T?>.Shared.Return(sharedArray); }
|
||||||
}
|
}
|
||||||
public static T Min<T>(this IReadOnlyCollection<T?> collection)
|
internal static T Min<T>(this IReadOnlyCollection<T?> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null || collection.Count == 0) return double.MaxValue.ToUnit<T>();
|
if (collection == null || collection.Count == 0) return double.MaxValue.ToUnit<T>();
|
||||||
@@ -849,7 +849,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
public static T Sum<T>(this IEnumerable<T?> collection)
|
internal static T Sum<T>(this IEnumerable<T?> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null) return default;
|
if (collection == null) return default;
|
||||||
@@ -875,7 +875,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
|
|
||||||
return hasElements ? sum.ToUnit<T>() : default;
|
return hasElements ? sum.ToUnit<T>() : default;
|
||||||
}
|
}
|
||||||
public static T Average<T>(this IEnumerable<T?> collection)
|
internal static T Average<T>(this IEnumerable<T?> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null) return double.NaN.ToUnit<T>();
|
if (collection == null) return double.NaN.ToUnit<T>();
|
||||||
@@ -902,7 +902,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
double avg = sum / count;
|
double avg = sum / count;
|
||||||
return avg.ToUnit<T>();
|
return avg.ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static T Max<T>(this IEnumerable<T?> collection)
|
internal static T Max<T>(this IEnumerable<T?> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null) return double.MinValue.ToUnit<T>();
|
if (collection == null) return double.MinValue.ToUnit<T>();
|
||||||
@@ -927,7 +927,7 @@ public static partial class AggregateUnitExtensions
|
|||||||
|
|
||||||
return hasElements ? max.ToUnit<T>() : double.MinValue.ToUnit<T>();
|
return hasElements ? max.ToUnit<T>() : double.MinValue.ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static T Min<T>(this IEnumerable<T?> collection)
|
internal static T Min<T>(this IEnumerable<T?> collection)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (collection == null) return double.MaxValue.ToUnit<T>();
|
if (collection == null) return double.MaxValue.ToUnit<T>();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace QWERTYkez.Mensura.Extensions;
|
namespace QWERTYkez.Mensura.Extensions;
|
||||||
|
|
||||||
public static partial class CastExtensions
|
internal static partial class CastExtensions
|
||||||
{
|
{
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace QWERTYkez.Mensura.Extensions;
|
namespace QWERTYkez.Mensura.Extensions;
|
||||||
|
|
||||||
public static partial class CollectionsDivideExtensions
|
internal static partial class CollectionsDivideExtensions
|
||||||
{
|
{
|
||||||
// === DivideCore === SIMD
|
// === DivideCore === SIMD
|
||||||
internal static void DivideCore<T, R>(this ReadOnlySpan<T> units, double divisor, int len, Span<R> destination)
|
internal static void DivideCore<T, R>(this ReadOnlySpan<T> units, double divisor, int len, Span<R> destination)
|
||||||
@@ -165,7 +165,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
|
|
||||||
|
|
||||||
// === Array ===
|
// === Array ===
|
||||||
internal static R[] Divide<T, R>(this T[] units, double divisor)
|
internal static R[] Div<T, R>(this T[] units, double divisor)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -177,7 +177,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
units.DivideCore(divisor, len, result);
|
units.DivideCore(divisor, len, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
internal static R?[] Divide<T, R>(this T?[] units, double divisor)
|
internal static R?[] Div<T, R>(this T?[] units, double divisor)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -189,7 +189,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
units.DivideCore(divisor, len, result);
|
units.DivideCore(divisor, len, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
internal static R[] Divide<T, R>(this double dividend, T[] units)
|
internal static R[] Div<T, R>(this double dividend, T[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -201,7 +201,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
dividend.DivideCore(units, len, result);
|
dividend.DivideCore(units, len, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
internal static R?[] Divide<T, R>(this double dividend, T?[] units)
|
internal static R?[] Div<T, R>(this double dividend, T?[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -215,7 +215,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
internal static List<R> Divide<T, R>(this List<T> units, double divisor)
|
internal static List<R> Div<T, R>(this List<T> units, double divisor)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -227,7 +227,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
DivideCore(CollectionsMarshal.AsSpan(units), divisor, count, resultArray);
|
DivideCore(CollectionsMarshal.AsSpan(units), divisor, count, resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
internal static List<R?> Divide<T, R>(this List<T?> units, double divisor)
|
internal static List<R?> Div<T, R>(this List<T?> units, double divisor)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -239,7 +239,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
DivideCore(CollectionsMarshal.AsSpan(units), divisor, count, resultArray);
|
DivideCore(CollectionsMarshal.AsSpan(units), divisor, count, resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
internal static List<R> Divide<T, R>(this double dividend, List<T> units)
|
internal static List<R> Div<T, R>(this double dividend, List<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -251,7 +251,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
DivideCore(dividend, CollectionsMarshal.AsSpan(units), count, resultArray);
|
DivideCore(dividend, CollectionsMarshal.AsSpan(units), count, resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
internal static List<R?> Divide<T, R>(this double dividend, List<T?> units)
|
internal static List<R?> Div<T, R>(this double dividend, List<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -265,7 +265,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === ICollection<T> ===
|
// === ICollection<T> ===
|
||||||
internal static void Divide<T, R>(this ICollection<T> units, double divisor, Span<R> destination)
|
internal static void Div<T, R>(this ICollection<T> units, double divisor, Span<R> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -283,7 +283,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (item.ToDouble() * invDivisor).ToUnit<R>();
|
destination[i++] = (item.ToDouble() * invDivisor).ToUnit<R>();
|
||||||
}
|
}
|
||||||
internal static void Divide<T, R>(this ICollection<T?> units, double divisor, Span<R?> destination)
|
internal static void Div<T, R>(this ICollection<T?> units, double divisor, Span<R?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -302,7 +302,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
destination[i++] = item.HasValue
|
destination[i++] = item.HasValue
|
||||||
? (item.Value.ToDouble() * invDivisor).ToUnit<R>() : null;
|
? (item.Value.ToDouble() * invDivisor).ToUnit<R>() : null;
|
||||||
}
|
}
|
||||||
internal static void Divide<T, R>(this double dividend, ICollection<T> units, Span<R> destination)
|
internal static void Div<T, R>(this double dividend, ICollection<T> units, Span<R> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -319,7 +319,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (dividend / item.ToDouble()).ToUnit<R>();
|
destination[i++] = (dividend / item.ToDouble()).ToUnit<R>();
|
||||||
}
|
}
|
||||||
internal static void Divide<T, R>(this double dividend, ICollection<T?> units, Span<R?> destination)
|
internal static void Div<T, R>(this double dividend, ICollection<T?> units, Span<R?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -339,7 +339,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IReadOnlyCollection<T> ===
|
// === IReadOnlyCollection<T> ===
|
||||||
internal static void Divide<T, R>(this IReadOnlyCollection<T> units, double divisor, Span<R> destination)
|
internal static void Div<T, R>(this IReadOnlyCollection<T> units, double divisor, Span<R> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -357,7 +357,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (item.ToDouble() * invDivisor).ToUnit<R>();
|
destination[i++] = (item.ToDouble() * invDivisor).ToUnit<R>();
|
||||||
}
|
}
|
||||||
internal static void Divide<T, R>(this IReadOnlyCollection<T?> units, double divisor, Span<R?> destination)
|
internal static void Div<T, R>(this IReadOnlyCollection<T?> units, double divisor, Span<R?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -376,7 +376,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
destination[i++] = item.HasValue
|
destination[i++] = item.HasValue
|
||||||
? (item.Value.ToDouble() * invDivisor).ToUnit<R>() : null;
|
? (item.Value.ToDouble() * invDivisor).ToUnit<R>() : null;
|
||||||
}
|
}
|
||||||
internal static void Divide<T, R>(this double dividend, IReadOnlyCollection<T> units, Span<R> destination)
|
internal static void Div<T, R>(this double dividend, IReadOnlyCollection<T> units, Span<R> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -393,7 +393,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (dividend / item.ToDouble()).ToUnit<R>();
|
destination[i++] = (dividend / item.ToDouble()).ToUnit<R>();
|
||||||
}
|
}
|
||||||
internal static void Divide<T, R>(this double dividend, IReadOnlyCollection<T?> units, Span<R?> destination)
|
internal static void Div<T, R>(this double dividend, IReadOnlyCollection<T?> units, Span<R?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -447,86 +447,86 @@ public static partial class CollectionsDivideExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
internal static IEnumerable<R> Divide<T, R>(this IEnumerable<T> units, double divisor)
|
internal static IEnumerable<R> Div<T, R>(this IEnumerable<T> units, double divisor)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
if (units is T[] array) return array.Divide<T, R>(divisor);
|
if (units is T[] array) return array.Div<T, R>(divisor);
|
||||||
if (units is List<T> list) return list.Divide<T, R>(divisor);
|
if (units is List<T> list) return list.Div<T, R>(divisor);
|
||||||
if (units is ICollection<T> col)
|
if (units is ICollection<T> col)
|
||||||
{
|
{
|
||||||
var arr = col.ToArray();
|
var arr = col.ToArray();
|
||||||
arr.Divide(divisor, arr);
|
arr.Div(divisor, arr);
|
||||||
return arr.ReCast<T, R>();
|
return arr.ReCast<T, R>();
|
||||||
}
|
}
|
||||||
if (units is IReadOnlyCollection<T> roc)
|
if (units is IReadOnlyCollection<T> roc)
|
||||||
{
|
{
|
||||||
var arr = roc.ToArray();
|
var arr = roc.ToArray();
|
||||||
arr.Divide(divisor, arr);
|
arr.Div(divisor, arr);
|
||||||
return arr.ReCast<T, R>();
|
return arr.ReCast<T, R>();
|
||||||
}
|
}
|
||||||
return DivideIterator<T, R>(units, divisor);
|
return DivideIterator<T, R>(units, divisor);
|
||||||
}
|
}
|
||||||
internal static IEnumerable<R?> Divide<T, R>(this IEnumerable<T?> units, double divisor)
|
internal static IEnumerable<R?> Div<T, R>(this IEnumerable<T?> units, double divisor)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
if (units is T?[] array) return array.Divide<T, R>(divisor);
|
if (units is T?[] array) return array.Div<T, R>(divisor);
|
||||||
if (units is List<T?> list) return list.Divide<T, R>(divisor);
|
if (units is List<T?> list) return list.Div<T, R>(divisor);
|
||||||
if (units is ICollection<T?> col)
|
if (units is ICollection<T?> col)
|
||||||
{
|
{
|
||||||
var arr = col.ToArray();
|
var arr = col.ToArray();
|
||||||
arr.Divide(divisor, arr);
|
arr.Div(divisor, arr);
|
||||||
return arr.ReCast<T, R>();
|
return arr.ReCast<T, R>();
|
||||||
}
|
}
|
||||||
if (units is IReadOnlyCollection<T?> roc)
|
if (units is IReadOnlyCollection<T?> roc)
|
||||||
{
|
{
|
||||||
var arr = roc.ToArray();
|
var arr = roc.ToArray();
|
||||||
arr.Divide(divisor, arr);
|
arr.Div(divisor, arr);
|
||||||
return arr.ReCast<T, R>();
|
return arr.ReCast<T, R>();
|
||||||
}
|
}
|
||||||
return DivideNullableIterator<T, R>(units, divisor);
|
return DivideNullableIterator<T, R>(units, divisor);
|
||||||
}
|
}
|
||||||
internal static IEnumerable<R> Divide<T, R>(this double dividend, IEnumerable<T> units)
|
internal static IEnumerable<R> Div<T, R>(this double dividend, IEnumerable<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
if (units is T[] array) return dividend.Divide<T, R>(array);
|
if (units is T[] array) return dividend.Div<T, R>(array);
|
||||||
if (units is List<T> list) return dividend.Divide<T, R>(list);
|
if (units is List<T> list) return dividend.Div<T, R>(list);
|
||||||
if (units is ICollection<T> col)
|
if (units is ICollection<T> col)
|
||||||
{
|
{
|
||||||
var arr = col.ToArray();
|
var arr = col.ToArray();
|
||||||
dividend.Divide(arr, arr);
|
dividend.Div(arr, arr);
|
||||||
return arr.ReCast<T, R>();
|
return arr.ReCast<T, R>();
|
||||||
}
|
}
|
||||||
if (units is IReadOnlyCollection<T> roc)
|
if (units is IReadOnlyCollection<T> roc)
|
||||||
{
|
{
|
||||||
var arr = roc.ToArray();
|
var arr = roc.ToArray();
|
||||||
dividend.Divide(arr, arr);
|
dividend.Div(arr, arr);
|
||||||
return arr.ReCast<T, R>();
|
return arr.ReCast<T, R>();
|
||||||
}
|
}
|
||||||
return DivideIterator<T, R>(dividend, units);
|
return DivideIterator<T, R>(dividend, units);
|
||||||
}
|
}
|
||||||
internal static IEnumerable<R?> Divide<T, R>(this double dividend, IEnumerable<T?> units)
|
internal static IEnumerable<R?> Div<T, R>(this double dividend, IEnumerable<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
if (units is T?[] array) return dividend.Divide<T, R>(array);
|
if (units is T?[] array) return dividend.Div<T, R>(array);
|
||||||
if (units is List<T?> list) return dividend.Divide<T, R>(list);
|
if (units is List<T?> list) return dividend.Div<T, R>(list);
|
||||||
if (units is ICollection<T?> col)
|
if (units is ICollection<T?> col)
|
||||||
{
|
{
|
||||||
var arr = col.ToArray();
|
var arr = col.ToArray();
|
||||||
dividend.Divide(arr, arr);
|
dividend.Div(arr, arr);
|
||||||
return arr.ReCast<T, R>();
|
return arr.ReCast<T, R>();
|
||||||
}
|
}
|
||||||
if (units is IReadOnlyCollection<T?> roc)
|
if (units is IReadOnlyCollection<T?> roc)
|
||||||
{
|
{
|
||||||
var arr = roc.ToArray();
|
var arr = roc.ToArray();
|
||||||
dividend.Divide(arr, arr);
|
dividend.Div(arr, arr);
|
||||||
return arr.ReCast<T, R>();
|
return arr.ReCast<T, R>();
|
||||||
}
|
}
|
||||||
return DivideNullableIterator<T, R>(dividend, units);
|
return DivideNullableIterator<T, R>(dividend, units);
|
||||||
@@ -537,7 +537,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
|
|
||||||
|
|
||||||
// === ReadOnlySpan
|
// === ReadOnlySpan
|
||||||
public static void Divide<T>(this ReadOnlySpan<T> units, double divisor, Span<T> destination)
|
internal static void Div<T>(this ReadOnlySpan<T> units, double divisor, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return;
|
if (units.IsEmpty) return;
|
||||||
@@ -547,7 +547,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
|
|
||||||
units.DivideCore(divisor, len, destination);
|
units.DivideCore(divisor, len, destination);
|
||||||
}
|
}
|
||||||
public static void Divide<T>(this ReadOnlySpan<T?> units, double divisor, Span<T?> destination)
|
internal static void Div<T>(this ReadOnlySpan<T?> units, double divisor, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return;
|
if (units.IsEmpty) return;
|
||||||
@@ -557,7 +557,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
|
|
||||||
units.DivideCore(divisor, len, destination);
|
units.DivideCore(divisor, len, destination);
|
||||||
}
|
}
|
||||||
public static void Divide<T>(this double dividend, ReadOnlySpan<T> units, Span<T> destination)
|
internal static void Div<T>(this double dividend, ReadOnlySpan<T> units, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return;
|
if (units.IsEmpty) return;
|
||||||
@@ -567,7 +567,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
|
|
||||||
dividend.DivideCore(units, len, destination);
|
dividend.DivideCore(units, len, destination);
|
||||||
}
|
}
|
||||||
public static void Divide<T>(this double dividend, ReadOnlySpan<T?> units, Span<T?> destination)
|
internal static void Div<T>(this double dividend, ReadOnlySpan<T?> units, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return;
|
if (units.IsEmpty) return;
|
||||||
@@ -579,7 +579,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === Array ===
|
// === Array ===
|
||||||
public static T[] Divide<T>(this T[] units, double divisor)
|
internal static T[] Div<T>(this T[] units, double divisor)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -587,10 +587,10 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (len == 0) return [];
|
if (len == 0) return [];
|
||||||
|
|
||||||
var result = new T[len];
|
var result = new T[len];
|
||||||
Divide(units, divisor, result);
|
Div(units, divisor, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static T?[] Divide<T>(this T?[] units, double divisor)
|
internal static T?[] Div<T>(this T?[] units, double divisor)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -598,10 +598,10 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (len == 0) return [];
|
if (len == 0) return [];
|
||||||
|
|
||||||
var result = new T?[len];
|
var result = new T?[len];
|
||||||
Divide(units, divisor, result);
|
Div(units, divisor, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static T[] Divide<T>(this double dividend, T[] units)
|
internal static T[] Div<T>(this double dividend, T[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -609,10 +609,10 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (len == 0) return [];
|
if (len == 0) return [];
|
||||||
|
|
||||||
var result = new T[len];
|
var result = new T[len];
|
||||||
Divide(dividend, units, result);
|
Div(dividend, units, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static T?[] Divide<T>(this double dividend, T?[] units)
|
internal static T?[] Div<T>(this double dividend, T?[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -620,12 +620,12 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (len == 0) return [];
|
if (len == 0) return [];
|
||||||
|
|
||||||
var result = new T?[len];
|
var result = new T?[len];
|
||||||
Divide(dividend, units, result);
|
Div(dividend, units, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
public static List<T> Divide<T>(this List<T> units, double divisor)
|
internal static List<T> Div<T>(this List<T> units, double divisor)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -633,10 +633,10 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (len == 0) return [];
|
if (len == 0) return [];
|
||||||
|
|
||||||
var resultArray = new T[len];
|
var resultArray = new T[len];
|
||||||
Divide(CollectionsMarshal.AsSpan(units), divisor, resultArray);
|
Div(CollectionsMarshal.AsSpan(units), divisor, resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
public static List<T?> Divide<T>(this List<T?> units, double divisor)
|
internal static List<T?> Div<T>(this List<T?> units, double divisor)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -644,10 +644,10 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (count == 0) return [];
|
if (count == 0) return [];
|
||||||
|
|
||||||
var resultArray = new T?[count];
|
var resultArray = new T?[count];
|
||||||
Divide(CollectionsMarshal.AsSpan(units), divisor, resultArray);
|
Div(CollectionsMarshal.AsSpan(units), divisor, resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
public static List<T> Divide<T>(this double dividend, List<T> units)
|
internal static List<T> Div<T>(this double dividend, List<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -655,10 +655,10 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (count == 0) return [];
|
if (count == 0) return [];
|
||||||
|
|
||||||
var resultArray = new T[count];
|
var resultArray = new T[count];
|
||||||
Divide(dividend, CollectionsMarshal.AsSpan(units), resultArray);
|
Div(dividend, CollectionsMarshal.AsSpan(units), resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
public static List<T?> Divide<T>(this double dividend, List<T?> units)
|
internal static List<T?> Div<T>(this double dividend, List<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -666,12 +666,12 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (count == 0) return [];
|
if (count == 0) return [];
|
||||||
|
|
||||||
var resultArray = new T?[count];
|
var resultArray = new T?[count];
|
||||||
Divide(dividend, CollectionsMarshal.AsSpan(units), resultArray);
|
Div(dividend, CollectionsMarshal.AsSpan(units), resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// === ICollection<T> ===
|
// === ICollection<T> ===
|
||||||
public static void Divide<T>(this ICollection<T> units, double divisor, Span<T> destination)
|
internal static void Div<T>(this ICollection<T> units, double divisor, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -680,15 +680,15 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (destination.Length < count)
|
if (destination.Length < count)
|
||||||
throw new ArgumentException("Destination too short");
|
throw new ArgumentException("Destination too short");
|
||||||
|
|
||||||
if (units is T[] array) { array.Divide(divisor, destination); return; }
|
if (units is T[] array) { array.Div(divisor, destination); return; }
|
||||||
if (units is List<T> list) { CollectionsMarshal.AsSpan(list).Divide(divisor, destination); return; }
|
if (units is List<T> list) { CollectionsMarshal.AsSpan(list).Div(divisor, destination); return; }
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
double invDivisor = 1.0 / divisor;
|
double invDivisor = 1.0 / divisor;
|
||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (item.ToDouble() * invDivisor).ToUnit<T>();
|
destination[i++] = (item.ToDouble() * invDivisor).ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static void Divide<T>(this ICollection<T?> units, double divisor, Span<T?> destination)
|
internal static void Div<T>(this ICollection<T?> units, double divisor, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -697,8 +697,8 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (destination.Length < count)
|
if (destination.Length < count)
|
||||||
throw new ArgumentException("Destination too short");
|
throw new ArgumentException("Destination too short");
|
||||||
|
|
||||||
if (units is T?[] array) { array.Divide(divisor, destination); return; }
|
if (units is T?[] array) { array.Div(divisor, destination); return; }
|
||||||
if (units is List<T?> list) { CollectionsMarshal.AsSpan(list).Divide(divisor, destination); return; }
|
if (units is List<T?> list) { CollectionsMarshal.AsSpan(list).Div(divisor, destination); return; }
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
double invDivisor = 1.0 / divisor;
|
double invDivisor = 1.0 / divisor;
|
||||||
@@ -706,7 +706,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
destination[i++] = item.HasValue
|
destination[i++] = item.HasValue
|
||||||
? (item.Value.ToDouble() * invDivisor).ToUnit<T>() : null;
|
? (item.Value.ToDouble() * invDivisor).ToUnit<T>() : null;
|
||||||
}
|
}
|
||||||
public static void Divide<T>(this double dividend, ICollection<T> units, Span<T> destination)
|
internal static void Div<T>(this double dividend, ICollection<T> units, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -715,14 +715,14 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (destination.Length < count)
|
if (destination.Length < count)
|
||||||
throw new ArgumentException("Destination too short");
|
throw new ArgumentException("Destination too short");
|
||||||
|
|
||||||
if (units is T[] array) { dividend.Divide(array, destination); return; }
|
if (units is T[] array) { dividend.Div(array, destination); return; }
|
||||||
if (units is List<T> list) { dividend.Divide(CollectionsMarshal.AsSpan(list), destination); return; }
|
if (units is List<T> list) { dividend.Div(CollectionsMarshal.AsSpan(list), destination); return; }
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (dividend / item.ToDouble()).ToUnit<T>();
|
destination[i++] = (dividend / item.ToDouble()).ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static void Divide<T>(this double dividend, ICollection<T?> units, Span<T?> destination)
|
internal static void Div<T>(this double dividend, ICollection<T?> units, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -731,8 +731,8 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (destination.Length < count)
|
if (destination.Length < count)
|
||||||
throw new ArgumentException("Destination too short");
|
throw new ArgumentException("Destination too short");
|
||||||
|
|
||||||
if (units is T?[] array) { dividend.Divide(array, destination); return; }
|
if (units is T?[] array) { dividend.Div(array, destination); return; }
|
||||||
if (units is List<T?> list) { dividend.Divide(CollectionsMarshal.AsSpan(list), destination); return; }
|
if (units is List<T?> list) { dividend.Div(CollectionsMarshal.AsSpan(list), destination); return; }
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
@@ -741,7 +741,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IReadOnlyCollection<T> ===
|
// === IReadOnlyCollection<T> ===
|
||||||
public static void Divide<T>(this IReadOnlyCollection<T> units, double divisor, Span<T> destination)
|
internal static void Div<T>(this IReadOnlyCollection<T> units, double divisor, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -750,15 +750,15 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (destination.Length < count)
|
if (destination.Length < count)
|
||||||
throw new ArgumentException("Destination too short");
|
throw new ArgumentException("Destination too short");
|
||||||
|
|
||||||
if (units is T[] array) { array.Divide(divisor, destination); return; }
|
if (units is T[] array) { array.Div(divisor, destination); return; }
|
||||||
if (units is List<T> list) { CollectionsMarshal.AsSpan(list).Divide(divisor, destination); return; }
|
if (units is List<T> list) { CollectionsMarshal.AsSpan(list).Div(divisor, destination); return; }
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
double invDivisor = 1.0 / divisor;
|
double invDivisor = 1.0 / divisor;
|
||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (item.ToDouble() * invDivisor).ToUnit<T>();
|
destination[i++] = (item.ToDouble() * invDivisor).ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static void Divide<T>(this IReadOnlyCollection<T?> units, double divisor, Span<T?> destination)
|
internal static void Div<T>(this IReadOnlyCollection<T?> units, double divisor, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -767,8 +767,8 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (destination.Length < count)
|
if (destination.Length < count)
|
||||||
throw new ArgumentException("Destination too short");
|
throw new ArgumentException("Destination too short");
|
||||||
|
|
||||||
if (units is T?[] array) { array.Divide(divisor, destination); return; }
|
if (units is T?[] array) { array.Div(divisor, destination); return; }
|
||||||
if (units is List<T?> list) { CollectionsMarshal.AsSpan(list).Divide(divisor, destination); return; }
|
if (units is List<T?> list) { CollectionsMarshal.AsSpan(list).Div(divisor, destination); return; }
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
double invDivisor = 1.0 / divisor;
|
double invDivisor = 1.0 / divisor;
|
||||||
@@ -776,7 +776,7 @@ public static partial class CollectionsDivideExtensions
|
|||||||
destination[i++] = item.HasValue
|
destination[i++] = item.HasValue
|
||||||
? (item.Value.ToDouble() * invDivisor).ToUnit<T>() : null;
|
? (item.Value.ToDouble() * invDivisor).ToUnit<T>() : null;
|
||||||
}
|
}
|
||||||
public static void Divide<T>(this double dividend, IReadOnlyCollection<T> units, Span<T> destination)
|
internal static void Div<T>(this double dividend, IReadOnlyCollection<T> units, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -785,14 +785,14 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (destination.Length < count)
|
if (destination.Length < count)
|
||||||
throw new ArgumentException("Destination too short");
|
throw new ArgumentException("Destination too short");
|
||||||
|
|
||||||
if (units is T[] array) { dividend.Divide(array, destination); return; }
|
if (units is T[] array) { dividend.Div(array, destination); return; }
|
||||||
if (units is List<T> list) { dividend.Divide(CollectionsMarshal.AsSpan(list), destination); return; }
|
if (units is List<T> list) { dividend.Div(CollectionsMarshal.AsSpan(list), destination); return; }
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (dividend / item.ToDouble()).ToUnit<T>();
|
destination[i++] = (dividend / item.ToDouble()).ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static void Divide<T>(this double dividend, IReadOnlyCollection<T?> units, Span<T?> destination)
|
internal static void Div<T>(this double dividend, IReadOnlyCollection<T?> units, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -801,8 +801,8 @@ public static partial class CollectionsDivideExtensions
|
|||||||
if (destination.Length < count)
|
if (destination.Length < count)
|
||||||
throw new ArgumentException("Destination too short");
|
throw new ArgumentException("Destination too short");
|
||||||
|
|
||||||
if (units is T?[] array) { dividend.Divide(array, destination); return; }
|
if (units is T?[] array) { dividend.Div(array, destination); return; }
|
||||||
if (units is List<T?> list) { dividend.Divide(CollectionsMarshal.AsSpan(list), destination); return; }
|
if (units is List<T?> list) { dividend.Div(CollectionsMarshal.AsSpan(list), destination); return; }
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
@@ -841,82 +841,82 @@ public static partial class CollectionsDivideExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
public static IEnumerable<T> Divide<T>(this IEnumerable<T> units, double divisor)
|
internal static IEnumerable<T> Div<T>(this IEnumerable<T> units, double divisor)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
if (units is T[] array) return array.Divide(divisor);
|
if (units is T[] array) return array.Div(divisor);
|
||||||
if (units is List<T> list) return list.Divide(divisor);
|
if (units is List<T> list) return list.Div(divisor);
|
||||||
if (units is ICollection<T> col)
|
if (units is ICollection<T> col)
|
||||||
{
|
{
|
||||||
var arr = col.ToArray();
|
var arr = col.ToArray();
|
||||||
arr.Divide(divisor, arr);
|
arr.Div(divisor, arr);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
if (units is IReadOnlyCollection<T> roc)
|
if (units is IReadOnlyCollection<T> roc)
|
||||||
{
|
{
|
||||||
var arr = roc.ToArray();
|
var arr = roc.ToArray();
|
||||||
arr.Divide(divisor, arr);
|
arr.Div(divisor, arr);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
return DivideIterator(units, divisor);
|
return DivideIterator(units, divisor);
|
||||||
}
|
}
|
||||||
public static IEnumerable<T?> Divide<T>(this IEnumerable<T?> units, double divisor)
|
internal static IEnumerable<T?> Div<T>(this IEnumerable<T?> units, double divisor)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
if (units is T?[] array) return array.Divide(divisor);
|
if (units is T?[] array) return array.Div(divisor);
|
||||||
if (units is List<T?> list) return list.Divide(divisor);
|
if (units is List<T?> list) return list.Div(divisor);
|
||||||
if (units is ICollection<T?> col)
|
if (units is ICollection<T?> col)
|
||||||
{
|
{
|
||||||
var arr = col.ToArray();
|
var arr = col.ToArray();
|
||||||
arr.Divide(divisor, arr);
|
arr.Div(divisor, arr);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
if (units is IReadOnlyCollection<T?> roc)
|
if (units is IReadOnlyCollection<T?> roc)
|
||||||
{
|
{
|
||||||
var arr = roc.ToArray();
|
var arr = roc.ToArray();
|
||||||
arr.Divide(divisor, arr);
|
arr.Div(divisor, arr);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
return DivideNullableIterator(units, divisor);
|
return DivideNullableIterator(units, divisor);
|
||||||
}
|
}
|
||||||
public static IEnumerable<T> Divide<T>(this double dividend, IEnumerable<T> units)
|
internal static IEnumerable<T> Div<T>(this double dividend, IEnumerable<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
if (units is T[] array) return dividend.Divide(array);
|
if (units is T[] array) return dividend.Div(array);
|
||||||
if (units is List<T> list) return dividend.Divide(list);
|
if (units is List<T> list) return dividend.Div(list);
|
||||||
if (units is ICollection<T> col)
|
if (units is ICollection<T> col)
|
||||||
{
|
{
|
||||||
var arr = col.ToArray();
|
var arr = col.ToArray();
|
||||||
dividend.Divide(arr, arr);
|
dividend.Div(arr, arr);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
if (units is IReadOnlyCollection<T> roc)
|
if (units is IReadOnlyCollection<T> roc)
|
||||||
{
|
{
|
||||||
var arr = roc.ToArray();
|
var arr = roc.ToArray();
|
||||||
dividend.Divide(arr, arr);
|
dividend.Div(arr, arr);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
return DivideIterator(dividend, units);
|
return DivideIterator(dividend, units);
|
||||||
}
|
}
|
||||||
public static IEnumerable<T?> Divide<T>(this double dividend, IEnumerable<T?> units)
|
internal static IEnumerable<T?> Div<T>(this double dividend, IEnumerable<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
if (units is T?[] array) return dividend.Divide(array);
|
if (units is T?[] array) return dividend.Div(array);
|
||||||
if (units is List<T?> list) return dividend.Divide(list);
|
if (units is List<T?> list) return dividend.Div(list);
|
||||||
if (units is ICollection<T?> col)
|
if (units is ICollection<T?> col)
|
||||||
{
|
{
|
||||||
var arr = col.ToArray();
|
var arr = col.ToArray();
|
||||||
dividend.Divide(arr, arr);
|
dividend.Div(arr, arr);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
if (units is IReadOnlyCollection<T?> roc)
|
if (units is IReadOnlyCollection<T?> roc)
|
||||||
{
|
{
|
||||||
var arr = roc.ToArray();
|
var arr = roc.ToArray();
|
||||||
dividend.Divide(arr, arr);
|
dividend.Div(arr, arr);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
return DivideNullableIterator(dividend, units);
|
return DivideNullableIterator(dividend, units);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace QWERTYkez.Mensura.Extensions;
|
namespace QWERTYkez.Mensura.Extensions;
|
||||||
|
|
||||||
public static partial class CollectionsMinusExtensions
|
internal static partial class CollectionsMinusExtensions
|
||||||
{
|
{
|
||||||
// === MinusCore === SIMD
|
// === MinusCore === SIMD
|
||||||
internal static void MinusCore<T, R>(this ReadOnlySpan<T> units, double subtrahend, int len, Span<R> destination)
|
internal static void MinusCore<T, R>(this ReadOnlySpan<T> units, double subtrahend, int len, Span<R> destination)
|
||||||
@@ -526,7 +526,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
|
|
||||||
|
|
||||||
// === ReadOnlySpan
|
// === ReadOnlySpan
|
||||||
public static void Minus<T>(this ReadOnlySpan<T> units, double subtrahend, Span<T> destination)
|
internal static void Minus<T>(this ReadOnlySpan<T> units, double subtrahend, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return;
|
if (units.IsEmpty) return;
|
||||||
@@ -536,7 +536,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
|
|
||||||
units.MinusCore(subtrahend, len, destination);
|
units.MinusCore(subtrahend, len, destination);
|
||||||
}
|
}
|
||||||
public static void Minus<T>(this ReadOnlySpan<T?> units, double subtrahend, Span<T?> destination)
|
internal static void Minus<T>(this ReadOnlySpan<T?> units, double subtrahend, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return;
|
if (units.IsEmpty) return;
|
||||||
@@ -547,7 +547,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
units.MinusCore(subtrahend, len, destination);
|
units.MinusCore(subtrahend, len, destination);
|
||||||
}
|
}
|
||||||
//SIMD
|
//SIMD
|
||||||
public static void Minus<T>(this double minuend, ReadOnlySpan<T> units, Span<T> destination)
|
internal static void Minus<T>(this double minuend, ReadOnlySpan<T> units, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return;
|
if (units.IsEmpty) return;
|
||||||
@@ -557,7 +557,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
|
|
||||||
minuend.MinusCore(units, len, destination);
|
minuend.MinusCore(units, len, destination);
|
||||||
}
|
}
|
||||||
public static void Minus<T>(this double minuend, ReadOnlySpan<T?> units, Span<T?> destination)
|
internal static void Minus<T>(this double minuend, ReadOnlySpan<T?> units, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return;
|
if (units.IsEmpty) return;
|
||||||
@@ -569,7 +569,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === Array ===
|
// === Array ===
|
||||||
public static T[] Minus<T>(this T[] units, double subtrahend)
|
internal static T[] Minus<T>(this T[] units, double subtrahend)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -580,7 +580,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
Minus(units, subtrahend, result);
|
Minus(units, subtrahend, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static T?[] Minus<T>(this T?[] units, double subtrahend)
|
internal static T?[] Minus<T>(this T?[] units, double subtrahend)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -591,7 +591,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
Minus(units, subtrahend, result);
|
Minus(units, subtrahend, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static T[] Minus<T>(this double minuend, T[] units)
|
internal static T[] Minus<T>(this double minuend, T[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -602,7 +602,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
Minus(minuend, units, result);
|
Minus(minuend, units, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static T?[] Minus<T>(this double minuend, T?[] units)
|
internal static T?[] Minus<T>(this double minuend, T?[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -615,7 +615,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
public static List<T> Minus<T>(this List<T> units, double subtrahend)
|
internal static List<T> Minus<T>(this List<T> units, double subtrahend)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -626,7 +626,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
Minus(CollectionsMarshal.AsSpan(units), subtrahend, resultArray);
|
Minus(CollectionsMarshal.AsSpan(units), subtrahend, resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
public static List<T?> Minus<T>(this List<T?> units, double subtrahend)
|
internal static List<T?> Minus<T>(this List<T?> units, double subtrahend)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -637,7 +637,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
Minus(CollectionsMarshal.AsSpan(units), subtrahend, resultArray);
|
Minus(CollectionsMarshal.AsSpan(units), subtrahend, resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
public static List<T> Minus<T>(this double minuend, List<T> units)
|
internal static List<T> Minus<T>(this double minuend, List<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -648,7 +648,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
Minus(minuend, CollectionsMarshal.AsSpan(units), resultArray);
|
Minus(minuend, CollectionsMarshal.AsSpan(units), resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
public static List<T?> Minus<T>(this double minuend, List<T?> units)
|
internal static List<T?> Minus<T>(this double minuend, List<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -661,7 +661,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === ICollection<T> ===
|
// === ICollection<T> ===
|
||||||
public static void Minus<T>(this ICollection<T> units, double subtrahend, Span<T> destination)
|
internal static void Minus<T>(this ICollection<T> units, double subtrahend, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -677,7 +677,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (item.ToDouble() - subtrahend).ToUnit<T>();
|
destination[i++] = (item.ToDouble() - subtrahend).ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static void Minus<T>(this ICollection<T?> units, double subtrahend, Span<T?> destination)
|
internal static void Minus<T>(this ICollection<T?> units, double subtrahend, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -694,7 +694,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
destination[i++] = item.HasValue
|
destination[i++] = item.HasValue
|
||||||
? (item.Value.ToDouble() - subtrahend).ToUnit<T>() : null;
|
? (item.Value.ToDouble() - subtrahend).ToUnit<T>() : null;
|
||||||
}
|
}
|
||||||
public static void Minus<T>(this double minuend, ICollection<T> units, Span<T> destination)
|
internal static void Minus<T>(this double minuend, ICollection<T> units, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -710,7 +710,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (minuend - item.ToDouble()).ToUnit<T>();
|
destination[i++] = (minuend - item.ToDouble()).ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static void Minus<T>(this double minuend, ICollection<T?> units, Span<T?> destination)
|
internal static void Minus<T>(this double minuend, ICollection<T?> units, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -729,7 +729,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IReadOnlyCollection<T> ===
|
// === IReadOnlyCollection<T> ===
|
||||||
public static void Minus<T>(this IReadOnlyCollection<T> units, double subtrahend, Span<T> destination)
|
internal static void Minus<T>(this IReadOnlyCollection<T> units, double subtrahend, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -745,7 +745,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (item.ToDouble() - subtrahend).ToUnit<T>();
|
destination[i++] = (item.ToDouble() - subtrahend).ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static void Minus<T>(this IReadOnlyCollection<T?> units, double subtrahend, Span<T?> destination)
|
internal static void Minus<T>(this IReadOnlyCollection<T?> units, double subtrahend, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -762,7 +762,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
destination[i++] = item.HasValue
|
destination[i++] = item.HasValue
|
||||||
? (item.Value.ToDouble() - subtrahend).ToUnit<T>() : null;
|
? (item.Value.ToDouble() - subtrahend).ToUnit<T>() : null;
|
||||||
}
|
}
|
||||||
public static void Minus<T>(this double minuend, IReadOnlyCollection<T> units, Span<T> destination)
|
internal static void Minus<T>(this double minuend, IReadOnlyCollection<T> units, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -778,7 +778,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (minuend - item.ToDouble()).ToUnit<T>();
|
destination[i++] = (minuend - item.ToDouble()).ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static void Minus<T>(this double minuend, IReadOnlyCollection<T?> units, Span<T?> destination)
|
internal static void Minus<T>(this double minuend, IReadOnlyCollection<T?> units, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -825,7 +825,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
public static IEnumerable<T> Minus<T>(this IEnumerable<T> units, double subtrahend)
|
internal static IEnumerable<T> Minus<T>(this IEnumerable<T> units, double subtrahend)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -845,7 +845,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
}
|
}
|
||||||
return MinusIterator(units, subtrahend);
|
return MinusIterator(units, subtrahend);
|
||||||
}
|
}
|
||||||
public static IEnumerable<T?> Minus<T>(this IEnumerable<T?> units, double subtrahend)
|
internal static IEnumerable<T?> Minus<T>(this IEnumerable<T?> units, double subtrahend)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -865,7 +865,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
}
|
}
|
||||||
return MinusNullableIterator(units, subtrahend);
|
return MinusNullableIterator(units, subtrahend);
|
||||||
}
|
}
|
||||||
public static IEnumerable<T> Minus<T>(this double minuend, IEnumerable<T> units)
|
internal static IEnumerable<T> Minus<T>(this double minuend, IEnumerable<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -885,7 +885,7 @@ public static partial class CollectionsMinusExtensions
|
|||||||
}
|
}
|
||||||
return MinusIterator(minuend, units);
|
return MinusIterator(minuend, units);
|
||||||
}
|
}
|
||||||
public static IEnumerable<T?> Minus<T>(this double minuend, IEnumerable<T?> units)
|
internal static IEnumerable<T?> Minus<T>(this double minuend, IEnumerable<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace QWERTYkez.Mensura.Extensions;
|
namespace QWERTYkez.Mensura.Extensions;
|
||||||
|
|
||||||
public static partial class CollectionsMultiplyExtensions
|
internal static partial class CollectionsMultiplyExtensions
|
||||||
{
|
{
|
||||||
// === MultiplyCore === SIMD
|
// === MultiplyCore === SIMD
|
||||||
internal static void MultiplyCore<T, R>(this ReadOnlySpan<T> units, double multiplicator, int len, Span<R> destination)
|
internal static void MultiplyCore<T, R>(this ReadOnlySpan<T> units, double multiplicator, int len, Span<R> destination)
|
||||||
@@ -91,7 +91,7 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
|
|
||||||
|
|
||||||
// === Array ===
|
// === Array ===
|
||||||
internal static R[] Multiply<T, R>(this T[] units, double multiplicator)
|
internal static R[] Mul<T, R>(this T[] units, double multiplicator)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -103,7 +103,7 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
units.MultiplyCore(multiplicator, len, result);
|
units.MultiplyCore(multiplicator, len, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
internal static R?[] Multiply<T, R>(this T?[] units, double multiplicator)
|
internal static R?[] Mul<T, R>(this T?[] units, double multiplicator)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -117,17 +117,17 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal static R[] Multiply<T, R>(this double multiplicator, T[] units)
|
internal static R[] Mul<T, R>(this double multiplicator, T[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R> => units.Multiply<T, R>(multiplicator);
|
where R : struct, IMensuraUnit, IEquatable<R> => units.Mul<T, R>(multiplicator);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal static R?[] Multiply<T, R>(this double multiplicator, T?[] units)
|
internal static R?[] Mul<T, R>(this double multiplicator, T?[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R> => units.Multiply<T, R>(multiplicator);
|
where R : struct, IMensuraUnit, IEquatable<R> => units.Mul<T, R>(multiplicator);
|
||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
internal static List<R> Multiply<T, R>(this List<T> units, double multiplicator)
|
internal static List<R> Mul<T, R>(this List<T> units, double multiplicator)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -139,7 +139,7 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
MultiplyCore(CollectionsMarshal.AsSpan(units), multiplicator, count, resultArray);
|
MultiplyCore(CollectionsMarshal.AsSpan(units), multiplicator, count, resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
internal static List<R?> Multiply<T, R>(this List<T?> units, double multiplicator)
|
internal static List<R?> Mul<T, R>(this List<T?> units, double multiplicator)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -153,17 +153,17 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal static List<R> Multiply<T, R>(this double multiplicator, List<T> units)
|
internal static List<R> Mul<T, R>(this double multiplicator, List<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R> => units.Multiply<T, R>(multiplicator);
|
where R : struct, IMensuraUnit, IEquatable<R> => units.Mul<T, R>(multiplicator);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal static List<R?> Multiply<T, R>(this double multiplicator, List<T?> units)
|
internal static List<R?> Mul<T, R>(this double multiplicator, List<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R> => units.Multiply<T, R>(multiplicator);
|
where R : struct, IMensuraUnit, IEquatable<R> => units.Mul<T, R>(multiplicator);
|
||||||
|
|
||||||
// === ICollection<T> ===
|
// === ICollection<T> ===
|
||||||
internal static void Multiply<T, R>(this ICollection<T> units, double multiplicator, Span<R> destination)
|
internal static void Mul<T, R>(this ICollection<T> units, double multiplicator, Span<R> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -180,7 +180,7 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (item.ToDouble() * multiplicator).ToUnit<R>();
|
destination[i++] = (item.ToDouble() * multiplicator).ToUnit<R>();
|
||||||
}
|
}
|
||||||
internal static void Multiply<T, R>(this ICollection<T?> units, double multiplicator, Span<R?> destination)
|
internal static void Mul<T, R>(this ICollection<T?> units, double multiplicator, Span<R?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -200,17 +200,17 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal static void Multiply<T, R>(this double multiplicator, ICollection<T> units, Span<R> destination)
|
internal static void Mul<T, R>(this double multiplicator, ICollection<T> units, Span<R> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R> => units.Multiply(multiplicator, destination);
|
where R : struct, IMensuraUnit, IEquatable<R> => units.Mul(multiplicator, destination);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal static void Multiply<T, R>(this double multiplicator, ICollection<T?> units, Span<R?> destination)
|
internal static void Mul<T, R>(this double multiplicator, ICollection<T?> units, Span<R?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R> => units.Multiply(multiplicator, destination);
|
where R : struct, IMensuraUnit, IEquatable<R> => units.Mul(multiplicator, destination);
|
||||||
|
|
||||||
// === IReadOnlyCollection<T> ===
|
// === IReadOnlyCollection<T> ===
|
||||||
internal static void Multiply<T, R>(this IReadOnlyCollection<T> units, double multiplicator, Span<R> destination)
|
internal static void Mul<T, R>(this IReadOnlyCollection<T> units, double multiplicator, Span<R> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -227,7 +227,7 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (item.ToDouble() * multiplicator).ToUnit<R>();
|
destination[i++] = (item.ToDouble() * multiplicator).ToUnit<R>();
|
||||||
}
|
}
|
||||||
internal static void Multiply<T, R>(this IReadOnlyCollection<T?> units, double multiplicator, Span<R?> destination)
|
internal static void Mul<T, R>(this IReadOnlyCollection<T?> units, double multiplicator, Span<R?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -247,14 +247,14 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal static void Multiply<T, R>(this double multiplicator, IReadOnlyCollection<T> units, Span<R> destination)
|
internal static void Mul<T, R>(this double multiplicator, IReadOnlyCollection<T> units, Span<R> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R> => units.Multiply(multiplicator, destination);
|
where R : struct, IMensuraUnit, IEquatable<R> => units.Mul(multiplicator, destination);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal static void Multiply<T, R>(this double multiplicator, IReadOnlyCollection<T?> units, Span<R?> destination)
|
internal static void Mul<T, R>(this double multiplicator, IReadOnlyCollection<T?> units, Span<R?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R> => units.Multiply(multiplicator, destination);
|
where R : struct, IMensuraUnit, IEquatable<R> => units.Mul(multiplicator, destination);
|
||||||
|
|
||||||
// === IEnumerable<T> + yeild ===
|
// === IEnumerable<T> + yeild ===
|
||||||
internal static IEnumerable<R> MultiplyIterator<T, R>(this IEnumerable<T> units, double multiplicator)
|
internal static IEnumerable<R> MultiplyIterator<T, R>(this IEnumerable<T> units, double multiplicator)
|
||||||
@@ -274,64 +274,64 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
internal static IEnumerable<R> Multiply<T, R>(this IEnumerable<T> units, double multiplicator)
|
internal static IEnumerable<R> Mul<T, R>(this IEnumerable<T> units, double multiplicator)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
if (units is T[] array) return array.Multiply<T, R>(multiplicator);
|
if (units is T[] array) return array.Mul<T, R>(multiplicator);
|
||||||
if (units is List<T> list) return list.Multiply<T, R>(multiplicator);
|
if (units is List<T> list) return list.Mul<T, R>(multiplicator);
|
||||||
if (units is ICollection<T> col)
|
if (units is ICollection<T> col)
|
||||||
{
|
{
|
||||||
var arr = col.ToArray();
|
var arr = col.ToArray();
|
||||||
arr.Multiply(multiplicator, arr);
|
arr.Mul(multiplicator, arr);
|
||||||
return arr.ReCast<T, R>();
|
return arr.ReCast<T, R>();
|
||||||
}
|
}
|
||||||
if (units is IReadOnlyCollection<T> roc)
|
if (units is IReadOnlyCollection<T> roc)
|
||||||
{
|
{
|
||||||
var arr = roc.ToArray();
|
var arr = roc.ToArray();
|
||||||
arr.Multiply(multiplicator, arr);
|
arr.Mul(multiplicator, arr);
|
||||||
return arr.ReCast<T, R>();
|
return arr.ReCast<T, R>();
|
||||||
}
|
}
|
||||||
return MultiplyIterator<T, R>(units, multiplicator);
|
return MultiplyIterator<T, R>(units, multiplicator);
|
||||||
}
|
}
|
||||||
internal static IEnumerable<R?> Multiply<T, R>(this IEnumerable<T?> units, double multiplicator)
|
internal static IEnumerable<R?> Mul<T, R>(this IEnumerable<T?> units, double multiplicator)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
if (units is T?[] array) return array.Multiply<T, R>(multiplicator);
|
if (units is T?[] array) return array.Mul<T, R>(multiplicator);
|
||||||
if (units is List<T?> list) return list.Multiply<T, R>(multiplicator);
|
if (units is List<T?> list) return list.Mul<T, R>(multiplicator);
|
||||||
if (units is ICollection<T?> col)
|
if (units is ICollection<T?> col)
|
||||||
{
|
{
|
||||||
var arr = col.ToArray();
|
var arr = col.ToArray();
|
||||||
arr.Multiply(multiplicator, arr);
|
arr.Mul(multiplicator, arr);
|
||||||
return arr.ReCast<T, R>();
|
return arr.ReCast<T, R>();
|
||||||
}
|
}
|
||||||
if (units is IReadOnlyCollection<T?> roc)
|
if (units is IReadOnlyCollection<T?> roc)
|
||||||
{
|
{
|
||||||
var arr = roc.ToArray();
|
var arr = roc.ToArray();
|
||||||
arr.Multiply(multiplicator, arr);
|
arr.Mul(multiplicator, arr);
|
||||||
return arr.ReCast<T, R>();
|
return arr.ReCast<T, R>();
|
||||||
}
|
}
|
||||||
return MultiplyNullableIterator<T, R>(units, multiplicator);
|
return MultiplyNullableIterator<T, R>(units, multiplicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal static IEnumerable<R> Multiply<T, R>(this double multiplicator, IEnumerable<T> units)
|
internal static IEnumerable<R> Mul<T, R>(this double multiplicator, IEnumerable<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R> => Multiply<T, R>(units, multiplicator);
|
where R : struct, IMensuraUnit, IEquatable<R> => Mul<T, R>(units, multiplicator);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal static IEnumerable<R?> Multiply<T, R>(this double multiplicator, IEnumerable<T?> units)
|
internal static IEnumerable<R?> Mul<T, R>(this double multiplicator, IEnumerable<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R> => Multiply<T, R>(units, multiplicator);
|
where R : struct, IMensuraUnit, IEquatable<R> => Mul<T, R>(units, multiplicator);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// === ReadOnlySpan
|
// === ReadOnlySpan
|
||||||
public static void Multiply<T>(this ReadOnlySpan<T> units, double multiplicator, Span<T> destination)
|
internal static void Mul<T>(this ReadOnlySpan<T> units, double multiplicator, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return;
|
if (units.IsEmpty) return;
|
||||||
@@ -341,7 +341,7 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
|
|
||||||
units.MultiplyCore(multiplicator, len, destination);
|
units.MultiplyCore(multiplicator, len, destination);
|
||||||
}
|
}
|
||||||
public static void Multiply<T>(this ReadOnlySpan<T?> units, double multiplicator, Span<T?> destination)
|
internal static void Mul<T>(this ReadOnlySpan<T?> units, double multiplicator, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return;
|
if (units.IsEmpty) return;
|
||||||
@@ -353,15 +353,15 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Multiply<T>(this double multiplicator, ReadOnlySpan<T> units, Span<T> destination)
|
internal static void Mul<T>(this double multiplicator, ReadOnlySpan<T> units, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Multiply(multiplicator, destination);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Mul(multiplicator, destination);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Multiply<T>(this double multiplicator, ReadOnlySpan<T?> units, Span<T?> destination)
|
internal static void Mul<T>(this double multiplicator, ReadOnlySpan<T?> units, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Multiply(multiplicator, destination);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Mul(multiplicator, destination);
|
||||||
|
|
||||||
// === Array ===
|
// === Array ===
|
||||||
public static T[] Multiply<T>(this T[] units, double multiplicator)
|
internal static T[] Mul<T>(this T[] units, double multiplicator)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -369,10 +369,10 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
if (len == 0) return [];
|
if (len == 0) return [];
|
||||||
|
|
||||||
var result = new T[len];
|
var result = new T[len];
|
||||||
Multiply(units, multiplicator, result);
|
Mul(units, multiplicator, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static T?[] Multiply<T>(this T?[] units, double multiplicator)
|
internal static T?[] Mul<T>(this T?[] units, double multiplicator)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -380,20 +380,20 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
if (len == 0) return [];
|
if (len == 0) return [];
|
||||||
|
|
||||||
var result = new T?[len];
|
var result = new T?[len];
|
||||||
Multiply(units, multiplicator, result);
|
Mul(units, multiplicator, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static T[] Multiply<T>(this double multiplicator, T[] units)
|
internal static T[] Mul<T>(this double multiplicator, T[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Multiply(multiplicator);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Mul(multiplicator);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static T?[] Multiply<T>(this double multiplicator, T?[] units)
|
internal static T?[] Mul<T>(this double multiplicator, T?[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Multiply(multiplicator);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Mul(multiplicator);
|
||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
public static List<T> Multiply<T>(this List<T> units, double multiplicator)
|
internal static List<T> Mul<T>(this List<T> units, double multiplicator)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -401,10 +401,10 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
if (len == 0) return [];
|
if (len == 0) return [];
|
||||||
|
|
||||||
var resultArray = new T[len];
|
var resultArray = new T[len];
|
||||||
Multiply(CollectionsMarshal.AsSpan(units), multiplicator, resultArray);
|
Mul(CollectionsMarshal.AsSpan(units), multiplicator, resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
public static List<T?> Multiply<T>(this List<T?> units, double multiplicator)
|
internal static List<T?> Mul<T>(this List<T?> units, double multiplicator)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -412,20 +412,20 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
if (count == 0) return [];
|
if (count == 0) return [];
|
||||||
|
|
||||||
var resultArray = new T?[count];
|
var resultArray = new T?[count];
|
||||||
Multiply(CollectionsMarshal.AsSpan(units), multiplicator, resultArray);
|
Mul(CollectionsMarshal.AsSpan(units), multiplicator, resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static List<T> Multiply<T>(this double multiplicator, List<T> units)
|
internal static List<T> Mul<T>(this double multiplicator, List<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Multiply(multiplicator);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Mul(multiplicator);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static List<T?> Multiply<T>(this double multiplicator, List<T?> units)
|
internal static List<T?> Mul<T>(this double multiplicator, List<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Multiply(multiplicator);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Mul(multiplicator);
|
||||||
|
|
||||||
// === ICollection<T> ===
|
// === ICollection<T> ===
|
||||||
public static void Multiply<T>(this ICollection<T> units, double multiplicator, Span<T> destination)
|
internal static void Mul<T>(this ICollection<T> units, double multiplicator, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -434,14 +434,14 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
if (destination.Length < count)
|
if (destination.Length < count)
|
||||||
throw new ArgumentException("Destination too short");
|
throw new ArgumentException("Destination too short");
|
||||||
|
|
||||||
if (units is T[] array) { array.Multiply(multiplicator, destination); return; }
|
if (units is T[] array) { array.Mul(multiplicator, destination); return; }
|
||||||
if (units is List<T> list) { CollectionsMarshal.AsSpan(list).Multiply(multiplicator, destination); return; }
|
if (units is List<T> list) { CollectionsMarshal.AsSpan(list).Mul(multiplicator, destination); return; }
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (item.ToDouble() * multiplicator).ToUnit<T>();
|
destination[i++] = (item.ToDouble() * multiplicator).ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static void Multiply<T>(this ICollection<T?> units, double multiplicator, Span<T?> destination)
|
internal static void Mul<T>(this ICollection<T?> units, double multiplicator, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -450,8 +450,8 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
if (destination.Length < count)
|
if (destination.Length < count)
|
||||||
throw new ArgumentException("Destination too short");
|
throw new ArgumentException("Destination too short");
|
||||||
|
|
||||||
if (units is T?[] array) { array.Multiply(multiplicator, destination); return; }
|
if (units is T?[] array) { array.Mul(multiplicator, destination); return; }
|
||||||
if (units is List<T?> list) { CollectionsMarshal.AsSpan(list).Multiply(multiplicator, destination); return; }
|
if (units is List<T?> list) { CollectionsMarshal.AsSpan(list).Mul(multiplicator, destination); return; }
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
@@ -460,15 +460,15 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Multiply<T>(this double multiplicator, ICollection<T> units, Span<T> destination)
|
internal static void Mul<T>(this double multiplicator, ICollection<T> units, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Multiply<T>(multiplicator, destination);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Mul<T>(multiplicator, destination);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Multiply<T>(this double multiplicator, ICollection<T?> units, Span<T?> destination)
|
internal static void Mul<T>(this double multiplicator, ICollection<T?> units, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Multiply<T>(multiplicator, destination);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Mul<T>(multiplicator, destination);
|
||||||
|
|
||||||
// === IReadOnlyCollection<T> ===
|
// === IReadOnlyCollection<T> ===
|
||||||
public static void Multiply<T>(this IReadOnlyCollection<T> units, double multiplicator, Span<T> destination)
|
internal static void Mul<T>(this IReadOnlyCollection<T> units, double multiplicator, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -477,14 +477,14 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
if (destination.Length < count)
|
if (destination.Length < count)
|
||||||
throw new ArgumentException("Destination too short");
|
throw new ArgumentException("Destination too short");
|
||||||
|
|
||||||
if (units is T[] array) { array.Multiply(multiplicator, destination); return; }
|
if (units is T[] array) { array.Mul(multiplicator, destination); return; }
|
||||||
if (units is List<T> list) { CollectionsMarshal.AsSpan(list).Multiply(multiplicator, destination); return; }
|
if (units is List<T> list) { CollectionsMarshal.AsSpan(list).Mul(multiplicator, destination); return; }
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (item.ToDouble() * multiplicator).ToUnit<T>();
|
destination[i++] = (item.ToDouble() * multiplicator).ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static void Multiply<T>(this IReadOnlyCollection<T?> units, double multiplicator, Span<T?> destination)
|
internal static void Mul<T>(this IReadOnlyCollection<T?> units, double multiplicator, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -493,8 +493,8 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
if (destination.Length < count)
|
if (destination.Length < count)
|
||||||
throw new ArgumentException("Destination too short");
|
throw new ArgumentException("Destination too short");
|
||||||
|
|
||||||
if (units is T?[] array) { array.Multiply(multiplicator, destination); return; }
|
if (units is T?[] array) { array.Mul(multiplicator, destination); return; }
|
||||||
if (units is List<T?> list) { CollectionsMarshal.AsSpan(list).Multiply(multiplicator, destination); return; }
|
if (units is List<T?> list) { CollectionsMarshal.AsSpan(list).Mul(multiplicator, destination); return; }
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
@@ -503,12 +503,12 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Multiply<T>(this double multiplicator, IReadOnlyCollection<T> units, Span<T> destination)
|
internal static void Mul<T>(this double multiplicator, IReadOnlyCollection<T> units, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Multiply<T>(multiplicator, destination);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Mul<T>(multiplicator, destination);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Multiply<T>(this double multiplicator, IReadOnlyCollection<T?> units, Span<T?> destination)
|
internal static void Mul<T>(this double multiplicator, IReadOnlyCollection<T?> units, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Multiply<T>(multiplicator, destination);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Mul<T>(multiplicator, destination);
|
||||||
|
|
||||||
// === IEnumerable<T> + yeild ===
|
// === IEnumerable<T> + yeild ===
|
||||||
internal static IEnumerable<T> MultiplyIterator<T>(this IEnumerable<T> units, double multiplicator)
|
internal static IEnumerable<T> MultiplyIterator<T>(this IEnumerable<T> units, double multiplicator)
|
||||||
@@ -526,52 +526,52 @@ public static partial class CollectionsMultiplyExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
public static IEnumerable<T> Multiply<T>(this IEnumerable<T> units, double multiplicator)
|
internal static IEnumerable<T> Mul<T>(this IEnumerable<T> units, double multiplicator)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
if (units is T[] array) return array.Multiply(multiplicator);
|
if (units is T[] array) return array.Mul(multiplicator);
|
||||||
if (units is List<T> list) return list.Multiply(multiplicator);
|
if (units is List<T> list) return list.Mul(multiplicator);
|
||||||
if (units is ICollection<T> col)
|
if (units is ICollection<T> col)
|
||||||
{
|
{
|
||||||
var arr = col.ToArray();
|
var arr = col.ToArray();
|
||||||
arr.Multiply(multiplicator, arr);
|
arr.Mul(multiplicator, arr);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
if (units is IReadOnlyCollection<T> roc)
|
if (units is IReadOnlyCollection<T> roc)
|
||||||
{
|
{
|
||||||
var arr = roc.ToArray();
|
var arr = roc.ToArray();
|
||||||
arr.Multiply(multiplicator, arr);
|
arr.Mul(multiplicator, arr);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
return MultiplyIterator(units, multiplicator);
|
return MultiplyIterator(units, multiplicator);
|
||||||
}
|
}
|
||||||
public static IEnumerable<T?> Multiply<T>(this IEnumerable<T?> units, double multiplicator)
|
internal static IEnumerable<T?> Mul<T>(this IEnumerable<T?> units, double multiplicator)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
if (units is T?[] array) return array.Multiply(multiplicator);
|
if (units is T?[] array) return array.Mul(multiplicator);
|
||||||
if (units is List<T?> list) return list.Multiply(multiplicator);
|
if (units is List<T?> list) return list.Mul(multiplicator);
|
||||||
if (units is ICollection<T?> col)
|
if (units is ICollection<T?> col)
|
||||||
{
|
{
|
||||||
var arr = col.ToArray();
|
var arr = col.ToArray();
|
||||||
arr.Multiply(multiplicator, arr);
|
arr.Mul(multiplicator, arr);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
if (units is IReadOnlyCollection<T?> roc)
|
if (units is IReadOnlyCollection<T?> roc)
|
||||||
{
|
{
|
||||||
var arr = roc.ToArray();
|
var arr = roc.ToArray();
|
||||||
arr.Multiply(multiplicator, arr);
|
arr.Mul(multiplicator, arr);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
return MultiplyNullableIterator(units, multiplicator);
|
return MultiplyNullableIterator(units, multiplicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static IEnumerable<T> Multiply<T>(this double multiplicator, IEnumerable<T> units)
|
internal static IEnumerable<T> Mul<T>(this double multiplicator, IEnumerable<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => Multiply(units, multiplicator);
|
where T : struct, IMensuraUnit, IEquatable<T> => Mul(units, multiplicator);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static IEnumerable<T?> Multiply<T>(this double multiplicator, IEnumerable<T?> units)
|
internal static IEnumerable<T?> Mul<T>(this double multiplicator, IEnumerable<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => Multiply(units, multiplicator);
|
where T : struct, IMensuraUnit, IEquatable<T> => Mul(units, multiplicator);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace QWERTYkez.Mensura.Extensions;
|
namespace QWERTYkez.Mensura.Extensions;
|
||||||
|
|
||||||
public static partial class CollectionsPlusExtensions
|
internal static partial class CollectionsPlusExtensions
|
||||||
{
|
{
|
||||||
// === ReadOnlySpan === SIMD
|
// === ReadOnlySpan === SIMD
|
||||||
internal static void PlusCore<T, R>(this ReadOnlySpan<T> units, double summand, int len, Span<R> destination)
|
internal static void PlusCore<T, R>(this ReadOnlySpan<T> units, double summand, int len, Span<R> destination)
|
||||||
@@ -332,7 +332,7 @@ public static partial class CollectionsPlusExtensions
|
|||||||
|
|
||||||
|
|
||||||
// === ReadOnlySpan
|
// === ReadOnlySpan
|
||||||
public static void Plus<T>(this ReadOnlySpan<T> units, double multiplicator, Span<T> destination)
|
internal static void Plus<T>(this ReadOnlySpan<T> units, double multiplicator, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return;
|
if (units.IsEmpty) return;
|
||||||
@@ -342,7 +342,7 @@ public static partial class CollectionsPlusExtensions
|
|||||||
|
|
||||||
units.PlusCore(multiplicator, len, destination);
|
units.PlusCore(multiplicator, len, destination);
|
||||||
}
|
}
|
||||||
public static void Plus<T>(this ReadOnlySpan<T?> units, double multiplicator, Span<T?> destination)
|
internal static void Plus<T>(this ReadOnlySpan<T?> units, double multiplicator, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units.IsEmpty) return;
|
if (units.IsEmpty) return;
|
||||||
@@ -354,15 +354,15 @@ public static partial class CollectionsPlusExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Plus<T>(this double multiplicator, ReadOnlySpan<T> units, Span<T> destination)
|
internal static void Plus<T>(this double multiplicator, ReadOnlySpan<T> units, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus(multiplicator, destination);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus(multiplicator, destination);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Plus<T>(this double multiplicator, ReadOnlySpan<T?> units, Span<T?> destination)
|
internal static void Plus<T>(this double multiplicator, ReadOnlySpan<T?> units, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus(multiplicator, destination);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus(multiplicator, destination);
|
||||||
|
|
||||||
// === Array ===
|
// === Array ===
|
||||||
public static T[] Plus<T>(this T[] units, double summand)
|
internal static T[] Plus<T>(this T[] units, double summand)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -373,7 +373,7 @@ public static partial class CollectionsPlusExtensions
|
|||||||
Plus(units, summand, result);
|
Plus(units, summand, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static T?[] Plus<T>(this T?[] units, double summand)
|
internal static T?[] Plus<T>(this T?[] units, double summand)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -386,15 +386,15 @@ public static partial class CollectionsPlusExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static T[] Plus<T>(this double summand, T[] units)
|
internal static T[] Plus<T>(this double summand, T[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus(summand);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus(summand);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static T?[] Plus<T>(this double summand, T?[] units)
|
internal static T?[] Plus<T>(this double summand, T?[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus(summand);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus(summand);
|
||||||
|
|
||||||
// === List<T> ===
|
// === List<T> ===
|
||||||
public static List<T> Plus<T>(this List<T> units, double summand)
|
internal static List<T> Plus<T>(this List<T> units, double summand)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -405,7 +405,7 @@ public static partial class CollectionsPlusExtensions
|
|||||||
Plus(CollectionsMarshal.AsSpan(units), summand, resultArray);
|
Plus(CollectionsMarshal.AsSpan(units), summand, resultArray);
|
||||||
return resultArray.WrapAsList();
|
return resultArray.WrapAsList();
|
||||||
}
|
}
|
||||||
public static List<T?> Plus<T>(this List<T?> units, double summand)
|
internal static List<T?> Plus<T>(this List<T?> units, double summand)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -418,15 +418,15 @@ public static partial class CollectionsPlusExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static List<T> Plus<T>(this double summand, List<T> units)
|
internal static List<T> Plus<T>(this double summand, List<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus(summand);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus(summand);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static List<T?> Plus<T>(this double summand, List<T?> units)
|
internal static List<T?> Plus<T>(this double summand, List<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus(summand);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus(summand);
|
||||||
|
|
||||||
// === ICollection<T> ===
|
// === ICollection<T> ===
|
||||||
public static void Plus<T>(this ICollection<T> units, double summand, Span<T> destination)
|
internal static void Plus<T>(this ICollection<T> units, double summand, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -442,7 +442,7 @@ public static partial class CollectionsPlusExtensions
|
|||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (item.ToDouble() + summand).ToUnit<T>();
|
destination[i++] = (item.ToDouble() + summand).ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static void Plus<T>(this ICollection<T?> units, double summand, Span<T?> destination)
|
internal static void Plus<T>(this ICollection<T?> units, double summand, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -461,15 +461,15 @@ public static partial class CollectionsPlusExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Plus<T>(this double summand, ICollection<T> units, Span<T> destination)
|
internal static void Plus<T>(this double summand, ICollection<T> units, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus<T>(summand, destination);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus<T>(summand, destination);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Plus<T>(this double summand, ICollection<T?> units, Span<T?> destination)
|
internal static void Plus<T>(this double summand, ICollection<T?> units, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus<T>(summand, destination);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus<T>(summand, destination);
|
||||||
|
|
||||||
// === IReadOnlyCollection<T> ===
|
// === IReadOnlyCollection<T> ===
|
||||||
public static void Plus<T>(this IReadOnlyCollection<T> units, double summand, Span<T> destination)
|
internal static void Plus<T>(this IReadOnlyCollection<T> units, double summand, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -485,7 +485,7 @@ public static partial class CollectionsPlusExtensions
|
|||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
destination[i++] = (item.ToDouble() + summand).ToUnit<T>();
|
destination[i++] = (item.ToDouble() + summand).ToUnit<T>();
|
||||||
}
|
}
|
||||||
public static void Plus<T>(this IReadOnlyCollection<T?> units, double summand, Span<T?> destination)
|
internal static void Plus<T>(this IReadOnlyCollection<T?> units, double summand, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return;
|
if (units is null) return;
|
||||||
@@ -504,11 +504,11 @@ public static partial class CollectionsPlusExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Plus<T>(this double summand, IReadOnlyCollection<T> units, Span<T> destination)
|
internal static void Plus<T>(this double summand, IReadOnlyCollection<T> units, Span<T> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus<T>(summand, destination);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus<T>(summand, destination);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Plus<T>(this double summand, IReadOnlyCollection<T?> units, Span<T?> destination)
|
internal static void Plus<T>(this double summand, IReadOnlyCollection<T?> units, Span<T?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus<T>(summand, destination);
|
where T : struct, IMensuraUnit, IEquatable<T> => units.Plus<T>(summand, destination);
|
||||||
|
|
||||||
// === IEnumerable<T> + yeild ===
|
// === IEnumerable<T> + yeild ===
|
||||||
@@ -527,7 +527,7 @@ public static partial class CollectionsPlusExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IEnumerable<T> ===
|
// === IEnumerable<T> ===
|
||||||
public static IEnumerable<T> Plus<T>(this IEnumerable<T> units, double summand)
|
internal static IEnumerable<T> Plus<T>(this IEnumerable<T> units, double summand)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -547,7 +547,7 @@ public static partial class CollectionsPlusExtensions
|
|||||||
}
|
}
|
||||||
return PlusIterator(units, summand);
|
return PlusIterator(units, summand);
|
||||||
}
|
}
|
||||||
public static IEnumerable<T?> Plus<T>(this IEnumerable<T?> units, double summand)
|
internal static IEnumerable<T?> Plus<T>(this IEnumerable<T?> units, double summand)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
{
|
{
|
||||||
if (units is null) return null!;
|
if (units is null) return null!;
|
||||||
@@ -569,10 +569,10 @@ public static partial class CollectionsPlusExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static IEnumerable<T> Plus<T>(this double summand, IEnumerable<T> units)
|
internal static IEnumerable<T> Plus<T>(this double summand, IEnumerable<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => Plus(units, summand);
|
where T : struct, IMensuraUnit, IEquatable<T> => Plus(units, summand);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static IEnumerable<T?> Plus<T>(this double summand, IEnumerable<T?> units)
|
internal static IEnumerable<T?> Plus<T>(this double summand, IEnumerable<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T> => Plus(units, summand);
|
where T : struct, IMensuraUnit, IEquatable<T> => Plus(units, summand);
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ using System.Runtime.Intrinsics.X86;
|
|||||||
|
|
||||||
namespace QWERTYkez.Mensura.Extensions;
|
namespace QWERTYkez.Mensura.Extensions;
|
||||||
|
|
||||||
public static partial class CollectionsPowExtensions
|
internal static partial class CollectionsPowExtensions
|
||||||
{
|
{
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace QWERTYkez.Mensura.Extensions;
|
namespace QWERTYkez.Mensura.Extensions;
|
||||||
|
|
||||||
public static partial class CollectionsSqrtExtensions
|
internal static partial class CollectionsSqrtExtensions
|
||||||
{
|
{
|
||||||
// === SqrtCore === SIMD
|
// === SqrtCore === SIMD
|
||||||
internal static unsafe void SqrtCore<T, R>(this ReadOnlySpan<T> units, int len, Span<R> destination)
|
internal static unsafe void SqrtCore<T, R>(this ReadOnlySpan<T> units, int len, Span<R> destination)
|
||||||
@@ -62,7 +62,7 @@ public static partial class CollectionsSqrtExtensions
|
|||||||
Unsafe.Add(ref dstRef, i) = Math.Sqrt(Unsafe.Add(ref srcRef, i));
|
Unsafe.Add(ref dstRef, i) = Math.Sqrt(Unsafe.Add(ref srcRef, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void SqrtCore<T, R>(this ReadOnlySpan<T?> units, int len, Span<R?> destination)
|
internal static void SqrtCore<T, R>(this ReadOnlySpan<T?> units, int len, Span<R?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -118,7 +118,7 @@ public static partial class CollectionsSqrtExtensions
|
|||||||
|
|
||||||
units.SqrtCore(len, destination);
|
units.SqrtCore(len, destination);
|
||||||
}
|
}
|
||||||
public static void Sqrt<T, R>(this ReadOnlySpan<T?> units, Span<R?> destination)
|
internal static void Sqrt<T, R>(this ReadOnlySpan<T?> units, Span<R?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -131,7 +131,7 @@ public static partial class CollectionsSqrtExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === Array ===
|
// === Array ===
|
||||||
public static R[] Sqrt<T, R>(this T[] units)
|
internal static R[] Sqrt<T, R>(this T[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -142,7 +142,7 @@ public static partial class CollectionsSqrtExtensions
|
|||||||
Sqrt(units, result);
|
Sqrt(units, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static R?[] Sqrt<T, R>(this T?[] units)
|
internal static R?[] Sqrt<T, R>(this T?[] units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -155,7 +155,7 @@ public static partial class CollectionsSqrtExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === List<Length> ===
|
// === List<Length> ===
|
||||||
public static List<R> Sqrt<T, R>(this List<T> units)
|
internal static List<R> Sqrt<T, R>(this List<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -181,7 +181,7 @@ public static partial class CollectionsSqrtExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === ICollection<Length> ===
|
// === ICollection<Length> ===
|
||||||
public static void Sqrt<T, R>(this ICollection<T> units, Span<R> destination)
|
internal static void Sqrt<T, R>(this ICollection<T> units, Span<R> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -198,7 +198,7 @@ public static partial class CollectionsSqrtExtensions
|
|||||||
foreach (T item in units)
|
foreach (T item in units)
|
||||||
destination[i++] = Math.Sqrt(item.ToDouble()).ToUnit<R>();
|
destination[i++] = Math.Sqrt(item.ToDouble()).ToUnit<R>();
|
||||||
}
|
}
|
||||||
public static void Sqrt<T, R>(this ICollection<T?> units, Span<R?> destination)
|
internal static void Sqrt<T, R>(this ICollection<T?> units, Span<R?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -218,7 +218,7 @@ public static partial class CollectionsSqrtExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IReadOnlyCollection<Length> ===
|
// === IReadOnlyCollection<Length> ===
|
||||||
public static void Sqrt<T, R>(this IReadOnlyCollection<T> units, Span<R> destination)
|
internal static void Sqrt<T, R>(this IReadOnlyCollection<T> units, Span<R> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -235,7 +235,7 @@ public static partial class CollectionsSqrtExtensions
|
|||||||
foreach (T item in units)
|
foreach (T item in units)
|
||||||
destination[i++] = Math.Sqrt(item.ToDouble()).ToUnit<R>();
|
destination[i++] = Math.Sqrt(item.ToDouble()).ToUnit<R>();
|
||||||
}
|
}
|
||||||
public static void Sqrt<T, R>(this IReadOnlyCollection<T?> units, Span<R?> destination)
|
internal static void Sqrt<T, R>(this IReadOnlyCollection<T?> units, Span<R?> destination)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
@@ -255,14 +255,14 @@ public static partial class CollectionsSqrtExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === IEnumerable<Length> + yield ===
|
// === IEnumerable<Length> + yield ===
|
||||||
public static IEnumerable<R> SqrtIterator<T, R>(this IEnumerable<T> units)
|
internal static IEnumerable<R> SqrtIterator<T, R>(this IEnumerable<T> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
foreach (var item in units)
|
foreach (var item in units)
|
||||||
yield return Math.Sqrt(item.ToDouble()).ToUnit<R>();
|
yield return Math.Sqrt(item.ToDouble()).ToUnit<R>();
|
||||||
}
|
}
|
||||||
public static IEnumerable<R?> SqrtNullableIterator<T, R>(this IEnumerable<T?> units)
|
internal static IEnumerable<R?> SqrtNullableIterator<T, R>(this IEnumerable<T?> units)
|
||||||
where T : struct, IMensuraUnit, IEquatable<T>
|
where T : struct, IMensuraUnit, IEquatable<T>
|
||||||
where R : struct, IMensuraUnit, IEquatable<R>
|
where R : struct, IMensuraUnit, IEquatable<R>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,338 +0,0 @@
|
|||||||
using System.Buffers;
|
|
||||||
using System.Runtime.Intrinsics;
|
|
||||||
using System.Runtime.Intrinsics.X86;
|
|
||||||
|
|
||||||
namespace QWERTYkez.Mensura;
|
|
||||||
|
|
||||||
public static partial class Extensions2
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ==========================================
|
|
||||||
// CORE
|
|
||||||
// ==========================================
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ==========================================
|
|
||||||
// === MULTIPLY ===
|
|
||||||
// ==========================================
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ==========================================
|
|
||||||
// === DIVIDE ===
|
|
||||||
// ==========================================
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ==========================================
|
|
||||||
// === PLUS ===
|
|
||||||
// ==========================================
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ==========================================
|
|
||||||
// === MINUS ===
|
|
||||||
// ==========================================
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//internal static U Protect<U>(this U? metric) where U : class, IMetric<U>, new() => metric ?? new();
|
|
||||||
//internal static C Protect<C, U>(this C? collection)
|
|
||||||
// where C : IMetricCollection<U>, new() where U : class, IMetric<U>, new() => collection ?? new();
|
|
||||||
|
|
||||||
|
|
||||||
//public static C MetricSelect<C, U>(this C? collection, Func<U, U>? selector)
|
|
||||||
// where C : IMetricCollection<U>, new() where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// var source = (collection ??= new());
|
|
||||||
// var nColl = (C)source.CreateByInstanceU(source.Count);
|
|
||||||
// if (selector is not null)
|
|
||||||
// {
|
|
||||||
// for (int i = 0; i < nColl.Count; i++)
|
|
||||||
// nColl[i] = selector(source[i]);
|
|
||||||
// return nColl;
|
|
||||||
// }
|
|
||||||
// return new();
|
|
||||||
//}
|
|
||||||
//public static IEnumerable<double> MetricSelect<U>(this IMetricCollection<U> collection, Func<U, double> selector)
|
|
||||||
// where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// if (collection is not null)
|
|
||||||
// {
|
|
||||||
// if (selector is not null)
|
|
||||||
// return collection.Select(selector);
|
|
||||||
// return collection.Select(u => double.NaN);
|
|
||||||
// }
|
|
||||||
// else return [];
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//public static IMetricCollection<Uz> MetricSelect<Ux, Uz>(this IMetricCollection<Ux>? collection, Func<Ux, Uz>? selector)
|
|
||||||
// where Ux : class, IMetric<Ux>, new() where Uz : class, IMetric<Uz>, new()
|
|
||||||
//{
|
|
||||||
// if (collection is not null && selector is not null)
|
|
||||||
// {
|
|
||||||
// var destCollection = collection.CreateByInstance<Uz>(collection.Count);
|
|
||||||
// for (int i = 0; i < collection.Count; i++)
|
|
||||||
// destCollection[i] = selector(collection[i]);
|
|
||||||
// return destCollection;
|
|
||||||
// }
|
|
||||||
// return null!;
|
|
||||||
//}
|
|
||||||
//public static MetricCollection<Uz> MetricSelect<Ux, Uz>(this MetricCollection<Ux>? collection, Func<Ux, Uz>? selector)
|
|
||||||
// where Ux : class, IMetric<Ux>, new() where Uz : class, IMetric<Uz>, new()
|
|
||||||
//{
|
|
||||||
// if (collection is not null && selector is not null)
|
|
||||||
// {
|
|
||||||
// var destCollection = collection.CreateByInstance<Uz>(collection.Count());
|
|
||||||
// for (int i = 0; i < collection.Count(); i++)
|
|
||||||
// destCollection[i] = selector(collection[i]);
|
|
||||||
// return destCollection;
|
|
||||||
// }
|
|
||||||
// return null!;
|
|
||||||
//}
|
|
||||||
//public static MetricArray<Uz> MetricSelect<Ux, Uz>(this MetricArray<Ux>? collection, Func<Ux, Uz>? selector)
|
|
||||||
// where Ux : class, IMetric<Ux>, new() where Uz : class, IMetric<Uz>, new()
|
|
||||||
//{
|
|
||||||
// var coll = collection?.ToArray();
|
|
||||||
// if (coll is not null && selector is not null)
|
|
||||||
// {
|
|
||||||
// var destCollection = new MetricArray<Uz>(coll.Length);
|
|
||||||
// for (int i = 0; i < coll.Length; i++)
|
|
||||||
// destCollection[i] = selector(coll[i]);
|
|
||||||
// return destCollection;
|
|
||||||
// }
|
|
||||||
// return null!;
|
|
||||||
//}
|
|
||||||
//public static MetricList<Uz> MetricSelect<Ux, Uz>(this MetricList<Ux>? collection, Func<Ux, Uz>? selector)
|
|
||||||
// where Ux : class, IMetric<Ux>, new() where Uz : class, IMetric<Uz>, new()
|
|
||||||
//{
|
|
||||||
// if (collection is not null && selector is not null)
|
|
||||||
// {
|
|
||||||
// var destCollection = new MetricList<Uz>(collection.Count);
|
|
||||||
// for (int i = 0; i < collection.Count; i++)
|
|
||||||
// destCollection[i] = selector(collection[i]);
|
|
||||||
// return destCollection;
|
|
||||||
// }
|
|
||||||
// return null!;
|
|
||||||
//}
|
|
||||||
//public static MetricObservableCollection<Uz> MetricSelect<Ux, Uz>(this MetricObservableCollection<Ux>? collection, Func<Ux, Uz>? selector)
|
|
||||||
// where Ux : class, IMetric<Ux>, new() where Uz : class, IMetric<Uz>, new()
|
|
||||||
//{
|
|
||||||
// if (collection is not null && selector is not null)
|
|
||||||
// {
|
|
||||||
// var destCollection = new MetricObservableCollection<Uz>(collection.Count);
|
|
||||||
// for (int i = 0; i < collection.Count; i++)
|
|
||||||
// destCollection[i] = selector(collection[i]);
|
|
||||||
// return destCollection;
|
|
||||||
// }
|
|
||||||
// return null!;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
//public static double[] MetricSelect<U>(this MetricArray<U> collection, Func<U, double> selector)
|
|
||||||
// where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// var coll = collection ?? [];
|
|
||||||
// var arr = new double[coll.Length];
|
|
||||||
// if (selector is not null)
|
|
||||||
// for (int i = 0; i < arr.Length; i++)
|
|
||||||
// arr[i] = selector(coll[i]);
|
|
||||||
// return arr;
|
|
||||||
//}
|
|
||||||
//public static List<double> MetricSelect<U>(this MetricList<U> collection, Func<U, double> selector)
|
|
||||||
// where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// var coll = collection ?? [];
|
|
||||||
// var list = new List<double>(coll.Count);
|
|
||||||
// if (selector is not null)
|
|
||||||
// for (int i = 0; i < list.Count; i++)
|
|
||||||
// list[i] = selector(coll[i]);
|
|
||||||
// return list;
|
|
||||||
//}
|
|
||||||
//public static ObservableCollection<double> MetricSelect<U>(this MetricObservableCollection<U> collection, Func<U, double> selector)
|
|
||||||
// where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// var coll = collection ?? [];
|
|
||||||
// var list = new List<double>(coll.Count);
|
|
||||||
// if (selector is not null)
|
|
||||||
// for (int i = 0; i < list.Count; i++)
|
|
||||||
// list[i] = selector(coll[i]);
|
|
||||||
// return new(list);
|
|
||||||
//}
|
|
||||||
//internal static C ForEachC<C, U>(this C? collection, Func<U, U>? Set)
|
|
||||||
// where C : IMetricCollection<U>, new() where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// var nColl = (C)(collection ??= new()).CreateByInstanceU(collection.Count);
|
|
||||||
// if (Set is not null)
|
|
||||||
// for (int i = 0; i < nColl.Count; i++)
|
|
||||||
// nColl[i] = Set(nColl[i]);
|
|
||||||
// return nColl;
|
|
||||||
//}
|
|
||||||
//internal static double Protect_Value(this IMetric? metric) => metric is null ? 0d : metric._Value;
|
|
||||||
|
|
||||||
//public static U Min<U>(this U? T1, U? T2) where U : class, IMetric<U>, new() => (T1.Protect_Value() < T2.Protect_Value() ? T1 : T2).Protect();
|
|
||||||
//public static U Min<U>(this U T1, IEnumerable<U> units) where U : class, IMetric<U>, new() => (T1 ?? new()).Min((units ?? []).MaxBy(u => u.Protect_Value()));
|
|
||||||
|
|
||||||
//public static U Max<U>(this U? T1, U? T2) where U : class, IMetric<U>, new() => (T1.Protect_Value() > T2.Protect_Value() ? T1 : T2).Protect();
|
|
||||||
//public static U Max<U>(this U T1, IEnumerable<U> units) where U : class, IMetric<U>, new() => (T1 ?? new()).Max((units ?? []).MaxBy(u => u.Protect_Value()));
|
|
||||||
|
|
||||||
|
|
||||||
////internal static double ToDouble(this double number) => number;
|
|
||||||
////internal static double ToDouble(this double? number) => number ?? 0d;
|
|
||||||
////internal static double ToDouble<N>(this N number) where N : INumber<N> => Convert.ToDouble(number);
|
|
||||||
////internal static double ToDouble<N>(this N? number) where N : struct, INumber<N> => number is not null ? Convert.ToDouble(number) : 0d;
|
|
||||||
|
|
||||||
|
|
||||||
//internal static IEnumerable<U> MetricSelect<U>(this double[] nums, Func<double, U> selector) where U : class, IMetric<U>, new() => nums.Select(selector);
|
|
||||||
//internal static IEnumerable<U> MetricSelect<U>(this double?[] nums, Func<double, U> selector) where U : class, IMetric<U>, new() => nums.Select(num => selector(num.ToDouble()));
|
|
||||||
//internal static IEnumerable<U> MetricSelect<U, N>(this N[] nums, Func<double, U> selector) where N : INumber<N> where U : class, IMetric<U>, new() => nums.Select(num => selector(num.ToDouble()));
|
|
||||||
//internal static IEnumerable<U> MetricSelect<U, N>(this N?[] nums, Func<double, U> selector) where N : struct, INumber<N> where U : class, IMetric<U>, new() => nums.Select(num => selector(num.ToDouble()));
|
|
||||||
|
|
||||||
|
|
||||||
//internal static IEnumerable<U> MetricSelect<U>(this IEnumerable<double> nums, Func<double, U> selector) where U : class, IMetric<U>, new() => nums.Select(selector);
|
|
||||||
//internal static IEnumerable<U> MetricSelect<U>(this IEnumerable<double?> nums, Func<double, U> selector) where U : class, IMetric<U>, new() => nums.Select(num => selector(num.ToDouble()));
|
|
||||||
//internal static IEnumerable<U> MetricSelect<U, N>(this IEnumerable<N> nums, Func<double, U> selector) where N : INumber<N> where U : class, IMetric<U>, new() => nums.Select(num => selector(num.ToDouble()));
|
|
||||||
//internal static IEnumerable<U> MetricSelect<U, N>(this IEnumerable<N?> nums, Func<double, U> selector) where N : struct, INumber<N> where U : class, IMetric<U>, new() => nums.Select(num => selector(num.ToDouble()));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//public static U Clone<U>(this U? metric) where U : class, IMetric<U>, new() => new() { _Value = metric.Protect_Value() };
|
|
||||||
//public static U Abs<U>(this U? metric) where U : class, IMetric<U>, new() => new() { _Value = Math.Abs(metric.Protect_Value()) };
|
|
||||||
|
|
||||||
///// <summary>C^2 = A^2 + B^2</summary>
|
|
||||||
///// <returns>C = (A^2 + B^2).Sqrt(2)</returns>
|
|
||||||
//public static U Hypotenuse<U>(this U? A, U? B) where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// var a = A.Protect_Value();
|
|
||||||
// var b = B.Protect_Value();
|
|
||||||
// return new U() { _Value = Math.Sqrt(a * a + b * b) };
|
|
||||||
//}
|
|
||||||
///// <summary>C^2 = A^2 + B^2</summary>
|
|
||||||
///// <returns>B = (C^2 - A^2).Sqrt(2)</returns>
|
|
||||||
//public static U KatetFromHyp<U>(this U? A, U? C) where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// var a = A.Protect_Value();
|
|
||||||
// var c = C.Protect_Value();
|
|
||||||
// return new U() { _Value = Math.Sqrt(c * c - a * a) };
|
|
||||||
//}
|
|
||||||
///// <summary>C^2 = A^2 + B^2</summary>
|
|
||||||
///// <returns>B = (C^2 - A^2).Sqrt(2)</returns>
|
|
||||||
//public static U KatetFromKatet<U>(this U? C, U? A) where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// var a = A.Protect_Value();
|
|
||||||
// var c = C.Protect_Value();
|
|
||||||
// return new U() { _Value = Math.Sqrt(c * c - a * a) };
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public static Area Pow(this Length? metric, double? val = 2) => new() { _Value = Math.Pow(metric.Protect_Value(), val ?? 2) };
|
|
||||||
//public static Length Sqrt(this Area? metric) => new() { _Value = Math.Sqrt(metric.Protect_Value()) };
|
|
||||||
|
|
||||||
|
|
||||||
//public static U MetricSum<U>(this IEnumerable<U> args) where U : IMetric, new() => new() { _Value = args?.Where(t => t is not null).Sum(m => m.Protect_Value()) ?? 0d };
|
|
||||||
//public static U MetricAverage<U>(this IEnumerable<U> args) where U : IMetric, new() => new() { _Value = args?.Average(m => m.Protect_Value()) ?? double.NaN };
|
|
||||||
//public static U MetricMax<U>(this IEnumerable<U> args) where U : IMetric, new() => new() { _Value = args.Max(m => m.Protect_Value()) };
|
|
||||||
//public static U MetricMin<U>(this IEnumerable<U> args) where U : IMetric, new() => new() { _Value = args.Min(m => m.Protect_Value()) };
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//public static C MetricSum<C, U>(this IEnumerable<MetricCollection<C, U>> collections)
|
|
||||||
// where C : MetricCollection<C, U>, ICreateByCapacity, new() where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// var cArr = collections.ToArray();
|
|
||||||
// C accumulator = (C)cArr.FirstOrDefault(new C());
|
|
||||||
// for (int i = 1; i < cArr.Length; i++)
|
|
||||||
// accumulator = accumulator.FuncByPairOrOneToMany(cArr[i], (a, b) => a + b, out C _);
|
|
||||||
// return accumulator;
|
|
||||||
//}
|
|
||||||
//public static C MetricAverage<C, U>(this IEnumerable<MetricCollection<C, U>> collections)
|
|
||||||
// where C : MetricCollection<C, U>, ICreateByCapacity, new() where U : class, IMetric<U>, new()
|
|
||||||
// => collections.Sum() / collections.Count();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//public static U MetricSumBy<TSource, U>(this IEnumerable<TSource> source, Func<TSource, U> selector)
|
|
||||||
// where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// if (source is null) return new();
|
|
||||||
// if (selector is null) throw new ArgumentNullException("selector is null");
|
|
||||||
|
|
||||||
// return new() { _Value = source.Select(selector).Where(t => t is not null).Sum(t => t.Protect_Value()) };
|
|
||||||
//}
|
|
||||||
//public static U MetricAverageBy<TSource, U>(this IEnumerable<TSource> source, Func<TSource, U> selector)
|
|
||||||
// where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// if (source is null) return new();
|
|
||||||
// if (selector is null) throw new ArgumentNullException("selector is null");
|
|
||||||
|
|
||||||
// return new() { _Value = source.Select(selector).Average(t => t.Protect_Value()) };
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
//public static C MetricSumBy<TSource, C, U>(this IEnumerable<TSource> source, Func<TSource, MetricCollection<C, U>> selector)
|
|
||||||
// where C : MetricCollection<C, U>, ICreateByCapacity, new() where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// if (source is null) return new();
|
|
||||||
// if (selector is null) throw new ArgumentNullException("selector is null");
|
|
||||||
|
|
||||||
// return source.Select(selector).Sum();
|
|
||||||
//}
|
|
||||||
//public static C MetricAverageBy<TSource, C, U>(this IEnumerable<TSource> source, Func<TSource, MetricCollection<C, U>> selector)
|
|
||||||
// where C : MetricCollection<C, U>, ICreateByCapacity, new() where U : class, IMetric<U>, new()
|
|
||||||
//{
|
|
||||||
// if (source is null) return new();
|
|
||||||
// if (selector is null) throw new ArgumentNullException("selector is null");
|
|
||||||
|
|
||||||
// return source.Select(selector).Average();
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//public static MetricArray<U> ToMetricArray<U>(this IEnumerable<U> source) where U : class, IMetric<U>, new() => new(source);
|
|
||||||
//public static MetricList<U> ToMetricList<U>(this IEnumerable<U> source) where U : class, IMetric<U>, new() => new(source);
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
namespace QWERTYkez.Mensura;
|
namespace QWERTYkez.Mensura;
|
||||||
|
|
||||||
public interface IMensuraUnit { }
|
internal interface IMensuraUnit { }
|
||||||
|
|
||||||
public interface IMensuraUnit<U> where U : struct, IMensuraUnit, IEquatable<U> { }
|
internal interface IMensuraUnit<U> where U : struct, IMensuraUnit, IEquatable<U> { }
|
||||||
@@ -1,98 +1,112 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Globalization;
|
|
||||||
|
|
||||||
namespace QWERTYkez.Mensura;
|
namespace QWERTYkez.Mensura;
|
||||||
|
|
||||||
internal static class MensuraBinder
|
internal static partial class MensuraBinder
|
||||||
{
|
{
|
||||||
// Атрибут заставляет .NET автоматически выполнить этот метод при загрузке вашей DLL
|
#pragma warning disable CA2255
|
||||||
#pragma warning disable CA2255 // Атрибут "ModuleInitializer" не должен использоваться в библиотеках
|
|
||||||
[ModuleInitializer]
|
[ModuleInitializer]
|
||||||
#pragma warning restore CA2255 // Атрибут "ModuleInitializer" не должен использоваться в библиотеках
|
#pragma warning restore CA2255
|
||||||
internal static void Initialize()
|
internal static void Initialize()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Проверяем, загружена ли вообще сборка Newtonsoft в текущем приложении
|
// Пытаемся лениво проверить доступность сборки в контексте приложения
|
||||||
bool isNewtonsoftLoaded = AppDomain.CurrentDomain.GetAssemblies()
|
// Если её нет в проекте, этот вызов или последующий шаг вызовут исключение,
|
||||||
.Any(a => a.GetName().Name == "Newtonsoft.Json");
|
// которое перехватит catch, предотвратив падение приложения.
|
||||||
|
var assemblyName = new System.Reflection.AssemblyName("Newtonsoft.Json");
|
||||||
|
var loadedAssembly = System.Reflection.Assembly.Load(assemblyName);
|
||||||
|
|
||||||
if (!isNewtonsoftLoaded) return;
|
if (loadedAssembly is null) return;
|
||||||
|
|
||||||
// Если Newtonsoft есть в приложении, безопасно регистрируем наш generic-конвертер
|
// Если сборка успешно найдена/загружена — регистрируем конвертеры
|
||||||
RegisterConverters();
|
NewtonsoftRegistrar.Register();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// Игнорируем любые ошибки, чтобы не сломать основное приложение
|
// Если Newtonsoft.Json отсутствует в проекте,
|
||||||
|
// мы просто молча игнорируем ошибку и ничего не регистрируем
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Выносим работу с типами Newtonsoft в отдельный метод.
|
// Этот класс JIT-компилятор не будет трогать, пока мы не вызовем NewtonsoftRegistrar.Register()
|
||||||
// Это критически важно! Если бы этот код был внутри Initialize(),
|
private static class NewtonsoftRegistrar
|
||||||
// рантайм упал бы еще при входе в Initialize().
|
{
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
private static void RegisterConverters()
|
public static void Register()
|
||||||
{
|
{
|
||||||
// Добавляем конвертер в глобальные настройки по умолчанию внешнего Newtonsoft.Json
|
var currentSettingsFactory = Newtonsoft.Json.JsonConvert.DefaultSettings;
|
||||||
var currentSettingsFactory = JsonConvert.DefaultSettings;
|
|
||||||
|
|
||||||
JsonConvert.DefaultSettings = () =>
|
Newtonsoft.Json.JsonConvert.DefaultSettings = () =>
|
||||||
{
|
{
|
||||||
// Берем старые настройки или создаем чистые
|
var settings = currentSettingsFactory?.Invoke() ?? new Newtonsoft.Json.JsonSerializerSettings();
|
||||||
var settings = currentSettingsFactory?.Invoke() ?? new JsonSerializerSettings();
|
|
||||||
|
|
||||||
???????????
|
// Приводим напрямую к интерфейсу IList, у которого нет generic-типа Newtonsoft
|
||||||
// https://www.google.com/search?mtid=nSMmasO9AbK6wPAPq4SMKA&ved=2ahUKEwi3uqDMxvaUAxUOGhAIHWz7OfgQoo4PegYIAggAEAI&q=var+json1+%3D+System.Text.Json.JsonSerializer.Serialize%28_testValue%29%3B+%2F%2F+60%0A++++++++var+json2+%3D+Newtonsoft.Json.JsonConvert.SerializeObject%28_testValue%29%3B+%2F%2F+%7B%7D%0A%0A++++%5BJsonInclude%2C+DataMember%2C+JsonPropertyName%28%22v%22%29%2C+Obsolete%5D%0A++++internal+double+Value+%7B+get+%3D%3E+_Value%3B+init+%3D%3E+_Value+%3D+value%3B+%7D%0A++++internal+readonly+double+_Value%3B%0A%0A%D0%BC%D0%BE%D0%B6%D0%BD%D0%BE+%D0%BB%D0%B8+%D0%BD%D0%B5+%D0%B4%D0%BE%D0%B1%D0%B0%D0%B2%D0%BB%D1%8F%D1%8F+%D0%B7%D0%B0%D0%B2%D0%B8%D1%81%D0%B8%D0%BC%D0%BE%D1%81%D1%82%D1%8C+Newtonsoft.Json+%D0%B2+%D0%BE%D1%81%D0%BD%D0%BE%D0%B2%D0%BD%D1%83%D1%8E+%D0%B1%D0%B8%D0%B1%D0%BB%D0%B8%D0%BE%D1%82%D0%B5%D0%BA%D1%83%0A%D0%BF%D1%80%D0%B0%D0%B2%D0%B8%D0%BB%D1%8C%D0%BD%D0%BE+%D1%81%D0%B5%D1%80%D0%B8%D0%B0%D0%BB%D0%B8%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D1%8C+%D0%BE%D0%B1%D1%8A%D0%B5%D0%BA%D1%82%D1%8B+%D0%B2%D0%BE+%D0%B2%D0%BD%D0%B5%D1%88%D0%BD%D0%B5%D0%BC+%D0%BA%D0%BE%D0%B4%D0%B5%2C+%D1%87%D1%82%D0%BE%D0%B1%D1%8B+%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%B0%D0%BB%D0%BE+%22%D0%B8%D0%B7+%D0%BA%D0%BE%D1%80%D0%BE%D0%B1%D0%BA%D0%B8%22%3F&mstk=AUtExfAYU_oj2WXNVX-yyCIyGikGi_SP9UgYVJZHrC_1QDUiSGIypGAvXnteDNaWaCTYlzJI-o3lN8V6c0rIaNM4Z594r_Cci9-tDOQPKNXlesQFCokO1LoCsqplwQwAMz-iYsR4mjWCpyZBdMuOtTN7Y-D4BFkxIlXPn53SCTiVWZDHkCkag6egP75rWkXMLV0mmCOxsNwDJybXD9w6zvETdAGVG6uxn97YRSCeCt7XHy8NVaG1CtR9BnH-2kpkVbtae4g1ZGTaqcsUynXbza3X5GMtB30L_91rmfI&csuir=1&udm=50
|
if (settings.Converters is System.Collections.IList nonGenericList)
|
||||||
|
{
|
||||||
// Добавляем наш быстрый generic-конвертер для Angle
|
AddGeneratedConverters(nonGenericList);
|
||||||
// (Если у вас есть другие физические величины — добавьте их сюда же через запятую)
|
AddGeneratedComplexConverters(nonGenericList);
|
||||||
settings.Converters.Add(new NewtonsoftUnitConverter<Angle>());
|
}
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public class NewtonsoftUnitConverter<U> : Newtonsoft.Json.JsonConverter<U> where U : struct, IMensuraUnit, IEquatable<U>
|
public class NewtonsoftUnitConverter<U> : Newtonsoft.Json.JsonConverter<U>
|
||||||
{
|
where U : struct, IMensuraUnit, IEquatable<U>
|
||||||
// СЕРИАЛИЗАЦИЯ: вызывается автоматически при записи объекта во внешнем коде
|
{
|
||||||
|
// СЕРИАЛИЗАЦИЯ: Пишем напрямую числовые примитивы без дополнительных ветвлений
|
||||||
public override void WriteJson(JsonWriter writer, U value, Newtonsoft.Json.JsonSerializer serializer)
|
public override void WriteJson(JsonWriter writer, U value, Newtonsoft.Json.JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
var numericValue = value.ToDouble();
|
double numericValue = value.ToDouble();
|
||||||
|
|
||||||
// Проверяем, является ли число целым (остаток от деления на 1 равен 0)
|
// Оптимизация: остаток от деления через '%' работает быстро,
|
||||||
if (numericValue % 1 == 0)
|
// но cast к long и обратно для проверки — самый надежный способ для JIT.
|
||||||
|
if (numericValue == (long)numericValue)
|
||||||
{
|
{
|
||||||
// Записываем как long — Newtonsoft уберет ".0" и выдаст просто 60
|
|
||||||
writer.WriteValue((long)numericValue);
|
writer.WriteValue((long)numericValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Если есть дробная часть (например, 60.5) — записываем как double
|
|
||||||
writer.WriteValue(numericValue);
|
writer.WriteValue(numericValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ДЕСЕРИАЛИЗАЦИЯ: вызывается автоматически при чтении объекта из JSON
|
// ДЕСЕРИАЛИЗАЦИЯ: Читаем напрямую из токена БЕЗ использования reader.Value (избегаем boxing)
|
||||||
public override U ReadJson(JsonReader reader, Type objectType, U existingValue, bool hasExistingValue, Newtonsoft.Json.JsonSerializer serializer)
|
public override U ReadJson(JsonReader reader, Type objectType, U existingValue, bool hasExistingValue, Newtonsoft.Json.JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
// Если в JSON пришел null (для Nullable<U>), возвращаем дефолтную структуру
|
// 1. Быстрая проверка на Null
|
||||||
if (reader.TokenType == JsonToken.Null)
|
if (reader.TokenType == JsonToken.Null)
|
||||||
{
|
{
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Читаем сырое число из потока. Newtonsoft автоматически парсит его как double или long
|
// 2. Если в потоке число (Float или Integer), Newtonsoft уже знает его тип.
|
||||||
if (reader.Value is null)
|
// Забираем значение НАПРЯМУЮ через специализированные касты, минуя reader.Value.
|
||||||
|
if (reader.TokenType == JsonToken.Float || reader.TokenType == JsonToken.Integer)
|
||||||
{
|
{
|
||||||
throw new JsonSerializationException($"Не удалось десериализовать тип {typeof(U).Name}: значение отсутствует.");
|
// reader.Value в этот момент содержит boxed-переменную, но JIT оптимизирует
|
||||||
}
|
// прямое обращение к внутренним конвертерам Newtonsoft, если мы доверяем типу токена.
|
||||||
|
double numericValue = Convert.ToDouble(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
|
||||||
// Приводим к double с учетом инвариантной культуры
|
|
||||||
double numericValue = Convert.ToDouble(reader.Value, CultureInfo.InvariantCulture);
|
|
||||||
|
|
||||||
// Создаем вашу структуру.
|
|
||||||
return numericValue.ToUnit<U>();
|
return numericValue.ToUnit<U>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3. Строковый fallback на случай, если число пришло в кавычках: "60.5"
|
||||||
|
if (reader.TokenType == JsonToken.String)
|
||||||
|
{
|
||||||
|
string? stringValue = reader.Value?.ToString();
|
||||||
|
if (double.TryParse(stringValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out double parsedValue))
|
||||||
|
{
|
||||||
|
return parsedValue.ToUnit<U>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Newtonsoft.Json.JsonSerializationException($"Не удалось десериализовать тип {typeof(U).Name}: неожиданный токен {reader.TokenType}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Сигнатуры partial-методов строго используют System.Collections.IList
|
||||||
|
static partial void AddGeneratedConverters(System.Collections.IList converters);
|
||||||
|
static partial void AddGeneratedComplexConverters(System.Collections.IList converters);
|
||||||
}
|
}
|
||||||
@@ -22,20 +22,20 @@ internal static class Coefficients
|
|||||||
|
|
||||||
public readonly partial record struct Length
|
public readonly partial record struct Length
|
||||||
{
|
{
|
||||||
[OperatorsGenerator] public static Area operator *(Length left, Length right) => new(left._Value * right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator] public static Area operator *(Length left, Length right) => new(left._Value * right._Value);
|
||||||
|
|
||||||
|
|
||||||
public static Volume operator *(Area left, Length right) => right * left;
|
[MethodImpl(MethodImplOptions.NoInlining)] public static Volume operator *(Area left, Length right) => right * left;
|
||||||
[OperatorsGenerator] public static Volume operator *(Length left, Area right) => new(left._Value * right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator] public static Volume operator *(Length left, Area right) => new(left._Value * right._Value);
|
||||||
|
|
||||||
|
|
||||||
public static Pressure operator *(Length left, ForceVolumetric right) => right * left;
|
[MethodImpl(MethodImplOptions.NoInlining)] public static Pressure operator *(Length left, ForceVolumetric right) => right * left;
|
||||||
[OperatorsGenerator(nameof(Coeff1))] public static Pressure operator *(ForceVolumetric left, Length right) => new(left._Value * right._Value * Coeff1);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff1))] public static Pressure operator *(ForceVolumetric left, Length right) => new(left._Value * right._Value * Coeff1);
|
||||||
internal static readonly double Coeff1 = Coefficients.MultiplyCoefficient(ForceVolumetric.NewtonPerMeterCubic, Length.Meter, Pressure.NewtonPerMeterSquared);
|
internal static readonly double Coeff1 = Coefficients.MultiplyCoefficient(ForceVolumetric.NewtonPerMeterCubic, Length.Meter, Pressure.NewtonPerMeterSquared);
|
||||||
|
|
||||||
|
|
||||||
public static Torque operator *(Force left, Length right) => right * left;
|
[MethodImpl(MethodImplOptions.NoInlining)] public static Torque operator *(Force left, Length right) => right * left;
|
||||||
[OperatorsGenerator(nameof(Coeff2))] public static Torque operator *(Length left, Force right) => new(left._Value * right._Value * Coeff2);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff2))] public static Torque operator *(Length left, Force right) => new(left._Value * right._Value * Coeff2);
|
||||||
internal static readonly double Coeff2 = Coefficients.MultiplyCoefficient(Length.Meter, Force._Newton, Torque._Newton_Meter);
|
internal static readonly double Coeff2 = Coefficients.MultiplyCoefficient(Length.Meter, Force._Newton, Torque._Newton_Meter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,62 +46,62 @@ public readonly partial record struct Mass // Grams
|
|||||||
|
|
||||||
public readonly partial record struct Pressure // Pascals
|
public readonly partial record struct Pressure // Pascals
|
||||||
{
|
{
|
||||||
[OperatorsGenerator(nameof(Coeff1))] public static Length operator /(Pressure left, ForceVolumetric right) => new(left._Value * Coeff1 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff1))] public static Length operator /(Pressure left, ForceVolumetric right) => new(left._Value * Coeff1 / right._Value);
|
||||||
internal static readonly double Coeff1 = Coefficients.DivideCoefficient(Pressure._Pascal, ForceVolumetric.NewtonPerMeterCubic, Length.Meter);
|
internal static readonly double Coeff1 = Coefficients.DivideCoefficient(Pressure._Pascal, ForceVolumetric.NewtonPerMeterCubic, Length.Meter);
|
||||||
|
|
||||||
public static Force operator *(Pressure left, Area right) => right * left;
|
[MethodImpl(MethodImplOptions.NoInlining)] public static Force operator *(Pressure left, Area right) => right * left;
|
||||||
[OperatorsGenerator(nameof(Coeff2))] public static Force operator *(Area left, Pressure right) => new (left._Value * right._Value * Coeff2);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff2))] public static Force operator *(Area left, Pressure right) => new (left._Value * right._Value * Coeff2);
|
||||||
internal static readonly double Coeff2 = Coefficients.MultiplyCoefficient(Area.MeterSquared, Pressure._Pascal, Force._Newton);
|
internal static readonly double Coeff2 = Coefficients.MultiplyCoefficient(Area.MeterSquared, Pressure._Pascal, Force._Newton);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[OperatorsGenerator(nameof(Coeff3))] public static Length operator /(ForceLinear left, Pressure right) => new(left._Value * Coeff3 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff3))] public static Length operator /(ForceLinear left, Pressure right) => new(left._Value * Coeff3 / right._Value);
|
||||||
internal static readonly double Coeff3 = Coefficients.DivideCoefficient(ForceLinear._NewtonPerMilliMeter, Pressure.NewtonPerMilliMeterSquared, Length._MilliMeter);
|
internal static readonly double Coeff3 = Coefficients.DivideCoefficient(ForceLinear._NewtonPerMilliMeter, Pressure.NewtonPerMilliMeterSquared, Length._MilliMeter);
|
||||||
|
|
||||||
public static ForceLinear operator *(Pressure left, Length right) => right * left;
|
[MethodImpl(MethodImplOptions.NoInlining)] public static ForceLinear operator *(Pressure left, Length right) => right * left;
|
||||||
[OperatorsGenerator(nameof(Coeff4))] public static ForceLinear operator *(Length left, Pressure right) => new(left._Value * right._Value * Coeff4);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff4))] public static ForceLinear operator *(Length left, Pressure right) => new(left._Value * right._Value * Coeff4);
|
||||||
internal static readonly double Coeff4 = Coefficients.MultiplyCoefficient(Length._MilliMeter, Pressure.NewtonPerMilliMeterSquared, ForceLinear._NewtonPerMilliMeter);
|
internal static readonly double Coeff4 = Coefficients.MultiplyCoefficient(Length._MilliMeter, Pressure.NewtonPerMilliMeterSquared, ForceLinear._NewtonPerMilliMeter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly partial record struct Area // MilliMetersSquared
|
public readonly partial record struct Area // MilliMetersSquared
|
||||||
{
|
{
|
||||||
public static Torque operator *(ForceLinear left, Area right) => right * left;
|
[MethodImpl(MethodImplOptions.NoInlining)] public static Torque operator *(ForceLinear left, Area right) => right * left;
|
||||||
[OperatorsGenerator(nameof(Coeff1))] public static Torque operator *(Area left, ForceLinear right) => new(left._Value * right._Value * Coeff1);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff1))] public static Torque operator *(Area left, ForceLinear right) => new(left._Value * right._Value * Coeff1);
|
||||||
internal static readonly double Coeff1 = Coefficients.MultiplyCoefficient(Area.MeterSquared, ForceLinear.NewtonPerMeter, Torque._Newton_Meter);
|
internal static readonly double Coeff1 = Coefficients.MultiplyCoefficient(Area.MeterSquared, ForceLinear.NewtonPerMeter, Torque._Newton_Meter);
|
||||||
|
|
||||||
[OperatorsGenerator] public static Length operator /(Area left, Length right) => new(left._Value / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator] public static Length operator /(Area left, Length right) => new(left._Value / right._Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly partial record struct Volume // MillimetersCubic
|
public readonly partial record struct Volume // MillimetersCubic
|
||||||
{
|
{
|
||||||
public static Torque operator *(Pressure left, Volume right) => right * left;
|
[MethodImpl(MethodImplOptions.NoInlining)] public static Torque operator *(Pressure left, Volume right) => right * left;
|
||||||
[OperatorsGenerator(nameof(Coeff2))] public static Torque operator *(Volume left, Pressure right) => new(left._Value * right._Value * Coeff2);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff2))] public static Torque operator *(Volume left, Pressure right) => new(left._Value * right._Value * Coeff2);
|
||||||
internal static readonly double Coeff2 = Coefficients.MultiplyCoefficient(Volume.MeterCubic, Pressure._Pascal, Torque._Newton_Meter);
|
internal static readonly double Coeff2 = Coefficients.MultiplyCoefficient(Volume.MeterCubic, Pressure._Pascal, Torque._Newton_Meter);
|
||||||
|
|
||||||
[OperatorsGenerator] public static Area operator /(Volume left, Length right) => new(left._Value / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator] public static Area operator /(Volume left, Length right) => new(left._Value / right._Value);
|
||||||
[OperatorsGenerator] public static Length operator /(Volume left, Area right) => new(left._Value / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator] public static Length operator /(Volume left, Area right) => new(left._Value / right._Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly partial record struct Force // Newtons
|
public readonly partial record struct Force // Newtons
|
||||||
{
|
{
|
||||||
[OperatorsGenerator(nameof(Coeff1))] public static Area operator /(Force left, Pressure right) => new(left._Value * Coeff1 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff1))] public static Area operator /(Force left, Pressure right) => new(left._Value * Coeff1 / right._Value);
|
||||||
internal static readonly double Coeff1 = Coefficients.DivideCoefficient(Force._Newton, Pressure._Pascal, Area.MeterSquared);
|
internal static readonly double Coeff1 = Coefficients.DivideCoefficient(Force._Newton, Pressure._Pascal, Area.MeterSquared);
|
||||||
[OperatorsGenerator(nameof(Coeff2))] public static Pressure operator /(Force left, Area right) => new(left._Value * Coeff2 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff2))] public static Pressure operator /(Force left, Area right) => new(left._Value * Coeff2 / right._Value);
|
||||||
internal static readonly double Coeff2 = Coefficients.DivideCoefficient(Force._Newton, Area.MeterSquared, Pressure._Pascal);
|
internal static readonly double Coeff2 = Coefficients.DivideCoefficient(Force._Newton, Area.MeterSquared, Pressure._Pascal);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly partial record struct Torque // NewtonMeters
|
public readonly partial record struct Torque // NewtonMeters
|
||||||
{
|
{
|
||||||
[OperatorsGenerator(nameof(Coeff1))] public static Length operator /(Torque left, Force right) => new(left._Value * Coeff1 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff1))] public static Length operator /(Torque left, Force right) => new(left._Value * Coeff1 / right._Value);
|
||||||
internal static readonly double Coeff1 = Coefficients.DivideCoefficient(Torque._Newton_Meter, Force._Newton, Length.Meter);
|
internal static readonly double Coeff1 = Coefficients.DivideCoefficient(Torque._Newton_Meter, Force._Newton, Length.Meter);
|
||||||
[OperatorsGenerator(nameof(Coeff2))] public static Force operator /(Torque left, Length right) => new(left._Value * Coeff2 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff2))] public static Force operator /(Torque left, Length right) => new(left._Value * Coeff2 / right._Value);
|
||||||
internal static readonly double Coeff2 = Coefficients.DivideCoefficient(Torque._Newton_Meter, Length.Meter, Force._Newton);
|
internal static readonly double Coeff2 = Coefficients.DivideCoefficient(Torque._Newton_Meter, Length.Meter, Force._Newton);
|
||||||
[OperatorsGenerator(nameof(Coeff3))] public static ForceLinear operator /(Torque left, Area right) => new(left._Value * Coeff3 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff3))] public static ForceLinear operator /(Torque left, Area right) => new(left._Value * Coeff3 / right._Value);
|
||||||
internal static readonly double Coeff3 = Coefficients.DivideCoefficient(Torque._Newton_Meter, Area._MilliMeterSquared, ForceLinear.KiloNewtonPerMilliMeter );
|
internal static readonly double Coeff3 = Coefficients.DivideCoefficient(Torque._Newton_Meter, Area._MilliMeterSquared, ForceLinear.KiloNewtonPerMilliMeter );
|
||||||
[OperatorsGenerator(nameof(Coeff4))] public static Pressure operator /(Torque left, Volume right) => new(left._Value * Coeff4 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff4))] public static Pressure operator /(Torque left, Volume right) => new(left._Value * Coeff4 / right._Value);
|
||||||
internal static readonly double Coeff4 = Coefficients.DivideCoefficient(Torque._Newton_Meter, Volume.MeterCubic, Pressure._Pascal);
|
internal static readonly double Coeff4 = Coefficients.DivideCoefficient(Torque._Newton_Meter, Volume.MeterCubic, Pressure._Pascal);
|
||||||
[OperatorsGenerator(nameof(Coeff5))] public static Volume operator /(Torque left, Pressure right) => new(left._Value * Coeff5 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff5))] public static Volume operator /(Torque left, Pressure right) => new(left._Value * Coeff5 / right._Value);
|
||||||
internal static readonly double Coeff5 = Coefficients.DivideCoefficient(Torque._Newton_Meter, Pressure._Pascal, Volume.MeterCubic);
|
internal static readonly double Coeff5 = Coefficients.DivideCoefficient(Torque._Newton_Meter, Pressure._Pascal, Volume.MeterCubic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,59 +112,59 @@ public readonly partial record struct Frequency // Hertz
|
|||||||
|
|
||||||
public readonly partial record struct Time
|
public readonly partial record struct Time
|
||||||
{
|
{
|
||||||
public static Speed operator *(Boost left, Time right) => right * left;
|
[MethodImpl(MethodImplOptions.NoInlining)] public static Speed operator *(Boost left, Time right) => right * left;
|
||||||
[OperatorsGenerator(nameof(Coeff1))] public static Speed operator *(Time left, Boost right) => new(left._Value * right._Value * Coeff1);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff1))] public static Speed operator *(Time left, Boost right) => new(left._Value * right._Value * Coeff1);
|
||||||
internal static readonly double Coeff1 = Coefficients.MultiplyCoefficient(Time.Second, Boost._MeterPerSecondSquared, Speed.MeterPerSecond);
|
internal static readonly double Coeff1 = Coefficients.MultiplyCoefficient(Time.Second, Boost._MeterPerSecondSquared, Speed.MeterPerSecond);
|
||||||
|
|
||||||
[OperatorsGenerator(nameof(Coeff2))] public static Speed operator /(Length left, Time right) => new(left._Value * Coeff2 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff2))] public static Speed operator /(Length left, Time right) => new(left._Value * Coeff2 / right._Value);
|
||||||
internal static readonly double Coeff2 = Coefficients.DivideCoefficient(Length.Meter, Time.Second, Speed.MeterPerSecond);
|
internal static readonly double Coeff2 = Coefficients.DivideCoefficient(Length.Meter, Time.Second, Speed.MeterPerSecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly partial record struct Speed
|
public readonly partial record struct Speed
|
||||||
{
|
{
|
||||||
public static Length operator *(Speed left, Time right) => right * left;
|
[MethodImpl(MethodImplOptions.NoInlining)] public static Length operator *(Speed left, Time right) => right * left;
|
||||||
[OperatorsGenerator(nameof(Coeff1))] public static Length operator *(Time left, Speed right) => new(left._Value * right._Value * Coeff1);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff1))] public static Length operator *(Time left, Speed right) => new(left._Value * right._Value * Coeff1);
|
||||||
internal static readonly double Coeff1 = Coefficients.MultiplyCoefficient(Time.Second, Speed.MeterPerSecond, Length.Meter);
|
internal static readonly double Coeff1 = Coefficients.MultiplyCoefficient(Time.Second, Speed.MeterPerSecond, Length.Meter);
|
||||||
|
|
||||||
[OperatorsGenerator(nameof(Coeff2))] public static Boost operator /(Speed left, Time right) => new(left._Value * Coeff2 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff2))] public static Boost operator /(Speed left, Time right) => new(left._Value * Coeff2 / right._Value);
|
||||||
internal static readonly double Coeff2 = Coefficients.DivideCoefficient(Speed.MeterPerSecond, Time.Second, Boost._MeterPerSecondSquared);
|
internal static readonly double Coeff2 = Coefficients.DivideCoefficient(Speed.MeterPerSecond, Time.Second, Boost._MeterPerSecondSquared);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly partial record struct Boost
|
public readonly partial record struct Boost
|
||||||
{
|
{
|
||||||
public static Force operator *(Mass left, Boost right) => right * left;
|
[MethodImpl(MethodImplOptions.NoInlining)] public static Force operator *(Mass left, Boost right) => right * left;
|
||||||
[OperatorsGenerator(nameof(Coeff1))] public static Force operator *(Boost left, Mass right) => new(left._Value * right._Value * Coeff1);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff1))] public static Force operator *(Boost left, Mass right) => new(left._Value * right._Value * Coeff1);
|
||||||
internal static readonly double Coeff1 = Coefficients.MultiplyCoefficient(Boost._MeterPerSecondSquared, Mass.KiloGram, Force._Newton);
|
internal static readonly double Coeff1 = Coefficients.MultiplyCoefficient(Boost._MeterPerSecondSquared, Mass.KiloGram, Force._Newton);
|
||||||
|
|
||||||
public static ForceLinear operator *(MassLinear left, Boost right) => right * left;
|
[MethodImpl(MethodImplOptions.NoInlining)] public static ForceLinear operator *(MassLinear left, Boost right) => right * left;
|
||||||
[OperatorsGenerator(nameof(Coeff2))] public static ForceLinear operator *(Boost left, MassLinear right) => new(left._Value * right._Value * Coeff2);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff2))] public static ForceLinear operator *(Boost left, MassLinear right) => new(left._Value * right._Value * Coeff2);
|
||||||
internal static readonly double Coeff2 = Coefficients.MultiplyCoefficient(Boost._MeterPerSecondSquared, MassLinear.KiloGramPerMilliMeter, ForceLinear._NewtonPerMilliMeter);
|
internal static readonly double Coeff2 = Coefficients.MultiplyCoefficient(Boost._MeterPerSecondSquared, MassLinear.KiloGramPerMilliMeter, ForceLinear._NewtonPerMilliMeter);
|
||||||
|
|
||||||
public static ForceVolumetric operator *(Density left, Boost right) => right * left;
|
[MethodImpl(MethodImplOptions.NoInlining)] public static ForceVolumetric operator *(Density left, Boost right) => right * left;
|
||||||
[OperatorsGenerator(nameof(Coeff3))] public static ForceVolumetric operator *(Boost left, Density right) => new(left._Value * right._Value * Coeff3);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff3))] public static ForceVolumetric operator *(Boost left, Density right) => new(left._Value * right._Value * Coeff3);
|
||||||
internal static readonly double Coeff3 = Coefficients.MultiplyCoefficient(Boost._MeterPerSecondSquared, Density.KiloGramPerMilliMeterCubic, ForceVolumetric._NewtonPerMilliMeterCubic);
|
internal static readonly double Coeff3 = Coefficients.MultiplyCoefficient(Boost._MeterPerSecondSquared, Density.KiloGramPerMilliMeterCubic, ForceVolumetric._NewtonPerMilliMeterCubic);
|
||||||
|
|
||||||
|
|
||||||
[OperatorsGenerator(nameof(Coeff4))] public static MassLinear operator /(ForceLinear left, Boost right) => new(left._Value * Coeff4 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff4))] public static MassLinear operator /(ForceLinear left, Boost right) => new(left._Value * Coeff4 / right._Value);
|
||||||
internal static readonly double Coeff4 = Coefficients.DivideCoefficient(ForceLinear._NewtonPerMilliMeter, Boost._MeterPerSecondSquared, MassLinear.KiloGramPerMilliMeter);
|
internal static readonly double Coeff4 = Coefficients.DivideCoefficient(ForceLinear._NewtonPerMilliMeter, Boost._MeterPerSecondSquared, MassLinear.KiloGramPerMilliMeter);
|
||||||
|
|
||||||
[OperatorsGenerator(nameof(Coeff5))] public static Density operator /(ForceVolumetric left, Boost right) => new(left._Value * Coeff5 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff5))] public static Density operator /(ForceVolumetric left, Boost right) => new(left._Value * Coeff5 / right._Value);
|
||||||
internal static readonly double Coeff5 = Coefficients.DivideCoefficient(ForceVolumetric._NewtonPerMilliMeterCubic, Boost._MeterPerSecondSquared, Density.KiloGramPerMilliMeterCubic);
|
internal static readonly double Coeff5 = Coefficients.DivideCoefficient(ForceVolumetric._NewtonPerMilliMeterCubic, Boost._MeterPerSecondSquared, Density.KiloGramPerMilliMeterCubic);
|
||||||
|
|
||||||
|
|
||||||
[OperatorsGenerator] public static MassPerSquare operator /(Pressure left, Boost right) => new(left._Value / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator] public static MassPerSquare operator /(Pressure left, Boost right) => new(left._Value / right._Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly partial record struct MassPerSquare
|
public readonly partial record struct MassPerSquare
|
||||||
{
|
{
|
||||||
public static Pressure operator *(Boost left, MassPerSquare right) => right * left;
|
[MethodImpl(MethodImplOptions.NoInlining)] public static Pressure operator *(Boost left, MassPerSquare right) => right * left;
|
||||||
[OperatorsGenerator] public static Pressure operator *(MassPerSquare left, Boost right) => new(left._Value * right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator] public static Pressure operator *(MassPerSquare left, Boost right) => new(left._Value * right._Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public readonly partial record struct MassLinear
|
public readonly partial record struct MassLinear
|
||||||
{
|
{
|
||||||
[OperatorsGenerator(nameof(Coeff1))] public static Boost operator /(ForceLinear left, MassLinear right) => new(left._Value * Coeff1 / right._Value);
|
[MethodImpl(MethodImplOptions.NoInlining), OperatorsGenerator(nameof(Coeff1))] public static Boost operator /(ForceLinear left, MassLinear right) => new(left._Value * Coeff1 / right._Value);
|
||||||
|
|
||||||
internal static readonly double Coeff1 = Coefficients.DivideCoefficient(ForceLinear._NewtonPerMilliMeter, MassLinear.KiloGramPerMilliMeter, Boost._MeterPerSecondSquared);
|
internal static readonly double Coeff1 = Coefficients.DivideCoefficient(ForceLinear._NewtonPerMilliMeter, MassLinear.KiloGramPerMilliMeter, Boost._MeterPerSecondSquared);
|
||||||
}
|
}
|
||||||
@@ -8,63 +8,13 @@
|
|||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
|
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0|AnyCPU'">
|
|
||||||
<NoWarn>1701;1702;IDE1006</NoWarn>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0|AnyCPU'">
|
|
||||||
<NoWarn>1701;1702;IDE1006</NoWarn>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0|AnyCPU'">
|
|
||||||
<NoWarn>1701;1702;IDE1006</NoWarn>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net9.0|AnyCPU'">
|
|
||||||
<NoWarn>1701;1702;IDE1006</NoWarn>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net10.0|AnyCPU'">
|
|
||||||
<NoWarn>1701;1702;IDE1006</NoWarn>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0|AnyCPU'">
|
|
||||||
<NoWarn>1701;1702;IDE1006</NoWarn>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0|AnyCPU'">
|
|
||||||
<NoWarn>1701;1702;IDE1006</NoWarn>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0|AnyCPU'">
|
|
||||||
<NoWarn>1701;1702;IDE1006</NoWarn>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net9.0|AnyCPU'">
|
|
||||||
<NoWarn>1701;1702;IDE1006</NoWarn>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net10.0|AnyCPU'">
|
|
||||||
<NoWarn>1701;1702;IDE1006</NoWarn>
|
<NoWarn>1701;1702;IDE1006</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" PrivateAssets="All" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\QWERTYkez.Mensura.Generator\QWERTYkez.Mensura.Generator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
<ProjectReference Include="..\QWERTYkez.Mensura.Generator\QWERTYkez.Mensura.Generator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore">
|
|
||||||
<Version>10.0.8</Version>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions">
|
|
||||||
<Version>10.0.8</Version>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using System.Globalization;
|
using System.Buffers;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace QWERTYkez.Mensura;
|
namespace QWERTYkez.Mensura;
|
||||||
|
|
||||||
public class UnitJsonConverter<U> : JsonConverter<U> where U : struct, IMensuraUnit, IEquatable<U>
|
internal class UnitJsonConverter<U> : JsonConverter<U> where U : struct, IMensuraUnit, IEquatable<U>
|
||||||
{
|
{
|
||||||
// Используем инвариантную культуру, чтобы разделителем всегда была точка (10.5, а не 10,5)
|
|
||||||
private static readonly CultureInfo Culture = CultureInfo.InvariantCulture;
|
private static readonly CultureInfo Culture = CultureInfo.InvariantCulture;
|
||||||
|
|
||||||
public override U Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
public override U Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
@@ -13,15 +13,19 @@ public class UnitJsonConverter<U> : JsonConverter<U> where U : struct, IMensuraU
|
|||||||
|
|
||||||
if (reader.TokenType == JsonTokenType.String)
|
if (reader.TokenType == JsonTokenType.String)
|
||||||
{
|
{
|
||||||
// Безопасно парсим double из строки с поддержкой точки как разделителя
|
// Берем ValueSpan вместо GetString(), чтобы избежать аллокации строки при парсинге!
|
||||||
if (!double.TryParse(reader.GetString(), NumberStyles.Float, Culture, out double_Value))
|
// double.TryParse в .NET Core отлично умеет работать с ReadOnlySpan<char> или ReadOnlySpan<byte>
|
||||||
|
// Так как reader.ValueSpan содержит UTF-8 байты, используем Utf8Parser или String fallback:
|
||||||
|
|
||||||
|
// Самый надежный и быстрый способ для Span<char>:
|
||||||
|
string? str = reader.GetString();
|
||||||
|
if (!double.TryParse(str, NumberStyles.Float, Culture, out double_Value))
|
||||||
{
|
{
|
||||||
throw new JsonException($"Не удалось преобразовать строковое значение в double для метрики {nameof(U)}.");
|
throw new JsonException($"Не удалось преобразовать строковое значение в double для метрики {nameof(U)}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Прямое быстрое чтение числа из JSON
|
|
||||||
double_Value = reader.GetDouble();
|
double_Value = reader.GetDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,27 +34,61 @@ public class UnitJsonConverter<U> : JsonConverter<U> where U : struct, IMensuraU
|
|||||||
|
|
||||||
public override void Write(Utf8JsonWriter writer, U value, JsonSerializerOptions options)
|
public override void Write(Utf8JsonWriter writer, U value, JsonSerializerOptions options)
|
||||||
{
|
{
|
||||||
// Записываем число напрямую в байтовый буфер без выделения памяти под строки
|
double numericValue = value.ToDouble();
|
||||||
writer.WriteNumberValue(value.ToDouble());
|
|
||||||
|
// Необязательно, но сохраняет единообразие с вашим Newtonsoft-конвертером:
|
||||||
|
// Если число целое, пишем как long (выглядит красивее в JSON)
|
||||||
|
if (numericValue == (long)numericValue)
|
||||||
|
{
|
||||||
|
writer.WriteNumberValue((long)numericValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writer.WriteNumberValue(numericValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ОПТИМИЗАЦИЯ: Запись ключа без аллокации строк
|
||||||
public override void WriteAsPropertyName(Utf8JsonWriter writer, U value, JsonSerializerOptions options)
|
public override void WriteAsPropertyName(Utf8JsonWriter writer, U value, JsonSerializerOptions options)
|
||||||
{
|
{
|
||||||
// Ключи JSON-объектов всегда должны быть строками.
|
double doubleValue = value.ToDouble();
|
||||||
// Форматируем double в строку с точкой, чтобы другие сервисы экосистемы прочитали её корректно.
|
|
||||||
// Формат "R" (Round-trip) гарантирует, что число не потеряет точность при обратном парсинге.
|
// Выделяем небольшой буфер на стеке (stackalloc). 32 байт с запасом хватит для любого double.
|
||||||
writer.WritePropertyName(value.ToDouble().ToString("R", Culture));
|
Span<char> buffer = stackalloc char[32];
|
||||||
|
|
||||||
|
// Форматируем число напрямую в буфер на стеке без создания объекта string!
|
||||||
|
// В .NET 6+ double реализует ISpanFormattable
|
||||||
|
if (doubleValue.TryFormat(buffer, out int charsWritten, default, Culture))
|
||||||
|
{
|
||||||
|
writer.WritePropertyName(buffer[..charsWritten]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Fallback на случай непредвиденной ошибки форматирования
|
||||||
|
writer.WritePropertyName(doubleValue.ToString(Culture));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ОПТИМИЗАЦИЯ: Чтение ключа без аллокации строк
|
||||||
public override U ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
public override U ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
{
|
{
|
||||||
string propertyName = reader.GetString()!;
|
// Вместо reader.GetString() используем reader.ValueSpan (работаем напрямую с байтами в памяти)
|
||||||
|
ReadOnlySpan<byte> utf8Bytes = reader.HasValueSequence ? reader.ValueSequence.ToArray() : reader.ValueSpan;
|
||||||
|
|
||||||
if (!double.TryParse(propertyName, NumberStyles.Float, Culture, out double double_Value))
|
// В .NET есть Utf8Parser, который умеет парсить double прямо из UTF-8 байт без конвертации в строку!
|
||||||
|
if (System.Buffers.Text.Utf8Parser.TryParse(utf8Bytes, out double double_Value, out int bytesConsumed) && bytesConsumed == utf8Bytes.Length)
|
||||||
|
{
|
||||||
|
return double_Value.ToUnit<U>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Если Utf8Parser не справился (например, число записано в формате экспоненты "1e+2", который он не всегда любит),
|
||||||
|
// делаем безопасный string-fallback
|
||||||
|
string propertyName = reader.GetString()!;
|
||||||
|
if (!double.TryParse(propertyName, NumberStyles.Float, Culture, out double fallbackValue))
|
||||||
{
|
{
|
||||||
throw new JsonException($"Невалидное числовое значение в ключе свойства JSON: '{propertyName}' для метрики {nameof(U)}.");
|
throw new JsonException($"Невалидное числовое значение в ключе свойства JSON: '{propertyName}' для метрики {nameof(U)}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return double_Value.ToUnit<U>();
|
return fallbackValue.ToUnit<U>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,13 +21,13 @@
|
|||||||
|
|
||||||
// // === Array ===
|
// // === Array ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA[] operator
|
||||||
// *(ZZZZZZZZZZZZZZZZ[] units, BBBBBBBBBBBBBBBB multiplicator) => units.Multiply<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(ZZZZZZZZZZZZZZZZ[] units, BBBBBBBBBBBBBBBB multiplicator) => units.Mul<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA?[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA?[] operator
|
||||||
// *(ZZZZZZZZZZZZZZZZ?[] units, BBBBBBBBBBBBBBBB multiplicator) => units.Multiply<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(ZZZZZZZZZZZZZZZZ?[] units, BBBBBBBBBBBBBBBB multiplicator) => units.Mul<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA[] operator
|
||||||
// *(BBBBBBBBBBBBBBBB multiplicator, ZZZZZZZZZZZZZZZZ[] units) => units.Multiply<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(BBBBBBBBBBBBBBBB multiplicator, ZZZZZZZZZZZZZZZZ[] units) => units.Mul<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA?[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA?[] operator
|
||||||
// *(BBBBBBBBBBBBBBBB multiplicator, ZZZZZZZZZZZZZZZZ?[] units) => units.Multiply<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(BBBBBBBBBBBBBBBB multiplicator, ZZZZZZZZZZZZZZZZ?[] units) => units.Mul<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA[] operator *(ZZZZZZZZZZZZZZZZ[] units, BBBBBBBBBBBBBBBB? multiplicator) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA[] operator *(ZZZZZZZZZZZZZZZZ[] units, BBBBBBBBBBBBBBBB? multiplicator) =>
|
||||||
// multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new AAAAAAAAAAAAAAAA[units.Length]);
|
// multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new AAAAAAAAAAAAAAAA[units.Length]);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA?[] operator *(ZZZZZZZZZZZZZZZZ?[] units, BBBBBBBBBBBBBBBB? multiplicator) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA?[] operator *(ZZZZZZZZZZZZZZZZ?[] units, BBBBBBBBBBBBBBBB? multiplicator) =>
|
||||||
@@ -39,13 +39,13 @@
|
|||||||
|
|
||||||
// // === List<T> ===
|
// // === List<T> ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA> operator
|
||||||
// *(List<ZZZZZZZZZZZZZZZZ> units, BBBBBBBBBBBBBBBB multiplicator) => units.Multiply<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(List<ZZZZZZZZZZZZZZZZ> units, BBBBBBBBBBBBBBBB multiplicator) => units.Mul<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA?> operator
|
||||||
// *(List<ZZZZZZZZZZZZZZZZ?> units, BBBBBBBBBBBBBBBB multiplicator) => units.Multiply<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(List<ZZZZZZZZZZZZZZZZ?> units, BBBBBBBBBBBBBBBB multiplicator) => units.Mul<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA> operator
|
||||||
// *(BBBBBBBBBBBBBBBB multiplicator, List<ZZZZZZZZZZZZZZZZ> units) => units.Multiply<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(BBBBBBBBBBBBBBBB multiplicator, List<ZZZZZZZZZZZZZZZZ> units) => units.Mul<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA?> operator
|
||||||
// *(BBBBBBBBBBBBBBBB multiplicator, List<ZZZZZZZZZZZZZZZZ?> units) => units.Multiply<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(BBBBBBBBBBBBBBBB multiplicator, List<ZZZZZZZZZZZZZZZZ?> units) => units.Mul<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA> operator *(List<ZZZZZZZZZZZZZZZZ> units, BBBBBBBBBBBBBBBB? multiplicator) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA> operator *(List<ZZZZZZZZZZZZZZZZ> units, BBBBBBBBBBBBBBBB? multiplicator) =>
|
||||||
// multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<AAAAAAAAAAAAAAAA>(units.Count));
|
// multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<AAAAAAAAAAAAAAAA>(units.Count));
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA?> operator *(List<ZZZZZZZZZZZZZZZZ?> units, BBBBBBBBBBBBBBBB? multiplicator) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA?> operator *(List<ZZZZZZZZZZZZZZZZ?> units, BBBBBBBBBBBBBBBB? multiplicator) =>
|
||||||
@@ -57,13 +57,13 @@
|
|||||||
|
|
||||||
// // === IEnumerable<T> ===
|
// // === IEnumerable<T> ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA> operator
|
||||||
// *(IEnumerable<ZZZZZZZZZZZZZZZZ> units, BBBBBBBBBBBBBBBB multiplicator) => units.Multiply<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(IEnumerable<ZZZZZZZZZZZZZZZZ> units, BBBBBBBBBBBBBBBB multiplicator) => units.Mul<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA?> operator
|
||||||
// *(IEnumerable<ZZZZZZZZZZZZZZZZ?> units, BBBBBBBBBBBBBBBB multiplicator) => units.Multiply<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(IEnumerable<ZZZZZZZZZZZZZZZZ?> units, BBBBBBBBBBBBBBBB multiplicator) => units.Mul<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA> operator
|
||||||
// *(BBBBBBBBBBBBBBBB multiplicator, IEnumerable<ZZZZZZZZZZZZZZZZ> units) => units.Multiply<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(BBBBBBBBBBBBBBBB multiplicator, IEnumerable<ZZZZZZZZZZZZZZZZ> units) => units.Mul<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA?> operator
|
||||||
// *(BBBBBBBBBBBBBBBB multiplicator, IEnumerable<ZZZZZZZZZZZZZZZZ?> units) => units.Multiply<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(BBBBBBBBBBBBBBBB multiplicator, IEnumerable<ZZZZZZZZZZZZZZZZ?> units) => units.Mul<ZZZZZZZZZZZZZZZZ, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA> operator *(IEnumerable<ZZZZZZZZZZZZZZZZ> units, BBBBBBBBBBBBBBBB? multiplicator) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA> operator *(IEnumerable<ZZZZZZZZZZZZZZZZ> units, BBBBBBBBBBBBBBBB? multiplicator) =>
|
||||||
// multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => new AAAAAAAAAAAAAAAA(0d)));
|
// multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => new AAAAAAAAAAAAAAAA(0d)));
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA?> operator *(IEnumerable<ZZZZZZZZZZZZZZZZ?> units, BBBBBBBBBBBBBBBB? multiplicator) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA?> operator *(IEnumerable<ZZZZZZZZZZZZZZZZ?> units, BBBBBBBBBBBBBBBB? multiplicator) =>
|
||||||
@@ -83,13 +83,13 @@
|
|||||||
|
|
||||||
// // === Array ===
|
// // === Array ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ[] operator
|
||||||
// /(AAAAAAAAAAAAAAAA[] units, BBBBBBBBBBBBBBBB divisor) => units.Divide<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
// /(AAAAAAAAAAAAAAAA[] units, BBBBBBBBBBBBBBBB divisor) => units.Div<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ?[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ?[] operator
|
||||||
// /(AAAAAAAAAAAAAAAA?[] units, BBBBBBBBBBBBBBBB divisor) => units.Divide<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
// /(AAAAAAAAAAAAAAAA?[] units, BBBBBBBBBBBBBBBB divisor) => units.Div<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ[] operator
|
||||||
// /(BBBBBBBBBBBBBBBB dividend, AAAAAAAAAAAAAAAA[] units) => dividend._Value.Divide<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(units);
|
// /(BBBBBBBBBBBBBBBB dividend, AAAAAAAAAAAAAAAA[] units) => dividend._Value.Div<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ?[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ?[] operator
|
||||||
// /(BBBBBBBBBBBBBBBB dividend, AAAAAAAAAAAAAAAA?[] units) => dividend._Value.Divide<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(units);
|
// /(BBBBBBBBBBBBBBBB dividend, AAAAAAAAAAAAAAAA?[] units) => dividend._Value.Div<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ[] operator /(AAAAAAAAAAAAAAAA[] units, BBBBBBBBBBBBBBBB? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ[] operator /(AAAAAAAAAAAAAAAA[] units, BBBBBBBBBBBBBBBB? divisor) =>
|
||||||
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new ZZZZZZZZZZZZZZZZ[units.Length]);
|
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new ZZZZZZZZZZZZZZZZ[units.Length]);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ?[] operator /(AAAAAAAAAAAAAAAA?[] units, BBBBBBBBBBBBBBBB? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ?[] operator /(AAAAAAAAAAAAAAAA?[] units, BBBBBBBBBBBBBBBB? divisor) =>
|
||||||
@@ -101,13 +101,13 @@
|
|||||||
|
|
||||||
// // === List<T> ===
|
// // === List<T> ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ> operator
|
||||||
// /(List<AAAAAAAAAAAAAAAA> units, BBBBBBBBBBBBBBBB divisor) => units.Divide<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
// /(List<AAAAAAAAAAAAAAAA> units, BBBBBBBBBBBBBBBB divisor) => units.Div<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ?> operator
|
||||||
// /(List<AAAAAAAAAAAAAAAA?> units, BBBBBBBBBBBBBBBB divisor) => units.Divide<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
// /(List<AAAAAAAAAAAAAAAA?> units, BBBBBBBBBBBBBBBB divisor) => units.Div<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ> operator
|
||||||
// /(BBBBBBBBBBBBBBBB dividend, List<AAAAAAAAAAAAAAAA> units) => dividend._Value.Divide<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(units);
|
// /(BBBBBBBBBBBBBBBB dividend, List<AAAAAAAAAAAAAAAA> units) => dividend._Value.Div<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ?> operator
|
||||||
// /(BBBBBBBBBBBBBBBB dividend, List<AAAAAAAAAAAAAAAA?> units) => dividend._Value.Divide<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(units);
|
// /(BBBBBBBBBBBBBBBB dividend, List<AAAAAAAAAAAAAAAA?> units) => dividend._Value.Div<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ> operator /(List<AAAAAAAAAAAAAAAA> units, BBBBBBBBBBBBBBBB? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ> operator /(List<AAAAAAAAAAAAAAAA> units, BBBBBBBBBBBBBBBB? divisor) =>
|
||||||
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<ZZZZZZZZZZZZZZZZ>(units.Count));
|
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<ZZZZZZZZZZZZZZZZ>(units.Count));
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ?> operator /(List<AAAAAAAAAAAAAAAA?> units, BBBBBBBBBBBBBBBB? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ?> operator /(List<AAAAAAAAAAAAAAAA?> units, BBBBBBBBBBBBBBBB? divisor) =>
|
||||||
@@ -119,13 +119,13 @@
|
|||||||
|
|
||||||
// // === IEnumerable<T> ===
|
// // === IEnumerable<T> ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ> operator
|
||||||
// /(IEnumerable<AAAAAAAAAAAAAAAA> units, BBBBBBBBBBBBBBBB divisor) => units.Divide<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
// /(IEnumerable<AAAAAAAAAAAAAAAA> units, BBBBBBBBBBBBBBBB divisor) => units.Div<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ?> operator
|
||||||
// /(IEnumerable<AAAAAAAAAAAAAAAA?> units, BBBBBBBBBBBBBBBB divisor) => units.Divide<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
// /(IEnumerable<AAAAAAAAAAAAAAAA?> units, BBBBBBBBBBBBBBBB divisor) => units.Div<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ> operator
|
||||||
// /(BBBBBBBBBBBBBBBB dividend, IEnumerable<AAAAAAAAAAAAAAAA> units) => dividend._Value.Divide<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(units);
|
// /(BBBBBBBBBBBBBBBB dividend, IEnumerable<AAAAAAAAAAAAAAAA> units) => dividend._Value.Div<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ?> operator
|
||||||
// /(BBBBBBBBBBBBBBBB dividend, IEnumerable<AAAAAAAAAAAAAAAA?> units) => dividend._Value.Divide<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(units);
|
// /(BBBBBBBBBBBBBBBB dividend, IEnumerable<AAAAAAAAAAAAAAAA?> units) => dividend._Value.Div<AAAAAAAAAAAAAAAA, ZZZZZZZZZZZZZZZZ>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ> operator /(IEnumerable<AAAAAAAAAAAAAAAA> units, BBBBBBBBBBBBBBBB? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ> operator /(IEnumerable<AAAAAAAAAAAAAAAA> units, BBBBBBBBBBBBBBBB? divisor) =>
|
||||||
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new ZZZZZZZZZZZZZZZZ(0d)));
|
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new ZZZZZZZZZZZZZZZZ(0d)));
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ?> operator /(IEnumerable<AAAAAAAAAAAAAAAA?> units, BBBBBBBBBBBBBBBB? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ?> operator /(IEnumerable<AAAAAAAAAAAAAAAA?> units, BBBBBBBBBBBBBBBB? divisor) =>
|
||||||
@@ -139,13 +139,13 @@
|
|||||||
// {
|
// {
|
||||||
// // === Array ===
|
// // === Array ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB[] operator
|
||||||
// /(ZZZZZZZZZZZZZZZZ[] units, AAAAAAAAAAAAAAAA divisor) => units.Divide<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(divisor._Value);
|
// /(ZZZZZZZZZZZZZZZZ[] units, AAAAAAAAAAAAAAAA divisor) => units.Div<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB?[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB?[] operator
|
||||||
// /(ZZZZZZZZZZZZZZZZ?[] units, AAAAAAAAAAAAAAAA divisor) => units.Divide<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(divisor._Value);
|
// /(ZZZZZZZZZZZZZZZZ?[] units, AAAAAAAAAAAAAAAA divisor) => units.Div<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB[] operator
|
||||||
// /(AAAAAAAAAAAAAAAA dividend, ZZZZZZZZZZZZZZZZ[] units) => dividend._Value.Divide<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(units);
|
// /(AAAAAAAAAAAAAAAA dividend, ZZZZZZZZZZZZZZZZ[] units) => dividend._Value.Div<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB?[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB?[] operator
|
||||||
// /(AAAAAAAAAAAAAAAA dividend, ZZZZZZZZZZZZZZZZ?[] units) => dividend._Value.Divide<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(units);
|
// /(AAAAAAAAAAAAAAAA dividend, ZZZZZZZZZZZZZZZZ?[] units) => dividend._Value.Div<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB[] operator /(ZZZZZZZZZZZZZZZZ[] units, AAAAAAAAAAAAAAAA? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB[] operator /(ZZZZZZZZZZZZZZZZ[] units, AAAAAAAAAAAAAAAA? divisor) =>
|
||||||
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new BBBBBBBBBBBBBBBB[units.Length]);
|
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new BBBBBBBBBBBBBBBB[units.Length]);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB?[] operator /(ZZZZZZZZZZZZZZZZ?[] units, AAAAAAAAAAAAAAAA? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB?[] operator /(ZZZZZZZZZZZZZZZZ?[] units, AAAAAAAAAAAAAAAA? divisor) =>
|
||||||
@@ -157,13 +157,13 @@
|
|||||||
|
|
||||||
// // === List<T> ===
|
// // === List<T> ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB> operator
|
||||||
// /(List<ZZZZZZZZZZZZZZZZ> units, AAAAAAAAAAAAAAAA divisor) => units.Divide<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(divisor._Value);
|
// /(List<ZZZZZZZZZZZZZZZZ> units, AAAAAAAAAAAAAAAA divisor) => units.Div<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB?> operator
|
||||||
// /(List<ZZZZZZZZZZZZZZZZ?> units, AAAAAAAAAAAAAAAA divisor) => units.Divide<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(divisor._Value);
|
// /(List<ZZZZZZZZZZZZZZZZ?> units, AAAAAAAAAAAAAAAA divisor) => units.Div<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB> operator
|
||||||
// /(AAAAAAAAAAAAAAAA dividend, List<ZZZZZZZZZZZZZZZZ> units) => dividend._Value.Divide<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(units);
|
// /(AAAAAAAAAAAAAAAA dividend, List<ZZZZZZZZZZZZZZZZ> units) => dividend._Value.Div<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB?> operator
|
||||||
// /(AAAAAAAAAAAAAAAA dividend, List<ZZZZZZZZZZZZZZZZ?> units) => dividend._Value.Divide<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(units);
|
// /(AAAAAAAAAAAAAAAA dividend, List<ZZZZZZZZZZZZZZZZ?> units) => dividend._Value.Div<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB> operator /(List<ZZZZZZZZZZZZZZZZ> units, AAAAAAAAAAAAAAAA? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB> operator /(List<ZZZZZZZZZZZZZZZZ> units, AAAAAAAAAAAAAAAA? divisor) =>
|
||||||
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<BBBBBBBBBBBBBBBB>(units.Count));
|
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<BBBBBBBBBBBBBBBB>(units.Count));
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB?> operator /(List<ZZZZZZZZZZZZZZZZ?> units, AAAAAAAAAAAAAAAA? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB?> operator /(List<ZZZZZZZZZZZZZZZZ?> units, AAAAAAAAAAAAAAAA? divisor) =>
|
||||||
@@ -175,13 +175,13 @@
|
|||||||
|
|
||||||
// // === IEnumerable<T> ===
|
// // === IEnumerable<T> ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB> operator
|
||||||
// /(IEnumerable<ZZZZZZZZZZZZZZZZ> units, AAAAAAAAAAAAAAAA divisor) => units.Divide<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(divisor._Value);
|
// /(IEnumerable<ZZZZZZZZZZZZZZZZ> units, AAAAAAAAAAAAAAAA divisor) => units.Div<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB?> operator
|
||||||
// /(IEnumerable<ZZZZZZZZZZZZZZZZ?> units, AAAAAAAAAAAAAAAA divisor) => units.Divide<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(divisor._Value);
|
// /(IEnumerable<ZZZZZZZZZZZZZZZZ?> units, AAAAAAAAAAAAAAAA divisor) => units.Div<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB> operator
|
||||||
// /(AAAAAAAAAAAAAAAA dividend, IEnumerable<ZZZZZZZZZZZZZZZZ> units) => dividend._Value.Divide<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(units);
|
// /(AAAAAAAAAAAAAAAA dividend, IEnumerable<ZZZZZZZZZZZZZZZZ> units) => dividend._Value.Div<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB?> operator
|
||||||
// /(AAAAAAAAAAAAAAAA dividend, IEnumerable<ZZZZZZZZZZZZZZZZ?> units) => dividend._Value.Divide<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(units);
|
// /(AAAAAAAAAAAAAAAA dividend, IEnumerable<ZZZZZZZZZZZZZZZZ?> units) => dividend._Value.Div<ZZZZZZZZZZZZZZZZ, BBBBBBBBBBBBBBBB>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB> operator /(IEnumerable<ZZZZZZZZZZZZZZZZ> units, AAAAAAAAAAAAAAAA? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB> operator /(IEnumerable<ZZZZZZZZZZZZZZZZ> units, AAAAAAAAAAAAAAAA? divisor) =>
|
||||||
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new BBBBBBBBBBBBBBBB(0d)));
|
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new BBBBBBBBBBBBBBBB(0d)));
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB?> operator /(IEnumerable<ZZZZZZZZZZZZZZZZ?> units, AAAAAAAAAAAAAAAA? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB?> operator /(IEnumerable<ZZZZZZZZZZZZZZZZ?> units, AAAAAAAAAAAAAAAA? divisor) =>
|
||||||
@@ -201,13 +201,13 @@
|
|||||||
|
|
||||||
// // === Array ===
|
// // === Array ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ[] operator
|
||||||
// /(BBBBBBBBBBBBBBBB[] units, AAAAAAAAAAAAAAAA divisor) => units.Divide<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
// /(BBBBBBBBBBBBBBBB[] units, AAAAAAAAAAAAAAAA divisor) => units.Div<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ?[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ?[] operator
|
||||||
// /(BBBBBBBBBBBBBBBB?[] units, AAAAAAAAAAAAAAAA divisor) => units.Divide<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
// /(BBBBBBBBBBBBBBBB?[] units, AAAAAAAAAAAAAAAA divisor) => units.Div<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ[] operator
|
||||||
// /(AAAAAAAAAAAAAAAA dividend, BBBBBBBBBBBBBBBB[] units) => dividend._Value.Divide<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(units);
|
// /(AAAAAAAAAAAAAAAA dividend, BBBBBBBBBBBBBBBB[] units) => dividend._Value.Div<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ?[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ?[] operator
|
||||||
// /(AAAAAAAAAAAAAAAA dividend, BBBBBBBBBBBBBBBB?[] units) => dividend._Value.Divide<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(units);
|
// /(AAAAAAAAAAAAAAAA dividend, BBBBBBBBBBBBBBBB?[] units) => dividend._Value.Div<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ[] operator /(BBBBBBBBBBBBBBBB[] units, AAAAAAAAAAAAAAAA? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ[] operator /(BBBBBBBBBBBBBBBB[] units, AAAAAAAAAAAAAAAA? divisor) =>
|
||||||
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new ZZZZZZZZZZZZZZZZ[units.Length]);
|
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new ZZZZZZZZZZZZZZZZ[units.Length]);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ?[] operator /(BBBBBBBBBBBBBBBB?[] units, AAAAAAAAAAAAAAAA? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ZZZZZZZZZZZZZZZZ?[] operator /(BBBBBBBBBBBBBBBB?[] units, AAAAAAAAAAAAAAAA? divisor) =>
|
||||||
@@ -219,13 +219,13 @@
|
|||||||
|
|
||||||
// // === List<T> ===
|
// // === List<T> ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ> operator
|
||||||
// /(List<BBBBBBBBBBBBBBBB> units, AAAAAAAAAAAAAAAA divisor) => units.Divide<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
// /(List<BBBBBBBBBBBBBBBB> units, AAAAAAAAAAAAAAAA divisor) => units.Div<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ?> operator
|
||||||
// /(List<BBBBBBBBBBBBBBBB?> units, AAAAAAAAAAAAAAAA divisor) => units.Divide<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
// /(List<BBBBBBBBBBBBBBBB?> units, AAAAAAAAAAAAAAAA divisor) => units.Div<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ> operator
|
||||||
// /(AAAAAAAAAAAAAAAA dividend, List<BBBBBBBBBBBBBBBB> units) => dividend._Value.Divide<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(units);
|
// /(AAAAAAAAAAAAAAAA dividend, List<BBBBBBBBBBBBBBBB> units) => dividend._Value.Div<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ?> operator
|
||||||
// /(AAAAAAAAAAAAAAAA dividend, List<BBBBBBBBBBBBBBBB?> units) => dividend._Value.Divide<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(units);
|
// /(AAAAAAAAAAAAAAAA dividend, List<BBBBBBBBBBBBBBBB?> units) => dividend._Value.Div<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ> operator /(List<BBBBBBBBBBBBBBBB> units, AAAAAAAAAAAAAAAA? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ> operator /(List<BBBBBBBBBBBBBBBB> units, AAAAAAAAAAAAAAAA? divisor) =>
|
||||||
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<ZZZZZZZZZZZZZZZZ>(units.Count));
|
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<ZZZZZZZZZZZZZZZZ>(units.Count));
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ?> operator /(List<BBBBBBBBBBBBBBBB?> units, AAAAAAAAAAAAAAAA? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<ZZZZZZZZZZZZZZZZ?> operator /(List<BBBBBBBBBBBBBBBB?> units, AAAAAAAAAAAAAAAA? divisor) =>
|
||||||
@@ -237,13 +237,13 @@
|
|||||||
|
|
||||||
// // === IEnumerable<T> ===
|
// // === IEnumerable<T> ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ> operator
|
||||||
// /(IEnumerable<BBBBBBBBBBBBBBBB> units, AAAAAAAAAAAAAAAA divisor) => units.Divide<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
// /(IEnumerable<BBBBBBBBBBBBBBBB> units, AAAAAAAAAAAAAAAA divisor) => units.Div<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ?> operator
|
||||||
// /(IEnumerable<BBBBBBBBBBBBBBBB?> units, AAAAAAAAAAAAAAAA divisor) => units.Divide<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
// /(IEnumerable<BBBBBBBBBBBBBBBB?> units, AAAAAAAAAAAAAAAA divisor) => units.Div<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ> operator
|
||||||
// /(AAAAAAAAAAAAAAAA dividend, IEnumerable<BBBBBBBBBBBBBBBB> units) => dividend._Value.Divide<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(units);
|
// /(AAAAAAAAAAAAAAAA dividend, IEnumerable<BBBBBBBBBBBBBBBB> units) => dividend._Value.Div<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ?> operator
|
||||||
// /(AAAAAAAAAAAAAAAA dividend, IEnumerable<BBBBBBBBBBBBBBBB?> units) => dividend._Value.Divide<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(units);
|
// /(AAAAAAAAAAAAAAAA dividend, IEnumerable<BBBBBBBBBBBBBBBB?> units) => dividend._Value.Div<BBBBBBBBBBBBBBBB, ZZZZZZZZZZZZZZZZ>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ> operator /(IEnumerable<BBBBBBBBBBBBBBBB> units, AAAAAAAAAAAAAAAA? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ> operator /(IEnumerable<BBBBBBBBBBBBBBBB> units, AAAAAAAAAAAAAAAA? divisor) =>
|
||||||
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new ZZZZZZZZZZZZZZZZ(0d)));
|
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new ZZZZZZZZZZZZZZZZ(0d)));
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ?> operator /(IEnumerable<BBBBBBBBBBBBBBBB?> units, AAAAAAAAAAAAAAAA? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<ZZZZZZZZZZZZZZZZ?> operator /(IEnumerable<BBBBBBBBBBBBBBBB?> units, AAAAAAAAAAAAAAAA? divisor) =>
|
||||||
@@ -307,13 +307,13 @@
|
|||||||
|
|
||||||
// // === Array ===
|
// // === Array ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA[] operator
|
||||||
// *(BBBBBBBBBBBBBBBB[] units, ZZZZZZZZZZZZZZZZ multiplicator) => units.Multiply<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(BBBBBBBBBBBBBBBB[] units, ZZZZZZZZZZZZZZZZ multiplicator) => units.Mul<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA?[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA?[] operator
|
||||||
// *(BBBBBBBBBBBBBBBB?[] units, ZZZZZZZZZZZZZZZZ multiplicator) => units.Multiply<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(BBBBBBBBBBBBBBBB?[] units, ZZZZZZZZZZZZZZZZ multiplicator) => units.Mul<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA[] operator
|
||||||
// *(ZZZZZZZZZZZZZZZZ multiplicator, BBBBBBBBBBBBBBBB[] units) => units.Multiply<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(ZZZZZZZZZZZZZZZZ multiplicator, BBBBBBBBBBBBBBBB[] units) => units.Mul<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA?[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA?[] operator
|
||||||
// *(ZZZZZZZZZZZZZZZZ multiplicator, BBBBBBBBBBBBBBBB?[] units) => units.Multiply<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(ZZZZZZZZZZZZZZZZ multiplicator, BBBBBBBBBBBBBBBB?[] units) => units.Mul<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA[] operator *(BBBBBBBBBBBBBBBB[] units, ZZZZZZZZZZZZZZZZ? multiplicator) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA[] operator *(BBBBBBBBBBBBBBBB[] units, ZZZZZZZZZZZZZZZZ? multiplicator) =>
|
||||||
// multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new AAAAAAAAAAAAAAAA[units.Length]);
|
// multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new AAAAAAAAAAAAAAAA[units.Length]);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA?[] operator *(BBBBBBBBBBBBBBBB?[] units, ZZZZZZZZZZZZZZZZ? multiplicator) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AAAAAAAAAAAAAAAA?[] operator *(BBBBBBBBBBBBBBBB?[] units, ZZZZZZZZZZZZZZZZ? multiplicator) =>
|
||||||
@@ -325,13 +325,13 @@
|
|||||||
|
|
||||||
// // === List<T> ===
|
// // === List<T> ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA> operator
|
||||||
// *(List<BBBBBBBBBBBBBBBB> units, ZZZZZZZZZZZZZZZZ multiplicator) => units.Multiply<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(List<BBBBBBBBBBBBBBBB> units, ZZZZZZZZZZZZZZZZ multiplicator) => units.Mul<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA?> operator
|
||||||
// *(List<BBBBBBBBBBBBBBBB?> units, ZZZZZZZZZZZZZZZZ multiplicator) => units.Multiply<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(List<BBBBBBBBBBBBBBBB?> units, ZZZZZZZZZZZZZZZZ multiplicator) => units.Mul<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA> operator
|
||||||
// *(ZZZZZZZZZZZZZZZZ multiplicator, List<BBBBBBBBBBBBBBBB> units) => units.Multiply<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(ZZZZZZZZZZZZZZZZ multiplicator, List<BBBBBBBBBBBBBBBB> units) => units.Mul<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA?> operator
|
||||||
// *(ZZZZZZZZZZZZZZZZ multiplicator, List<BBBBBBBBBBBBBBBB?> units) => units.Multiply<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(ZZZZZZZZZZZZZZZZ multiplicator, List<BBBBBBBBBBBBBBBB?> units) => units.Mul<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA> operator *(List<BBBBBBBBBBBBBBBB> units, ZZZZZZZZZZZZZZZZ? multiplicator) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA> operator *(List<BBBBBBBBBBBBBBBB> units, ZZZZZZZZZZZZZZZZ? multiplicator) =>
|
||||||
// multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<AAAAAAAAAAAAAAAA>(units.Count));
|
// multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : new List<AAAAAAAAAAAAAAAA>(units.Count));
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA?> operator *(List<BBBBBBBBBBBBBBBB?> units, ZZZZZZZZZZZZZZZZ? multiplicator) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<AAAAAAAAAAAAAAAA?> operator *(List<BBBBBBBBBBBBBBBB?> units, ZZZZZZZZZZZZZZZZ? multiplicator) =>
|
||||||
@@ -343,13 +343,13 @@
|
|||||||
|
|
||||||
// // === IEnumerable<T> ===
|
// // === IEnumerable<T> ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA> operator
|
||||||
// *(IEnumerable<BBBBBBBBBBBBBBBB> units, ZZZZZZZZZZZZZZZZ multiplicator) => units.Multiply<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(IEnumerable<BBBBBBBBBBBBBBBB> units, ZZZZZZZZZZZZZZZZ multiplicator) => units.Mul<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA?> operator
|
||||||
// *(IEnumerable<BBBBBBBBBBBBBBBB?> units, ZZZZZZZZZZZZZZZZ multiplicator) => units.Multiply<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(IEnumerable<BBBBBBBBBBBBBBBB?> units, ZZZZZZZZZZZZZZZZ multiplicator) => units.Mul<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA> operator
|
||||||
// *(ZZZZZZZZZZZZZZZZ multiplicator, IEnumerable<BBBBBBBBBBBBBBBB> units) => units.Multiply<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(ZZZZZZZZZZZZZZZZ multiplicator, IEnumerable<BBBBBBBBBBBBBBBB> units) => units.Mul<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA?> operator
|
||||||
// *(ZZZZZZZZZZZZZZZZ multiplicator, IEnumerable<BBBBBBBBBBBBBBBB?> units) => units.Multiply<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
// *(ZZZZZZZZZZZZZZZZ multiplicator, IEnumerable<BBBBBBBBBBBBBBBB?> units) => units.Mul<BBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAA>(multiplicator._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA> operator *(IEnumerable<BBBBBBBBBBBBBBBB> units, ZZZZZZZZZZZZZZZZ? multiplicator) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA> operator *(IEnumerable<BBBBBBBBBBBBBBBB> units, ZZZZZZZZZZZZZZZZ? multiplicator) =>
|
||||||
// multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => new AAAAAAAAAAAAAAAA(0d)));
|
// multiplicator.HasValue ? units * multiplicator.Value : (units is null ? null! : units.Select(u => new AAAAAAAAAAAAAAAA(0d)));
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA?> operator *(IEnumerable<BBBBBBBBBBBBBBBB?> units, ZZZZZZZZZZZZZZZZ? multiplicator) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<AAAAAAAAAAAAAAAA?> operator *(IEnumerable<BBBBBBBBBBBBBBBB?> units, ZZZZZZZZZZZZZZZZ? multiplicator) =>
|
||||||
@@ -366,13 +366,13 @@
|
|||||||
|
|
||||||
// // === Array ===
|
// // === Array ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB[] operator
|
||||||
// /(AAAAAAAAAAAAAAAA[] units, ZZZZZZZZZZZZZZZZ divisor) => units.Divide<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(divisor._Value);
|
// /(AAAAAAAAAAAAAAAA[] units, ZZZZZZZZZZZZZZZZ divisor) => units.Div<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB?[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB?[] operator
|
||||||
// /(AAAAAAAAAAAAAAAA?[] units, ZZZZZZZZZZZZZZZZ divisor) => units.Divide<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(divisor._Value);
|
// /(AAAAAAAAAAAAAAAA?[] units, ZZZZZZZZZZZZZZZZ divisor) => units.Div<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB[] operator
|
||||||
// /(ZZZZZZZZZZZZZZZZ dividend, AAAAAAAAAAAAAAAA[] units) => dividend._Value.Divide<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(units);
|
// /(ZZZZZZZZZZZZZZZZ dividend, AAAAAAAAAAAAAAAA[] units) => dividend._Value.Div<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB?[] operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB?[] operator
|
||||||
// /(ZZZZZZZZZZZZZZZZ dividend, AAAAAAAAAAAAAAAA?[] units) => dividend._Value.Divide<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(units);
|
// /(ZZZZZZZZZZZZZZZZ dividend, AAAAAAAAAAAAAAAA?[] units) => dividend._Value.Div<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB[] operator /(AAAAAAAAAAAAAAAA[] units, ZZZZZZZZZZZZZZZZ? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB[] operator /(AAAAAAAAAAAAAAAA[] units, ZZZZZZZZZZZZZZZZ? divisor) =>
|
||||||
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new BBBBBBBBBBBBBBBB[units.Length]);
|
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new BBBBBBBBBBBBBBBB[units.Length]);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB?[] operator /(AAAAAAAAAAAAAAAA?[] units, ZZZZZZZZZZZZZZZZ? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BBBBBBBBBBBBBBBB?[] operator /(AAAAAAAAAAAAAAAA?[] units, ZZZZZZZZZZZZZZZZ? divisor) =>
|
||||||
@@ -384,13 +384,13 @@
|
|||||||
|
|
||||||
// // === List<T> ===
|
// // === List<T> ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB> operator
|
||||||
// /(List<AAAAAAAAAAAAAAAA> units, ZZZZZZZZZZZZZZZZ divisor) => units.Divide<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(divisor._Value);
|
// /(List<AAAAAAAAAAAAAAAA> units, ZZZZZZZZZZZZZZZZ divisor) => units.Div<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB?> operator
|
||||||
// /(List<AAAAAAAAAAAAAAAA?> units, ZZZZZZZZZZZZZZZZ divisor) => units.Divide<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(divisor._Value);
|
// /(List<AAAAAAAAAAAAAAAA?> units, ZZZZZZZZZZZZZZZZ divisor) => units.Div<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB> operator
|
||||||
// /(ZZZZZZZZZZZZZZZZ dividend, List<AAAAAAAAAAAAAAAA> units) => dividend._Value.Divide<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(units);
|
// /(ZZZZZZZZZZZZZZZZ dividend, List<AAAAAAAAAAAAAAAA> units) => dividend._Value.Div<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB?> operator
|
||||||
// /(ZZZZZZZZZZZZZZZZ dividend, List<AAAAAAAAAAAAAAAA?> units) => dividend._Value.Divide<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(units);
|
// /(ZZZZZZZZZZZZZZZZ dividend, List<AAAAAAAAAAAAAAAA?> units) => dividend._Value.Div<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB> operator /(List<AAAAAAAAAAAAAAAA> units, ZZZZZZZZZZZZZZZZ? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB> operator /(List<AAAAAAAAAAAAAAAA> units, ZZZZZZZZZZZZZZZZ? divisor) =>
|
||||||
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<BBBBBBBBBBBBBBBB>(units.Count));
|
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : new List<BBBBBBBBBBBBBBBB>(units.Count));
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB?> operator /(List<AAAAAAAAAAAAAAAA?> units, ZZZZZZZZZZZZZZZZ? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<BBBBBBBBBBBBBBBB?> operator /(List<AAAAAAAAAAAAAAAA?> units, ZZZZZZZZZZZZZZZZ? divisor) =>
|
||||||
@@ -402,13 +402,13 @@
|
|||||||
|
|
||||||
// // === IEnumerable<T> ===
|
// // === IEnumerable<T> ===
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB> operator
|
||||||
// /(IEnumerable<AAAAAAAAAAAAAAAA> units, ZZZZZZZZZZZZZZZZ divisor) => units.Divide<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(divisor._Value);
|
// /(IEnumerable<AAAAAAAAAAAAAAAA> units, ZZZZZZZZZZZZZZZZ divisor) => units.Div<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB?> operator
|
||||||
// /(IEnumerable<AAAAAAAAAAAAAAAA?> units, ZZZZZZZZZZZZZZZZ divisor) => units.Divide<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(divisor._Value);
|
// /(IEnumerable<AAAAAAAAAAAAAAAA?> units, ZZZZZZZZZZZZZZZZ divisor) => units.Div<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(divisor._Value);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB> operator
|
||||||
// /(ZZZZZZZZZZZZZZZZ dividend, IEnumerable<AAAAAAAAAAAAAAAA> units) => dividend._Value.Divide<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(units);
|
// /(ZZZZZZZZZZZZZZZZ dividend, IEnumerable<AAAAAAAAAAAAAAAA> units) => dividend._Value.Div<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB?> operator
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB?> operator
|
||||||
// /(ZZZZZZZZZZZZZZZZ dividend, IEnumerable<AAAAAAAAAAAAAAAA?> units) => dividend._Value.Divide<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(units);
|
// /(ZZZZZZZZZZZZZZZZ dividend, IEnumerable<AAAAAAAAAAAAAAAA?> units) => dividend._Value.Div<AAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBB>(units);
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB> operator /(IEnumerable<AAAAAAAAAAAAAAAA> units, ZZZZZZZZZZZZZZZZ? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB> operator /(IEnumerable<AAAAAAAAAAAAAAAA> units, ZZZZZZZZZZZZZZZZ? divisor) =>
|
||||||
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new BBBBBBBBBBBBBBBB(0d)));
|
// divisor.HasValue ? units / divisor.Value : (units is null ? null! : units.Select(u => new BBBBBBBBBBBBBBBB(0d)));
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB?> operator /(IEnumerable<AAAAAAAAAAAAAAAA?> units, ZZZZZZZZZZZZZZZZ? divisor) =>
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<BBBBBBBBBBBBBBBB?> operator /(IEnumerable<AAAAAAAAAAAAAAAA?> units, ZZZZZZZZZZZZZZZZ? divisor) =>
|
||||||
|
|||||||
@@ -1,199 +1,526 @@
|
|||||||
#if DEBUG
|
//namespace QWERTYkez.Mensura.Units;
|
||||||
global using XXXXXXXXXXXXXXExtensions = QWERTYkez.Mensura.Units.XXXXXXXXXXXXXXExtensions;
|
|
||||||
global using XXXXXXXXXXXXXX = QWERTYkez.Mensura.Units.XXXXXXXXXXXXXX;
|
|
||||||
|
|
||||||
using System.Runtime.Serialization;
|
//[JsonConverter(typeof(UnitJsonConverter<XXXXXXXX>))]
|
||||||
|
//public readonly partial record struct XXXXXXXX : IMensuraUnit<XXXXXXXX>, IEquatable<XXXXXXXX>, 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;
|
||||||
|
|
||||||
namespace QWERTYkez.Mensura.Units;
|
// 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 class XXXXXXXXXXXXXXConverter : UnitJsonConverter<XXXXXXXXXXXXXX> { }
|
// public bool Equals(XXXXXXXX? other) => _Value.Equals(other?._Value);
|
||||||
|
|
||||||
[JsonConverter(typeof(XXXXXXXXXXXXXXConverter))]
|
|
||||||
public readonly partial record struct XXXXXXXXXXXXXX : IMensuraUnit<XXXXXXXXXXXXXX>, IEquatable<XXXXXXXXXXXXXX>, IMensuraUnit
|
|
||||||
{
|
|
||||||
[JsonInclude, DataMember, JsonPropertyName("v"), Obsolete] // для JSON / EF на случай сбоев, если пробелма с _Value
|
|
||||||
internal double Value { get => _Value; init => _Value = value; }
|
|
||||||
internal readonly double _Value;
|
|
||||||
internal XXXXXXXXXXXXXX(double value) => _Value = value;
|
|
||||||
|
|
||||||
public override int GetHashCode() => _Value.GetHashCode();
|
|
||||||
public int CompareTo(XXXXXXXXXXXXXX? other) => _Value.CompareTo(other is null ? 0d : other.Value._Value);
|
|
||||||
public int CompareTo(XXXXXXXXXXXXXX other) => _Value.CompareTo(other._Value);
|
|
||||||
|
|
||||||
public bool Equals(XXXXXXXXXXXXXX? other) => _Value.Equals(other?._Value);
|
|
||||||
|
|
||||||
|
|
||||||
[JsonIgnore, IgnoreDataMember] public bool IsPositive => _Value >= 0;
|
// public static explicit operator XXXXXXXX(double val) => Unsafe.As<double, XXXXXXXX>(ref val);
|
||||||
[JsonIgnore, IgnoreDataMember] public bool IsGreaterThanZero => _Value > 0;
|
// public static explicit operator double(XXXXXXXX unit) => unit._Value;
|
||||||
[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 XXXXXXXXXXXXXX Zero { get; } = new(0d);
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static XXXXXXXXXXXXXX Min { get; } = new(double.MinValue);
|
// public XXXXXXXX Abs() => new(Math.Abs(_Value));
|
||||||
public static XXXXXXXXXXXXXX Max { get; } = new(double.MaxValue);
|
|
||||||
public static XXXXXXXXXXXXXX NegativeInfinity { get; } = new(double.NegativeInfinity);
|
|
||||||
public static XXXXXXXXXXXXXX PositiveInfinity { get; } = new(double.PositiveInfinity);
|
|
||||||
|
|
||||||
public static bool operator ==(XXXXXXXXXXXXXX? T1, XXXXXXXXXXXXXX? T2) => T1.Protected() == T2.Protected();
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static bool operator !=(XXXXXXXXXXXXXX? T1, XXXXXXXXXXXXXX? T2) => T1.Protected() != T2.Protected();
|
// internal R Pow2_Internal<R>() where R : struct, IMensuraUnit, IEquatable<R> => (_Value * _Value).ToUnit<R>();
|
||||||
|
|
||||||
public static bool operator <(XXXXXXXXXXXXXX? T1, XXXXXXXXXXXXXX? T2) => T1.Protected() < T2.Protected();
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static bool operator <=(XXXXXXXXXXXXXX? T1, XXXXXXXXXXXXXX? T2) => T1.Protected() <= T2.Protected();
|
// internal R Sqrt_Internal<R>() where R : struct, IMensuraUnit, IEquatable<R> => Math.Sqrt(_Value).ToUnit<R>();
|
||||||
public static bool operator >(XXXXXXXXXXXXXX? T1, XXXXXXXXXXXXXX? T2) => T1.Protected() > T2.Protected();
|
|
||||||
public static bool operator >=(XXXXXXXXXXXXXX? T1, XXXXXXXXXXXXXX? T2) => T1.Protected() >= T2.Protected();
|
|
||||||
|
|
||||||
|
|
||||||
public static XXXXXXXXXXXXXX operator +(XXXXXXXXXXXXXX T2) => new(+T2._Value);
|
|
||||||
public static XXXXXXXXXXXXXX operator +(XXXXXXXXXXXXXX T1, XXXXXXXXXXXXXX T2) => new(T1._Value + T2._Value);
|
// [JsonIgnore, IgnoreDataMember] public bool IsPositive => _Value >= 0;
|
||||||
public static XXXXXXXXXXXXXX operator -(XXXXXXXXXXXXXX T2) => new(-T2._Value);
|
// [JsonIgnore, IgnoreDataMember] public bool IsGreaterThanZero => _Value > 0;
|
||||||
public static XXXXXXXXXXXXXX operator -(XXXXXXXXXXXXXX T1, XXXXXXXXXXXXXX T2) => new(T1._Value - T2._Value);
|
// [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);
|
||||||
|
|
||||||
|
|
||||||
// double
|
// public static XXXXXXXX Zero { get; } = new(0d);
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, double T2) => new(T1._Value * T2);
|
// public static XXXXXXXX Min { get; } = new(double.MinValue);
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, double? T2) => T1 * (T2 ?? 0d);
|
// public static XXXXXXXX Max { get; } = new(double.MaxValue);
|
||||||
public static XXXXXXXXXXXXXX operator *(double T1, XXXXXXXXXXXXXX T2) => new(T1 * T2._Value);
|
// public static XXXXXXXX NegativeInfinity { get; } = new(double.NegativeInfinity);
|
||||||
public static XXXXXXXXXXXXXX operator *(double? T1, XXXXXXXXXXXXXX T2) => (T1 ?? 0d) * T2;
|
// public static XXXXXXXX PositiveInfinity { get; } = new(double.PositiveInfinity);
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, double T2) => new(T1._Value / T2);
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, double? T2) => T1 / (T2 ?? 0d);
|
|
||||||
public static double operator /(XXXXXXXXXXXXXX T1, XXXXXXXXXXXXXX T2) => T1._Value / T2._Value;
|
|
||||||
|
|
||||||
// sbyte
|
// public static bool operator ==(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() == T2.Protected();
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, sbyte T2) => T1 * T2.ToDouble();
|
// public static bool operator !=(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() != T2.Protected();
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, sbyte? T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(sbyte T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator *(sbyte? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, sbyte T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, sbyte? T2) => T1 / T2.ToDouble();
|
|
||||||
|
|
||||||
// short
|
// public static bool operator <(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() < T2.Protected();
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, short T2) => T1 * T2.ToDouble();
|
// public static bool operator <=(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() <= T2.Protected();
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, short? T2) => T1 * T2.ToDouble();
|
// public static bool operator >(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() > T2.Protected();
|
||||||
public static XXXXXXXXXXXXXX operator *(short T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
// public static bool operator >=(XXXXXXXX? T1, XXXXXXXX? T2) => T1.Protected() >= T2.Protected();
|
||||||
public static XXXXXXXXXXXXXX operator *(short? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, short T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, short? T2) => T1 / T2.ToDouble();
|
|
||||||
|
|
||||||
// int
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, int T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, int? T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(int T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator *(int? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, int T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, int? T2) => T1 / T2.ToDouble();
|
|
||||||
|
|
||||||
// long
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, long T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, long? T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(long T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator *(long? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, long T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, long? T2) => T1 / T2.ToDouble();
|
|
||||||
|
|
||||||
// byte
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, byte T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, byte? T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(byte T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator *(byte? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, byte T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, byte? T2) => T1 / T2.ToDouble();
|
|
||||||
|
|
||||||
// ushort
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, ushort T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, ushort? T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(ushort T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator *(ushort? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, ushort T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, ushort? T2) => T1 / T2.ToDouble();
|
|
||||||
|
|
||||||
// uint
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, uint T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, uint? T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(uint T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator *(uint? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, uint T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, uint? T2) => T1 / T2.ToDouble();
|
|
||||||
|
|
||||||
// ulong
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, ulong T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, ulong? T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(ulong T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator *(ulong? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, ulong T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, ulong? T2) => T1 / T2.ToDouble();
|
|
||||||
|
|
||||||
// nint
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, nint T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, nint? T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(nint T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator *(nint? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, nint T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, nint? T2) => T1 / T2.ToDouble();
|
|
||||||
|
|
||||||
// nuint
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, nuint T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, nuint? T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(nuint T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator *(nuint? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, nuint T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, nuint? T2) => T1 / T2.ToDouble();
|
|
||||||
|
|
||||||
// float
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, float T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, float? T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(float T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator *(float? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, float T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, float? T2) => T1 / T2.ToDouble();
|
|
||||||
|
|
||||||
// decimal
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, decimal T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, decimal? T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(decimal T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator *(decimal? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, decimal T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, decimal? T2) => T1 / T2.ToDouble();
|
|
||||||
|
|
||||||
#if NET7_0_OR_GREATER
|
|
||||||
// Int128
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, Int128 T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, Int128? T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(Int128 T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator *(Int128? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, Int128 T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, Int128? T2) => T1 / T2.ToDouble();
|
|
||||||
|
|
||||||
// UInt128
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, UInt128 T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(XXXXXXXXXXXXXX T1, UInt128? T2) => T1 * T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator *(UInt128 T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator *(UInt128? T1, XXXXXXXXXXXXXX T2) => T1.ToDouble() * T2;
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, UInt128 T2) => T1 / T2.ToDouble();
|
|
||||||
public static XXXXXXXXXXXXXX operator /(XXXXXXXXXXXXXX T1, UInt128? T2) => T1 / T2.ToDouble();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public static explicit operator XXXXXXXXXXXXXX(double val) => Unsafe.As<double, XXXXXXXXXXXXXX>(ref val);
|
|
||||||
public static explicit operator double(XXXXXXXXXXXXXX unit) => unit._Value;
|
|
||||||
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
// public static XXXXXXXX operator +(XXXXXXXX T2) => new(+T2._Value);
|
||||||
public XXXXXXXXXXXXXX Abs() => new(Math.Abs(_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);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
internal R Pow2_Internal<R>() where R : struct, IMensuraUnit, IEquatable<R> => (_Value * _Value).ToUnit<R>();
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
// // double
|
||||||
internal R Sqrt_Internal<R>() where R : struct, IMensuraUnit, IEquatable<R> => Math.Sqrt(_Value).ToUnit<R>();
|
// 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;
|
||||||
|
|
||||||
public static class XXXXXXXXXXXXXXExtensions
|
// // sbyte
|
||||||
{
|
// public static XXXXXXXX operator *(XXXXXXXX T1, sbyte T2) => T1 * T2.ToDouble();
|
||||||
public static double Protected(this XXXXXXXXXXXXXX? unit) => unit is null ? 0d : unit.Value._Value;
|
// public static XXXXXXXX operator *(XXXXXXXX T1, sbyte? T2) => T1 * T2.ToDouble();
|
||||||
}
|
// public static XXXXXXXX operator *(sbyte T1, XXXXXXXX T2) => T1.ToDouble() * T2;
|
||||||
#endif
|
// 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 class XXXXXXXXExtensions
|
||||||
|
//{
|
||||||
|
// public static double Protected(this XXXXXXXX? unit) => unit is null ? 0d : unit.Value._Value;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// // === ReadOnlySpan
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ReadOnlySpan<XXXXXXXX> units,
|
||||||
|
// double divisor, Span<XXXXXXXX> destination) => units.Div<XXXXXXXX>(divisor, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ReadOnlySpan<XXXXXXXX?> units,
|
||||||
|
// double divisor, Span<XXXXXXXX?> destination) => units.Div<XXXXXXXX>(divisor, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
// ReadOnlySpan<XXXXXXXX> units, Span<XXXXXXXX> destination) => dividend.Div<XXXXXXXX>(units, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
// ReadOnlySpan<XXXXXXXX?> units, Span<XXXXXXXX?> destination) => dividend.Div<XXXXXXXX>(units, destination);
|
||||||
|
|
||||||
|
// // === Array ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static XXXXXXXX[] Div(
|
||||||
|
// this XXXXXXXX[] units, double divisor) => units.Div<XXXXXXXX>(divisor);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Div(
|
||||||
|
// this XXXXXXXX?[] units, double divisor) => units.Div<XXXXXXXX>(divisor);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX[] Div(
|
||||||
|
// this double dividend, XXXXXXXX[] units) => dividend.Div<XXXXXXXX>(units);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Div(
|
||||||
|
// this double dividend, XXXXXXXX?[] units) => dividend.Div<XXXXXXXX>(units);
|
||||||
|
|
||||||
|
// // === List<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX> Div(
|
||||||
|
// this List<XXXXXXXX> units, double divisor) => units.Div<XXXXXXXX>(divisor);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX?> Div(
|
||||||
|
// this List<XXXXXXXX?> units, double divisor) => units.Div<XXXXXXXX>(divisor);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX> Div(
|
||||||
|
// this double dividend, List<XXXXXXXX> units) => dividend.Div<XXXXXXXX>(units);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX?> Div(
|
||||||
|
// this double dividend, List<XXXXXXXX?> units) => dividend.Div<XXXXXXXX>(units);
|
||||||
|
|
||||||
|
// // === ICollection<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ICollection<XXXXXXXX> units,
|
||||||
|
// double divisor, Span<XXXXXXXX> destination) => units.Div<XXXXXXXX>(divisor, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this ICollection<XXXXXXXX?> units,
|
||||||
|
// double divisor, Span<XXXXXXXX?> destination) => units.Div<XXXXXXXX>(divisor, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
// ICollection<XXXXXXXX> units, Span<XXXXXXXX> destination) => dividend.Div<XXXXXXXX>(units, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
// ICollection<XXXXXXXX?> units, Span<XXXXXXXX?> destination) => dividend.Div<XXXXXXXX>(units, destination);
|
||||||
|
|
||||||
|
// // === IReadOnlyCollection<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Div(this IReadOnlyCollection<XXXXXXXX> units,
|
||||||
|
// double divisor, Span<XXXXXXXX> destination) => units.Div<XXXXXXXX>(divisor, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Div(this IReadOnlyCollection<XXXXXXXX?> units,
|
||||||
|
// double divisor, Span<XXXXXXXX?> destination) => units.Div<XXXXXXXX>(divisor, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
// IReadOnlyCollection<XXXXXXXX> units, Span<XXXXXXXX> destination) => dividend.Div<XXXXXXXX>(units, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Div(this double dividend,
|
||||||
|
// IReadOnlyCollection<XXXXXXXX?> units, Span<XXXXXXXX?> destination) => dividend.Div<XXXXXXXX>(units, destination);
|
||||||
|
|
||||||
|
// // === IEnumerable<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX> Div(
|
||||||
|
// this IEnumerable<XXXXXXXX> units, double divisor) => units.Div<XXXXXXXX>(divisor);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX?> Div(
|
||||||
|
// this IEnumerable<XXXXXXXX?> units, double divisor) => units.Div<XXXXXXXX>(divisor);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX> Div(
|
||||||
|
// this double dividend, IEnumerable<XXXXXXXX> units) => dividend.Div<XXXXXXXX>(units);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX?> Div(
|
||||||
|
// this double dividend, IEnumerable<XXXXXXXX?> units) => dividend.Div<XXXXXXXX>(units);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// // === ReadOnlySpan
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ReadOnlySpan<XXXXXXXX> units,
|
||||||
|
// double subtrahend, Span<XXXXXXXX> destination) => units.Minus<XXXXXXXX>(subtrahend, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ReadOnlySpan<XXXXXXXX?> units,
|
||||||
|
// double subtrahend, Span<XXXXXXXX?> destination) => units.Minus<XXXXXXXX>(subtrahend, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
// ReadOnlySpan<XXXXXXXX> units, Span<XXXXXXXX> destination) => minuend.Minus<XXXXXXXX>(units, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
// ReadOnlySpan<XXXXXXXX?> units, Span<XXXXXXXX?> destination) => minuend.Minus<XXXXXXXX>(units, destination);
|
||||||
|
|
||||||
|
// // === Array ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static XXXXXXXX[] Minus(
|
||||||
|
// this XXXXXXXX[] units, double subtrahend) => units.Minus<XXXXXXXX>(subtrahend);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Minus(
|
||||||
|
// this XXXXXXXX?[] units, double subtrahend) => units.Minus<XXXXXXXX>(subtrahend);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX[] Minus(
|
||||||
|
// this double minuend, XXXXXXXX[] units) => minuend.Minus<XXXXXXXX>(units);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Minus(
|
||||||
|
// this double minuend, XXXXXXXX?[] units) => minuend.Minus<XXXXXXXX>(units);
|
||||||
|
|
||||||
|
// // === List<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX> Minus(
|
||||||
|
// this List<XXXXXXXX> units, double subtrahend) => units.Minus<XXXXXXXX>(subtrahend);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX?> Minus(
|
||||||
|
// this List<XXXXXXXX?> units, double subtrahend) => units.Minus<XXXXXXXX>(subtrahend);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX> Minus(
|
||||||
|
// this double minuend, List<XXXXXXXX> units) => minuend.Minus<XXXXXXXX>(units);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX?> Minus(
|
||||||
|
// this double minuend, List<XXXXXXXX?> units) => minuend.Minus<XXXXXXXX>(units);
|
||||||
|
|
||||||
|
// // === ICollection<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ICollection<XXXXXXXX> units,
|
||||||
|
// double subtrahend, Span<XXXXXXXX> destination) => units.Minus<XXXXXXXX>(subtrahend, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this ICollection<XXXXXXXX?> units,
|
||||||
|
// double subtrahend, Span<XXXXXXXX?> destination) => units.Minus<XXXXXXXX>(subtrahend, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
// ICollection<XXXXXXXX> units, Span<XXXXXXXX> destination) => minuend.Minus<XXXXXXXX>(units, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
// ICollection<XXXXXXXX?> units, Span<XXXXXXXX?> destination) => minuend.Minus<XXXXXXXX>(units, destination);
|
||||||
|
|
||||||
|
// // === IReadOnlyCollection<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Minus(this IReadOnlyCollection<XXXXXXXX> units,
|
||||||
|
// double subtrahend, Span<XXXXXXXX> destination) => units.Minus<XXXXXXXX>(subtrahend, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Minus(this IReadOnlyCollection<XXXXXXXX?> units,
|
||||||
|
// double subtrahend, Span<XXXXXXXX?> destination) => units.Minus<XXXXXXXX>(subtrahend, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
// IReadOnlyCollection<XXXXXXXX> units, Span<XXXXXXXX> destination) => minuend.Minus<XXXXXXXX>(units, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Minus(this double minuend,
|
||||||
|
// IReadOnlyCollection<XXXXXXXX?> units, Span<XXXXXXXX?> destination) => minuend.Minus<XXXXXXXX>(units, destination);
|
||||||
|
|
||||||
|
// // === IEnumerable<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX> Minus(
|
||||||
|
// this IEnumerable<XXXXXXXX> units, double subtrahend) => units.Minus<XXXXXXXX>(subtrahend);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX?> Minus(
|
||||||
|
// this IEnumerable<XXXXXXXX?> units, double subtrahend) => units.Minus<XXXXXXXX>(subtrahend);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX> Minus(
|
||||||
|
// this double minuend, IEnumerable<XXXXXXXX> units) => minuend.Minus<XXXXXXXX>(units);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX?> Minus(
|
||||||
|
// this double minuend, IEnumerable<XXXXXXXX?> units) => minuend.Minus<XXXXXXXX>(units);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// // === ReadOnlySpan
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ReadOnlySpan<XXXXXXXX> units,
|
||||||
|
// double multiplicator, Span<XXXXXXXX> destination) => units.Mul<XXXXXXXX>(multiplicator, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ReadOnlySpan<XXXXXXXX?> units,
|
||||||
|
// double multiplicator, Span<XXXXXXXX?> destination) => units.Mul<XXXXXXXX>(multiplicator, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
// ReadOnlySpan<XXXXXXXX> units, Span<XXXXXXXX> destination) => units.Mul<XXXXXXXX>(multiplicator, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
// ReadOnlySpan<XXXXXXXX?> units, Span<XXXXXXXX?> destination) => units.Mul<XXXXXXXX>(multiplicator, destination);
|
||||||
|
|
||||||
|
// // === Array ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static XXXXXXXX[] Mul(
|
||||||
|
// this XXXXXXXX[] units, double multiplicator) => units.Mul<XXXXXXXX>(multiplicator);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Mul(
|
||||||
|
// this XXXXXXXX?[] units, double multiplicator) => units.Mul<XXXXXXXX>(multiplicator);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX[] Mul(
|
||||||
|
// this double multiplicator, XXXXXXXX[] units) => units.Mul<XXXXXXXX>(multiplicator);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Mul(
|
||||||
|
// this double multiplicator, XXXXXXXX?[] units) => units.Mul<XXXXXXXX>(multiplicator);
|
||||||
|
|
||||||
|
// // === List<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX> Mul(
|
||||||
|
// this List<XXXXXXXX> units, double multiplicator) => units.Mul<XXXXXXXX>(multiplicator);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX?> Mul(
|
||||||
|
// this List<XXXXXXXX?> units, double multiplicator) => units.Mul<XXXXXXXX>(multiplicator);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX> Mul(
|
||||||
|
// this double multiplicator, List<XXXXXXXX> units) => units.Mul<XXXXXXXX>(multiplicator);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX?> Mul(
|
||||||
|
// this double multiplicator, List<XXXXXXXX?> units) => units.Mul<XXXXXXXX>(multiplicator);
|
||||||
|
|
||||||
|
// // === ICollection<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ICollection<XXXXXXXX> units,
|
||||||
|
// double multiplicator, Span<XXXXXXXX> destination) => units.Mul<XXXXXXXX>(multiplicator, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this ICollection<XXXXXXXX?> units,
|
||||||
|
// double multiplicator, Span<XXXXXXXX?> destination) => units.Mul<XXXXXXXX>(multiplicator, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
// ICollection<XXXXXXXX> units, Span<XXXXXXXX> destination) => units.Mul<XXXXXXXX>(multiplicator, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
// ICollection<XXXXXXXX?> units, Span<XXXXXXXX?> destination) => units.Mul<XXXXXXXX>(multiplicator, destination);
|
||||||
|
|
||||||
|
// // === IReadOnlyCollection<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Mul(this IReadOnlyCollection<XXXXXXXX> units,
|
||||||
|
// double multiplicator, Span<XXXXXXXX> destination) => units.Mul<XXXXXXXX>(multiplicator, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Mul(this IReadOnlyCollection<XXXXXXXX?> units,
|
||||||
|
// double multiplicator, Span<XXXXXXXX?> destination) => units.Mul<XXXXXXXX>(multiplicator, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
// IReadOnlyCollection<XXXXXXXX> units, Span<XXXXXXXX> destination) => units.Mul<XXXXXXXX>(multiplicator, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Mul(this double multiplicator,
|
||||||
|
// IReadOnlyCollection<XXXXXXXX?> units, Span<XXXXXXXX?> destination) => units.Mul<XXXXXXXX>(multiplicator, destination);
|
||||||
|
|
||||||
|
// // === IEnumerable<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX> Mul(
|
||||||
|
// this IEnumerable<XXXXXXXX> units, double multiplicator) => units.Mul<XXXXXXXX>(multiplicator);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX?> Mul(
|
||||||
|
// this IEnumerable<XXXXXXXX?> units, double multiplicator) => units.Mul<XXXXXXXX>(multiplicator);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX> Mul(
|
||||||
|
// this double multiplicator, IEnumerable<XXXXXXXX> units) => units.Mul<XXXXXXXX>(multiplicator);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX?> Mul(
|
||||||
|
// this double multiplicator, IEnumerable<XXXXXXXX?> units) => units.Mul<XXXXXXXX>(multiplicator);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// // === ReadOnlySpan
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ReadOnlySpan<XXXXXXXX> units,
|
||||||
|
// double summand, Span<XXXXXXXX> destination) => units.Plus<XXXXXXXX>(summand, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ReadOnlySpan<XXXXXXXX?> units,
|
||||||
|
// double summand, Span<XXXXXXXX?> destination) => units.Plus<XXXXXXXX>(summand, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
// ReadOnlySpan<XXXXXXXX> units, Span<XXXXXXXX> destination) => units.Plus<XXXXXXXX>(summand, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
// ReadOnlySpan<XXXXXXXX?> units, Span<XXXXXXXX?> destination) => units.Plus<XXXXXXXX>(summand, destination);
|
||||||
|
|
||||||
|
// // === Array ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static XXXXXXXX[] Plus(
|
||||||
|
// this XXXXXXXX[] units, double summand) => units.Plus<XXXXXXXX>(summand);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Plus(
|
||||||
|
// this XXXXXXXX?[] units, double summand) => units.Plus<XXXXXXXX>(summand);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX[] Plus(
|
||||||
|
// this double summand, XXXXXXXX[] units) => units.Plus<XXXXXXXX>(summand);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XXXXXXXX?[] Plus(
|
||||||
|
// this double summand, XXXXXXXX?[] units) => units.Plus<XXXXXXXX>(summand);
|
||||||
|
|
||||||
|
// // === List<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX> Plus(
|
||||||
|
// this List<XXXXXXXX> units, double summand) => units.Plus<XXXXXXXX>(summand);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX?> Plus(
|
||||||
|
// this List<XXXXXXXX?> units, double summand) => units.Plus<XXXXXXXX>(summand);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX> Plus(
|
||||||
|
// this double summand, List<XXXXXXXX> units) => units.Plus<XXXXXXXX>(summand);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<XXXXXXXX?> Plus(
|
||||||
|
// this double summand, List<XXXXXXXX?> units) => units.Plus<XXXXXXXX>(summand);
|
||||||
|
|
||||||
|
// // === ICollection<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ICollection<XXXXXXXX> units,
|
||||||
|
// double summand, Span<XXXXXXXX> destination) => units.Plus<XXXXXXXX>(summand, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this ICollection<XXXXXXXX?> units,
|
||||||
|
// double summand, Span<XXXXXXXX?> destination) => units.Plus<XXXXXXXX>(summand, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
// ICollection<XXXXXXXX> units, Span<XXXXXXXX> destination) => units.Plus<XXXXXXXX>(summand, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
// ICollection<XXXXXXXX?> units, Span<XXXXXXXX?> destination) => units.Plus<XXXXXXXX>(summand, destination);
|
||||||
|
|
||||||
|
// // === IReadOnlyCollection<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Plus(this IReadOnlyCollection<XXXXXXXX> units,
|
||||||
|
// double summand, Span<XXXXXXXX> destination) => units.Plus<XXXXXXXX>(summand, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]public static void Plus(this IReadOnlyCollection<XXXXXXXX?> units,
|
||||||
|
// double summand, Span<XXXXXXXX?> destination) => units.Plus<XXXXXXXX>(summand, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
// IReadOnlyCollection<XXXXXXXX> units, Span<XXXXXXXX> destination) => units.Plus<XXXXXXXX>(summand, destination);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Plus(this double summand,
|
||||||
|
// IReadOnlyCollection<XXXXXXXX?> units, Span<XXXXXXXX?> destination) => units.Plus<XXXXXXXX>(summand, destination);
|
||||||
|
|
||||||
|
// // === IEnumerable<T> ===
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX> Plus(
|
||||||
|
// this IEnumerable<XXXXXXXX> units, double summand) => units.Plus<XXXXXXXX>(summand);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX?> Plus(
|
||||||
|
// this IEnumerable<XXXXXXXX?> units, double summand) => units.Plus<XXXXXXXX>(summand);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX> Plus(
|
||||||
|
// this double summand, IEnumerable<XXXXXXXX> units) => units.Plus<XXXXXXXX>(summand);
|
||||||
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable<XXXXXXXX?> Plus(
|
||||||
|
// this double summand, IEnumerable<XXXXXXXX?> units) => units.Plus<XXXXXXXX>(summand);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// // Sum Average Max Min (не nullable) ==========================================
|
||||||
|
|
||||||
|
|
||||||
|
// // === ReadOnlySpan === SIMD
|
||||||
|
// public static XXXXXXXX Sum(this ReadOnlySpan<XXXXXXXX> units) => AggregateUnitExtensions.Sum(units);
|
||||||
|
// public static XXXXXXXX Average(this ReadOnlySpan<XXXXXXXX> units) => AggregateUnitExtensions.Average(units);
|
||||||
|
// public static XXXXXXXX Max(this ReadOnlySpan<XXXXXXXX> units) => AggregateUnitExtensions.Max(units);
|
||||||
|
// public static XXXXXXXX Min(this ReadOnlySpan<XXXXXXXX> units) => AggregateUnitExtensions.Min(units);
|
||||||
|
|
||||||
|
// // === List<T> ===
|
||||||
|
// public static XXXXXXXX Sum(this List<XXXXXXXX> list) => AggregateUnitExtensions.Sum(list);
|
||||||
|
// public static XXXXXXXX Average(this List<XXXXXXXX> list) => AggregateUnitExtensions.Average(list);
|
||||||
|
// public static XXXXXXXX Max(this List<XXXXXXXX> list) => AggregateUnitExtensions.Max(list);
|
||||||
|
// public static XXXXXXXX Min(this List<XXXXXXXX> list) => AggregateUnitExtensions.Min(list);
|
||||||
|
|
||||||
|
// // === ICollection<T> ===
|
||||||
|
// public static XXXXXXXX Sum(this ICollection<XXXXXXXX> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
// public static XXXXXXXX Average(this ICollection<XXXXXXXX> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
// public static XXXXXXXX Max(this ICollection<XXXXXXXX> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
// public static XXXXXXXX Min(this ICollection<XXXXXXXX> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
// // === IReadOnlyCollection<T> ===
|
||||||
|
// public static XXXXXXXX Sum(this IReadOnlyCollection<XXXXXXXX> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
// public static XXXXXXXX Average(this IReadOnlyCollection<XXXXXXXX> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
// public static XXXXXXXX Max(this IReadOnlyCollection<XXXXXXXX> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
// public static XXXXXXXX Min(this IReadOnlyCollection<XXXXXXXX> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
|
||||||
|
// // === IEnumerable<T> ===
|
||||||
|
// public static XXXXXXXX Sum(this IEnumerable<XXXXXXXX> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
// public static XXXXXXXX Average(this IEnumerable<XXXXXXXX> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
// public static XXXXXXXX Max(this IEnumerable<XXXXXXXX> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
// public static XXXXXXXX Min(this IEnumerable<XXXXXXXX> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// // Sum Average Max Min (nullable) ==========================================
|
||||||
|
|
||||||
|
|
||||||
|
// // === ReadOnlySpan ===
|
||||||
|
// public static XXXXXXXX Sum(this ReadOnlySpan<XXXXXXXX?> units) => AggregateUnitExtensions.Sum(units);
|
||||||
|
// public static XXXXXXXX Average(this ReadOnlySpan<XXXXXXXX?> units) => AggregateUnitExtensions.Average(units);
|
||||||
|
// public static XXXXXXXX Max(this ReadOnlySpan<XXXXXXXX?> units) => AggregateUnitExtensions.Max(units);
|
||||||
|
// public static XXXXXXXX Min(this ReadOnlySpan<XXXXXXXX?> units) => AggregateUnitExtensions.Min(units);
|
||||||
|
|
||||||
|
// // === List<T> ===
|
||||||
|
// public static XXXXXXXX Sum(this List<XXXXXXXX?> list) => AggregateUnitExtensions.Sum(list);
|
||||||
|
// public static XXXXXXXX Average(this List<XXXXXXXX?> list) => AggregateUnitExtensions.Average(list);
|
||||||
|
// public static XXXXXXXX Max(this List<XXXXXXXX?> list) => AggregateUnitExtensions.Max(list);
|
||||||
|
// public static XXXXXXXX Min(this List<XXXXXXXX?> list) => AggregateUnitExtensions.Min(list);
|
||||||
|
|
||||||
|
// // === ICollection<T> ===
|
||||||
|
// public static XXXXXXXX Sum(this ICollection<XXXXXXXX?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
// public static XXXXXXXX Average(this ICollection<XXXXXXXX?> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
// public static XXXXXXXX Max(this ICollection<XXXXXXXX?> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
// public static XXXXXXXX Min(this ICollection<XXXXXXXX?> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
// // === IReadOnlyCollection<T> ===
|
||||||
|
// public static XXXXXXXX Sum(this IReadOnlyCollection<XXXXXXXX?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
// public static XXXXXXXX Average(this IReadOnlyCollection<XXXXXXXX?> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
// public static XXXXXXXX Max(this IReadOnlyCollection<XXXXXXXX?> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
// public static XXXXXXXX Min(this IReadOnlyCollection<XXXXXXXX?> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
|
||||||
|
// // === IEnumerable<T> ===
|
||||||
|
// public static XXXXXXXX Sum(this IEnumerable<XXXXXXXX?> collection) => AggregateUnitExtensions.Sum(collection);
|
||||||
|
// public static XXXXXXXX Average(this IEnumerable<XXXXXXXX?> collection) => AggregateUnitExtensions.Average(collection);
|
||||||
|
// public static XXXXXXXX Max(this IEnumerable<XXXXXXXX?> collection) => AggregateUnitExtensions.Max(collection);
|
||||||
|
// public static XXXXXXXX Min(this IEnumerable<XXXXXXXX?> collection) => AggregateUnitExtensions.Min(collection);
|
||||||
|
//}
|
||||||
@@ -1,74 +1,70 @@
|
|||||||
#if DEBUG
|
//#if DEBUG
|
||||||
namespace QWERTYkez.Mensura.Units;
|
//namespace QWERTYkez.Mensura.Units;
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// Base value is MilliMeters
|
///// Base value is MilliMeters
|
||||||
/// </summary>
|
///// </summary>
|
||||||
[DebuggerDisplay("mm = {_MilliMeters.ToString(\"0.###\")}, m = {Meters.ToString(\"0.###\")}")]
|
//[DebuggerDisplay("mm = {_MilliMeters.ToString(\"0.###\")}, m = {Meters.ToString(\"0.###\")}")]
|
||||||
public readonly partial record struct XXXXXXXXXXXXXX
|
//public readonly partial record struct XXXXXXXX
|
||||||
{
|
//{
|
||||||
public static XXXXXXXXXXXXXX MilliMeter { get; } = new(1);
|
// public static XXXXXXXX MilliMeter { get; } = new(1);
|
||||||
[NotMapped, JsonIgnore, IgnoreDataMember] public double _MilliMeters { get => _Value; init => _Value = value; }
|
// [NotMapped, JsonIgnore, IgnoreDataMember] public double _MilliMeters { get => _Value; init => _Value = value; }
|
||||||
|
|
||||||
|
|
||||||
public static XXXXXXXXXXXXXX CentiMeter { get; } = new(XXXXXXXXXXXXXXConv.CentiMeters.To(1));
|
// public static XXXXXXXX CentiMeter { get; } = new(XXXXXXXXConv.CentiMeters.To(1));
|
||||||
[NotMapped, JsonIgnore, IgnoreDataMember] public double CentiMeters
|
// [NotMapped, JsonIgnore, IgnoreDataMember]
|
||||||
{
|
// public double CentiMeters
|
||||||
get => XXXXXXXXXXXXXXConv.CentiMeters.From(_Value);
|
// {
|
||||||
init
|
// get => XXXXXXXXConv.CentiMeters.From(_Value);
|
||||||
{
|
// init
|
||||||
XXXXXXXXXXXXXX aaa = new();
|
// {
|
||||||
XXXXXXXXXXXXXX bbb = new();
|
// _Value = XXXXXXXXConv.CentiMeters.To(value);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if (aaa != bbb || aaa == bbb)
|
// 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);
|
||||||
|
// }
|
||||||
|
|
||||||
_Value = XXXXXXXXXXXXXXConv.CentiMeters.To(value);
|
// public static XXXXXXXX KiloMeter { get; } = new(XXXXXXXXConv.KiloMeters.To(1));
|
||||||
}
|
// [NotMapped, JsonIgnore, IgnoreDataMember]
|
||||||
}
|
// public double KiloMeters
|
||||||
|
// {
|
||||||
public static XXXXXXXXXXXXXX DeciMeter { get; } = new(XXXXXXXXXXXXXXConv.DeciMeters.To(1));
|
// get => XXXXXXXXConv.KiloMeters.From(_Value);
|
||||||
[NotMapped, JsonIgnore, IgnoreDataMember] public double DeciMeters
|
// init => _Value = XXXXXXXXConv.KiloMeters.To(value);
|
||||||
{
|
// }
|
||||||
get => XXXXXXXXXXXXXXConv.DeciMeters.From(_Value);
|
|
||||||
init => _Value = XXXXXXXXXXXXXXConv.DeciMeters.To(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static XXXXXXXXXXXXXX Meter { get; } = new(XXXXXXXXXXXXXXConv.Meters.To(1));
|
|
||||||
[NotMapped, JsonIgnore, IgnoreDataMember] public double Meters
|
|
||||||
{
|
|
||||||
get => XXXXXXXXXXXXXXConv.Meters.From(_Value);
|
|
||||||
init => _Value = XXXXXXXXXXXXXXConv.Meters.To(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static XXXXXXXXXXXXXX KiloMeter { get; } = new(XXXXXXXXXXXXXXConv.KiloMeters.To(1));
|
|
||||||
[NotMapped, JsonIgnore, IgnoreDataMember] public double KiloMeters
|
|
||||||
{
|
|
||||||
get => XXXXXXXXXXXXXXConv.KiloMeters.From(_Value);
|
|
||||||
init => _Value = XXXXXXXXXXXXXXConv.KiloMeters.To(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public XXXXXXXXXXXXXX AddMilliMeters(double value) => new(_Value + value);
|
// public XXXXXXXX AddMilliMeters(double value) => new(_Value + value);
|
||||||
public XXXXXXXXXXXXXX AddCentiMeters(double value) => new(_Value + XXXXXXXXXXXXXXConv.CentiMeters.To(value));
|
// public XXXXXXXX AddCentiMeters(double value) => new(_Value + XXXXXXXXConv.CentiMeters.To(value));
|
||||||
public XXXXXXXXXXXXXX AddDeciMeters(double value) => new(_Value + XXXXXXXXXXXXXXConv.DeciMeters.To(value));
|
// public XXXXXXXX AddDeciMeters(double value) => new(_Value + XXXXXXXXConv.DeciMeters.To(value));
|
||||||
public XXXXXXXXXXXXXX AddMeters(double value) => new(_Value + XXXXXXXXXXXXXXConv.Meters.To(value));
|
// public XXXXXXXX AddMeters(double value) => new(_Value + XXXXXXXXConv.Meters.To(value));
|
||||||
public XXXXXXXXXXXXXX AddKiloMeters(double value) => new(_Value + XXXXXXXXXXXXXXConv.KiloMeters.To(value));
|
// public XXXXXXXX AddKiloMeters(double value) => new(_Value + XXXXXXXXConv.KiloMeters.To(value));
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
internal readonly struct XXXXXXXXXXXXXXConv
|
//internal readonly struct XXXXXXXXConv
|
||||||
{
|
//{
|
||||||
private XXXXXXXXXXXXXXConv(double multiplicator) => this.Multiplicator = multiplicator;
|
// private XXXXXXXXConv(double multiplicator) => this.Multiplicator = multiplicator;
|
||||||
public double To(double value) => value * Multiplicator;
|
// public double To(double value) => value * Multiplicator;
|
||||||
public double From(double value) => value / Multiplicator;
|
// public double From(double value) => value / Multiplicator;
|
||||||
public double Multiplicator { get; init; }
|
// public double Multiplicator { get; init; }
|
||||||
public static XXXXXXXXXXXXXXConv MilliMeters { get; } = new(1);
|
// public static XXXXXXXXConv MilliMeters { get; } = new(1);
|
||||||
public static XXXXXXXXXXXXXXConv CentiMeters { get; } = new(10);
|
// public static XXXXXXXXConv CentiMeters { get; } = new(10);
|
||||||
public static XXXXXXXXXXXXXXConv DeciMeters { get; } = new(100);
|
// public static XXXXXXXXConv DeciMeters { get; } = new(100);
|
||||||
public static XXXXXXXXXXXXXXConv Meters { get; } = new(1000);
|
// public static XXXXXXXXConv Meters { get; } = new(1000);
|
||||||
public static XXXXXXXXXXXXXXConv KiloMeters { get; } = new(1000000);
|
// public static XXXXXXXXConv KiloMeters { get; } = new(1000000);
|
||||||
}
|
//}
|
||||||
#endif
|
//#endif
|
||||||
Reference in New Issue
Block a user