![]() |
VOOZH | about |
dotnet add package NeinMath --version 1.5.1
NuGet\Install-Package NeinMath -Version 1.5.1
<PackageReference Include="NeinMath" Version="1.5.1" />
<PackageVersion Include="NeinMath" Version="1.5.1" />Directory.Packages.props
<PackageReference Include="NeinMath" />Project file
paket add NeinMath --version 1.5.1
#r "nuget: NeinMath, 1.5.1"
#:package NeinMath@1.5.1
#addin nuget:?package=NeinMath&version=1.5.1Install as a Cake Addin
#tool nuget:?package=NeinMath&version=1.5.1Install as a Cake Tool
👁 Latest package
👁 Download tracker
👁 GitHub status
👁 Code coverage
NeinMath is playing around with arbitrary precision integers, written in pure managed code, not using any unsafe stuff, and a bit faster than the build-in .NET type for integers with a few thousand bits.
To install NeinMath, run the following command in the NuGet Package Manager Console.
PM> Install-Package NeinMath
It's generally based on the integer implementation of this work, but rewritten to not use pointer arithmetic and other fancy things. Thus, it's a bit slower albeit portable.
Note: starting with the new .NET Core this project becomes a bit obsolete, because the performance gains disappear since some improvements have been contributed. 🎉
Let's start with a simple comparison (time per 100 operations).
| Operation | Length (bits) | BigInteger (.NET) | Integer (NeinMath) |
|---|---|---|---|
| log | 4,194,304 | 1306 ms | 0 ms |
| add (+) | 4,194,304 | 40 ms | 17 ms |
| sub (-) | 4,194,304 | 43 ms | 18 ms |
| mul (*) | 65,536 | 980 ms | 116 ms |
| squ (^2) | 65,536 | 980 ms | 82 ms |
| div (/) | 65,536 | 555 ms | 231 ms |
| mod (%) | 65,536 | 555 ms | 231 ms |
| gcd | 65,536 | 730 ms | 532 ms |
| modinv | 65,536 | N/A | 1,412 ms |
| modpow | 16,384 | 5,124,600 ms | 652,900 ms |
Note: ensure you're running a 64-bit process. Handling this with just 32-bits is a huge impediment for both, BigInteger and Integer.
Note: these results are from "my machine". A basic (very basic) benchmark utility is included to verify / disprove them.
Like BigInteger a structure Integer provides all the operators you would expect from an integer, so it should be quite compatible to existing .NET code. In fact, there are tests based on BigInteger to ensure it computes correctly most of the time.
To get an idea, this is an example for calculating the Greatest Common Divisor:
Integer Gcd(Integer left, Integer right)
{
var a = left.Abs();
var b = right.Abs();
while (b != 0)
{
var c = a % b;
a = b;
b = c;
}
return a;
}
Note: calling left.Gcd(right) is much faster, since the internal implementation is based on a more sophisticated algorithm.
Coming sometime... maybe... who knows?
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net40 net40 is compatible. net403 net403 was computed. net45 net45 was computed. net451 net451 was computed. net452 net452 was computed. net46 net46 was computed. net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 1 NuGet packages that depend on NeinMath:
| Package | Downloads |
|---|---|
|
PoseidonSharp
This is a Poseidon Hashing Library built for use with Loopring |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.5.1 | 1,596 | 1/7/2023 |
| 1.5.0 | 504 | 11/11/2022 |
| 1.4.0 | 635 | 11/8/2021 |
| 1.3.1 | 1,156 | 2/15/2019 |
| 1.3.0 | 1,285 | 9/12/2018 |
| 1.2.0 | 1,647 | 6/28/2018 |
| 1.1.1 | 1,718 | 1/4/2018 |
| 1.1.0 | 1,583 | 6/11/2017 |
| 1.0.1 | 2,392 | 6/28/2016 |
| 1.0.0 | 1,755 | 5/19/2016 |
| 0.2.5 | 1,984 | 12/6/2015 |
| 0.2.4 | 1,869 | 11/21/2015 |
| 0.2.3 | 1,847 | 9/13/2015 |
| 0.2.2 | 1,765 | 8/16/2015 |
| 0.2.1 | 1,692 | 4/11/2015 |
| 0.2.0 | 1,606 | 4/7/2015 |
| 0.1.1 | 1,640 | 4/1/2015 |
| 0.1.0 | 1,652 | 3/27/2015 |
Added current README.md to package contents.