equadrat.Framework.Math.Interfaces 8.3.6

Prefix Reserved
dotnet add package equadrat.Framework.Math.Interfaces --version 8.3.6
                    
NuGet\Install-Package equadrat.Framework.Math.Interfaces -Version 8.3.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="equadrat.Framework.Math.Interfaces" Version="8.3.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="equadrat.Framework.Math.Interfaces" Version="8.3.6" />
                    
Directory.Packages.props
<PackageReference Include="equadrat.Framework.Math.Interfaces" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add equadrat.Framework.Math.Interfaces --version 8.3.6
                    
#r "nuget: equadrat.Framework.Math.Interfaces, 8.3.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package equadrat.Framework.Math.Interfaces@8.3.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=equadrat.Framework.Math.Interfaces&version=8.3.6
                    
Install as a Cake Addin
#tool nuget:?package=equadrat.Framework.Math.Interfaces&version=8.3.6
                    
Install as a Cake Tool

equadrat Framework Math

The idea of the equadrat Framework is to provide APIs to build applications with an architecture of highly decoupled components. Every single component, aspect or pattern is represented by interfaces. The framework provides a standard implementation for these but each type can be replaced by a custom implementation.

The framework is not about reimplementing components, but making them available using common interfaces.

Getting started

You can use most of the components by simply instantiating them. This is maybe the easiest way to evaluate the framework.

If you're using an IOC/DI container such as Microsoft Extensions DependencyInjection or if you want to use the built-in IOC framework, you can use the bootstrapper and bootstrapper modules to register the framework to the IOC.

Usage

Register to IOC/DI container

public static void Main(string[] args)
{
    var builder = Host.CreateApplicationBuilder(args);

    // Use the module registry to register bootstrapper modules. Usually each assembly has its own bootstrapper module.
    // This will add their service declarations to the IServiceCollection.
    // This requires equadrat.Framework.Core.Microsoft.Extensions.Hosting NuGet package.
    builder.Services.RegisterBootstrapperModules(moduleRegistry => moduleRegistry.MathFramework().RegisterBaseModule());

    // Declare other services as usual.
    // builder.Services.AddSingleton<...>(...);

    var app = builder.Build();

    // Optional: initialize all services declared by the registered bootstrapper modules. Calling this method is required for all environments which doesn't support IHostedService, such es browsers/webassembly.
    app.Services.InitBootstrapperModules();

    app.Run();
}

IMathValueOperator<TValue>

IServiceProvider serviceProvider = ...;

var valueOperatorProvider = serviceProvider.GetRequiredService<IMathValueOperatorProvider>();
var decimalValueOperator = valueOperatorProvider.GetOperator<decimal>();
var doubleValueOperator = valueOperatorProvider.GetOperator<double>();
var intValueOperator = valueOperatorProvider.GetOperator<int>();
var enumValueOperator = valueOperatorProvider.GetOperator<eMathScalePrefix>();

// Get the GCD - greatest common divisor.
Assert.IsTrue(decimalValueOperator.TryGetDenominator(new[] { 512m, 40m, 64m }, out var denominator));
Assert.AreEqual(8m, denominator);

// Get the scale of a value.
Assert.AreEqual(4, doubleValueOperator.Scale(3.1415d));

// Gets the quotient and remainder of a division.
var (quotient, remainder) = intValueOperator.DivRem(87, 9);
Assert.AreEqual(9, quotient);
Assert.AreEqual(6, remainder);

// Use same math for enums.
Assert.AreEqual(eMathScalePrefix.Mega, enumValueOperator.Multiply(eMathScalePrefix.Kilo, eMathScalePrefix.Hecto)); // Kilo = 3, Hecto = 2, Mega = 6.

IMathItemsCombinator<TItem>

IServiceProvider serviceProvider = ...;

var itemsCombinator = serviceProvider.GetRequiredService<IMathItemsCombinator<char>>();

// Get all combinations of a specified list of items.
var actualItemCombinations = string.Join(", ", itemsCombinator.GetCombinations(['A', 'B', 'C']).Select(static x => string.Concat(x)));
var expectedItemCombinations = "ABC, AB, AC, BC, A, B, C";
Assert.AreEqual(actualItemCombinations, expectedItemCombinations);

// Get all combinations (and the remainder) of a specified list of items.
actualItemCombinations = string.Join(", ", itemsCombinator.GetCombinationsWithRemainder(['A', 'B', 'C']).Select(x => $"{string.Concat(x.Combination)}|{string.Concat(x.Remainder)}"));
expectedItemCombinations = "ABC|, AB|C, AC|B, BC|A, A|BC, B|AC, C|AB";
Assert.AreEqual(actualItemCombinations, expectedItemCombinations);

Have a look at the example applications on equadrat.net and in the wiki.

Compatibility

The plan is to keep the equadrat Framework compatible to these .net versions as long as possible.

.net version min max automated tests*
Core 3.1 ≥ 10.x yes
Standard 2.0 ≥ 2.1 no
Framework 4.6.2 ≥ 4.8.x no

*The automated tests run under Linux for .net Core 6.x and above.

Version scheme and breaking changes

Version change Scope
Major Overhaul of the project
Minor Some types have changed
Revision Fully backward compatible
Build Set in preview versions only

Additional documentation

You can find some guides regarding specific features on my website: www.equadrat.net

Feedback

You can contact me on my website: www.equadrat.net

License

Please respect the license and check equadrat.Framework.Math.License.md before using the package.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (9)

Showing the top 5 NuGet packages that depend on equadrat.Framework.Math.Interfaces:

Package Downloads
equadrat.Framework.Math.Uom.Interfaces

A framework to extend the Microsoft .net framework with extra math functionality.

equadrat.Framework.Math

A framework to extend the Microsoft .net framework with extra math functionality.

equadrat.Framework.Math.Uom.Ucum.Interfaces

A framework to extend the Microsoft .net framework with extra math functionality.

equadrat.Framework.Math.Uom

A framework to extend the Microsoft .net framework with extra math functionality.

equadrat.Framework.Math.Uom.Units.Interfaces

A framework to extend the Microsoft .net framework with extra math functionality.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.3.6 87 9/9/2026
8.3.5 87 9/8/2026

# Release notes
## v8.3.6
- Adjusted code to work with limitations of Microsoft Dependency Injection.
- Adjusted behaviors of UOM operators when one or both members are empty.
## v8.3.5
- Initial Release