Mpir.NET
Mpir.NET lets you use the MPIR library, which is a GMP fork for Windows, from .NET languages.
The current version incorporates 32- and 64-bit builds of MPIR 2.7.2.
PM> Install-Package Mpir.NET
F# Example
The type representing MPIR integers is mpz_t. In F#, you can write literals suffixed with Z, to create mpz_t objects, as in this simple example:
1: 2: 3: 4: 5: 6: |
open Mpir.NET let a = 756749075976907490175905790287846502134Z let b = 529134916478965674697197076070175107505Z let c = a*b printfn "%O" c |
C# Example
A short C# example:
using Mpir.NET;
class MpirSample
{
static void MpirCalcs()
{
mpz_t a = new mpz_t(12345678901234567890);
mpz_t b = new mpz_t(9876543210987654321);
mpz_t c = a * b;
System.Console.WriteLine("{0}", c);
}
}
Basics
As mentioned before, mpz_t is the class that represents MPIR integers. If you need to use any MPIR function that doesn't have a corresponding mpz_t method, it can be found in the static mpir class, where the original MPIR/GMP function names are preserved. For example, call mpz_addmul like so:
1:
|
mpir.mpz_addmul(c, a, b); |
Supported CPUs
Mpir.NET includes an MPIR 32-bit build for Pentium 3 (p3 target in MPIR), and a 64-bit build for K8. In other words, Mpir.NET runs on Pentiums and later x86 32-bit CPUs, and all x64 64-bit CPUs. It will not run on pre-Pentium 3 PCs (which would be from 1999 or earlier) or weird stuff like Itaniums.
Origins
Mpir.NET is basically a fusion of modified versions of X-MPIR by Sergey Bochkanov and "GMP for .NET" by Emil Stefanov.
Copyright
Mpir.NET library is licensed under LGPL, because that's the license used by the libraries that Mpir.NET is derived from. For more information see the License file in the GitHub repository.
Full name: Index.a
Full name: Index.b
Full name: Index.c
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
static member GetOSString : unit -> string
static member GetXMPIRLibraryPath : unit -> string
static member LocateLibrary : name:string -> string
static member Max : a:mpz_t * b:mpz_t -> mpz_t
static member Min : a:mpz_t * b:mpz_t -> mpz_t
static member Mpir_mpz_export : order:int * size:uint32 * endian:int * nails:uint32 * op:mpz_t -> byte[]
static member Mpir_mpz_import : rop:mpz_t * count:uint32 * order:int * size:uint32 * endian:int * nails:uint32 * op:byte[] -> unit
static member Mpir_mpz_import_by_offset : rop:mpz_t * startOffset:int * endOffset:int * order:int * size:uint32 * endian:int * nails:uint32 * op:byte[] -> unit
static member gmp_randclear : v:gmp_randstate_t -> unit
static member gmp_randinit_default : unit -> nativeint
...
Full name: Mpir.NET.mpir