diff --git a/Documentation/Content/VersionHistory/VersionHistory.aml b/Documentation/Content/VersionHistory/VersionHistory.aml new file mode 100644 index 0000000..7695fa4 --- /dev/null +++ b/Documentation/Content/VersionHistory/VersionHistory.aml @@ -0,0 +1,33 @@ + + + + + The topics in this section describe the various changes made to the [TODO: Project Title] over the +life of the project. + + +
+ Version History + + Select a version below to see a description of its changes. + + + + + + + + [TODO: Add links to each specific version page] + + + + + +
+ + + + + +
+
diff --git a/Documentation/Content/VersionHistory/v1.0.0.0.aml b/Documentation/Content/VersionHistory/v1.0.0.0.aml new file mode 100644 index 0000000..16bc041 --- /dev/null +++ b/Documentation/Content/VersionHistory/v1.0.0.0.aml @@ -0,0 +1,28 @@ + + + + + Version [TODO: Version] was released on [TODO: Date]. + + + +
+ Changes in This Release + + + + + [TODO: Add change items here] + + + + + +
+ + + + + +
+
diff --git a/Documentation/Content/Welcome.aml b/Documentation/Content/Welcome.aml new file mode 100644 index 0000000..e3aff22 --- /dev/null +++ b/Documentation/Content/Welcome.aml @@ -0,0 +1,69 @@ + + + + + + + The GMP Native Interface for .NET Library exposes to .NET (through P-Invoke and .NET types) + all of the functionality of the + + GNU MP Library + https://gmplib.org/ + + (version 6.1.2). It automatically loads at runtime the 32-bit or 64-bit GNU MP library that matches the current CPU + architecture, thus allowing building Visual Studio Projects for AnyCPU, x86, or x64. + It is based on the GNU MP "fat" build which automatically detects the current CPU type, and selects any available + assembly language code optimization for that CPU, thus providing optimal performance. + + + + + + C Standard + http://en.cppreference.com/w/c/numeric/math + + functions that are missing from the .NET framework. + Functions include among others: + + Both double and single precision functions are implemented. + All functions are static and their names follow the + + C Standard + http://en.cppreference.com/w/c/numeric/math + . + + + All functions have been thoroughly tested using a large set of unit tests that cover all + limit cases to guarantee that all functions behave as specified by the C standard. + + + + + + + + + + + + C Standard + http://en.cppreference.com/w/c/numeric/math + _self + + + C.math.NET on GitHub + https://github.com/MachineCognitis/C.math.NET + _self + + + + + diff --git a/Documentation/ContentLayout.content b/Documentation/ContentLayout.content new file mode 100644 index 0000000..af03743 --- /dev/null +++ b/Documentation/ContentLayout.content @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Documentation/Documentation.shfbproj b/Documentation/Documentation.shfbproj new file mode 100644 index 0000000..a66d98b --- /dev/null +++ b/Documentation/Documentation.shfbproj @@ -0,0 +1,130 @@ + + + + + $(MSBuildThisFileDirectory)..\packages\EWSoftware.SHFB.2016.9.17.0\Tools\ + + Debug + AnyCPU + 2.0 + ce631e64-52bf-4527-99ad-1eaeb76550a8 + 2015.6.5.0 + + Documentation + Documentation + Documentation + + .NET Framework 2.0 + ..\docs\ + Gmp.Native + en-US + + + + + + + + + + + + + + + + + 100 + OnlyWarningsAndErrors + HtmlHelp1, Website + False + True + False + True + + + + False + 1.0.0.0 + 2 + False + Standard + Blank + False + VS2013 + False + Guid + GMP Native Interface for .NET + AboveNamespaces + + ..\packages\EWSoftware.SHFB.NETFramework.4.6.2\ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + facebook + facebook + + + google + google + + + linkedin + linkedin + + + mail + mail + + + twitter + twitter + + + + + + + + + + + OnBuildSuccess + + \ No newline at end of file diff --git a/Documentation/icons/Help.png b/Documentation/icons/Help.png new file mode 100644 index 0000000..945e89f Binary files /dev/null and b/Documentation/icons/Help.png differ diff --git a/Documentation/icons/facebook.png b/Documentation/icons/facebook.png new file mode 100644 index 0000000..2728f61 Binary files /dev/null and b/Documentation/icons/facebook.png differ diff --git a/Documentation/icons/google.png b/Documentation/icons/google.png new file mode 100644 index 0000000..42f4f7e Binary files /dev/null and b/Documentation/icons/google.png differ diff --git a/Documentation/icons/linkedin.png b/Documentation/icons/linkedin.png new file mode 100644 index 0000000..7cf3a0b Binary files /dev/null and b/Documentation/icons/linkedin.png differ diff --git a/Documentation/icons/mail.png b/Documentation/icons/mail.png new file mode 100644 index 0000000..ce7c980 Binary files /dev/null and b/Documentation/icons/mail.png differ diff --git a/Documentation/icons/twitter.png b/Documentation/icons/twitter.png new file mode 100644 index 0000000..b1394ec Binary files /dev/null and b/Documentation/icons/twitter.png differ diff --git a/GMP Sizes.xlsx b/GMP Sizes.xlsx new file mode 100644 index 0000000..9e0c7eb Binary files /dev/null and b/GMP Sizes.xlsx differ diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..e81da79 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2017 Robert Baron, Machine Cognitis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/Math.Gmp.Native.UnitTests/Math.Gmp.Native.UnitTests.csproj b/Math.Gmp.Native.UnitTests/Math.Gmp.Native.UnitTests.csproj new file mode 100644 index 0000000..cfd0fe8 --- /dev/null +++ b/Math.Gmp.Native.UnitTests/Math.Gmp.Native.UnitTests.csproj @@ -0,0 +1,107 @@ + + + + Debug + AnyCPU + {8E987EBD-1611-488C-BC4D-639074C88CB1} + Library + Properties + Math.Gmp.Native.UnitTests + Math.Gmp.Native.UnitTests + v4.5.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + + + + + + + + + + + + + + + + + + + + + + + {145d16a4-b3b6-49c6-b0dd-e4e0a2a00e4a} + Math.Gmp.Native + + + + + + + False + + + False + + + False + + + False + + + + + + + + \ No newline at end of file diff --git a/Math.Gmp.Native.UnitTests/Properties/AssemblyInfo.cs b/Math.Gmp.Native.UnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d3eda92 --- /dev/null +++ b/Math.Gmp.Native.UnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Math.Native.Gmp.UnitTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Math.Native.Gmp.UnitTests")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8e987ebd-1611-488c-bc4d-639074c88cb1")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Math.Gmp.Native.UnitTests/UnitTest.cs b/Math.Gmp.Native.UnitTests/UnitTest.cs new file mode 100644 index 0000000..fa8a8ad --- /dev/null +++ b/Math.Gmp.Native.UnitTests/UnitTest.cs @@ -0,0 +1,9071 @@ + +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Runtime.InteropServices; +using Math.Gmp.Native; +using System.Linq; +using System.Text; + +namespace UnitTests +{ + [TestClass] + public class UnitTest + { + + #region "Utility functions." + + private delegate TResult _Func(); + + private string Test(_Func func) + { + object result = null; + try + { + result = func(); + } + catch (System.Exception ex) + { + return ex.GetType().Name; + } + return result.ToString(); + } + + #endregion + + #region "Types." + + [TestMethod] + public void char_ptr_test() + { + // Create new string in unmanaged memory. + char_ptr s = new char_ptr("Test"); + Assert.IsTrue(s.ToString() == "Test"); + + // Set string pointer to zero. + s = char_ptr.Zero; + Assert.IsTrue(s.ToIntPtr() == IntPtr.Zero); + + // Assert that obj and s are the same pointer. + object obj = s; + Assert.IsTrue(s.Equals(obj) == true); + + // Create new unmanaged string. + char_ptr t = new char_ptr("Test"); + + // Assert that s and t are distinct string pointers. + Assert.IsTrue(s.Equals(t) == false); + + // Check inequality and equality of s and t pointers. + Assert.IsTrue(s != t); + gmp_lib.free(t); + t = s; + Assert.IsTrue(s == t); + gmp_lib.free(t); + } + + [TestMethod] + public void gmp_randstate_t_test() + { + // Allocate and release random number generator state. + gmp_randstate_t state = new gmp_randstate_t(); + gmp_lib.free(state); + } + + [TestMethod] + public void mp_bitcnt_t_test() + { + mp_bitcnt_t v; + + byte zero = 0; + sbyte minusOne = -1; + + // Check implicit and explict conversions to mp_bitcnt_t. + v = (byte)zero; + v = (mp_bitcnt_t)(sbyte)zero; + v = (ushort)zero; + v = (mp_bitcnt_t)(short)zero; + v = (uint)zero; + v = (mp_bitcnt_t)(int)zero; + v = (mp_bitcnt_t)(ulong)zero; + v = (mp_bitcnt_t)(long)zero; + + // Check implicit and explict conversions from mp_bitcnt_t. + byte b = (byte)v; + sbyte sb = (sbyte)v; + ushort us = (ushort)v; + short s = (short)v; + uint ui = v; + int i = (int)v; + ulong ul = v; + long l = v; + + // Check OverflowException cases. + Assert.IsTrue(Test(() => v = (mp_bitcnt_t)(sbyte)minusOne) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => v = (mp_bitcnt_t)(short)minusOne) == typeof(OverflowException).Name); + //Assert.IsTrue(Test(() => v = (mp_bitcnt_t)(int)minusOne) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => v = (mp_bitcnt_t)(long)minusOne) == typeof(OverflowException).Name); + + Assert.IsTrue(Test(() => v = (mp_bitcnt_t)ulong.MaxValue) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => v = (mp_bitcnt_t)long.MaxValue) == typeof(OverflowException).Name); + + Assert.IsTrue(Test(() => b = (byte)(new mp_bitcnt_t(uint.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => sb = (sbyte)(new mp_bitcnt_t(uint.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => us = (ushort)(new mp_bitcnt_t(uint.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => s = (short)(new mp_bitcnt_t(uint.MaxValue))) == typeof(OverflowException).Name); + //Assert.IsTrue(Test(() => i = (int)(new mp_bitcnt_t(uint.MaxValue))) == typeof(OverflowException).Name); + + // Check equality and inequality. + Object obj = new mp_bitcnt_t(8); + Assert.IsTrue((new mp_bitcnt_t(8)).Equals(obj)); + Assert.IsTrue(!(new mp_bitcnt_t(8)).Equals(new int())); + Assert.IsTrue((new mp_bitcnt_t(8)).Equals(new mp_bitcnt_t(8))); + Assert.IsTrue(!(new mp_bitcnt_t(8)).Equals(new mp_bitcnt_t(9))); + Assert.IsTrue((new mp_bitcnt_t(8)) == (new mp_bitcnt_t(8))); + Assert.IsTrue((new mp_bitcnt_t(8)) != (new mp_bitcnt_t(9))); + } + + //[TestMethod] + //public void mp_exp_ptr_test() + //{ + // // Create new exponent pointer. + // mp_exp_ptr i = new mp_exp_ptr(8); + + // // Assert that obj and i are the same pointer. + // object obj = i; + // Assert.IsTrue(i.Equals(obj) == true); + + // // Create new exponent pointer. + // mp_exp_ptr j = new mp_exp_ptr(8); + + // // Assert that i and j are distinct exponent pointers. + // Assert.IsTrue(i.Equals(j) == false); + + // // Check equality of i and j values. + // Assert.IsTrue(i.Value == j.Value); + // i.Value += 4; + // Assert.IsTrue(i.Value != j.Value); + + // // Check inequality and equality of i and j pointers. + // Assert.IsTrue(i != j); + // gmp_lib.free(j); + // j = i; + // Assert.IsTrue(i == j); + + // // Check equality of i and j values. + // Assert.IsTrue(i.Value == j.Value); + // i.Value += 4; + // Assert.IsTrue(i.Value == j.Value); + + // gmp_lib.free(j); + //} + + [TestMethod] + public void mp_exp_t_test() + { + mp_exp_t v; + + byte zero = 0; + + // Check implicit and explict conversions to mp_exp_t. + v = (byte)zero; + v = (sbyte)zero; + v = (ushort)zero; + v = (short)zero; + v = (mp_exp_t)(uint)zero; + v = (int)zero; + v = (mp_exp_t)(ulong)zero; + v = (mp_exp_t)(long)zero; + + // Check implicit and explict conversions from mp_exp_t. + byte b = (byte)v; + sbyte sb = (sbyte)v; + ushort us = (ushort)v; + short s = (short)v; + uint ui = (uint)v; + int i = v; + ulong ul = (ulong)v; + long l = v; + + // Check OverflowException cases. + Assert.IsTrue(Test(() => v = (mp_exp_t)uint.MaxValue) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => v = (mp_exp_t)long.MaxValue) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => v = (mp_exp_t)ulong.MaxValue) == typeof(OverflowException).Name); + + Assert.IsTrue(Test(() => b = (byte)(new mp_exp_t(int.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => sb = (sbyte)(new mp_exp_t(int.MinValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => sb = (sbyte)(new mp_exp_t(int.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => us = (ushort)(new mp_exp_t(int.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => s = (short)(new mp_exp_t(int.MinValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => s = (short)(new mp_exp_t(int.MaxValue))) == typeof(OverflowException).Name); + + // Check equality and inequality. + Object obj = new mp_exp_t(8); + Assert.IsTrue((new mp_exp_t(8)).Equals(obj)); + Assert.IsTrue(!(new mp_exp_t(8)).Equals(new byte())); + Assert.IsTrue((new mp_exp_t(8)).Equals(new mp_exp_t(8))); + Assert.IsTrue(!(new mp_exp_t(8)).Equals(new mp_exp_t(9))); + Assert.IsTrue((new mp_exp_t(8)) == (new mp_exp_t(8))); + Assert.IsTrue((new mp_exp_t(8)) != (new mp_exp_t(9))); + } + + [TestMethod] + public void mp_limb_t_test() + { + mp_limb_t v; + + byte zero = 0; + sbyte minusOne = -1; + + // Check implicit and explict conversions to mp_limb_t. + v = (byte)zero; + v = (mp_limb_t)(sbyte)zero; + v = (ushort)zero; + v = (mp_limb_t)(short)zero; + v = (uint)zero; + v = (mp_limb_t)(int)zero; + v = (ulong)zero; + v = (mp_limb_t)(long)zero; + + // Check implicit and explict conversions from mp_limb_t. + byte b = (byte)v; + sbyte sb = (sbyte)v; + ushort us = (ushort)v; + short s = (short)v; + uint ui = (uint)v; + int i = (int)v; + ulong ul = v; + long l = (long)v; + + // Check OverflowException cases. + Assert.IsTrue(Test(() => v = (mp_limb_t)(sbyte)minusOne) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => v = (mp_limb_t)(short)minusOne) == typeof(OverflowException).Name); + //Assert.IsTrue(Test(() => v = (mp_limb_t)(int)minusOne) == typeof(OverflowException).Name); + //Assert.IsTrue(Test(() => v = (mp_limb_t)(long)minusOne) == typeof(OverflowException).Name); + + Assert.IsTrue(Test(() => b = (byte)(new mp_limb_t(ulong.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => sb = (sbyte)(new mp_limb_t(ulong.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => us = (ushort)(new mp_limb_t(ulong.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => s = (short)(new mp_limb_t(ulong.MaxValue))) == typeof(OverflowException).Name); + //Assert.IsTrue(Test(() => i = (int)(new mp_limb_t(ulong.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => ui = (uint)(new mp_limb_t(ulong.MaxValue))) == typeof(OverflowException).Name); + //Assert.IsTrue(Test(() => l = (long)(new mp_limb_t(ulong.MaxValue))) == typeof(OverflowException).Name); + + // Check equality and inequality. + Object obj = new mp_limb_t(8); + Assert.IsTrue((new mp_limb_t(8)).Equals(obj)); + Assert.IsTrue(!(new mp_limb_t(8)).Equals(new byte())); + Assert.IsTrue((new mp_limb_t(8)).Equals(new mp_limb_t(8))); + Assert.IsTrue(!(new mp_limb_t(8)).Equals(new mp_limb_t(9))); + Assert.IsTrue((new mp_limb_t(8)) == (new mp_limb_t(8))); + Assert.IsTrue((new mp_limb_t(8)) != (new mp_limb_t(9))); + } + + [TestMethod] + public void mp_ptr_test() + { + mp_ptr bytes0 = new mp_ptr(new byte[0]); + Assert.IsTrue(bytes0.Size == 0); + gmp_lib.free(bytes0); + + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + mp_ptr bytes1 = new mp_ptr(new byte[] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 }); + gmp_lib.mpz_roinit_n(z, bytes1, bytes1.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0x00000088 })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0x0000000000000088 })); + gmp_lib.free(bytes1); + + mp_ptr bytes2 = new mp_ptr(new byte[] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 }); + gmp_lib.mpz_roinit_n(z, bytes2, bytes2.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0x00009988 })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0x0000000000009988 })); + gmp_lib.free(bytes2); + + mp_ptr bytes3 = new mp_ptr(new byte[] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa }); + gmp_lib.mpz_roinit_n(z, bytes3, bytes3.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0x00aa9988 })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0x0000000000aa9988 })); + gmp_lib.free(bytes3); + + mp_ptr bytes4 = new mp_ptr(new byte[] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb }); + gmp_lib.mpz_roinit_n(z, bytes4, bytes4.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0xbbaa9988 })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0x00000000bbaa9988 })); + gmp_lib.free(bytes4); + + mp_ptr bytes5 = new mp_ptr(new byte[] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc }); + gmp_lib.mpz_roinit_n(z, bytes5, bytes5.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0xbbaa9988, 0x000000cc })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0x000000ccbbaa9988 })); + gmp_lib.free(bytes5); + + mp_ptr bytes6 = new mp_ptr(new byte[] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd }); + gmp_lib.mpz_roinit_n(z, bytes6, bytes6.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0xbbaa9988, 0x0000ddcc })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0x0000ddccbbaa9988 })); + gmp_lib.free(bytes6); + + mp_ptr bytes7 = new mp_ptr(new byte[] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee }); + gmp_lib.mpz_roinit_n(z, bytes7, bytes7.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0xbbaa9988, 0x00eeddcc })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0x00eeddccbbaa9988 })); + gmp_lib.free(bytes7); + + mp_ptr bytes8 = new mp_ptr(new byte[] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }); + gmp_lib.mpz_roinit_n(z, bytes8, bytes8.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0xbbaa9988, 0xffeeddcc })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0xffeeddccbbaa9988 })); + gmp_lib.free(bytes8); + + mp_ptr ushort1 = new mp_ptr(new ushort[] { 0x1100, 0x3322, 0x5544, 0x7766, 0x9988 }); + gmp_lib.mpz_roinit_n(z, ushort1, ushort1.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0x00009988 })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0x0000000000009988 })); + gmp_lib.free(ushort1); + + mp_ptr ushort2 = new mp_ptr(new ushort[] { 0x1100, 0x3322, 0x5544, 0x7766, 0x9988, 0xbbaa }); + gmp_lib.mpz_roinit_n(z, ushort2, ushort2.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0xbbaa9988 })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0x00000000bbaa9988 })); + gmp_lib.free(ushort2); + + mp_ptr ushort3 = new mp_ptr(new ushort[] { 0x1100, 0x3322, 0x5544, 0x7766, 0x9988, 0xbbaa, 0xddcc }); + gmp_lib.mpz_roinit_n(z, ushort3, ushort3.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0xbbaa9988, 0x0000ddcc })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0x0000ddccbbaa9988 })); + gmp_lib.free(ushort3); + + mp_ptr ushort4 = new mp_ptr(new ushort[] { 0x1100, 0x3322, 0x5544, 0x7766, 0x9988, 0xbbaa, 0xddcc, 0xffee }); + gmp_lib.mpz_roinit_n(z, ushort4, ushort4.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0xbbaa9988, 0xffeeddcc })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0xffeeddccbbaa9988 })); + gmp_lib.free(ushort4); + + mp_ptr uint1 = new mp_ptr(new uint[] { 0x33221100, 0x77665544, 0xbbaa9988 }); + gmp_lib.mpz_roinit_n(z, uint1, uint1.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0xbbaa9988 })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0x00000000bbaa9988 })); + gmp_lib.free(uint1); + + mp_ptr uint2 = new mp_ptr(new uint[] { 0x33221100, 0x77665544, 0xbbaa9988, 0xffeeddcc }); + gmp_lib.mpz_roinit_n(z, uint2, uint2.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0xbbaa9988, 0xffeeddcc })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0xffeeddccbbaa9988 })); + gmp_lib.free(uint2); + + mp_ptr ulong1 = new mp_ptr(new ulong[] { 0x7766554433221100, 0xffeeddccbbaa9988 }); + gmp_lib.mpz_roinit_n(z, ulong1, ulong1.Size); + if (gmp_lib.mp_bits_per_limb == 32) + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x33221100, 0x77665544, 0xbbaa9988, 0xffeeddcc })); + else + Assert.IsTrue(gmp_lib.mpz_limbs_read(z).SequenceEqual(new mp_limb_t[] { 0x7766554433221100, 0xffeeddccbbaa9988 })); + gmp_lib.free(ulong1); + } + + [TestMethod] + public void mp_size_t_test() + { + mp_size_t v; + + byte zero = 0; + + // Check implicit and explict conversions to mp_size_t. + v = (byte)zero; + v = (sbyte)zero; + v = (ushort)zero; + v = (short)zero; + v = (mp_size_t)(uint)zero; + v = (int)zero; + v = (mp_size_t)(ulong)zero; + v = (mp_size_t)(long)zero; + + // Check implicit and explict conversions from mp_size_t. + byte b = (byte)v; + sbyte sb = (sbyte)v; + ushort us = (ushort)v; + short s = (short)v; + uint ui = (uint)v; + int i = v; + ulong ul = (ulong)v; + long l = v; + + // Check OverflowException cases. + Assert.IsTrue(Test(() => v = (mp_size_t)uint.MaxValue) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => v = (mp_size_t)long.MaxValue) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => v = (mp_size_t)ulong.MaxValue) == typeof(OverflowException).Name); + + Assert.IsTrue(Test(() => b = (byte)(new mp_size_t(int.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => sb = (sbyte)(new mp_size_t(int.MinValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => sb = (sbyte)(new mp_size_t(int.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => us = (ushort)(new mp_size_t(int.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => s = (short)(new mp_size_t(int.MinValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => s = (short)(new mp_size_t(int.MaxValue))) == typeof(OverflowException).Name); + + // Check equality and inequality. + Object obj = new mp_size_t(8); + Assert.IsTrue((new mp_size_t(8)).Equals(obj)); + Assert.IsTrue(!(new mp_size_t(8)).Equals(new byte())); + Assert.IsTrue((new mp_size_t(8)).Equals(new mp_size_t(8))); + Assert.IsTrue(!(new mp_size_t(8)).Equals(new mp_size_t(9))); + Assert.IsTrue((new mp_size_t(8)) == (new mp_size_t(8))); + Assert.IsTrue((new mp_size_t(8)) != (new mp_size_t(9))); + } + + [TestMethod] + public void size_t_test() + { + size_t v; + + byte zero = 0; + sbyte minusOne = -1; + + // Check implicit and explict conversions to size_t. + v = (byte)zero; + v = (size_t)(sbyte)zero; + v = (ushort)zero; + v = (size_t)(short)zero; + v = (uint)zero; + v = (size_t)(int)zero; + v = (ulong)zero; + v = (size_t)(long)zero; + + // Check implicit and explict conversions from size_t. + byte b = (byte)v; + sbyte sb = (sbyte)v; + ushort us = (ushort)v; + short s = (short)v; + uint ui = (uint)v; + int i = (int)v; + ulong ul = v; + long l = (long)v; + + // Check OverflowException cases. + Assert.IsTrue(Test(() => v = (size_t)(sbyte)minusOne) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => v = (size_t)(short)minusOne) == typeof(OverflowException).Name); + //Assert.IsTrue(Test(() => v = (size_t)(int)minusOne) == typeof(OverflowException).Name); + //Assert.IsTrue(Test(() => v = (size_t)(long)minusOne) == typeof(OverflowException).Name); + + Assert.IsTrue(Test(() => b = (byte)(new size_t(ulong.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => sb = (sbyte)(new size_t(ulong.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => us = (ushort)(new size_t(ulong.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => s = (short)(new size_t(ulong.MaxValue))) == typeof(OverflowException).Name); + //Assert.IsTrue(Test(() => i = (int)(new size_t(ulong.MaxValue))) == typeof(OverflowException).Name); + Assert.IsTrue(Test(() => ui = (uint)(new size_t(ulong.MaxValue))) == typeof(OverflowException).Name); + //Assert.IsTrue(Test(() => l = (long)(new size_t(ulong.MaxValue))) == typeof(OverflowException).Name); + + // Check equality and inequality. + Object obj = new size_t(8); + Assert.IsTrue((new size_t(8)).Equals(obj)); + Assert.IsTrue(!(new size_t(8)).Equals(new byte())); + Assert.IsTrue((new size_t(8)).Equals(new size_t(8))); + Assert.IsTrue(!(new size_t(8)).Equals(new size_t(9))); + Assert.IsTrue((new size_t(8)) == (new size_t(8))); + Assert.IsTrue((new size_t(8)) != (new size_t(9))); + } + + [TestMethod] + public void void_ptr_test() + { + // Set block pointer to zero. + void_ptr s = void_ptr.Zero; + Assert.IsTrue(s.ToIntPtr() == IntPtr.Zero); + + // Create new block in unmanaged memory. + s = gmp_lib.allocate(10); + + // Assert that obj and s are the same pointer. + object obj = s; + Assert.IsTrue(s.Equals(obj) == true); + + // Create new unmanaged string. + void_ptr t = gmp_lib.allocate(10); + + // Assert that s and t are distinct block pointers. + Assert.IsTrue(s.Equals(t) == false); + + // Check inequality and equality of s and t pointers. + Assert.IsTrue(s != t); + gmp_lib.free(t); + t = s; + Assert.IsTrue(s == t); + gmp_lib.free(t); + } + + [TestMethod] + public void mpz_t_test() + { + // Create new multiple-precision integers. + mpz_t x = "123 456 789 012 345 678 901 234 567 890"; + mpz_t y = "123 456 789 012 345 678 901 234 567 890"; + mpz_t z = new mpz_t(); + mpz_t result = "246 913 578 024 691 357 802 469 135 780"; + gmp_lib.mpz_init(z); + + // Add integers, and assert result. + gmp_lib.mpz_add(z, x, y); + Assert.IsTrue(gmp_lib.mpz_cmp(z, result) == 0); + + // Release allocated memory for integers. + gmp_lib.mpz_clears(x, y, z, result, null); + } + + [TestMethod] + public void mpq_t_test() + { + // Create new multiple-precision rationals. + mpq_t x = "123 456 789 012 345 / 0x2 6975 02EC 8AD2"; + mpq_t y = "03 404 420 603 357 571 / 678 901 234 567 890"; + mpq_t z = new mpq_t(); + mpq_t result = "246 913 578 024 690 / 0b10 0110 1001 0111 0101 0000 0010 1110 1100 1000 1010 1101 0010"; + gmp_lib.mpq_init(z); + + // Add rationals, and assert result. + gmp_lib.mpq_add(z, x, y); + Assert.IsTrue(gmp_lib.mpq_cmp(z, result) == 0); + + // Release allocated memory for rationals. + gmp_lib.mpq_clears(x, y, z, result, null); + } + + [TestMethod] + public void mpf_t_test() + { + // Set default precision to 84 bits. + gmp_lib.mpf_set_default_prec(32U); + + // Create new multiple-precision floating-point numbers. + mpf_t x = "B-16 7048 860D DF79@0"; + mpf_t y = "123 456 789 012 345e0"; + mpf_t z = new mpf_t(); + mpf_t result = "246 913 578 024 690e0"; + gmp_lib.mpf_init(z); + + // Add floating-point numbers, and assert result. + gmp_lib.mpf_add(z, x, y); + Assert.IsTrue(gmp_lib.mpf_cmp(z, result) == 0); + + // Release allocated memory for floating-point numbers. + gmp_lib.mpf_clears(x, y, z, result, null); + } + + //[TestMethod] + //public void va_list() + //{ + // object[] args; + // va_list va_args; + + // args = new object[] { new ptr('A') }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == 'A'); + + // args = new object[] { new ptr(Byte.MinValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == Byte.MinValue); + + // args = new object[] { new ptr(SByte.MaxValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == SByte.MaxValue); + + // args = new object[] { new ptr(Int16.MinValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == Int16.MinValue); + + // args = new object[] { new ptr(UInt16.MaxValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == UInt16.MaxValue); + + // args = new object[] { new ptr(Int32.MinValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == Int32.MinValue); + + // args = new object[] { new ptr(UInt32.MaxValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == UInt32.MaxValue); + + // args = new object[] { new ptr(Int64.MinValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == Int64.MinValue); + + // args = new object[] { new ptr(UInt64.MaxValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == UInt64.MaxValue); + + // args = new object[] { new ptr(UInt32.MaxValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == UInt32.MaxValue); + + // args = new object[] { new ptr(Int32.MinValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == Int32.MinValue); + + // args = new object[] { new ptr(Single.MinValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == Single.MinValue); + + // args = new object[] { new ptr(Double.MaxValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == Double.MaxValue); + + // args = new object[] { new ptr(IntPtr.Size == 4 ? UInt32.MaxValue : UInt64.MaxValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == (IntPtr.Size == 4 ? UInt32.MaxValue : UInt64.MaxValue)); + + // args = new object[] { new ptr(IntPtr.Size == 4 ? UInt32.MaxValue : UInt64.MaxValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == (IntPtr.Size == 4 ? UInt32.MaxValue : UInt64.MaxValue)); + + // args = new object[] { new ptr(Int32.MinValue) }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((ptr)args[0]).Value == Int32.MinValue); + + // args = new object[] { new StringBuilder("ABCDEFGHIJ") }; + // va_args = new va_list(args); + // va_args.RetrieveArgumentValues(); + // Assert.IsTrue(((StringBuilder)args[0]).ToString() == "ABCDEFGHIJ"); + //} + + #endregion + + #region "Global variables." + + [TestMethod] + public void mp_bits_per_limb() + { + int bitsPerLimb = gmp_lib.mp_bits_per_limb; + Assert.AreEqual(bitsPerLimb, IntPtr.Size * 8); + } + + [TestMethod] + public void mp_bytes_per_limb() + { + mp_size_t bytesPerLimb = gmp_lib.mp_bytes_per_limb; + Assert.AreEqual(bytesPerLimb, (mp_size_t)IntPtr.Size); + } + + [TestMethod] + public void mp_uint_per_limb() + { + mp_size_t uintsPerLimb = gmp_lib.mp_uint_per_limb; + Assert.AreEqual(uintsPerLimb, (mp_size_t)(IntPtr.Size / 4)); + } + + [TestMethod] + public void gmp_errno() + { + int errno = gmp_lib.gmp_errno; + Assert.AreEqual(errno, 0); + gmp_lib.gmp_errno = 100; + errno = gmp_lib.gmp_errno; + Assert.AreEqual(errno, 100); + } + + [TestMethod] + public void gmp_version() + { + string version = gmp_lib.gmp_version; + Assert.AreEqual(version, "6.1.2"); + } + + #endregion + + #region "Memory allocation functions." + + [TestMethod] + public void gmp_get_memory_functions() + { + allocate_function allocate; + reallocate_function reallocate; + free_function free; + + // Retrieve the GMP memory allocation functions. + allocate = null; reallocate = null; free = null; + gmp_lib.gmp_get_memory_functions(ref allocate, ref reallocate, ref free); + Assert.IsTrue(allocate != null && reallocate != null && free != null); + + // Allocate and free memory. + void_ptr p = allocate(100); + free(p, 100); + } + + [TestMethod] + public void gmp_set_memory_functions() + { + // Retrieve GMP default memory allocation functions. + allocate_function default_allocate = null; + reallocate_function default_reallocate = null; + free_function default_free = null; + gmp_lib.gmp_get_memory_functions(ref default_allocate, ref default_reallocate, ref default_free); + + // Create and set new memory allocation functions that count the number of times they are called. + int counter = 0; + allocate_function new_allocate = (size_t alloc_size) => { counter++; return default_allocate(alloc_size); }; + reallocate_function new_reallocate = (void_ptr ptr, size_t old_size, size_t new_size) => { counter++; return default_reallocate(ptr, old_size, new_size); }; + free_function new_free = (void_ptr ptr, size_t size) => { counter++; default_free(ptr, size); }; + gmp_lib.gmp_set_memory_functions(new_allocate, new_reallocate, new_free); + + // Retrieve GMP memory allocation functions. + allocate_function allocate = null; + reallocate_function reallocate = null; + free_function free = null; + gmp_lib.gmp_get_memory_functions(ref allocate, ref reallocate, ref free); + + // Call memory function and assert calls count. + void_ptr p = allocate(10); + Assert.IsTrue(counter == 1); + + reallocate(p, 10, 20); + Assert.IsTrue(counter == 2); + + free(p, 20); + Assert.IsTrue(counter == 3); + + // Restore default memory allocation functions. + gmp_lib.gmp_set_memory_functions(null, null, null); + } + + #endregion + + #region "Random number routines." + + [TestMethod] + public void gmp_randinit_default() + { + // Create new random number generator state. + gmp_randstate_t state = new gmp_randstate_t(); + + // Initialize state with default random number generator algorithm. + gmp_lib.gmp_randinit_default(state); + + // Free all memory occupied by state. + gmp_lib.gmp_randclear(state); + } + + [TestMethod] + public void gmp_randinit_lc_2exp() + { + // Create new random number generator state. + gmp_randstate_t state = new gmp_randstate_t(); + + // Initialize state with a linear congruential random number generator algorithm. + mpz_t a = new mpz_t(); + gmp_lib.mpz_init_set_ui(a, 100000U); + gmp_lib.gmp_randinit_lc_2exp(state, a, 13, 300); + + // Free all memory occupied by state and a. + gmp_lib.gmp_randclear(state); + gmp_lib.mpz_clear(a); + } + + [TestMethod] + public void gmp_randinit_lc_2exp_size() + { + // Create new random number generator state. + gmp_randstate_t state = new gmp_randstate_t(); + + // Initialize state with a linear congruential random number generator algorithm. + gmp_lib.gmp_randinit_lc_2exp_size(state, 30); + + // Free all memory occupied by state. + gmp_lib.gmp_randclear(state); + } + + [TestMethod] + public void gmp_randinit_mt() + { + // Create new random number generator state. + gmp_randstate_t state = new gmp_randstate_t(); + + // Initialize state with Mersenne Twister random number generator algorithm. + gmp_lib.gmp_randinit_mt(state); + + // Free all memory occupied by state. + gmp_lib.gmp_randclear(state); + } + + [TestMethod] + public void gmp_randinit_set() + { + // Create new random number generator state, and initialize state with the Mersenne Twister algorithm. + gmp_randstate_t op = new gmp_randstate_t(); + gmp_lib.gmp_randinit_mt(op); + + // Create new random number generator state, and initialize it with the state op. + gmp_randstate_t rop = new gmp_randstate_t(); + gmp_lib.gmp_randinit_set(rop, op); + + // Free all memory occupied by op and rop. + gmp_lib.gmp_randclear(op); + gmp_lib.gmp_randclear(rop); + } + + [TestMethod] + public void gmp_randseed() + { + // Create new random number generator state, and initialize state with the Mersenne Twister algorithm. + gmp_randstate_t state = new gmp_randstate_t(); + gmp_lib.gmp_randinit_mt(state); + + // Seed random number generator. + mpz_t seed = new mpz_t(); + gmp_lib.mpz_init_set_ui(seed, 100000U); + gmp_lib.gmp_randseed(state, seed); + + // Free all memory occupied by state and seed. + gmp_lib.gmp_randclear(state); + gmp_lib.mpz_clear(seed); + } + + [TestMethod] + public void gmp_randseed_ui() + { + // Create new random number generator state, and initialize state with the Mersenne Twister algorithm. + gmp_randstate_t state = new gmp_randstate_t(); + gmp_lib.gmp_randinit_mt(state); + + // Seed random number generator. + gmp_lib.gmp_randseed_ui(state, 100000U); + + // Free all memory occupied by state. + gmp_lib.gmp_randclear(state); + } + + [TestMethod] + public void gmp_urandomb_ui() + { + // Create, initialize, and seed a new random number generator. + gmp_randstate_t state = new gmp_randstate_t(); + gmp_lib.gmp_randinit_mt(state); + gmp_lib.gmp_randseed_ui(state, 100000U); + + // Generate a random integer in the range [0, 2^8-1]. + uint rand = gmp_lib.gmp_urandomb_ui(state, 8); + + // Free all memory occupied by state. + gmp_lib.gmp_randclear(state); + } + + [TestMethod] + public void gmp_urandomm_ui() + { + // Create, initialize, and seed a new random number generator. + gmp_randstate_t state = new gmp_randstate_t(); + gmp_lib.gmp_randinit_mt(state); + gmp_lib.gmp_randseed_ui(state, 1000U); + + // Generate a random integer in the range [0, 8-1]. + uint rand = gmp_lib.gmp_urandomm_ui(state, 8); + + // Free all memory occupied by state. + gmp_lib.gmp_randclear(state); + } + + #endregion + + #region "Formatted output routines." + + [TestMethod] + public void gmp_asprintf() + { + // Create pointer to unmanaged character string pointer. + ptr str = new ptr(); + + mpz_t z = "123456"; + mpq_t q = "123/456"; + mpf_t f = "12345e6"; + mp_limb_t m = 123456; + + // Print to newly allocated unmanaged memory string. + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + Assert.IsTrue(str.Value.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100"); + + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Zd", z) == 6); + Assert.IsTrue(str.Value.ToString() == "123456"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Zi", z) == 6); + Assert.IsTrue(str.Value.ToString() == "123456"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%ZX", z) == 5); + Assert.IsTrue(str.Value.ToString() == "1E240"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Zo", z) == 6); + Assert.IsTrue(str.Value.ToString() == "361100"); + gmp_lib.free(str.Value); + gmp_lib.mpz_clear(z); + + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Qd", q) == 7); + Assert.IsTrue(str.Value.ToString() == "123/456"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Qi", q) == 7); + Assert.IsTrue(str.Value.ToString() == "123/456"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%QX", q) == 6); + Assert.IsTrue(str.Value.ToString() == "7B/1C8"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Qo", q) == 7); + Assert.IsTrue(str.Value.ToString() == "173/710"); + gmp_lib.free(str.Value); + gmp_lib.mpq_clear(q); + + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Fe", f) == 12); + Assert.IsTrue(str.Value.ToString() == "1.234500e+10"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Ff", f) == 18); + Assert.IsTrue(str.Value.ToString() == "12345000000.000000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Fg", f) == 10); + Assert.IsTrue(str.Value.ToString() == "1.2345e+10"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Fa", f) == 15); + Assert.IsTrue(str.Value.ToString() == "0x2.dfd1c04p+32"); + gmp_lib.free(str.Value); + gmp_lib.mpf_clear(f); + + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Md", m) == 6); + Assert.IsTrue(str.Value.ToString() == "123456"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Mi", m) == 6); + Assert.IsTrue(str.Value.ToString() == "123456"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%MX", m) == 5); + Assert.IsTrue(str.Value.ToString() == "1E240"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Mo", m) == 6); + Assert.IsTrue(str.Value.ToString() == "361100"); + gmp_lib.free(str.Value); + + mp_ptr n = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 }); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Nd", n, n.Size) == 11); + Assert.IsTrue(str.Value.ToString() == "11111111111"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Ni", n, n.Size) == 11); + Assert.IsTrue(str.Value.ToString() == "11111111111"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%NX", n, n.Size) == 9); + Assert.IsTrue(str.Value.ToString() == "2964619C7"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%No", n, n.Size) == 12); + Assert.IsTrue(str.Value.ToString() == "122621414707"); + gmp_lib.free(str.Value); + + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%hd", (short)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%hhd", (byte)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%hhc", 'A') == 1); + Assert.IsTrue(str.Value.ToString() == "A"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%ld", (Int32)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%lld", (Int64)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + + // Instead of %z, use %M. + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Md", (size_t)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%d", (mp_bitcnt_t)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%d", (mp_size_t)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%d", (mp_exp_t)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%f", (Double)1.0) == 8); + Assert.IsTrue(str.Value.ToString() == "1.000000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%f", (Single)1.0) == 8); + Assert.IsTrue(str.Value.ToString() == "1.000000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%e", (Double)1.0) == 13); + Assert.IsTrue(str.Value.ToString() == "1.000000e+000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%e", (Single)1.0) == 13); + Assert.IsTrue(str.Value.ToString() == "1.000000e+000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%g", (Double)1.0) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%g", (Single)1.0) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%E", (Double)1.0) == 13); + Assert.IsTrue(str.Value.ToString() == "1.000000E+000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%E", (Single)1.0) == 13); + Assert.IsTrue(str.Value.ToString() == "1.000000E+000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%G", (Double)1.0) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%G", (Single)1.0) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + + //Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%a", (Double)1.0) == 13); + //Assert.IsTrue(str.Value.ToString() == "0x1.000000p+0"); + //gmp_lib.free(str.Value); + //Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%a", (Single)1.0) == 13); + //Assert.IsTrue(str.Value.ToString() == "0x1.000004p+0"); + //gmp_lib.free(str.Value); + + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%s", "Hello World!") == 12); + Assert.IsTrue(str.Value.ToString() == "Hello World!"); + gmp_lib.free(str.Value); + + ptr p = new ptr(12); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "123456%n", p) == 6); + Assert.IsTrue(str.Value.ToString() == "123456"); + Assert.IsTrue(p.Value == 6); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%p", p) == 2 * IntPtr.Size); + gmp_lib.free(str.Value); + } + + [TestMethod] + public void gmp_vasprintf() + { + ptr str = new ptr(); + + mpz_t z = "123456"; + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Zd", z) == 6); + Assert.IsTrue(str.Value.ToString() == "123456"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Zi", z) == 6); + Assert.IsTrue(str.Value.ToString() == "123456"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%ZX", z) == 5); + Assert.IsTrue(str.Value.ToString() == "1E240"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Zo", z) == 6); + Assert.IsTrue(str.Value.ToString() == "361100"); + gmp_lib.free(str.Value); + gmp_lib.mpz_clear(z); + + mpq_t q = "123/456"; + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Qd", q) == 7); + Assert.IsTrue(str.Value.ToString() == "123/456"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Qi", q) == 7); + Assert.IsTrue(str.Value.ToString() == "123/456"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%QX", q) == 6); + Assert.IsTrue(str.Value.ToString() == "7B/1C8"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Qo", q) == 7); + Assert.IsTrue(str.Value.ToString() == "173/710"); + gmp_lib.free(str.Value); + gmp_lib.mpq_clear(q); + + mpf_t f = "12345e6"; + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Fe", f) == 12); + Assert.IsTrue(str.Value.ToString() == "1.234500e+10"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Ff", f) == 18); + Assert.IsTrue(str.Value.ToString() == "12345000000.000000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Fg", f) == 10); + Assert.IsTrue(str.Value.ToString() == "1.2345e+10"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Fa", f) == 15); + Assert.IsTrue(str.Value.ToString() == "0x2.dfd1c04p+32"); + gmp_lib.free(str.Value); + gmp_lib.mpf_clear(f); + + mp_limb_t m = 123456; + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Md", m) == 6); + Assert.IsTrue(str.Value.ToString() == "123456"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Mi", m) == 6); + Assert.IsTrue(str.Value.ToString() == "123456"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%MX", m) == 5); + Assert.IsTrue(str.Value.ToString() == "1E240"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Mo", m) == 6); + Assert.IsTrue(str.Value.ToString() == "361100"); + gmp_lib.free(str.Value); + + mp_ptr n = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 }); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Nd", n, n.Size) == 11); + Assert.IsTrue(str.Value.ToString() == "11111111111"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Ni", n, n.Size) == 11); + Assert.IsTrue(str.Value.ToString() == "11111111111"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%NX", n, n.Size) == 9); + Assert.IsTrue(str.Value.ToString() == "2964619C7"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%No", n, n.Size) == 12); + Assert.IsTrue(str.Value.ToString() == "122621414707"); + gmp_lib.free(str.Value); + + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%hd", (short)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%hhd", (byte)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%hhc", 'A') == 1); + Assert.IsTrue(str.Value.ToString() == "A"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%ld", (Int32)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%lld", (Int64)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + + // Instead of %z, use %M. + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Md", (size_t)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%d", (mp_bitcnt_t)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%d", (mp_size_t)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%d", (mp_exp_t)1) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%f", (Double)1.0) == 8); + Assert.IsTrue(str.Value.ToString() == "1.000000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%f", (Single)1.0) == 8); + Assert.IsTrue(str.Value.ToString() == "1.000000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%e", (Double)1.0) == 13); + Assert.IsTrue(str.Value.ToString() == "1.000000e+000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%e", (Single)1.0) == 13); + Assert.IsTrue(str.Value.ToString() == "1.000000e+000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%g", (Double)1.0) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%g", (Single)1.0) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%E", (Double)1.0) == 13); + Assert.IsTrue(str.Value.ToString() == "1.000000E+000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%E", (Single)1.0) == 13); + Assert.IsTrue(str.Value.ToString() == "1.000000E+000"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%G", (Double)1.0) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%G", (Single)1.0) == 1); + Assert.IsTrue(str.Value.ToString() == "1"); + gmp_lib.free(str.Value); + + //Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%a", (Double)1.0) == 13); + //Assert.IsTrue(str.Value.ToString() == "0x1.000000p+0"); + //gmp_lib.free(str.Value); + //Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%a", (Single)1.0) == 13); + //Assert.IsTrue(str.Value.ToString() == "0x1.000004p+0"); + //gmp_lib.free(str.Value); + + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%s", "Hello World!") == 12); + Assert.IsTrue(str.Value.ToString() == "Hello World!"); + gmp_lib.free(str.Value); + + ptr p = new ptr(12); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "123456%n", p) == 6); + Assert.IsTrue(str.Value.ToString() == "123456"); + Assert.IsTrue(p.Value == 6); + gmp_lib.free(str.Value); + Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%p", p) == 2 * IntPtr.Size); + gmp_lib.free(str.Value); + } + + [TestMethod] + public void gmp_fprintf() + { + // Create unique file pathname and a file pointer. + string pathname = System.IO.Path.GetTempFileName(); + ptr stream = new ptr(); + + mpz_t z = "123456"; + mpq_t q = "123/456"; + mpf_t f = "12345e6"; + mp_limb_t m = 123456; + + // Open file stream and print to it. + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Zd", z) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Zi", z) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%ZX", z) == 5); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1E240"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Zo", z) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "361100"); + gmp_lib.mpz_clear(z); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Qd", q) == 7); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123/456"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Qi", q) == 7); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123/456"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%QX", q) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "7B/1C8"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Qo", q) == 7); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "173/710"); + gmp_lib.mpq_clear(q); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Fe", f) == 12); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.234500e+10"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Ff", f) == 18); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "12345000000.000000"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Fg", f) == 10); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.2345e+10"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Fa", f) == 15); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "0x2.dfd1c04p+32"); + gmp_lib.mpf_clear(f); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Md", m) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Mi", m) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%MX", m) == 5); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1E240"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Mo", m) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "361100"); + + mp_ptr n = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 }); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Nd", n, n.Size) == 11); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "11111111111"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Ni", n, n.Size) == 11); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "11111111111"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%NX", n, n.Size) == 9); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "2964619C7"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%No", n, n.Size) == 12); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "122621414707"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%hd", (short)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%hhd", (byte)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%hhc", 'A') == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "A"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%ld", (Int32)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%lld", (Int64)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + // Instead of %z, use %M. + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Md", (size_t)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%d", (mp_bitcnt_t)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%d", (mp_size_t)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%d", (mp_exp_t)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%f", (Double)1.0) == 8); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.000000"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%f", (Single)1.0) == 8); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.000000"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%e", (Double)1.0) == 13); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.000000e+000"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%e", (Single)1.0) == 13); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.000000e+000"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%g", (Double)1.0) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%g", (Single)1.0) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%E", (Double)1.0) == 13); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.000000E+000"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%E", (Single)1.0) == 13); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.000000E+000"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%G", (Double)1.0) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%G", (Single)1.0) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%a", (Double)1.0) == 13); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "0x1.000000p+0"); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%a", (Single)1.0) == 13); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "0x1.000000p+0"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%s", "Hello World!") == 12); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "Hello World!"); + + ptr p = new ptr(12); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "123456%n", p) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456"); + + Assert.IsTrue(p.Value == 6); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%p", p) == 2 * IntPtr.Size); + fclose(stream.Value.Value); + } + + [TestMethod] + public void gmp_vfprintf() + { + string pathname = System.IO.Path.GetTempFileName(); + ptr stream = new ptr(); + + mpz_t z = "123456"; + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Zd", z) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Zi", z) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%ZX", z) == 5); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1E240"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Zo", z) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "361100"); + gmp_lib.mpz_clear(z); + + mpq_t q = "123/456"; + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Qd", q) == 7); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123/456"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Qi", q) == 7); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123/456"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%QX", q) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "7B/1C8"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Qo", q) == 7); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "173/710"); + gmp_lib.mpq_clear(q); + + mpf_t f = "12345e6"; + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Fe", f) == 12); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.234500e+10"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Ff", f) == 18); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "12345000000.000000"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Fg", f) == 10); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.2345e+10"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Fa", f) == 15); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "0x2.dfd1c04p+32"); + gmp_lib.mpf_clear(f); + + mp_limb_t m = 123456; + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Md", m) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Mi", m) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%MX", m) == 5); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1E240"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Mo", m) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "361100"); + + mp_ptr n = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 }); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Nd", n, n.Size) == 11); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "11111111111"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Ni", n, n.Size) == 11); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "11111111111"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%NX", n, n.Size) == 9); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "2964619C7"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%No", n, n.Size) == 12); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "122621414707"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%hd", (short)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%hhd", (byte)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%hhc", 'A') == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "A"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%ld", (Int32)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%lld", (Int64)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + // Instead of %z, use %M. + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Md", (size_t)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%d", (mp_bitcnt_t)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%d", (mp_size_t)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%d", (mp_exp_t)1) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%f", (Double)1.0) == 8); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.000000"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%f", (Single)1.0) == 8); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.000000"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%e", (Double)1.0) == 13); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.000000e+000"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%e", (Single)1.0) == 13); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.000000e+000"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%g", (Double)1.0) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%g", (Single)1.0) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%E", (Double)1.0) == 13); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.000000E+000"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%E", (Single)1.0) == 13); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1.000000E+000"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%G", (Double)1.0) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%G", (Single)1.0) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "1"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%a", (Double)1.0) == 13); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "0x1.000000p+0"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%a", (Single)1.0) == 13); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "0x1.000000p+0"); + + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%s", "Hello World!") == 12); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "Hello World!"); + + ptr p = new ptr(12); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "123456%n", p) == 6); + fclose(stream.Value.Value); + Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456"); + + Assert.IsTrue(p.Value == 6); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%p", p) == 2 * IntPtr.Size); + fclose(stream.Value.Value); + } + + [TestMethod] + public void gmp_snprintf() + { + // Allocate unmanaged string with 50 characters. + char_ptr str = new char_ptr("................................................."); + + mpz_t z = "123456"; + mpq_t q = "123/456"; + mpf_t f = "12345e6"; + mp_limb_t m = 123456; + + // Print to string. + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 50, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100"); + + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Zd", z) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Zi", z) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%ZX", z) == 5); + Assert.IsTrue(str.ToString() == "1E240"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Zo", z) == 6); + Assert.IsTrue(str.ToString() == "361100"); + gmp_lib.mpz_clear(z); + + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Qd", q) == 7); + Assert.IsTrue(str.ToString() == "123/456"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Qi", q) == 7); + Assert.IsTrue(str.ToString() == "123/456"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%QX", q) == 6); + Assert.IsTrue(str.ToString() == "7B/1C8"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Qo", q) == 7); + Assert.IsTrue(str.ToString() == "173/710"); + gmp_lib.mpq_clear(q); + + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Fe", f) == 12); + Assert.IsTrue(str.ToString() == "1.234500e+10"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Ff", f) == 18); + Assert.IsTrue(str.ToString() == "12345000000.000000"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Fg", f) == 10); + Assert.IsTrue(str.ToString() == "1.2345e+10"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Fa", f) == 15); + Assert.IsTrue(str.ToString() == "0x2.dfd1c04p+32"); + gmp_lib.mpf_clear(f); + + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Md", m) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Mi", m) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%MX", m) == 5); + Assert.IsTrue(str.ToString() == "1E240"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Mo", m) == 6); + Assert.IsTrue(str.ToString() == "361100"); + + mp_ptr n = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 }); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Nd", n, n.Size) == 11); + Assert.IsTrue(str.ToString() == "11111111111"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Ni", n, n.Size) == 11); + Assert.IsTrue(str.ToString() == "11111111111"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%NX", n, n.Size) == 9); + Assert.IsTrue(str.ToString() == "2964619C7"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%No", n, n.Size) == 12); + Assert.IsTrue(str.ToString() == "122621414707"); + + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%hd", (short)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%hhd", (byte)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%hhc", 'A') == 1); + Assert.IsTrue(str.ToString() == "A"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%ld", (Int32)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%lld", (Int64)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + + // Instead of %z, use %M. + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%Md", (size_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%d", (mp_bitcnt_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%d", (mp_size_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%d", (mp_exp_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%f", (Double)1.0) == 8); + Assert.IsTrue(str.ToString() == "1.000000"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%f", (Single)1.0) == 8); + Assert.IsTrue(str.ToString() == "1.000000"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%e", (Double)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000e+000"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%e", (Single)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000e+000"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%g", (Double)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%g", (Single)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%E", (Double)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000E+000"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%E", (Single)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000E+000"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%G", (Double)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%G", (Single)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + + //Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%a", (Double)1.0) == 13); + //Assert.IsTrue(str.ToString() == "0x1.000000p+0"); + //Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%a", (Single)1.0) == 13); + //Assert.IsTrue(str.ToString() == "0x1.000000p+0"); + + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%s", "Hello World!") == 12); + Assert.IsTrue(str.ToString() == "Hello World!"); + + ptr p = new ptr(12); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "123456%n", p) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(p.Value == 6); + Assert.IsTrue(gmp_lib.gmp_snprintf(str, 41, "%p", p) == 2 * IntPtr.Size); + + gmp_lib.free(str); + } + + [TestMethod] + public void gmp_vsnprintf() + { + char_ptr str = new char_ptr("........................................."); + + mpz_t z = "123456"; + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Zd", z) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Zi", z) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%ZX", z) == 5); + Assert.IsTrue(str.ToString() == "1E240"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Zo", z) == 6); + Assert.IsTrue(str.ToString() == "361100"); + gmp_lib.mpz_clear(z); + + mpq_t q = "123/456"; + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Qd", q) == 7); + Assert.IsTrue(str.ToString() == "123/456"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Qi", q) == 7); + Assert.IsTrue(str.ToString() == "123/456"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%QX", q) == 6); + Assert.IsTrue(str.ToString() == "7B/1C8"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Qo", q) == 7); + Assert.IsTrue(str.ToString() == "173/710"); + gmp_lib.mpq_clear(q); + + mpf_t f = "12345e6"; + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Fe", f) == 12); + Assert.IsTrue(str.ToString() == "1.234500e+10"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Ff", f) == 18); + Assert.IsTrue(str.ToString() == "12345000000.000000"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Fg", f) == 10); + Assert.IsTrue(str.ToString() == "1.2345e+10"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Fa", f) == 15); + Assert.IsTrue(str.ToString() == "0x2.dfd1c04p+32"); + gmp_lib.mpf_clear(f); + + mp_limb_t m = 123456; + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Md", m) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Mi", m) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%MX", m) == 5); + Assert.IsTrue(str.ToString() == "1E240"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Mo", m) == 6); + Assert.IsTrue(str.ToString() == "361100"); + + mp_ptr n = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 }); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Nd", n, n.Size) == 11); + Assert.IsTrue(str.ToString() == "11111111111"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Ni", n, n.Size) == 11); + Assert.IsTrue(str.ToString() == "11111111111"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%NX", n, n.Size) == 9); + Assert.IsTrue(str.ToString() == "2964619C7"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%No", n, n.Size) == 12); + Assert.IsTrue(str.ToString() == "122621414707"); + + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%hd", (short)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%hhd", (byte)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%hhc", 'A') == 1); + Assert.IsTrue(str.ToString() == "A"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%ld", (Int32)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%lld", (Int64)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + + // Instead of %z, use %M. + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%Md", (size_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%d", (mp_bitcnt_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%d", (mp_size_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%d", (mp_exp_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%f", (Double)1.0) == 8); + Assert.IsTrue(str.ToString() == "1.000000"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%f", (Single)1.0) == 8); + Assert.IsTrue(str.ToString() == "1.000000"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%e", (Double)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000e+000"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%e", (Single)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000e+000"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%g", (Double)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%g", (Single)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%E", (Double)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000E+000"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%E", (Single)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000E+000"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%G", (Double)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%G", (Single)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + + //Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%a", (Double)1.0) == 13); + //Assert.IsTrue(str.ToString() == "0x1.000000p+0"); + //Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%a", (Single)1.0) == 13); + //Assert.IsTrue(str.ToString() == "0x1.000000p+0"); + + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%s", "Hello World!") == 12); + Assert.IsTrue(str.ToString() == "Hello World!"); + + ptr p = new ptr(12); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "123456%n", p) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(p.Value == 6); + Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 41, "%p", p) == 2 * IntPtr.Size); + + gmp_lib.free(str); + } + + [TestMethod] + public void gmp_sprintf() + { + // Allocate unmanaged string with 50 characters. + char_ptr str = new char_ptr("................................................."); + + mpz_t z = "123456"; + mpq_t q = "123/456"; + mpf_t f = "12345e6"; + mp_limb_t m = 123456; + + // Print to string. + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100"); + + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Zd", z) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Zi", z) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%ZX", z) == 5); + Assert.IsTrue(str.ToString() == "1E240"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Zo", z) == 6); + Assert.IsTrue(str.ToString() == "361100"); + gmp_lib.mpz_clear(z); + + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Qd", q) == 7); + Assert.IsTrue(str.ToString() == "123/456"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Qi", q) == 7); + Assert.IsTrue(str.ToString() == "123/456"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%QX", q) == 6); + Assert.IsTrue(str.ToString() == "7B/1C8"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Qo", q) == 7); + Assert.IsTrue(str.ToString() == "173/710"); + gmp_lib.mpq_clear(q); + + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Fe", f) == 12); + Assert.IsTrue(str.ToString() == "1.234500e+10"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Ff", f) == 18); + Assert.IsTrue(str.ToString() == "12345000000.000000"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Fg", f) == 10); + Assert.IsTrue(str.ToString() == "1.2345e+10"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Fa", f) == 15); + Assert.IsTrue(str.ToString() == "0x2.dfd1c04p+32"); + gmp_lib.mpf_clear(f); + + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Md", m) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Mi", m) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%MX", m) == 5); + Assert.IsTrue(str.ToString() == "1E240"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Mo", m) == 6); + Assert.IsTrue(str.ToString() == "361100"); + + mp_ptr n = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 }); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Nd", n, n.Size) == 11); + Assert.IsTrue(str.ToString() == "11111111111"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Ni", n, n.Size) == 11); + Assert.IsTrue(str.ToString() == "11111111111"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%NX", n, n.Size) == 9); + Assert.IsTrue(str.ToString() == "2964619C7"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%No", n, n.Size) == 12); + Assert.IsTrue(str.ToString() == "122621414707"); + + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%hd", (short)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%hhd", (byte)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%hhc", 'A') == 1); + Assert.IsTrue(str.ToString() == "A"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%ld", (Int32)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%lld", (Int64)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + + // Instead of %z, use %M. + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Md", (size_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%d", (mp_bitcnt_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%d", (mp_size_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%d", (mp_exp_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%f", (Double)1.0) == 8); + Assert.IsTrue(str.ToString() == "1.000000"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%f", (Single)1.0) == 8); + Assert.IsTrue(str.ToString() == "1.000000"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%e", (Double)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000e+000"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%e", (Single)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000e+000"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%g", (Double)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%g", (Single)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%E", (Double)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000E+000"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%E", (Single)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000E+000"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%G", (Double)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%G", (Single)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%a", (Double)1.0) == 13); + Assert.IsTrue(str.ToString() == "0x1.000000p+0"); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%a", (Single)1.0) == 13); + Assert.IsTrue(str.ToString() == "0x1.000000p+0"); + + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%s", "Hello World!") == 12); + Assert.IsTrue(str.ToString() == "Hello World!"); + + ptr p = new ptr(12); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "123456%n", p) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(p.Value == 6); + Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%p", p) == 2 * IntPtr.Size); + + gmp_lib.free(str); + } + + [TestMethod] + public void gmp_vsprintf() + { + // Create string. + char_ptr str = new char_ptr("........................................."); + + mpz_t z = "123456"; + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Zd", z) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Zi", z) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%ZX", z) == 5); + Assert.IsTrue(str.ToString() == "1E240"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Zo", z) == 6); + Assert.IsTrue(str.ToString() == "361100"); + gmp_lib.mpz_clear(z); + + mpq_t q = "123/456"; + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Qd", q) == 7); + Assert.IsTrue(str.ToString() == "123/456"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Qi", q) == 7); + Assert.IsTrue(str.ToString() == "123/456"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%QX", q) == 6); + Assert.IsTrue(str.ToString() == "7B/1C8"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Qo", q) == 7); + Assert.IsTrue(str.ToString() == "173/710"); + gmp_lib.mpq_clear(q); + + mpf_t f = "12345e6"; + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Fe", f) == 12); + Assert.IsTrue(str.ToString() == "1.234500e+10"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Ff", f) == 18); + Assert.IsTrue(str.ToString() == "12345000000.000000"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Fg", f) == 10); + Assert.IsTrue(str.ToString() == "1.2345e+10"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Fa", f) == 15); + Assert.IsTrue(str.ToString() == "0x2.dfd1c04p+32"); + gmp_lib.mpf_clear(f); + + mp_limb_t m = 123456; + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Md", m) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Mi", m) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%MX", m) == 5); + Assert.IsTrue(str.ToString() == "1E240"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Mo", m) == 6); + Assert.IsTrue(str.ToString() == "361100"); + + mp_ptr n = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 }); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Nd", n, n.Size) == 11); + Assert.IsTrue(str.ToString() == "11111111111"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Ni", n, n.Size) == 11); + Assert.IsTrue(str.ToString() == "11111111111"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%NX", n, n.Size) == 9); + Assert.IsTrue(str.ToString() == "2964619C7"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%No", n, n.Size) == 12); + Assert.IsTrue(str.ToString() == "122621414707"); + + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%hd", (short)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%hhd", (byte)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%hhc", 'A') == 1); + Assert.IsTrue(str.ToString() == "A"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%ld", (Int32)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%lld", (Int64)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + + // Instead of %z, use %M. + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Md", (size_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%d", (mp_bitcnt_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%d", (mp_size_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%d", (mp_exp_t)1) == 1); + Assert.IsTrue(str.ToString() == "1"); + + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%f", (Double)1.0) == 8); + Assert.IsTrue(str.ToString() == "1.000000"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%f", (Single)1.0) == 8); + Assert.IsTrue(str.ToString() == "1.000000"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%e", (Double)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000e+000"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%e", (Single)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000e+000"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%g", (Double)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%g", (Single)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%E", (Double)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000E+000"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%E", (Single)1.0) == 13); + Assert.IsTrue(str.ToString() == "1.000000E+000"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%G", (Double)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%G", (Single)1.0) == 1); + Assert.IsTrue(str.ToString() == "1"); + + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%a", (Double)1.0) == 13); + Assert.IsTrue(str.ToString() == "0x1.000000p+0"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%a", (Single)1.0) == 13); + Assert.IsTrue(str.ToString() == "0x1.000004p+0"); + + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%s", "Hello World!") == 12); + Assert.IsTrue(str.ToString() == "Hello World!"); + + ptr p = new ptr(12); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "123456%n", p) == 6); + Assert.IsTrue(str.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%p", p) == 2 * IntPtr.Size); + //Assert.IsTrue(str.ToString() == p.ToIntPtr().ToString("X0" + (2 * IntPtr.Size).ToString())); + + // Free allocated unmanaged memory. + gmp_lib.free(str); + } + + #endregion + + #region "Formatted input routines." + + [TestMethod] + public void gmp_fscanf() + { + // Create unique filename and stream pointer. + string pathname = System.IO.Path.GetTempFileName(); + ptr stream = new ptr(); + + mpz_t z = "0"; + mpq_t q = "0"; + mpf_t f = "0"; + ptr c = new ptr('0'); + ptr zt = new ptr(0); + ptr dbl = new ptr(0); + + // Write string to file, and then read values from it. + System.IO.File.WriteAllText(pathname, "123456 7B/1C8 1.234500e+10 A 10 1.000000"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6); + fclose(stream.Value.Value); + + // Assert values read. + Assert.IsTrue(z.ToString() == "123456"); + Assert.IsTrue(q.ToString() == "123/456"); + Assert.IsTrue(f.ToString() == "0.12345e11"); + Assert.IsTrue(c.Value == 'A'); + Assert.IsTrue(zt.Value == 10); + Assert.IsTrue(dbl.Value == 1.0); + + System.IO.File.WriteAllText(pathname, "123456"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Zd", z) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(z.ToString() == "123456"); + System.IO.File.WriteAllText(pathname, "123456"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Zi", z) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(z.ToString() == "123456"); + System.IO.File.WriteAllText(pathname, "1E240"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%ZX", z) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(z.ToString() == "123456"); + System.IO.File.WriteAllText(pathname, "361100"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, " %Zo", z) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(z.ToString() == "123456"); + gmp_lib.mpz_clear(z); + + System.IO.File.WriteAllText(pathname, "123/456"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Qd", q) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(q.ToString() == "123/456"); + System.IO.File.WriteAllText(pathname, "123/456"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Qi", q) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(q.ToString() == "123/456"); + System.IO.File.WriteAllText(pathname, "7B/1C8"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%QX", q) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(q.ToString() == "123/456"); + System.IO.File.WriteAllText(pathname, "173/710"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Qo", q) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(q.ToString() == "123/456"); + gmp_lib.mpq_clear(q); + + System.IO.File.WriteAllText(pathname, "1.234500e+10"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Fe", f) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(f.ToString() == "0.12345e11"); + System.IO.File.WriteAllText(pathname, "12345000000.000000"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Ff", f) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(f.ToString() == "0.12345e11"); + System.IO.File.WriteAllText(pathname, "1.2345e+10"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Fg", f) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(f.ToString() == "0.12345e11"); + //System.IO.File.WriteAllText(pathname, "0x2.dfd1c04p+32"); + //_wfopen_s(out stream.Value.Value, pathname, "r"); + //Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Fa", f) == 1); + //fclose(stream.Value.Value); + //Assert.IsTrue(f.ToString() == "0.12345e11"); + gmp_lib.mpf_clear(f); + + ptr s = new ptr(0); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%hd", s) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(s.Value == 1); + ptr b = new ptr(0); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%hhd", b) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(b.Value == 1); + System.IO.File.WriteAllText(pathname, "A"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%hhc", c) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(c.Value == 'A'); + ptr i = new ptr(0); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%ld", i) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(i.Value == 1); + ptr l = new ptr(0); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%lld", l) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(l.Value == 1); + + ptr st = new ptr(0); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, IntPtr.Size == 4 ? "%d" : "%ld", st) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(st.Value == 1); + ptr bt = new ptr(0); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%d", bt) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(bt.Value == 1); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%d", zt) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(zt.Value == 1); + ptr et = new ptr(0); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%d", et) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(et.Value == 1); + + ptr flt = new ptr(0); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%lf", dbl) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(dbl.Value == 1.0); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%f", flt) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(flt.Value == 1.0); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%le", dbl) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(dbl.Value == 1.0); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%e", flt) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(flt.Value == 1.0); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%lg", dbl) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(dbl.Value == 1.0); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%g", flt) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(flt.Value == 1.0); + + System.IO.File.WriteAllText(pathname, "1.000000E+000"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%lE", dbl) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(dbl.Value == 1); + System.IO.File.WriteAllText(pathname, "1.000000E+000"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%E", flt) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(flt.Value == 1); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%lG", dbl) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(dbl.Value == 1); + System.IO.File.WriteAllText(pathname, "1"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%G", flt) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(flt.Value == 1); + + //System.IO.File.WriteAllText(pathname, "0x1.000000p+0"); + //_wfopen_s(out stream.Value.Value, pathname, "r"); + //Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%a", dbl) == 1); + //fclose(stream.Value.Value); + //Assert.IsTrue(dbl.Value == 1); + //System.IO.File.WriteAllText(pathname, "0x1.000000p+0"); + //_wfopen_s(out stream.Value.Value, pathname, "r"); + //Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%a", flt) == 1); + //fclose(stream.Value.Value); + //Assert.IsTrue(flt.Value == 1); + + System.IO.File.WriteAllText(pathname, "Hello World!"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + char_ptr str = new char_ptr("________________________"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%s", str) == 1); + fclose(stream.Value.Value); + Assert.IsTrue(str.ToString() == "Hello"); + gmp_lib.free(str); + + ptr p = new ptr(12); + System.IO.File.WriteAllText(pathname, "123456"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "123456%n", p) == 0); + fclose(stream.Value.Value); + Assert.IsTrue(p.Value == 6); + ptr ptr = new ptr(); + System.IO.File.WriteAllText(pathname, IntPtr.Size == 4 ? "0060F0F4" : "000000000060F0F4"); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%p", ptr) == 1); + fclose(stream.Value.Value); + Assert.IsTrue((UInt64)ptr.Value == 6353140); + + System.IO.File.Delete(pathname); + } + + [TestMethod] + public void gmp_sscanf() + { + mpz_t z = "0"; + mpq_t q = "0"; + mpf_t f = "0"; + ptr c = new ptr('0'); + ptr zt = new ptr(0); + ptr dbl = new ptr(0); + + Assert.IsTrue(gmp_lib.gmp_sscanf("123456 7B/1C8 1.234500e+10 A 10 1.000000", "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6); + + Assert.IsTrue(z.ToString() == "123456"); + Assert.IsTrue(q.ToString() == "123/456"); + Assert.IsTrue(f.ToString() == "0.12345e11"); + Assert.IsTrue(c.Value == 'A'); + Assert.IsTrue(zt.Value == 10); + Assert.IsTrue(dbl.Value == 1.0); + + Assert.IsTrue(gmp_lib.gmp_sscanf("123456", "%Zd", z) == 1); + Assert.IsTrue(z.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_sscanf("123456", "%Zi", z) == 1); + Assert.IsTrue(z.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_sscanf("1E240", "%ZX", z) == 1); + Assert.IsTrue(z.ToString() == "123456"); + Assert.IsTrue(gmp_lib.gmp_sscanf("361100", "%Zo", z) == 1); + Assert.IsTrue(z.ToString() == "123456"); + gmp_lib.mpz_clear(z); + + Assert.IsTrue(gmp_lib.gmp_sscanf("123/456", "%Qd", q) == 1); + Assert.IsTrue(q.ToString() == "123/456"); + Assert.IsTrue(gmp_lib.gmp_sscanf("123/456", "%Qi", q) == 1); + Assert.IsTrue(q.ToString() == "123/456"); + Assert.IsTrue(gmp_lib.gmp_sscanf("7B/1C8", "%QX", q) == 1); + Assert.IsTrue(q.ToString() == "123/456"); + Assert.IsTrue(gmp_lib.gmp_sscanf("173/710", "%Qo", q) == 1); + Assert.IsTrue(q.ToString() == "123/456"); + gmp_lib.mpq_clear(q); + + Assert.IsTrue(gmp_lib.gmp_sscanf("1.234500e+10", "%Fe", f) == 1); + Assert.IsTrue(f.ToString() == "0.12345e11"); + Assert.IsTrue(gmp_lib.gmp_sscanf("12345000000.000000", "%Ff", f) == 1); + Assert.IsTrue(f.ToString() == "0.12345e11"); + Assert.IsTrue(gmp_lib.gmp_sscanf("1.2345e+10", "%Fg", f) == 1); + Assert.IsTrue(f.ToString() == "0.12345e11"); + //Assert.IsTrue(gmp_lib.gmp_sscanf("0x2.dfd1c04p+32", "%Fa", f) == 1); + //Assert.IsTrue(f.ToString() == "0.12345e11"); + gmp_lib.mpf_clear(f); + + ptr s = new ptr(0); + Assert.IsTrue(gmp_lib.gmp_sscanf("1", "%hd", s) == 1); + Assert.IsTrue(s.Value == 1); + ptr b = new ptr(0); + Assert.IsTrue(gmp_lib.gmp_sscanf("1", "%hhd", b) == 1); + Assert.IsTrue(b.Value == 1); + Assert.IsTrue(gmp_lib.gmp_sscanf("A", "%hhc", c) == 1); + Assert.IsTrue(c.Value == 'A'); + ptr i = new ptr(0); + Assert.IsTrue(gmp_lib.gmp_sscanf("1", "%ld", i) == 1); + Assert.IsTrue(i.Value == 1); + ptr l = new ptr(0); + Assert.IsTrue(gmp_lib.gmp_sscanf("1", "%lld", l) == 1); + Assert.IsTrue(l.Value == 1); + + ptr st = new ptr(0); + Assert.IsTrue(gmp_lib.gmp_sscanf("1", IntPtr.Size == 4 ? "%d" : "%ld", st) == 1); + Assert.IsTrue(st.Value == 1); + ptr bt = new ptr(0); + Assert.IsTrue(gmp_lib.gmp_sscanf("1", "%d", bt) == 1); + Assert.IsTrue(bt.Value == 1); + Assert.IsTrue(gmp_lib.gmp_sscanf("1", "%d", zt) == 1); + Assert.IsTrue(zt.Value == 1); + ptr et = new ptr(0); + Assert.IsTrue(gmp_lib.gmp_sscanf("1", "%d", et) == 1); + Assert.IsTrue(et.Value == 1); + + ptr flt = new ptr(0); + Assert.IsTrue(gmp_lib.gmp_sscanf("1.000000", "%lf", dbl) == 1); + Assert.IsTrue(dbl.Value == 1.0); + Assert.IsTrue(gmp_lib.gmp_sscanf("1.000000", "%f", flt) == 1); + Assert.IsTrue(flt.Value == 1.0); + Assert.IsTrue(gmp_lib.gmp_sscanf("1.000000e+000", "%le", dbl) == 1); + Assert.IsTrue(dbl.Value == 1.0); + Assert.IsTrue(gmp_lib.gmp_sscanf("1.000000e+000", "%e", flt) == 1); + Assert.IsTrue(flt.Value == 1.0); + Assert.IsTrue(gmp_lib.gmp_sscanf("1", "%lg", dbl) == 1); + Assert.IsTrue(dbl.Value == 1.0); + Assert.IsTrue(gmp_lib.gmp_sscanf("1", "%g", flt) == 1); + Assert.IsTrue(flt.Value == 1.0); + + Assert.IsTrue(gmp_lib.gmp_sscanf("1.000000E+000", "%lE", dbl) == 1); + Assert.IsTrue(dbl.Value == 1); + Assert.IsTrue(gmp_lib.gmp_sscanf("1.000000E+000", "%E", flt) == 1); + Assert.IsTrue(flt.Value == 1); + Assert.IsTrue(gmp_lib.gmp_sscanf("1", "%lG", dbl) == 1); + Assert.IsTrue(dbl.Value == 1); + Assert.IsTrue(gmp_lib.gmp_sscanf("1", "%G", flt) == 1); + Assert.IsTrue(flt.Value == 1); + + //Assert.IsTrue(gmp_lib.gmp_sscanf("0x1.000000p+0", "%a", dbl) == 1); + //Assert.IsTrue(dbl.Value == 1); + //Assert.IsTrue(gmp_lib.gmp_sscanf("0x1.000000p+0", "%a", flt) == 1); + //Assert.IsTrue(flt.Value == 1); + + char_ptr str = new char_ptr("________________________"); + Assert.IsTrue(gmp_lib.gmp_sscanf("Hello World!", "%s", str) == 1); + Assert.IsTrue(str.ToString() == "Hello"); + gmp_lib.free(str); + + ptr p = new ptr(12); + Assert.IsTrue(gmp_lib.gmp_sscanf("123456", "123456%n", p) == 0); + Assert.IsTrue(p.Value == 6); + ptr ptr = new ptr(); + Assert.IsTrue(gmp_lib.gmp_sscanf(IntPtr.Size == 4 ? "0060F0F4" : "000000000060F0F4", "%p", ptr) == 1); + Assert.IsTrue((UInt64)ptr.Value == 6353140); + } + + #endregion + + #region "Integer (i.e. Z) routines." + + [TestMethod] + public void _mpz_realloc() + { + // Create and initialize new integer x. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + + // Set the value of x to a 77-bit integer. + char_ptr value = new char_ptr("1000 0000 0000 0000 0000"); + gmp_lib.mpz_set_str(x, value, 16); + + // Resize x to 50 limbs, and assert that its value has not changed. + gmp_lib._mpz_realloc(x, 50); + char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 16, x); + Assert.IsTrue(s.ToString() == "1000 0000 0000 0000 0000".Replace(" ", "")); + + // Resize x to 1 limb, and assert that its value has changed to 0. + gmp_lib._mpz_realloc(x, 1); + Assert.IsTrue(gmp_lib.mpz_get_si(x) == 0); + + // Release unmanaged memory allocated for x and string values. + gmp_lib.mpz_clear(x); + gmp_lib.free(value); + gmp_lib.free(s); + } + + [TestMethod] + public void mpz_abs() + { + // Create, initialize, and set the value of x to -10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_si(x, -10000); + + // Create, initialize, and set the value of z to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = |x|. + gmp_lib.mpz_abs(z, x); + + // Assert that z is |x|. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == 10000); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpz_clears(x, z, null); + } + + [TestMethod] + public void mpz_add() + { + // Create, initialize, and set the value of x to 10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10000U); + + // Create, initialize, and set the value of y to 12222. + mpz_t y = new mpz_t(); + gmp_lib.mpz_init_set_ui(y, 12222U); + + // Create, initialize, and set the value of z to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = x + y. + gmp_lib.mpz_add(z, x, y); + + // Assert that z is the sum of x and y. + Assert.IsTrue(gmp_lib.mpz_get_ui(z) == 22222U); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpz_clears(x, y, z, null); + } + + [TestMethod] + public void mpz_add_ui() + { + // Create, initialize, and set the value of x to 0. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + + // Increment x twice by 101999. + gmp_lib.mpz_add_ui(x, x, 101999U); + gmp_lib.mpz_add_ui(x, x, 101999U); + + // Assert that x is 203998. + Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 203998U); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_addmul() + { + // Create, initialize, and set the value of x to 10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10000U); + + // Create, initialize, and set the value of y to 12222. + mpz_t y = new mpz_t(); + gmp_lib.mpz_init_set_ui(y, 12222U); + + // Create, initialize, and set the value of z to 20000. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init_set_ui(z, 20000U); + + // Set z += x * y. + gmp_lib.mpz_addmul(z, x, y); + + // Assert that z has been incremented by 10000 * 12222. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000U + 10000 * 12222); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpz_clears(x, y, z, null); + } + + [TestMethod] + public void mpz_addmul_ui() + { + // Create, initialize, and set the value of x to -10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_si(x, -10000); + + // Create, initialize, and set the value of z to 20000. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init_set_si(z, 20000); + + // Set z += x * 12222. + gmp_lib.mpz_addmul_ui(z, x, 12222U); + + // Assert that z has been incremented by -10000 * 12222. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000 + -10000 * 12222); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpz_clears(x, z, null); + } + + [TestMethod] + public void mpz_and() + { + // Create, initialize, and set the value of op1 to 63. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op1, 63U); + + // Create, initialize, and set the value of op2 to 70. + mpz_t op2 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op2, 70U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop to the bitwise and of op1 and op2. + gmp_lib.mpz_and(rop, op1, op2); + + // Assert that rop is 6. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6); + + // Release unmanaged memory allocated for rop, op1, and op2. + gmp_lib.mpz_clears(rop, op1, op2, null); + } + + [TestMethod] + public void mpz_bin_ui() + { + // Create, initialize, and set the value of n to 4. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 4); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop to the binomial coefficient (n:2). + gmp_lib.mpz_bin_ui(rop, n, 2U); + + // Assert that rop is 6. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6); + + // Release unmanaged memory allocated for n and rop. + gmp_lib.mpz_clears(n, rop, null); + } + + [TestMethod] + public void mpz_bin_uiui() + { + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop to the binomial coefficient (4:2). + gmp_lib.mpz_bin_uiui(rop, 4U, 2U); + + // Assert that rop is 6. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6); + + // Release unmanaged memory allocated for rop. + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_cdiv_q() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of d to 3. + mpz_t d = new mpz_t(); + gmp_lib.mpz_init_set_si(d, 3); + + // Create, initialize, and set the value of q to 0. + mpz_t q = new mpz_t(); + gmp_lib.mpz_init(q); + + // Set q = ceiling(n / d). + gmp_lib.mpz_cdiv_q(q, n, d); + + // Assert that q is ceiling(10000 / 3). + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334); + + // Release unmanaged memory allocated for n, d, and q. + gmp_lib.mpz_clears(n, d, q, null); + } + + [TestMethod] + public void mpz_cdiv_q_2exp() + { + // Create, initialize, and set the value of n to 10001. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10001); + + // Create, initialize, and set the value of q to 0. + mpz_t q = new mpz_t(); + gmp_lib.mpz_init(q); + + // Set q = ceiling(n / 2^2). + gmp_lib.mpz_cdiv_q_2exp(q, n, 2U); + + // Assert that q is ceiling(10001 / 4). + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 2501); + + // Release unmanaged memory allocated for n and q. + gmp_lib.mpz_clears(n, q, null); + } + + [TestMethod] + public void mpz_cdiv_q_ui() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of q to 0. + mpz_t q = new mpz_t(); + gmp_lib.mpz_init(q); + + // Set q = ceiling(n / 3) and return r = n - 3 * q. + // Assert q and r values. + Assert.IsTrue(gmp_lib.mpz_cdiv_q_ui(q, n, 3U) == 2U); + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334); + + // Release unmanaged memory allocated for n and q. + gmp_lib.mpz_clears(n, q, null); + } + + [TestMethod] + public void mpz_cdiv_qr() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of d to 3. + mpz_t d = new mpz_t(); + gmp_lib.mpz_init_set_si(d, 3); + + // Create, initialize, and set the values of q and r to 0. + mpz_t q = new mpz_t(); + mpz_t r = new mpz_t(); + gmp_lib.mpz_inits(q, r, null); + + // Set q = ceiling(n / 3) and r = n - d * q. + gmp_lib.mpz_cdiv_qr(q, r, n, d); + + // Assert that q is 3334, and that r is -2. + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334); + Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2); + + // Release unmanaged memory allocated for n, d, q, and r. + gmp_lib.mpz_clears(n, d, q, r, null); + } + + [TestMethod] + public void mpz_cdiv_qr_ui() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the values of q and r to 0. + mpz_t q = new mpz_t(); + mpz_t r = new mpz_t(); + gmp_lib.mpz_inits(q, r, null); + + // Set q = ceiling(n / 3), r = n - d * q, and return r. + Assert.IsTrue(gmp_lib.mpz_cdiv_qr_ui(q, r, n, 3U) == 2U); + + // Assert that q is 3334, and that r is -2. + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334); + Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2); + + // Release unmanaged memory allocated for n, q, and r. + gmp_lib.mpz_clears(n, q, r, null); + } + + [TestMethod] + public void mpz_cdiv_r() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of d to 3. + mpz_t d = new mpz_t(); + gmp_lib.mpz_init_set_si(d, 3); + + // Create, initialize, and set the value of r to 0. + mpz_t r = new mpz_t(); + gmp_lib.mpz_init(r); + + // Set r = n - d * ceiling(n / d). + gmp_lib.mpz_cdiv_r(r, n, d); + + // Assert that r is -2. + Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2); + + // Release unmanaged memory allocated for n, d, and r. + gmp_lib.mpz_clears(n, d, r, null); + } + + [TestMethod] + public void mpz_cdiv_r_2exp() + { + // Create, initialize, and set the value of n to 10001. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10001); + + // Create, initialize, and set the value of r to 0. + mpz_t r = new mpz_t(); + gmp_lib.mpz_init(r); + + // Set r = n - 2^2 * ceiling(n / 2^2) + gmp_lib.mpz_cdiv_r_2exp(r, n, 2U); + + // Assert that r is -3. + Assert.IsTrue(gmp_lib.mpz_get_si(r) == -3); + + // Release unmanaged memory allocated for n and r. + gmp_lib.mpz_clears(n, r, null); + } + + [TestMethod] + public void mpz_cdiv_r_ui() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of r to 0. + mpz_t r = new mpz_t(); + gmp_lib.mpz_init(r); + + // Set r = n - 3 * ceiling(n / 3), and return |r|. + Assert.IsTrue(gmp_lib.mpz_cdiv_r_ui(r, n, 3U) == 2U); + + // Assert that r is -2. + Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2); + + // Release unmanaged memory allocated for n and r. + gmp_lib.mpz_clears(n, r, null); + } + + [TestMethod] + public void mpz_cdiv_ui() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Assert that returned value is |n - 3 * ceiling(n / 3)|. + Assert.IsTrue(gmp_lib.mpz_cdiv_ui(n, 3U) == 2U); + + // Release unmanaged memory allocated for n. + gmp_lib.mpz_clear(n); + } + + [TestMethod] + public void mpz_clear() + { + // Create and initialize a new integer x. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + + // Assert that the value of x is 0. + Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 0U); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_clears() + { + // Create new integers x1, x2 and x3. + mpz_t x1 = new mpz_t(); + mpz_t x2 = new mpz_t(); + mpz_t x3 = new mpz_t(); + + // Initialize the integers. + gmp_lib.mpz_inits(x1, x2, x3, null); + + // Assert that their value is 0. + Assert.IsTrue(gmp_lib.mpz_get_si(x1) == 0); + Assert.IsTrue(gmp_lib.mpz_get_si(x2) == 0); + Assert.IsTrue(gmp_lib.mpz_get_si(x3) == 0); + + // Release unmanaged memory allocated for the integers. + gmp_lib.mpz_clears(x1, x2, x3, null); + } + + [TestMethod] + public void mpz_clrbit() + { + // Create, initialize, and set the value of rop to 70. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init_set_si(rop, 70); + + // Clear bit 3 of rop. + gmp_lib.mpz_clrbit(rop, 3U); + + // Assert that rop is 70. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 70); + + // Release unmanaged memory allocated for rop. + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_cmp() + { + // Create, initialize, and set the value of op1 to 63. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op1, 63U); + + // Create, initialize, and set the value of op2 to 70. + mpz_t op2 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op2, 70U); + + // Assert that op1 < op2. + Assert.IsTrue(gmp_lib.mpz_cmp(op1, op2) < 0); + + // Release unmanaged memory allocated for op1 and op2. + gmp_lib.mpz_clears(op1, op2, null); + } + + [TestMethod] + public void mpz_cmp_d() + { + // Create, initialize, and set the value of op1 to 63. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op1, 63U); + + // Assert that op1 < 70.0. + Assert.IsTrue(gmp_lib.mpz_cmp_d(op1, 70.0) < 0); + + // Release unmanaged memory allocated for op1. + gmp_lib.mpz_clear(op1); + } + + [TestMethod] + public void mpz_cmp_si() + { + // Create, initialize, and set the value of op1 to 63. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op1, 63U); + + // Assert that op1 < 70. + Assert.IsTrue(gmp_lib.mpz_cmp_si(op1, 70) < 0); + + // Release unmanaged memory allocated for op1. + gmp_lib.mpz_clear(op1); + } + + [TestMethod] + public void mpz_cmp_ui() + { + // Create, initialize, and set the value of op1 to 63. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op1, 63U); + + // Assert that op1 < 70. + Assert.IsTrue(gmp_lib.mpz_cmp_ui(op1, 70U) < 0); + + // Release unmanaged memory allocated for op1. + gmp_lib.mpz_clear(op1); + } + + [TestMethod] + public void mpz_cmpabs() + { + // Create, initialize, and set the value of op1 to -63. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_si(op1, -63); + + // Create, initialize, and set the value of op2 to 70. + mpz_t op2 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op2, 70U); + + // Assert that |op1| < |op2|. + Assert.IsTrue(gmp_lib.mpz_cmp(op1, op2) < 0); + + // Release unmanaged memory allocated for op1 and op2. + gmp_lib.mpz_clears(op1, op2, null); + } + + [TestMethod] + public void mpz_cmpabs_d() + { + // Create, initialize, and set the value of op1 to -63. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_si(op1, -63); + + // Assert that |op1| < |-70.0|. + Assert.IsTrue(gmp_lib.mpz_cmpabs_d(op1, -70.0) < 0); + + // Release unmanaged memory allocated for op1. + gmp_lib.mpz_clear(op1); + } + + [TestMethod] + public void mpz_cmpabs_ui() + { + // Create, initialize, and set the value of op1 to -63. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_si(op1, -63); + + // Assert that |op1| < |70|. + Assert.IsTrue(gmp_lib.mpz_cmpabs_ui(op1, 70U) < 0); + + // Release unmanaged memory allocated for op1. + gmp_lib.mpz_clear(op1); + } + + [TestMethod] + public void mpz_com() + { + // Create, initialize, and set the value of op to 63. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, 63U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop to the one's complement of op. + gmp_lib.mpz_com(rop, op); + + // Assert that rop is -64. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == -64); + + // Release unmanaged memory allocated for rop and op. + gmp_lib.mpz_clears(rop, op, null); + } + + [TestMethod] + public void mpz_combit() + { + // Create, initialize, and set the value of rop to 70. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init_set_si(rop, 70); + + // Complement bit 3 of rop. + gmp_lib.mpz_combit(rop, 3U); + + // Assert that rop is 78. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 78); + + // Release unmanaged memory allocated for rop. + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_congruent_p() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_ui(n, 10000U); + + // Create, initialize, and set the value of d to 3. + mpz_t d = new mpz_t(); + gmp_lib.mpz_init_set_ui(d, 3U); + + // Create, initialize, and set the value of c to 1. + mpz_t c = new mpz_t(); + gmp_lib.mpz_init_set_ui(c, 1U); + + // Assert that n is congruent to c mod d. + Assert.IsTrue(gmp_lib.mpz_congruent_p(n, c, d) > 0); + + // Release unmanaged memory allocated for n, d, and c. + gmp_lib.mpz_clears(n, d, c, null); + } + + [TestMethod] + public void mpz_congruent_2exp_p() + { + // Create, initialize, and set the value of n to 10001. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_ui(n, 10001U); + + // Create, initialize, and set the value of b to 1. + mpz_t c = new mpz_t(); + gmp_lib.mpz_init_set_ui(c, 1U); + + // Assert that n is congruent to c mod 2^3. + Assert.IsTrue(gmp_lib.mpz_congruent_2exp_p(n, c, 3U) > 0); + + // Release unmanaged memory allocated for n and c. + gmp_lib.mpz_clears(n, c, null); + } + + [TestMethod] + public void mpz_congruent_ui_p() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_ui(n, 10000U); + + // Assert that n is congruent to 1 mod 3. + Assert.IsTrue(gmp_lib.mpz_congruent_ui_p(n, 1U, 3U) > 0); + + // Release unmanaged memory allocated for n. + gmp_lib.mpz_clear(n); + } + + [TestMethod] + public void mpz_divexact() + { + // Create, initialize, and set the value of x to 10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10000U); + + // Create, initialize, and set the value of y to 5. + mpz_t y = new mpz_t(); + gmp_lib.mpz_init_set_ui(y, 5U); + + // Create, initialize, and set the value of z to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = x / y. + gmp_lib.mpz_divexact(z, x, y); + + // Assert that z is 2000. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == 2000); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpz_clears(x, y, z, null); + } + + [TestMethod] + public void mpz_divexact_ui() + { + // Create, initialize, and set the value of x to 10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10000U); + + // Create, initialize, and set the value of z to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = x / 5. + gmp_lib.mpz_divexact_ui(z, x, 5U); + + // Assert that z is 2000. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == 2000); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpz_clears(x, z, null); + } + + [TestMethod] + public void mpz_divisible_p() + { + // Create, initialize, and set the value of x to 10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10000U); + + // Create, initialize, and set the value of y to 5. + mpz_t y = new mpz_t(); + gmp_lib.mpz_init_set_ui(y, 5U); + + // Assert that x is divisible by y. + Assert.IsTrue(gmp_lib.mpz_divisible_p(x, y) > 0); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpz_clears(x, y, null); + } + + [TestMethod] + public void mpz_divisible_ui_p() + { + // Create, initialize, and set the value of x to 10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10000U); + + // Assert that x is divisible by 5. + Assert.IsTrue(gmp_lib.mpz_divisible_ui_p(x, 5U) > 0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_divisible_2exp_p() + { + // Create, initialize, and set the value of x to 10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10000U); + + Assert.IsTrue(gmp_lib.mpz_divisible_2exp_p(x, 2U) > 0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_even() + { + // Create, initialize, and set the value of op to 427295. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, 427295); + + // Assert that op is not even but odd. + Assert.IsTrue(gmp_lib.mpz_even_p(op) == 0); + Assert.IsTrue(gmp_lib.mpz_odd_p(op) > 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_export() + { + // Create, initialize, and set the value of op to 0x800000000000000000000001. + mpz_t op = new mpz_t(); + char_ptr value = new char_ptr("800000000000000000000001"); + gmp_lib.mpz_init_set_str(op, value, 16); + + // Export op as 3 words of 4 bytes each, first word is lsb, and first byte in each word is msb. + void_ptr data = gmp_lib.allocate(12); + size_t countp = 0; + gmp_lib.mpz_export(data, ref countp, -1, 4, 1, 0, op); + + // Assert the result. + byte[] result = new byte[12]; + Marshal.Copy(data.ToIntPtr(), result, 0, 12); + Assert.IsTrue(result[0] == 0x00); + Assert.IsTrue(result[1] == 0x00); + Assert.IsTrue(result[2] == 0x00); + Assert.IsTrue(result[3] == 0x01); + Assert.IsTrue(result[4] == 0x00); + Assert.IsTrue(result[5] == 0x00); + Assert.IsTrue(result[6] == 0x00); + Assert.IsTrue(result[7] == 0x00); + Assert.IsTrue(result[8] == 0x80); + Assert.IsTrue(result[9] == 0x00); + Assert.IsTrue(result[10] == 0x00); + Assert.IsTrue(result[11] == 0x00); + + // Release unmanaged memory allocated for rop, data, and value. + gmp_lib.mpz_clear(op); + gmp_lib.free(data); + gmp_lib.free(value); + } + + [TestMethod] + public void mpz_fac_ui() + { + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop = 3!. + gmp_lib.mpz_fac_ui(rop, 3U); + + // Assert that rop is 6. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6); + + // Release unmanaged memory allocated for rop. + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_2fac_ui() + { + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop = 9!!. + gmp_lib.mpz_2fac_ui(rop, 9U); + + // Assert that rop is 945. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 945); + + // Release unmanaged memory allocated for rop. + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_mfac_uiui() + { + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop = 10!^(4). + gmp_lib.mpz_mfac_uiui(rop, 10U, 4U); + + // Assert that rop is 945. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 120); + + // Release unmanaged memory allocated for rop. + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_primorial_ui() + { + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop = 7 * 5 * 3 * 2 = 210. + gmp_lib.mpz_primorial_ui(rop, 9U); + + // Assert that rop is 210. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 210); + + // Release unmanaged memory allocated for rop. + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_fdiv_q() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of d to 3. + mpz_t d = new mpz_t(); + gmp_lib.mpz_init_set_si(d, 3); + + // Create, initialize, and set the value of q to 0. + mpz_t q = new mpz_t(); + gmp_lib.mpz_init(q); + + // Set q = floor(n / d). + gmp_lib.mpz_fdiv_q(q, n, d); + + // Assert that q is floor(10000 / 3). + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + + // Release unmanaged memory allocated for n, d, and q. + gmp_lib.mpz_clears(n, d, q, null); + } + + [TestMethod] + public void mpz_fdiv_q_2exp() + { + // Create, initialize, and set the value of n to 10001. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10001); + + // Create, initialize, and set the value of q to 0. + mpz_t q = new mpz_t(); + gmp_lib.mpz_init(q); + + // Set q = floor(n / 2^2). + gmp_lib.mpz_fdiv_q_2exp(q, n, 2U); + + // Assert that q is floor(10001 / 4). + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 2500); + + // Release unmanaged memory allocated for n and q. + gmp_lib.mpz_clears(n, q, null); + } + + [TestMethod] + public void mpz_fdiv_q_ui() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of q to 0. + mpz_t q = new mpz_t(); + gmp_lib.mpz_init(q); + + // Set q = floor(n / 3) and return r = n - 3 * q. + // Assert q and r values. + Assert.IsTrue(gmp_lib.mpz_fdiv_q_ui(q, n, 3U) == 1U); + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + + // Release unmanaged memory allocated for n and q. + gmp_lib.mpz_clears(n, q, null); + } + + [TestMethod] + public void mpz_fdiv_qr() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of d to 3. + mpz_t d = new mpz_t(); + gmp_lib.mpz_init_set_si(d, 3); + + // Create, initialize, and set the values of q and r to 0. + mpz_t q = new mpz_t(); + mpz_t r = new mpz_t(); + gmp_lib.mpz_inits(q, r, null); + + // Set q = floor(n / 3) and r = n - d * q. + gmp_lib.mpz_fdiv_qr(q, r, n, d); + + // Assert that q is 3333, and that r is 1. + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + + // Release unmanaged memory allocated for n, d, q, and r. + gmp_lib.mpz_clears(n, d, q, r, null); + } + + [TestMethod] + public void mpz_fdiv_qr_ui() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the values of q and r to 0. + mpz_t q = new mpz_t(); + mpz_t r = new mpz_t(); + gmp_lib.mpz_inits(q, r, null); + + // Set q = floor(n / 3), r = n - d * q, and return r. + Assert.IsTrue(gmp_lib.mpz_fdiv_qr_ui(q, r, n, 3U) == 1U); + + // Assert that q is 3333, and that r is 1. + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + + // Release unmanaged memory allocated for n, q, and r. + gmp_lib.mpz_clears(n, q, r, null); + } + + [TestMethod] + public void mpz_fdiv_r() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of d to 3. + mpz_t d = new mpz_t(); + gmp_lib.mpz_init_set_si(d, 3); + + // Create, initialize, and set the value of r to 0. + mpz_t r = new mpz_t(); + gmp_lib.mpz_init(r); + + // Set r = n - d * floor(n / d). + gmp_lib.mpz_fdiv_r(r, n, d); + + // Assert that r is 1. + Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + + // Release unmanaged memory allocated for n, d, and r. + gmp_lib.mpz_clears(n, d, r, null); + } + + [TestMethod] + public void mpz_fdiv_r_2exp() + { + // Create, initialize, and set the value of n to 10001. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10001); + + // Create, initialize, and set the value of r to 0. + mpz_t r = new mpz_t(); + gmp_lib.mpz_init(r); + + // Set r = n - 2^2 * floor(n / 2^2) + gmp_lib.mpz_fdiv_r_2exp(r, n, 2U); + + // Assert that r is 1. + Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + + // Release unmanaged memory allocated for n and r. + gmp_lib.mpz_clears(n, r, null); + } + + [TestMethod] + public void mpz_fdiv_r_ui() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of r to 0. + mpz_t r = new mpz_t(); + gmp_lib.mpz_init(r); + + // Set r = n - 3 * floor(n / 3), and return |r|. + Assert.IsTrue(gmp_lib.mpz_fdiv_r_ui(r, n, 3U) == 1U); + + // Assert that r is 1. + Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + + // Release unmanaged memory allocated for n and r. + gmp_lib.mpz_clears(n, r, null); + } + + [TestMethod] + public void mpz_fdiv_ui() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Assert that returned value is |n - 3 * floor(n / 3)|. + Assert.IsTrue(gmp_lib.mpz_fdiv_ui(n, 3U) == 1U); + + // Release unmanaged memory allocated for n. + gmp_lib.mpz_clear(n); + } + + [TestMethod] + public void mpz_fib_ui() + { + // Create, initialize, and set the value of fn to 0. + mpz_t fn = new mpz_t(); + gmp_lib.mpz_init(fn); + + // Set fn to the n'th Fibonacci number. + gmp_lib.mpz_fib_ui(fn, 20U); + + // Assert that fn is 6765. + Assert.IsTrue(gmp_lib.mpz_get_si(fn) == 6765); + + // Release unmanaged memory allocated for fn. + gmp_lib.mpz_clear(fn); + } + + [TestMethod] + public void mpz_fib2_ui() + { + // Create, initialize, and set the values of fn and fnsub1 to 0. + mpz_t fn = new mpz_t(); + mpz_t fnsub1 = new mpz_t(); + gmp_lib.mpz_inits(fn, fnsub1, null); + + // Set fnsub1 and fn to the 19'th and 20'th Fibonacci numbers respectively. + gmp_lib.mpz_fib2_ui(fn, fnsub1, 20U); + + // Assert that fnsub1 and fn are respectively 4181 and 6765. + Assert.IsTrue(gmp_lib.mpz_get_si(fnsub1) == 4181); + Assert.IsTrue(gmp_lib.mpz_get_si(fn) == 6765); + + // Release unmanaged memory allocated for fn and fnsub1. + gmp_lib.mpz_clears(fn, fnsub1, null); + } + + [TestMethod] + public void mpz_fits_sint_p() + { + // Create, initialize, and set the value of op 4294967295. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, uint.MaxValue); + + // Assert that op does not fit in int. + Assert.IsTrue(gmp_lib.mpz_fits_sint_p(op) == 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_fits_slong_p() + { + // Create, initialize, and set the value of op 4294967295. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, uint.MaxValue); + + // Assert that op does not fit in long. + Assert.IsTrue(gmp_lib.mpz_fits_slong_p(op) == 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_fits_sshort_p() + { + // Create, initialize, and set the value of op 4294967295. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, uint.MaxValue); + + // Assert that op does not fit in short. + Assert.IsTrue(gmp_lib.mpz_fits_sshort_p(op) == 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_fits_uint_p() + { + // Create, initialize, and set the value of op 4294967295. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, uint.MaxValue); + + // Assert that op does not fit in uint. + Assert.IsTrue(gmp_lib.mpz_fits_uint_p(op) > 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_fits_ulong_p() + { + // Create, initialize, and set the value of op 4294967295. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, uint.MaxValue); + + // Assert that op fits in ulong. + Assert.IsTrue(gmp_lib.mpz_fits_ulong_p(op) > 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_fits_ushort_p() + { + // Create, initialize, and set the value of op 4294967295. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, uint.MaxValue); + + // Assert that op does not fit in ushort. + Assert.IsTrue(gmp_lib.mpz_fits_ushort_p(op) == 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_gcd() + { + // Create, initialize, and set the value of op1 to 63. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op1, 63U); + + // Create, initialize, and set the value of op2 to 70. + mpz_t op2 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op2, 70U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop to the greatest common divisor of op1 and op2. + gmp_lib.mpz_gcd(rop, op1, op2); + + // Assert that rop is 7. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 7); + + // Release unmanaged memory allocated for rop, op1, and op2. + gmp_lib.mpz_clears(rop, op1, op2, null); + } + + [TestMethod] + public void mpz_gcd_ui() + { + // Create, initialize, and set the value of op1 to 63. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op1, 63U); + + // Return the greatest common divisor of op1 and 70. + Assert.IsTrue(gmp_lib.mpz_gcd_ui(null, op1, 70U) == 7); + + // Release unmanaged memory allocated for op1. + gmp_lib.mpz_clear(op1); + } + + [TestMethod] + public void mpz_gcdext() + { + // Create, initialize, and set the value of op1 to 63. + mpz_t a = new mpz_t(); + gmp_lib.mpz_init_set_ui(a, 63U); + + // Create, initialize, and set the value of op2 to 70. + mpz_t b = new mpz_t(); + gmp_lib.mpz_init_set_ui(b, 70U); + + // Create, initialize, and set the values of g, s, and t to 0. + mpz_t g = new mpz_t(); + mpz_t s = new mpz_t(); + mpz_t t = new mpz_t(); + gmp_lib.mpz_inits(g, s, t, null); + + // Set g to the the greatest common divisor of a and b, and set s and t such that a * s + b * t = g. + gmp_lib.mpz_gcdext(g, s, t, a, b); + + // Assert that g is 7, and that s and t are respectively -1 and 1. + Assert.IsTrue(gmp_lib.mpz_get_si(g) == 7); + Assert.IsTrue(gmp_lib.mpz_get_si(s) == -1); + Assert.IsTrue(gmp_lib.mpz_get_si(t) == 1); + + // Release unmanaged memory allocated for g, s, t, a, and b. + gmp_lib.mpz_clears(g, s, t, a, b, null); + } + + [TestMethod] + public void mpz_get_d() + { + // Create, initialize, and set the value of x to 10. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_d(x, 10.7D); + + // Assert that the value of x is 10.0. + Assert.IsTrue(gmp_lib.mpz_get_d(x) == 10.0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_get_d_2exp() + { + // Create, initialize, and set the value of x to 2^20. + mpz_t x = new mpz_t(); + char_ptr value = new char_ptr("100000000000000000000"); + gmp_lib.mpz_init_set_str(x, value, 2); + + // Assert that x is equal to 0.5^21. + int exp = 0; + Assert.IsTrue(gmp_lib.mpz_get_d_2exp(ref exp, x) == 0.5D); + Assert.IsTrue(exp == 21); + + // Release unmanaged memory allocated for x and the string value. + gmp_lib.mpz_clear(x); + gmp_lib.free(value); + } + + [TestMethod] + public void mpz_get_si() + { + // Create, initialize, and set the value of x to -10. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_si(x, -10); + + // Retrieve the value of x, and assert that it is -10. + Assert.IsTrue(gmp_lib.mpz_get_si(x) == -10); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_get_str() + { + // Create, initialize, and set the value of x to -210. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_si(x, -210); + + // Retrieve the string value of x, and assert that it is "-210". + char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x); + Assert.IsTrue(s.ToString() == "-210"); + + // Release unmanaged memory allocated for x and the string value. + gmp_lib.mpz_clear(x); + gmp_lib.free(s); + } + + [TestMethod] + public void mpz_get_ui() + { + // Create, initialize, and set the value of x to 10. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10U); + + // Retrieve the value of x, and assert that it is 10. + Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 10U); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_getlimbn() + { + // Create and initialize new integer x. + mpz_t op = new mpz_t(); + char_ptr value = new char_ptr("1000 ABCD 1234 7AB8 24FD"); + gmp_lib.mpz_init_set_str(op, value, 16); + + // Assert the value of the limbs of op. + if (gmp_lib.mp_bytes_per_limb == 4) + { + Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 0) == 0x7AB824FD); + Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 1) == 0xABCD1234); + Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 2) == 0x00001000); + } + else // gmp_lib.mp_bytes_per_limb == 8 + { + Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 0) == 0xABCD12347AB824FD); + Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 1) == 0x0000000000001000); + } + + // Release unmanaged memory allocated for op and value. + gmp_lib.mpz_clear(op); + gmp_lib.free(value); + } + + [TestMethod] + public void mpz_hamdist() + { + // Create, initialize, and set the value of op1 to 63. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op1, 63U); + + // Create, initialize, and set the value of op2 to 70. + mpz_t op2 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op2, 70U); + + // Assert that the Hamming distance between op1 and op2 is 5. + Assert.IsTrue(gmp_lib.mpz_hamdist(op1, op2) == 5U); + + // Release unmanaged memory allocated for op1 and op2. + gmp_lib.mpz_clears(op1, op2, null); + } + + [TestMethod] + public void mpz_import() + { + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Copy 0x800000000000000000000001, 3 words of 4 bytes each, first word is lsb, and first byte in each word is msb. + void_ptr data = gmp_lib.allocate(12); + Marshal.Copy(new byte[] { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 }, 0, data.ToIntPtr(), 12); + + // Import value into rop. + gmp_lib.mpz_import(rop, 3, -1, 4, 1, 0, data); + + // Assert the value of rop. + char_ptr value = gmp_lib.mpz_get_str(char_ptr.Zero, 16, rop); + Assert.IsTrue(value.ToString() == "800000000000000000000001"); + + // Release unmanaged memory allocated for rop, data, and value. + gmp_lib.mpz_clear(rop); + gmp_lib.free(data); + gmp_lib.free(value); + } + + [TestMethod] + public void mpz_init() + { + // Create and initialize a new integer x. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + + // Assert that the value of x is 0. + char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x); + Assert.IsTrue(s.ToString() == "0"); + + // Release unmanaged memory allocated for x and its string value. + gmp_lib.mpz_clear(x); + gmp_lib.free(s); + } + + [TestMethod] + public void mpz_init2() + { + // Create a new integer x, and initialize its size to 300 bits. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init2(x, 300); + + // Assert that the value of x is 0. + Assert.IsTrue(gmp_lib.mpz_get_si(x) == 0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_inits() + { + // Create new integers x1, x2 and x3. + mpz_t x1 = new mpz_t(); + mpz_t x2 = new mpz_t(); + mpz_t x3 = new mpz_t(); + + // Initialize the integers. + gmp_lib.mpz_inits(x1, x2, x3, null); + + // Assert that their value is 0. + Assert.IsTrue(gmp_lib.mpz_get_si(x1) == 0); + Assert.IsTrue(gmp_lib.mpz_get_si(x2) == 0); + Assert.IsTrue(gmp_lib.mpz_get_si(x3) == 0); + + // Release unmanaged memory allocated for the integers. + gmp_lib.mpz_clears(x1, x2, x3, null); + } + + [TestMethod] + public void mpz_init_set() + { + // Create, initialize, and set a new integer y to -210. + mpz_t y = new mpz_t(); + gmp_lib.mpz_init(y); + gmp_lib.mpz_set_si(y, -210); + + // Create, initialize, and set a new integer x to the value of y. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set(x, y); + + // Assert that x is equal to the value of y. + Assert.IsTrue(gmp_lib.mpz_get_si(x) == -210); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpz_clears(x, y, null); + } + + [TestMethod] + public void mpz_init_set_d() + { + // Create, initialize, and set the value of x to the truncation of 10.7. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_d(x, 10.7D); + + // Assert that the value of x is 10. + Assert.IsTrue(gmp_lib.mpz_get_si(x) == 10); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_init_set_si() + { + // Create, initialize, and set the value of x to 10. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_si(x, 10); + + // Assert that the value of x is 10. + Assert.IsTrue(gmp_lib.mpz_get_si(x) == 10); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_init_set_str() + { + // Create, initialize, and set the value of x. + mpz_t x = new mpz_t(); + char_ptr value = new char_ptr(" 1 234 567 890 876 543 211 234 567 890 987 654 321 "); + gmp_lib.mpz_init_set_str(x, value, 10); + + // Assert the value of x. + char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x); + Assert.IsTrue(s.ToString() == value.ToString().Replace(" ", "")); + + // Release unmanaged memory allocated for x and string values. + gmp_lib.mpz_clear(x); + gmp_lib.free(value); + gmp_lib.free(s); + } + + [TestMethod] + public void mpz_init_set_ui() + { + // Create, initialize, and set the value of x to 10. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10U); + + // Assert that the value of x is 10. + Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 10U); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_inp_raw() + { + // Create, initialize, and set the value of op to 123456. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, 123456U); + + // Write op to a temporary file. + string pathname = System.IO.Path.GetTempFileName(); + ptr stream = new ptr(); + _wfopen_s(out stream.Value.Value, pathname, "w"); + Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) == 7); + fclose(stream.Value.Value); + + // Read op from the temporary file, and assert that the number of bytes read is 6. + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.mpz_inp_raw(op, stream) == 7); + fclose(stream.Value.Value); + + // Assert that op is 123456. + Assert.IsTrue(gmp_lib.mpz_get_ui(op) == 123456U); + + // Delete temporary file. + System.IO.File.Delete(pathname); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_inp_str() + { + // Create and initialize op. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init(op); + + // Write op to a temporary file. + string pathname = System.IO.Path.GetTempFileName(); + System.IO.File.WriteAllText(pathname, "123456"); + + // Read op from the temporary file, and assert that the number of bytes read is 6. + ptr stream = new ptr(); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.mpz_inp_str(op, stream, 10) == 6); + fclose(stream.Value.Value); + + // Assert that op is 123456. + Assert.IsTrue(gmp_lib.mpz_get_ui(op) == 123456U); + + // Delete temporary file. + System.IO.File.Delete(pathname); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_invert() + { + // Create, initialize, and set the value of op1 to 3. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op1, 3U); + + // Create, initialize, and set the value of op2 to 11. + mpz_t op2 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op2, 11U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop to the modular inverse of op1 mod op2, i.e. b, where op1 * b mod op1 = 1. + gmp_lib.mpz_invert(rop, op1, op2); + + // Assert that rop is 4, + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 4); + + // Release unmanaged memory allocated for rop, op1, and op2. + gmp_lib.mpz_clears(rop, op1, op2, null); + } + + [TestMethod] + public void mpz_ior() + { + // Create, initialize, and set the value of op1 to 63. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op1, 63U); + + // Create, initialize, and set the value of op2 to 70. + mpz_t op2 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op2, 70U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop to the bitwise inclusive or of op1 and op2. + gmp_lib.mpz_ior(rop, op1, op2); + + // Assert that rop is 127. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 127); + + // Release unmanaged memory allocated for rop, op1, and op2. + gmp_lib.mpz_clears(rop, op1, op2, null); + } + + [TestMethod] + public void mpz_jacobi() + { + // Create, initialize, and set the value of a to 11. + mpz_t a = new mpz_t(); + gmp_lib.mpz_init_set_ui(a, 11U); + + // Create, initialize, and set the value of b to 9. + mpz_t b = new mpz_t(); + gmp_lib.mpz_init_set_ui(b, 9U); + + // Assert that the Jacobi symbol of (a/b) is 1. + Assert.IsTrue(gmp_lib.mpz_jacobi(a, b) == 1); + + // Release unmanaged memory allocated for a and b. + gmp_lib.mpz_clears(a, b, null); + } + + [TestMethod] + public void mpz_kronecker() + { + // Create, initialize, and set the value of a to 15. + mpz_t a = new mpz_t(); + gmp_lib.mpz_init_set_ui(a, 15U); + + // Create, initialize, and set the value of b to 4. + mpz_t b = new mpz_t(); + gmp_lib.mpz_init_set_ui(b, 4U); + + // Assert that the Kronecker symbol of (a/b) is 1. + Assert.IsTrue(gmp_lib.mpz_kronecker(a, b) == 1); + + // Release unmanaged memory allocated for a and b. + gmp_lib.mpz_clears(a, b, null); + } + + [TestMethod] + public void mpz_kronecker_si() + { + // Create, initialize, and set the value of a to 15. + mpz_t a = new mpz_t(); + gmp_lib.mpz_init_set_ui(a, 15U); + + // Assert that the Kronecker symbol of (a/4) is 1. + Assert.IsTrue(gmp_lib.mpz_kronecker_si(a, 4) == 1); + + // Release unmanaged memory allocated for a. + gmp_lib.mpz_clear(a); + } + + [TestMethod] + public void mpz_kronecker_ui() + { + // Create, initialize, and set the value of a to 15. + mpz_t a = new mpz_t(); + gmp_lib.mpz_init_set_ui(a, 15U); + + // Assert that the Kronecker symbol of (a/4) is 1. + Assert.IsTrue(gmp_lib.mpz_kronecker_ui(a, 4U) == 1); + + // Release unmanaged memory allocated for a. + gmp_lib.mpz_clear(a); + } + + [TestMethod] + public void mpz_si_kronecker() + { + // Create, initialize, and set the value of b to 4. + mpz_t b = new mpz_t(); + gmp_lib.mpz_init_set_ui(b, 4U); + + // Assert that the Kronecker symbol of (15/b) is 1. + Assert.IsTrue(gmp_lib.mpz_si_kronecker(15, b) == 1); + + // Release unmanaged memory allocated for b. + gmp_lib.mpz_clear(b); + } + + [TestMethod] + public void mpz_ui_kronecker() + { + // Create, initialize, and set the value of b to 4. + mpz_t b = new mpz_t(); + gmp_lib.mpz_init_set_ui(b, 4U); + + // Assert that the Kronecker symbol of (15/b) is 1. + Assert.IsTrue(gmp_lib.mpz_ui_kronecker(15U, b) == 1); + + // Release unmanaged memory allocated for b. + gmp_lib.mpz_clear(b); + } + + [TestMethod] + public void mpz_lcm() + { + // Create, initialize, and set the value of op1 to 2. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op1, 2U); + + // Create, initialize, and set the value of op2 to 3. + mpz_t op2 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op2, 3U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop to the least common multiple of op1 and op2. + gmp_lib.mpz_lcm(rop, op1, op2); + + // Assert that rop is 6. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6); + + // Release unmanaged memory allocated for rop, op1, and op2. + gmp_lib.mpz_clears(rop, op1, op2, null); + } + + [TestMethod] + public void mpz_lcm_ui() + { + // Create, initialize, and set the value of op1 to 2. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op1, 2U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop to the least common multiple of op1 and 3. + gmp_lib.mpz_lcm_ui(rop, op1, 3U); + + // Assert that rop is 6. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6); + + // Release unmanaged memory allocated for rop and op1. + gmp_lib.mpz_clears(rop, op1, null); + } + + [TestMethod] + public void mpz_legendre() + { + // Create, initialize, and set the value of a to 20. + mpz_t a = new mpz_t(); + gmp_lib.mpz_init_set_ui(a, 20U); + + // Create, initialize, and set the value of p to 11. + mpz_t p = new mpz_t(); + gmp_lib.mpz_init_set_ui(p, 11U); + + // Assert that the Legendre symbol of (a/p) is 1. + Assert.IsTrue(gmp_lib.mpz_legendre(a, p) == 1); + + // Release unmanaged memory allocated for a and p. + gmp_lib.mpz_clears(a, p, null); + } + + [TestMethod] + public void mpz_lucnum_ui() + { + // Create, initialize, and set the value of ln to 0. + mpz_t ln = new mpz_t(); + gmp_lib.mpz_init(ln); + + // Set ln to the 9'th Lucas number. + gmp_lib.mpz_lucnum_ui(ln, 9U); + + // Assert that ln is 76. + Assert.IsTrue(gmp_lib.mpz_get_si(ln) == 76); + + // Release unmanaged memory allocated for ln. + gmp_lib.mpz_clear(ln); + } + + [TestMethod] + public void mpz_lucnum2_ui() + { + // Create, initialize, and set the values of lnsub1 and ln to 0. + mpz_t ln = new mpz_t(); + mpz_t lnsub1 = new mpz_t(); + gmp_lib.mpz_inits(ln, lnsub1, null); + + // Set lnsub1 and ln to the 8'th and 9'th Lucas nunbers respectively. + gmp_lib.mpz_lucnum2_ui(ln, lnsub1, 9U); + + // Assert that lnsub1 and ln are respectively 47 and 76. + Assert.IsTrue(gmp_lib.mpz_get_si(lnsub1) == 47); + Assert.IsTrue(gmp_lib.mpz_get_si(ln) == 76); + + // Release unmanaged memory allocated for ln and lnsub1. + gmp_lib.mpz_clears(ln, lnsub1, null); + } + + [TestMethod] + public void mpz_millerrabin() + { + // Create, initialize, and set the value of n to 12. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_ui(n, 12U); + + // Assert that n is a composite number. + Assert.IsTrue(gmp_lib.mpz_millerrabin(n, 25) == 0); + + // Release unmanaged memory allocated for n. + gmp_lib.mpz_clear(n); + } + + [TestMethod] + public void mpz_mod() + { + // Create, initialize, and set the value of x to 12222. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 12222U); + + // Create, initialize, and set the value of y to 10000. + mpz_t y = new mpz_t(); + gmp_lib.mpz_init_set_ui(y, 10000U); + + // Create, initialize, and set the value of z to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = x mod y. + gmp_lib.mpz_mod(z, x, y); + + // Assert that z is 12222 mod 10000. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == 12222 % 10000); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpz_clears(x, y, z, null); + } + + [TestMethod] + public void mpz_mod_ui() + { + // Create, initialize, and set the value of x to 12222. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 12222U); + + // Create, initialize, and set the value of z to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = x mod y, and return z. + Assert.IsTrue(gmp_lib.mpz_mod_ui(z, x, 10000U) == 12222 % 10000); + + // Assert that z is 12222 mod 10000. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == 12222 % 10000); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpz_clears(x, z, null); + } + + [TestMethod] + public void mpz_mul() + { + // Create, initialize, and set the value of x to 10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10000U); + + // Create, initialize, and set the value of y to 12222. + mpz_t y = new mpz_t(); + gmp_lib.mpz_init_set_ui(y, 12222U); + + // Create, initialize, and set the value of z to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = x * y. + gmp_lib.mpz_mul(z, x, y); + + // Assert that z is the product of x and y. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == 10000 * 12222); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpz_clears(x, y, z, null); + } + + [TestMethod] + public void mpz_mul_2exp() + { + // Create, initialize, and set the value of x to -10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_si(x, -10000); + + // Create, initialize, and set the value of x to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = -10000 * 2^2. + gmp_lib.mpz_mul_2exp(z, x, 2U); + + // Assert that z is -40000. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == -10000 * 4); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpz_clears(x, z, null); + } + + [TestMethod] + public void mpz_mul_si() + { + // Create, initialize, and set the value of x to -10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_si(x, -10000); + + // Create, initialize, and set the value of z to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = x * 12222. + gmp_lib.mpz_mul_si(z, x, 12222); + + // Assert that z is the product of x and 12222. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == -10000 * 12222); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpz_clears(x, z, null); + } + + [TestMethod] + public void mpz_mul_ui() + { + // Create, initialize, and set the value of x to -10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_si(x, -10000); + + // Create, initialize, and set the value of z to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = x * 12222. + gmp_lib.mpz_mul_ui(z, x, 12222); + + // Assert that z is the product of x and 12222. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == -10000 * 12222); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpz_clears(x, z, null); + } + + [TestMethod] + public void mpz_neg() + { + // Create, initialize, and set the value of x to -10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_si(x, -10000); + + // Create, initialize, and set the value of z to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = -x. + gmp_lib.mpz_neg(z, x); + + // Assert that z is -x. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == 10000); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpz_clears(x, z, null); + } + + [TestMethod] + public void mpz_nextprime() + { + // Create, initialize, and set the value of n to 12. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, 12U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop to the next following op. + gmp_lib.mpz_nextprime(rop, op); + + // Assert that rop is 13. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 13); + + // Release unmanaged memory allocated for rop and op. + gmp_lib.mpz_clears(rop, op, null); + } + + [TestMethod] + public void mpz_odd() + { + // Create, initialize, and set the value of op to 427294. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, 427294); + + // Assert that op is not odd but even. + Assert.IsTrue(gmp_lib.mpz_even_p(op) > 0); + Assert.IsTrue(gmp_lib.mpz_odd_p(op) == 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_out_raw() + { + // Create, initialize, and set the value of op to 123456 (0x1E240). + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, 0x1E240); + + // Get a temporary file. + string pathname = System.IO.Path.GetTempFileName(); + + // Open temporary file for writing. + ptr stream = new ptr(); + _wfopen_s(out stream.Value.Value, pathname, "w"); + + // Write op to temporary file, and assert that the number of bytes written is 7. + Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) == 7); + + // Close temporary file. + fclose(stream.Value.Value); + + // Assert that the content of the temporary file. + byte[] r = System.IO.File.ReadAllBytes(pathname); + Assert.IsTrue(r[0] == 0 && r[1] == 0 && r[2] == 0 && r[3] == 3 && r[4] == 0x01 && r[5] == 0xE2 && r[6] == 0x40); + + // Delete temporary file. + System.IO.File.Delete(pathname); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, SetLastError = true)] + public static extern Int32 _wfopen_s(out IntPtr pFile, String filename, String mode); + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = true)] + public static extern Int32 fclose(IntPtr stream); + + [TestMethod] + public void mpz_out_str() + { + // Create, initialize, and set the value of op to 123456. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, 123456U); + + // Get a temporary file. + string pathname = System.IO.Path.GetTempFileName(); + + // Open temporary file for writing. + ptr stream = new ptr(); + _wfopen_s(out stream.Value.Value, pathname, "w"); + + // Write op to temporary file, and assert that the number of bytes written is 6. + Assert.IsTrue(gmp_lib.mpz_out_str(stream, 10, op) == 6); + + // Close temporary file. + fclose(stream.Value.Value); + + // Assert that the content of the temporary file is "123456". + string result = System.IO.File.ReadAllText(pathname); + Assert.IsTrue(result == "123456"); + + // Delete temporary file. + System.IO.File.Delete(pathname); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_perfect_power_p() + { + // Create, initialize, and set the value of x to 10000. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_si(op, 10000); + + // Assert that op is a perfect power. + Assert.IsTrue(gmp_lib.mpz_perfect_power_p(op) > 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_perfect_square_p() + { + // Create, initialize, and set the value of x to 10000. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_si(op, 10000); + + // Assert that op is a perfect square. + Assert.IsTrue(gmp_lib.mpz_perfect_square_p(op) > 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_popcount() + { + // Create, initialize, and set the value of op to 63. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, 63U); + + // Assert that op has 6 one bits. + Assert.IsTrue(gmp_lib.mpz_popcount(op) == 6U); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clears(op); + } + + [TestMethod] + public void mpz_pow_ui() + { + // Create, initialize, and set the value of base to 2. + mpz_t @base = new mpz_t(); + gmp_lib.mpz_init_set_ui(@base, 2U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop = base^4. + gmp_lib.mpz_pow_ui(rop, @base, 4U); + + // Assert that rop is 16. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 16); + + // Release unmanaged memory allocated for rop and base. + gmp_lib.mpz_clears(rop, @base, null); + } + + [TestMethod] + public void mpz_powm() + { + // Create, initialize, and set the value of base to 2. + mpz_t @base = new mpz_t(); + gmp_lib.mpz_init_set_ui(@base, 2U); + + // Create, initialize, and set the value of exp to 4. + mpz_t exp = new mpz_t(); + gmp_lib.mpz_init_set_ui(exp, 4U); + + // Create, initialize, and set the value of mod to 3. + mpz_t mod = new mpz_t(); + gmp_lib.mpz_init_set_ui(mod, 3U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop = base^exp mod mod. + gmp_lib.mpz_powm(rop, @base, exp, mod); + + // Assert that rop is 1. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 1); + + // Release unmanaged memory allocated for rop, base, exp, and mod. + gmp_lib.mpz_clears(rop, @base, exp, mod, null); + } + + [TestMethod] + public void mpz_powm_sec() + { + // Create, initialize, and set the value of base to 2. + mpz_t @base = new mpz_t(); + gmp_lib.mpz_init_set_ui(@base, 2U); + + // Create, initialize, and set the value of exp to 4. + mpz_t exp = new mpz_t(); + gmp_lib.mpz_init_set_ui(exp, 4U); + + // Create, initialize, and set the value of mod to 3. + mpz_t mod = new mpz_t(); + gmp_lib.mpz_init_set_ui(mod, 3U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop = base^exp mod mod. + gmp_lib.mpz_powm_sec(rop, @base, exp, mod); + + // Assert that rop is 1. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 1); + + // Release unmanaged memory allocated for rop, base, exp, and mod. + gmp_lib.mpz_clears(rop, @base, exp, mod, null); + } + + [TestMethod] + public void mpz_powm_ui() + { + // Create, initialize, and set the value of base to 2. + mpz_t @base = new mpz_t(); + gmp_lib.mpz_init_set_ui(@base, 2U); + + mpz_t mod = new mpz_t(); + gmp_lib.mpz_init_set_ui(mod, 3U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop = base^4 mod mod. + gmp_lib.mpz_powm_ui(rop, @base, 4U, mod); + + // Assert that rop is 1. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 1); + + // Release unmanaged memory allocated for rop, base, and mod. + gmp_lib.mpz_clears(rop, @base, mod, null); + } + + [TestMethod] + public void mpz_probab_prime_p() + { + // Create, initialize, and set the value of n to 12. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_ui(n, 12U); + + // Assert that n is a composite number. + Assert.IsTrue(gmp_lib.mpz_probab_prime_p(n, 25) == 0); + + // Release unmanaged memory allocated for n. + gmp_lib.mpz_clear(n); + } + + [TestMethod] + public void mpz_random() + { + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Generate a random integer. + gmp_lib.mpz_random(rop, 500); + + // Free all memory occupied by state and rop. + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_random2() + { + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Generate a random integer. + gmp_lib.mpz_random(rop, 100); + + // Free all memory occupied by rop. + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_realloc2() + { + // Create and initialize new integer x. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + + // Set the value of x to a 77-bit integer. + char_ptr value = new char_ptr("1000 0000 0000 0000 0000"); + gmp_lib.mpz_set_str(x, value, 16); + + // Resize x to 512 bits, and assert that its value has not changed. + gmp_lib.mpz_realloc2(x, 512U); + char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 16, x); + Assert.IsTrue(s.ToString() == "1000 0000 0000 0000 0000".Replace(" ", "")); + + // Resize x to 2 bits, and assert that its value has changed to 0. + gmp_lib.mpz_realloc2(x, 2U); + Assert.IsTrue(gmp_lib.mpz_get_si(x) == 0); + + // Release unmanaged memory allocated for x and string values. + gmp_lib.mpz_clear(x); + gmp_lib.free(value); + gmp_lib.free(s); + } + + [TestMethod] + public void mpz_remove() + { + // Create, initialize, and set the value of op to 45. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, 45U); + + // Create, initialize, and set the value of f to 3. + mpz_t f = new mpz_t(); + gmp_lib.mpz_init_set_ui(f, 3U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop = op / f^n, and return n, the largest integer greater than or equal to 0, such that f^n divides op. + Assert.IsTrue(gmp_lib.mpz_remove(rop, op, f) == 2); + + // Assert that rop is 5. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 5); + + // Release unmanaged memory allocated for rop, op, and f. + gmp_lib.mpz_clears(rop, op, f, null); + } + + [TestMethod] + public void mpz_root() + { + // Create, initialize, and set the value of op to 10000. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_si(op, 10000); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop = trunc(cbrt(10000)). + gmp_lib.mpz_root(rop, op, 3U); + + // Assert that rop is 21. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 21); + + // Release unmanaged memory allocated for rop. + gmp_lib.mpz_clears(rop, op, null); + } + + [TestMethod] + public void mpz_rootrem() + { + // Create, initialize, and set the value of u to 10000. + mpz_t u = new mpz_t(); + gmp_lib.mpz_init_set_si(u, 10000); + + // Create, initialize, and set the values of root and rem to 0. + mpz_t root = new mpz_t(); + mpz_t rem = new mpz_t(); + gmp_lib.mpz_inits(root, rem, null); + + // Set root = trunc(cbrt(10000)) and rem = u - root. + gmp_lib.mpz_rootrem(root, rem, u, 3U); + + // Assert that root is 21, and rem is 739. + Assert.IsTrue(gmp_lib.mpz_get_si(root) == 21); + Assert.IsTrue(gmp_lib.mpz_get_si(rem) == 739); + + // Release unmanaged memory allocated for root, rem, and u. + gmp_lib.mpz_clears(root, rem, u, null); + } + + [TestMethod] + public void mpz_rrandomb() + { + // Create, initialize, and seed a new random number generator. + gmp_randstate_t state = new gmp_randstate_t(); + gmp_lib.gmp_randinit_mt(state); + gmp_lib.gmp_randseed_ui(state, 100000U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Generate a random integer in the range [2^(50-1), (2^50)-1]. + gmp_lib.mpz_rrandomb(rop, state, 50); + + // Free all memory occupied by state and rop. + gmp_lib.gmp_randclear(state); + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_scan0() + { + // Create, initialize, and set the value of op to 70. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, 70U); + + // Assert that the first 0 bit starting from bit 1 in op is bit 3. + Assert.IsTrue(gmp_lib.mpz_scan0(op, 1U) == 3U); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_scan1() + { + // Create, initialize, and set the value of op to 70. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_ui(op, 70U); + + // Assert that the first 1 bit starting from bit 3 in op is bit 6. + Assert.IsTrue(gmp_lib.mpz_scan1(op, 3U) == 6U); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_set() + { + // Create, initialize, and set a new integer x to 10. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + gmp_lib.mpz_set_si(x, 10); + + // Create, initialize, and set a new integer y to -210. + mpz_t y = new mpz_t(); + gmp_lib.mpz_init(y); + gmp_lib.mpz_set_si(y, -210); + + // Assign the value of y to x. + gmp_lib.mpz_set(x, y); + + // Assert that the value of x is -210. + Assert.IsTrue(gmp_lib.mpz_get_si(x) == -210); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpz_clears(x, y, null); + } + + [TestMethod] + public void mpz_set_d() + { + // Create and initialize a new integer x. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + + // Set the value of x to the truncation of 10.7. + gmp_lib.mpz_set_d(x, 10.7D); + + // Assert that the value of x is 10. + Assert.IsTrue(gmp_lib.mpz_get_si(x) == 10); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_set_f() + { + // Create and initialize new integer x, and float y. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + mpf_t y = "1.7007e3"; + + // Set the value of x to the truncation of 1700.7. + gmp_lib.mpz_set_f(x, y); + + // Assert that the value of x is 1700. + Assert.IsTrue(gmp_lib.mpz_get_si(x) == 1700); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpz_clear(x); + gmp_lib.mpf_clear(y); + } + + [TestMethod] + public void mpz_set_q() + { + // Create and initialize new integer x, and rational y. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + mpq_t y = "100/3"; + + // Set the value of x to the truncation of 100/3. + gmp_lib.mpz_set_q(x, y); + + // Assert that the value of x is 33. + Assert.IsTrue(gmp_lib.mpz_get_si(x) == 33); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpz_clear(x); + gmp_lib.mpq_clear(y); + } + + [TestMethod] + public void mpz_set_si() + { + // Create and initialize a new integer x. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + + // Set the value of x to -10. + gmp_lib.mpz_set_si(x, -10); + + // Assert that the value of x is -10. + Assert.IsTrue(gmp_lib.mpz_get_si(x) == -10); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_set_str() + { + // Create and initialize a new integer x. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + + // Set the value of x. + char_ptr value = new char_ptr("12 345 678 909 876 543 211 234 567 890 987 654 321"); + gmp_lib.mpz_set_str(x, value, 10); + + // Assert the value of x. + char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x); + Assert.IsTrue(s.ToString() == value.ToString().Replace(" ", "")); + + // Release unmanaged memory allocated for x and string values. + gmp_lib.mpz_clear(x); + gmp_lib.free(value); + gmp_lib.free(s); + } + + [TestMethod] + public void mpz_set_ui() + { + // Create and initialize a new integer x. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + + // Set the value of x to 10. + gmp_lib.mpz_set_ui(x, 10U); + + // Assert that the value of x is 10. + Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 10U); + + // Release unmanaged memory allocated for x. + gmp_lib.mpz_clear(x); + } + + [TestMethod] + public void mpz_setbit() + { + // Create, initialize, and set the value of rop to 70. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init_set_si(rop, 70); + + // Set bit 3 of rop. + gmp_lib.mpz_setbit(rop, 3U); + + // Assert that rop is 78. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 78); + + // Release unmanaged memory allocated for rop. + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_sgn() + { + // Create, initialize, and set the value of op to -10. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_si(op, -10); + + // Assert that the sign of op is -1. + Assert.IsTrue(gmp_lib.mpz_sgn(op) == -1); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_size() + { + // Create and initialize new integer x. + mpz_t op = new mpz_t(); + char_ptr value = new char_ptr("1000 ABCD 1234 7AB8 24FD"); + gmp_lib.mpz_init_set_str(op, value, 16); + + // Assert the value of the limbs of op. + if (gmp_lib.mp_bytes_per_limb == 4) + Assert.IsTrue(gmp_lib.mpz_size(op) == 3); + else // gmp_lib.mp_bytes_per_limb == 8 + Assert.IsTrue(gmp_lib.mpz_size(op) == 2); + + // Release unmanaged memory allocated for op and value. + gmp_lib.mpz_clear(op); + gmp_lib.free(value); + } + + [TestMethod] + public void mpz_sizeinbase() + { + // Create, initialize, and set the value of op to 10000. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_si(op, 10000); + + // Assert size in different bases. + Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 2) == 14); + Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 8) == 5); + Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 10) == 5); + Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 16) == 4); + + // Release unmanaged memory allocated for op. + gmp_lib.mpz_clear(op); + } + + [TestMethod] + public void mpz_sqrt() + { + // Create, initialize, and set the value of op to 10000. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_si(op, 10000); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop = trunc(sqrt(op)). + gmp_lib.mpz_sqrt(rop, op); + + // Assert that rop is 100. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 100); + + // Release unmanaged memory allocated for rop and op. + gmp_lib.mpz_clears(rop, op, null); + } + + [TestMethod] + public void mpz_sqrtrem() + { + // Create, initialize, and set the value of op to 10000. + mpz_t op = new mpz_t(); + gmp_lib.mpz_init_set_si(op, 10000); + + // Create, initialize, and set the values of root and rem to 0. + mpz_t root = new mpz_t(); + mpz_t rem = new mpz_t(); + gmp_lib.mpz_inits(root, rem); + + // Set root = trunc(sqrt(op)), and rem = op - root. + gmp_lib.mpz_sqrtrem(root, rem, op); + + // Assert that root is 100, and rem is 0. + Assert.IsTrue(gmp_lib.mpz_get_si(root) == 100); + Assert.IsTrue(gmp_lib.mpz_get_si(rem) == 0); + + // Release unmanaged memory allocated for root, rem, and op. + gmp_lib.mpz_clears(root, rem, op, null); + } + + [TestMethod] + public void mpz_sub() + { + // Create, initialize, and set the value of x to 10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10000U); + + // Create, initialize, and set the value of y to 12222. + mpz_t y = new mpz_t(); + gmp_lib.mpz_init_set_ui(y, 12222U); + + // Create, initialize, and set the value of z to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = x - y. + gmp_lib.mpz_sub(z, x, y); + + // Assert that z = x - y. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == -2222); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpz_clears(x, y, z, null); + } + + [TestMethod] + public void mpz_sub_ui() + { + // Create, initialize, and set the value of x to 10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10000U); + + // Create, initialize, and set the value of z to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = x - 12222. + gmp_lib.mpz_sub_ui(z, x, 12222U); + + // Assert that z = x - 12222. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == -2222); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpz_clears(x, z, null); + } + + [TestMethod] + public void mpz_ui_sub() + { + // Create, initialize, and set the value of x to 10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10000U); + + // Create, initialize, and set the value of z to 0. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init(z); + + // Set z = 12222 - x. + gmp_lib.mpz_ui_sub(z, 12222U, x); + + // Assert that z = 12222 - x. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == 2222); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpz_clears(x, z, null); + } + + [TestMethod] + public void mpz_submul() + { + // Create, initialize, and set the value of x to 10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 10000U); + + // Create, initialize, and set the value of y to 12222. + mpz_t y = new mpz_t(); + gmp_lib.mpz_init_set_ui(y, 12222U); + + // Create, initialize, and set the value of z to 20000. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init_set_si(z, 20000); + + // Set z -= x * y. + gmp_lib.mpz_submul(z, x, y); + + // Assert that z has been decremented by 10000 * 12222. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000 - 10000 * 12222); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpz_clears(x, y, z, null); + } + + [TestMethod] + public void mpz_submul_ui() + { + // Create, initialize, and set the value of x to -10000. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_si(x, -10000); + + // Create, initialize, and set the value of z to 20000. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init_set_si(z, 20000); + + // Set z -= x * 12222U. + gmp_lib.mpz_submul_ui(z, x, 12222U); + + // Assert that z has been decremented by -10000 * 12222. + Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000 - -10000 * 12222); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpz_clears(x, z, null); + } + + [TestMethod] + public void mpz_swap() + { + // Create, initialize, and set a new integer x to 10. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_si(x, 10); + + // Create, initialize, and set a new integer x to -210. + mpz_t y = new mpz_t(); + gmp_lib.mpz_init_set_si(y, -210); + + // Swap the values of x and y. + gmp_lib.mpz_swap(x, y); + + // Assert that the values have been swapped. + Assert.IsTrue(gmp_lib.mpz_get_si(x) == -210); + Assert.IsTrue(gmp_lib.mpz_get_si(y) == 10); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpz_clears(x, y, null); + } + + [TestMethod] + public void mpz_tdiv_q() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of d to 3. + mpz_t d = new mpz_t(); + gmp_lib.mpz_init_set_si(d, 3); + + // Create, initialize, and set the value of q to 0. + mpz_t q = new mpz_t(); + gmp_lib.mpz_init(q); + + // Set q = trunc(n / d). + gmp_lib.mpz_tdiv_q(q, n, d); + + // Assert that q is trunc(10000 / 3). + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + + // Release unmanaged memory allocated for n, d, and q. + gmp_lib.mpz_clears(n, d, q, null); + } + + [TestMethod] + public void mpz_tdiv_q_2exp() + { + // Create, initialize, and set the value of n to 10001. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10001); + + // Create, initialize, and set the value of q to 0. + mpz_t q = new mpz_t(); + gmp_lib.mpz_init(q); + + // Set q = trunc(n / 2^2). + gmp_lib.mpz_tdiv_q_2exp(q, n, 2U); + + // Assert that q is trunc(10001 / 4). + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 2500); + + // Release unmanaged memory allocated for n and q. + gmp_lib.mpz_clears(n, q, null); + } + + [TestMethod] + public void mpz_tdiv_q_ui() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of q to 0. + mpz_t q = new mpz_t(); + gmp_lib.mpz_init(q); + + // Set q = trunc(n / 3) and return r = n - 3 * q. + // Assert q and r values. + Assert.IsTrue(gmp_lib.mpz_tdiv_q_ui(q, n, 3U) == 1U); + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + + // Release unmanaged memory allocated for n and q. + gmp_lib.mpz_clears(n, q, null); + } + + [TestMethod] + public void mpz_tdiv_qr() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of d to 3. + mpz_t d = new mpz_t(); + gmp_lib.mpz_init_set_si(d, 3); + + // Create, initialize, and set the values of q and r to 0. + mpz_t q = new mpz_t(); + mpz_t r = new mpz_t(); + gmp_lib.mpz_inits(q, r, null); + + // Set q = trunc(n / 3) and r = n - d * q. + gmp_lib.mpz_tdiv_qr(q, r, n, d); + + // Assert that q is 3333, and that r is 1. + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + + // Release unmanaged memory allocated for n, d, q, and r. + gmp_lib.mpz_clears(n, d, q, r, null); + } + + [TestMethod] + public void mpz_tdiv_qr_ui() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the values of q and r to 0. + mpz_t q = new mpz_t(); + mpz_t r = new mpz_t(); + gmp_lib.mpz_inits(q, r, null); + + // Set q = trunc(n / 3), r = n - d * q, and return r. + Assert.IsTrue(gmp_lib.mpz_tdiv_qr_ui(q, r, n, 3U) == 1U); + + // Assert that q is 3333, and that r is 1. + Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + + // Release unmanaged memory allocated for n, q, and r. + gmp_lib.mpz_clears(n, q, r, null); + } + + [TestMethod] + public void mpz_tdiv_r() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of d to 3. + mpz_t d = new mpz_t(); + gmp_lib.mpz_init_set_si(d, 3); + + // Create, initialize, and set the value of r to 0. + mpz_t r = new mpz_t(); + gmp_lib.mpz_init(r); + + // Set r = n - d * trunc(n / d). + gmp_lib.mpz_tdiv_r(r, n, d); + + // Assert that r is 1. + Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + + // Release unmanaged memory allocated for n, d, and r. + gmp_lib.mpz_clears(n, d, r, null); + } + + [TestMethod] + public void mpz_tdiv_r_2exp() + { + // Create, initialize, and set the value of n to 10001. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10001); + + // Create, initialize, and set the value of r to 0. + mpz_t r = new mpz_t(); + gmp_lib.mpz_init(r); + + // Set r = n - 2^2 * trunc(n / 2^2) + gmp_lib.mpz_tdiv_r_2exp(r, n, 2U); + + // Assert that r is 1. + Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + + // Release unmanaged memory allocated for n and r. + gmp_lib.mpz_clears(n, r, null); + } + + [TestMethod] + public void mpz_tdiv_r_ui() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Create, initialize, and set the value of r to 0. + mpz_t r = new mpz_t(); + gmp_lib.mpz_init(r); + + // Set r = n - 3 * trunc(n / 3), and return |r|. + Assert.IsTrue(gmp_lib.mpz_tdiv_r_ui(r, n, 3U) == 1U); + + // Assert that r is 1. + Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + + // Release unmanaged memory allocated for n and r. + gmp_lib.mpz_clears(n, r, null); + } + + [TestMethod] + public void mpz_tdiv_ui() + { + // Create, initialize, and set the value of n to 10000. + mpz_t n = new mpz_t(); + gmp_lib.mpz_init_set_si(n, 10000); + + // Assert that returned value is |n - 3 * trunc(n / 3)|. + Assert.IsTrue(gmp_lib.mpz_tdiv_ui(n, 3U) == 1U); + + // Release unmanaged memory allocated for n. + gmp_lib.mpz_clear(n); + } + + [TestMethod] + public void mpz_tstbit() + { + // Create, initialize, and set the value of rop to 70. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init_set_si(rop, 70); + + // Assert that bit 3 of rop is 0. + Assert.IsTrue(gmp_lib.mpz_tstbit(rop, 3U) == 0); + + // Release unmanaged memory allocated for rop. + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_ui_pow_ui() + { + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop = 2^4. + gmp_lib.mpz_ui_pow_ui(rop, 2U, 4U); + + // Assert that rop is 16. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 16); + + // Release unmanaged memory allocated for rop. + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_urandomb() + { + // Create, initialize, and seed a new random number generator. + gmp_randstate_t state = new gmp_randstate_t(); + gmp_lib.gmp_randinit_mt(state); + gmp_lib.gmp_randseed_ui(state, 100000U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Generate a random integer in the range [0, (2^50)-1]. + gmp_lib.mpz_urandomb(rop, state, 50); + + // Free all memory occupied by state and rop. + gmp_lib.gmp_randclear(state); + gmp_lib.mpz_clear(rop); + } + + [TestMethod] + public void mpz_urandomm() + { + // Create, initialize, and seed a new random number generator. + gmp_randstate_t state = new gmp_randstate_t(); + gmp_lib.gmp_randinit_mt(state); + gmp_lib.gmp_randseed_ui(state, 100000U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Create, initialize, and set a large integer. + mpz_t n = new mpz_t(); + char_ptr value = new char_ptr("123 456 789 012 345 678 901"); + gmp_lib.mpz_init_set_str(n, value, 10); + + // Generate a random integer in the range [0, n-1]. + gmp_lib.mpz_urandomm(rop, state, n); + + // Free all memory occupied by state, rop, and n. + gmp_lib.gmp_randclear(state); + gmp_lib.mpz_clears(rop, n, null); + } + + [TestMethod] + public void mpz_xor() + { + // Create, initialize, and set the value of op1 to 63. + mpz_t op1 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op1, 63U); + + // Create, initialize, and set the value of op2 to 70. + mpz_t op2 = new mpz_t(); + gmp_lib.mpz_init_set_ui(op2, 70U); + + // Create, initialize, and set the value of rop to 0. + mpz_t rop = new mpz_t(); + gmp_lib.mpz_init(rop); + + // Set rop to the bitwise exclusive or of op1 and op2. + gmp_lib.mpz_xor(rop, op1, op2); + + // Assert that rop is 121. + Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 121); + + // Release unmanaged memory allocated for rop, op1, and op2. + gmp_lib.mpz_clears(rop, op1, op2, null); + } + + [TestMethod] + public void mpz_limbs_read() + { + // Create and initialize new integer x. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + + // Set the value of x. + char_ptr value = new char_ptr("10000 00000000000000000000000000000000"); + gmp_lib.mpz_set_str(x, value, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4); + + // Get pointer to the limbs of x. + mp_ptr limbs = gmp_lib.mpz_limbs_read(x); + + // Assert the values of the limbs based on current architecture (x86 or x64). + Assert.IsTrue(limbs[0] == 0); + Assert.IsTrue(limbs[1] == (gmp_lib.mp_bytes_per_limb == 4 ? 16U : 256U)); + + // Release unmanaged memory allocated for x and value. + gmp_lib.mpz_clear(x); + gmp_lib.free(value); + } + + [TestMethod] + public void mpz_limbs_write() + { + // Create and initialize new integer x. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + + // Resize x to 3 limbs, and get pointer to the limbs. + gmp_lib.mpz_set_ui(x, 2U); + mp_ptr limbs = gmp_lib.mpz_limbs_write(x, 3); + + // Set the values of the limbs. + limbs[0] = 0U; + limbs[1] = 0U; + limbs[2] = (gmp_lib.mp_bytes_per_limb == 4 ? 2U : 4U); + gmp_lib.mpz_limbs_finish(x, -3); + + // Assert the value of x based on current architecture (x86 or x64). + char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4, x); + Assert.IsTrue(s.ToString() == "-10 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", "")); + + // Release unmanaged memory allocated for x and s. + gmp_lib.mpz_clear(x); + gmp_lib.free(s); + } + + [TestMethod] + public void mpz_limbs_modify() + { + // Create, initialize, and set the value of x to 2. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init_set_ui(x, 2U); + + // Resize x to 3 limbs, and get pointer to the limbs. + mp_ptr limbs = gmp_lib.mpz_limbs_modify(x, 3); + + // Set the value of x. + limbs[0] = 0; + limbs[1] = 0; + limbs[2] = (IntPtr.Size == 4 ? 8U : 64U); + gmp_lib.mpz_limbs_finish(x, -3); + + // Assert the value of x based on current architecture (x86 or x64). + char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4, x); + Assert.IsTrue(s.ToString() == "-1000 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", "")); + + // Release unmanaged memory allocated for x and s. + gmp_lib.mpz_clear(x); + gmp_lib.free(s); + } + + [TestMethod] + public void mpz_roinit_n() + { + // Create and initialize new integer x. + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + + // Prepare new limbs for x. + mp_ptr limbs; + if (gmp_lib.mp_bytes_per_limb == 4) + limbs = new mp_ptr(new uint[] { 0U, 0U, 2U }); + else + limbs = new mp_ptr(new ulong[] { 0UL, 0UL, 4UL }); + + // Assign new limbs to x, and make x negative. + x = gmp_lib.mpz_roinit_n(x, limbs, -3); + + // Assert new value of x. + char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4, x); + Assert.IsTrue(s.ToString() == "-10 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", "")); + + // Release unmanaged memory allocated for x and s. + gmp_lib.mpz_clear(x); + gmp_lib.free(s); + } + + #endregion + + #region "Rational (i.e. Q) routines." + + [TestMethod] + public void mpq_abs() + { + // Create, initialize, and set the value of op to -1 / 3. + mpq_t op = new mpq_t(); + gmp_lib.mpq_init(op); + gmp_lib.mpq_set_si(op, -1, 3U); + + // Create, initialize, and set the value of rop to 0. + mpq_t rop = new mpq_t(); + gmp_lib.mpq_init(rop); + + // Set rop = |-1/3|. + gmp_lib.mpq_abs(rop, op); + + // Assert that rop is 1 / 3. + Assert.IsTrue(gmp_lib.mpq_cmp_si(rop, 1, 3U) == 0); + + // Release unmanaged memory allocated for rop and op. + gmp_lib.mpq_clears(rop, op, null); + } + + [TestMethod] + public void mpq_add() + { + // Create, initialize, and set the value of x to 1 / 2. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + gmp_lib.mpq_set_si(x, 1, 2U); + + // Create, initialize, and set the value of y to 1 / 3. + mpq_t y = new mpq_t(); + gmp_lib.mpq_init(y); + gmp_lib.mpq_set_si(y, 1, 3U); + + // Create, initialize, and set the value of z to 0 / 1. + mpq_t z = new mpq_t(); + gmp_lib.mpq_init(z); + + // Set z = x + y. + gmp_lib.mpq_add(z, x, y); + + // Assert that z is the sum of x and y. + Assert.IsTrue(gmp_lib.mpq_cmp_si(z, 5, 6U) == 0); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpq_clears(x, y, z, null); + } + + [TestMethod] + public void mpq_canonicalize() + { + // Create, initialize, and set a new rational to 10 / 20. + mpq_t op = new mpq_t(); + gmp_lib.mpq_init(op); + gmp_lib.mpq_set_si(op, 10, 20U); + + // Reduce op to its canonical form. + gmp_lib.mpq_canonicalize(op); + + // Assert that z is the sum of x and y. + Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 1, 2U) == 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpq_clear(op); + } + + [TestMethod] + public void mpq_clear() + { + // Create and initialize a new rational x. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + + // Assert that the value of x is 0.0. + Assert.IsTrue(gmp_lib.mpq_get_d(x) == 0.0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpq_clear(x); + } + + [TestMethod] + public void mpq_clears() + { + // Create new rationals x1, x2 and x3. + mpq_t x1 = new mpq_t(); + mpq_t x2 = new mpq_t(); + mpq_t x3 = new mpq_t(); + + // Initialize the rationals. + gmp_lib.mpq_inits(x1, x2, x3, null); + + // Assert that their value is 0.0. + Assert.IsTrue(gmp_lib.mpq_get_d(x1) == 0.0); + Assert.IsTrue(gmp_lib.mpq_get_d(x2) == 0.0); + Assert.IsTrue(gmp_lib.mpq_get_d(x3) == 0.0); + + // Release unmanaged memory allocated for the rationals. + gmp_lib.mpq_clears(x1, x2, x3, null); + } + + [TestMethod] + public void mpq_cmp() + { + // Create, initialize, and set the value of op1 to 1 / 2. + mpq_t op1 = new mpq_t(); + gmp_lib.mpq_init(op1); + gmp_lib.mpq_set_si(op1, 1, 2U); + + // Create, initialize, and set the value of op2 to 1 / 3. + mpq_t op2 = new mpq_t(); + gmp_lib.mpq_init(op2); + gmp_lib.mpq_set_si(op2, 1, 3U); + + // Assert that op1 > op2. + Assert.IsTrue(gmp_lib.mpq_cmp(op1, op2) > 0); + + // Release unmanaged memory allocated for op1 and op2. + gmp_lib.mpq_clears(op1, op2, null); + } + + [TestMethod] + public void mpq_cmp_si() + { + // Create, initialize, and set the value of op1 to 1 / 2. + mpq_t op1 = new mpq_t(); + gmp_lib.mpq_init(op1); + gmp_lib.mpq_set_si(op1, 1, 2U); + + // Assert that op1 < 5/6. + Assert.IsTrue(gmp_lib.mpq_cmp_si(op1, 5, 6U) < 0); + + // Release unmanaged memory allocated for op1. + gmp_lib.mpq_clear(op1); + } + + [TestMethod] + public void mpq_cmp_ui() + { + // Create, initialize, and set the value of op1 to 1 / 2. + mpq_t op1 = new mpq_t(); + gmp_lib.mpq_init(op1); + gmp_lib.mpq_set_si(op1, 1, 2U); + + // Assert that op1 == 3/6. + Assert.IsTrue(gmp_lib.mpq_cmp_ui(op1, 3, 6U) == 0); + + // Release unmanaged memory allocated for op1. + gmp_lib.mpq_clear(op1); + } + + [TestMethod] + public void mpq_cmp_z() + { + // Create, initialize, and set the value of op1 to 1 / 2. + mpq_t op1 = new mpq_t(); + gmp_lib.mpq_init(op1); + gmp_lib.mpq_set_si(op1, 1, 2U); + + // Create, initialize, and set the value of op2 to 3. + mpz_t op2 = new mpz_t(); + gmp_lib.mpz_init(op2); + gmp_lib.mpz_set_si(op2, 3); + + // Assert that op1 < op2. + Assert.IsTrue(gmp_lib.mpq_cmp_z(op1, op2) < 0); + + // Release unmanaged memory allocated for op1 and op2. + gmp_lib.mpq_clear(op1); + gmp_lib.mpz_clear(op2); + } + + [TestMethod] + public void mpq_denref() + { + // Create, initialize, and set the value of op to -1 / 3. + mpq_t op = new mpq_t(); + gmp_lib.mpq_init(op); + gmp_lib.mpq_set_si(op, -1, 3U); + + // Get reference to denominator, and increment it by 2. + mpz_t num = gmp_lib.mpq_denref(op); + gmp_lib.mpz_add_ui(num, num, 2U); + + // Assert that op is -1 / 5. + Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5U) == 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpq_clear(op); + } + + [TestMethod] + public void mpq_div() + { + // Create, initialize, and set the value of n to 1 / 2. + mpq_t n = new mpq_t(); + gmp_lib.mpq_init(n); + gmp_lib.mpq_set_si(n, 1, 2U); + + // Create, initialize, and set the value of d to 1 / 3. + mpq_t d = new mpq_t(); + gmp_lib.mpq_init(d); + gmp_lib.mpq_set_si(d, 1, 3U); + + // Create, initialize, and set the value of q to 0. + mpq_t q = new mpq_t(); + gmp_lib.mpq_init(q); + + // Set q = n / d. + gmp_lib.mpq_div(q, n, d); + + // Assert that q is 3 / 2. + Assert.IsTrue(gmp_lib.mpq_cmp_si(q, 3, 2U) == 0); + + // Release unmanaged memory allocated for n, d, and q. + gmp_lib.mpq_clears(n, d, q, null); + } + + [TestMethod] + public void mpq_div_2exp() + { + // Create, initialize, and set the value of op to -1 / 3. + mpq_t op = new mpq_t(); + gmp_lib.mpq_init(op); + gmp_lib.mpq_set_si(op, -1, 3U); + + // Create, initialize, and set the value of rop to 0. + mpq_t rop = new mpq_t(); + gmp_lib.mpq_init(rop); + + // Set rop = (-1/3) / 2^3. + gmp_lib.mpq_div_2exp(rop, op, 3U); + + // Assert that rop is -1 / 24. + Assert.IsTrue(gmp_lib.mpq_cmp_si(rop, -1, 24U) == 0); + + // Release unmanaged memory allocated for rop and op. + gmp_lib.mpq_clears(rop, op, null); + } + + [TestMethod] + public void mpq_equal() + { + // Create, initialize, and set the value of op1 to 1 / 2. + mpq_t op1 = new mpq_t(); + gmp_lib.mpq_init(op1); + gmp_lib.mpq_set_si(op1, 1, 2U); + + // Create, initialize, and set the value of op2 to 1 / 3. + mpq_t op2 = new mpq_t(); + gmp_lib.mpq_init(op2); + gmp_lib.mpq_set_si(op2, 1, 3U); + + // Assert that op1 != op2. + Assert.IsTrue(gmp_lib.mpq_equal(op1, op2) == 0); + + // Release unmanaged memory allocated for op1 and op2. + gmp_lib.mpq_clears(op1, op2, null); + } + + [TestMethod] + public void mpq_get_num() + { + // Create, initialize, and set the value of op to -1 / 3. + mpq_t op = new mpq_t(); + gmp_lib.mpq_init(op); + gmp_lib.mpq_set_si(op, -1, 3U); + + // Create and initialize a new integer. + mpz_t num = new mpz_t(); + gmp_lib.mpz_init(num); + + // Set integer to numerator of rational, and increment integer by 2. + gmp_lib.mpq_get_num(num, op); + gmp_lib.mpz_add_ui(num, num, 2U); + + // Assert that num is 1, and op is -1 / 3. + Assert.IsTrue(gmp_lib.mpz_cmp_si(num, 1) == 0); + Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 3U) == 0); + + // Release unmanaged memory allocated for op and num. + gmp_lib.mpq_clear(op); + gmp_lib.mpz_clear(num); + } + + [TestMethod] + public void mpq_get_den() + { + // Create, initialize, and set the value of op to -1 / 3. + mpq_t op = new mpq_t(); + gmp_lib.mpq_init(op); + gmp_lib.mpq_set_si(op, -1, 3U); + + // Create and initialize a new integer. + mpz_t den = new mpz_t(); + gmp_lib.mpz_init(den); + + // Set integer to numerator of rational, and increment integer by 2.. + gmp_lib.mpq_get_den(den, op); + gmp_lib.mpz_add_ui(den, den, 2U); + + // Assert that num is 1, and op is -1 / 3. + Assert.IsTrue(gmp_lib.mpz_cmp_si(den, 5) == 0); + Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 3U) == 0); + + // Release unmanaged memory allocated for op and num. + gmp_lib.mpq_clear(op); + gmp_lib.mpz_clear(den); + } + + [TestMethod] + public void mpq_get_d() + { + // Create, initialize, and set the value of x to 10 / 11. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + gmp_lib.mpq_set_si(x, 10, 11U); + + // Assert that the value of x is 10.0. + Assert.IsTrue(gmp_lib.mpq_get_d(x) == 10.0 / 11.0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpq_clear(x); + } + + [TestMethod] + public void mpq_get_str() + { + // Create, initialize, and set the value of x to -210 / 13. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + gmp_lib.mpq_set_si(x, -210, 13U); + + // Retrieve the string value of x, and assert that it is "-210/13". + char_ptr s = gmp_lib.mpq_get_str(char_ptr.Zero, 10, x); + Assert.IsTrue(s.ToString() == "-210/13"); + + // Release unmanaged memory allocated for x and the string value. + gmp_lib.mpq_clear(x); + gmp_lib.free(s); + } + + [TestMethod] + public void mpq_init() + { + // Create and initialize a new rational x. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + + // Assert that the value of x is 0. + char_ptr s = gmp_lib.mpq_get_str(char_ptr.Zero, 10, x); + Assert.IsTrue(s.ToString() == "0"); + + // Release unmanaged memory allocated for x and its string value. + gmp_lib.mpq_clear(x); + gmp_lib.free(s); + } + + [TestMethod] + public void mpq_inits() + { + // Create new rationals x1, x2 and x3. + mpq_t x1 = new mpq_t(); + mpq_t x2 = new mpq_t(); + mpq_t x3 = new mpq_t(); + + // Initialize the rationals. + gmp_lib.mpq_inits(x1, x2, x3); + + // Assert that their value is 0. + Assert.IsTrue(gmp_lib.mpq_get_d(x1) == 0.0); + Assert.IsTrue(gmp_lib.mpq_get_d(x2) == 0.0); + Assert.IsTrue(gmp_lib.mpq_get_d(x3) == 0.0); + + // Release unmanaged memory allocated for the rationals. + gmp_lib.mpq_clears(x1, x2, x3, null); + } + + [TestMethod] + public void mpq_inp_str() + { + // Create, initialize, and set the value of op to 123/456. + mpq_t op = new mpq_t(); + gmp_lib.mpq_init(op); + + // Write rational to a temporary file. + string pathname = System.IO.Path.GetTempFileName(); + System.IO.File.WriteAllText(pathname, "123/456"); + + // Read op from the temporary file, and assert that the number of bytes read is 7. + ptr stream = new ptr(); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.mpq_inp_str(op, stream, 10) == 7); + fclose(stream.Value.Value); + + // Assert that op is 123/456. + Assert.IsTrue(gmp_lib.mpq_cmp_ui(op, 123, 456U) == 0); + + // Delete temporary file. + System.IO.File.Delete(pathname); + + // Release unmanaged memory allocated for op. + gmp_lib.mpq_clear(op); + } + + [TestMethod] + public void mpq_inv() + { + // Create, initialize, and set the value of number to -1 / 3. + mpq_t number = new mpq_t(); + gmp_lib.mpq_init(number); + gmp_lib.mpq_set_si(number, -1, 3U); + + // Create, initialize, and set the value of inverted_number to 0. + mpq_t inverted_number = new mpq_t(); + gmp_lib.mpq_init(inverted_number); + + // Set inverted_number = 1/(-1/3). + gmp_lib.mpq_inv(inverted_number, number); + + // Assert that inverted_number is -3 / 1. + Assert.IsTrue(gmp_lib.mpq_cmp_si(inverted_number, -3, 1U) == 0); + + // Release unmanaged memory allocated for inverted_number and number. + gmp_lib.mpq_clears(inverted_number, number, null); + } + + [TestMethod] + public void mpq_mul() + { + // Create, initialize, and set the value of x to 1 / 2. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + gmp_lib.mpq_set_si(x, 1, 2U); + + // Create, initialize, and set the value of y to -1 / 3. + mpq_t y = new mpq_t(); + gmp_lib.mpq_init(y); + gmp_lib.mpq_set_si(y, -1, 3U); + + // Create, initialize, and set the value of z to 0. + mpq_t z = new mpq_t(); + gmp_lib.mpq_init(z); + + // Set z = x * y. + gmp_lib.mpq_mul(z, x, y); + + // Assert that z is the product of x and y. + Assert.IsTrue(gmp_lib.mpq_cmp_si(z, -1, 6U) == 0); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpq_clears(x, y, z, null); + } + + [TestMethod] + public void mpq_mul_2exp() + { + // Create, initialize, and set the value of op to -1 / 3. + mpq_t op = new mpq_t(); + gmp_lib.mpq_init(op); + gmp_lib.mpq_set_si(op, -1, 3U); + + // Create, initialize, and set the value of rop to 0. + mpq_t rop = new mpq_t(); + gmp_lib.mpq_init(rop); + + // Set rop = (-1/3) * 2^3. + gmp_lib.mpq_mul_2exp(rop, op, 3U); + + // Assert that rop is -8 / 3. + Assert.IsTrue(gmp_lib.mpq_cmp_si(rop, -8, 3U) == 0); + + // Release unmanaged memory allocated for rop and op. + gmp_lib.mpq_clears(rop, op, null); + } + + [TestMethod] + public void mpq_neg() + { + // Create, initialize, and set the value of operand to -1 / 3. + mpq_t operand = new mpq_t(); + gmp_lib.mpq_init(operand); + gmp_lib.mpq_set_si(operand, -1, 3U); + + // Create, initialize, and set the value of negated_operand to 0. + mpq_t negated_operand = new mpq_t(); + gmp_lib.mpq_init(negated_operand); + + // Set negated_operand = -(-1/3). + gmp_lib.mpq_neg(negated_operand, operand); + + // Assert that negated_operand is -8 / 3. + Assert.IsTrue(gmp_lib.mpq_cmp_si(negated_operand, 1, 3U) == 0); + + // Release unmanaged memory allocated for negated_operand and operand. + gmp_lib.mpq_clears(negated_operand, operand, null); + } + + [TestMethod] + public void mpq_numref() + { + // Create, initialize, and set the value of op to -1 / 3. + mpq_t op = new mpq_t(); + gmp_lib.mpq_init(op); + gmp_lib.mpq_set_si(op, -1, 3U); + + // Get reference to numerator, and increment it by 2. + mpz_t num = gmp_lib.mpq_numref(op); + gmp_lib.mpz_add_ui(num, num, 2U); + + // Assert that op is 1 / 3. + Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 1, 3U) == 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpq_clear(op); + } + + [TestMethod] + public void mpq_out_str() + { + // Create, initialize, and set the value of op to 123/456. + mpq_t op = new mpq_t(); + gmp_lib.mpq_init(op); + gmp_lib.mpq_set_ui(op, 123, 456U); + + // Get a temporary file. + string pathname = System.IO.Path.GetTempFileName(); + + // Open temporary file for writing. + ptr stream = new ptr(); + _wfopen_s(out stream.Value.Value, pathname, "w"); + + // Write op to temporary file, and assert that the number of bytes written is 7. + Assert.IsTrue(gmp_lib.mpq_out_str(stream, 10, op) == 7); + + // Close temporary file. + fclose(stream.Value.Value); + + // Assert that the content of the temporary file is "123/456". + string result = System.IO.File.ReadAllText(pathname); + Assert.IsTrue(result == "123/456"); + + // Delete temporary file. + System.IO.File.Delete(pathname); + + // Release unmanaged memory allocated for op. + gmp_lib.mpq_clear(op); + } + + [TestMethod] + public void mpq_set() + { + // Create, initialize, and set a new rational x to 10 / 11. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + gmp_lib.mpq_set_si(x, 10, 11); + + // Create, initialize, and set a new rational y to -210 / 13. + mpq_t y = new mpq_t(); + gmp_lib.mpq_init(y); + gmp_lib.mpq_set_si(y, -210, 13); + + // Assign the value of y to x. + gmp_lib.mpq_set(x, y); + + // Assert that the value of x is -210 / 13. + Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 13) == 0); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpq_clears(x, y, null); + } + + [TestMethod] + public void mpq_set_d() + { + // Create and initialize a new rational. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + + // Set the value of x to 10.0 / 11.0. + gmp_lib.mpq_set_d(x, 10.0D / 11.0); + + // Assert that the value of x is 10.0 / 11.0. + Assert.IsTrue(gmp_lib.mpq_get_d(x) == 10.0D / 11.0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpq_clear(x); + } + + [TestMethod] + public void mpq_set_den() + { + // Create, initialize, and set the value of op to -1 / 3. + mpq_t op = new mpq_t(); + gmp_lib.mpq_init(op); + gmp_lib.mpq_set_si(op, -1, 3U); + + // Create, initialize, and set the value of a new integer to 5. + mpz_t den = new mpz_t(); + gmp_lib.mpz_init_set_ui(den, 5U); + + // Set the denominator of op. + gmp_lib.mpq_set_den(op, den); + + // Assert that op is -1 / 5. + Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5U) == 0); + + // Release unmanaged memory allocated for op and num. + gmp_lib.mpq_clear(op); + gmp_lib.mpz_clear(den); + } + + [TestMethod] + public void mpq_set_f() + { + // Create, initialize, and set a new rational x to 10 / 11. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + gmp_lib.mpq_set_si(x, 10, 11); + + // Create, initialize, and set a new float y to -210. + mpf_t y = new mpf_t(); + gmp_lib.mpf_init(y); + gmp_lib.mpf_set_si(y, -210); + + // Assign the value of y to x. + gmp_lib.mpq_set_f(x, y); + + // Assert that the value of x is -210 / 1. + Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 1) == 0); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpq_clear(x); + gmp_lib.mpf_clear(y); + } + + [TestMethod] + public void mpq_set_num() + { + // Create, initialize, and set the value of op to -1 / 3. + mpq_t op = new mpq_t(); + gmp_lib.mpq_init(op); + gmp_lib.mpq_set_si(op, -1, 3U); + + // Create, initialize, and set the value of a new integer to 5. + mpz_t num = new mpz_t(); + gmp_lib.mpz_init_set_ui(num, 5U); + + // Set the numerator of op. + gmp_lib.mpq_set_num(op, num); + + // Assert that op is 5 / 3. + Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 5, 3U) == 0); + + // Release unmanaged memory allocated for op and num. + gmp_lib.mpq_clear(op); + gmp_lib.mpz_clear(num); + } + + [TestMethod] + public void mpq_set_si() + { + // Create and initialize a new rational x. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + + // Set the value of x to -10 / 11. + gmp_lib.mpq_set_si(x, -10, 11); + + // Assert that the value of x is -10 / 1. + Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -10, 11U) == 0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpq_clear(x); + } + + [TestMethod] + public void mpq_set_str() + { + // Create and initialize a new rational x. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + + // Set the value of x. + char_ptr value = new char_ptr("12 345 678 909 876 543 211 234 567 890 987 654 321 / 234 567 890"); + gmp_lib.mpq_set_str(x, value, 10); + + // Assert the value of x. + char_ptr s = gmp_lib.mpq_get_str(char_ptr.Zero, 10, x); + Assert.IsTrue(s.ToString() == value.ToString().Replace(" ", "")); + + // Release unmanaged memory allocated for x and string values. + gmp_lib.mpq_clear(x); + gmp_lib.free(value); + gmp_lib.free(s); + } + + [TestMethod] + public void mpq_set_ui() + { + // Create and initialize a new rational x. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + + // Set the value of x to 10 / 11. + gmp_lib.mpq_set_ui(x, 10U, 11U); + + // Assert that the value of x is 10 / 11. + Assert.IsTrue(gmp_lib.mpq_cmp_ui(x, 10U, 11U) == 0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpq_clear(x); + } + + [TestMethod] + public void mpq_set_z() + { + // Create, initialize, and set a new rational x to 10 / 11. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + gmp_lib.mpq_set_si(x, 10, 11); + + // Create, initialize, and set a new integer y to -210. + mpz_t y = new mpz_t(); + gmp_lib.mpz_init(y); + gmp_lib.mpz_set_si(y, -210); + + // Assign the value of y to x. + gmp_lib.mpq_set_z(x, y); + + // Assert that the value of x is -210 / 1. + Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 1) == 0); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpq_clear(x); + gmp_lib.mpz_clear(y); + } + + [TestMethod] + public void mpq_sgn() + { + // Create, initialize, and set a new rational x to -10 / 11. + mpq_t op = new mpq_t(); + gmp_lib.mpq_init(op); + gmp_lib.mpq_set_si(op, -10, 11); + + // Assert that op is negative. + Assert.IsTrue(gmp_lib.mpq_sgn(op) == -1); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpq_clear(op); + } + + [TestMethod] + public void mpq_sub() + { + // Create, initialize, and set the value of x to 1 / 2. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + gmp_lib.mpq_set_si(x, 1, 2U); + + // Create, initialize, and set the value of y to 1 / 3. + mpq_t y = new mpq_t(); + gmp_lib.mpq_init(y); + gmp_lib.mpq_set_si(y, 1, 3U); + + // Create, initialize, and set the value of z to 0. + mpq_t z = new mpq_t(); + gmp_lib.mpq_init(z); + + // Set z = x - y. + gmp_lib.mpq_sub(z, x, y); + + // Assert that z = x - y. + Assert.IsTrue(gmp_lib.mpq_cmp_si(z, 1, 6U) == 0); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpq_clears(x, y, z, null); + } + + [TestMethod] + public void mpq_swap() + { + // Create, initialize, and set a new rational x to 10 / 11. + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + gmp_lib.mpq_set_si(x, 10, 11U); + + // Create, initialize, and set a new rational x to -210 / 13. + mpq_t y = new mpq_t(); + gmp_lib.mpq_init(y); + gmp_lib.mpq_set_si(y, -210, 13U); + + // Swap the values of x and y. + gmp_lib.mpq_swap(x, y); + + // Assert that the values have been swapped. + Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 13U) == 0); + Assert.IsTrue(gmp_lib.mpq_cmp_si(y, 10, 11U) == 0); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpq_clears(x, y, null); + } + + #endregion + + #region "Float (i.e. F) routines." + + [TestMethod] + public void mpf_abs() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to -10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, -10); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = |x|. + gmp_lib.mpf_neg(z, x); + + // Assert that the value of z is 10. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_add() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 10); + + // Create, initialize, and set a new floating-point number y to -210. + mpf_t y = new mpf_t(); + gmp_lib.mpf_init_set_si(y, -210); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = x + y. + gmp_lib.mpf_add(z, x, y); + + // Assert that the value of z is -200. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == -200.0); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpf_clears(x, y, z, null); + } + + [TestMethod] + public void mpf_add_ui() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 10); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = x + 210. + gmp_lib.mpf_add_ui(z, x, 210U); + + // Assert that the value of z is 220. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 220.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_ceil() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10.4. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_d(x, 10.4); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = ceil(x). + gmp_lib.mpf_ceil(z, x); + + // Assert that the value of z is 11. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 11.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_clear() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create and initialize a new floating-point number x. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init(x); + + // Assert that the value of x is 0.0. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_clears() + { + // Create new floating-point numbers x1, x2 and x3. + mpf_t x1 = new mpf_t(); + mpf_t x2 = new mpf_t(); + mpf_t x3 = new mpf_t(); + + // Initialize the floating-point numbers. + gmp_lib.mpf_inits(x1, x2, x3, null); + + // Assert that their value is 0. + Assert.IsTrue(gmp_lib.mpf_get_d(x1) == 0.0); + Assert.IsTrue(gmp_lib.mpf_get_d(x2) == 0.0); + Assert.IsTrue(gmp_lib.mpf_get_d(x3) == 0.0); + + // Release unmanaged memory allocated for the floating-point numbers. + gmp_lib.mpf_clears(x1, x2, x3, null); + } + + [TestMethod] + public void mpf_cmp() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 512. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 512); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init_set_si(z, 128); + + // Assert that x > z. + Assert.IsTrue(gmp_lib.mpf_cmp(x, z) > 0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_cmp_z() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 512. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 512); + + // Create and initialize a new floating-point number z. + mpz_t z = new mpz_t(); + gmp_lib.mpz_init_set_si(z, 128); + + // Assert that x > z. + Assert.IsTrue(gmp_lib.mpf_cmp_z(x, z) > 0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clear(x); + gmp_lib.mpz_clear(z); + } + + [TestMethod] + public void mpf_cmp_d() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 512. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 512); + + // Assert that x > 128.0. + Assert.IsTrue(gmp_lib.mpf_cmp_d(x, 128.0) > 0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_cmp_si() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 512. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 512); + + // Assert that x > 128. + Assert.IsTrue(gmp_lib.mpf_cmp_si(x, 128) > 0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_cmp_ui() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 512. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 512); + + // Assert that x > 128. + Assert.IsTrue(gmp_lib.mpf_cmp_ui(x, 128) > 0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_div() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 10); + + // Create, initialize, and set a new floating-point number y to -210. + mpf_t y = new mpf_t(); + gmp_lib.mpf_init_set_si(y, -210); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = y / x. + gmp_lib.mpf_div(z, y, x); + + // Assert that the value of z is -21. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == -21.0); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpf_clears(x, y, z, null); + } + + [TestMethod] + public void mpf_div_2exp() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 512. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 512); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = x / 2^8. + gmp_lib.mpf_div_2exp(z, x, 8U); + + // Assert that the value of z is 2. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 2.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_div_ui() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number y to -210. + mpf_t y = new mpf_t(); + gmp_lib.mpf_init_set_si(y, -210); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = y / 10. + gmp_lib.mpf_div_ui(z, y, 10U); + + // Assert that the value of z is -21. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == -21.0); + + // Release unmanaged memory allocated for y and z. + gmp_lib.mpf_clears(y, z, null); + } + + [TestMethod] + public void mpf_fits_sint_p() + { + // Create, initialize, and set the value of op 4294967295. + mpf_t op = new mpf_t(); + gmp_lib.mpf_init_set_ui(op, uint.MaxValue); + + // Assert that op does not fit in int. + Assert.IsTrue(gmp_lib.mpf_fits_sint_p(op) == 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpf_clear(op); + } + + [TestMethod] + public void mpf_fits_slong_p() + { + // Create, initialize, and set the value of op 4294967295. + mpf_t op = new mpf_t(); + gmp_lib.mpf_init_set_ui(op, uint.MaxValue); + + // Assert that op does not fit in long. + Assert.IsTrue(gmp_lib.mpf_fits_slong_p(op) == 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpf_clear(op); + } + + [TestMethod] + public void mpf_fits_sshort_p() + { + // Create, initialize, and set the value of op 4294967295. + mpf_t op = new mpf_t(); + gmp_lib.mpf_init_set_ui(op, uint.MaxValue); + + // Assert that op does not fit in short. + Assert.IsTrue(gmp_lib.mpf_fits_sshort_p(op) == 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpf_clear(op); + } + + [TestMethod] + public void mpf_fits_uint_p() + { + // Create, initialize, and set the value of op 4294967295. + mpf_t op = new mpf_t(); + gmp_lib.mpf_init_set_ui(op, uint.MaxValue); + + // Assert that op does not fit in uint. + Assert.IsTrue(gmp_lib.mpf_fits_uint_p(op) > 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpf_clear(op); + } + + [TestMethod] + public void mpf_fits_ulong_p() + { + // Create, initialize, and set the value of op 4294967295. + mpf_t op = new mpf_t(); + gmp_lib.mpf_init_set_ui(op, uint.MaxValue); + + // Assert that op does not fit in int. + Assert.IsTrue(gmp_lib.mpf_fits_sint_p(op) == 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpf_clear(op); + } + + [TestMethod] + public void mpf_fits_ushort_p() + { + // Create, initialize, and set the value of op 4294967295. + mpf_t op = new mpf_t(); + gmp_lib.mpf_init_set_ui(op, uint.MaxValue); + + // Assert that op does not fit in ushort. + Assert.IsTrue(gmp_lib.mpf_fits_ushort_p(op) == 0); + + // Release unmanaged memory allocated for op. + gmp_lib.mpf_clear(op); + } + + [TestMethod] + public void mpf_floor() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10.4. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_d(x, 10.4); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = floor(x). + gmp_lib.mpf_floor(z, x); + + // Assert that the value of z is 10. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_get_d() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number to -123.0 + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_d(x, -123.0); + + // Assert that the value of x is -123.0. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_get_d_2exp() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number to -8.0 + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_d(x, -8.0); + + // Assert that the absolute value of x is 0.5 x 2^4. + ptr exp = new ptr(0); + Assert.IsTrue(gmp_lib.mpf_get_d_2exp(exp, x) == 0.5); + Assert.IsTrue(exp.Value == 4); + + // Release unmanaged memory allocated for x and exp. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_get_default_prec() + { + // Set default precision to 128 bits. + gmp_lib.mpf_set_default_prec(128U); + + // Assert that the value of x is 128 bits. + Assert.IsTrue(gmp_lib.mpf_get_default_prec() == 128U); + } + + [TestMethod] + public void mpf_get_prec() + { + // Create and initialize a new floating-point number x with 64-bit precision. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init2(x, 64U); + + // Assert that the value of x is 0.0, and that its precision is 64 bits. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0); + Assert.IsTrue(gmp_lib.mpf_get_prec(x) == 64U); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_get_si() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number to -8.0 + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_d(x, -8.0); + + // Assert that the value of x is -8. + Assert.IsTrue(gmp_lib.mpf_get_si(x) == -8); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_get_str() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number to -8.0 + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_d(x, -8.0); + + // Assert that the value of x is -8. + ptr exp = new ptr(0); + char_ptr value = gmp_lib.mpf_get_str(char_ptr.Zero, exp, 10, 0, x); + Assert.IsTrue(value.ToString() == "-8"); + Assert.IsTrue(exp.Value == 1); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + gmp_lib.free(value); + } + + [TestMethod] + public void mpf_get_ui() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number to 8.0 + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_d(x, 8.0); + + // Assert that the value of x is -8. + Assert.IsTrue(gmp_lib.mpf_get_ui(x) == 8); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_init() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create and initialize a new floating-point number x. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init(x); + + // Assert that the value of x is 0.0. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_init2() + { + // Create and initialize a new floating-point number x with 64-bit precision. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init2(x, 64U); + + // Assert that the value of x is 0.0, and that its precision is 64 bits. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0); + uint p = gmp_lib.mpf_get_prec(x); + Assert.IsTrue(gmp_lib.mpf_get_prec(x) == 64U); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_inits() + { + // Create new floating-point numbers x1, x2 and x3. + mpf_t x1 = new mpf_t(); + mpf_t x2 = new mpf_t(); + mpf_t x3 = new mpf_t(); + + // Initialize the floating-point numbers. + gmp_lib.mpf_inits(x1, x2, x3, null); + + // Assert that their value is 0. + Assert.IsTrue(gmp_lib.mpf_get_d(x1) == 0.0); + Assert.IsTrue(gmp_lib.mpf_get_d(x2) == 0.0); + Assert.IsTrue(gmp_lib.mpf_get_d(x3) == 0.0); + + // Release unmanaged memory allocated for the floating-point numbers. + gmp_lib.mpf_clears(x1, x2, x3, null); + } + + [TestMethod] + public void mpf_init_set() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 10); + + // Create, initialize, and set a new floating-point number y to x. + mpf_t y = new mpf_t(); + gmp_lib.mpf_init_set(y, x); + + // Assert that the value of y is 10. + Assert.IsTrue(gmp_lib.mpf_get_d(y) == 10.0); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpf_clears(x, y, null); + } + + [TestMethod] + public void mpf_init_set_d() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number to -123.0 + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_d(x, -123.0); + + // Assert that the value of x is -123.0. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_init_set_si() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize and set a new floating-point number to -123. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, -123); + + // Assert that the value of x is -123. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_init_set_str() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 0.0234. + char_ptr value = new char_ptr("234e-4"); + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_str(x, value, 10); + + // Assert that x is 40. + Assert.IsTrue(x.ToString() == "0.234e-1"); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpf_clear(x); + gmp_lib.free(value); + } + + [TestMethod] + public void mpf_init_set_ui() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number to 100. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_ui(x, 100U); + + // Assert that the value of x is 100. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == 100.0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_inp_str() + { + // Create and initialize op. + mpf_t op = new mpf_t(); + gmp_lib.mpf_init(op); + + // Write op to a temporary file. + string pathname = System.IO.Path.GetTempFileName(); + System.IO.File.WriteAllText(pathname, "0.123456e6"); + + // Read op from the temporary file, and assert that the number of bytes read is 6. + ptr stream = new ptr(); + _wfopen_s(out stream.Value.Value, pathname, "r"); + Assert.IsTrue(gmp_lib.mpf_inp_str(op, stream, 10) == 10); + fclose(stream.Value.Value); + + // Assert that op is 123456. + Assert.IsTrue(gmp_lib.mpf_get_ui(op) == 123456U); + + // Delete temporary file. + System.IO.File.Delete(pathname); + + // Release unmanaged memory allocated for op. + gmp_lib.mpf_clear(op); + } + + [TestMethod] + public void mpf_integer_p() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_d(x, 10); + + // Assert that s is an integer. + Assert.IsTrue(gmp_lib.mpf_integer_p(x) != 0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_mul() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 10); + + // Create, initialize, and set a new floating-point number y to -210. + mpf_t y = new mpf_t(); + gmp_lib.mpf_init_set_si(y, -210); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = x * y. + gmp_lib.mpf_mul(z, x, y); + + // Assert that the value of z is -2100. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == -2100.0); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpf_clears(x, y, z, null); + } + + [TestMethod] + public void mpf_mul_2exp() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 100. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 100); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = x * 2^8. + gmp_lib.mpf_mul_2exp(z, x, 8U); + + // Assert that the value of z is 25600. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 25600.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_mul_ui() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 10); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = x * 210. + gmp_lib.mpf_mul_ui(z, x, 210U); + + // Assert that the value of z is 2100. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 2100.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_neg() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 10); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = -x. + gmp_lib.mpf_neg(z, x); + + // Assert that the value of z is -10. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == -10.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_out_str() + { + // Create, initialize, and set the value of op to 123456. + mpf_t op = new mpf_t(); + gmp_lib.mpf_init_set_ui(op, 123456U); + + // Get a temporary file. + string pathname = System.IO.Path.GetTempFileName(); + + // Open temporary file for writing. + ptr stream = new ptr(); + _wfopen_s(out stream.Value.Value, pathname, "w"); + + // Write op to temporary file, and assert that the number of bytes written is 10. + Assert.IsTrue(gmp_lib.mpf_out_str(stream, 10, 0, op) == 10); + + // Close temporary file. + fclose(stream.Value.Value); + + // Assert that the content of the temporary file is "123456". + string result = System.IO.File.ReadAllText(pathname); + Assert.IsTrue(result == "0.123456e6"); + + // Delete temporary file. + System.IO.File.Delete(pathname); + + // Release unmanaged memory allocated for op. + gmp_lib.mpf_clear(op); + } + + [TestMethod] + public void mpf_pow_ui() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 10); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = sqrt(x). + gmp_lib.mpf_pow_ui(z, x, 3U); + + // Assert that the value of z is 1000. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 1000.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_random2() + { + // Create, initialize, and set the value of rop to 0. + mpf_t rop = new mpf_t(); + gmp_lib.mpf_init(rop); + + // Generate a random floating-point number with at most 10 limbs and its exponent in [-5 5]. + gmp_lib.mpf_random2(rop, 10, 5); + + // Free all memory occupied by rop. + gmp_lib.mpf_clear(rop); + } + + [TestMethod] + public void mpf_reldiff() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 10); + + // Create, initialize, and set a new floating-point number y to -210. + mpf_t y = new mpf_t(); + gmp_lib.mpf_init_set_si(y, -210); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = |x - y| / x. + gmp_lib.mpf_reldiff(z, x, y); + + // Assert that the value of z is 22. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 22.0); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpf_clears(x, y, z, null); + } + + [TestMethod] + public void mpf_set() + { + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init2(x, 128U); + gmp_lib.mpf_set_si(x, 10); + + // Create, initialize, and set a new floating-point number y to -210. + mpf_t y = new mpf_t(); + gmp_lib.mpf_init2(y, 128U); + gmp_lib.mpf_set_si(y, -210); + + // Assign the value of y to x. + gmp_lib.mpf_set(x, y); + + // Assert that the value of x is -210. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == -210.0); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpf_clears(x, y, null); + } + + [TestMethod] + public void mpf_set_d() + { + // Create and initialize a new floating-point number. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init2(x, 128U); + + // Set x to -123.0. + gmp_lib.mpf_set_d(x, -123.0); + + // Assert that the value of x is -123.0. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_set_default_prec() + { + // Set default precision to 128 bits. + gmp_lib.mpf_set_default_prec(128U); + + // Assert that the value of x is 128 bits. + Assert.IsTrue(gmp_lib.mpf_get_default_prec() == 128U); + } + + [TestMethod] + public void mpf_set_prec() + { + // Create and initialize a new floating-point number x. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init(x); + + // Set its precision to 64 bits. + gmp_lib.mpf_set_prec(x, 64U); + + // Assert that the value of x is 0.0, and that its precision is 64 bits. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0); + Assert.IsTrue(gmp_lib.mpf_get_prec(x) == 64U); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_set_prec_raw() + { + // Set default precision to 128 bits. + gmp_lib.mpf_set_default_prec(128U); + + // Create, initialize, and set a new rational y to 200 / 3. + mpq_t y = new mpq_t(); + gmp_lib.mpq_init(y); + gmp_lib.mpq_set_ui(y, 200, 3U); + + // Create, initialize, and set a new floating-point number x to y. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init(x); + gmp_lib.mpf_set_q(x, y); + + Assert.IsTrue(x.ToString() == "0.6666666666666666666666666666666666666667e2"); + + // Change precision of x, and set its value to 10000 / 3. + gmp_lib.mpf_set_prec_raw(x, 8U); + gmp_lib.mpq_set_ui(y, 10000, 3U); + gmp_lib.mpf_set_q(x, y); + + Assert.IsTrue(x.ToString() == "0.333333333333333333333e4"); + + // Restore precision of x. + gmp_lib.mpf_set_prec_raw(x, 128U); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpf_clear(x); + gmp_lib.mpq_clear(y); + } + + [TestMethod] + public void mpf_set_q() + { + // Create, initialize, and set a new rational y to 200 / 5. + mpq_t y = new mpq_t(); + gmp_lib.mpq_init(y); + gmp_lib.mpq_set_ui(y, 200, 5U); + + // Create, initialize, and set a new floating-point number x to y. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init(x); + gmp_lib.mpf_set_q(x, y); + + // Assert that x is 40. + Assert.IsTrue(x.ToString() == "0.4e2"); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpf_clear(x); + gmp_lib.mpq_clear(y); + } + + [TestMethod] + public void mpf_set_si() + { + // Create and initialize a new floating-point number. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init2(x, 128U); + + // Set x to -123. + gmp_lib.mpf_set_si(x, -123); + + // Assert that the value of x is -123. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_set_str() + { + // Create, initialize, and set a new floating-point number x to 0.0234. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init(x); + char_ptr value = new char_ptr("234e-4"); + gmp_lib.mpf_set_str(x, value, 10); + + // Assert that x is 40. + Assert.IsTrue(x.ToString() == "0.234e-1"); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpf_clear(x); + gmp_lib.free(value); + } + + [TestMethod] + public void mpf_set_ui() + { + // Create and initialize a new floating-point number. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init2(x, 128U); + + // Set x to 100. + gmp_lib.mpf_set_ui(x, 100U); + + // Assert that the value of x is 100. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == 100.0); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_set_z() + { + // Create, initialize, and set a new integer y to 200. + mpz_t y = new mpz_t(); + gmp_lib.mpz_init(y); + gmp_lib.mpz_set_ui(y, 200U); + + // Create, initialize, and set a new floating-point number x to y. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init(x); + gmp_lib.mpf_set_z(x, y); + + // Assert that x is 200. + Assert.IsTrue(x.ToString() == "0.2e3"); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpf_clear(x); + gmp_lib.mpz_clear(y); + } + + [TestMethod] + public void mpf_sgn() + { + // Create, initialize, and set the value of op to -10. + mpf_t op = new mpf_t(); + gmp_lib.mpf_init_set_si(op, -10); + + // Assert that the sign of op is -1. + Assert.IsTrue(gmp_lib.mpf_sgn(op) == -1); + + // Release unmanaged memory allocated for op. + gmp_lib.mpf_clear(op); + } + + [TestMethod] + public void mpf_size() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x. + mpf_t x = "1.00000000000000000000001"; + + // Assert that the size of x is 1. + Assert.IsTrue(gmp_lib.mpf_size(x) == 4); + + // Release unmanaged memory allocated for x. + gmp_lib.mpf_clear(x); + } + + [TestMethod] + public void mpf_sqrt() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 100. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 100); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = sqrt(x). + gmp_lib.mpf_sqrt(z, x); + + // Assert that the value of z is 10. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_sqrt_ui() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = sqrt(100). + gmp_lib.mpf_sqrt_ui(z, 100U); + + // Assert that the value of z is 10. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clear(z); + } + + [TestMethod] + public void mpf_sub() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 10); + + // Create, initialize, and set a new floating-point number y to -210. + mpf_t y = new mpf_t(); + gmp_lib.mpf_init_set_si(y, -210); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = x - y. + gmp_lib.mpf_sub(z, x, y); + + // Assert that the value of z is 220. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 220.0); + + // Release unmanaged memory allocated for x, y, and z. + gmp_lib.mpf_clears(x, y, z, null); + } + + [TestMethod] + public void mpf_sub_ui() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 10); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = x - 200. + gmp_lib.mpf_sub_ui(z, x, 200U); + + // Assert that the value of z is -190. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == -190.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_swap() + { + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init2(x, 128U); + gmp_lib.mpf_set_si(x, 10); + + // Create, initialize, and set a new floating-point number y to -210. + mpf_t y = new mpf_t(); + gmp_lib.mpf_init2(y, 128U); + gmp_lib.mpf_set_si(y, -210); + + // Swap the values of x and y. + gmp_lib.mpf_swap(x, y); + + // Assert that the value of x is -210. + Assert.IsTrue(gmp_lib.mpf_get_d(x) == -210.0); + + // Assert that the value of y is 10. + Assert.IsTrue(gmp_lib.mpf_get_d(y) == 10.0); + + // Release unmanaged memory allocated for x and y. + gmp_lib.mpf_clears(x, y, null); + } + + [TestMethod] + public void mpf_trunc() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10.4. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_d(x, 10.4); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = trunc(x). + gmp_lib.mpf_trunc(z, x); + + // Assert that the value of z is 10. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_ui_div() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number x to 10. + mpf_t x = new mpf_t(); + gmp_lib.mpf_init_set_si(x, 10); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = 210 / x. + gmp_lib.mpf_ui_div(z, 210U, x); + + // Assert that the value of z is 21. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 21.0); + + // Release unmanaged memory allocated for x and z. + gmp_lib.mpf_clears(x, z, null); + } + + [TestMethod] + public void mpf_ui_sub() + { + // Set default precision to 64 bits. + gmp_lib.mpf_set_default_prec(64U); + + // Create, initialize, and set a new floating-point number y to -210. + mpf_t y = new mpf_t(); + gmp_lib.mpf_init_set_si(y, -210); + + // Create and initialize a new floating-point number z. + mpf_t z = new mpf_t(); + gmp_lib.mpf_init(z); + + // Set z = 10 - y. + gmp_lib.mpf_ui_sub(z, 10U, y); + + // Assert that the value of z is 220. + Assert.IsTrue(gmp_lib.mpf_get_d(z) == 220.0); + + // Release unmanaged memory allocated for y, and z. + gmp_lib.mpf_clears(y, z, null); + } + + [TestMethod] + public void mpf_urandomb() + { + // Create, initialize, and seed a new random number generator. + gmp_randstate_t state = new gmp_randstate_t(); + gmp_lib.gmp_randinit_mt(state); + gmp_lib.gmp_randseed_ui(state, 100000U); + + // Create, initialize, and set the value of rop to 0. + mpf_t rop = new mpf_t(); + gmp_lib.mpf_init(rop); + + // Generate a random integer in the range [0, 1) with 50 bits precision. + gmp_lib.mpf_urandomb(rop, state, 50); + + // Free all memory occupied by state and rop. + gmp_lib.gmp_randclear(state); + gmp_lib.mpf_clear(rop); + } + + #endregion + + #region "Low level positive-integer (i.e. N) routines." + + [TestMethod] + public void mpn_add() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + + // Set rp = s1 + s2. + mp_limb_t carry = gmp_lib.mpn_add(rp, s1p, s1p.Size, s2p, s2p.Size); + + // Assert result of operation. + Assert.IsTrue(carry == 1); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_add_1() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + + // Set rp = s1 + 1. + mp_limb_t carry = gmp_lib.mpn_add_1(rp, s1p, s1p.Size, 1); + + // Assert result of operation. + Assert.IsTrue(carry == 1); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, result); + } + + [TestMethod] + public void mpn_add_n() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + + // Set rp = s1 + s2. + mp_limb_t carry = gmp_lib.mpn_add_n(rp, s1p, s2p, rp.Size); + + // Assert result of operation. + Assert.IsTrue(carry == 1); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_addmul_1() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr rp = new mp_ptr(new uint[] { 0x00000002, 0x00000000 }); + mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + + // Set rp += s1 * 2. + mp_limb_t carry = gmp_lib.mpn_addmul_1(rp, s1p, s1p.Size, 2); + + // Assert result of operation. + Assert.IsTrue(carry == 0x02); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, result); + } + + [TestMethod] + public void mpn_cmp() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + + // Assert s1p > s2p. + Assert.IsTrue(gmp_lib.mpn_cmp(s1p, s2p, s1p.Size) > 0); + + // Release unmanaged memory. + gmp_lib.free(s1p, s2p); + } + + [TestMethod] + public void mpn_zero_p() + { + // Create multi-precision operand. + mp_ptr sp = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + + // Assert sp == 0. + Assert.IsTrue(gmp_lib.mpn_zero_p(sp, sp.Size) == 1); + + // Release unmanaged memory. + gmp_lib.free(sp); + } + + [TestMethod] + public void mpn_divexact_1() + { + // Create multi-precision operands, and expected result. + mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x55555555, 0x00005555 }); + + // Set rp = sp / 3. + gmp_lib.mpn_divexact_1(rp, sp, sp.Size, 0x3); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, sp, result); + } + + [TestMethod] + public void mpn_divexact_by3() + { + // Create multi-precision operands, and expected result. + mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x55555555, 0x00005555 }); + + // Set rp = sp / 3. + mp_limb_t remainder = gmp_lib.mpn_divexact_by3(rp, sp, sp.Size); + + // Assert result of operation. + Assert.IsTrue(remainder == 0); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, sp, result); + } + + [TestMethod] + public void mpn_divexact_by3c() + { + // Create multi-precision operands, and expected result. + mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xaaaaaaaa, 0x5555aaaa }); + + // Set rp = sp / 3. + mp_limb_t remainder = gmp_lib.mpn_divexact_by3c(rp, sp, sp.Size, 1); + + // Assert result of operation. + Assert.IsTrue(remainder == 1); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, sp, result); + } + + [TestMethod] + public void mpn_divrem_1() + { + // Create multi-precision operands, and expected result. + mp_ptr s2p = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + mp_ptr r1p = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x435e50d7, 0x00000d79 }); + + // Set r1p = s2p / 19. + mp_limb_t remainder = gmp_lib.mpn_divrem_1(r1p, 0, s2p, s2p.Size, 0x13); + + // Assert result of operation. + Assert.IsTrue(remainder == 10); + Assert.IsTrue(r1p.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(r1p, s2p, result); + } + + [TestMethod] + public void mpn_divmod_1() + { + // Create multi-precision operands, and expected result. + mp_ptr s2p = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + mp_ptr r1p = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x435e50d7, 0x00000d79 }); + + // Set r1p = s2p / 19. + mp_limb_t remainder = gmp_lib.mpn_divmod_1(r1p, s2p, s2p.Size, 0x13); + + // Assert result of operation. + Assert.IsTrue(remainder == 10); + Assert.IsTrue(r1p.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(r1p, s2p, result); + } + + [TestMethod] + public void mpn_gcd() + { + // Create multi-precision operands, and expected result. + mp_ptr xp = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 }); + mp_ptr yp = new mp_ptr(new uint[] { 0xc2d24d55, 0x00000007 }); + mp_ptr rp = new mp_ptr(yp.Size); + mp_ptr result = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 }); + + // Set rp = gcd(xp, yp). + mp_size_t size = gmp_lib.mpn_gcd(rp, xp, xp.Size, yp, yp.Size); + + // Assert result of operation. + Assert.IsTrue(size == result.Size); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, xp, yp, result); + } + + [TestMethod] + public void mpn_gcd_1() + { + // Create multi-precision operand. + mp_ptr xp = new mp_ptr(new uint[] { 0x00000000, 0x00000001 }); + + // Assert result of operation. + Assert.IsTrue(gmp_lib.mpn_gcd_1(xp, xp.Size, 1073741824) == 1073741824); + + // Release unmanaged memory. + gmp_lib.free(xp); + } + + [TestMethod] + public void mpn_gcdext() + { + // Create multi-precision operands, and expected result. + mp_ptr up = new mp_ptr(new uint[] { 0x40000000, 0x00000000 }); + mp_ptr vp = new mp_ptr(new uint[] { 0x00000000, 0x00000001 }); + mp_ptr gp = new mp_ptr(new uint[vp.Size * (IntPtr.Size / 4)]); + mp_ptr sp = new mp_ptr(new uint[(vp.Size + 1) * (IntPtr.Size / 4)]); + mp_ptr result = new mp_ptr(new uint[] { 0x40000000, 0x00000000 }); + mp_ptr cofactor = new mp_ptr(new uint[] { 0x00000001, 0x00000000, 0x00000000 }); + + // Set gp = gcd(up, vp). + ptr sn = new ptr(0); + mp_size_t size = gmp_lib.mpn_gcdext(gp, sp, sn, up, up.Size, vp, vp.Size); + + // Assert result. + Assert.IsTrue(size == 1); + Assert.IsTrue(gp.SequenceEqual(result)); + Assert.IsTrue(sn.Value == 1); + Assert.IsTrue(sp.SequenceEqual(cofactor)); + + // Release unmanaged memory. + gmp_lib.free(gp, up, vp, sp, result, cofactor); + } + + [TestMethod] + public void mpn_get_str() + { + // Create multi-precision operands. + mp_ptr s1p = new mp_ptr(new uint[] { 0x00000001, 0x00000001 }); + char_ptr str = new char_ptr("xxxxxxxxxxxxxxxxx"); + + // Convert s1p to hex string. + size_t count = gmp_lib.mpn_get_str(str, 16, s1p, s1p.Size); + + // Copy out str to bytes. + byte[] s = new byte[count]; + Marshal.Copy(str.ToIntPtr(), s, 0, (int)count); + + // Assert the non-ASCII, hex representation of s1p. + Assert.IsTrue(s.SequenceEqual(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 1 })); + + // Release unmanaged memory. + gmp_lib.free(s1p); + gmp_lib.free(str); + } + + [TestMethod] + public void mpn_hamdist() + { + // Create multi-precision operands. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0xffffffff }); + + // Assert hamming distance. + Assert.IsTrue(gmp_lib.mpn_hamdist(s1p, s2p, s1p.Size) == 31); + + // Release unmanaged memory. + gmp_lib.free(s1p, s2p); + } + + [TestMethod] + public void mpn_lshift() + { + // Create multi-precision operands, and expected result. + mp_ptr sp = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xfffffffc, 0xffffffff }); + + // Set rp = sp << 1. + mp_limb_t bits = gmp_lib.mpn_lshift(rp, sp, sp.Size, 1); + + // Assert result of operation. + Assert.IsTrue(bits == 1); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, sp, result); + } + + [TestMethod] + public void mpn_mod_1() + { + // Create multi-precision operand. + mp_ptr s1p = new mp_ptr(new uint[] { 0xfffffffe, 0x0000ffff }); + + // Assert s1p mod 3 is 2. + Assert.IsTrue(gmp_lib.mpn_mod_1(s1p, s1p.Size, 3) == 2); + + // Release unmanaged memory. + gmp_lib.free(s1p); + } + + [TestMethod] + public void mpn_mul() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000002 }); + mp_ptr rp = new mp_ptr(new uint[3]); + mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff, 0x00000001 }); + + // Set rp = s1 * s2. + gmp_lib.mpn_mul(rp, s1p, s1p.Size, s2p, s2p.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_mul_1() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + + // Set rp = s1 * 2. + mp_limb_t carry = gmp_lib.mpn_mul_1(rp, s1p, s1p.Size, 2); + + // Assert result of operation. + Assert.IsTrue(carry == 1); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, result); + } + + [TestMethod] + public void mpn_mul_n() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000002, 0x00000000 }); + mp_ptr rp = new mp_ptr(new uint[4]); + mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff, 0x00000001, 0x00000000 }); + + // Set rp = s1 * s2. + gmp_lib.mpn_mul_n(rp, s1p, s2p, s1p.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_sqr() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr rp = new mp_ptr(new uint[4]); + mp_ptr result = new mp_ptr(new uint[] {0x00000001, 0x00000000, 0xfffffffe, 0xffffffff }); + + // Set rp = s1^2. + gmp_lib.mpn_sqr(rp, s1p, s1p.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, result); + } + + [TestMethod] + public void mpn_neg() + { + // Create multi-precision operands, and expected result. + mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x0000001, 0x00000000 }); + + // Set rp = -sp. + mp_limb_t borrow = gmp_lib.mpn_neg(rp, sp, sp.Size); + + // Assert result of operation. + Assert.IsTrue(borrow == 1); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, sp, result); + } + + [TestMethod] + public void mpn_com() + { + // Create multi-precision operands, and expected result. + mp_ptr sp = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x0f0f0f0f, 0x0f0f0f0f }); + + // Set rp = not(sp). + gmp_lib.mpn_com(rp, sp, sp.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, sp, result); + } + + [TestMethod] + public void mpn_perfect_square_p() + { + // Create multi-precision operand. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + + // Assert s1p is not a perfect square. + Assert.IsTrue(gmp_lib.mpn_perfect_square_p(s1p, s1p.Size) == 0); + + // Release unmanaged memory. + gmp_lib.free(s1p); + } + + [TestMethod] + public void mpn_perfect_power_p() + { + // Create multi-precision operand. + mp_ptr s1p = new mp_ptr(new uint[] { 0xd4a51000, 0x000000e8 }); + + // Assert s1p is a perfect power. + Assert.IsTrue(gmp_lib.mpn_perfect_power_p(s1p, s1p.Size) != 0); + + // Release unmanaged memory. + gmp_lib.free(s1p); + } + + [TestMethod] + public void mpn_popcount() + { + // Create multi-precision operand. + mp_ptr s1p = new mp_ptr(new uint[] { 0x0000001, 0x00000001 }); + + // Assert result of operation. + Assert.IsTrue(gmp_lib.mpn_popcount(s1p, s1p.Size) == 2); + + // Release unmanaged memory. + gmp_lib.free(s1p); + } + + [TestMethod] + public void mpn_random() + { + // Create multi-precision operand. + mp_ptr r1p = new mp_ptr(new uint[2]); + + // Generate random number. + gmp_lib.mpn_random(r1p, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 1); + + // Release unmanaged memory. + gmp_lib.free(r1p); + } + + [TestMethod] + public void mpn_random2() + { + // Create multi-precision operand. + mp_ptr r1p = new mp_ptr(new uint[2]); + + // Generate random number. + gmp_lib.mpn_random2(r1p, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 1); + + // Release unmanaged memory. + gmp_lib.free(r1p); + } + + [TestMethod] + public void mpn_rshift() + { + // Create multi-precision operands, and expected result. + mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xffffffff, 0x7fffffff }); + + // Set rp = sp >> 1. + mp_limb_t bits = gmp_lib.mpn_rshift(rp, sp, sp.Size, 1); + + // Assert result of operation. + Assert.IsTrue(bits == (gmp_lib.mp_bytes_per_limb == 4 ? 0x80000000 : 0x8000000000000000)); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, sp, result); + } + + [TestMethod] + public void mpn_scan0() + { + // Create multi-precision operand. + mp_ptr s1p = new mp_ptr(new uint[] { 0x0000001, 0x00000001 }); + + // Assert result of operation. + Assert.IsTrue(gmp_lib.mpn_scan0(s1p, 0) == 1); + + // Release unmanaged memory. + gmp_lib.free(s1p); + } + + [TestMethod] + public void mpn_scan1() + { + // Create multi-precision operand. + mp_ptr s1p = new mp_ptr(new uint[] { 0x0000001, 0x00000001 }); + + // Assert result of operation. + Assert.IsTrue(gmp_lib.mpn_scan1(s1p, 1) == 32); + + // Release unmanaged memory. + gmp_lib.free(s1p); + } + + [TestMethod] + public void mpn_set_str() + { + // Create multi-precision operands. + mp_ptr rp = new mp_ptr(new uint[2]); + byte[] s = new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 1 }; + mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x00000001 }); + char_ptr str = new char_ptr("xxxxxxxxxxxxxxxxx"); + Marshal.Copy(s, 0, str.ToIntPtr(), 9); + + // Convert rp from str in hex base. + mp_size_t count = gmp_lib.mpn_set_str(rp, str, 9, 16); + + // Assert the non-ASCII, hex representation of s1p. + Assert.IsTrue(count == rp.Size); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp); + gmp_lib.free(str); + } + + [TestMethod] + public void mpn_sizeinbase() + { + // Create multi-precision operands, and expected result. + mp_ptr xp = new mp_ptr(new uint[] { 0x00000001, 0x00000001 }); + + // Assert that the number of bits required is 33. + Assert.IsTrue(gmp_lib.mpn_sizeinbase(xp, xp.Size, 2) == 33); + + // Release unmanaged memory. + gmp_lib.free(xp); + } + + [TestMethod] + public void mpn_sqrtrem() + { + // Create multi-precision operands, and expected result. + mp_ptr sp = new mp_ptr(new uint[] { 0x00000001, 0x00000001 }); + mp_ptr r1p = new mp_ptr(new uint[sp.Size * (gmp_lib.mp_bytes_per_limb / 4)]); + mp_ptr r2p = new mp_ptr(new uint[sp.Size * (gmp_lib.mp_bytes_per_limb / 4)]); + mp_ptr result = new mp_ptr(new uint[] { 0x00010000, 0x00000000 }); + mp_ptr remainder = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + + // Set r1p = trunc(sqrt(sp)), r2p = sp - r1p^2 + mp_size_t r2n = gmp_lib.mpn_sqrtrem(r1p, r2p, sp, sp.Size); + + // Assert result. + Assert.IsTrue(r2n == 1); + Assert.IsTrue(r1p.SequenceEqual(result)); + Assert.IsTrue(r2p.SequenceEqual(remainder)); + + // Release unmanaged memory. + gmp_lib.free(sp, r1p, r2p, result); + } + + [TestMethod] + public void mpn_sub() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + + // Set rp = s1 - s2. + mp_limb_t borrow = gmp_lib.mpn_sub(rp, s1p, s1p.Size, s2p, s2p.Size); + + // Assert result of operation. + Assert.IsTrue(borrow == 0); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_sub_1() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + + // Set rp = s1 - 1. + mp_limb_t borrow = gmp_lib.mpn_sub_1(rp, s1p, s1p.Size, 1); + + // Assert result of operation. + Assert.IsTrue(borrow == 0); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, result); + } + + [TestMethod] + public void mpn_sub_n() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + + // Set rp = s1 - s2. + mp_limb_t borrow = gmp_lib.mpn_sub_n(rp, s1p, s2p, rp.Size); + + // Assert result of operation. + Assert.IsTrue(borrow == 0); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_submul_1() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr rp = new mp_ptr(new uint[] { 0x00000002, 0x00000000 }); + mp_ptr result = new mp_ptr(new uint[] { 0x00000004, 0x00000000 }); + + // Set rp -= s1 * 2. + mp_limb_t borrow = gmp_lib.mpn_submul_1(rp, s1p, s1p.Size, 2); + + // Assert result of operation. + Assert.IsTrue(borrow == 0x02); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, result); + } + + [TestMethod] + public void mpn_tdiv_qr() + { + // Create multi-precision operands, and expected result. + mp_ptr np = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + mp_ptr dp = new mp_ptr(new uint[] { 0x00000013 }); + mp_ptr qp = new mp_ptr(new uint[np.Size - dp.Size + 1]); + mp_ptr rp = new mp_ptr(new uint[dp.Size]); + mp_ptr quotient = new mp_ptr(new uint[] { 0x435e50d7, 0x00000d79 }); + mp_ptr remainder = new mp_ptr(new uint[] { 0x0000000a }); + + // Set rp = np / dp. + gmp_lib.mpn_tdiv_qr(qp, rp, 0, np, np.Size, dp, dp.Size); + + // Assert result of operation. + Assert.IsTrue(qp.SequenceEqual(quotient)); + Assert.IsTrue(rp.SequenceEqual(remainder)); + + // Release unmanaged memory. + gmp_lib.free(qp, rp, np, dp, quotient, remainder); + } + + [TestMethod] + public void mpn_and_n() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + + // Set rp = s1 and s2. + gmp_lib.mpn_and_n(rp, s1p, s2p, s1p.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_andn_n() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xedcba987 }); + + // Set rp = s1 and not s2. + gmp_lib.mpn_andn_n(rp, s1p, s2p, s1p.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_nand_n() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + + // Set rp = not(s1 and s2). + gmp_lib.mpn_and_n(rp, s1p, s2p, s1p.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_ior_n() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + + // Set rp = s1 or s2. + gmp_lib.mpn_ior_n(rp, s1p, s2p, s1p.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_iorn_n() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + + // Set rp = s1 or not s2. + gmp_lib.mpn_iorn_n(rp, s1p, s2p, s1p.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_nior_n() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + + // Set rp = not (s1 or s2). + gmp_lib.mpn_nior_n(rp, s1p, s2p, s1p.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_xor_n() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xedcba987 }); + + // Set rp = s1 xor s2. + gmp_lib.mpn_xor_n(rp, s1p, s2p, s1p.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_xnor_n() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + + // Set rp = not(s1 xor s2). + gmp_lib.mpn_xnor_n(rp, s1p, s2p, s1p.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_copyi() + { + // Create multi-precision operands, and expected result. + mp_ptr sp = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 }); + + // Set rp = sp. + gmp_lib.mpn_copyi(rp, sp, sp.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, sp, result); + } + + [TestMethod] + public void mpn_copyd() + { + // Create multi-precision operands, and expected result. + mp_ptr sp = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 }); + + // Set rp = sp. + gmp_lib.mpn_copyd(rp, sp, sp.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, sp, result); + } + + [TestMethod] + public void mpn_zero() + { + // Create multi-precision operand, and expected result. + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + + // Set rp = sp. + gmp_lib.mpn_zero(rp, rp.Size); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, result); + } + + [TestMethod] + public void mpn_cnd_add_n() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + + // Set rp = s1 + s2. + mp_limb_t carry = gmp_lib.mpn_cnd_add_n(1, rp, s1p, s2p, rp.Size); + + // Assert result of operation. + Assert.IsTrue(carry == 1); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_cnd_sub_n() + { + // Create multi-precision operands, and expected result. + mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + mp_ptr rp = new mp_ptr(new uint[2]); + mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + + // Set rp = s1 - s2. + mp_limb_t borrow = gmp_lib.mpn_cnd_sub_n(1, rp, s1p, s2p, rp.Size); + + // Assert result of operation. + Assert.IsTrue(borrow == 0); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, s1p, s2p, result); + } + + [TestMethod] + public void mpn_sec_add_1() + { + // Create multi-precision operands, and expected result. + mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + mp_ptr rp = new mp_ptr(result.Size); + + // Create scratch space. + mp_size_t size = gmp_lib.mpn_sec_add_1_itch(ap.Size); + mp_ptr tp = new mp_ptr(size); + + // Set rp = ap + 1. + mp_limb_t carry = gmp_lib.mpn_sec_add_1(rp, ap, ap.Size, 1, tp); + + // Assert result of operation. + Assert.IsTrue(carry == 1); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, ap, tp, result); + } + + [TestMethod] + public void mpn_sec_sub_1() + { + // Create multi-precision operands, and expected result. + mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + mp_ptr rp = new mp_ptr(result.Size); + + // Create scratch space. + mp_size_t size = gmp_lib.mpn_sec_sub_1_itch(ap.Size); + mp_ptr tp = new mp_ptr(size); + + // Set rp = ap - 1. + mp_limb_t borrow = gmp_lib.mpn_sec_sub_1(rp, ap, ap.Size, 1, tp); + + // Assert result of operation. + Assert.IsTrue(borrow == 0); + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, ap, tp, result); + } + + [TestMethod] + public void mpn_cnd_swap() + { + // Create multi-precision operands, and expected result. + mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr bp = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + mp_ptr a1p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + mp_ptr b1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + + // Exchange ab and bp. + gmp_lib.mpn_cnd_swap(1, ap, bp, ap.Size); + + // Assert result of operation. + Assert.IsTrue(ap.SequenceEqual(a1p)); + Assert.IsTrue(bp.SequenceEqual(b1p)); + + // Release unmanaged memory. + gmp_lib.free(ap, bp, a1p, b1p); + } + + [TestMethod] + public void mpn_sec_mul() + { + // Create multi-precision operands, and expected result. + mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr bp = new mp_ptr(new uint[] { 0x00000002 }); + mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff, 0x00000001 }); + mp_ptr rp = new mp_ptr(ap.Size + bp.Size); + + // Create scratch space. + mp_size_t size = gmp_lib.mpn_sec_mul_itch(ap.Size, bp.Size); + mp_ptr tp = new mp_ptr(size); + + // Set rp = ap * bp. + gmp_lib.mpn_sec_mul(rp, ap, ap.Size, bp, bp.Size, tp); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, ap, bp, tp, result); + } + + [TestMethod] + public void mpn_sec_sqr() + { + // Create multi-precision operands, and expected result. + mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x00000000, 0xfffffffe, 0xffffffff }); + mp_ptr rp = new mp_ptr(2 * ap.Size); + + // Create scratch space. + mp_size_t size = gmp_lib.mpn_sec_sqr_itch(ap.Size); + mp_ptr tp = new mp_ptr(size); + + // Set rp = s1^2. + gmp_lib.mpn_sec_sqr(rp, ap, ap.Size, tp); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, ap, tp, result); + } + + [TestMethod] + public void mpn_sec_powm() + { + // Create multi-precision operands, and expected result. + mp_ptr bp = new mp_ptr(new uint[] { 0x00000002 }); + mp_ptr ep = new mp_ptr(new uint[] { 0x00000004 }); + mp_ptr mp = new mp_ptr(new uint[] { 0x00000003 }); + mp_ptr result = new mp_ptr(new uint[] { 0x00000001 }); + mp_ptr rp = new mp_ptr(bp.Size); + + // Create scratch space. + mp_size_t size = gmp_lib.mpn_sec_powm_itch(bp.Size, 3, mp.Size); + mp_ptr tp = new mp_ptr(size); + + // Set rp = bp^ep mod mp. + gmp_lib.mpn_sec_powm(rp, bp, bp.Size, ep, 3, mp, mp.Size, tp); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(rp, bp, ep, mp, tp, result); + } + + [TestMethod] + public void mpn_sec_tabselect() + { + // Create multi-precision operands, and expected result. + mp_ptr tab = new mp_ptr(new uint[] { 0x11111111, 0x22222222, 0x33333333, 0x44444444, 0x33333333, 0x00000000 }); + mp_ptr result = new mp_ptr(new uint[] { 0x33333333 }); + mp_ptr rp = new mp_ptr(result.Size); + + // Set rp to third entry in tab. + gmp_lib.mpn_sec_tabselect(rp, tab, 1, tab.Size, 2); + + // Assert result of operation. + Assert.IsTrue(rp.SequenceEqual(result)); + + // Release unmanaged memory. + gmp_lib.free(tab, result); + } + + [TestMethod] + public void mpn_sec_div_qr() + { + // Create multi-precision operands, and expected result. + mp_ptr np = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + mp_ptr dp = new mp_ptr(new uint[] { 0x00000003 }); + mp_ptr remainder = new mp_ptr(new uint[] { 0x00000000 }); + mp_ptr qp = new mp_ptr(new uint[np.Size]); + + // Create scratch space. + mp_size_t size = gmp_lib.mpn_sec_div_qr_itch(np.Size, dp.Size); + mp_ptr tp = new mp_ptr(size); + + // Set qp = floor(np / dp) and rp = np mod dp. + mp_limb_t mslimb = gmp_lib.mpn_sec_div_qr(qp, np, np.Size, dp, dp.Size, tp); + + // Assert result of operation. + Assert.IsTrue(mslimb == (ulong)(gmp_lib.mp_bytes_per_limb == 4 ? 0x00005555 : 0x0000555555555555)); + Assert.IsTrue(qp[0] == (ulong)(gmp_lib.mp_bytes_per_limb == 4 ? 0x55555555 : 0x0000000000000000)); + Assert.IsTrue(np[0] == remainder[0]); + + // Release unmanaged memory. + gmp_lib.free(qp, np, dp, remainder, tp); + } + + [TestMethod] + public void mpn_sec_div_r() + { + // Create multi-precision operands, and expected result. + mp_ptr np = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + mp_ptr dp = new mp_ptr(new uint[] { 0x00000004 }); + + // Create scratch space. + mp_size_t size = gmp_lib.mpn_sec_div_r_itch(np.Size, dp.Size); + mp_ptr tp = new mp_ptr(size); + + // Set np = np mod dp. + gmp_lib.mpn_sec_div_r(np, np.Size, dp, dp.Size, tp); + + // Assert result of operation. + Assert.IsTrue(np[0] == 3); + + // Release unmanaged memory. + gmp_lib.free(np, dp, tp); + } + + [TestMethod] + public void mpn_sec_invert() + { + // Create multi-precision operands, and expected result. + mp_ptr ap = new mp_ptr(new uint[] { 3 }); + mp_ptr mp = new mp_ptr(new uint[] { 11 }); + mp_ptr rp = new mp_ptr(ap.Size); + mp_ptr result = new mp_ptr(new uint[] { 4 }); + + // Create scratch space. + mp_size_t size = gmp_lib.mpn_sec_invert_itch(ap.Size); + mp_ptr tp = new mp_ptr(size); + + // Set rp = ap^-1 mod mp. + gmp_lib.mpn_sec_invert(rp, ap, mp, ap.Size, (uint)(2 * ap.Size * gmp_lib.mp_bits_per_limb), tp); + + // Assert result of operation. + Assert.IsTrue(rp[0] == result[0]); + + // Release unmanaged memory. + gmp_lib.free(ap, mp, rp, result, tp); + } + + #endregion + + } +} diff --git a/Math.Gmp.Native.sln b/Math.Gmp.Native.sln new file mode 100644 index 0000000..aab2590 --- /dev/null +++ b/Math.Gmp.Native.sln @@ -0,0 +1,107 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{68DC166D-565A-4F3D-B777-B8E384F26864}" + ProjectSection(SolutionItems) = preProject + LICENSE.md = LICENSE.md + README.md = README.md + EndProjectSection +EndProject +Project("{7CF6DF6D-3B04-46F8-A40B-537D21BCA0B4}") = "Documentation", "Documentation\Documentation.shfbproj", "{CE631E64-52BF-4527-99AD-1EAEB76550A8}" + ProjectSection(ProjectDependencies) = postProject + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A} = {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A} + EndProjectSection +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "docs", "docs\docs.shproj", "{39B1E62E-D491-495F-8E90-B7D09B76D8A1}" +EndProject +Project("{E09DD79A-4488-4AB9-8D3F-A7EEE78BF432}") = "NuGet", "NuGet\NuGet.nuproj", "{B51A83D0-21F1-454A-A62C-8173DB309348}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "packages", "packages\packages.shproj", "{7C014AD2-2519-4B17-A89E-26A7C6D0BD50}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Math.Gmp.Native", "Math.Gmp.Native\Math.Gmp.Native.csproj", "{145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Math.Gmp.Native.UnitTests", "Math.Gmp.Native.UnitTests\Math.Gmp.Native.UnitTests.csproj", "{8E987EBD-1611-488C-BC4D-639074C88CB1}" +EndProject +Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + docs\docs.projitems*{39b1e62e-d491-495f-8e90-b7d09b76d8a1}*SharedItemsImports = 13 + packages\packages.projitems*{7c014ad2-2519-4b17-a89e-26a7c6d0bd50}*SharedItemsImports = 13 + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Debug|ARM.ActiveCfg = Debug|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Debug|ARM.Build.0 = Debug|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Debug|x64.ActiveCfg = Debug|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Debug|x64.Build.0 = Debug|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Debug|x86.ActiveCfg = Debug|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Debug|x86.Build.0 = Debug|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Release|Any CPU.Build.0 = Release|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Release|ARM.ActiveCfg = Release|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Release|ARM.Build.0 = Release|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Release|x64.ActiveCfg = Release|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Release|x64.Build.0 = Release|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Release|x86.ActiveCfg = Release|Any CPU + {CE631E64-52BF-4527-99AD-1EAEB76550A8}.Release|x86.Build.0 = Release|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Debug|ARM.ActiveCfg = Debug|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Debug|ARM.Build.0 = Debug|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Debug|x64.ActiveCfg = Debug|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Debug|x64.Build.0 = Debug|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Debug|x86.ActiveCfg = Debug|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Debug|x86.Build.0 = Debug|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Release|ARM.ActiveCfg = Release|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Release|ARM.Build.0 = Release|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Release|x64.ActiveCfg = Release|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Release|x64.Build.0 = Release|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Release|x86.ActiveCfg = Release|Any CPU + {B51A83D0-21F1-454A-A62C-8173DB309348}.Release|x86.Build.0 = Release|Any CPU + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Debug|ARM.ActiveCfg = Debug|Any CPU + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Debug|ARM.Build.0 = Debug|Any CPU + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Debug|x64.ActiveCfg = Debug|x64 + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Debug|x64.Build.0 = Debug|x64 + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Debug|x86.ActiveCfg = Debug|Any CPU + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Debug|x86.Build.0 = Debug|Any CPU + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Release|Any CPU.Build.0 = Release|Any CPU + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Release|ARM.ActiveCfg = Release|Any CPU + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Release|ARM.Build.0 = Release|Any CPU + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Release|x64.ActiveCfg = Release|x64 + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Release|x64.Build.0 = Release|x64 + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Release|x86.ActiveCfg = Release|Any CPU + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A}.Release|x86.Build.0 = Release|Any CPU + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Debug|ARM.ActiveCfg = Debug|Any CPU + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Debug|ARM.Build.0 = Debug|Any CPU + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Debug|x64.ActiveCfg = Debug|x64 + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Debug|x64.Build.0 = Debug|x64 + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Debug|x86.ActiveCfg = Debug|Any CPU + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Debug|x86.Build.0 = Debug|Any CPU + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Release|ARM.ActiveCfg = Release|Any CPU + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Release|ARM.Build.0 = Release|Any CPU + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Release|x64.ActiveCfg = Release|x64 + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Release|x64.Build.0 = Release|x64 + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Release|x86.ActiveCfg = Release|Any CPU + {8E987EBD-1611-488C-BC4D-639074C88CB1}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Math.Gmp.Native/FILE.cs b/Math.Gmp.Native/FILE.cs new file mode 100644 index 0000000..9873057 --- /dev/null +++ b/Math.Gmp.Native/FILE.cs @@ -0,0 +1,77 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Math.Gmp.Native +{ + + /// + /// Represents a file stream. + /// + /// + public struct FILE + { + + /// + /// File pointer in unmanaged memory. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")] + public IntPtr Value; + + /// + /// Returns a value indicating whether this instance is equal to a specified object. + /// + /// An object to compare with this instance. + /// True if is an instance of and equals the value of this instance; otherwise, False. + public override bool Equals(object obj) + { + if (!(obj is FILE)) + return false; + + return Equals((FILE)obj); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified value. + /// + /// A value to compare to this instance. + /// True if has the same value as this instance; otherwise, False. + public bool Equals(FILE other) + { + return Value == other.Value; + } + + /// + /// Returns the hash code for this instance. + /// + /// A 32-bit signed integer hash code. + public override int GetHashCode() + { + return Value.GetHashCode(); + } + + /// + /// Gets a value that indicates whether the two argument values are equal. + /// + /// A value. + /// A value. + /// True if the two values are equal, and False otherwise. + public static bool operator ==(FILE value1, FILE value2) + { + return value1.Equals(value2); + } + + /// + /// Gets a value that indicates whether the two argument values are different. + /// + /// A value. + /// A value. + /// True if the two FILE are different, and False otherwise. + public static bool operator !=(FILE value1, FILE value2) + { + return !value1.Equals(value2); + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/GlobalSuppressions.cs b/Math.Gmp.Native/GlobalSuppressions.cs new file mode 100644 index 0000000..3de118b Binary files /dev/null and b/Math.Gmp.Native/GlobalSuppressions.cs differ diff --git a/Math.Gmp.Native/Math.Gmp.Native.csproj b/Math.Gmp.Native/Math.Gmp.Native.csproj new file mode 100644 index 0000000..a1316b3 --- /dev/null +++ b/Math.Gmp.Native/Math.Gmp.Native.csproj @@ -0,0 +1,110 @@ + + + + + Debug + AnyCPU + {145D16A4-B3B6-49C6-B0DD-E4E0A2A00E4A} + Library + Properties + Math.Gmp.Native + Math.Gmp.Native + v4.0 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + true + Math.Gmp.Native.ruleset + false + + + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + Math.Gmp.Native.ruleset + bin\Release\Math.Gmp.Native.XML + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + Math.Gmp.Native.ruleset + false + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + Math.Gmp.Native.ruleset + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + + + + + + + \ No newline at end of file diff --git a/Math.Gmp.Native/Math.Gmp.Native.ruleset b/Math.Gmp.Native/Math.Gmp.Native.ruleset new file mode 100644 index 0000000..416c163 --- /dev/null +++ b/Math.Gmp.Native/Math.Gmp.Native.ruleset @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Math.Gmp.Native/Properties/AssemblyInfo.cs b/Math.Gmp.Native/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a95b74b --- /dev/null +++ b/Math.Gmp.Native/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Math.Native.Gmp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Math.Native.Gmp")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("145d16a4-b3b6-49c6-b0dd-e4e0a2a00e4a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Math.Gmp.Native/ReadMe.txt b/Math.Gmp.Native/ReadMe.txt new file mode 100644 index 0000000..97446a5 --- /dev/null +++ b/Math.Gmp.Native/ReadMe.txt @@ -0,0 +1,4 @@ + +Code Analysis is run under .NET Framework 4.0 + + diff --git a/Math.Gmp.Native/allocate_function.cs b/Math.Gmp.Native/allocate_function.cs new file mode 100644 index 0000000..26e2944 --- /dev/null +++ b/Math.Gmp.Native/allocate_function.cs @@ -0,0 +1,15 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Math.Gmp.Native +{ + + /// + /// Return a pointer to newly allocated space with at least bytes. + /// + /// The minimum number of bytes to allocate. + /// A pointer to newly allocated space with at least bytes. + public delegate void_ptr allocate_function(size_t alloc_size); + +} diff --git a/Math.Gmp.Native/char_ptr.cs b/Math.Gmp.Native/char_ptr.cs new file mode 100644 index 0000000..117a95f --- /dev/null +++ b/Math.Gmp.Native/char_ptr.cs @@ -0,0 +1,118 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Math.Gmp.Native +{ + + /// + /// Represents a pointer to a string in unmanaged memory. + /// + /// + public struct char_ptr + { + + internal IntPtr pointer; + + /// + /// Creates new string in unmanaged memory and initializes it with . + /// + /// The value of the new string. + /// + /// + /// When done with the string, unmanaged memory must be released with . + /// + /// + public char_ptr(string str) + { + if (str == null) throw new ArgumentNullException("str"); + pointer = gmp_lib.allocate((size_t)(str.Length + 1)).ToIntPtr(); + Marshal.Copy(System.Text.Encoding.ASCII.GetBytes(str), 0, pointer, str.Length); + Marshal.Copy(new Byte[] { 0 }, 0, (IntPtr)(pointer.ToInt64() + str.Length), 1); + } + + internal char_ptr(IntPtr pointer) + { + this.pointer = pointer; + } + + /// + /// Gets pointer to string in unmanaged memory. + /// + /// Pointer to string in unmanaged memory. + public IntPtr ToIntPtr() + { + return pointer; + } + + /// + /// Gets a null . + /// + public static readonly char_ptr Zero = new char_ptr(IntPtr.Zero); + + /// + /// Gets the .NET equivalent of the unmanaged string. + /// + /// The .NET equivalent of the unmanaged string. + public override string ToString() + { + return Marshal.PtrToStringAnsi(pointer); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified object. + /// + /// An object to compare with this instance. + /// True if is an instance of and equals the value of this instance; otherwise, False. + public override bool Equals(object obj) + { + if (!(obj is char_ptr)) + return false; + + return Equals((char_ptr)obj); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified value. + /// + /// A value to compare to this instance. + /// True if has the same value as this instance; otherwise, False. + public bool Equals(char_ptr other) + { + return pointer == other.pointer; + } + + /// + /// Returns the hash code for this instance. + /// + /// A 32-bit signed integer hash code. + public override int GetHashCode() + { + return pointer.GetHashCode(); + } + + /// + /// Gets a value that indicates whether the two argument values are equal. + /// + /// A value. + /// A value. + /// True if the two values are equal, and False otherwise. + public static bool operator ==(char_ptr value1, char_ptr value2) + { + return value1.Equals(value2); + } + + /// + /// Gets a value that indicates whether the two argument values are different. + /// + /// A value. + /// A value. + /// True if the two values are different, and False otherwise. + public static bool operator !=(char_ptr value1, char_ptr value2) + { + return !value1.Equals(value2); + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/free_function.cs b/Math.Gmp.Native/free_function.cs new file mode 100644 index 0000000..3436bc0 --- /dev/null +++ b/Math.Gmp.Native/free_function.cs @@ -0,0 +1,15 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Math.Gmp.Native + +{ + /// + /// De-allocate the space pointed to by . + /// + /// Pointer to previously allocated block. + /// Number of bytes of previously allocated block. + public delegate void free_function(void_ptr ptr, size_t size); + +} diff --git a/Math.Gmp.Native/gmp_lib.cs b/Math.Gmp.Native/gmp_lib.cs new file mode 100644 index 0000000..3026a79 --- /dev/null +++ b/Math.Gmp.Native/gmp_lib.cs @@ -0,0 +1,23802 @@ + +using System; +using System.Runtime.InteropServices; +using Microsoft.Win32.SafeHandles; +using System.Runtime.ConstrainedExecution; +using System.Security; + +namespace Math.Gmp.Native +{ + + /// + /// + /// + /// + public static class gmp_lib + { + + // Safe handle to the loaded GMP library. + private static SafeHandle _gmp_lib = new SafeHandle(_load_gmp_lib()); + + // Delegate to GMP dynamic unmanaged memory allocation function. + private static allocate_function allocate_func_ptr; + + // Delegate to GMP dynamic unmanaged memory reallocation function. + private static reallocate_function reallocate_func_ptr; + + // Delegate to GMP dynamic unmanaged memory free function. + private static free_function free_func_ptr; + + private static IntPtr _load_gmp_lib() + { + // Load GMP library based on current computer x86 or x64 architecture. + string folderName = IntPtr.Size == 4 ? "x86" : "x64"; + // Get pathname of executing assembly. + string codeBase = System.Reflection.Assembly.GetExecutingAssembly().EscapedCodeBase; + // Get directory pathname of GMP library. + string libpath = System.IO.Path.GetDirectoryName(System.Uri.UnescapeDataString((new System.UriBuilder(codeBase)).Path)) + System.IO.Path.DirectorySeparatorChar + folderName; + // Add GMP library directory to DLL search paths. + SafeNativeMethods.SetDllDirectory(libpath); + // Load GMP library and create safe handle to it. + IntPtr handle = SafeNativeMethods.LoadLibrary(@"libgmp-10.dll"); + // Retrieve and cache GMP dynamic memory allocation functions. + _get_memory_functions(); + return handle; + } + + #region "Global variables." + + /// + /// Gets or sets the global GMP error number. + /// + public static int gmp_errno + { + get + { + return Marshal.ReadInt32(SafeNativeMethods.GetProcAddress(_gmp_lib.Handle, "__gmp_errno")); + } + set + { + Marshal.WriteInt32(SafeNativeMethods.GetProcAddress(_gmp_lib.Handle, "__gmp_errno"), value); + } + } + + /// + /// The GMP version number in the form “i.j.k”. This release is "6.1.2". + /// + /// GNU MP - Useful Macros and Constants + /// + /// + /// string version = gmp_lib.gmp_version; + /// Assert.AreEqual(version, "6.1.2"); + /// + /// + /// Dim version As String = gmp_lib.gmp_version + /// Assert.AreEqual(version, "6.1.2") + /// + /// + public static readonly string gmp_version = Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(SafeNativeMethods.GetProcAddress(_gmp_lib.Handle, "__gmp_version"))); + + /// + /// The number of bits per limb. + /// + /// + /// + /// GNU MP - Useful Macros and Constants + /// + /// + /// int bitsPerLimb = gmp_lib.mp_bits_per_limb; + /// Assert.AreEqual(bitsPerLimb, IntPtr.Size * 8); + /// + /// + /// Dim bitsPerLimb As Integer = gmp_lib.mp_bits_per_limb + /// Assert.AreEqual(bitsPerLimb, IntPtr.Size * 8) + /// + /// + public static readonly int mp_bits_per_limb = Marshal.ReadInt32(SafeNativeMethods.GetProcAddress(_gmp_lib.Handle, "__gmp_bits_per_limb")); + + /// + /// The number of bytes per limb. + /// + /// + /// + /// + /// + /// mp_size_t bytesPerLimb = gmp_lib.mp_bytes_per_limb; + /// Assert.AreEqual(bytesPerLimb, (mp_size_t)IntPtr.Size); + /// + /// + /// Dim bytesPerLimb As mp_size_t = gmp_lib.mp_bytes_per_limb + /// Assert.AreEqual(bytesPerLimb, DirectCast(IntPtr.Size, mp_size_t)) + /// + /// + public static readonly mp_size_t mp_bytes_per_limb = mp_bits_per_limb / 8; + + /// + /// The number of 32-bit, unsigned integers per limb. + /// + /// + /// + /// + /// + /// mp_size_t uintsPerLimb = gmp_lib.mp_uint_per_limb; + /// Assert.AreEqual(uintsPerLimb, (mp_size_t)(IntPtr.Size / 4)); + /// + /// + /// Dim uintsPerLimb As mp_size_t = gmp_lib.mp_uint_per_limb + /// Assert.AreEqual(uintsPerLimb, DirectCast(IntPtr.Size / 4, mp_size_t)) + /// + /// + public static readonly mp_size_t mp_uint_per_limb = mp_bits_per_limb / 32; + + #endregion + + #region "Memory allocation functions." + + /// + /// Return a pointer to newly allocated space with at least bytes. + /// + /// The minimum number of bytes to allocate. + /// A pointer to newly allocated space with at least bytes. + /// + /// + /// + /// GNU MP - Custom Allocation + public static void_ptr allocate(size_t alloc_size) + { + return allocate_func_ptr(alloc_size); + } + + /// + /// Resize a previously allocated block of bytes to be bytes. + /// + /// Pointer to previously allocated block. + /// Number of bytes of previously allocated block. + /// New number of bytes of previously allocated block. + /// A previously allocated block ptr of bytes to be bytes. + /// + /// + /// The block may be moved if necessary or if desired, and in that case the smaller of and + /// bytes must be copied to the new location. + /// The return value is a pointer to the resized block, that being the new location if moved or just if not. + /// + /// + /// is never NULL, it’s always a previously allocated block. + /// may be bigger or smaller than . + /// + /// + /// The reallocate function parameter is passed for convenience, but of course it can be ignored + /// if not needed by an implementation. The default functions using malloc and friends for instance don’t use it. + /// + /// + /// + /// + /// GNU MP - Custom Allocation + public static void_ptr reallocate(void_ptr ptr, size_t old_size, size_t new_size) + { + return reallocate_func_ptr(ptr, old_size, new_size); + } + + /// + /// De-allocate the space pointed to by . + /// + /// Pointers to previously allocated memory. + /// + /// + public static void free(params mp_ptr[] ptrs) + { + if (ptrs == null) throw new ArgumentNullException("ptrs"); + foreach (mp_ptr p in ptrs) + if (p.Size > 0) + free_func_ptr(new void_ptr(p.ToIntPtr()), 0); + } + + /// + /// De-allocate the space pointed to by . + /// + /// Pointer to previously allocated memory. + /// + /// + public static void free(gmp_randstate_t ptr) + { + if (ptr == null) throw new ArgumentNullException("ptr"); + free_func_ptr(new void_ptr(ptr.ToIntPtr()), 0); + } + + /// + /// De-allocate the space pointed to by . + /// + /// Pointer to previously allocated memory. + /// + /// + public static void free(char_ptr ptr) + { + free_func_ptr(new void_ptr(ptr.ToIntPtr()), 0); + } + + /// + /// De-allocate the space pointed to by . + /// + /// Pointer to previously allocated memory. + /// + /// + public static void free(void_ptr ptr) + { + free_func_ptr(ptr, 0); + } + + internal static void free(IntPtr ptr) + { + free_func_ptr(new void_ptr(ptr), 0); + } + + /// + /// De-allocate the space pointed to by . + /// + /// Pointer to previously allocated block. + /// Number of bytes of previously allocated block. + /// + /// + /// The free function parameter is passed for convenience, but of course it can be ignored + /// if not needed by an implementation. The default functions using malloc and friends for instance don’t use it. + /// + /// + /// + /// + /// GNU MP - Custom Allocation + public static void free(void_ptr ptr, size_t size) + { + free_func_ptr(ptr, size); + } + + /// + /// Get the current allocation functions, storing function pointers to the locations given by the arguments. + /// + /// The memory allocation function. + /// The memory reallocation function. + /// The memory de-allocation function. + /// + /// GNU MP - Custom Allocation + /// + /// + /// allocate_function allocate; + /// reallocate_function reallocate; + /// free_function free; + /// + /// // Retrieve the GMP memory allocation functions. + /// allocate = null; + /// reallocate = null; + /// free = null; + /// gmp_lib.gmp_get_memory_functions(ref allocate, ref reallocate, ref free); + /// Assert.IsTrue(allocate != null && reallocate != null && free != null); + /// + /// // Allocate and free memory. + /// void_ptr p = allocate(100); + /// free(p, 100); + /// + /// + /// Dim allocate As allocate_function + /// Dim reallocate As reallocate_function + /// Dim free As free_function + /// + /// ' Retrieve the GMP memory allocation functions. + /// allocate = Nothing + /// reallocate = Nothing + /// free = Nothing + /// gmp_lib.gmp_get_memory_functions(allocate, reallocate, free) + /// Assert.IsTrue(allocate IsNot Nothing AndAlso reallocate IsNot Nothing AndAlso free IsNot Nothing) + /// + /// ' Allocate and free memory. + /// Dim p As void_ptr = allocate(100) + /// free(p, 100) + /// + /// + public static void gmp_get_memory_functions(ref allocate_function alloc_func_ptr, ref reallocate_function realloc_func_ptr, ref free_function free_func_ptr) + { + alloc_func_ptr = gmp_lib.allocate_func_ptr; + realloc_func_ptr = gmp_lib.reallocate_func_ptr; + free_func_ptr = gmp_lib.free_func_ptr; + } + + /// + /// Replace the current allocation functions from the arguments. + /// + /// The new memory allocation function. + /// The new memory reallocation function. + /// The new memory de-allocation function. + /// + /// + /// If an argument is null (Nothing in VB.NET), the corresponding + /// default function is used. + /// + /// + /// + /// GNU MP - Custom Allocation + /// + /// + /// // Retrieve GMP default memory allocation functions. + /// allocate_function default_allocate = null; + /// reallocate_function default_reallocate = null; + /// free_function default_free = null; + /// gmp_lib.gmp_get_memory_functions(ref default_allocate, ref default_reallocate, ref default_free); + /// + /// // Create and set new memory allocation functions that count the number of times they are called. + /// int counter = 0; + /// allocate_function new_allocate = (size_t alloc_size) => { counter++; return default_allocate(alloc_size); }; + /// reallocate_function new_reallocate = (void_ptr ptr, size_t old_size, size_t new_size) => { counter++; return default_reallocate(ptr, old_size, new_size); }; + /// free_function new_free = (void_ptr ptr, size_t size) => { counter++; default_free(ptr, size); }; + /// gmp_lib.gmp_set_memory_functions(new_allocate, new_reallocate, new_free); + /// + /// // Retrieve GMP memory allocation functions. + /// allocate_function allocate = null; + /// reallocate_function reallocate = null; + /// free_function free = null; + /// gmp_lib.gmp_get_memory_functions(ref allocate, ref reallocate, ref free); + /// + /// // Call memory function and assert calls count. + /// void_ptr p = allocate(10); + /// Assert.IsTrue(counter == 1); + /// + /// reallocate(p, 10, 20); + /// Assert.IsTrue(counter == 2); + /// + /// free(p, 20); + /// Assert.IsTrue(counter == 3); + /// + /// // Restore default memory allocation functions. + /// gmp_lib.gmp_set_memory_functions(null, null, null); + /// + /// + /// ' Retrieve GMP default memory allocation functions. + /// Dim default_allocate As allocate_function = Nothing + /// Dim default_reallocate As reallocate_function = Nothing + /// Dim default_free As free_function = Nothing + /// gmp_lib.gmp_get_memory_functions(default_allocate, default_reallocate, default_free) + /// + /// ' Create and set new memory allocation functions that count the number of times they are called. + /// Dim counter As Integer = 0 + /// Dim new_allocate As allocate_function = + /// Function(alloc_size As size_t) + /// counter += 1 + /// Return default_allocate(alloc_size) + /// End Function + /// Dim new_reallocate As reallocate_function = + /// Function(ptr As void_ptr, old_size As size_t, new_size As size_t) + /// counter += 1 + /// Return default_reallocate(ptr, old_size, new_size) + /// End Function + /// Dim new_free As free_function = + /// Function(ptr As void_ptr, size As size_t) + /// counter += 1 + /// default_free(ptr, size) + /// End Function + /// gmp_lib.gmp_set_memory_functions(new_allocate, new_reallocate, new_free) + /// + /// ' Retrieve GMP memory allocation functions. + /// Dim allocate As allocate_function = Nothing + /// Dim reallocate As reallocate_function = Nothing + /// Dim free As free_function = Nothing + /// gmp_lib.gmp_get_memory_functions(allocate, reallocate, free) + /// + /// ' Call memory function and assert calls count. + /// Dim p As void_ptr = allocate(10) + /// Assert.IsTrue(counter = 1) + /// + /// reallocate(p, 10, 20) + /// Assert.IsTrue(counter = 2) + /// + /// free(p, 20) + /// Assert.IsTrue(counter = 3) + /// + /// ' Restore default memory allocation functions. + /// gmp_lib.gmp_set_memory_functions(Nothing, Nothing, Nothing) + /// + /// + public static void gmp_set_memory_functions(allocate_function alloc_func_ptr, reallocate_function realloc_func_ptr, free_function free_func_ptr) + { + IntPtr allocate = IntPtr.Zero; + IntPtr reallocate = IntPtr.Zero; + IntPtr free = IntPtr.Zero; + + if (IntPtr.Size == 4) + { + if (alloc_func_ptr != null) + allocate = Marshal.GetFunctionPointerForDelegate((_allocate_function_x86)((uint alloc_size) => { return alloc_func_ptr((size_t)alloc_size).ToIntPtr(); })); + if (realloc_func_ptr != null) + reallocate = Marshal.GetFunctionPointerForDelegate((_reallocate_function_x86)((IntPtr ptr, uint old_size, uint new_size) => { return realloc_func_ptr(new void_ptr(ptr), (size_t)old_size, (size_t)new_size).ToIntPtr(); })); + if (free_func_ptr != null) + free = Marshal.GetFunctionPointerForDelegate((_free_function_x86)((IntPtr ptr, uint size) => { free_func_ptr(new void_ptr(ptr), (size_t)size); })); + } + else + { + if (alloc_func_ptr != null) + allocate = Marshal.GetFunctionPointerForDelegate((_allocate_function_x64)((ulong alloc_size) => { return alloc_func_ptr((size_t)alloc_size).ToIntPtr(); })); + if (realloc_func_ptr != null) + reallocate = Marshal.GetFunctionPointerForDelegate((_reallocate_function_x64)((IntPtr ptr, ulong old_size, ulong new_size) => { return realloc_func_ptr(new void_ptr(ptr), (size_t)old_size, (size_t)new_size).ToIntPtr(); })); + if (free_func_ptr != null) + free = Marshal.GetFunctionPointerForDelegate((_free_function_x64)((IntPtr ptr, ulong size) => { free_func_ptr(new void_ptr(ptr), (size_t)size); })); + } + + SafeNativeMethods.__gmp_set_memory_functions(allocate, reallocate, free); + + _get_memory_functions(); + } + + private static void _get_memory_functions() + { + // Cache dynamic memory allocation functions. + + IntPtr allocate = IntPtr.Zero; + IntPtr reallocate = IntPtr.Zero; + IntPtr free = IntPtr.Zero; + + SafeNativeMethods.__gmp_get_memory_functions(ref allocate, ref reallocate, ref free); + + _get_memory_function(allocate, ref gmp_lib.allocate_func_ptr); + _get_memory_function(reallocate, ref gmp_lib.reallocate_func_ptr); + _get_memory_function(free, ref gmp_lib.free_func_ptr); + } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr _allocate_function_x86(uint alloc_size); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr _allocate_function_x64(ulong alloc_size); + + private static void _get_memory_function(IntPtr allocate, ref allocate_function alloc_func_ptr) + { + if (IntPtr.Size == 4) + alloc_func_ptr = (size_t alloc_size) => { return new void_ptr(((_allocate_function_x86)Marshal.GetDelegateForFunctionPointer(allocate, typeof(_allocate_function_x86)))((uint)alloc_size)); }; + else + alloc_func_ptr = (size_t alloc_size) => { return new void_ptr(((_allocate_function_x64)Marshal.GetDelegateForFunctionPointer(allocate, typeof(_allocate_function_x64)))((ulong)alloc_size)); }; + } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr _reallocate_function_x86(IntPtr ptr, uint old_size, uint new_size); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr _reallocate_function_x64(IntPtr ptr, ulong old_size, ulong new_size); + + private static void _get_memory_function(IntPtr reallocate, ref reallocate_function realloc_func_ptr) + { + if (IntPtr.Size == 4) + realloc_func_ptr = (ptr, old_size, new_size) => { return ptr.FromIntPtr(((_reallocate_function_x86)Marshal.GetDelegateForFunctionPointer(reallocate, typeof(_reallocate_function_x86)))(ptr.ToIntPtr(), (uint)old_size, (uint)new_size)); }; + else + realloc_func_ptr = (ptr, old_size, new_size) => { return ptr.FromIntPtr(((_reallocate_function_x64)Marshal.GetDelegateForFunctionPointer(reallocate, typeof(_reallocate_function_x64)))(ptr.ToIntPtr(), (ulong)old_size, (ulong)new_size)); }; + } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void _free_function_x86(IntPtr ptr, uint size); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void _free_function_x64(IntPtr ptr, ulong size); + + private static void _get_memory_function(IntPtr free, ref free_function free_func_ptr) + { + if (IntPtr.Size == 4) + free_func_ptr = (ptr, size) => { ((_free_function_x86)Marshal.GetDelegateForFunctionPointer(free, typeof(_free_function_x86)))(ptr.ToIntPtr(), (uint)size); }; + else + free_func_ptr = (ptr, size) => { ((_free_function_x64)Marshal.GetDelegateForFunctionPointer(free, typeof(_free_function_x64)))(ptr.ToIntPtr(), (ulong)size); }; + } + + /// + /// The routine fills a block of memory with zeros, given a pointer to the block and the length, in bytes, to be filled. + /// + /// A pointer to the memory block to be filled with zeros. + /// The number of bytes to fill with zeros. + public static void ZeroMemory(IntPtr dst, int length) + { + SafeNativeMethods.RtlZeroMemory(dst, length); + } + + #endregion + + #region "Random number routines." + + /// + /// Initialize with a default algorithm. + /// + /// The state to initialize. + /// + /// + /// This will be a compromise between speed and randomness, + /// and is recommended for applications with no special requirements. + /// Currently this is . + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Random State Initialization + /// + /// + /// // Create new random number generator state. + /// gmp_randstate_t state = new gmp_randstate_t(); + /// + /// // Initialize state with default random number generator algorithm. + /// gmp_lib.gmp_randinit_default(state); + /// + /// // Free all memory occupied by state. + /// gmp_lib.gmp_randclear(state); + /// + /// + /// ' Create new random number generator state. + /// Dim state As New gmp_randstate_t() + /// + /// ' Initialize state with default random number generator algorithm. + /// gmp_lib.gmp_randinit_default(state) + /// + /// ' Free all memory occupied by state. + /// gmp_lib.gmp_randclear(state) + /// + /// + public static void gmp_randinit_default(gmp_randstate_t state) + { + if (state == null) throw new ArgumentNullException("state"); + SafeNativeMethods.__gmp_randinit_default(state.ToIntPtr()); + } + + /// + /// Initialize with a linear congruential algorithm X = (X + ) mod 2^. + /// + /// The state to initialize. + /// Parameter of the algorithm. + /// Parameter of the algorithm. + /// Parameter of the algorithm. + /// + /// + /// The low bits of X in this algorithm are not very random. + /// The least significant bit will have a period no more than 2, and the second bit + /// no more than 4, etc. For this reason only the high half of each X is actually used. + /// + /// + /// When a random number of more than / 2 bits is to be generated, + /// multiple iterations of the recurrence are used and the results concatenated. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Random State Initialization + /// + /// + /// // Create new random number generator state. + /// gmp_randstate_t state = new gmp_randstate_t(); + /// + /// // Initialize state with a linear congruential random number generator algorithm. + /// mpz_t a = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(a, 100000U); + /// gmp_lib.gmp_randinit_lc_2exp(state, a, 13, 300); + /// + /// // Free all memory occupied by state and a. + /// gmp_lib.gmp_randclear(state); + /// gmp_lib.mpz_clear(a); + /// + /// + /// ' Create new random number generator state. + /// Dim state As New gmp_randstate_t() + /// + /// ' Initialize state with a linear congruential random number generator algorithm. + /// Dim a As New mpz_t() + /// + /// gmp_lib.mpz_init_set_ui(a, 100000UI) + /// gmp_lib.gmp_randinit_lc_2exp(state, a, 13, 300) + /// + /// ' Free all memory occupied by state and a. + /// gmp_lib.gmp_randclear(state) + /// gmp_lib.mpz_clear(a) + /// + /// + public static void gmp_randinit_lc_2exp(gmp_randstate_t state, /*const*/ mpz_t a, uint /*unsigned long int*/ c, mp_bitcnt_t m2exp) + { + if (state == null) throw new ArgumentNullException("state"); + if (a == null) throw new ArgumentNullException("a"); + SafeNativeMethods.__gmp_randinit_lc_2exp(state.ToIntPtr(), a.ToIntPtr(), c, m2exp); + } + + /// + /// Initialize for a linear congruential algorithm as per . + /// + /// The state to initialize. + /// + /// If successful the return value is non-zero. If is bigger than the table data provides then the return value is zero. + /// + /// + /// a, c and m2exp are selected from a table, chosen so that + /// bits (or more) of each X will be used, i.e. m2exp / 2 ≥ . + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Random State Initialization + /// + /// + /// // Create new random number generator state. + /// gmp_randstate_t state = new gmp_randstate_t(); + /// + /// // Initialize state with a linear congruential random number generator algorithm. + /// gmp_lib.gmp_randinit_lc_2exp_size(state, 30); + /// + /// // Free all memory occupied by state. + /// gmp_lib.gmp_randclear(state); + /// + /// + /// ' Create new random number generator state. + /// Dim state As New gmp_randstate_t() + /// + /// ' Initialize state with a linear congruential random number generator algorithm. + /// gmp_lib.gmp_randinit_lc_2exp_size(state, 30) + /// + /// ' Free all memory occupied by state. + /// gmp_lib.gmp_randclear(state) + /// + /// + public static int gmp_randinit_lc_2exp_size(gmp_randstate_t state, mp_bitcnt_t size) + { + if (state == null) throw new ArgumentNullException("state"); + return SafeNativeMethods.__gmp_randinit_lc_2exp_size(state.ToIntPtr(), size); + } + + /// + /// Initialize for a Mersenne Twister algorithm. + /// + /// The state to initialize. + /// + /// + /// This algorithm is fast and has good randomness properties. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Random State Initialization + /// + /// + /// // Create new random number generator state. + /// gmp_randstate_t state = new gmp_randstate_t(); + /// + /// // Initialize state with Mersenne Twister random number generator algorithm. + /// gmp_lib.gmp_randinit_mt(state); + /// + /// // Free all memory occupied by state. + /// gmp_lib.gmp_randclear(state); + /// + /// + /// ' Create new random number generator state. + /// Dim state As New gmp_randstate_t() + /// + /// ' Initialize state with Mersenne Twister random number generator algorithm. + /// gmp_lib.gmp_randinit_mt(state) + /// + /// ' Free all memory occupied by state. + /// gmp_lib.gmp_randclear(state) + /// + /// + public static void gmp_randinit_mt(gmp_randstate_t state) + { + if (state == null) throw new ArgumentNullException("state"); + SafeNativeMethods.__gmp_randinit_mt(state.ToIntPtr()); + } + + /// + /// Initialize with a copy of the algorithm and state from . + /// + /// The state to initialize. + /// The source state. + /// + /// + /// + /// + /// + /// GNU MP - Random State Initialization + /// + /// + /// // Create new random number generator state, and initialize state with the Mersenne Twister algorithm. + /// gmp_randstate_t op = new gmp_randstate_t(); + /// gmp_lib.gmp_randinit_mt(op); + /// + /// // Create new random number generator state, and initialize it with the state op. + /// gmp_randstate_t rop = new gmp_randstate_t(); + /// gmp_lib.gmp_randinit_set(rop, op); + /// + /// // Free all memory occupied by op and rop. + /// gmp_lib.gmp_randclear(op); + /// gmp_lib.gmp_randclear(rop); + /// + /// + /// ' Create new random number generator state, and initialize state with the Mersenne Twister algorithm. + /// Dim op As New gmp_randstate_t() + /// + /// gmp_lib.gmp_randinit_mt(op) + /// + /// ' Create new random number generator state, and initialize it with the state op. + /// Dim rop As New gmp_randstate_t() + /// + /// gmp_lib.gmp_randinit_set(rop, op) + /// + /// ' Free all memory occupied by op and rop. + /// gmp_lib.gmp_randclear(op) + /// gmp_lib.gmp_randclear(rop) + /// + /// + public static void gmp_randinit_set(gmp_randstate_t rop, /*const*/ gmp_randstate_t /*__gmp_randstate_struct **/ op) + { + if (rop == null) throw new ArgumentNullException("state"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmp_randinit_set(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set an initial value into . + /// + /// The state to seed. + /// The seed. + /// + /// + /// The size of a seed determines how many different sequences of random numbers that it’s possible to + /// generate. The “quality” of the seed is the randomness of a given seed compared to the previous seed + /// used, and this affects the randomness of separate number sequences. The method for choosing a seed + /// is critical if the generated numbers are to be used for important applications, such as generating + /// cryptographic keys. + /// + /// + /// Traditionally the system time has been used to seed, but care needs to be taken with this. If an + /// application seeds often and the resolution of the system clock is low, then the same sequence of + /// numbers might be repeated. Also, the system time is quite easy to guess, so if unpredictability is + /// required then it should definitely not be the only source for the seed value. On some systems + /// there’s a special device /dev/random which provides random data better suited for use as a seed. + /// + /// + /// + /// GNU MP - Random State Seeding + /// + /// + /// // Create new random number generator state, and initialize state with the Mersenne Twister algorithm. + /// gmp_randstate_t state = new gmp_randstate_t(); + /// gmp_lib.gmp_randinit_mt(state); + /// + /// // Seed random number generator. + /// mpz_t seed = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(seed, 100000U); + /// gmp_lib.gmp_randseed(state, seed); + /// + /// // Free all memory occupied by state and seed. + /// gmp_lib.gmp_randclear(state); + /// gmp_lib.mpz_clear(seed); + /// + /// + /// ' Create new random number generator state, and initialize state with the Mersenne Twister algorithm. + /// Dim state As New gmp_randstate_t() + /// + /// gmp_lib.gmp_randinit_mt(state) + /// + /// ' Seed random number generator. + /// Dim seed As New mpz_t() + /// + /// gmp_lib.mpz_init_set_ui(seed, 100000UI) + /// gmp_lib.gmp_randseed(state, seed) + /// + /// ' Free all memory occupied by state and seed. + /// gmp_lib.gmp_randclear(state) + /// gmp_lib.mpz_clear(seed) + /// + /// + public static void gmp_randseed(gmp_randstate_t state, /*const*/ mpz_t seed) + { + if (state == null) throw new ArgumentNullException("state"); + if (seed == null) throw new ArgumentNullException("seed"); + SafeNativeMethods.__gmp_randseed(state.ToIntPtr(), seed.ToIntPtr()); + } + + /// + /// Set an initial value into . + /// + /// The state to seed. + /// The seed. + /// + /// + /// The size of a seed determines how many different sequences of random numbers that it’s possible to + /// generate. The “quality” of the seed is the randomness of a given seed compared to the previous seed + /// used, and this affects the randomness of separate number sequences. The method for choosing a seed + /// is critical if the generated numbers are to be used for important applications, such as generating + /// cryptographic keys. + /// + /// + /// Traditionally the system time has been used to seed, but care needs to be taken with this. If an + /// application seeds often and the resolution of the system clock is low, then the same sequence of + /// numbers might be repeated. Also, the system time is quite easy to guess, so if unpredictability is + /// required then it should definitely not be the only source for the seed value. On some systems + /// there’s a special device /dev/random which provides random data better suited for use as a seed. + /// + /// + /// + /// GNU MP - Random State Seeding + /// + /// + /// // Create new random number generator state, and initialize state with the Mersenne Twister algorithm. + /// gmp_randstate_t state = new gmp_randstate_t(); + /// gmp_lib.gmp_randinit_mt(state); + /// + /// // Seed random number generator. + /// gmp_lib.gmp_randseed_ui(state, 100000U); + /// + /// // Free all memory occupied by state. + /// gmp_lib.gmp_randclear(state); + /// + /// + /// ' Create new random number generator state, and initialize state with the Mersenne Twister algorithm. + /// Dim state As New gmp_randstate_t() + /// + /// gmp_lib.gmp_randinit_mt(state) + /// + /// ' Seed random number generator. + /// gmp_lib.gmp_randseed_ui(state, 100000UI) + /// + /// ' Free all memory occupied by state. + /// gmp_lib.gmp_randclear(state) /// + /// + public static void gmp_randseed_ui(gmp_randstate_t state, uint /*unsigned long int*/ seed) + { + if (state == null) throw new ArgumentNullException("state"); + SafeNativeMethods.__gmp_randseed_ui(state.ToIntPtr(), seed); + } + + /// + /// Free all memory occupied by . + /// + /// A state. + /// + /// + /// + /// + /// + /// GNU MP - Random State Initialization + public static void gmp_randclear(gmp_randstate_t state) + { + if (state == null) throw new ArgumentNullException("state"); + SafeNativeMethods.__gmp_randclear(state.ToIntPtr()); + gmp_lib.free(state); + } + + /// + /// Generate a uniformly distributed random number of bits, i.e. in the range 0 to 2^ - 1 inclusive. + /// + /// The state of the random number generator to use. + /// The numbe rof bits. + /// The generated random number. + /// + /// + /// must be less than or equal to the number of bits in an unsigned long. + /// + /// + /// In .NET, must be less than or equal to the number of bits in an unsigned 32-bit integer. + /// + /// + /// + /// GNU MP - Random State Miscellaneous + /// + /// + /// // Create, initialize, and seed a new random number generator. + /// gmp_randstate_t state = new gmp_randstate_t(); + /// gmp_lib.gmp_randinit_mt(state); + /// gmp_lib.gmp_randseed_ui(state, 100000U); + /// + /// // Generate a random integer in the range [0, 2^8-1]. + /// uint rand = gmp_lib.gmp_urandomb_ui(state, 8); + /// + /// // Free all memory occupied by state. + /// gmp_lib.gmp_randclear(state); + /// + /// + /// ' Create, initialize, and seed a new random number generator. + /// Dim state As New gmp_randstate_t() + /// gmp_lib.gmp_randinit_mt(state) + /// gmp_lib.gmp_randseed_ui(state, 100000UI) + /// + /// ' Generate a random integer in the range [0, 2^8-1]. + /// Dim rand As UInteger = gmp_lib.gmp_urandomb_ui(state, 8) + /// + /// ' Free all memory occupied by state. + /// gmp_lib.gmp_randclear(state) + /// + /// + public static uint /*unsigned long int*/ gmp_urandomb_ui(gmp_randstate_t state, uint /*unsigned long int*/ n) + { + if (state == null) throw new ArgumentNullException("state"); + return SafeNativeMethods.__gmp_urandomb_ui(state.ToIntPtr(), n); + } + + /// + /// Generate a uniformly distributed random number in the range 0 to - 1, inclusive. + /// + /// The state of the random number generator to use. + /// The upper bound of the range. + /// The generated random number. + /// + /// GNU MP - Random State Miscellaneous + /// + /// + /// // Create, initialize, and seed a new random number generator. + /// gmp_randstate_t state = new gmp_randstate_t(); + /// gmp_lib.gmp_randinit_mt(state); + /// gmp_lib.gmp_randseed_ui(state, 1000U); + /// + /// // Generate a random integer in the range [0, 8-1]. + /// uint rand = gmp_lib.gmp_urandomm_ui(state, 8); + /// + /// // Free all memory occupied by state. + /// gmp_lib.gmp_randclear(state); + /// + /// + /// ' Create, initialize, and seed a new random number generator. + /// Dim state As New gmp_randstate_t() + /// + /// gmp_lib.gmp_randinit_mt(state) + /// gmp_lib.gmp_randseed_ui(state, 1000UI) + /// + /// ' Generate a random integer in the range [0, 8-1]. + /// Dim rand As UInteger = gmp_lib.gmp_urandomm_ui(state, 8) + /// + /// ' Free all memory occupied by state. + /// gmp_lib.gmp_randclear(state) + /// + /// + public static uint /*unsigned long int*/ gmp_urandomm_ui(gmp_randstate_t state, uint /*unsigned long int*/ n) + { + if (state == null) throw new ArgumentNullException("state"); + return SafeNativeMethods.__gmp_urandomm_ui(state.ToIntPtr(), n); + } + + #endregion + + #region "Formatted output routines." + + /// + /// Form a null-terminated string in a block of memory obtained from the current memory allocation function. + /// + /// Pointer to returned, allocated string. + /// Format string. See Formatted Output Strings. + /// Arguments. + /// The return value is the number of characters produced, excluding the null-terminator. + /// + /// + /// The block will be the size of the string and null-terminator. The address of the block in stored to . + /// + /// + /// Unlike the C library asprintf, doesn’t return -1 if there’s no more memory available, + /// it lets the current allocation function handle that. + /// + /// + /// + /// + /// + /// GNU MP - Formatted Output Functions + /// GNU MP - Formatted Output Strings + /// + /// + /// // Create pointer to unmanaged character string pointer. + /// ptr<char_ptr> str = new ptr<char_ptr>(); + /// + /// mpz_t z = "123456"; + /// mpq_t q = "123/456"; + /// mpf_t f = "12345e6"; + /// mp_limb_t m = 123456; + /// + /// // Print to newly allocated unmanaged memory string. + /// Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + /// Assert.IsTrue(str.Value.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100"); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(str.Value); + /// gmp_lib.mpz_clear(z); + /// gmp_lib.mpq_clear(q); + /// gmp_lib.mpf_clear(f); + /// + /// + /// ' Create pointer to unmanaged character string pointer. + /// Dim str As New ptr(Of char_ptr)() + /// + /// Dim z As mpz_t = "123456" + /// Dim q As mpq_t = "123/456" + /// Dim f As mpf_t = "12345e6" + /// Dim m As mp_limb_t = 123456 + /// + /// ' Print to newly allocated unmanaged memory string. + /// Assert.IsTrue(gmp_lib.gmp_asprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42) + /// Assert.IsTrue(str.Value.ToString() = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100") + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(str.Value) + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_asprintf(ptr /*char ***/ pp, /*const*/ string /*char **/ fmt, params object[] /*...*/ args) + { + return gmp_vasprintf(pp, fmt, args); + } + + /// + /// Print to the stream . + /// + /// File stream. + /// Format string. See Formatted Output Strings. + /// Arguments. + /// Return the number of characters written, or -1 if an error occurred. + /// + /// + /// + /// GNU MP - Formatted Output Functions + /// GNU MP - Formatted Output Strings + /// + /// + /// // Create unique file pathname and a file pointer. + /// string pathname = System.IO.Path.GetTempFileName(); + /// ptr<FILE> stream = new ptr<FILE>(); + /// + /// mpz_t z = "123456"; + /// mpq_t q = "123/456"; + /// mpf_t f = "12345e6"; + /// mp_limb_t m = 123456; + /// + /// // Open file stream and print to it. + /// _wfopen_s(out stream.Value.Value, pathname, "w"); + /// Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + /// fclose(stream.Value.Value); + /// Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100"); + /// + /// // Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + /// ' Create unique file pathname and a file pointer. + /// Dim pathname As String = System.IO.Path.GetTempFileName() + /// Dim stream As New ptr(Of FILE)() + /// + /// Dim z As mpz_t = "123456" + /// Dim q As mpq_t = "123/456" + /// Dim f As mpf_t = "12345e6" + /// Dim m As mp_limb_t = 123456 + /// + /// ' Open file stream and print to it. + /// _wfopen_s(stream.Value.Value, pathname, "w") + /// Assert.IsTrue(gmp_lib.gmp_fprintf(stream, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42) + /// fclose(stream.Value.Value) + /// Assert.IsTrue(System.IO.File.ReadAllText(pathname) = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100") + /// + /// ' Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_fprintf(ptr /*FILE **/ fp, /*const*/ string /*char **/ fmt, params object[] /*...*/ args) + { + return gmp_vfprintf(fp, fmt, args); + } + + //#define gmp_obstack_printf __gmp_obstack_printf + //#if defined (_GMP_H_HAVE_OBSTACK) + //__GMP_DECLSPEC int gmp_obstack_printf (struct obstack *, const char *, ...); + //#endif + + //#define gmp_obstack_vprintf __gmp_obstack_vprintf + //#if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST) + //__GMP_DECLSPEC int gmp_obstack_vprintf (struct obstack *, const char *, va_list); + //#endif + + /// + /// Print to the standard output stdout. + /// + /// Format string. See Formatted Output Strings. + /// Arguments. + /// Return the number of characters written, or -1 if an error occurred. + /// + /// + /// + /// GNU MP - Formatted Output Functions + /// GNU MP - Formatted Output Strings + /// + /// + /// mpz_t z = "123456"; + /// mpq_t q = "123/456"; + /// mpf_t f = "12345e6"; + /// mp_limb_t m = 123456; + /// + /// // Print to standard output. + /// Assert.IsTrue(gmp_lib.gmp_printf("%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + /// + /// // Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + /// Dim z As mpz_t = "123456" + /// Dim q As mpq_t = "123/456" + /// Dim f As mpf_t = "12345e6" + /// Dim m As mp_limb_t = 123456 + /// + /// ' Print to standard output. + /// Assert.IsTrue(gmp_lib.gmp_printf("%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42) + /// + /// ' Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_printf(/*const*/ string /*char **/ fmt, params object[] /*...*/ args) + { + return gmp_vprintf(fmt, args); + } + + /// + /// Form a null-terminated string in . + /// + /// The string to print to. + /// The maximum number of bytes to write. + /// Format string. See Formatted Output Strings. + /// Arguments. + /// The return value is the total number of characters which ought to have been produced, excluding the terminating null. If retval ≥ then the actual output has been truncated to the first - 1 characters, and a null appended. + /// + /// + /// No more than bytes will be written. To get the full output, must be enough for the string and null-terminator. + /// + /// + /// No overlap is permitted between the regiom {,} and the string. + /// + /// + /// Notice the return value is in ISO C99 snprintf style. This is so even if the C library vsnprintf is the older GLIBC 2.0.x style. + /// + /// + /// + /// + /// + /// GNU MP - Formatted Output Functions + /// GNU MP - Formatted Output Strings + /// + /// + /// // Allocate unmanaged string with 50 characters. + /// char_ptr str = new char_ptr("................................................."); + /// + /// mpz_t z = "123456"; + /// mpq_t q = "123/456"; + /// mpf_t f = "12345e6"; + /// mp_limb_t m = 123456; + /// + /// // Print to string. + /// Assert.IsTrue(gmp_lib.gmp_snprintf(str, 50, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + /// Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100"); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(str); + /// gmp_lib.mpz_clear(z); + /// gmp_lib.mpq_clear(q); + /// gmp_lib.mpf_clear(f); + /// + /// + /// ' Allocate unmanaged string with 50 characters. + /// Dim str As New char_ptr(".................................................") + /// + /// Dim z As mpz_t = "123456" + /// Dim q As mpq_t = "123/456" + /// Dim f As mpf_t = "12345e6" + /// Dim m As mp_limb_t = 123456 + /// + /// ' Print to string. + /// Assert.IsTrue(gmp_lib.gmp_snprintf(str, 50, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42) + /// Assert.IsTrue(str.ToString() = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100") + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(str) + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_snprintf(char_ptr /*char **/ buf, size_t size, /*const*/ string /*char **/ fmt, params object[] /*...*/ args) + { + return gmp_vsnprintf(buf, size, fmt, args); + } + + /// + /// Form a null-terminated string in . + /// + /// The string to print to. + /// Format string. See Formatted Output Strings. + /// Arguments. + /// Return the number of characters written, excluding the terminating null. + /// + /// + /// No overlap is permitted between the space at and the string . + /// + /// + /// These functions are not recommended, since there’s no protection against exceeding the space available at . + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Formatted Output Functions + /// GNU MP - Formatted Output Strings + /// + /// + /// // Allocate unmanaged string with 50 characters. + /// char_ptr str = new char_ptr("................................................."); + /// + /// mpz_t z = "123456"; + /// mpq_t q = "123/456"; + /// mpf_t f = "12345e6"; + /// mp_limb_t m = 123456; + /// + /// // Print to string. + /// Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + /// Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100"); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(str); + /// gmp_lib.mpz_clear(z); + /// gmp_lib.mpq_clear(q); + /// gmp_lib.mpf_clear(f); + /// + /// + /// ' Allocate unmanaged string with 50 characters. + /// Dim str As New char_ptr(".................................................") + /// + /// Dim z As mpz_t = "123456" + /// Dim q As mpq_t = "123/456" + /// Dim f As mpf_t = "12345e6" + /// Dim m As mp_limb_t = 123456 + /// + /// ' Print to string. + /// Assert.IsTrue(gmp_lib.gmp_sprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42) + /// Assert.IsTrue(str.ToString() = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100") + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(str) + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_sprintf(char_ptr /*char **/ buf, /*const*/ string /*char **/ fmt, params object[] /*...*/ args) + { + return gmp_vsprintf(buf, fmt, args); + } + + /// + /// Form a null-terminated string in a block of memory obtained from the current memory allocation function. + /// + /// + /// Format string. See Formatted Output Strings. + /// Arguments. + /// The return value is the number of characters produced, excluding the null-terminator. + /// + /// + /// The block will be the size of the string and null-terminator. The address of the block in stored to . + /// + /// + /// Unlike the C library vasprintf, doesn’t return -1 if there’s no more memory available, + /// it lets the current allocation function handle that. + /// + /// + /// + /// GNU MP - Formatted Output Functions + /// GNU MP - Formatted Output Strings + /// + /// + /// // Create pointer to unmanaged character string pointer. + /// ptr<char_ptr> str = new ptr<char_ptr>(); + /// + /// mpz_t z = "123456"; + /// mpq_t q = "123/456"; + /// mpf_t f = "12345e6"; + /// mp_limb_t m = 123456; + /// + /// // Print to newly allocated unmanaged memory string. + /// Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + /// Assert.IsTrue(str.Value.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100"); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(str.Value); + /// gmp_lib.mpz_clear(z); + /// gmp_lib.mpq_clear(q); + /// gmp_lib.mpf_clear(f); + /// + /// + /// ' Create pointer to unmanaged character string pointer. + /// Dim str As New ptr(Of char_ptr)() + /// + /// Dim z As mpz_t = "123456" + /// Dim q As mpq_t = "123/456" + /// Dim f As mpf_t = "12345e6" + /// Dim m As mp_limb_t = 123456 + /// + /// ' Print to newly allocated unmanaged memory string. + /// Assert.IsTrue(gmp_lib.gmp_vasprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42) + /// Assert.IsTrue(str.Value.ToString() = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100") + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(str.Value) + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_vasprintf(ptr /*char ***/ ptr, /*const*/ string /*char **/ fmt, params object[] /*va_list*/ ap) + { + if (ptr == null) throw new ArgumentNullException("ptr"); + if (fmt == null) throw new ArgumentNullException("fmt"); + if (ap == null) throw new ArgumentNullException("ap"); + va_list va_args = new va_list(ap); + char_ptr format = new char_ptr(fmt); + int result = SafeNativeMethods.__gmp_vasprintf(ref ptr.Value.pointer, format.ToIntPtr(), va_args.ToIntPtr()); + va_args.RetrieveArgumentValues(); + gmp_lib.free(format); + return result; + } + + /// + /// Print to the stream . + /// + /// File stream. + /// Format string. See Formatted Output Strings. + /// Arguments. + /// Return the number of characters written, or -1 if an error occurred. + /// + /// GNU MP - Formatted Output Functions + /// GNU MP - Formatted Output Strings + /// + /// + /// // Create unique file pathname and a file pointer. + /// string pathname = System.IO.Path.GetTempFileName(); + /// ptr<FILE> stream = new ptr<FILE>(); + /// + /// mpz_t z = "123456"; + /// mpq_t q = "123/456"; + /// mpf_t f = "12345e6"; + /// mp_limb_t m = 123456; + /// + /// // Open file stream and print to it. + /// _wfopen_s(out stream.Value.Value, pathname, "w"); + /// Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + /// fclose(stream.Value.Value); + /// Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100"); + /// + /// // Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + /// ' Create unique file pathname and a file pointer. + /// Dim pathname As String = System.IO.Path.GetTempFileName() + /// Dim stream As New ptr(Of FILE)() + /// + /// Dim z As mpz_t = "123456" + /// Dim q As mpq_t = "123/456" + /// Dim f As mpf_t = "12345e6" + /// Dim m As mp_limb_t = 123456 + /// + /// ' Open file stream and print to it. + /// _wfopen_s(stream.Value.Value, pathname, "w") + /// Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42) + /// fclose(stream.Value.Value) + /// Assert.IsTrue(System.IO.File.ReadAllText(pathname) = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100") + /// ' Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_vfprintf(ptr /*FILE **/ fp, /*const*/ string /*char **/ fmt, params object[] /*va_list*/ ap) + { + if (fp == null) throw new ArgumentNullException("fp"); + if (fmt == null) throw new ArgumentNullException("fmt"); + if (ap == null) throw new ArgumentNullException("ap"); + va_list va_args = new va_list(ap); + char_ptr format = new char_ptr(fmt); + int result = SafeNativeMethods.__gmp_vfprintf(fp.Value.Value, format.ToIntPtr(), va_args.ToIntPtr()); + va_args.RetrieveArgumentValues(); + gmp_lib.free(format); + return result; + } + + /// + /// Print to the standard output stdout. + /// + /// Format string. See Formatted Output Strings. + /// Arguments. + /// Return the number of characters written, or -1 if an error occurred. + /// + /// GNU MP - Formatted Output Functions + /// GNU MP - Formatted Output Strings + /// + /// + /// mpz_t z = "123456"; + /// mpq_t q = "123/456"; + /// mpf_t f = "12345e6"; + /// mp_limb_t m = 123456; + /// + /// // Print to standard output. + /// Assert.IsTrue(gmp_lib.gmp_vprintf("%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + /// + /// // Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + /// Dim z As mpz_t = "123456" + /// Dim q As mpq_t = "123/456" + /// Dim f As mpf_t = "12345e6" + /// Dim m As mp_limb_t = 123456 + /// + /// ' Print to standard output. + /// Assert.IsTrue(gmp_lib.gmp_vprintf("%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42) + /// + /// ' Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_vprintf(/*const*/ string /*char **/ fmt, params object[] /*va_list*/ ap) + { + if (fmt == null) throw new ArgumentNullException("fmt"); + if (ap == null) throw new ArgumentNullException("ap"); + va_list va_args = new va_list(ap); + char_ptr format = new char_ptr(fmt); + int result = SafeNativeMethods.__gmp_vprintf(format.ToIntPtr(), va_args.ToIntPtr()); + va_args.RetrieveArgumentValues(); + gmp_lib.free(format); + return result; + } + + /// + /// Form a null-terminated string in . + /// + /// The string to print to. + /// The maximum number of bytes to write. + /// Format string. See Formatted Output Strings. + /// Arguments. + /// The return value is the total number of characters which ought to have been produced, excluding the terminating null. If retval ≥ then the actual output has been truncated to the first - 1 characters, and a null appended. + /// + /// + /// No more than bytes will be written. To get the full output, must be enough for the string and null-terminator. + /// + /// + /// No overlap is permitted between the regiom {,} and the string. + /// + /// + /// Notice the return value is in ISO C99 snprintf style. This is so even if the C library vsnprintf is the older GLIBC 2.0.x style. + /// + /// + /// + /// GNU MP - Formatted Output Functions + /// GNU MP - Formatted Output Strings + /// + /// + /// // Allocate unmanaged string with 50 characters. + /// char_ptr str = new char_ptr("................................................."); + /// + /// mpz_t z = "123456"; + /// mpq_t q = "123/456"; + /// mpf_t f = "12345e6"; + /// mp_limb_t m = 123456; + /// + /// // Print to string. + /// Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 50, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + /// Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100"); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(str); + /// gmp_lib.mpz_clear(z); + /// gmp_lib.mpq_clear(q); + /// gmp_lib.mpf_clear(f); + /// + /// + /// ' Allocate unmanaged string with 50 characters. + /// Dim str As New char_ptr(".................................................") + /// + /// Dim z As mpz_t = "123456" + /// Dim q As mpq_t = "123/456" + /// Dim f As mpf_t = "12345e6" + /// Dim m As mp_limb_t = 123456 + /// + /// ' Print to string. + /// Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 50, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42) + /// Assert.IsTrue(str.ToString() = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100") + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(str) + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_vsnprintf(char_ptr /*char **/ buf, size_t size, /*const*/ string /*char **/ fmt, params object[] /*va_list*/ ap) + { + if (buf == null) throw new ArgumentNullException("buf"); + if (fmt == null) throw new ArgumentNullException("fmt"); + if (ap == null) throw new ArgumentNullException("ap"); + va_list va_args = new va_list(ap); + char_ptr format = new char_ptr(fmt); + int result; + if (IntPtr.Size == 4) + result = SafeNativeMethods.__gmp_vsnprintf_x86(buf.ToIntPtr(), (uint)size, format.ToIntPtr(), va_args.ToIntPtr()); + else + result = SafeNativeMethods.__gmp_vsnprintf_x64(buf.ToIntPtr(), (ulong)size, format.ToIntPtr(), va_args.ToIntPtr()); + va_args.RetrieveArgumentValues(); + gmp_lib.free(format); + return result; + } + + /// + /// Form a null-terminated string in . + /// + /// The string to print to. + /// Format string. See Formatted Output Strings. + /// Arguments. + /// Return the number of characters written, excluding the terminating null. + /// + /// + /// No overlap is permitted between the space at and the string . + /// + /// + /// These functions are not recommended, since there’s no protection against exceeding the space available at . + /// + /// + /// + /// GNU MP - Formatted Output Functions + /// GNU MP - Formatted Output Strings + /// + /// + /// // Allocate unmanaged string with 50 characters. + /// char_ptr str = new char_ptr("................................................."); + /// + /// mpz_t z = "123456"; + /// mpq_t q = "123/456"; + /// mpf_t f = "12345e6"; + /// mp_limb_t m = 123456; + /// + /// // Print to string. + /// Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42); + /// Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100"); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(str); + /// gmp_lib.mpz_clear(z); + /// gmp_lib.mpq_clear(q); + /// gmp_lib.mpf_clear(f); + /// + /// + /// ' Allocate unmanaged string with 50 characters. + /// Dim str As New char_ptr(".................................................") + /// + /// Dim z As mpz_t = "123456" + /// Dim q As mpq_t = "123/456" + /// Dim f As mpf_t = "12345e6" + /// Dim m As mp_limb_t = 123456 + /// + /// ' Print to string. + /// Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) = 42) + /// Assert.IsTrue(str.ToString() = "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100") + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(str) + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_vsprintf(char_ptr /*char **/ buf, /*const*/ string /*char **/ fmt, params object[] /*va_list*/ ap) + { + if (buf == null) throw new ArgumentNullException("buf"); + if (fmt == null) throw new ArgumentNullException("fmt"); + if (ap == null) throw new ArgumentNullException("ap"); + va_list va_args = new va_list(ap); + char_ptr format = new char_ptr(fmt); + int result = SafeNativeMethods.__gmp_vsprintf(buf.ToIntPtr(), format.ToIntPtr(), va_args.ToIntPtr()); + va_args.RetrieveArgumentValues(); + gmp_lib.free(format); + return result; + } + + #endregion + + #region "Formatted input routines." + + /// + /// Read from the stream fp. + /// + /// File stream. + /// Format string. See Formatted Input Strings. + /// Arguments. + /// The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value. + /// + /// + /// + /// GNU MP - Formatted Input Functions + /// GNU MP - Formatted Input Strings + /// + /// + /// // Create unique filename and stream pointer. + /// string pathname = System.IO.Path.GetTempFileName(); + /// ptr<FILE> stream = new ptr<FILE>(); + /// + /// mpz_t z = "0"; + /// mpq_t q = "0"; + /// mpf_t f = "0"; + /// ptr<Char> c = new ptr<Char>('0'); + /// ptr<mp_size_t> zt = new ptr<mp_size_t>(0); + /// ptr<Double> dbl = new ptr<Double>(0); + /// + /// // Write string to file, and then read values from it. + /// System.IO.File.WriteAllText(pathname, "123456 7B/1C8 1.234500e+10 A 10 1.000000"); + /// _wfopen_s(out stream.Value.Value, pathname, "r"); + /// Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6); + /// fclose(stream.Value.Value); + /// + /// // Assert values read. + /// Assert.IsTrue(z.ToString() == "123456"); + /// Assert.IsTrue(q.ToString() == "123/456"); + /// Assert.IsTrue(f.ToString() == "0.12345e11"); + /// Assert.IsTrue(c.Value == 'A'); + /// Assert.IsTrue(zt.Value == 10); + /// Assert.IsTrue(dbl.Value == 1.0); + /// + /// // Release unmanaged memory. + /// gmp_lib.mpz_clear(z); + /// gmp_lib.mpq_clear(q); + /// gmp_lib.mpf_clear(f); + /// + /// + /// ' Create unique filename and stream pointer. + /// Dim pathname As String = System.IO.Path.GetTempFileName() + /// Dim stream As New ptr(Of FILE)() + /// + /// Dim z As mpz_t = "0" + /// Dim q As mpq_t = "0" + /// Dim f As mpf_t = "0" + /// Dim c As New ptr(Of[Char])("0"C) + /// Dim zt As New ptr(Of mp_size_t)(0) + /// Dim dbl As New ptr(Of[Double])(0) + /// + /// ' Write string to file, and then read values from it. + /// System.IO.File.WriteAllText(pathname, "123456 7B/1C8 1.234500e+10 A 10 1.000000") + /// _wfopen_s(stream.Value.Value, pathname, "r") + /// Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) = 6) + /// fclose(stream.Value.Value) + /// + /// ' Assert values read. + /// Assert.IsTrue(z.ToString() = "123456") + /// Assert.IsTrue(q.ToString() = "123/456") + /// Assert.IsTrue(f.ToString() = "0.12345e11") + /// Assert.IsTrue(c.Value = "A"C) + /// Assert.IsTrue(zt.Value = 10) + /// Assert.IsTrue(dbl.Value = 1.0) + /// + /// ' Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_fscanf(ptr /*FILE **/ fp, /*const*/ string /*char **/ fmt, params object[] /*...*/ ap) + { + return gmp_vfscanf(fp, fmt, ap); + } + + /// + /// Read from the standard input stdin. + /// + /// Format string. See Formatted Input Strings. + /// Arguments. + /// The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value. + /// + /// + /// + /// GNU MP - Formatted Input Functions + /// GNU MP - Formatted Input Strings + /// + /// + /// mpz_t z = "0"; + /// mpq_t q = "0"; + /// mpf_t f = "0"; + /// ptr<Char> c = new ptr<Char>('0'); + /// ptr<mp_size_t> zt = new ptr<mp_size_t>(0); + /// ptr<Double> dbl = new ptr<Double>(0); + /// + /// // Read values from standard input. + /// Assert.IsTrue(gmp_lib.gmp_scanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6); + /// + /// // Assert values read. + /// Assert.IsTrue(z.ToString() == "123456"); + /// Assert.IsTrue(q.ToString() == "123/456"); + /// Assert.IsTrue(f.ToString() == "0.12345e11"); + /// Assert.IsTrue(c.Value == 'A'); + /// Assert.IsTrue(zt.Value == 10); + /// Assert.IsTrue(dbl.Value == 1.0); + /// + /// // Release unmanaged memory. + /// gmp_lib.mpz_clear(z); + /// gmp_lib.mpq_clear(q); + /// gmp_lib.mpf_clear(f); + /// + /// + /// Dim z As mpz_t = "0" + /// Dim q As mpq_t = "0" + /// Dim f As mpf_t = "0" + /// Dim c As New ptr(Of[Char])("0"C) + /// Dim zt As New ptr(Of mp_size_t)(0) + /// Dim dbl As New ptr(Of[Double])(0) + /// + /// ' Read values from standard input. + /// Assert.IsTrue(gmp_lib.gmp_scanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) = 6) + /// + /// ' Assert values read. + /// Assert.IsTrue(z.ToString() = "123456") + /// Assert.IsTrue(q.ToString() = "123/456") + /// Assert.IsTrue(f.ToString() = "0.12345e11") + /// Assert.IsTrue(c.Value = "A"C) + /// Assert.IsTrue(zt.Value = 10) + /// Assert.IsTrue(dbl.Value = 1.0) + /// + /// ' Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_scanf(/*const*/ string /*char **/ fmt, params object[] /*...*/ ap) + { + return gmp_vscanf(fmt, ap); + } + + /// + /// Read from a null-terminated string . + /// + /// A string. + /// Format string. See Formatted Input Strings. + /// Arguments. + /// The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value. + /// + /// + /// + /// GNU MP - Formatted Input Functions + /// GNU MP - Formatted Input Strings + /// + /// + /// mpz_t z = "0"; + /// mpq_t q = "0"; + /// mpf_t f = "0"; + /// ptr<Char> c = new ptr<Char>('0'); + /// ptr<mp_size_t> zt = new ptr<mp_size_t>(0); + /// ptr<Double> dbl = new ptr<Double>(0); + /// + /// Assert.IsTrue(gmp_lib.gmp_sscanf("123456 7B/1C8 1.234500e+10 A 10 1.000000", "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6); + /// + /// Assert.IsTrue(z.ToString() == "123456"); + /// Assert.IsTrue(q.ToString() == "123/456"); + /// Assert.IsTrue(f.ToString() == "0.12345e11"); + /// Assert.IsTrue(c.Value == 'A'); + /// Assert.IsTrue(zt.Value == 10); + /// Assert.IsTrue(dbl.Value == 1.0); + /// + /// // Release unmanaged memory. + /// gmp_lib.mpz_clear(z); + /// gmp_lib.mpq_clear(q); + /// gmp_lib.mpf_clear(f); + /// + /// + /// Dim z As mpz_t = "0" + /// Dim q As mpq_t = "0" + /// Dim f As mpf_t = "0" + /// Dim c As New ptr(Of[Char])("0"C) + /// Dim zt As New ptr(Of mp_size_t)(0) + /// Dim dbl As New ptr(Of[Double])(0) + /// + /// Assert.IsTrue(gmp_lib.gmp_sscanf("123456 7B/1C8 1.234500e+10 A 10 1.000000", "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) = 6) + /// + /// Assert.IsTrue(z.ToString() = "123456") + /// Assert.IsTrue(q.ToString() = "123/456") + /// Assert.IsTrue(f.ToString() = "0.12345e11") + /// Assert.IsTrue(c.Value = "A"C) + /// Assert.IsTrue(zt.Value = 10) + /// Assert.IsTrue(dbl.Value = 1.0) + /// + /// ' Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_sscanf(/*const*/ string /*char **/ s, /*const*/ string /*char **/ fmt, params object[] /*...*/ ap) + { + return gmp_vsscanf(s, fmt, ap); + } + + /// + /// Read from the stream fp. + /// + /// File stream. + /// Format string. See Formatted Input Strings. + /// Arguments. + /// The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value. + /// + /// + /// + /// GNU MP - Formatted Input Functions + /// GNU MP - Formatted Input Strings + /// + /// + /// // Create unique filename and stream pointer. + /// string pathname = System.IO.Path.GetTempFileName(); + /// ptr<FILE> stream = new ptr<FILE>(); + /// + /// mpz_t z = "0"; + /// mpq_t q = "0"; + /// mpf_t f = "0"; + /// ptr<Char> c = new ptr<Char>('0'); + /// ptr<mp_size_t> zt = new ptr<mp_size_t>(0); + /// ptr<Double> dbl = new ptr<Double>(0); + /// + /// // Write string to file, and then read values from it. + /// System.IO.File.WriteAllText(pathname, "123456 7B/1C8 1.234500e+10 A 10 1.000000"); + /// _wfopen_s(out stream.Value.Value, pathname, "r"); + /// Assert.IsTrue(gmp_lib.gmp_vfscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6); + /// fclose(stream.Value.Value); + /// + /// // Assert values read. + /// Assert.IsTrue(z.ToString() == "123456"); + /// Assert.IsTrue(q.ToString() == "123/456"); + /// Assert.IsTrue(f.ToString() == "0.12345e11"); + /// Assert.IsTrue(c.Value == 'A'); + /// Assert.IsTrue(zt.Value == 10); + /// Assert.IsTrue(dbl.Value == 1.0); + /// + /// // Release unmanaged memory. + /// gmp_lib.mpz_clear(z); + /// gmp_lib.mpq_clear(q); + /// gmp_lib.mpf_clear(f); + /// + /// + /// ' Create unique filename and stream pointer. + /// Dim pathname As String = System.IO.Path.GetTempFileName() + /// Dim stream As New ptr(Of FILE)() + /// + /// Dim z As mpz_t = "0" + /// Dim q As mpq_t = "0" + /// Dim f As mpf_t = "0" + /// Dim c As New ptr(Of[Char])("0"C) + /// Dim zt As New ptr(Of mp_size_t)(0) + /// Dim dbl As New ptr(Of[Double])(0) + /// + /// ' Write string to file, and then read values from it. + /// System.IO.File.WriteAllText(pathname, "123456 7B/1C8 1.234500e+10 A 10 1.000000") + /// _wfopen_s(stream.Value.Value, pathname, "r") + /// Assert.IsTrue(gmp_lib.gmp_vfscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) = 6) + /// fclose(stream.Value.Value) + /// + /// ' Assert values read. + /// Assert.IsTrue(z.ToString() = "123456") + /// Assert.IsTrue(q.ToString() = "123/456") + /// Assert.IsTrue(f.ToString() = "0.12345e11") + /// Assert.IsTrue(c.Value = "A"C) + /// Assert.IsTrue(zt.Value = 10) + /// Assert.IsTrue(dbl.Value = 1.0) + /// + /// ' Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_vfscanf(ptr /*FILE **/ fp, /*const*/ string /*char **/ fmt, params object[] /*va_list*/ ap) + { + if (fp == null) throw new ArgumentNullException("fp"); + if (fmt == null) throw new ArgumentNullException("fmt"); + if (ap == null) throw new ArgumentNullException("ap"); + va_list va_args = new va_list(ap); + char_ptr format = new char_ptr(fmt); + int result = SafeNativeMethods.__gmp_vfscanf(fp.Value.Value, format.ToIntPtr(), va_args.ToIntPtr()); + va_args.RetrieveArgumentValues(); + gmp_lib.free(format); + return result; + } + + /// + /// Read from the standard input stdin. + /// + /// Format string. See Formatted Input Strings. + /// Arguments. + /// The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value. + /// + /// + /// + /// GNU MP - Formatted Input Functions + /// GNU MP - Formatted Input Strings + /// + /// + /// mpz_t z = "0"; + /// mpq_t q = "0"; + /// mpf_t f = "0"; + /// ptr<Char> c = new ptr<Char>('0'); + /// ptr<mp_size_t> zt = new ptr<mp_size_t>(0); + /// ptr<Double> dbl = new ptr<Double>(0); + /// + /// // Read values from standard input. + /// Assert.IsTrue(gmp_lib.gmp_vscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6); + /// + /// // Assert values read. + /// Assert.IsTrue(z.ToString() == "123456"); + /// Assert.IsTrue(q.ToString() == "123/456"); + /// Assert.IsTrue(f.ToString() == "0.12345e11"); + /// Assert.IsTrue(c.Value == 'A'); + /// Assert.IsTrue(zt.Value == 10); + /// Assert.IsTrue(dbl.Value == 1.0); + /// + /// // Release unmanaged memory. + /// gmp_lib.mpz_clear(z); + /// gmp_lib.mpq_clear(q); + /// gmp_lib.mpf_clear(f); + /// + /// + /// Dim z As mpz_t = "0" + /// Dim q As mpq_t = "0" + /// Dim f As mpf_t = "0" + /// Dim c As New ptr(Of[Char])("0"C) + /// Dim zt As New ptr(Of mp_size_t)(0) + /// Dim dbl As New ptr(Of[Double])(0) + /// + /// ' Read values from standard input. + /// Assert.IsTrue(gmp_lib.gmp_vscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) = 6) + /// + /// ' Assert values read. + /// Assert.IsTrue(z.ToString() = "123456") + /// Assert.IsTrue(q.ToString() = "123/456") + /// Assert.IsTrue(f.ToString() = "0.12345e11") + /// Assert.IsTrue(c.Value = "A"C) + /// Assert.IsTrue(zt.Value = 10) + /// Assert.IsTrue(dbl.Value = 1.0) + /// + /// ' Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_vscanf(/*const*/ string /*char **/ fmt, params object[] /*va_list*/ ap) + { + if (fmt == null) throw new ArgumentNullException("fmt"); + if (ap == null) throw new ArgumentNullException("ap"); + va_list va_args = new va_list(ap); + char_ptr format = new char_ptr(fmt); + int result = SafeNativeMethods.__gmp_vscanf(format.ToIntPtr(), va_args.ToIntPtr()); + va_args.RetrieveArgumentValues(); + gmp_lib.free(format); + return result; + } + + /// + /// Read from a null-terminated string . + /// + /// A string. + /// Format string. See Formatted Input Strings. + /// Arguments. + /// The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value. + /// + /// + /// + /// GNU MP - Formatted Input Functions + /// GNU MP - Formatted Input Strings + /// + /// + /// mpz_t z = "0"; + /// mpq_t q = "0"; + /// mpf_t f = "0"; + /// ptr<Char> c = new ptr<Char>('0'); + /// ptr<mp_size_t> zt = new ptr<mp_size_t>(0); + /// ptr<Double> dbl = new ptr<Double>(0); + /// + /// Assert.IsTrue(gmp_lib.gmp_vsscanf("123456 7B/1C8 1.234500e+10 A 10 1.000000", "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6); + /// + /// Assert.IsTrue(z.ToString() == "123456"); + /// Assert.IsTrue(q.ToString() == "123/456"); + /// Assert.IsTrue(f.ToString() == "0.12345e11"); + /// Assert.IsTrue(c.Value == 'A'); + /// Assert.IsTrue(zt.Value == 10); + /// Assert.IsTrue(dbl.Value == 1.0); + /// + /// // Release unmanaged memory. + /// gmp_lib.mpz_clear(z); + /// gmp_lib.mpq_clear(q); + /// gmp_lib.mpf_clear(f); + /// + /// + /// Dim z As mpz_t = "0" + /// Dim q As mpq_t = "0" + /// Dim f As mpf_t = "0" + /// Dim c As New ptr(Of[Char])("0"C) + /// Dim zt As New ptr(Of mp_size_t)(0) + /// Dim dbl As New ptr(Of[Double])(0) + /// + /// Assert.IsTrue(gmp_lib.gmp_vsscanf("123456 7B/1C8 1.234500e+10 A 10 1.000000", "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) = 6) + /// + /// Assert.IsTrue(z.ToString() = "123456") + /// Assert.IsTrue(q.ToString() = "123/456") + /// Assert.IsTrue(f.ToString() = "0.12345e11") + /// Assert.IsTrue(c.Value = "A"C) + /// Assert.IsTrue(zt.Value = 10) + /// Assert.IsTrue(dbl.Value = 1.0) + /// + /// ' Release unmanaged memory. + /// gmp_lib.mpz_clear(z) + /// gmp_lib.mpq_clear(q) + /// gmp_lib.mpf_clear(f) + /// + /// + public static int gmp_vsscanf(/*const*/ string /*char **/ s, /*const*/ string /*char **/ fmt, params object[] /*va_list*/ ap) + { + if (s == null) throw new ArgumentNullException("s"); + if (fmt == null) throw new ArgumentNullException("fmt"); + if (ap == null) throw new ArgumentNullException("ap"); + va_list va_args = new va_list(ap); + char_ptr format = new char_ptr(fmt); + char_ptr buf = new char_ptr(s); + int result = SafeNativeMethods.__gmp_vsscanf(buf.ToIntPtr(), format.ToIntPtr(), va_args.ToIntPtr()); + va_args.RetrieveArgumentValues(); + gmp_lib.free(format); + gmp_lib.free(buf); + return result; + } + + #endregion + + #region "Integer (i.e. Z) routines." + + /// + /// Change the space for to limbs. + /// + /// The integer to resize. + /// The new number of limbs. + /// + /// + /// The value in is preserved if it fits, or is set to 0 if not. + /// + /// + /// is the preferred way to accomplish allocation changes like this. + /// and are the same except that + /// takes its size in limbs. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Special Functions + /// + /// + /// // Create and initialize new integer x. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// + /// // Set the value of x to a 77-bit integer. + /// char_ptr value = new char_ptr("1000 0000 0000 0000 0000"); + /// gmp_lib.mpz_set_str(x, value, 16); + /// + /// // Resize x to 50 limbs, and assert that its value has not changed. + /// gmp_lib._mpz_realloc(x, 50); + /// char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 16, x); + /// Assert.IsTrue(s.ToString() == "1000 0000 0000 0000 0000".Replace(" ", "")); + /// + /// // Resize x to 1 limb, and assert that its value has changed to 0. + /// gmp_lib._mpz_realloc(x, 1); + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) == 0); + /// + /// // Release unmanaged memory allocated for x and string values. + /// gmp_lib.mpz_clear(x); + /// gmp_lib.free(value); + /// gmp_lib.free(s); + /// + /// + /// ' Create and initialize new integer x. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init(x) + /// + /// ' Set the value of x to a 77-bit integer. + /// Dim value As New char_ptr("1000 0000 0000 0000 0000") + /// gmp_lib.mpz_set_str(x, value, 16) + /// + /// ' Resize x to 50 limbs, and assert that its value has not changed. + /// gmp_lib._mpz_realloc(x, 50) + /// Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 16, x) + /// Assert.IsTrue(s.ToString() = "1000 0000 0000 0000 0000".Replace(" ", "")) + /// + /// ' Resize x to 1 limb, and assert that its value has changed to 0. + /// gmp_lib._mpz_realloc(x, 1) + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) = 0) + /// + /// ' Release unmanaged memory allocated for x and string values. + /// gmp_lib.mpz_clear(x) + /// gmp_lib.free(value) + /// gmp_lib.free(s) + /// + /// + public static void _mpz_realloc(mpz_t integer, mp_size_t new_alloc) + { + if (integer == null) throw new ArgumentNullException("integer"); + SafeNativeMethods.__gmpz_realloc(integer.ToIntPtr(), new_alloc); + } + + /// + /// Set to the absolute value of . + /// + /// The result integer. + /// The operand integer. + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to -10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_si(x, -10000); + /// + /// // Create, initialize, and set the value of z to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = |x|. + /// gmp_lib.mpz_abs(z, x); + /// + /// // Assert that z is |x|. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == 10000); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to -10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_si(x, -10000) + /// + /// ' Create, initialize, and set the value of z to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = |x|. + /// gmp_lib.mpz_abs(z, x) + /// + /// ' Assert that z is |x|. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = 10000) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, Nothing) + /// + /// + public static void mpz_abs(mpz_t rop, /*const*/ mpz_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpz_abs(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set to + . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10000U); + /// + /// // Create, initialize, and set the value of y to 12222. + /// mpz_t y = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(y, 12222U); + /// + /// // Create, initialize, and set the value of z to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = x + y. + /// gmp_lib.mpz_add(z, x, y); + /// + /// // Assert that z is the sum of x and y. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(z) == 22222U); + /// + /// // Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpz_clears(x, y, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10000UI) + /// + /// ' Create, initialize, and set the value of y to 12222. + /// Dim y As New mpz_t() + /// gmp_lib.mpz_init_set_ui(y, 12222UI) + /// + /// ' Create, initialize, and set the value of z to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = x + y. + /// gmp_lib.mpz_add(z, x, y) + /// + /// ' Assert that z is the sum of x and y. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(z) = 22222UI) + /// + /// ' Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpz_clears(x, y, z, Nothing) + /// + /// + public static void mpz_add(mpz_t rop, /*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpz_add(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Set to + . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to 0. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// + /// // Increment x twice by 101999. + /// gmp_lib.mpz_add_ui(x, x, 101999U); + /// gmp_lib.mpz_add_ui(x, x, 101999U); + /// + /// // Assert that x is 203998. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 203998U); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create, initialize, and set the value of x to 0. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init(x) + /// + /// ' Increment x twice by 101999. + /// gmp_lib.mpz_add_ui(x, x, 101999UI) + /// gmp_lib.mpz_add_ui(x, x, 101999UI) + /// + /// ' Assert that x is 203998. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(x) = 203998UI) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static void mpz_add_ui(mpz_t rop, /*const*/ mpz_t op1, uint /*unsigned long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpz_add_ui(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Set to + * . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10000U); + /// + /// // Create, initialize, and set the value of y to 12222. + /// mpz_t y = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(y, 12222U); + /// + /// // Create, initialize, and set the value of z to 20000. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(z, 20000U); + /// + /// // Set z += x * y. + /// gmp_lib.mpz_addmul(z, x, y); + /// + /// // Assert that z has been incremented by 10000 * 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000U + 10000 * 12222); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, y, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10000UI) + /// + /// ' Create, initialize, and set the value of y to 12222. + /// Dim y As New mpz_t() + /// gmp_lib.mpz_init_set_ui(y, 12222UI) + /// + /// ' Create, initialize, and set the value of z to 20000. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init_set_ui(z, 20000UI) + /// + /// ' Set z += x * y. + /// gmp_lib.mpz_addmul(z, x, y) + /// + /// ' Assert that z has been incremented by 10000 * 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = 20000UI + 10000 * 12222) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, y, z, Nothing) + /// + /// + public static void mpz_addmul(mpz_t rop, /*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpz_addmul(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Set to + * . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to -10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_si(x, -10000); + /// + /// // Create, initialize, and set the value of z to 20000. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init_set_si(z, 20000); + /// + /// // Set z += x * 12222. + /// gmp_lib.mpz_addmul_ui(z, x, 12222U); + /// + /// // Assert that z has been incremented by -10000 * 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000 + -10000 * 12222); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to -10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_si(x, -10000) + /// + /// ' Create, initialize, and set the value of z to 20000. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init_set_si(z, 20000) + /// + /// ' Set z += x * 12222. + /// gmp_lib.mpz_addmul_ui(z, x, 12222UI) + /// + /// ' Assert that z has been incremented by -10000 * 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = 20000 + -10000 * 12222) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, Nothing) + /// + /// + public static void mpz_addmul_ui(mpz_t rop, /*const*/ mpz_t op1, uint /*unsigned long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpz_addmul_ui(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Set to bitwise-and . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + /// The least significant bit is number 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Logic and Bit Fiddling + /// + /// + /// // Create, initialize, and set the value of op1 to 63. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op1, 63U); + /// + /// // Create, initialize, and set the value of op2 to 70. + /// mpz_t op2 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op2, 70U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop to the bitwise and of op1 and op2. + /// gmp_lib.mpz_and(rop, op1, op2); + /// + /// // Assert that rop is 6. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6); + /// + /// // Release unmanaged memory allocated for rop, op1, and op2. + /// gmp_lib.mpz_clears(rop, op1, op2, null); + /// + /// + /// ' Create, initialize, and set the value of op1 to 63. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op1, 63UI) + /// + /// ' Create, initialize, and set the value of op2 to 70. + /// Dim op2 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op2, 70UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop to the bitwise and of op1 and op2. + /// gmp_lib.mpz_and(rop, op1, op2) + /// + /// ' Assert that rop is 6. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 6) + /// + /// ' Release unmanaged memory allocated for rop, op1, and op2. + /// gmp_lib.mpz_clears(rop, op1, op2, Nothing) + /// + /// + public static void mpz_and(mpz_t rop, /*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpz_and(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Compute the binomial coefficient over and store the result in . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// Negative values of n are supported by , using the identity + /// bin(-, ) = (-1)^ * bin( + - 1, ), + /// see Knuth volume 1 section 1.2.6 part G. + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of n to 4. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 4); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop to the binomial coefficient (n:2). + /// gmp_lib.mpz_bin_ui(rop, n, 2U); + /// + /// // Assert that rop is 6. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6); + /// + /// // Release unmanaged memory allocated for n and rop. + /// gmp_lib.mpz_clears(n, rop, null); + /// + /// + /// ' Create, initialize, and set the value of n to 4. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 4) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop to the binomial coefficient (n:2). + /// gmp_lib.mpz_bin_ui(rop, n, 2UI) + /// + /// ' Assert that rop is 6. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 6) + /// + /// ' Release unmanaged memory allocated for n and rop. + /// gmp_lib.mpz_clears(n, rop, Nothing) + /// + /// + public static void mpz_bin_ui(mpz_t rop, /*const*/ mpz_t n, uint /*unsigned long int*/ k) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (n == null) throw new ArgumentNullException("n"); + SafeNativeMethods.__gmpz_bin_ui(rop.ToIntPtr(), n.ToIntPtr(), k); + } + + /// + /// Compute the binomial coefficient over and store the result in . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop to the binomial coefficient (4:2). + /// gmp_lib.mpz_bin_uiui(rop, 4U, 2U); + /// + /// // Assert that rop is 6. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6); + /// + /// // Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop to the binomial coefficient (4:2). + /// gmp_lib.mpz_bin_uiui(rop, 4UI, 2UI) + /// + /// ' Assert that rop is 6. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 6) + /// + /// ' Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop) + /// + /// + public static void mpz_bin_uiui(mpz_t rop, uint /*unsigned long int*/ n, uint /*unsigned long int*/ k) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_bin_uiui(rop.ToIntPtr(), n, k); + } + + /// + /// Set the quotient to ceiling( / ). + /// + /// The result quotient integer. + /// The numerator integer. + /// The denominator integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of d to 3. + /// mpz_t d = new mpz_t(); + /// gmp_lib.mpz_init_set_si(d, 3); + /// + /// // Create, initialize, and set the value of q to 0. + /// mpz_t q = new mpz_t(); + /// gmp_lib.mpz_init(q); + /// + /// // Set q = ceiling(n / d). + /// gmp_lib.mpz_cdiv_q(q, n, d); + /// + /// // Assert that q is ceiling(10000 / 3). + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334); + /// + /// // Release unmanaged memory allocated for n, d, and q. + /// gmp_lib.mpz_clears(n, d, q, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of d to 3. + /// Dim d As New mpz_t() + /// gmp_lib.mpz_init_set_si(d, 3) + /// + /// ' Create, initialize, and set the value of q to 0. + /// Dim q As New mpz_t() + /// gmp_lib.mpz_init(q) + /// + /// ' Set q = ceiling(n / d). + /// gmp_lib.mpz_cdiv_q(q, n, d) + /// + /// ' Assert that q is ceiling(10000 / 3). + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3334) + /// + /// ' Release unmanaged memory allocated for n, d, and q. + /// gmp_lib.mpz_clears(n, d, q, Nothing) + /// + /// + public static void mpz_cdiv_q(mpz_t q, /*const*/ mpz_t n, /*const*/ mpz_t d) + { + if (q == null) throw new ArgumentNullException("q"); + if (n == null) throw new ArgumentNullException("n"); + if (d == null) throw new ArgumentNullException("d"); + SafeNativeMethods.__gmpz_cdiv_q(q.ToIntPtr(), n.ToIntPtr(), d.ToIntPtr()); + } + + /// + /// Set the quotient to ceiling( / 2^). + /// + /// The result quotient integer. + /// The numerator integer. + /// The exponent of the power of two denominator. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10001. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10001); + /// + /// // Create, initialize, and set the value of q to 0. + /// mpz_t q = new mpz_t(); + /// gmp_lib.mpz_init(q); + /// + /// // Set q = ceiling(n / 2^2). + /// gmp_lib.mpz_cdiv_q_2exp(q, n, 2U); + /// + /// // Assert that q is ceiling(10001 / 4). + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 2501); + /// + /// // Release unmanaged memory allocated for n and q. + /// gmp_lib.mpz_clears(n, q, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10001. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10001) + /// + /// ' Create, initialize, and set the value of q to 0. + /// Dim q As New mpz_t() + /// gmp_lib.mpz_init(q) + /// + /// ' Set q = ceiling(n / 2^2). + /// gmp_lib.mpz_cdiv_q_2exp(q, n, 2UI) + /// + /// ' Assert that q is ceiling(10001 / 4). + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 2501) + /// + /// ' Release unmanaged memory allocated for n and q. + /// gmp_lib.mpz_clears(n, q, Nothing) + /// + /// + public static void mpz_cdiv_q_2exp(mpz_t q, /*const*/ mpz_t n, mp_bitcnt_t b) + { + if (q == null) throw new ArgumentNullException("q"); + if (n == null) throw new ArgumentNullException("n"); + SafeNativeMethods.__gmpz_cdiv_q_2exp(q.ToIntPtr(), n.ToIntPtr(), b); + } + + /// + /// Set the quotient to ceiling( / ), and return the remainder r = | - * |. + /// + /// The result quotient integer. + /// The numerator integer. + /// The denominator integer. + /// Return the remainder r = | - * |. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of q to 0. + /// mpz_t q = new mpz_t(); + /// gmp_lib.mpz_init(q); + /// + /// // Set q = ceiling(n / 3) and return r = n - 3 * q. + /// // Assert q and r values. + /// Assert.IsTrue(gmp_lib.mpz_cdiv_q_ui(q, n, 3U) == 2U); + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334); + /// + /// // Release unmanaged memory allocated for n and q. + /// gmp_lib.mpz_clears(n, q, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of q to 0. + /// Dim q As New mpz_t() + /// gmp_lib.mpz_init(q) + /// + /// ' Set q = ceiling(n / 3) and return r = n - 3 * q. + /// ' Assert q and r values. + /// Assert.IsTrue(gmp_lib.mpz_cdiv_q_ui(q, n, 3UI) = 2UI) + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3334) + /// + /// ' Release unmanaged memory allocated for n and q. + /// gmp_lib.mpz_clears(n, q, Nothing) + /// + /// + public static uint /*unsigned long int*/ mpz_cdiv_q_ui(mpz_t q, /*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (q == null) throw new ArgumentNullException("q"); + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_cdiv_q_ui(q.ToIntPtr(), n.ToIntPtr(), d); + } + + /// + /// Set the quotient to ceiling( / ), and set the remainder to - * . + /// + /// The result quotient integer. + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of d to 3. + /// mpz_t d = new mpz_t(); + /// gmp_lib.mpz_init_set_si(d, 3); + /// + /// // Create, initialize, and set the values of q and r to 0. + /// mpz_t q = new mpz_t(); + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_inits(q, r, null); + /// + /// // Set q = ceiling(n / 3) and r = n - d * q. + /// gmp_lib.mpz_cdiv_qr(q, r, n, d); + /// + /// // Assert that q is 3334, and that r is -2. + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334); + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2); + /// + /// // Release unmanaged memory allocated for n, d, q, and r. + /// gmp_lib.mpz_clears(n, d, q, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of d to 3. + /// Dim d As New mpz_t() + /// gmp_lib.mpz_init_set_si(d, 3) + /// + /// ' Create, initialize, and set the values of q and r to 0. + /// Dim q As New mpz_t() + /// Dim r As New mpz_t() + /// gmp_lib.mpz_inits(q, r, Nothing) + /// + /// Set q = ceiling(n / 3) and r = n - d * q. + /// gmp_lib.mpz_cdiv_qr(q, r, n, d) + /// + /// ' Assert that q is 3334, and that r is -2. + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3334) + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = -2) + /// + /// ' Release unmanaged memory allocated for n, d, q, and r. + /// gmp_lib.mpz_clears(n, d, q, r, Nothing) + /// + /// + public static void mpz_cdiv_qr(mpz_t q, mpz_t r, /*const*/ mpz_t n, /*const*/ mpz_t d) + { + if (q == null) throw new ArgumentNullException("q"); + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + if (d == null) throw new ArgumentNullException("d"); + SafeNativeMethods.__gmpz_cdiv_qr(q.ToIntPtr(), r.ToIntPtr(), n.ToIntPtr(), d.ToIntPtr()); + } + + /// + /// Set quotient to ceiling( / ), set the remainder to - * , and return ||. + /// + /// The result quotient integer. + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// Return ||. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the values of q and r to 0. + /// mpz_t q = new mpz_t(); + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_inits(q, r, null); + /// + /// // Set q = ceiling(n / 3), r = n - d * q, and return r. + /// Assert.IsTrue(gmp_lib.mpz_cdiv_qr_ui(q, r, n, 3U) == 2U); + /// + /// // Assert that q is 3334, and that r is -2. + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334); + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2); + /// + /// // Release unmanaged memory allocated for n, q, and r. + /// gmp_lib.mpz_clears(n, q, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the values of q and r to 0. + /// Dim q As New mpz_t() + /// Dim r As New mpz_t() + /// gmp_lib.mpz_inits(q, r, Nothing) + /// + /// ' Set q = ceiling(n / 3), r = n - d * q, and return r. + /// Assert.IsTrue(gmp_lib.mpz_cdiv_qr_ui(q, r, n, 3UI) = 2UI) + /// + /// ' Assert that q is 3334, and that r is -2. + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3334) + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = -2) + /// + /// ' Release unmanaged memory allocated for n, q, and r. + /// gmp_lib.mpz_clears(n, q, r, Nothing) + /// + /// + public static uint /*unsigned long int*/ mpz_cdiv_qr_ui(mpz_t q, mpz_t r, /*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (q == null) throw new ArgumentNullException("q"); + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_cdiv_qr_ui(q.ToIntPtr(), r.ToIntPtr(), n.ToIntPtr(), d); + } + + /// + /// Set the remainder to - q * where q = ceiling( / ). + /// + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of d to 3. + /// mpz_t d = new mpz_t(); + /// gmp_lib.mpz_init_set_si(d, 3); + /// + /// // Create, initialize, and set the value of r to 0. + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_init(r); + /// + /// // Set r = n - d * ceiling(n / d). + /// gmp_lib.mpz_cdiv_r(r, n, d); + /// + /// // Assert that r is -2. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2); + /// + /// // Release unmanaged memory allocated for n, d, and r. + /// gmp_lib.mpz_clears(n, d, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of d to 3. + /// Dim d As New mpz_t() + /// gmp_lib.mpz_init_set_si(d, 3) + /// + /// ' Create, initialize, and set the value of r to 0. + /// Dim r As New mpz_t() + /// gmp_lib.mpz_init(r) + /// + /// ' Set r = n - d * ceiling(n / d). + /// gmp_lib.mpz_cdiv_r(r, n, d) + /// + /// ' Assert that r is -2. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = -2) + /// + /// ' Release unmanaged memory allocated for n, d, and r. + /// gmp_lib.mpz_clears(n, d, r, Nothing) + /// + /// + public static void mpz_cdiv_r(mpz_t r, /*const*/ mpz_t n, /*const*/ mpz_t d) + { + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + if (d == null) throw new ArgumentNullException("d"); + SafeNativeMethods.__gmpz_cdiv_r(r.ToIntPtr(), n.ToIntPtr(), d.ToIntPtr()); + } + + /// + /// Set the remainder to - q * 2^ where q = ceiling( / 2^). + /// + /// The result remainder integer. + /// The numerator integer. + /// The exponent of the power of two denominator. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10001. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10001); + /// + /// // Create, initialize, and set the value of r to 0. + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_init(r); + /// + /// // Set r = n - 2^2 * ceiling(n / 2^2) + /// gmp_lib.mpz_cdiv_r_2exp(r, n, 2U); + /// + /// // Assert that r is -3. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == -3); + /// + /// // Release unmanaged memory allocated for n and r. + /// gmp_lib.mpz_clears(n, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10001. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10001) + /// + /// ' Create, initialize, and set the value of r to 0. + /// Dim r As New mpz_t() + /// gmp_lib.mpz_init(r) + /// ' Set r = n - 2^2 * ceiling(n / 2^2) + /// gmp_lib.mpz_cdiv_r_2exp(r, n, 2UI) + /// + /// ' Assert that r is -3. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = -3) + /// + /// ' Release unmanaged memory allocated for n and r. + /// gmp_lib.mpz_clears(n, r, Nothing) + /// + /// + public static void mpz_cdiv_r_2exp(mpz_t r, /*const*/ mpz_t n, mp_bitcnt_t b) + { + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + SafeNativeMethods.__gmpz_cdiv_r_2exp(r.ToIntPtr(), n.ToIntPtr(), b); + } + + /// + /// Set the remainder to - q * where q = ceiling( / ), and return ||. + /// + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// Return ||. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of r to 0. + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_init(r); + /// + /// // Set r = n - 3 * ceiling(n / 3), and return |r|. + /// Assert.IsTrue(gmp_lib.mpz_cdiv_r_ui(r, n, 3U) == 2U); + /// + /// // Assert that r is -2. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2); + /// + /// // Release unmanaged memory allocated for n and r. + /// gmp_lib.mpz_clears(n, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of r to 0. + /// Dim r As New mpz_t() + /// gmp_lib.mpz_init(r) + /// + /// ' Set r = n - 3 * ceiling(n / 3), and return |r|. + /// Assert.IsTrue(gmp_lib.mpz_cdiv_r_ui(r, n, 3UI) = 2UI) + /// + /// ' Assert that r is -2. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = -2) + /// + /// ' Release unmanaged memory allocated for n and r. + /// gmp_lib.mpz_clears(n, r, Nothing) + /// + /// + public static uint /*unsigned long int*/ mpz_cdiv_r_ui(mpz_t r, /*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_cdiv_r_ui(r.ToIntPtr(), n.ToIntPtr(), d); + } + + /// + /// Return the remainder |r| where r = - q * , and where q = ceiling( / ). + /// + /// The numerator integer. + /// The denominator integer. + /// The remainder |r| where r = - q * , and where q = ceiling( / ). + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Assert that returned value is |n - 3 * ceiling(n / 3)|. + /// Assert.IsTrue(gmp_lib.mpz_cdiv_ui(n, 3U) == 2U); + /// + /// // Release unmanaged memory allocated for n. + /// gmp_lib.mpz_clear(n); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Assert that returned value is |n - 3 * ceiling(n / 3)|. + /// Assert.IsTrue(gmp_lib.mpz_cdiv_ui(n, 3UI) = 2UI) + /// + /// ' Release unmanaged memory allocated for n. + /// gmp_lib.mpz_clear(n) + /// + /// + public static ulong mpz_cdiv_ui(/*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_cdiv_ui(n.ToIntPtr(), d); + } + + /// + /// Free the space occupied by . + /// + /// The integer. + /// + /// + /// Call this function for all variables when you are done with them. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Integers + /// + /// + /// // Create and initialize a new integer x. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// + /// // Assert that the value of x is 0. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 0U); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create and initialize a new integer x. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init(x) + /// + /// ' Assert that the value of x is 0. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(x) = 0UI) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static void mpz_clear(mpz_t x) + { + if (x == null) throw new ArgumentNullException("x"); + SafeNativeMethods.__gmpz_clear(x.ToIntPtr()); + gmp_lib.free(new void_ptr(x.ToIntPtr())); + } + + /// + /// Free the space occupied by a NULL-terminated list of variables. + /// + /// A NULL-terminated list of variables. + /// + /// + /// + /// + /// + /// GNU MP - Initializing Integers + /// + /// + /// // Create new integers x1, x2 and x3. + /// mpz_t x1 = new mpz_t(); + /// mpz_t x2 = new mpz_t(); + /// mpz_t x3 = new mpz_t(); + /// + /// // Initialize the integers. + /// gmp_lib.mpz_inits(x1, x2, x3, null); + /// + /// // Assert that their value is 0. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x1) == 0); + /// Assert.IsTrue(gmp_lib.mpz_get_si(x2) == 0); + /// Assert.IsTrue(gmp_lib.mpz_get_si(x3) == 0); + /// + /// // Release unmanaged memory allocated for the integers. + /// gmp_lib.mpz_clears(x1, x2, x3, null); + /// + /// + /// ' Create new integers x1, x2 and x3. + /// Dim x1 As New mpz_t() + /// Dim x2 As New mpz_t() + /// Dim x3 As New mpz_t() + /// + /// ' Initialize the integers. + /// gmp_lib.mpz_inits(x1, x2, x3, Nothing) + /// + /// ' Assert that their value is 0. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x1) = 0) + /// Assert.IsTrue(gmp_lib.mpz_get_si(x2) = 0) + /// Assert.IsTrue(gmp_lib.mpz_get_si(x3) = 0) + /// + /// ' Release unmanaged memory allocated for the integers. + /// gmp_lib.mpz_clears(x1, x2, x3, Nothing) + /// + /// + public static void mpz_clears(params mpz_t[] x) + { + if (x == null) throw new ArgumentNullException("x"); + foreach (mpz_t a in x) { if (a != null) mpz_clear(a); } + } + + /// + /// Clear bit in . + /// + /// The result integer. + /// The index of the bit to clear. + /// + /// + /// The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + /// The least significant bit is number 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Logic and Bit Fiddling + /// + /// + /// // Create, initialize, and set the value of rop to 70. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init_set_si(rop, 70); + /// + /// // Clear bit 3 of rop. + /// gmp_lib.mpz_clrbit(rop, 3U); + /// + /// // Assert that rop is 70. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 70); + /// + /// // Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and set the value of rop to 70. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init_set_si(rop, 70) + /// + /// ' Clear bit 3 of rop. + /// gmp_lib.mpz_clrbit(rop, 3UI) + /// + /// ' Assert that rop is 70. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 70) + /// + /// ' Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop) + /// + /// + public static void mpz_clrbit(mpz_t rop, mp_bitcnt_t bit_index) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_clrbit(rop.ToIntPtr(), bit_index); + } + + /// + /// Compare and . + /// + /// The first operand integer. + /// The second operand integer. + /// Return a positive value if > , zero if = , or a negative value if < . + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Comparisons + /// + /// + /// // Create, initialize, and set the value of op1 to 63. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op1, 63U); + /// + /// // Create, initialize, and set the value of op2 to 70. + /// mpz_t op2 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op2, 70U); + /// + /// // Assert that op1 < op2. + /// Assert.IsTrue(gmp_lib.mpz_cmp(op1, op2) < 0); + /// + /// // Release unmanaged memory allocated for op1 and op2. + /// gmp_lib.mpz_clears(op1, op2, null); + /// + /// + /// ' Create, initialize, and set the value of op1 to 63. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op1, 63UI) + /// + /// ' Create, initialize, and set the value of op2 to 70. + /// Dim op2 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op2, 70UI) + /// + /// ' Assert that op1 < op2. + /// Assert.IsTrue(gmp_lib.mpz_cmp(op1, op2) < 0) + /// + /// ' Release unmanaged memory allocated for op1 and op2. + /// gmp_lib.mpz_clears(op1, op2, Nothing) + /// + /// + public static int mpz_cmp(/*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + return SafeNativeMethods.__gmpz_cmp(op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Compare and . + /// + /// The first operand integer. + /// The second operand integer. + /// Return a positive value if > , zero if = , or a negative value if < . + /// + /// + /// can be called with an infinity (see or ), + /// but results are undefined for a . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Comparisons + /// + /// + /// // Create, initialize, and set the value of op1 to 63. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op1, 63U); + /// + /// // Assert that op1 < 70.0. + /// Assert.IsTrue(gmp_lib.mpz_cmp_d(op1, 70.0) < 0); + /// + /// // Release unmanaged memory allocated for op1. + /// gmp_lib.mpz_clear(op1); + /// + /// + /// ' Create, initialize, and set the value of op1 to 63. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op1, 63UI) + /// + /// ' Assert that op1 < 70.0. + /// Assert.IsTrue(gmp_lib.mpz_cmp_d(op1, 70.0) < 0) + /// + /// ' Release unmanaged memory allocated for op1. + /// gmp_lib.mpz_clear(op1) + /// + /// + public static int mpz_cmp_d(/*const*/ mpz_t op1, double op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + return SafeNativeMethods.__gmpz_cmp_d(op1.ToIntPtr(), op2); + } + + /// + /// Compare and . + /// + /// The first operand integer. + /// The second operand integer. + /// Return a positive value if > , zero if = , or a negative value if < . + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Comparisons + /// + /// + /// // Create, initialize, and set the value of op1 to 63. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op1, 63U); + /// + /// // Assert that op1 < 70. + /// Assert.IsTrue(gmp_lib.mpz_cmp_si(op1, 70) < 0); + /// + /// // Release unmanaged memory allocated for op1. + /// gmp_lib.mpz_clear(op1); + /// + /// + /// ' Create, initialize, and set the value of op1 to 63. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op1, 63UI) + /// + /// ' Assert that op1 < 70. + /// Assert.IsTrue(gmp_lib.mpz_cmp_si(op1, 70) < 0) + /// + /// ' Release unmanaged memory allocated for op1. + /// gmp_lib.mpz_clear(op1) + /// + /// + public static int mpz_cmp_si(/*const*/ mpz_t op1, int /*long int*/ op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + return SafeNativeMethods.__gmpz_cmp_si(op1.ToIntPtr(), op2); + } + + /// + /// Compare and . + /// + /// The first operand integer. + /// The second operand integer. + /// Return a positive value if > , zero if = , or a negative value if < . + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Comparisons + /// + /// + /// // Create, initialize, and set the value of op1 to 63. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op1, 63U); + /// + /// // Assert that op1 < 70. + /// Assert.IsTrue(gmp_lib.mpz_cmp_ui(op1, 70U) < 0); + /// + /// // Release unmanaged memory allocated for op1. + /// gmp_lib.mpz_clear(op1); + /// + /// + /// ' Create, initialize, and set the value of op1 to 63. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op1, 63UI) + /// + /// ' Assert that op1 < 70. + /// Assert.IsTrue(gmp_lib.mpz_cmp_ui(op1, 70UI) < 0) + /// + /// ' Release unmanaged memory allocated for op1. + /// gmp_lib.mpz_clear(op1) + /// + /// + public static int mpz_cmp_ui(/*const*/ mpz_t op1, uint /*unsigned long int*/ op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + return SafeNativeMethods.__gmpz_cmp_ui(op1.ToIntPtr(), op2); + } + + /// + /// Compare the absolute values of and . + /// + /// The first operand integer. + /// The second operand integer. + /// Return a positive value if || > ||, zero if || = ||, or a negative value if || < ||. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Comparisons + /// + /// + /// // Create, initialize, and set the value of op1 to -63. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_si(op1, -63); + /// + /// // Create, initialize, and set the value of op2 to 70. + /// mpz_t op2 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op2, 70U); + /// + /// // Assert that |op1| < |op2|. + /// Assert.IsTrue(gmp_lib.mpz_cmp(op1, op2) < 0); + /// + /// // Release unmanaged memory allocated for op1 and op2. + /// gmp_lib.mpz_clears(op1, op2, null); + /// + /// + /// ' Create, initialize, and set the value of op1 to -63. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_si(op1, -63) + /// + /// ' Create, initialize, and set the value of op2 to 70. + /// Dim op2 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op2, 70UI) + /// + /// ' Assert that |op1| < |op2|. + /// Assert.IsTrue(gmp_lib.mpz_cmp(op1, op2) < 0) + /// + /// ' Release unmanaged memory allocated for op1 and op2. + /// gmp_lib.mpz_clears(op1, op2, Nothing) + /// + /// + public static int mpz_cmpabs(/*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + return SafeNativeMethods.__gmpz_cmpabs(op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Compare the absolute values of and . + /// + /// The first operand integer. + /// The second operand integer. + /// Return a positive value if || > ||, zero if || = ||, or a negative value if || < ||. + /// + /// + /// can be called with an infinity (see or ), + /// but results are undefined for a . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Comparisons + /// + /// + /// // Create, initialize, and set the value of op1 to -63. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_si(op1, -63); + /// + /// // Assert that |op1| < |-70.0|. + /// Assert.IsTrue(gmp_lib.mpz_cmpabs_d(op1, -70.0) < 0); + /// + /// // Release unmanaged memory allocated for op1. + /// gmp_lib.mpz_clear(op1); + /// + /// + /// ' Create, initialize, and set the value of op1 to -63. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_si(op1, -63) + /// + /// ' Assert that |op1| < |-70.0|. + /// Assert.IsTrue(gmp_lib.mpz_cmpabs_d(op1, -70.0) < 0) + /// + /// ' Release unmanaged memory allocated for op1. + /// gmp_lib.mpz_clear(op1) + /// + /// + public static int mpz_cmpabs_d(/*const*/ mpz_t op1, double op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + return SafeNativeMethods.__gmpz_cmpabs_d(op1.ToIntPtr(), op2); + } + + /// + /// Compare the absolute values of and . + /// + /// The first operand integer. + /// The second operand integer. + /// Return a positive value if || > ||, zero if || = ||, or a negative value if || < ||. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Comparisons + /// + /// + /// // Create, initialize, and set the value of op1 to -63. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_si(op1, -63); + /// + /// // Assert that |op1| < |70|. + /// Assert.IsTrue(gmp_lib.mpz_cmpabs_ui(op1, 70U) < 0); + /// + /// // Release unmanaged memory allocated for op1. + /// gmp_lib.mpz_clear(op1); + /// + /// + /// + /// + public static int mpz_cmpabs_ui(/*const*/ mpz_t op1, uint /*unsigned long int*/ op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + return SafeNativeMethods.__gmpz_cmpabs_ui(op1.ToIntPtr(), op2); + } + + /// + /// Set to the one’s complement of . + /// + /// The result integer. + /// The operand integer. + /// + /// + /// The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + /// The least significant bit is number 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Logic and Bit Fiddling + /// + /// + /// // Create, initialize, and set the value of op to 63. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, 63U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop to the one's complement of op. + /// gmp_lib.mpz_com(rop, op); + /// + /// // Assert that rop is -64. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == -64); + /// + /// // Release unmanaged memory allocated for rop and op. + /// gmp_lib.mpz_clears(rop, op, null); + /// + /// + /// ' Create, initialize, and set the value of op to 63. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, 63UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop to the one's complement of op. + /// gmp_lib.mpz_com(rop, op) + /// + /// ' Assert that rop is -64. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = -64) + /// + /// ' Release unmanaged memory allocated for rop and op. + /// gmp_lib.mpz_clears(rop, op, Nothing) + /// + /// + public static void mpz_com(mpz_t rop, /*const*/ mpz_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpz_com(rop.ToIntPtr(), op.ToIntPtr()); + } + + + /// + /// Complement bit in . + /// + /// The result integer. + /// The index of the bit to comlpement. + /// + /// + /// The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + /// The least significant bit is number 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Logic and Bit Fiddling + /// + /// + /// // Create, initialize, and set the value of rop to 70. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init_set_si(rop, 70); + /// + /// // Complement bit 3 of rop. + /// gmp_lib.mpz_combit(rop, 3U); + /// + /// // Assert that rop is 78. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 78); + /// + /// // Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and set the value of rop to 70. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init_set_si(rop, 70) + /// + /// ' Complement bit 3 of rop. + /// gmp_lib.mpz_combit(rop, 3UI) + /// + /// ' Assert that rop is 78. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 78) + /// + /// ' Release unmanaged memory allocated for rop. + /// + /// + public static void mpz_combit(mpz_t rop, mp_bitcnt_t bit_index) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_combit(rop.ToIntPtr(), bit_index); + } + + /// + /// Return non-zero if is congruent to modulo . + /// + /// An operand integer. + /// The remainder of the division by . + /// The divisor operand integer. + /// Non-zero if is congruent to modulo . + /// + /// + /// is congruent to mod if there exists an integer q + /// satisfying = + q * . + /// Unlike the other division functions, = 0 is accepted and following the rule it can be seen + /// that and are considered congruent mod 0 only when exactly equal. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(n, 10000U); + /// + /// // Create, initialize, and set the value of d to 3. + /// mpz_t d = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(d, 3U); + /// + /// // Create, initialize, and set the value of c to 1. + /// mpz_t c = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(c, 1U); + /// + /// // Assert that n is congruent to c mod d. + /// Assert.IsTrue(gmp_lib.mpz_congruent_p(n, c, d) > 0); + /// + /// // Release unmanaged memory allocated for n, d, and c. + /// gmp_lib.mpz_clears(n, d, c, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_ui(n, 10000UI) + /// + /// ' Create, initialize, and set the value of d to 3. + /// Dim d As New mpz_t() + /// gmp_lib.mpz_init_set_ui(d, 3UI) + /// + /// ' Create, initialize, and set the value of c to 1. + /// Dim c As New mpz_t() + /// gmp_lib.mpz_init_set_ui(c, 1UI) + /// + /// ' Assert that n is congruent to c mod d. + /// Assert.IsTrue(gmp_lib.mpz_congruent_p(n, c, d) > 0) + /// + /// ' Release unmanaged memory allocated for n, d, and c. + /// gmp_lib.mpz_clears(n, d, c, Nothing) + /// + /// + public static int mpz_congruent_p(/*const*/ mpz_t n, /*const*/ mpz_t c, /*const*/ mpz_t d) + { + if (n == null) throw new ArgumentNullException("n"); + if (c == null) throw new ArgumentNullException("c"); + if (d == null) throw new ArgumentNullException("d"); + return SafeNativeMethods.__gmpz_congruent_p(n.ToIntPtr(), c.ToIntPtr(), d.ToIntPtr()); + } + + /// + /// Return non-zero if is congruent to modulo 2^. + /// + /// An operand integer. + /// The remainder of the division by 2^. + /// The exponent of the power of two divisor. + /// Non-zero if is congruent to modulo 2^. + /// + /// + /// is congruent to mod 2^ if there exists an integer q + /// satisfying = + q * 2^. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10001. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(n, 10001U); + /// + /// // Create, initialize, and set the value of b to 1. + /// mpz_t c = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(c, 1U); + /// + /// // Assert that n is congruent to c mod 2^3. + /// Assert.IsTrue(gmp_lib.mpz_congruent_2exp_p(n, c, 3U) > 0); + /// + /// // Release unmanaged memory allocated for n and c. + /// gmp_lib.mpz_clears(n, c, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10001. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_ui(n, 10001UI) + /// + /// ' Create, initialize, and set the value of b to 1. + /// Dim c As New mpz_t() + /// gmp_lib.mpz_init_set_ui(c, 1UI) + /// + /// ' Assert that n is congruent to c mod 2^3. + /// Assert.IsTrue(gmp_lib.mpz_congruent_2exp_p(n, c, 3UI) > 0) + /// + /// ' Release unmanaged memory allocated for n and c. + /// gmp_lib.mpz_clears(n, c, Nothing) + /// + /// + public static int mpz_congruent_2exp_p(/*const*/ mpz_t n, /*const*/ mpz_t c, mp_bitcnt_t b) + { + if (n == null) throw new ArgumentNullException("n"); + if (c == null) throw new ArgumentNullException("c"); + return SafeNativeMethods.__gmpz_congruent_2exp_p(n.ToIntPtr(), c.ToIntPtr(), b); + } + + /// + /// Return non-zero if is congruent to modulo . + /// + /// An operand integer. + /// The remainder of the division by . + /// The divisor operand integer. + /// Non-zero if is congruent to modulo . + /// + /// + /// is congruent to mod if there exists an integer q + /// satisfying = + q * . + /// Unlike the other division functions, = 0 is accepted and following the rule it can be seen + /// that and are considered congruent mod 0 only when exactly equal. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(n, 10000U); + /// + /// // Assert that n is congruent to 1 mod 3. + /// Assert.IsTrue(gmp_lib.mpz_congruent_ui_p(n, 1U, 3U) > 0); + /// + /// // Release unmanaged memory allocated for n. + /// gmp_lib.mpz_clear(n); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_ui(n, 10000UI) + /// + /// ' Assert that n is congruent to 1 mod 3. + /// Assert.IsTrue(gmp_lib.mpz_congruent_ui_p(n, 1UI, 3UI) > 0) + /// + /// ' Release unmanaged memory allocated for n. + /// gmp_lib.mpz_clear(n) + /// + /// + public static int mpz_congruent_ui_p(/*const*/ mpz_t n, uint /*unsigned long int*/ c, uint /*unsigned long int*/ d) + { + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_congruent_ui_p(n.ToIntPtr(), c, d); + } + + /// + /// Set to / when it is known in advance that divides . + /// + /// The result quotient integer. + /// The numerator integer. + /// The denominator integer. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10000U); + /// + /// // Create, initialize, and set the value of y to 5. + /// mpz_t y = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(y, 5U); + /// + /// // Create, initialize, and set the value of z to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = x / y. + /// gmp_lib.mpz_divexact(z, x, y); + /// + /// // Assert that z is 2000. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == 2000); + /// + /// // Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpz_clears(x, y, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10000UI) + /// + /// ' Create, initialize, and set the value of y to 5. + /// Dim y As New mpz_t() + /// gmp_lib.mpz_init_set_ui(y, 5UI) + /// + /// ' Create, initialize, and set the value of z to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = x / y. + /// gmp_lib.mpz_divexact(z, x, y) + /// + /// ' Assert that z is 2000. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = 2000) + /// + /// ' Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpz_clears(x, y, z, Nothing) + /// + /// + public static void mpz_divexact(mpz_t q, /*const*/ mpz_t n, /*const*/ mpz_t d) + { + if (q == null) throw new ArgumentNullException("q"); + if (n == null) throw new ArgumentNullException("n"); + if (d == null) throw new ArgumentNullException("d"); + SafeNativeMethods.__gmpz_divexact(q.ToIntPtr(), n.ToIntPtr(), d.ToIntPtr()); + } + + /// + /// Set to / when it is known in advance that divides . + /// + /// The result quotient integer. + /// The numerator integer. + /// The denominator integer. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10000U); + /// + /// // Create, initialize, and set the value of z to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = x / 5. + /// gmp_lib.mpz_divexact_ui(z, x, 5U); + /// + /// // Assert that z is 2000. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == 2000); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10000UI) + /// + /// ' Create, initialize, and set the value of z to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = x / 5. + /// gmp_lib.mpz_divexact_ui(z, x, 5UI) + /// + /// ' Assert that z is 2000. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = 2000) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, Nothing) + /// + /// + public static void mpz_divexact_ui(mpz_t q, /*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (q == null) throw new ArgumentNullException("q"); + if (n == null) throw new ArgumentNullException("n"); + SafeNativeMethods.__gmpz_divexact_ui(q.ToIntPtr(), n.ToIntPtr(), d); + } + + /// + /// Return non-zero if is exactly divisible by . + /// + /// The numerator integer. + /// The denominator integer. + /// Non-zero if is exactly divisible by . + /// + /// + /// is divisible by if there exists an integer q + /// satisfying = q * . Unlike the other division functions, + /// = 0 is accepted and following the rule it can be seen that only 0 is + /// considered divisible by 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10000U); + /// + /// // Create, initialize, and set the value of y to 5. + /// mpz_t y = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(y, 5U); + /// + /// // Assert that x is divisible by y. + /// Assert.IsTrue(gmp_lib.mpz_divisible_p(x, y) > 0); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpz_clears(x, y, null); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10000UI) + /// + /// ' Create, initialize, and set the value of y to 5. + /// Dim y As New mpz_t() + /// gmp_lib.mpz_init_set_ui(y, 5UI) + /// + /// ' Assert that x is divisible by y. + /// Assert.IsTrue(gmp_lib.mpz_divisible_p(x, y) > 0) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpz_clears(x, y, Nothing) + /// + /// + public static int mpz_divisible_p(/*const*/ mpz_t n, /*const*/ mpz_t d) + { + if (n == null) throw new ArgumentNullException("n"); + if (d == null) throw new ArgumentNullException("d"); + return SafeNativeMethods.__gmpz_divisible_p(n.ToIntPtr(), d.ToIntPtr()); + } + + /// + /// Return non-zero if is exactly divisible by . + /// + /// The numerator integer. + /// The denominator integer. + /// Non-zero if is exactly divisible by . + /// + /// + /// is divisible by if there exists an integer q + /// satisfying = q * . Unlike the other division functions, + /// = 0 is accepted and following the rule it can be seen that only 0 is + /// considered divisible by 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10000U); + /// + /// // Assert that x is divisible by 5. + /// Assert.IsTrue(gmp_lib.mpz_divisible_ui_p(x, 5U) > 0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10000UI) + /// + /// ' Assert that x is divisible by 5. + /// Assert.IsTrue(gmp_lib.mpz_divisible_ui_p(x, 5UI) > 0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static int mpz_divisible_ui_p(/*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_divisible_ui_p(n.ToIntPtr(), d); + } + + /// + /// Return non-zero if is exactly divisible by 2^. + /// + /// The numerator integer. + /// The exponent of the power of two denominator integer. + /// Non-zero if is exactly divisible by 2^. + /// + /// + /// is divisible by 2^ if there exists an integer q + /// satisfying = q * 2^. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10000U); + /// + /// Assert.IsTrue(gmp_lib.mpz_divisible_2exp_p(x, 2U) > 0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10000UI) + /// + /// Assert.IsTrue(gmp_lib.mpz_divisible_2exp_p(x, 2UI) > 0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static int mpz_divisible_2exp_p(/*const*/ mpz_t n, mp_bitcnt_t b) + { + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_divisible_2exp_p(n.ToIntPtr(), b); + } + + /// + /// Determine whether is even. + /// + /// The operand integer. + /// Return non-zero if even, zero if odd. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Integer Functions + /// + /// + /// // Create, initialize, and set the value of op to 427295. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, 427295); + /// + /// // Assert that op is not even but odd. + /// Assert.IsTrue(gmp_lib.mpz_even_p(op) == 0); + /// Assert.IsTrue(gmp_lib.mpz_odd_p(op) > 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to 427295. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, 427295) + /// + /// ' Assert that op is not even but odd. + /// Assert.IsTrue(gmp_lib.mpz_even_p(op) = 0) + /// Assert.IsTrue(gmp_lib.mpz_odd_p(op) > 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static int mpz_even_p(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return op._mp_size != 0 && (op._mp_d[0] & 1) == 0 ? 1 : 0; + } + + /// + /// Fill with word data from . + /// + /// The result integer. + /// The number of words produced. + /// 1 for most significant word first or -1 for least significant first. + /// The number of bytes in each word. + /// 1 for most significant byte first, -1 for least significant first, or 0 for the native endianness of the host CPU. + /// The number of most significant bits to skip. + /// The operand integer. + /// Either or the allocated block. + /// + /// + /// The parameters specify the format of the data produced. + /// Each word will be bytes and can be 1 for most significant word first + /// or -1 for least significant first. + /// Within each word can be 1 for most significant byte first, + /// -1 for least significant first, or 0 for the native endianness of the host CPU. + /// The most significant bits of each word are unused and set to zero, + /// this can be 0 to produce full words. + /// + /// + /// The number of words produced is written to , or can be NULL to discard the count. + /// must have enough space for the data, or if is NULL then a result array of the necessary + /// size is allocated using the current GMP allocation function + /// (see GNU MP - Custom Allocation). + /// In either case the return value is the destination used, either or the allocated block. + /// + /// + /// If is non-zero then the most significant word produced will be non-zero. + /// If is zero then the count returned will be zero and nothing written to . + /// If is NULL in this case, no block is allocated, just NULL is returned. + /// + /// + /// The sign of is ignored, just the absolute value is exported. + /// An application can use to get the sign and handle it as desired. + /// (see GNU MP - Integer Comparisons) + /// + /// + /// There are no data alignment restrictions on , any address is allowed. + /// + /// + /// When an application is allocating space itself the required size can be determined with a calculation like the following. + /// Since always returns at least 1, count here will be at least one, which avoids any portability + /// problems with malloc(0), though if z is zero no space at all is actually needed (or written). + /// + /// + /// numb = 8 * size - nail; + /// count = (mpz_sizeinbase(z, 2) + numb - 1) / numb; + /// p = malloc(count * size); + /// + /// + /// + /// GNU MP - Integer Import and Export + /// + /// + /// // Create, initialize, and set the value of op to 0x800000000000000000000001. + /// mpz_t op = new mpz_t(); + /// char_ptr value = new char_ptr("800000000000000000000001"); + /// gmp_lib.mpz_init_set_str(op, value, 16); + /// + /// // Export op as 3 words of 4 bytes each, first word is lsb, and first byte in each word is msb. + /// void_ptr data = gmp_lib.allocate(12); + /// size_t countp = 0; + /// gmp_lib.mpz_export(data, ref countp, -1, 4, 1, 0, op); + /// + /// // Assert the result. + /// byte[] result = new byte[12]; + /// Marshal.Copy(data.ToIntPtr(), result, 0, 12); + /// Assert.IsTrue(result[0] == 0x00); + /// Assert.IsTrue(result[1] == 0x00); + /// Assert.IsTrue(result[2] == 0x00); + /// Assert.IsTrue(result[3] == 0x01); + /// Assert.IsTrue(result[4] == 0x00); + /// Assert.IsTrue(result[5] == 0x00); + /// Assert.IsTrue(result[6] == 0x00); + /// Assert.IsTrue(result[7] == 0x00); + /// Assert.IsTrue(result[8] == 0x80); + /// Assert.IsTrue(result[9] == 0x00); + /// Assert.IsTrue(result[10] == 0x00); + /// Assert.IsTrue(result[11] == 0x00); + /// + /// // Release unmanaged memory allocated for rop, data, and value. + /// gmp_lib.mpz_clear(op); + /// gmp_lib.free(data); + /// gmp_lib.free(value); + /// + /// + /// ' Create, initialize, and set the value of op to 0x800000000000000000000001. + /// Dim op As New mpz_t() + /// Dim value As New char_ptr("800000000000000000000001") + /// gmp_lib.mpz_init_set_str(op, value, 16) + /// + /// ' Export op as 3 words of 4 bytes each, first word is lsb, and first byte in each word is msb. + /// Dim data As void_ptr = gmp_lib.allocate(12) + /// Dim countp As size_t = 0 + /// gmp_lib.mpz_export(data, countp, -1, 4, 1, 0, op) + /// + /// ' Assert the result. + /// Dim result As Byte() = New Byte(11) { } + /// Marshal.Copy(data.ToIntPtr(), result, 0, 12) + /// Assert.IsTrue(result(0) = &H0) + /// Assert.IsTrue(result(1) = &H0) + /// Assert.IsTrue(result(2) = &H0) + /// Assert.IsTrue(result(3) = &H1) + /// Assert.IsTrue(result(4) = &H0) + /// Assert.IsTrue(result(5) = &H0) + /// Assert.IsTrue(result(6) = &H0) + /// Assert.IsTrue(result(7) = &H0) + /// Assert.IsTrue(result(8) = &H80) + /// Assert.IsTrue(result(9) = &H0) + /// Assert.IsTrue(result(10) = &H0) + /// Assert.IsTrue(result(11) = &H0) + /// + /// ' Release unmanaged memory allocated for rop, data, and value. + /// gmp_lib.mpz_clear(op) + /// gmp_lib.free(data) + /// gmp_lib.free(value) + /// + /// + public static void_ptr mpz_export(void_ptr rop, ref size_t countp, int order, size_t size, int endian, size_t nails, /*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + if (IntPtr.Size == 4) + { + uint temp = (uint)countp; + IntPtr result = SafeNativeMethods.__gmpz_export_x86(rop.ToIntPtr(), ref temp, order, (uint)size, endian, (uint)nails, op.ToIntPtr()); + countp = temp; + return new void_ptr(result); + } + else + { + ulong temp = countp; + IntPtr result = SafeNativeMethods.__gmpz_export_x64(rop.ToIntPtr(), ref temp, order, size, endian, nails, op.ToIntPtr()); + countp = temp; + return new void_ptr(result); + } + } + + /// + /// Set to the factorial !. + /// + /// The result integer. + /// The operand integer. + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop = 3!. + /// gmp_lib.mpz_fac_ui(rop, 3U); + /// + /// // Assert that rop is 6. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6); + /// + /// // Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop = 3!. + /// gmp_lib.mpz_fac_ui(rop, 3UI) + /// + /// ' Assert that rop is 6. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 6) + /// + /// ' Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop) + /// + /// + public static void mpz_fac_ui(mpz_t rop, uint /*unsigned long int*/ n) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_fac_ui(rop.ToIntPtr(), n); + } + + /// + /// Set to the double-factorial !!. + /// + /// The result integer. + /// The operand integer. + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop = 9!!. + /// gmp_lib.mpz_2fac_ui(rop, 9U); + /// + /// // Assert that rop is 945. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 945); + /// + /// // Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop = 9!!. + /// gmp_lib.mpz_2fac_ui(rop, 9UI) + /// + /// ' Assert that rop is 945. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 945) + /// + /// ' Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop) + /// + /// + public static void mpz_2fac_ui(mpz_t rop, uint /*unsigned long int*/ n) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_2fac_ui(rop.ToIntPtr(), n); + } + + /// + /// Set to the m-multi-factorial !^()n. + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop = 10!^(4). + /// gmp_lib.mpz_mfac_uiui(rop, 10U, 4U); + /// + /// // Assert that rop is 945. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 120); + /// + /// // Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop = 10!^(4). + /// gmp_lib.mpz_mfac_uiui(rop, 10UI, 4UI) + /// + /// ' Assert that rop is 945. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 120) + /// + /// ' Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop) + /// + /// + public static void mpz_mfac_uiui(mpz_t rop, uint /*unsigned long int*/ n, uint /*unsigned long int*/ m) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_mfac_uiui(rop.ToIntPtr(), n, m); + } + + /// + /// Set to the primorial of , i.e. the product of all positive prime numbers . + /// + /// The result integer. + /// The operand integer. + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop = 7 * 5 * 3 * 2 = 210. + /// gmp_lib.mpz_primorial_ui(rop, 9U); + /// + /// // Assert that rop is 210. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 210); + /// + /// // Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop = 7 * 5 * 3 * 2 = 210. + /// gmp_lib.mpz_primorial_ui(rop, 9UI) + /// + /// ' Assert that rop is 210. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 210) + /// + /// ' Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop) + /// + /// + public static void mpz_primorial_ui(mpz_t rop, uint /*unsigned long int*/ n) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_primorial_ui(rop.ToIntPtr(), n); + } + + /// + /// Set the quotient to floor( / ). + /// + /// The result quotient integer. + /// The numerator integer. + /// The denominator integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of d to 3. + /// mpz_t d = new mpz_t(); + /// gmp_lib.mpz_init_set_si(d, 3); + /// + /// // Create, initialize, and set the value of q to 0. + /// mpz_t q = new mpz_t(); + /// gmp_lib.mpz_init(q); + /// + /// // Set q = floor(n / d). + /// gmp_lib.mpz_fdiv_q(q, n, d); + /// + /// // Assert that q is floor(10000 / 3). + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + /// + /// // Release unmanaged memory allocated for n, d, and q. + /// gmp_lib.mpz_clears(n, d, q, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of d to 3. + /// Dim d As New mpz_t() + /// gmp_lib.mpz_init_set_si(d, 3) + /// + /// ' Create, initialize, and set the value of q to 0. + /// Dim q As New mpz_t() + /// gmp_lib.mpz_init(q) + /// + /// ' Set q = floor(n / d). + /// gmp_lib.mpz_fdiv_q(q, n, d) + /// + /// ' Assert that q is floor(10000 / 3). + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333) + /// + /// ' Release unmanaged memory allocated for n, d, and q. + /// gmp_lib.mpz_clears(n, d, q, Nothing) + /// + /// + public static void mpz_fdiv_q(mpz_t q, /*const*/ mpz_t n, /*const*/ mpz_t d) + { + if (q == null) throw new ArgumentNullException("q"); + if (n == null) throw new ArgumentNullException("n"); + if (d == null) throw new ArgumentNullException("d"); + SafeNativeMethods.__gmpz_fdiv_q(q.ToIntPtr(), n.ToIntPtr(), d.ToIntPtr()); + } + + /// + /// Set the quotient to floor( / 2^). + /// + /// The result quotient integer. + /// The numerator integer. + /// The exponent of the power of two denominator. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10001. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10001); + /// + /// // Create, initialize, and set the value of q to 0. + /// mpz_t q = new mpz_t(); + /// gmp_lib.mpz_init(q); + /// + /// // Set q = floor(n / 2^2). + /// gmp_lib.mpz_fdiv_q_2exp(q, n, 2U); + /// + /// // Assert that q is floor(10001 / 4). + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 2500); + /// + /// // Release unmanaged memory allocated for n and q. + /// gmp_lib.mpz_clears(n, q, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10001. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10001) + /// + /// ' Create, initialize, and set the value of q to 0. + /// Dim q As New mpz_t() + /// gmp_lib.mpz_init(q) + /// + /// ' Set q = floor(n / 2^2). + /// gmp_lib.mpz_fdiv_q_2exp(q, n, 2UI) + /// + /// ' Assert that q is floor(10001 / 4). + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 2500) + /// + /// ' Release unmanaged memory allocated for n and q. + /// gmp_lib.mpz_clears(n, q, Nothing) + /// + /// + public static void mpz_fdiv_q_2exp(mpz_t q, /*const*/ mpz_t n, mp_bitcnt_t b) + { + if (q == null) throw new ArgumentNullException("q"); + if (n == null) throw new ArgumentNullException("n"); + SafeNativeMethods.__gmpz_fdiv_q_2exp(q.ToIntPtr(), n.ToIntPtr(), b); + } + + /// + /// Set the quotient to floor( / ), and return the remainder r = | - * |. + /// + /// The result quotient integer. + /// The numerator integer. + /// The denominator integer. + /// Return the remainder r = | - * |. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of q to 0. + /// mpz_t q = new mpz_t(); + /// gmp_lib.mpz_init(q); + /// + /// // Set q = floor(n / 3) and return r = n - 3 * q. + /// // Assert q and r values. + /// Assert.IsTrue(gmp_lib.mpz_fdiv_q_ui(q, n, 3U) == 1U); + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + /// + /// // Release unmanaged memory allocated for n and q. + /// gmp_lib.mpz_clears(n, q, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of q to 0. + /// Dim q As New mpz_t() + /// gmp_lib.mpz_init(q) + /// + /// ' Set q = floor(n / 3) and return r = n - 3 * q. + /// ' Assert q and r values. + /// Assert.IsTrue(gmp_lib.mpz_fdiv_q_ui(q, n, 3UI) = 1UI) + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333) + /// + /// ' Release unmanaged memory allocated for n and q. + /// gmp_lib.mpz_clears(n, q, Nothing) + /// + /// + public static long mpz_fdiv_q_ui(mpz_t q, /*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (q == null) throw new ArgumentNullException("q"); + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_fdiv_q_ui(q.ToIntPtr(), n.ToIntPtr(), d); + } + + /// + /// Set the quotient to floor( / ), and set the remainder to - * . + /// + /// The result quotient integer. + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of d to 3. + /// mpz_t d = new mpz_t(); + /// gmp_lib.mpz_init_set_si(d, 3); + /// + /// // Create, initialize, and set the values of q and r to 0. + /// mpz_t q = new mpz_t(); + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_inits(q, r, null); + /// + /// // Set q = floor(n / 3) and r = n - d * q. + /// gmp_lib.mpz_fdiv_qr(q, r, n, d); + /// + /// // Assert that q is 3333, and that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + /// + /// // Release unmanaged memory allocated for n, d, q, and r. + /// gmp_lib.mpz_clears(n, d, q, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of d to 3. + /// Dim d As New mpz_t() + /// gmp_lib.mpz_init_set_si(d, 3) + /// + /// ' Create, initialize, and set the values of q and r to 0. + /// Dim q As New mpz_t() + /// Dim r As New mpz_t() + /// gmp_lib.mpz_inits(q, r, Nothing) + /// + /// ' Set q = floor(n / 3) and r = n - d * q. + /// gmp_lib.mpz_fdiv_qr(q, r, n, d) + /// /// + /// ' Assert that q is 3333, and that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333) + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1) + /// + /// ' Release unmanaged memory allocated for n, d, q, and r. + /// gmp_lib.mpz_clears(n, d, q, r, Nothing) + /// + /// + public static void mpz_fdiv_qr(mpz_t q, mpz_t r, /*const*/ mpz_t n, /*const*/ mpz_t d) + { + if (q == null) throw new ArgumentNullException("q"); + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + if (d == null) throw new ArgumentNullException("d"); + SafeNativeMethods.__gmpz_fdiv_qr(q.ToIntPtr(), r.ToIntPtr(), n.ToIntPtr(), d.ToIntPtr()); + } + + /// + /// Set quotient to floor( / ), set the remainder to - * , and return ||. + /// + /// The result quotient integer. + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// Return ||. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the values of q and r to 0. + /// mpz_t q = new mpz_t(); + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_inits(q, r, null); + /// + /// // Set q = floor(n / 3), r = n - d * q, and return r. + /// Assert.IsTrue(gmp_lib.mpz_fdiv_qr_ui(q, r, n, 3U) == 1U); + /// + /// // Assert that q is 3333, and that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + /// + /// // Release unmanaged memory allocated for n, q, and r. + /// gmp_lib.mpz_clears(n, q, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the values of q and r to 0. + /// Dim q As New mpz_t() + /// Dim r As New mpz_t() + /// gmp_lib.mpz_inits(q, r, Nothing) + /// + /// ' Set q = floor(n / 3), r = n - d * q, and return r. + /// Assert.IsTrue(gmp_lib.mpz_fdiv_qr_ui(q, r, n, 3UI) = 1UI) + /// + /// ' Assert that q is 3333, and that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333) + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1) + /// + /// ' Release unmanaged memory allocated for n, q, and r. + /// gmp_lib.mpz_clears(n, q, r, Nothing) + /// + /// + public static uint /*unsigned long int*/ mpz_fdiv_qr_ui(mpz_t q, mpz_t r, /*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (q == null) throw new ArgumentNullException("q"); + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_fdiv_qr_ui(q.ToIntPtr(), r.ToIntPtr(), n.ToIntPtr(), d); + } + + /// + /// Set the remainder to - q * where q = floor( / ). + /// + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of d to 3. + /// mpz_t d = new mpz_t(); + /// gmp_lib.mpz_init_set_si(d, 3); + /// + /// // Create, initialize, and set the value of r to 0. + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_init(r); + /// + /// // Set r = n - d * floor(n / d). + /// gmp_lib.mpz_fdiv_r(r, n, d); + /// + /// // Assert that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + /// + /// // Release unmanaged memory allocated for n, d, and r. + /// gmp_lib.mpz_clears(n, d, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of d to 3. + /// Dim d As New mpz_t() + /// gmp_lib.mpz_init_set_si(d, 3) + /// + /// ' Create, initialize, and set the value of r to 0. + /// Dim r As New mpz_t() + /// gmp_lib.mpz_init(r) + /// + /// ' Set r = n - d * floor(n / d). + /// gmp_lib.mpz_fdiv_r(r, n, d) + /// ' Assert that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1) + /// + /// ' Release unmanaged memory allocated for n, d, and r. + /// gmp_lib.mpz_clears(n, d, r, Nothing) + /// + /// + public static void mpz_fdiv_r(mpz_t r, /*const*/ mpz_t n, /*const*/ mpz_t d) + { + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + if (d == null) throw new ArgumentNullException("d"); + SafeNativeMethods.__gmpz_fdiv_r(r.ToIntPtr(), n.ToIntPtr(), d.ToIntPtr()); + } + + /// + /// Set the remainder to - q * 2^ where q = floor( / 2^). + /// + /// The result remainder integer. + /// The numerator integer. + /// The exponent of the power of two denominator. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10001. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10001); + /// + /// // Create, initialize, and set the value of r to 0. + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_init(r); + /// + /// // Set r = n - 2^2 * floor(n / 2^2) + /// gmp_lib.mpz_fdiv_r_2exp(r, n, 2U); + /// + /// // Assert that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + /// + /// // Release unmanaged memory allocated for n and r. + /// gmp_lib.mpz_clears(n, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10001. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10001) + /// + /// ' Create, initialize, and set the value of r to 0. + /// Dim r As New mpz_t() + /// gmp_lib.mpz_init(r) + /// + /// ' Set r = n - 2^2 * floor(n / 2^2) + /// gmp_lib.mpz_fdiv_r_2exp(r, n, 2UI) + /// + /// ' Assert that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1) + /// + /// ' Release unmanaged memory allocated for n and r. + /// gmp_lib.mpz_clears(n, r, Nothing) + /// + /// + public static void mpz_fdiv_r_2exp(mpz_t r, /*const*/ mpz_t n, mp_bitcnt_t b) + { + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + SafeNativeMethods.__gmpz_fdiv_r_2exp(r.ToIntPtr(), n.ToIntPtr(), b); + } + + /// + /// Set the remainder to - q * where q = floor( / ), and return ||. + /// + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// Return ||. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of r to 0. + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_init(r); + /// + /// // Set r = n - 3 * floor(n / 3), and return |r|. + /// Assert.IsTrue(gmp_lib.mpz_fdiv_r_ui(r, n, 3U) == 1U); + /// + /// // Assert that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + /// + /// // Release unmanaged memory allocated for n and r. + /// gmp_lib.mpz_clears(n, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of r to 0. + /// Dim r As New mpz_t() + /// gmp_lib.mpz_init(r) + /// + /// ' Set r = n - 3 * floor(n / 3), and return |r|. + /// Set r = n - 3 * floor(n / 3), and return |r|. + /// Assert.IsTrue(gmp_lib.mpz_fdiv_r_ui(r, n, 3UI) = 1UI) + /// + /// ' Assert that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1) + /// + /// ' Release unmanaged memory allocated for n and r. + /// gmp_lib.mpz_clears(n, r, Nothing) + /// + /// + public static long mpz_fdiv_r_ui(mpz_t r, /*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_fdiv_r_ui(r.ToIntPtr(), n.ToIntPtr(), d); + } + + /// + /// Return the remainder |r| where r = - q * , and where q = floor( / ). + /// + /// The numerator integer. + /// The denominator integer. + /// The remainder |r| where r = - q * , and where q = floor( / ). + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Assert that returned value is |n - 3 * floor(n / 3)|. + /// Assert.IsTrue(gmp_lib.mpz_fdiv_ui(n, 3U) == 1U); + /// + /// // Release unmanaged memory allocated for n. + /// gmp_lib.mpz_clear(n); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Assert that returned value is |n - 3 * floor(n / 3)|. + /// Assert.IsTrue(gmp_lib.mpz_fdiv_ui(n, 3UI) = 1UI) + /// + /// ' Release unmanaged memory allocated for n. + /// gmp_lib.mpz_clear(n) + /// + /// + public static long mpz_fdiv_ui(/*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_fdiv_ui(n.ToIntPtr(), d); + } + + /// + /// Sets to to F[], the ’th Fibonacci number. + /// + /// The F[] result. + /// The operand integer. + /// + /// + /// The Fibonacci numbers and Lucas numbers are related sequences, so it’s never necessary to call both + /// and . + /// The formulas for going from Fibonacci to Lucas can be found in + /// GNU MP - Lucas Numbers Algorithm, + /// the reverse is straightforward too. + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of fn to 0. + /// mpz_t fn = new mpz_t(); + /// gmp_lib.mpz_init(fn); + /// + /// // Set fn to the n'th Fibonacci number. + /// gmp_lib.mpz_fib_ui(fn, 20U); + /// + /// // Assert that fn is 6765. + /// Assert.IsTrue(gmp_lib.mpz_get_si(fn) == 6765); + /// + /// // Release unmanaged memory allocated for fn. + /// gmp_lib.mpz_clear(fn); + /// + /// + /// ' Create, initialize, and set the value of fn to 0. + /// Dim fn As New mpz_t() + /// gmp_lib.mpz_init(fn) + /// + /// ' Set fn to the n'th Fibonacci number. + /// gmp_lib.mpz_fib_ui(fn, 20UI) + /// + /// ' Assert that fn is 6765. + /// Assert.IsTrue(gmp_lib.mpz_get_si(fn) = 6765) + /// + /// ' Release unmanaged memory allocated for fn. + /// gmp_lib.mpz_clear(fn) + /// + /// + public static void mpz_fib_ui(mpz_t fn, uint /*unsigned long int*/ n) + { + if (fn == null) throw new ArgumentNullException("fn"); + SafeNativeMethods.__gmpz_fib_ui(fn.ToIntPtr(), n); + } + + /// + /// Sets to F[], and to F[ - 1]. + /// + /// The F[] result. + /// The F[ - 1] result. + /// The operand integer. + /// + /// + /// This function is designed for calculating isolated Fibonacci numbers. + /// When a sequence of values is wanted it’s best to start with + /// and iterate the defining F[n + 1] = F[n] + F[n - 1] or similar. + /// + /// + /// The Fibonacci numbers and Lucas numbers are related sequences, so it’s never necessary to call both + /// and . + /// The formulas for going from Fibonacci to Lucas can be found in + /// GNU MP - Lucas Numbers Algorithm, + /// the reverse is straightforward too. + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the values of fn and fnsub1 to 0. + /// mpz_t fn = new mpz_t(); + /// mpz_t fnsub1 = new mpz_t(); + /// gmp_lib.mpz_inits(fn, fnsub1, null); + /// + /// // Set fnsub1 and fn to the 19'th and 20'th Fibonacci numbers respectively. + /// gmp_lib.mpz_fib2_ui(fn, fnsub1, 20U); + /// + /// // Assert that fnsub1 and fn are respectively 4181 and 6765. + /// Assert.IsTrue(gmp_lib.mpz_get_si(fnsub1) == 4181); + /// Assert.IsTrue(gmp_lib.mpz_get_si(fn) == 6765); + /// + /// // Release unmanaged memory allocated for fn and fnsub1. + /// gmp_lib.mpz_clears(fn, fnsub1, null); + /// + /// + /// ' Create, initialize, and set the values of fn and fnsub1 to 0. + /// Dim fn As New mpz_t() + /// Dim fnsub1 As New mpz_t() + /// gmp_lib.mpz_inits(fn, fnsub1, Nothing) + /// + /// ' Set fnsub1 and fn to the 19'th and 20'th Fibonacci numbers respectively. + /// gmp_lib.mpz_fib2_ui(fn, fnsub1, 20UI) + /// + /// ' Assert that fnsub1 and fn are respectively 4181 and 6765. + /// Assert.IsTrue(gmp_lib.mpz_get_si(fnsub1) = 4181) + /// Assert.IsTrue(gmp_lib.mpz_get_si(fn) = 6765) + /// + /// ' Release unmanaged memory allocated for fn and fnsub1. + /// gmp_lib.mpz_clears(fn, fnsub1, Nothing) + /// + /// + public static void mpz_fib2_ui(mpz_t fn, mpz_t fnsub1, uint /*unsigned long int*/ n) + { + if (fn == null) throw new ArgumentNullException("fn"); + if (fnsub1 == null) throw new ArgumentNullException("fnsub1"); + SafeNativeMethods.__gmpz_fib2_ui(fn.ToIntPtr(), fnsub1.ToIntPtr(), n); + } + + /// + /// Return non-zero iff the value of fits in a signed 32-bit integer. Otherwise, return zero. + /// + /// The operand integer. + /// Return non-zero iff the value of fits in a signed 32-bit integer. Otherwise, return zero. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Integer Functions + /// + /// + /// // Create, initialize, and set the value of op 4294967295. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, uint.MaxValue); + /// + /// // Assert that op does not fit in int. + /// Assert.IsTrue(gmp_lib.mpz_fits_sint_p(op) == 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op 4294967295. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, UInteger.MaxValue) + /// + /// ' Assert that op does not fit in int. + /// Assert.IsTrue(gmp_lib.mpz_fits_sint_p(op) = 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static int mpz_fits_sint_p(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_fits_sint_p(op.ToIntPtr()); + } + + /// + /// Return non-zero iff the value of fits in a signed 32-bit integer. Otherwise, return zero. + /// + /// The operand integer. + /// Return non-zero iff the value of fits in a signed 32-bit integer. Otherwise, return zero. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Integer Functions + /// + /// + /// // Create, initialize, and set the value of op 4294967295. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, uint.MaxValue); + /// + /// // Assert that op does not fit in long. + /// Assert.IsTrue(gmp_lib.mpz_fits_slong_p(op) == 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op 4294967295. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, UInteger.MaxValue) + /// + /// ' Assert that op does not fit in long. + /// Assert.IsTrue(gmp_lib.mpz_fits_slong_p(op) = 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static int mpz_fits_slong_p(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_fits_slong_p(op.ToIntPtr()); + } + + /// + /// Return non-zero iff the value of fits in a signed 16-bit integer. Otherwise, return zero. + /// + /// The operand integer. + /// Return non-zero iff the value of fits in a signed 16-bit integer. Otherwise, return zero. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Integer Functions + /// + /// + /// // Create, initialize, and set the value of op 4294967295. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, uint.MaxValue); + /// + /// // Assert that op does not fit in short. + /// Assert.IsTrue(gmp_lib.mpz_fits_sshort_p(op) == 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op 4294967295. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, UInteger.MaxValue) + /// + /// ' Assert that op does not fit in short. + /// Assert.IsTrue(gmp_lib.mpz_fits_sshort_p(op) = 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static int mpz_fits_sshort_p(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_fits_sshort_p(op.ToIntPtr()); + } + + /// + /// Return non-zero iff the value of fits in an unsigned 32-bit integer. Otherwise, return zero. + /// + /// The operand integer. + /// Return non-zero iff the value of fits in an unsigned 32-bit integer. Otherwise, return zero. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Integer Functions + /// + /// + /// // Create, initialize, and set the value of op 4294967295. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, uint.MaxValue); + /// + /// // Assert that op does not fit in uint. + /// Assert.IsTrue(gmp_lib.mpz_fits_uint_p(op) > 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op 4294967295. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, UInteger.MaxValue) + /// + /// ' Assert that op does not fit in uint. + /// Assert.IsTrue(gmp_lib.mpz_fits_uint_p(op) > 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static int mpz_fits_uint_p(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_fits_uint_p(op.ToIntPtr()); + } + + /// + /// Return non-zero iff the value of fits in an unsigned 32-bit integer. Otherwise, return zero. + /// + /// The operand integer. + /// Return non-zero iff the value of fits in a signed 32-bit integer. Otherwise, return zero. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Integer Functions + /// + /// + /// // Create, initialize, and set the value of op 4294967295. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, uint.MaxValue); + /// + /// // Assert that op fits in ulong. + /// Assert.IsTrue(gmp_lib.mpz_fits_ulong_p(op) > 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op 4294967295. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, UInteger.MaxValue) + /// + /// ' Assert that op fits in ulong. + /// Assert.IsTrue(gmp_lib.mpz_fits_ulong_p(op) > 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static int mpz_fits_ulong_p(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_fits_ulong_p(op.ToIntPtr()); + } + + /// + /// Return non-zero iff the value of fits in an unsigned 16-bit integer. Otherwise, return zero. + /// + /// The operand integer. + /// Return non-zero iff the value of fits in an unsigned 16-bit integer. Otherwise, return zero. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Integer Functions + /// + /// + /// // Create, initialize, and set the value of op 4294967295. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, uint.MaxValue); + /// + /// // Assert that op does not fit in ushort. + /// Assert.IsTrue(gmp_lib.mpz_fits_ushort_p(op) == 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op 4294967295. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, UInteger.MaxValue) + /// + /// ' Assert that op does not fit in ushort. + /// Assert.IsTrue(gmp_lib.mpz_fits_ushort_p(op) = 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static int mpz_fits_ushort_p(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_fits_ushort_p(op.ToIntPtr()); + } + + /// + /// Set to the greatest common divisor of and . + /// + /// The result operand integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// The result is always positive even if one or both input operands are negative. + /// Except if both inputs are zero; then this function defines gcd(0,0) = 0. + /// + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of op1 to 63. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op1, 63U); + /// + /// // Create, initialize, and set the value of op2 to 70. + /// mpz_t op2 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op2, 70U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop to the greatest common divisor of op1 and op2. + /// gmp_lib.mpz_gcd(rop, op1, op2); + /// + /// // Assert that rop is 7. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 7); + /// + /// // Release unmanaged memory allocated for rop, op1, and op2. + /// gmp_lib.mpz_clears(rop, op1, op2, null); + /// + /// + /// ' Create, initialize, and set the value of op1 to 63. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op1, 63UI) + /// + /// ' Create, initialize, and set the value of op2 to 70. + /// Dim op2 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op2, 70UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop to the greatest common divisor of op1 and op2. + /// gmp_lib.mpz_gcd(rop, op1, op2) + /// + /// ' Assert that rop is 7. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 7) + /// + /// ' Release unmanaged memory allocated for rop, op1, and op2. + /// gmp_lib.mpz_clears(rop, op1, op2, Nothing) + /// + /// + public static void mpz_gcd(mpz_t rop, /*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpz_gcd(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Compute the greatest common divisor of and . If is not null, store the result there. + /// + /// The result operand integer. + /// The first operand integer. + /// The second operand integer. + /// If the result is small enough to fit in an unsigned int, it is returned. If the result does not fit, 0 is returned, and the result is equal to the argument . + /// + /// + /// Note that the result will always fit if is non-zero. + /// + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of op1 to 63. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op1, 63U); + /// + /// // Return the greatest common divisor of op1 and 70. + /// Assert.IsTrue(gmp_lib.mpz_gcd_ui(null, op1, 70U) == 7); + /// + /// // Release unmanaged memory allocated for op1. + /// gmp_lib.mpz_clear(op1); + /// + /// + /// ' Create, initialize, and set the value of op1 to 63. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op1, 63UI) + /// + /// ' Return the greatest common divisor of op1 and 70. + /// Assert.IsTrue(gmp_lib.mpz_gcd_ui(Nothing, op1, 70UI) = 7) + /// ' Release unmanaged memory allocated for op1. + /// gmp_lib.mpz_clear(op1) + /// + /// + public static uint mpz_gcd_ui(mpz_t rop, /*const*/ mpz_t op1, uint /*unsigned long int*/ op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + return SafeNativeMethods.__gmpz_gcd_ui(rop == null ? IntPtr.Zero : rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Set to the greatest common divisor of and , and in addition set and to coefficients satisfying * + * = . + /// + /// The greateast common divisor. + /// The first result coefficient. + /// The second result coefficient. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// The value in is always positive, even if one or both of and + /// are negative (or zero if both inputs are zero). The values in and are chosen such + /// that normally, || < || / (2 ) + /// and || < || / (2 ), and these relations + /// define and uniquely. There are a few exceptional cases: + /// + /// + /// If || = ||, then = 0, + /// = sgn(). + /// + /// + /// Otherwise, = sgn() if = 0 + /// or || = 2 , and = sgn() + /// if = 0 or || = 2 . + /// + /// + /// In all cases, = 0 if and only if + /// = ||, i.e., + /// if divides + /// or = = 0. + /// + /// + /// If is null then that value is not computed. + /// + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of op1 to 63. + /// mpz_t a = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(a, 63U); + /// + /// // Create, initialize, and set the value of op2 to 70. + /// mpz_t b = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(b, 70U); + /// + /// // Create, initialize, and set the values of g, s, and t to 0. + /// mpz_t g = new mpz_t(); + /// mpz_t s = new mpz_t(); + /// mpz_t t = new mpz_t(); + /// gmp_lib.mpz_inits(g, s, t, null); + /// + /// // Set g to the the greatest common divisor of a and b, and set s and t such that a * s + b * t = g. + /// gmp_lib.mpz_gcdext(g, s, t, a, b); + /// + /// // Assert that g is 7, and that s and t are respectively -1 and 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(g) == 7); + /// Assert.IsTrue(gmp_lib.mpz_get_si(s) == -1); + /// Assert.IsTrue(gmp_lib.mpz_get_si(t) == 1); + /// + /// // Release unmanaged memory allocated for g, s, t, a, and b. + /// gmp_lib.mpz_clears(g, s, t, a, b, null); + /// + /// + /// ' Create, initialize, and set the value of op1 to 63. + /// Dim a As New mpz_t() + /// gmp_lib.mpz_init_set_ui(a, 63UI) + /// + /// ' Create, initialize, and set the value of op2 to 70. + /// Dim b As New mpz_t() + /// gmp_lib.mpz_init_set_ui(b, 70UI) + /// + /// ' Create, initialize, and set the values of g, s, and t to 0. + /// Dim g As New mpz_t() + /// Dim s As New mpz_t() + /// Dim t As New mpz_t() + /// gmp_lib.mpz_inits(g, s, t, Nothing) + /// + /// ' Set g to the the greatest common divisor of a and b, and set s and t such that a * s + b * t = g. + /// gmp_lib.mpz_gcdext(g, s, t, a, b) + /// + /// ' Assert that g is 7, and that s and t are respectively -1 and 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(g) = 7) + /// Assert.IsTrue(gmp_lib.mpz_get_si(s) = -1) + /// Assert.IsTrue(gmp_lib.mpz_get_si(t) = 1) + /// + /// ' Release unmanaged memory allocated for g, s, t, a, and b. + /// gmp_lib.mpz_clears(g, s, t, a, b, Nothing) + /// + /// + public static void mpz_gcdext(mpz_t g, mpz_t s, mpz_t t, /*const*/ mpz_t a, /*const*/ mpz_t b) + { + if (g == null) throw new ArgumentNullException("g"); + if (s == null) throw new ArgumentNullException("s"); + if (a == null) throw new ArgumentNullException("a"); + if (b == null) throw new ArgumentNullException("b"); + SafeNativeMethods.__gmpz_gcdext(g.ToIntPtr(), s.ToIntPtr(), t == null ? IntPtr.Zero : t.ToIntPtr(), a.ToIntPtr(), b.ToIntPtr()); + } + + /// + /// Convert to a double, truncating if necessary (i.e. rounding towards zero). + /// + /// The integer. + /// as a double, truncating it if necessary (i.e. rounding towards zero). + /// + /// + /// If the exponent from the conversion is too big, the result is system dependent. An infinity is returned + /// where available. A hardware overflow trap may or may not occur. + /// + /// + /// + /// + /// + /// + /// GNU MP - Converting Integers + /// + /// + /// // Create, initialize, and set the value of x to 10. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_d(x, 10.7D); + /// + /// // Assert that the value of x is 10.0. + /// Assert.IsTrue(gmp_lib.mpz_get_d(x) == 10.0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create, initialize, and set the value of x to 10. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_d(x, 10.7) + /// + /// ' Assert that the value of x is 10.0. + /// Assert.IsTrue(gmp_lib.mpz_get_d(x) = 10.0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static double mpz_get_d(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_get_d(op.ToIntPtr()); + } + + /// + /// Convert to a double, truncating if necessary (i.e. rounding towards zero), and returning the exponent separately. + /// + /// The returned exponent. + /// The integer. + /// as a double, truncating if necessary (i.e. rounding towards zero). + /// + /// + /// The return value is in the range 0.5 ≤ |d| < 1 and the exponent is stored to . + /// d x 2^ is the (truncated) value. + /// If is zero, the return value is 0.0 and 0 is stored to . + /// + /// + /// This is similar to the standard C frexp function. + /// + /// + /// + /// + /// + /// + /// GNU MP - Converting Integers + /// + /// + /// // Create, initialize, and set the value of x to 2^20. + /// mpz_t x = new mpz_t(); + /// char_ptr value = new char_ptr("100000000000000000000"); + /// gmp_lib.mpz_init_set_str(x, value, 2); + /// + /// // Assert that x is equal to 0.5^21. + /// int exp = 0; + /// Assert.IsTrue(gmp_lib.mpz_get_d_2exp(ref exp, x) == 0.5D); + /// Assert.IsTrue(exp == 21); + /// + /// // Release unmanaged memory allocated for x and the string value. + /// gmp_lib.mpz_clear(x); + /// gmp_lib.free(value); + /// + /// + /// ' Create, initialize, and set the value of x to 2^20. + /// Dim x As New mpz_t() + /// Dim value As New char_ptr("100000000000000000000") + /// gmp_lib.mpz_init_set_str(x, value, 2) + /// + /// ' Assert that x is equal to 0.5^21. + /// Dim exp As Integer = 0 + /// Assert.IsTrue(gmp_lib.mpz_get_d_2exp(exp, x) = 0.5) + /// Assert.IsTrue(exp = 21) + /// + /// ' Release unmanaged memory allocated for x and the string value. + /// gmp_lib.mpz_clear(x) + /// gmp_lib.free(value) + /// + /// + public static double mpz_get_d_2exp(ref int /*long int*/ exp, /*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_get_d_2exp(ref exp, op.ToIntPtr()); + } + + /// + /// Return the value of as an signed long. + /// + /// The integer. + /// The value of as an signed long. + /// + /// + /// If fits into a signed long int return the value of . + /// Otherwise return the least significant part of , with the same sign as . + /// + /// + /// If is too big to fit in a signed long int, the returned result is probably not very useful. + /// To find out if the value will fit, use the function . + /// + /// + /// + /// + /// + /// + /// GNU MP - Converting Integers + /// + /// + /// // Create, initialize, and set the value of x to -10. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_si(x, -10); + /// + /// // Retrieve the value of x, and assert that it is -10. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) == -10); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create, initialize, and set the value of x to -10. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_si(x, -10) + /// + /// ' Retrieve the value of x, and assert that it is -10. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) = -10) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static int mpz_get_si(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_get_si(op.ToIntPtr()); + } + + /// + /// Convert to a string of digits in base . + /// + /// The converted integer. + /// The base. + /// The integer. + /// A pointer to the result string is returned, being either the allocated block, or the given . + /// + /// + /// The base argument may vary from 2 to 62 or from −2 to −36. + /// + /// + /// For base in the range 2..36, digits and lower-case letters are used; for −2..−36, digits and + /// upper-case letters are used; for 37..62, digits, upper-case letters, and lower-case letters (in that + /// significance order) are used. + /// + /// + /// If is , the result string is allocated using the current + /// allocation function. The block will be strlen(str)+1 bytes, that being exactly enough for the string and + /// null-terminator. + /// + /// + /// If is not , it should point to a block of storage large + /// enough for the result, that being (op, base) + 2. + /// The two extra bytes are for a possible minus sign, and the null-terminator. + /// + /// + /// + /// + /// + /// + /// GNU MP - Converting Integers + /// + /// + /// // Create, initialize, and set the value of x to -210. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_si(x, -210); + /// + /// // Retrieve the string value of x, and assert that it is "-210". + /// char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x); + /// Assert.IsTrue(s.ToString() == "-210"); + /// + /// // Release unmanaged memory allocated for x and the string value. + /// gmp_lib.mpz_clear(x); + /// gmp_lib.free(s); + /// + /// + /// ' Create, initialize, and set the value of x to -210. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_si(x, -210) + /// + /// ' Retrieve the string value of x, and assert that it is "-210". + /// Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x) + /// Assert.IsTrue(s.ToString() = "-210") + /// + /// ' Release unmanaged memory allocated for x and the string value. + /// gmp_lib.mpz_clear(x) + /// gmp_lib.free(s) + /// + /// + public static char_ptr mpz_get_str(char_ptr str, int @base, /*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return new char_ptr(SafeNativeMethods.__gmpz_get_str(str.ToIntPtr(), @base, op.ToIntPtr())); + } + + /// + /// Return the value of as an unsigned long. + /// + /// The integer. + /// The value of as an unsigned long. + /// + /// + /// If is too big to fit an unsigned long then just the least significant + /// bits that do fit are returned. The sign of is ignored, only the absolute + /// value is used. + /// + /// + /// + /// + /// + /// + /// GNU MP - Converting Integers + /// + /// + /// // Create, initialize, and set the value of x to 10. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10U); + /// + /// // Retrieve the value of x, and assert that it is 10. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 10U); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create, initialize, and set the value of x to 10. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10UI) + /// + /// ' Retrieve the value of x, and assert that it is 10. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(x) = 10UI) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static uint /*unsigned long int*/ mpz_get_ui(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_get_ui(op.ToIntPtr()); + } + + /// + /// Return limb number from . + /// + /// The operand integer. + /// The zero-based limb index. + /// The limb number from . + /// + /// + /// The sign of is ignored, just the absolute value is used. + /// The least significant limb is number 0. + /// + /// + /// can be used to find how many limbs make up . + /// returns zero if is outside the range 0 + /// to mpz_size() - 1. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Special Functions + /// + /// + /// // Create and initialize new integer x. + /// mpz_t op = new mpz_t(); + /// char_ptr value = new char_ptr("1000 ABCD 1234 7AB8 24FD"); + /// gmp_lib.mpz_init_set_str(op, value, 16); + /// + /// // Assert the value of the limbs of op. + /// if (gmp_lib.mp_bytes_per_limb == 4) + /// { + /// Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 0) == 0x7AB824FD); + /// Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 1) == 0xABCD1234); + /// Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 2) == 0x00001000); + /// } + /// else // gmp_lib.mp_bytes_per_limb == 8 + /// { + /// Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 0) == 0xABCD12347AB824FD); + /// Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 1) == 0x0000000000001000); + /// } + /// + /// // Release unmanaged memory allocated for op and value. + /// gmp_lib.mpz_clear(op); + /// gmp_lib.free(value); + /// + /// + /// ' Create and initialize new integer x. + /// Dim op As New mpz_t() + /// Dim value As New char_ptr("1000 ABCD 1234 7AB8 24FD") + /// gmp_lib.mpz_init_set_str(op, value, 16) + /// + /// ' Assert the value of the limbs of op. + /// If gmp_lib.mp_bytes_per_limb = 4 Then + /// Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 0) = &H7ab824fd) + /// Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 1) = &Habcd1234UI) + /// Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 2) = &H1000) + /// Else ' gmp_lib.mp_bytes_per_limb == 8 + /// Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 0) = &Habcd12347ab824fdUL) + /// Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 1) = &H1000) + /// End If + /// + /// ' Release unmanaged memory allocated for op and value. + /// gmp_lib.mpz_clear(op) + /// gmp_lib.free(value) + /// + /// + public static mp_limb_t mpz_getlimbn(/*const*/ mpz_t op, mp_size_t n) + { + if (op == null) throw new ArgumentNullException("op"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpz_getlimbn_x86(op.ToIntPtr(), n)); + else + return new mp_limb_t(SafeNativeMethods.__gmpz_getlimbn_x64(op.ToIntPtr(), n)); + } + + /// + /// Return the hamming distance between the two operands. + /// + /// The first operanf integer. + /// The second operanf integer. + /// The hamming distance between the two operands. + /// + /// + /// If and are both ≥ 0 or both < 0, + /// return the hamming distance between the two operands, which is the number of bit positions where + /// and have different bit values. If one operand is + /// ≥ 0 and the other < 0 then the number of bits different is infinite, and the + /// return value is the largest possible . + /// + /// + /// The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + /// The least significant bit is number 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Logic and Bit Fiddling + /// + /// + /// // Create, initialize, and set the value of op1 to 63. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op1, 63U); + /// + /// // Create, initialize, and set the value of op2 to 70. + /// mpz_t op2 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op2, 70U); + /// + /// // Assert that the Hamming distance between op1 and op2 is 5. + /// Assert.IsTrue(gmp_lib.mpz_hamdist(op1, op2) == 5U); + /// + /// // Release unmanaged memory allocated for op1 and op2. + /// gmp_lib.mpz_clears(op1, op2, null); + /// + /// + /// ' Create, initialize, and set the value of op1 to 63. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op1, 63UI) + /// + /// ' Create, initialize, and set the value of op2 to 70. + /// Dim op2 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op2, 70UI) + /// + /// ' Assert that the Hamming distance between op1 and op2 is 5. + /// Assert.IsTrue(gmp_lib.mpz_hamdist(op1, op2) = 5UI) + /// + /// ' Release unmanaged memory allocated for op1 and op2. + /// gmp_lib.mpz_clears(op1, op2, Nothing) + /// + /// + public static mp_bitcnt_t mpz_hamdist(/*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + return new mp_bitcnt_t(SafeNativeMethods.__gmpz_hamdist(op1.ToIntPtr(), op2.ToIntPtr())); + } + + /// + /// Set from an array of word data at . + /// + /// The result integer. + /// The number of words to read. + /// 1 for most significant word first or -1 for least significant first. + /// The number of bytes in each word. + /// 1 for most significant byte first, -1 for least significant first, or 0 for the native endianness of the host CPU. + /// The number of most significant bits to skip. + /// The operand integer. + /// + /// + /// The parameters specify the format of the data. + /// many words are read, each bytes. + /// can be 1 for most significant word first or -1 for least significant first. + /// Within each word endian can be 1 for most significant byte first, -1 for least significant first, or 0 for the native endianness of the host CPU. + /// The most significant bits of each word are skipped, this can be 0 to use the full words. + /// + /// + /// There is no sign taken from the data, will simply be a positive integer. + /// An application can handle any sign itself, and apply it for instance with . + /// + /// + /// There are no data alignment restrictions on , any address is allowed. + /// + /// + /// Here’s an example converting an array of unsigned long data, most significant element first, and host byte order within each value. + /// + /// + /// unsigned long a[20]; + /// /* Initialize z and a */ + /// mpz_import(z, 20, 1, sizeof(a[0]), 0, 0, a); + /// + /// + /// This example assumes the full sizeof bytes are used for data in the given type, which is usually true, + /// and certainly true for unsigned long everywhere we know of. However on Cray vector systems it may be noted that short + /// and int are always stored in 8 bytes (and with sizeof indicating that) but use only 32 or 46 bits. + /// The feature can account for this, by passing for instance 8 * sizeof(int) - INT_BIT. + /// + /// + /// + /// GNU MP - Integer Import and Export + /// + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Copy 0x800000000000000000000001, 3 words of 4 bytes each, first word is lsb, and first byte in each word is msb. + /// void_ptr data = gmp_lib.allocate(12); + /// Marshal.Copy(new byte[] { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 }, 0, data.ToIntPtr(), 12); + /// + /// // Import value into rop. + /// gmp_lib.mpz_import(rop, 3, -1, 4, 1, 0, data); + /// + /// // Assert the value of rop. + /// char_ptr value = gmp_lib.mpz_get_str(char_ptr.Zero, 16, rop); + /// Assert.IsTrue(value.ToString() == "800000000000000000000001"); + /// + /// // Release unmanaged memory allocated for rop, data, and value. + /// gmp_lib.mpz_clear(rop); + /// gmp_lib.free(data); + /// gmp_lib.free(value); + /// + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Copy 0x800000000000000000000001, 3 words of 4 bytes each, first word is lsb, and first byte in each word is msb. + /// Dim data As void_ptr = gmp_lib.allocate(12) + /// Marshal.Copy(New Byte() { &H0, &H0, &H0, &H1, &H0, &H0, &H0, &H0, &H80, &H0, &H0, &H0}, 0, data.ToIntPtr(), 12) + /// + /// ' Import value into rop. + /// gmp_lib.mpz_import(rop, 3, -1, 4, 1, 0, data) + /// + /// ' Assert the value of rop. + /// Dim value As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 16, rop) + /// Assert.IsTrue(value.ToString() = "800000000000000000000001") + /// + /// ' Release unmanaged memory allocated for rop, data, and value. + /// gmp_lib.mpz_clear(rop) + /// gmp_lib.free(data) + /// gmp_lib.free(value) + /// + /// + public static void mpz_import(mpz_t rop, size_t count, int order, size_t size, int endian, size_t nails, void_ptr op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (IntPtr.Size == 4) + SafeNativeMethods.__gmpz_import_x86(rop.ToIntPtr(), (uint)count, order, (uint)size, endian, (uint)nails, op.ToIntPtr()); + else + SafeNativeMethods.__gmpz_import_x64(rop.ToIntPtr(), count, order, size, endian, nails, op.ToIntPtr()); + } + + /// + /// Initialize , and set its value to 0. + /// + /// The integer. + /// + /// + /// + /// + /// + /// GNU MP - Initializing Integers + /// + /// + /// // Create and initialize a new integer x. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// + /// // Assert that the value of x is 0. + /// char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x); + /// Assert.IsTrue(s.ToString() == "0"); + /// + /// // Release unmanaged memory allocated for x and its string value. + /// gmp_lib.mpz_clear(x); + /// gmp_lib.free(s); + /// + /// + /// ' Create and initialize a new integer x. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init(x) + /// + /// ' Assert that the value of x is 0. + /// Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x) + /// Assert.IsTrue(s.ToString() = "0") + /// + /// ' Release unmanaged memory allocated for x and its string value. + /// gmp_lib.mpz_clear(x) + /// gmp_lib.free(s) + /// + /// + public static void mpz_init(mpz_t x) + { + if (x == null) throw new ArgumentNullException("x"); + SafeNativeMethods.__gmpz_init(x.ToIntPtr()); + } + + /// + /// Initialize , with space for -bit numbers, and set its value to 0. + /// + /// The integer. + /// The number of bits. + /// + /// + /// Calling this function instead of or + /// is never necessary; reallocation is handled automatically by GMP when needed. + /// + /// + /// While defines the initial space, will grow automatically in the normal way, + /// if necessary, for subsequent values stored. + /// makes it possible to avoid such reallocations if a maximum size is known in advance. + /// + /// + /// In preparation for an operation, GMP often allocates one limb more than ultimately needed. + /// To make sure GMP will not perform reallocation for , you need to add the number of bits + /// in to . + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Integers + /// + /// + /// // Create a new integer x, and initialize its size to 300 bits. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init2(x, 300); + /// + /// // Assert that the value of x is 0. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) == 0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create a new integer x, and initialize its size to 300 bits. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init2(x, 300) + /// + /// ' Assert that the value of x is 0. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) = 0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static void mpz_init2(mpz_t x, mp_bitcnt_t n) + { + if (x == null) throw new ArgumentNullException("x"); + SafeNativeMethods.__gmpz_init2(x.ToIntPtr(), n); + } + + /// + /// Initialize a NULL-terminated list of variables, and set their values to 0. + /// + /// A NULL-terminated list of variables. + /// + /// + /// + /// + /// + /// GNU MP - Initializing Integers + /// + /// + /// // Create new integers x1, x2 and x3. + /// mpz_t x1 = new mpz_t(); + /// mpz_t x2 = new mpz_t(); + /// mpz_t x3 = new mpz_t(); + /// + /// // Initialize the integers. + /// gmp_lib.mpz_inits(x1, x2, x3, null); + /// + /// // Assert that their value is 0. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x1) == 0); + /// Assert.IsTrue(gmp_lib.mpz_get_si(x2) == 0); + /// Assert.IsTrue(gmp_lib.mpz_get_si(x3) == 0); + /// + /// // Release unmanaged memory allocated for the integers. + /// gmp_lib.mpz_clears(x1, x2, x3, null); + /// + /// + /// ' Create new integers x1, x2 and x3. + /// Dim x1 As New mpz_t() + /// Dim x2 As New mpz_t() + /// Dim x3 As New mpz_t() + /// + /// ' Initialize the integers. + /// gmp_lib.mpz_inits(x1, x2, x3, Nothing) + /// + /// ' Assert that their value is 0. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x1) = 0) + /// Assert.IsTrue(gmp_lib.mpz_get_si(x2) = 0) + /// Assert.IsTrue(gmp_lib.mpz_get_si(x3) = 0) + /// + /// ' Release unmanaged memory allocated for the integers. + /// gmp_lib.mpz_clears(x1, x2, x3, Nothing) + /// + /// + public static void mpz_inits(params mpz_t[] x) + { + if (x == null) throw new ArgumentNullException("x"); + foreach (mpz_t a in x) { if (a != null) mpz_init(a); } + } + + /// + /// Initialize with limb space and set the initial numeric value from . + /// + /// The destination integer. + /// The source integer. + /// + /// + /// + /// + /// GNU MP - Combined Integer Initialization and Assignment + /// + /// + /// // Create, initialize, and set a new integer y to -210. + /// mpz_t y = new mpz_t(); + /// gmp_lib.mpz_init(y); + /// gmp_lib.mpz_set_si(y, -210); + /// + /// // Create, initialize, and set a new integer x to the value of y. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set(x, y); + /// + /// // Assert that x is equal to the value of y. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) == -210); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpz_clears(x, y, null); + /// + /// + /// ' Create, initialize, and set a new integer y to -210. + /// Dim y As New mpz_t() + /// + /// gmp_lib.mpz_init(y) + /// gmp_lib.mpz_set_si(y, -210) + /// + /// ' Create, initialize, and set a new integer x to the value of y. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set(x, y) + /// + /// ' Assert that x is equal to the value of y. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) = -210) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpz_clears(x, y, Nothing) + /// + /// + public static void mpz_init_set(mpz_t rop, /*const*/ mpz_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpz_init_set(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Initialize with limb space and set the initial numeric value from . + /// + /// The destination integer. + /// The source integer. + /// + /// + /// truncate to make it an integer. + /// + /// + /// + /// + /// + /// + /// GNU MP - Combined Integer Initialization and Assignment + /// + /// + /// // Create, initialize, and set the value of x to the truncation of 10.7. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_d(x, 10.7D); + /// + /// // Assert that the value of x is 10. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) == 10); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create, initialize, and set the value of x to the truncation of 10.7. + /// Dim x As New mpz_t() + /// + /// gmp_lib.mpz_init_set_d(x, 10.7) + /// + /// ' Assert that the value of x is 10. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) = 10) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static void mpz_init_set_d(mpz_t rop, double op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_init_set_d(rop.ToIntPtr(), op); + } + + /// + /// Initialize with limb space and set the initial numeric value from . + /// + /// The destination integer. + /// The source integer. + /// + /// + /// + /// + /// GNU MP - Combined Integer Initialization and Assignment + /// + /// + /// // Create, initialize, and set the value of x to 10. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_si(x, 10); + /// + /// // Assert that the value of x is 10. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) == 10); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create, initialize, and set the value of x to 10. + /// Dim x As New mpz_t() + /// + /// gmp_lib.mpz_init_set_si(x, 10) + /// + /// ' Assert that the value of x is 10. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) = 10) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static void mpz_init_set_si(mpz_t rop, int /*long int*/ op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_init_set_si(rop.ToIntPtr(), op); + } + + /// + /// Initialize and set its value like . + /// + /// The destination integer. + /// The source integer. + /// The base. + /// If the string is a correct base number, the function returns 0; if an error occurs it returns −1. is initialized even if an error occurs. + /// + /// + /// See for details. + /// + /// + /// + /// + /// + /// + /// GNU MP - Combined Integer Initialization and Assignment + /// + /// + /// // Create, initialize, and set the value of x. + /// mpz_t x = new mpz_t(); + /// char_ptr value = new char_ptr(" 1 234 567 890 876 543 211 234 567 890 987 654 321 "); + /// gmp_lib.mpz_init_set_str(x, value, 10); + /// + /// // Assert the value of x. + /// char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x); + /// Assert.IsTrue(s.ToString() == value.ToString().Replace(" ", "")); + /// + /// // Release unmanaged memory allocated for x and string values. + /// gmp_lib.mpz_clear(x); + /// gmp_lib.free(value); + /// gmp_lib.free(s); + /// + /// + /// ' Create, initialize, and set the value of x. + /// Dim x As New mpz_t() + /// Dim value As New char_ptr(" 1 234 567 890 876 543 211 234 567 890 987 654 321 ") + /// gmp_lib.mpz_init_set_str(x, value, 10) + /// + /// ' Assert the value of x. + /// Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x) + /// + /// Assert.IsTrue(s.ToString() = value.ToString().Replace(" ", "")) + /// ' Release unmanaged memory allocated for x and string values. + /// gmp_lib.mpz_clear(x) + /// gmp_lib.free(value) + /// gmp_lib.free(s) + /// + /// + public static int mpz_init_set_str(mpz_t rop, /*const*/ char_ptr str, int @base) + { + if (rop == null) throw new ArgumentNullException("rop"); + return SafeNativeMethods.__gmpz_init_set_str(rop.ToIntPtr(), str.ToIntPtr(), @base); + } + + /// + /// Initialize with limb space and set the initial numeric value from . + /// + /// The destination integer. + /// The source integer. + /// + /// + /// + /// + /// GNU MP - Combined Integer Initialization and Assignment + /// + /// + /// // Create, initialize, and set the value of x to 10. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10U); + /// + /// // Assert that the value of x is 10. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 10U); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create, initialize, and set the value of x to 10. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10UI) + /// + /// ' Assert that the value of x is 10. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(x) = 10UI) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static void mpz_init_set_ui(mpz_t rop, uint /*unsigned long int*/ op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_init_set_ui(rop.ToIntPtr(), op); + } + + /// + /// Input from stdio stream in the format written by , and put the result in . + /// + /// The result operand. + /// Pointer to file stream. + /// Return the number of bytes read, or if an error occurred, return 0. + /// + /// + /// This routine can read the output from also from GMP 1, + /// in spite of changes necessary for compatibility between 32-bit and 64-bit machines. + /// + /// + /// + /// + /// + /// GNU MP - I/O of Integers + /// + /// + /// // Create, initialize, and set the value of op to 123456. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, 123456U); + /// + /// // Write op to a temporary file. + /// string pathname = System.IO.Path.GetTempFileName(); + /// ptr<FILE> stream = new ptr<FILE>(); + /// _wfopen_s(out stream.Value.Value, pathname, "w"); + /// Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) == 7); + /// fclose(stream.Value.Value); + /// + /// // Read op from the temporary file, and assert that the number of bytes read is 6. + /// _wfopen_s(out stream.Value.Value, pathname, "r"); + /// Assert.IsTrue(gmp_lib.mpz_inp_raw(op, stream) == 7); + /// fclose(stream.Value.Value); + /// + /// // Assert that op is 123456. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(op) == 123456U); + /// + /// // Delete temporary file. + /// System.IO.File.Delete(pathname); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to 123456. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, 123456UI) + /// + /// ' Write op to a temporary file. + /// Dim pathname As String = System.IO.Path.GetTempFileName() + /// Dim stream As New ptr(Of FILE)() + /// _wfopen_s(stream.Value.Value, pathname, "w") + /// Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) = 7) + /// fclose(stream.Value.Value) + /// + /// ' Read op from the temporary file, and assert that the number of bytes read is 6. + /// _wfopen_s(stream.Value.Value, pathname, "r") + /// Assert.IsTrue(gmp_lib.mpz_inp_raw(op, stream) = 7) + /// fclose(stream.Value.Value) + /// + /// ' Assert that op is 123456. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(op) = 123456UI) + /// + /// ' Delete temporary file. + /// System.IO.File.Delete(pathname) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static size_t mpz_inp_raw(mpz_t rop, ptr stream) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (IntPtr.Size == 4) + return new size_t(SafeNativeMethods.__gmpz_inp_raw_x86(rop.ToIntPtr(), stream.Value.Value)); + else + return new size_t(SafeNativeMethods.__gmpz_inp_raw_x64(rop.ToIntPtr(), stream.Value.Value)); + } + + /// + /// Input a possibly white-space preceded string in base from stdio stream , and put the read integer in . + /// + /// The result integer. + /// Pointer to file stream. + /// The base operand. + /// Return the number of bytes read, or if an error occurred, return 0. + /// + /// + /// The may vary from 2 to 62, or if base is 0, + /// then the leading characters are used: 0x and 0X for hexadecimal, + /// 0b and 0B for binary, 0 for octal, or decimal otherwise. + /// + /// + /// For bases up to 36, case is ignored; upper-case and lower-case letters have the same value. + /// For bases 37 to 62, upper-case letter represent the usual 10..35 while + /// lower-case letter represent 36..61. + /// + /// + /// + /// + /// + /// GNU MP - I/O of Integers + /// + /// + /// // Create and initialize op. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init(op); + /// + /// // Write op to a temporary file. + /// string pathname = System.IO.Path.GetTempFileName(); + /// System.IO.File.WriteAllText(pathname, "123456"); + /// + /// // Read op from the temporary file, and assert that the number of bytes read is 6. + /// ptr<FILE> stream = new ptr<FILE>(); + /// _wfopen_s(out stream.Value.Value, pathname, "r"); + /// Assert.IsTrue(gmp_lib.mpz_inp_str(op, stream, 10) == 6); + /// fclose(stream.Value.Value); + /// + /// // Assert that op is 123456. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(op) == 123456U); + /// + /// // Delete temporary file. + /// System.IO.File.Delete(pathname); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create and initialize op. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init(op) + /// + /// ' Write op to a temporary file. + /// Dim pathname As String = System.IO.Path.GetTempFileName() + /// System.IO.File.WriteAllText(pathname, "123456") + /// + /// ' Read op from the temporary file, and assert that the number of bytes read is 6. + /// Dim stream As New ptr(Of FILE)() + /// _wfopen_s(stream.Value.Value, pathname, "r") + /// Assert.IsTrue(gmp_lib.mpz_inp_str(op, stream, 10) = 6) + /// fclose(stream.Value.Value) + /// + /// ' Assert that op is 123456. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(op) = 123456UI) + /// + /// ' Delete temporary file. + /// System.IO.File.Delete(pathname) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static size_t mpz_inp_str(mpz_t rop, ptr stream, int @base) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (IntPtr.Size == 4) + return new size_t(SafeNativeMethods.__gmpz_inp_str_x86(rop.ToIntPtr(), stream.Value.Value, @base)); + else + return new size_t(SafeNativeMethods.__gmpz_inp_str_x64(rop.ToIntPtr(), stream.Value.Value, @base)); + } + + /// + /// Compute the inverse of modulo and put the result in . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// If the inverse exists, the return value is non-zero. If an inverse doesn’t exist the return value is zero. + /// + /// + /// If the inverse exists, the return value is non-zero and will satisfy + /// 0 ≤ < || (with = 0 + /// possible only when || = 1, i.e., in the somewhat degenerate zero ring). + /// If an inverse doesn’t exist the return value is zero and is undefined. + /// The behaviour of this function is undefined when is zero. + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of op1 to 3. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op1, 3U); + /// + /// // Create, initialize, and set the value of op2 to 11. + /// mpz_t op2 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op2, 11U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop to the modular inverse of op1 mod op2, i.e. b, where op1 * b mod op1 = 1. + /// gmp_lib.mpz_invert(rop, op1, op2); + /// + /// // Assert that rop is 4, + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 4); + /// + /// // Release unmanaged memory allocated for rop, op1, and op2. + /// gmp_lib.mpz_clears(rop, op1, op2, null); + /// + /// + /// ' Create, initialize, and set the value of op1 to 3. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op1, 3UI) + /// + /// ' Create, initialize, and set the value of op2 to 11. + /// Dim op2 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op2, 11UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop to the modular inverse of op1 mod op2, i.e. b, where op1 * b mod op1 = 1. + /// gmp_lib.mpz_invert(rop, op1, op2) + /// + /// ' Assert that rop is 4, + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 4) + /// + /// ' Release unmanaged memory allocated for rop, op1, and op2. + /// gmp_lib.mpz_clears(rop, op1, op2, Nothing) + /// + /// + public static int mpz_invert(mpz_t rop, /*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + return SafeNativeMethods.__gmpz_invert(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Set to bitwise inclusive-or . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + /// The least significant bit is number 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Logic and Bit Fiddling + /// + /// + /// // Create, initialize, and set the value of op1 to 63. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op1, 63U); + /// + /// // Create, initialize, and set the value of op2 to 70. + /// mpz_t op2 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op2, 70U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop to the bitwise inclusive or of op1 and op2. + /// gmp_lib.mpz_ior(rop, op1, op2); + /// + /// // Assert that rop is 127. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 127); + /// + /// // Release unmanaged memory allocated for rop, op1, and op2. + /// gmp_lib.mpz_clears(rop, op1, op2, null); + /// + /// + /// ' Create, initialize, and set the value of op1 to 63. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op1, 63UI) + /// + /// ' Create, initialize, and set the value of op2 to 70. + /// Dim op2 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op2, 70UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop to the bitwise inclusive or of op1 and op2. + /// gmp_lib.mpz_ior(rop, op1, op2) + /// + /// ' Assert that rop is 127. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 127) + /// + /// ' Release unmanaged memory allocated for rop, op1, and op2. + /// gmp_lib.mpz_clears(rop, op1, op2, Nothing) + /// + /// + public static void mpz_ior(mpz_t rop, /*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpz_ior(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Calculate the Jacobi symbol (/). + /// + /// The first operand integer. + /// The second operand integer. + /// The Jacobi symbol (/). + /// + /// + /// This is defined only for odd. + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of a to 11. + /// mpz_t a = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(a, 11U); + /// + /// // Create, initialize, and set the value of b to 9. + /// mpz_t b = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(b, 9U); + /// + /// // Assert that the Jacobi symbol of (a/b) is 1. + /// Assert.IsTrue(gmp_lib.mpz_jacobi(a, b) == 1); + /// + /// // Release unmanaged memory allocated for a and b. + /// gmp_lib.mpz_clears(a, b, null); + /// + /// + /// ' Create, initialize, and set the value of a to 11. + /// Dim a As New mpz_t() + /// gmp_lib.mpz_init_set_ui(a, 11UI) + /// + /// ' Create, initialize, and set the value of b to 9. + /// Dim b As New mpz_t() + /// gmp_lib.mpz_init_set_ui(b, 9UI) + /// + /// ' Assert that the Jacobi symbol of (a/b) is 1. + /// Assert.IsTrue(gmp_lib.mpz_jacobi(a, b) = 1) + /// + /// ' Release unmanaged memory allocated for a and b. + /// gmp_lib.mpz_clears(a, b, Nothing) + /// + /// + public static int mpz_jacobi(/*const*/ mpz_t a, /*const*/ mpz_t b) + { + if (a == null) throw new ArgumentNullException("a"); + if (b == null) throw new ArgumentNullException("b"); + return SafeNativeMethods.__gmpz_jacobi(a.ToIntPtr(), b.ToIntPtr()); + } + + /// + /// Calculate the Jacobi symbol (/) with the Kronecker extension (/2) = (2/) when odd, or (/2) = 0 when even. + /// + /// The first operand integer. + /// The second operand integer. + /// The Jacobi symbol (/) with the Kronecker extension (/2) = (2/) when odd, or (/2) = 0 when even. + /// + /// + /// When is odd the Jacobi symbol and Kronecker symbol are identical, + /// so , etc. can be used for mixed precision Jacobi symbols too. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of a to 15. + /// mpz_t a = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(a, 15U); + /// + /// // Create, initialize, and set the value of b to 4. + /// mpz_t b = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(b, 4U); + /// + /// // Assert that the Kronecker symbol of (a/b) is 1. + /// Assert.IsTrue(gmp_lib.mpz_kronecker(a, b) == 1); + /// + /// // Release unmanaged memory allocated for a and b. + /// gmp_lib.mpz_clears(a, b, null); + /// + /// + /// ' Create, initialize, and set the value of a to 15. + /// Dim a As New mpz_t() + /// gmp_lib.mpz_init_set_ui(a, 15UI) + /// + /// ' Create, initialize, and set the value of b to 4. + /// Dim b As New mpz_t() + /// gmp_lib.mpz_init_set_ui(b, 4UI) + /// + /// ' Assert that the Kronecker symbol of (a/b) is 1. + /// Assert.IsTrue(gmp_lib.mpz_kronecker(a, b) = 1) + /// + /// ' Release unmanaged memory allocated for a and b. + /// gmp_lib.mpz_clears(a, b, Nothing) + /// + /// + public static int mpz_kronecker(/*const*/ mpz_t a, /*const*/ mpz_t b) + { + if (a == null) throw new ArgumentNullException("a"); + if (b == null) throw new ArgumentNullException("b"); + return SafeNativeMethods.__gmpz_jacobi(a.ToIntPtr(), b.ToIntPtr()); + } + + /// + /// Calculate the Jacobi symbol (/) with the Kronecker extension (/2) = (2/) when odd, or (/2) = 0 when even. + /// + /// The first operand integer. + /// The second operand integer. + /// The Jacobi symbol (/) with the Kronecker extension (/2) = (2/) when odd, or (/2) = 0 when even. + /// + /// + /// When is odd the Jacobi symbol and Kronecker symbol are identical, + /// so , etc. can be used for mixed precision Jacobi symbols too. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of a to 15. + /// mpz_t a = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(a, 15U); + /// + /// // Assert that the Kronecker symbol of (a/4) is 1. + /// Assert.IsTrue(gmp_lib.mpz_kronecker_si(a, 4) == 1); + /// + /// // Release unmanaged memory allocated for a. + /// gmp_lib.mpz_clear(a); + /// + /// + /// ' Create, initialize, and set the value of a to 15. + /// Dim a As New mpz_t() + /// gmp_lib.mpz_init_set_ui(a, 15UI) + /// + /// ' Assert that the Kronecker symbol of (a/4) is 1. + /// Assert.IsTrue(gmp_lib.mpz_kronecker_si(a, 4) = 1) + /// + /// ' Release unmanaged memory allocated for a. + /// gmp_lib.mpz_clear(a) + /// + /// + public static int mpz_kronecker_si(/*const*/ mpz_t a, int /*long int*/ b) + { + if (a == null) throw new ArgumentNullException("a"); + return SafeNativeMethods.__gmpz_kronecker_si(a.ToIntPtr(), b); + } + + /// + /// Calculate the Jacobi symbol (/) with the Kronecker extension (/2) = (2/) when odd, or (/2) = 0 when even. + /// + /// The first operand integer. + /// The second operand integer. + /// The Jacobi symbol (/) with the Kronecker extension (/2) = (2/) when odd, or (/2) = 0 when even. + /// + /// + /// When is odd the Jacobi symbol and Kronecker symbol are identical, + /// so , etc. can be used for mixed precision Jacobi symbols too. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of a to 15. + /// mpz_t a = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(a, 15U); + /// + /// // Assert that the Kronecker symbol of (a/4) is 1. + /// Assert.IsTrue(gmp_lib.mpz_kronecker_ui(a, 4U) == 1); + /// + /// // Release unmanaged memory allocated for a. + /// gmp_lib.mpz_clear(a); + /// + /// + /// ' Create, initialize, and set the value of a to 15. + /// Dim a As New mpz_t() + /// gmp_lib.mpz_init_set_ui(a, 15UI) + /// + /// ' Assert that the Kronecker symbol of (a/4) is 1. + /// Assert.IsTrue(gmp_lib.mpz_kronecker_ui(a, 4UI) = 1) + /// + /// ' Release unmanaged memory allocated for a. + /// gmp_lib.mpz_clear(a) + /// + /// + public static int mpz_kronecker_ui(/*const*/ mpz_t a, uint /*unsigned long int*/ b) + { + if (a == null) throw new ArgumentNullException("a"); + return SafeNativeMethods.__gmpz_kronecker_ui(a.ToIntPtr(), b); + } + + /// + /// Calculate the Jacobi symbol (/) with the Kronecker extension (/2) = (2/) when odd, or (/2) = 0 when even. + /// + /// The first operand integer. + /// The second operand integer. + /// The Jacobi symbol (/) with the Kronecker extension (/2) = (2/) when odd, or (/2) = 0 when even. + /// + /// + /// When is odd the Jacobi symbol and Kronecker symbol are identical, + /// so , etc. can be used for mixed precision Jacobi symbols too. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of b to 4. + /// mpz_t b = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(b, 4U); + /// + /// // Assert that the Kronecker symbol of (15/b) is 1. + /// Assert.IsTrue(gmp_lib.mpz_si_kronecker(15, b) == 1); + /// + /// // Release unmanaged memory allocated for b. + /// gmp_lib.mpz_clear(b); + /// + /// + /// ' Create, initialize, and set the value of b to 4. + /// Dim b As New mpz_t() + /// gmp_lib.mpz_init_set_ui(b, 4UI) + /// + /// ' Assert that the Kronecker symbol of (15/b) is 1. + /// Assert.IsTrue(gmp_lib.mpz_si_kronecker(15, b) = 1) + /// + /// ' Release unmanaged memory allocated for b. + /// gmp_lib.mpz_clear(b) + /// + /// + public static int mpz_si_kronecker(int /*long int*/ a, /*const*/ mpz_t b) + { + if (b == null) throw new ArgumentNullException("b"); + return SafeNativeMethods.__gmpz_si_kronecker(a, b.ToIntPtr()); + } + + /// + /// Calculate the Jacobi symbol (/) with the Kronecker extension (/2) = (2/) when odd, or (/2) = 0 when even. + /// + /// The first operand integer. + /// The second operand integer. + /// The Jacobi symbol (/) with the Kronecker extension (/2) = (2/) when odd, or (/2) = 0 when even. + /// + /// + /// When is odd the Jacobi symbol and Kronecker symbol are identical, + /// so , etc. can be used for mixed precision Jacobi symbols too. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of b to 4. + /// mpz_t b = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(b, 4U); + /// + /// // Assert that the Kronecker symbol of (15/b) is 1. + /// Assert.IsTrue(gmp_lib.mpz_ui_kronecker(15U, b) == 1); + /// + /// // Release unmanaged memory allocated for b. + /// gmp_lib.mpz_clear(b); + /// + /// + /// ' Create, initialize, and set the value of b to 4. + /// Dim b As New mpz_t() + /// gmp_lib.mpz_init_set_ui(b, 4UI) + /// + /// ' Assert that the Kronecker symbol of (15/b) is 1. + /// Assert.IsTrue(gmp_lib.mpz_ui_kronecker(15UI, b) = 1) + /// + /// ' Release unmanaged memory allocated for b. + /// gmp_lib.mpz_clear(b) + /// + /// + public static int mpz_ui_kronecker(uint /*unsigned long int*/ a, /*const*/ mpz_t b) + { + if (b == null) throw new ArgumentNullException("b"); + return SafeNativeMethods.__gmpz_ui_kronecker(a, b.ToIntPtr()); + } + + /// + /// Set to the least common multiple of and . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// is always positive, irrespective of the signs of and . + /// will be zero if either or is zero. + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of op1 to 2. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op1, 2U); + /// + /// // Create, initialize, and set the value of op2 to 3. + /// mpz_t op2 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op2, 3U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop to the least common multiple of op1 and op2. + /// gmp_lib.mpz_lcm(rop, op1, op2); + /// + /// // Assert that rop is 6. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6); + /// + /// // Release unmanaged memory allocated for rop, op1, and op2. + /// gmp_lib.mpz_clears(rop, op1, op2, null); + /// + /// + /// ' Create, initialize, and set the value of op1 to 2. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op1, 2UI) + /// + /// ' Create, initialize, and set the value of op2 to 3. + /// Dim op2 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op2, 3UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop to the least common multiple of op1 and op2. + /// gmp_lib.mpz_lcm(rop, op1, op2) + /// + /// ' Assert that rop is 6. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 6) + /// + /// ' Release unmanaged memory allocated for rop, op1, and op2. + /// gmp_lib.mpz_clears(rop, op1, op2, Nothing) + /// + /// + public static void mpz_lcm(mpz_t rop, /*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpz_lcm(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Set to the least common multiple of and . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// is always positive, irrespective of the signs of and . + /// will be zero if either or is zero. + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// + /// + /// + /// + public static void mpz_lcm_ui(mpz_t rop, /*const*/ mpz_t op1, uint /*unsigned long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpz_lcm_ui(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Calculate the Legendre symbol (/). + /// + /// The first operand integer. + /// The second operand integer. + /// The Legendre symbol (/). + /// + /// + /// This is defined only for an odd positive prime, + /// and for such it’s identical to the Jacobi symbol. + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of a to 20. + /// mpz_t a = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(a, 20U); + /// + /// // Create, initialize, and set the value of p to 11. + /// mpz_t p = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(p, 11U); + /// + /// // Assert that the Legendre symbol of (a/p) is 1. + /// Assert.IsTrue(gmp_lib.mpz_legendre(a, p) == 1); + /// + /// // Release unmanaged memory allocated for a and p. + /// gmp_lib.mpz_clears(a, p, null); + /// + /// + /// ' Create, initialize, and set the value of a to 20. + /// Dim a As New mpz_t() + /// gmp_lib.mpz_init_set_ui(a, 20UI) + /// + /// ' Create, initialize, and set the value of p to 11. + /// Dim p As New mpz_t() + /// gmp_lib.mpz_init_set_ui(p, 11UI) + /// + /// ' Assert that the Legendre symbol of (a/p) is 1. + /// Assert.IsTrue(gmp_lib.mpz_legendre(a, p) = 1) + /// + /// ' Release unmanaged memory allocated for a and p. + /// gmp_lib.mpz_clears(a, p, Nothing) + /// + /// + public static int mpz_legendre(/*const*/ mpz_t a, /*const*/ mpz_t p) + { + if (a == null) throw new ArgumentNullException("a"); + if (p == null) throw new ArgumentNullException("p"); + return SafeNativeMethods.__gmpz_legendre(a.ToIntPtr(), p.ToIntPtr()); + } + + /// + /// Sets to to L[], the ’th Lucas number. + /// + /// The L[] result. + /// The operand integer. + /// + /// + /// The Fibonacci numbers and Lucas numbers are related sequences, so it’s never necessary to call both + /// and . + /// The formulas for going from Fibonacci to Lucas can be found in + /// GNU MP - Lucas Numbers Algorithm, + /// the reverse is straightforward too. + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of ln to 0. + /// mpz_t ln = new mpz_t(); + /// gmp_lib.mpz_init(ln); + /// + /// // Set ln to the 9'th Lucas number. + /// gmp_lib.mpz_lucnum_ui(ln, 9U); + /// + /// // Assert that ln is 76. + /// Assert.IsTrue(gmp_lib.mpz_get_si(ln) == 76); + /// + /// // Release unmanaged memory allocated for ln. + /// gmp_lib.mpz_clear(ln); + /// + /// + /// ' Create, initialize, and set the value of ln to 0. + /// Dim ln As New mpz_t() + /// gmp_lib.mpz_init(ln) + /// + /// ' Set ln to the 9'th Lucas number. + /// gmp_lib.mpz_lucnum_ui(ln, 9UI) + /// + /// ' Assert that ln is 76. + /// Assert.IsTrue(gmp_lib.mpz_get_si(ln) = 76) + /// + /// ' Release unmanaged memory allocated for ln. + /// gmp_lib.mpz_clear(ln) + /// + /// + public static void mpz_lucnum_ui(mpz_t ln, uint /*unsigned long int*/ n) + { + if (ln == null) throw new ArgumentNullException("ln"); + SafeNativeMethods.__gmpz_lucnum_ui(ln.ToIntPtr(), n); + } + + /// + /// Sets to L[], and to L[ - 1]. + /// + /// The L[] result. + /// The L[ - 1] result. + /// The operand integer. + /// + /// + /// This function is designed for calculating isolated Lucas numbers. + /// When a sequence of values is wanted it’s best to start with + /// and iterate the defining L[n + 1] = L[n] + L[n - 1] or similar. + /// + /// + /// The Fibonacci numbers and Lucas numbers are related sequences, so it’s never necessary to call both + /// and . + /// The formulas for going from Fibonacci to Lucas can be found in + /// GNU MP - Lucas Numbers Algorithm, + /// the reverse is straightforward too. + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the values of lnsub1 and ln to 0. + /// mpz_t ln = new mpz_t(); + /// mpz_t lnsub1 = new mpz_t(); + /// gmp_lib.mpz_inits(ln, lnsub1, null); + /// + /// // Set lnsub1 and ln to the 8'th and 9'th Lucas nunbers respectively. + /// gmp_lib.mpz_lucnum2_ui(ln, lnsub1, 9U); + /// + /// // Assert that lnsub1 and ln are respectively 47 and 76. + /// Assert.IsTrue(gmp_lib.mpz_get_si(lnsub1) == 47); + /// Assert.IsTrue(gmp_lib.mpz_get_si(ln) == 76); + /// + /// // Release unmanaged memory allocated for ln and lnsub1. + /// gmp_lib.mpz_clears(ln, lnsub1, null); + /// + /// + /// ' Create, initialize, and set the values of lnsub1 and ln to 0. + /// Dim ln As New mpz_t() + /// Dim lnsub1 As New mpz_t() + /// gmp_lib.mpz_inits(ln, lnsub1, Nothing) + /// + /// ' Set lnsub1 and ln to the 8'th and 9'th Lucas nunbers respectively. + /// gmp_lib.mpz_lucnum2_ui(ln, lnsub1, 9UI) + /// + /// ' Assert that lnsub1 and ln are respectively 47 and 76. + /// Assert.IsTrue(gmp_lib.mpz_get_si(lnsub1) = 47) + /// Assert.IsTrue(gmp_lib.mpz_get_si(ln) = 76) + /// + /// ' Release unmanaged memory allocated for ln and lnsub1. + /// gmp_lib.mpz_clears(ln, lnsub1, Nothing) + /// + /// + public static void mpz_lucnum2_ui(mpz_t ln, mpz_t lnsub1, uint /*unsigned long int*/ n) + { + if (ln == null) throw new ArgumentNullException("ln"); + if (lnsub1 == null) throw new ArgumentNullException("lnsub1"); + SafeNativeMethods.__gmpz_lucnum2_ui(ln.ToIntPtr(), lnsub1.ToIntPtr(), n); + } + + /// + /// An implementation of the probabilistic primality test found in Knuth's Seminumerical Algorithms book. + /// + /// The operand integer. + /// The number of internal passes of the probabilistic algorithm. + /// If the function returns 0 then is not prime. If it returns 1, then is 'probably' prime. + /// + /// + /// The probability of a false positive is (1/4)^, where + /// is the number of internal passes of the probabilistic algorithm. + /// Knuth indicates that 25 passes are reasonable. + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of n to 12. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(n, 12U); + /// + /// // Assert that n is a composite number. + /// Assert.IsTrue(gmp_lib.mpz_millerrabin(n, 25) == 0); + /// + /// // Release unmanaged memory allocated for n. + /// gmp_lib.mpz_clear(n); + /// + /// + /// ' Create, initialize, and set the value of n to 12. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_ui(n, 12UI) + /// + /// ' Assert that n is a composite number. + /// Assert.IsTrue(gmp_lib.mpz_millerrabin(n, 25) = 0) + /// + /// ' Release unmanaged memory allocated for n. + /// gmp_lib.mpz_clear(n) + /// + /// + public static int mpz_millerrabin(/*const*/ mpz_t n, int reps) + { + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_millerrabin(n.ToIntPtr(), reps); + } + + /// + /// Set to mod . + /// + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// + /// + /// The sign of the divisor is ignored; the result is always non-negative. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of x to 12222. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 12222U); + /// + /// // Create, initialize, and set the value of y to 10000. + /// mpz_t y = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(y, 10000U); + /// + /// // Create, initialize, and set the value of z to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = x mod y. + /// gmp_lib.mpz_mod(z, x, y); + /// + /// // Assert that z is 12222 mod 10000. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == 12222 % 10000); + /// + /// // Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpz_clears(x, y, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to 12222. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 12222UI) + /// + /// ' Create, initialize, and set the value of y to 10000. + /// Dim y As New mpz_t() + /// gmp_lib.mpz_init_set_ui(y, 10000UI) + /// + /// ' Create, initialize, and set the value of z to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = x mod y. + /// gmp_lib.mpz_mod(z, x, y) + /// + /// ' Assert that z is 12222 mod 10000. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = 12222 Mod 10000) + /// + /// ' Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpz_clears(x, y, z, Nothing) + /// + /// + public static void mpz_mod(mpz_t r, /*const*/ mpz_t n, /*const*/ mpz_t d) + { + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + if (d == null) throw new ArgumentNullException("d"); + SafeNativeMethods.__gmpz_mod(r.ToIntPtr(), n.ToIntPtr(), d.ToIntPtr()); + } + + /// + /// Set to mod . + /// + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// The remainder . + /// + /// + /// The sign of the divisor is ignored; the result is always non-negative. + /// + /// + /// is identical to , returning the remainder as well as setting . + /// See if only the return value is wanted. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of x to 12222. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 12222U); + /// + /// // Create, initialize, and set the value of z to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = x mod y, and return z. + /// Assert.IsTrue(gmp_lib.mpz_mod_ui(z, x, 10000U) == 12222 % 10000); + /// + /// // Assert that z is 12222 mod 10000. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == 12222 % 10000); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to 12222. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 12222UI) + /// + /// ' Create, initialize, and set the value of z to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = x mod y, and return z. + /// Assert.IsTrue(gmp_lib.mpz_mod_ui(z, x, 10000UI) = 12222 Mod 10000) + /// + /// ' Assert that z is 12222 mod 10000. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = 12222 Mod 10000) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, Nothing) + /// + /// + public static uint /*unsigned long int*/ mpz_mod_ui(mpz_t r, /*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_fdiv_r_ui(r.ToIntPtr(), n.ToIntPtr(), d); + } + + /// + /// Set to * . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10000U); + /// + /// // Create, initialize, and set the value of y to 12222. + /// mpz_t y = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(y, 12222U); + /// + /// // Create, initialize, and set the value of z to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = x * y. + /// gmp_lib.mpz_mul(z, x, y); + /// + /// // Assert that z is the product of x and y. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == 10000 * 12222); + /// + /// // Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpz_clears(x, y, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10000UI) + /// + /// ' Create, initialize, and set the value of y to 12222. + /// Dim y As New mpz_t() + /// gmp_lib.mpz_init_set_ui(y, 12222UI) + /// + /// ' Create, initialize, and set the value of z to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = x * y. + /// gmp_lib.mpz_mul(z, x, y) + /// + /// ' Assert that z is the product of x and y. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = 10000 * 12222) + /// + /// ' Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpz_clears(x, y, z, Nothing) + /// + /// + public static void mpz_mul(mpz_t rop, /*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpz_mul(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Set to * 2^. + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// This operation can also be defined as a left shift by bits. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to -10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_si(x, -10000); + /// + /// // Create, initialize, and set the value of x to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = -10000 * 2^2. + /// gmp_lib.mpz_mul_2exp(z, x, 2U); + /// + /// // Assert that z is -40000. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == -10000 * 4); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to -10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_si(x, -10000) + /// + /// ' Create, initialize, and set the value of x to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = -10000 * 2^2. + /// gmp_lib.mpz_mul_2exp(z, x, 2UI) + /// + /// ' Assert that z is -40000. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = -10000 * 4) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, Nothing) + /// + /// + public static void mpz_mul_2exp(mpz_t rop, /*const*/ mpz_t op1, mp_bitcnt_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpz_mul_2exp(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Set to * . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to -10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_si(x, -10000); + /// + /// // Create, initialize, and set the value of z to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = x * 12222. + /// gmp_lib.mpz_mul_si(z, x, 12222); + /// + /// // Assert that z is the product of x and 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == -10000 * 12222); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to -10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_si(x, -10000) + /// + /// ' Create, initialize, and set the value of z to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = x * 12222. + /// gmp_lib.mpz_mul_si(z, x, 12222) + /// + /// ' Assert that z is the product of x and 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = -10000 * 12222) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, Nothing) + /// + /// + public static void mpz_mul_si(mpz_t rop, /*const*/ mpz_t op1, int /*long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpz_mul_si(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Set to * . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to -10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_si(x, -10000); + /// + /// // Create, initialize, and set the value of z to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = x * 12222. + /// gmp_lib.mpz_mul_ui(z, x, 12222); + /// + /// // Assert that z is the product of x and 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == -10000 * 12222); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to -10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_si(x, -10000) + /// + /// ' Create, initialize, and set the value of z to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = x * 12222. + /// gmp_lib.mpz_mul_ui(z, x, 12222) + /// + /// ' Assert that z is the product of x and 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = -10000 * 12222) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, Nothing) + /// + /// + public static void mpz_mul_ui(mpz_t rop, /*const*/ mpz_t op1, uint /*unsigned long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpz_mul_ui(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Set to -. + /// + /// The result integer. + /// The operand integer. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to -10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_si(x, -10000); + /// + /// // Create, initialize, and set the value of z to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = -x. + /// gmp_lib.mpz_neg(z, x); + /// + /// // Assert that z is -x. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == 10000); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to -10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_si(x, -10000) + /// + /// ' Create, initialize, and set the value of z to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = -x. + /// gmp_lib.mpz_neg(z, x) + /// + /// ' Assert that z is -x. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = 10000) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, Nothing) + /// + /// + public static void mpz_neg(mpz_t rop, /*const*/ mpz_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpz_neg(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set to the next prime greater than . + /// + /// The result prime integer. + /// The operand integer. + /// + /// + /// This function uses a probabilistic algorithm to identify primes. + /// For practical purposes it’s adequate, the chance of a composite passing will be extremely small. + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of n to 12. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, 12U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop to the next following op. + /// gmp_lib.mpz_nextprime(rop, op); + /// + /// // Assert that rop is 13. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 13); + /// + /// // Release unmanaged memory allocated for rop and op. + /// gmp_lib.mpz_clears(rop, op, null); + /// + /// + /// ' Create, initialize, and set the value of n to 12. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, 12UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop to the next following op. + /// gmp_lib.mpz_nextprime(rop, op) + /// + /// ' Assert that rop is 13. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 13) + /// + /// ' Release unmanaged memory allocated for rop and op. + /// gmp_lib.mpz_clears(rop, op, Nothing) + /// + /// + public static void mpz_nextprime(mpz_t rop, /*const*/ mpz_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpz_nextprime(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Determine whether is odd. + /// + /// The operand integer. + /// Return non-zero if odd, zero if even. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Integer Functions + /// + /// + /// // Create, initialize, and set the value of op to 427294. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, 427294); + /// + /// // Assert that op is not odd but even. + /// Assert.IsTrue(gmp_lib.mpz_even_p(op) > 0); + /// Assert.IsTrue(gmp_lib.mpz_odd_p(op) == 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to 427294. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, 427294) + /// + /// ' Assert that op is not odd but even. + /// Assert.IsTrue(gmp_lib.mpz_even_p(op) > 0) + /// Assert.IsTrue(gmp_lib.mpz_odd_p(op) = 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static int mpz_odd_p(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return op._mp_size != 0 && (op._mp_d[0] & 1) == 0 ? 0 : 1; + } + + /// + /// Output on stdio stream , in raw binary format. + /// + /// Pointer to file streama. + /// The operand integer. + /// Return the number of bytes written, or if an error occurred, return 0. + /// + /// + /// The integer is written in a portable format, with 4 bytes of size information, and that many bytes of limbs. + /// Both the size and the limbs are written in decreasing significance order (i.e., in big-endian). + /// + /// + /// The output can be read with . + /// + /// + /// The output of this can not be read by mpz_inp_raw from GMP 1, + /// because of changes necessary for compatibility between 32-bit and 64-bit machines. + /// + /// + /// + /// + /// + /// GNU MP - I/O of Integers + /// + /// + /// // Create, initialize, and set the value of op to 123456 (0x1E240). + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, 0x1E240); + /// + /// // Get a temporary file. + /// string pathname = System.IO.Path.GetTempFileName(); + /// + /// // Open temporary file for writing. + /// ptr<FILE> stream = new ptr<FILE>(); + /// _wfopen_s(out stream.Value.Value, pathname, "w"); + /// + /// // Write op to temporary file, and assert that the number of bytes written is 7. + /// Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) == 7); + /// + /// // Close temporary file. + /// fclose(stream.Value.Value); + /// + /// // Assert that the content of the temporary file. + /// byte[] r = System.IO.File.ReadAllBytes(pathname); + /// Assert.IsTrue(r[0] == 0 && r[1] == 0 && r[2] == 0 && r[3] == 3 && r[4] == 0x01 && r[5] == 0xE2 && r[6] == 0x40); + /// + /// // Delete temporary file. + /// System.IO.File.Delete(pathname); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to 123456 (0x1E240). + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, &H1e240) + /// + /// ' Get a temporary file. + /// Dim pathname As String = System.IO.Path.GetTempFileName() + /// + /// ' Open temporary file for writing. + /// Dim stream As New ptr(Of FILE)() + /// _wfopen_s(stream.Value.Value, pathname, "w") + /// + /// ' Write op to temporary file, and assert that the number of bytes written is 7. + /// Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) = 7) + /// + /// ' Close temporary file. + /// fclose(stream.Value.Value) + /// + /// ' Assert that the content of the temporary file. + /// Dim r As Byte() = System.IO.File.ReadAllBytes(pathname) + /// Assert.IsTrue(r(0) = 0 AndAlso r(1) = 0 AndAlso r(2) = 0 AndAlso r(3) = 3 AndAlso r(4) = &H1 AndAlso r(5) = &He2 AndAlso r(6) = &H40) + /// + /// ' Delete temporary file. + /// System.IO.File.Delete(pathname) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static size_t mpz_out_raw(ptr stream, /*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + if (IntPtr.Size == 4) + return new size_t(SafeNativeMethods.__gmpz_out_raw_x86(stream.Value.Value, op.ToIntPtr())); + else + return new size_t(SafeNativeMethods.__gmpz_out_raw_x64(stream.Value.Value, op.ToIntPtr())); + } + + /// + /// Output on stdio stream , as a string of digits in base . + /// + /// Pointer to file stream. + /// The base operand. + /// The operand integer. + /// Return the number of bytes written, or if an error occurred, return 0. + /// + /// + /// The argument may vary from 2 to 62 or from -2 to -36. + /// + /// + /// For in the range 2..36, digits and lower-case letters are used; + /// for -2..-36, digits and upper-case letters are used; for 37..62, digits, upper-case letters, + /// and lower-case letters (in that significance order) are used. + /// + /// + /// + /// + /// + /// GNU MP - I/O of Integers + /// + /// + /// // Create, initialize, and set the value of op to 123456. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, 123456U); + /// + /// // Get a temporary file. + /// string pathname = System.IO.Path.GetTempFileName(); + /// + /// // Open temporary file for writing. + /// ptr<FILE> stream = new ptr<FILE>(); + /// _wfopen_s(out stream.Value.Value, pathname, "w"); + /// + /// // Write op to temporary file, and assert that the number of bytes written is 6. + /// Assert.IsTrue(gmp_lib.mpz_out_str(stream, 10, op) == 6); + /// + /// // Close temporary file. + /// fclose(stream.Value.Value); + /// + /// // Assert that the content of the temporary file is "123456". + /// string result = System.IO.File.ReadAllText(pathname); + /// Assert.IsTrue(result == "123456"); + /// + /// // Delete temporary file. + /// System.IO.File.Delete(pathname); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to 123456. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, 123456UI) + /// + /// ' Get a temporary file. + /// Dim pathname As String = System.IO.Path.GetTempFileName() + /// + /// ' Open temporary file for writing. + /// Dim stream As New ptr(Of FILE)() + /// _wfopen_s(stream.Value.Value, pathname, "w") + /// + /// ' Write op to temporary file, and assert that the number of bytes written is 6. + /// Assert.IsTrue(gmp_lib.mpz_out_str(stream, 10, op) = 6) + /// + /// ' Close temporary file. + /// fclose(stream.Value.Value) + /// + /// ' Assert that the content of the temporary file is "123456". + /// Dim result As String = System.IO.File.ReadAllText(pathname) + /// Assert.IsTrue(result = "123456") + /// + /// ' Delete temporary file. + /// System.IO.File.Delete(pathname) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static size_t mpz_out_str(ptr stream, int @base, /*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + if (IntPtr.Size == 4) + return new size_t(SafeNativeMethods.__gmpz_out_str_x86(stream.Value.Value, @base, op.ToIntPtr())); + else + return new size_t(SafeNativeMethods.__gmpz_out_str_x64(stream.Value.Value, @base, op.ToIntPtr())); + } + + /// + /// Return non-zero if is a perfect power, i.e., if there exist integers a and b, with b > 1, such that = a^b. + /// + /// The operand integer. + /// Non-zero if is a perfect power, i.e., if there exist integers a and b, with b > 1, such that = a^b. + /// + /// + /// Under this definition both 0 and 1 are considered to be perfect powers. Negative values of are accepted, but of course can only be odd perfect powers. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Roots + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_si(op, 10000); + /// + /// // Assert that op is a perfect power. + /// Assert.IsTrue(gmp_lib.mpz_perfect_power_p(op) > 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_si(op, 10000) + /// + /// ' Assert that op is a perfect power. + /// Assert.IsTrue(gmp_lib.mpz_perfect_power_p(op) > 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static int mpz_perfect_power_p(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_perfect_power_p(op.ToIntPtr()); + } + + /// + /// Return non-zero if is a perfect square, i.e., if the square root of is an integer. + /// + /// The operand integer. + /// Non-zero if is a perfect square, i.e., if the square root of is an integer. + /// + /// + /// Under this definition both 0 and 1 are considered to be perfect squares. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Roots + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_si(op, 10000); + /// + /// // Assert that op is a perfect square. + /// Assert.IsTrue(gmp_lib.mpz_perfect_square_p(op) > 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_si(op, 10000) + /// + /// ' Assert that op is a perfect square. + /// Assert.IsTrue(gmp_lib.mpz_perfect_square_p(op) > 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static int mpz_perfect_square_p(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_perfect_square_p(op.ToIntPtr()); + } + + /// + /// Return the population count of . + /// + /// The operand integer. + /// If ≥ 0, return the population count of , which is the number of 1 bits in the binary representation. If < 0, the number of 1s is infinite, and the return value is the largest possible . + /// + /// + /// The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + /// The least significant bit is number 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Logic and Bit Fiddling + /// + /// + /// // Create, initialize, and set the value of op to 63. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, 63U); + /// + /// // Assert that op has 6 one bits. + /// Assert.IsTrue(gmp_lib.mpz_popcount(op) == 6U); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clears(op); + /// + /// + /// ' Create, initialize, and set the value of op to 63. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, 63UI) + /// + /// ' Assert that op has 6 one bits. + /// Assert.IsTrue(gmp_lib.mpz_popcount(op) = 6UI) + /// + /// ' Release unmanaged memory allocated for op. + /// + /// + public static mp_bitcnt_t mpz_popcount(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return new mp_bitcnt_t(SafeNativeMethods.__gmpz_popcount(op.ToIntPtr())); + } + + /// + /// Set to ^. The case 0^0 yields 1. + /// + /// The result integer. + /// The base integer. + /// The exponent integer. + /// + /// + /// + /// + /// GNU MP - Integer Exponentiation + /// + /// + /// // Create, initialize, and set the value of base to 2. + /// mpz_t @base = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(@base, 2U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop = base^4. + /// gmp_lib.mpz_pow_ui(rop, @base, 4U); + /// + /// // Assert that rop is 16. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 16); + /// + /// // Release unmanaged memory allocated for rop and base. + /// gmp_lib.mpz_clears(rop, @base, null); + /// + /// + /// ' Create, initialize, and set the value of base to 2. + /// Dim base As New mpz_t() + /// gmp_lib.mpz_init_set_ui(base, 2UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop = base^4. + /// gmp_lib.mpz_pow_ui(rop, base, 4UI) + /// + /// ' Assert that rop is 16. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 16) + /// + /// ' Release unmanaged memory allocated for rop and base. + /// gmp_lib.mpz_clears(rop, base, Nothing) + /// + /// + public static void mpz_pow_ui(mpz_t rop, /*const*/ mpz_t @base, uint /*unsigned long int*/ exp) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (@base == null) throw new ArgumentNullException("base"); + SafeNativeMethods.__gmpz_pow_ui(rop.ToIntPtr(), @base.ToIntPtr(), exp); + } + + /// + /// Set to (^) modulo . + /// + /// The result integer. + /// The base integer. + /// The exponent integer. + /// The modulo integer. + /// + /// + /// Negative is supported if an inverse ^-1 modulo exists (see ). + /// If an inverse doesn’t exist then a divide by zero is raised. + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Exponentiation + /// + /// + /// // Create, initialize, and set the value of base to 2. + /// mpz_t @base = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(@base, 2U); + /// + /// // Create, initialize, and set the value of exp to 4. + /// mpz_t exp = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(exp, 4U); + /// + /// // Create, initialize, and set the value of mod to 3. + /// mpz_t mod = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(mod, 3U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop = base^exp mod mod. + /// gmp_lib.mpz_powm(rop, @base, exp, mod); + /// + /// // Assert that rop is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 1); + /// + /// // Release unmanaged memory allocated for rop, base, exp, and mod. + /// gmp_lib.mpz_clears(rop, @base, exp, mod, null); + /// + /// + /// ' Create, initialize, and set the value of base to 2. + /// Dim base As New mpz_t() + /// gmp_lib.mpz_init_set_ui(base, 2UI) + /// + /// ' Create, initialize, and set the value of exp to 4. + /// Dim exp As New mpz_t() + /// gmp_lib.mpz_init_set_ui(exp, 4UI) + /// + /// ' Create, initialize, and set the value of mod to 3. + /// Dim[mod] As New mpz_t() + /// gmp_lib.mpz_init_set_ui([mod], 3UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop = base^exp mod mod. + /// gmp_lib.mpz_powm(rop, base, exp, [mod]) + /// + /// ' Assert that rop is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 1) + /// + /// ' Release unmanaged memory allocated for rop, base, exp, and mod. + /// gmp_lib.mpz_clears(rop, base, exp, [mod], Nothing) + /// + /// + public static void mpz_powm(mpz_t rop, /*const*/ mpz_t @base, /*const*/ mpz_t exp, /*const*/ mpz_t mod) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (@base == null) throw new ArgumentNullException("base"); + if (exp == null) throw new ArgumentNullException("exp"); + if (mod == null) throw new ArgumentNullException("mod"); + SafeNativeMethods.__gmpz_powm(rop.ToIntPtr(), @base.ToIntPtr(), exp.ToIntPtr(), mod.ToIntPtr()); + } + + /// + /// Set to (^) modulo . + /// + /// The result integer. + /// The base integer. + /// The exponent integer. + /// The modulo integer. + /// + /// + /// It is required that > 0 and that is odd. + /// + /// + /// This function is designed to take the same time and have the same cache access patterns for any two same-size arguments, + /// assuming that function arguments are placed at the same position and that the machine state is identical upon function entry. + /// This function is intended for cryptographic purposes, where resilience to side-channel attacks is desired. + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Exponentiation + /// + /// + /// // Create, initialize, and set the value of base to 2. + /// mpz_t @base = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(@base, 2U); + /// + /// // Create, initialize, and set the value of exp to 4. + /// mpz_t exp = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(exp, 4U); + /// + /// // Create, initialize, and set the value of mod to 3. + /// mpz_t mod = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(mod, 3U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop = base^exp mod mod. + /// gmp_lib.mpz_powm_sec(rop, @base, exp, mod); + /// + /// // Assert that rop is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 1); + /// + /// // Release unmanaged memory allocated for rop, base, exp, and mod. + /// gmp_lib.mpz_clears(rop, @base, exp, mod, null); + /// + /// + /// ' Create, initialize, and set the value of base to 2. + /// Dim base As New mpz_t() + /// gmp_lib.mpz_init_set_ui(base, 2UI) + /// + /// ' Create, initialize, and set the value of exp to 4. + /// Dim exp As New mpz_t() + /// gmp_lib.mpz_init_set_ui(exp, 4UI) + /// + /// ' Create, initialize, and set the value of mod to 3. + /// Dim[mod] As New mpz_t() + /// gmp_lib.mpz_init_set_ui([mod], 3UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop = base^exp mod mod. + /// gmp_lib.mpz_powm_sec(rop, base, exp, [mod]) + /// + /// ' Assert that rop is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 1) + /// + /// ' Release unmanaged memory allocated for rop, base, exp, and mod. + /// gmp_lib.mpz_clears(rop, base, exp, [mod], Nothing) + /// + /// + public static void mpz_powm_sec(mpz_t rop, /*const*/ mpz_t @base, /*const*/ mpz_t exp, /*const*/ mpz_t mod) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (@base == null) throw new ArgumentNullException("base"); + if (exp == null) throw new ArgumentNullException("exp"); + if (mod == null) throw new ArgumentNullException("mod"); + SafeNativeMethods.__gmpz_powm_sec(rop.ToIntPtr(), @base.ToIntPtr(), exp.ToIntPtr(), mod.ToIntPtr()); + } + + /// + /// Set to (^) modulo . + /// + /// The result integer. + /// The base integer. + /// The exponent integer. + /// The modulo integer. + /// + /// + /// Negative is supported if an inverse ^-1 modulo exists (see ). + /// If an inverse doesn’t exist then a divide by zero is raised. + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Exponentiation + /// + /// + /// // Create, initialize, and set the value of base to 2. + /// mpz_t @base = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(@base, 2U); + /// + /// mpz_t mod = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(mod, 3U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop = base^4 mod mod. + /// gmp_lib.mpz_powm_ui(rop, @base, 4U, mod); + /// + /// // Assert that rop is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 1); + /// + /// // Release unmanaged memory allocated for rop, base, and mod. + /// gmp_lib.mpz_clears(rop, @base, mod, null); + /// + /// + /// ' Create, initialize, and set the value of base to 2. + /// Dim base As New mpz_t() + /// gmp_lib.mpz_init_set_ui(base, 2UI) + /// Dim[mod] As New mpz_t() + /// gmp_lib.mpz_init_set_ui([mod], 3UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop = base^4 mod mod. + /// gmp_lib.mpz_powm_ui(rop, base, 4UI, [mod]) + /// + /// ' Assert that rop is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 1) + /// + /// ' Release unmanaged memory allocated for rop, base, and mod. + /// gmp_lib.mpz_clears(rop, base, [mod], Nothing) + /// + /// + public static void mpz_powm_ui(mpz_t rop, /*const*/ mpz_t @base, uint /*unsigned long int*/ exp, /*const*/ mpz_t mod) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (@base == null) throw new ArgumentNullException("base"); + if (mod == null) throw new ArgumentNullException("mod"); + SafeNativeMethods.__gmpz_powm_ui(rop.ToIntPtr(), @base.ToIntPtr(), exp, mod.ToIntPtr()); + } + + /// + /// Determine whether is prime. + /// + /// The operand integer. + /// The number of Miller-Rabin probabilistic primality tests to perform. + /// Return 2 if is definitely prime, return 1 if is probably prime (without being certain), or return 0 if is definitely non-prime. + /// + /// + /// This function performs some trial divisions, then Miller-Rabin probabilistic primality tests. + /// A higher value will reduce the chances of a non-prime being identified as “probably prime”. + /// A composite number will be identified as a prime with a probability of less than 4^(-reps). + /// Reasonable values of are between 15 and 50. + /// + /// + /// + /// + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of n to 12. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(n, 12U); + /// + /// // Assert that n is a composite number. + /// Assert.IsTrue(gmp_lib.mpz_probab_prime_p(n, 25) == 0); + /// + /// // Release unmanaged memory allocated for n. + /// gmp_lib.mpz_clear(n); + /// + /// + /// ' Create, initialize, and set the value of n to 12. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_ui(n, 12UI) + /// + /// ' Assert that n is a composite number. + /// Assert.IsTrue(gmp_lib.mpz_probab_prime_p(n, 25) = 0) + /// + /// ' Release unmanaged memory allocated for n. + /// gmp_lib.mpz_clear(n) + /// + /// + public static int mpz_probab_prime_p(/*const*/ mpz_t n, int reps) + { + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_probab_prime_p(n.ToIntPtr(), reps); + } + + /// + /// Generate a random integer of at most limbs. + /// + /// The result integer. + /// The maximum number of limbs. + /// + /// + /// The generated random number doesn’t satisfy any particular requirements of randomness. + /// Negative random numbers are generated when is negative. + /// + /// + /// This function is obsolete. Use or instead. + /// + /// + /// The random number functions of GMP come in two groups; older function that rely on a global state, + /// and newer functions that accept a state parameter that is read and modified. + /// Please see the GNU MP - Random Number Functions + /// for more information on how to use and not to use random number functions. + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Random Numbers + /// + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Generate a random integer. + /// gmp_lib.mpz_random(rop, 500); + /// + /// // Free all memory occupied by state and rop. + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Generate a random integer. + /// gmp_lib.mpz_random(rop, 500) + /// + /// ' Free all memory occupied by state and rop. + /// gmp_lib.mpz_clear(rop) + /// + /// + public static void mpz_random(mpz_t rop, mp_size_t max_size) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_random(rop.ToIntPtr(), max_size); + } + + /// + /// Generate a random integer of at most limbs, with long strings of zeros and ones in the binary representation. + /// + /// The result integer. + /// The maximum number of limbs. + /// + /// + /// Useful for testing functions and algorithms, since this kind of random numbers have proven to be more likely to trigger corner-case bugs. + /// Negative random numbers are generated when is negative. + /// + /// + /// This function is obsolete. Use instead. + /// + /// + /// The random number functions of GMP come in two groups; older function that rely on a global state, + /// and newer functions that accept a state parameter that is read and modified. + /// Please see the GNU MP - Random Number Functions + /// for more information on how to use and not to use random number functions. + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Random Numbers + /// + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Generate a random integer. + /// gmp_lib.mpz_random(rop, 100); + /// + /// // Free all memory occupied by rop. + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Generate a random integer. + /// gmp_lib.mpz_random(rop, 100) + /// + /// ' Free all memory occupied by rop. + /// gmp_lib.mpz_clear(rop) + /// + /// + public static void mpz_random2(mpz_t rop, mp_size_t max_size) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_random2(rop.ToIntPtr(), max_size); + } + + /// + /// Change the space allocated for to bits. + /// + /// The integer. + /// The number of bits. + /// + /// + /// The value in is preserved if it fits, or is set to 0 if not. + /// + /// + /// Calling this function is never necessary; reallocation is handled automatically by GMP when + /// needed. But this function can be used to increase the space for a variable in order to avoid + /// repeated automatic reallocations, or to decrease it to give memory back to the heap. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Integers + /// + /// + /// // Create and initialize new integer x. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// + /// // Set the value of x to a 77-bit integer. + /// char_ptr value = new char_ptr("1000 0000 0000 0000 0000"); + /// gmp_lib.mpz_set_str(x, value, 16); + /// + /// // Resize x to 512 bits, and assert that its value has not changed. + /// gmp_lib.mpz_realloc2(x, 512U); + /// char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 16, x); + /// Assert.IsTrue(s.ToString() == "1000 0000 0000 0000 0000".Replace(" ", "")); + /// + /// // Resize x to 2 bits, and assert that its value has changed to 0. + /// gmp_lib.mpz_realloc2(x, 2U); + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) == 0); + /// + /// // Release unmanaged memory allocated for x and string values. + /// gmp_lib.mpz_clear(x); + /// gmp_lib.free(value); + /// gmp_lib.free(s); + /// + /// + /// ' Create and initialize new integer x. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init(x) + /// + /// ' Set the value of x to a 77-bit integer. + /// Dim value As New char_ptr("1000 0000 0000 0000 0000") + /// gmp_lib.mpz_set_str(x, value, 16) + /// + /// ' Resize x to 512 bits, and assert that its value has not changed. + /// gmp_lib.mpz_realloc2(x, 512UI) + /// Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 16, x) + /// Assert.IsTrue(s.ToString() = "1000 0000 0000 0000 0000".Replace(" ", "")) + /// + /// ' Resize x to 2 bits, and assert that its value has changed to 0. + /// gmp_lib.mpz_realloc2(x, 2UI) + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) = 0) + /// + /// ' Release unmanaged memory allocated for x and string values. + /// gmp_lib.mpz_clear(x) + /// gmp_lib.free(value) + /// gmp_lib.free(s) + /// + /// + public static void mpz_realloc2(mpz_t x, mp_bitcnt_t n) + { + if (x == null) throw new ArgumentNullException("x"); + SafeNativeMethods.__gmpz_realloc2(x.ToIntPtr(), n); + } + + /// + /// Remove all occurrences of the factor from and store the result in . + /// + /// The result integer. + /// The operand integer. + /// The factor operand integer. + /// The return value is how many such occurrences were removed. + /// GNU MP - Number Theoretic Functions + /// + /// + /// // Create, initialize, and set the value of op to 45. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, 45U); + /// + /// // Create, initialize, and set the value of f to 3. + /// mpz_t f = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(f, 3U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop = op / f^n, and return n, the largest integer greater than or equal to 0, such that f^n divides op. + /// Assert.IsTrue(gmp_lib.mpz_remove(rop, op, f) == 2); + /// + /// // Assert that rop is 5. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 5); + /// + /// // Release unmanaged memory allocated for rop, op, and f. + /// gmp_lib.mpz_clears(rop, op, f, null); + /// + /// + /// ' Create, initialize, and set the value of op to 45. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, 45UI) + /// + /// ' Create, initialize, and set the value of f to 3. + /// Dim f As New mpz_t() + /// gmp_lib.mpz_init_set_ui(f, 3UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop = op / f^n, and return n, the largest integer greater than or equal to 0, such that f^n divides op. + /// Assert.IsTrue(gmp_lib.mpz_remove(rop, op, f) = 2) + /// + /// ' Assert that rop is 5. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 5) + /// + /// ' Release unmanaged memory allocated for rop, op, and f. + /// gmp_lib.mpz_clears(rop, op, f, Nothing) + /// + /// + public static mp_bitcnt_t mpz_remove(mpz_t rop, /*const*/ mpz_t op, /*const*/ mpz_t f) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + if (f == null) throw new ArgumentNullException("f"); + return new mp_bitcnt_t(SafeNativeMethods.__gmpz_remove(rop.ToIntPtr(), op.ToIntPtr(), f.ToIntPtr())); + } + + /// + /// Set to the truncated integer part of the th root of . + /// + /// The result root integer. + /// The first operand integer. + /// The second operand integer. + /// Return non-zero if the computation was exact, i.e., if is to the th power. + /// + /// + /// + /// + /// + /// GNU MP - Integer Roots + /// + /// + /// // Create, initialize, and set the value of op to 10000. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_si(op, 10000); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop = trunc(cbrt(10000)). + /// gmp_lib.mpz_root(rop, op, 3U); + /// + /// // Assert that rop is 21. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 21); + /// + /// // Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clears(rop, op, null); + /// + /// + /// ' Create, initialize, and set the value of op to 10000. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_si(op, 10000) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop = trunc(cbrt(10000)). + /// gmp_lib.mpz_root(rop, op, 3UI) + /// + /// ' Assert that rop is 21. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 21) + /// + /// ' Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clears(rop, op, Nothing) + /// + /// + public static int mpz_root(mpz_t rop, /*const*/ mpz_t op, uint /*unsigned long int*/ n) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_root(rop.ToIntPtr(), op.ToIntPtr(), n); + } + + /// + /// Set to the truncated integer part of the th root of . Set to the remainder, - ^. + /// + /// The result root integer. + /// The result remainder integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// + /// + /// + /// GNU MP - Integer Roots + /// + /// + /// // Create, initialize, and set the value of u to 10000. + /// mpz_t u = new mpz_t(); + /// gmp_lib.mpz_init_set_si(u, 10000); + /// + /// // Create, initialize, and set the values of root and rem to 0. + /// mpz_t root = new mpz_t(); + /// mpz_t rem = new mpz_t(); + /// gmp_lib.mpz_inits(root, rem, null); + /// + /// // Set root = trunc(cbrt(10000)) and rem = u - root. + /// gmp_lib.mpz_rootrem(root, rem, u, 3U); + /// + /// // Assert that root is 21, and rem is 739. + /// Assert.IsTrue(gmp_lib.mpz_get_si(root) == 21); + /// Assert.IsTrue(gmp_lib.mpz_get_si(rem) == 739); + /// + /// // Release unmanaged memory allocated for root, rem, and u. + /// gmp_lib.mpz_clears(root, rem, u, null); + /// + /// + /// ' Create, initialize, and set the value of u to 10000. + /// Dim u As New mpz_t() + /// gmp_lib.mpz_init_set_si(u, 10000) + /// + /// ' Create, initialize, and set the values of root and rem to 0. + /// Dim root As New mpz_t() + /// Dim[rem] As New mpz_t() + /// gmp_lib.mpz_inits(root, [rem], Nothing) + /// + /// ' Set root = trunc(cbrt(10000)) and rem = u - root. + /// gmp_lib.mpz_rootrem(root, [rem], u, 3UI) + /// + /// ' Assert that root is 21, and rem is 739. + /// Assert.IsTrue(gmp_lib.mpz_get_si(root) = 21) + /// Assert.IsTrue(gmp_lib.mpz_get_si([rem]) = 739) + /// + /// ' Release unmanaged memory allocated for root, rem, and u. + /// gmp_lib.mpz_clears(root, [rem], u, Nothing) + /// + /// + public static void mpz_rootrem(mpz_t root, mpz_t rem, /*const*/ mpz_t u, uint /*unsigned long int*/ n) + { + if (root == null) throw new ArgumentNullException("root"); + if (rem == null) throw new ArgumentNullException("rem"); + if (u == null) throw new ArgumentNullException("u"); + SafeNativeMethods.__gmpz_rootrem(root.ToIntPtr(), rem.ToIntPtr(), u.ToIntPtr(), n); + } + + /// + /// Generate a random integer with long strings of zeros and ones in the binary representation. + /// + /// The result integer. + /// The random number generator state. + /// The operand integer. + /// + /// + /// Useful for testing functions and algorithms, since this kind of random numbers have proven to be more + /// likely to trigger corner-case bugs. The random number will be in the + /// range 2^( - 1) to 2^ - 1, inclusive. + /// + /// + /// The variable must be initialized by calling one of the gmp_randinit + /// functions (GNU MP - Random State Initialization) before invoking this function. + /// + /// + /// The random number functions of GMP come in two groups; older function that rely on a global state, + /// and newer functions that accept a state parameter that is read and modified. + /// Please see the GNU MP - Random Number Functions + /// for more information on how to use and not to use random number functions. + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Random Numbers + /// + /// + /// // Create, initialize, and seed a new random number generator. + /// gmp_randstate_t state = new gmp_randstate_t(); + /// gmp_lib.gmp_randinit_mt(state); + /// gmp_lib.gmp_randseed_ui(state, 100000U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Generate a random integer in the range [2^(50-1), (2^50)-1]. + /// gmp_lib.mpz_rrandomb(rop, state, 50); + /// + /// // Free all memory occupied by state and rop. + /// gmp_lib.gmp_randclear(state); + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and seed a new random number generator. + /// Dim state As New gmp_randstate_t() + /// gmp_lib.gmp_randinit_mt(state) + /// gmp_lib.gmp_randseed_ui(state, 100000UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Generate a random integer in the range [2^(50-1), (2^50)-1]. + /// gmp_lib.mpz_rrandomb(rop, state, 50) + /// + /// ' Free all memory occupied by state and rop. + /// gmp_lib.gmp_randclear(state) + /// gmp_lib.mpz_clear(rop) + /// + /// + public static void mpz_rrandomb(mpz_t rop, gmp_randstate_t state, mp_bitcnt_t n) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (state == null) throw new ArgumentNullException("state"); + SafeNativeMethods.__gmpz_rrandomb(rop.ToIntPtr(), state.ToIntPtr(), n); + } + + /// + /// Scan for 0 bit. + /// + /// The operand integer. + /// The start bit index position. + /// Return the index of the found bit. + /// + /// + /// Scan , starting from bit , towards more significant bits, + /// until the first 0 bit is found. Return the index of the found bit. + /// + /// + /// If the bit at is already what’s sought, + /// then is returned. + /// + /// + /// If there’s no bit found, then the largest possible is returned. + /// This will happen in past the end of a negative number, + /// or past the end of a nonnegative number. + /// + /// + /// The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + /// The least significant bit is number 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Logic and Bit Fiddling + /// + /// + /// // Create, initialize, and set the value of op to 70. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, 70U); + /// + /// // Assert that the first 0 bit starting from bit 1 in op is bit 3. + /// Assert.IsTrue(gmp_lib.mpz_scan0(op, 1U) == 3U); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to 70. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, 70UI) + /// + /// ' Assert that the first 0 bit starting from bit 1 in op is bit 3. + /// Assert.IsTrue(gmp_lib.mpz_scan0(op, 1UI) = 3UI) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static mp_bitcnt_t mpz_scan0(/*const*/ mpz_t op, mp_bitcnt_t starting_bit) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_scan0(op.ToIntPtr(), starting_bit); + } + + /// + /// Scan for 1 bit. + /// + /// The operand integer. + /// The start bit index position. + /// Return the index of the found bit. + /// + /// + /// Scan , starting from bit , towards more significant bits, + /// until the first 1 bit is found. Return the index of the found bit. + /// + /// + /// If the bit at is already what’s sought, + /// then is returned. + /// + /// + /// If there’s no bit found, then the largest possible is returned. + /// This will happen in past the end of a negative number, + /// or past the end of a nonnegative number. + /// + /// + /// The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + /// The least significant bit is number 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Logic and Bit Fiddling + /// + /// + /// // Create, initialize, and set the value of op to 70. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op, 70U); + /// + /// // Assert that the first 1 bit starting from bit 3 in op is bit 6. + /// Assert.IsTrue(gmp_lib.mpz_scan1(op, 3U) == 6U); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to 70. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op, 70UI) + /// + /// ' Assert that the first 1 bit starting from bit 3 in op is bit 6. + /// Assert.IsTrue(gmp_lib.mpz_scan1(op, 3UI) = 6UI) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static mp_bitcnt_t mpz_scan1(/*const*/ mpz_t op, mp_bitcnt_t starting_bit) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_scan1(op.ToIntPtr(), starting_bit); + } + + /// + /// Set the value of from . + /// + /// The destination integer. + /// The source integer. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Integers + /// + /// + /// // Create, initialize, and set a new integer x to 10. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// gmp_lib.mpz_set_si(x, 10); + /// + /// // Create, initialize, and set a new integer y to -210. + /// mpz_t y = new mpz_t(); + /// gmp_lib.mpz_init(y); + /// gmp_lib.mpz_set_si(y, -210); + /// + /// // Assign the value of y to x. + /// gmp_lib.mpz_set(x, y); + /// + /// // Assert that the value of x is -210. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) == -210); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpz_clears(x, y, null); + /// + /// + /// ' Create, initialize, and set a new integer x to 10. + /// Dim x As New mpz_t() + /// + /// gmp_lib.mpz_init(x) + /// gmp_lib.mpz_set_si(x, 10) + /// + /// ' Create, initialize, and set a new integer y to -210. + /// Dim y As New mpz_t() + /// gmp_lib.mpz_init(y) + /// gmp_lib.mpz_set_si(y, -210) + /// + /// ' Assign the value of y to x. + /// gmp_lib.mpz_set(x, y) + /// + /// ' Assert that the value of x is -210. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) = -210) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpz_clears(x, y, Nothing) + /// + /// + public static void mpz_set(mpz_t rop, /*const*/ mpz_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpz_set(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set the value of from . + /// + /// The destination integer. + /// The source integer. + /// + /// + /// truncate to make it an integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Integers + /// + /// + /// // Create and initialize a new integer x. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// + /// // Set the value of x to the truncation of 10.7. + /// gmp_lib.mpz_set_d(x, 10.7D); + /// + /// // Assert that the value of x is 10. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) == 10); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create and initialize a new integer x. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init(x) + /// + /// ' Set the value of x to the truncation of 10.7. + /// gmp_lib.mpz_set_d(x, 10.7) + /// + /// ' Assert that the value of x is 10. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) = 10) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static void mpz_set_d(mpz_t rop, double op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_set_d(rop.ToIntPtr(), op); + } + + /// + /// Set the value of from . + /// + /// The destination integer. + /// The source integer. + /// + /// + /// truncate to make it an integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Integers + /// + /// + /// // Create and initialize new integer x, and float y. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// mpf_t y = "1.7007e3"; + /// + /// // Set the value of x to the truncation of 1700.7. + /// gmp_lib.mpz_set_f(x, y); + /// + /// // Assert that the value of x is 1700. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) == 1700); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpz_clear(x); + /// gmp_lib.mpf_clear(y); + /// + /// + /// ' Create and initialize new integer x, and float y. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init(x) + /// Dim y As mpf_t = "1.7007e3" + /// + /// ' Set the value of x to the truncation of 1700.7. + /// gmp_lib.mpz_set_f(x, y) + /// + /// ' Assert that the value of x is 1700. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) = 1700) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpz_clear(x) + /// gmp_lib.mpf_clear(y) + /// + /// + public static void mpz_set_f(mpz_t rop, /*const*/ mpf_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_set_f(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set the value of from . + /// + /// The destination integer. + /// The source integer. + /// + /// + /// truncate to make it an integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Integers + /// + /// + /// // Create and initialize new integer x, and rational y. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// mpq_t y = "100/3"; + /// + /// // Set the value of x to the truncation of 100/3. + /// gmp_lib.mpz_set_q(x, y); + /// + /// // Assert that the value of x is 33. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) == 33); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpz_clear(x); + /// gmp_lib.mpq_clear(y); + /// + /// + /// ' Create and initialize new integer x, and rational y. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init(x) + /// Dim y As mpq_t = "100/3" + /// + /// ' Set the value of x to the truncation of 100/3. + /// gmp_lib.mpz_set_q(x, y) + /// + /// ' Assert that the value of x is 33. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) = 33) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpz_clear(x) + /// gmp_lib.mpq_clear(y) + /// + /// + public static void mpz_set_q(mpz_t rop, /*const*/ mpq_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_set_q(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set the value of from . + /// + /// The destination integer. + /// The source integer. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Integers + /// + /// + /// // Create and initialize a new integer x. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// + /// // Set the value of x to -10. + /// gmp_lib.mpz_set_si(x, -10); + /// + /// // Assert that the value of x is -10. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) == -10); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create and initialize a new integer x. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init(x) + /// + /// ' Set the value of x to -10. + /// gmp_lib.mpz_set_si(x, -10) + /// + /// ' Assert that the value of x is -10. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) = -10) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static void mpz_set_si(mpz_t rop, int /*long int*/ op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_set_si(rop.ToIntPtr(), op); + } + + /// + /// Set the value of from , a null-terminated C string in base . + /// + /// The destination integer. + /// The source integer. + /// The base. + /// This function returns 0 if the entire string is a valid number in base . Otherwise it returns −1. + /// + /// + /// White space is allowed in the string, and is simply ignored. + /// + /// + /// The base may vary from 2 to 62, or if base is 0, then the leading characters are + /// used: 0x and 0X for hexadecimal, 0b and 0B for binary, 0 for octal, + /// or decimal otherwise. + /// + /// + /// For bases up to 36, case is ignored; upper-case and lower-case letters have the same value. + /// For bases 37 to 62, upper-case letter represent the usual 10..35 while lower-case + /// letter represent 36..61. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Integers + /// + /// + /// // Create and initialize a new integer x. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// + /// // Set the value of x. + /// char_ptr value = new char_ptr("12 345 678 909 876 543 211 234 567 890 987 654 321"); + /// gmp_lib.mpz_set_str(x, value, 10); + /// + /// // Assert the value of x. + /// char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x); + /// Assert.IsTrue(s.ToString() == value.ToString().Replace(" ", "")); + /// + /// // Release unmanaged memory allocated for x and string values. + /// gmp_lib.mpz_clear(x); + /// gmp_lib.free(value); + /// gmp_lib.free(s); + /// + /// + /// ' Create and initialize a new integer x. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init(x) + /// + /// ' Set the value of x. + /// Dim value As New char_ptr("12 345 678 909 876 543 211 234 567 890 987 654 321") + /// gmp_lib.mpz_set_str(x, value, 10) + /// + /// ' Assert the value of x. + /// Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x) + /// Assert.IsTrue(s.ToString() = value.ToString().Replace(" ", "")) + /// + /// ' Release unmanaged memory allocated for x and string values. + /// gmp_lib.mpz_clear(x) + /// gmp_lib.free(value) + /// gmp_lib.free(s) + /// + /// + public static int mpz_set_str(mpz_t rop, /*const*/ char_ptr str, int @base) + { + if (rop == null) throw new ArgumentNullException("rop"); + return SafeNativeMethods.__gmpz_set_str(rop.ToIntPtr(), str.ToIntPtr(), @base); + } + + /// + /// Set the value of from . + /// + /// The destination integer. + /// The source integer. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Integers + /// + /// + /// // Create and initialize a new integer x. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// + /// // Set the value of x to 10. + /// gmp_lib.mpz_set_ui(x, 10U); + /// + /// // Assert that the value of x is 10. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 10U); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x); + /// + /// + /// ' Create and initialize a new integer x. + /// Dim x As New mpz_t() + /// + /// gmp_lib.mpz_init(x) + /// + /// ' Set the value of x to 10. + /// gmp_lib.mpz_set_ui(x, 10UI) + /// + /// ' Assert that the value of x is 10. + /// Assert.IsTrue(gmp_lib.mpz_get_ui(x) = 10UI) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpz_clear(x) + /// + /// + public static void mpz_set_ui(mpz_t rop, uint /*unsigned long int*/ op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_set_ui(rop.ToIntPtr(), op); + } + + /// + /// Set bit in . + /// + /// The result integer. + /// The index of the bit to set. + /// + /// + /// The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + /// The least significant bit is number 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Logic and Bit Fiddling + /// + /// + /// // Create, initialize, and set the value of rop to 70. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init_set_si(rop, 70); + /// + /// // Set bit 3 of rop. + /// gmp_lib.mpz_setbit(rop, 3U); + /// + /// // Assert that rop is 78. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 78); + /// + /// // Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and set the value of rop to 70. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init_set_si(rop, 70) + /// + /// ' Set bit 3 of rop. + /// gmp_lib.mpz_setbit(rop, 3UI) + /// + /// ' Assert that rop is 78. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 78) + /// + /// ' Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop) + /// + /// + public static void mpz_setbit(mpz_t rop, mp_bitcnt_t bit_index) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_setbit(rop.ToIntPtr(), bit_index); + } + + /// + /// Return +1 if > 0, 0 if = 0, and -1 if < 0. + /// + /// The operand integer. + /// Return +1 if > 0, 0 if = 0, and -1 if < 0. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Comparisons + /// + /// + /// // Create, initialize, and set the value of op to -10. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_si(op, -10); + /// + /// // Assert that the sign of op is -1. + /// Assert.IsTrue(gmp_lib.mpz_sgn(op) == -1); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to -10. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_si(op, -10) + /// + /// ' Assert that the sign of op is -1. + /// Assert.IsTrue(gmp_lib.mpz_sgn(op) = -1) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static int mpz_sgn(mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return op._mp_size < 0 ? -1 : (op._mp_size > 0 ? 1 : 0); + } + + /// + /// Return the size of measured in number of limbs. + /// + /// The operand integer. + /// The size of measured in number of limbs. + /// + /// + /// If is zero, the returned value will be zero. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Special Functions + /// + /// + /// // Create and initialize new integer x. + /// mpz_t op = new mpz_t(); + /// char_ptr value = new char_ptr("1000 ABCD 1234 7AB8 24FD"); + /// gmp_lib.mpz_init_set_str(op, value, 16); + /// + /// // Assert the value of the limbs of op. + /// if (gmp_lib.mp_bytes_per_limb == 4) + /// Assert.IsTrue(gmp_lib.mpz_size(op) == 3); + /// else // gmp_lib.mp_bytes_per_limb == 8 + /// Assert.IsTrue(gmp_lib.mpz_size(op) == 2); + /// + /// // Release unmanaged memory allocated for op and value. + /// gmp_lib.mpz_clear(op); + /// gmp_lib.free(value); + /// + /// + /// ' Create and initialize new integer x. + /// Dim op As New mpz_t() + /// Dim value As New char_ptr("1000 ABCD 1234 7AB8 24FD") + /// gmp_lib.mpz_init_set_str(op, value, 16) + /// + /// ' Assert the value of the limbs of op. + /// If gmp_lib.mp_bytes_per_limb = 4 Then + /// Assert.IsTrue(gmp_lib.mpz_size(op) = 3) + /// Else ' gmp_lib.mp_bytes_per_limb == 8 + /// Assert.IsTrue(gmp_lib.mpz_size(op) = 2) + /// End If + /// + /// ' Release unmanaged memory allocated for op and value. + /// gmp_lib.mpz_clear(op) + /// gmp_lib.free(value) + /// + /// + public static mp_size_t mpz_size(/*const*/ mpz_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return new mp_size_t(SafeNativeMethods.__gmpz_size(op.ToIntPtr())); + } + + /// + /// Return the size of measured in number of digits in the given . + /// + /// The operand integer + /// The base. + /// The size of measured in number of digits in the given . + /// + /// + /// can vary from 2 to 62. + /// The sign of is ignored, just the absolute value is used. + /// The result will be either exact or 1 too big. + /// If is a power of 2, the result is always exact. + /// If is zero the return value is always 1. + /// + /// + /// This function can be used to determine the space required when converting to a string. + /// The right amount of allocation is normally two more than the value returned by , + /// one extra for a minus sign and one for the null-terminator. + /// + /// + /// It will be noted that mpz_sizeinbase(, 2) can be used to locate the most + /// significant 1 bit in , counting from 1. + /// (Unlike the bitwise functions which start from 0, + /// see GNU MP - Logical and Bit Manipulation Functions.) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Integer Functions + /// + /// + /// // Create, initialize, and set the value of op to 10000. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_si(op, 10000); + /// + /// // Assert size in different bases. + /// Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 2) == 14); + /// Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 8) == 5); + /// Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 10) == 5); + /// Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 16) == 4); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to 10000. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_si(op, 10000) + /// + /// ' Assert size in different bases. + /// Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 2) = 14) + /// Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 8) = 5) + /// Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 10) = 5) + /// Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 16) = 4) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpz_clear(op) + /// + /// + public static size_t mpz_sizeinbase(/*const*/ mpz_t op, int @base) + { + if (op == null) throw new ArgumentNullException("op"); + if (IntPtr.Size == 4) + return new size_t(SafeNativeMethods.__gmpz_sizeinbase_x86(op.ToIntPtr(), @base)); + else + return new size_t(SafeNativeMethods.__gmpz_sizeinbase_x64(op.ToIntPtr(), @base)); + } + + /// + /// Set to the truncated integer part of the square root of . + /// + /// The result square root integer. + /// The operand integer. + /// + /// + /// + /// + /// + /// GNU MP - Integer Roots + /// + /// + /// // Create, initialize, and set the value of op to 10000. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_si(op, 10000); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop = trunc(sqrt(op)). + /// gmp_lib.mpz_sqrt(rop, op); + /// + /// // Assert that rop is 100. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 100); + /// + /// // Release unmanaged memory allocated for rop and op. + /// gmp_lib.mpz_clears(rop, op, null); + /// + /// + /// ' Create, initialize, and set the value of op to 10000. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_si(op, 10000) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop = trunc(sqrt(op)). + /// gmp_lib.mpz_sqrt(rop, op) + /// + /// ' Assert that rop is 100. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 100) + /// + /// ' Release unmanaged memory allocated for rop and op. + /// gmp_lib.mpz_clears(rop, op, Nothing) + /// + /// + public static void mpz_sqrt(mpz_t rop, /*const*/ mpz_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpz_sqrt(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set to the truncated integer part of the square root of , like . Set to the remainder - * , which will be zero if is a perfect square. + /// + /// The result square root integer. + /// The result remainder integer. + /// The operand integer. + /// + /// + /// + /// + /// + /// GNU MP - Integer Roots + /// + /// + /// // Create, initialize, and set the value of op to 10000. + /// mpz_t op = new mpz_t(); + /// gmp_lib.mpz_init_set_si(op, 10000); + /// + /// // Create, initialize, and set the values of root and rem to 0. + /// mpz_t root = new mpz_t(); + /// mpz_t rem = new mpz_t(); + /// gmp_lib.mpz_inits(root, rem); + /// + /// // Set root = trunc(sqrt(op)), and rem = op - root. + /// gmp_lib.mpz_sqrtrem(root, rem, op); + /// + /// // Assert that root is 100, and rem is 0. + /// Assert.IsTrue(gmp_lib.mpz_get_si(root) == 100); + /// Assert.IsTrue(gmp_lib.mpz_get_si(rem) == 0); + /// + /// // Release unmanaged memory allocated for root, rem, and op. + /// gmp_lib.mpz_clears(root, rem, op, null); + /// + /// + /// ' Create, initialize, and set the value of op to 10000. + /// Dim op As New mpz_t() + /// gmp_lib.mpz_init_set_si(op, 10000) + /// + /// ' Create, initialize, and set the values of root and rem to 0. + /// Dim root As New mpz_t() + /// Dim[rem] As New mpz_t() + /// gmp_lib.mpz_inits(root, [rem]) + /// + /// ' Set root = trunc(sqrt(op)), and rem = op - root. + /// gmp_lib.mpz_sqrtrem(root, [rem], op) + /// + /// ' Assert that root is 100, and rem is 0. + /// Assert.IsTrue(gmp_lib.mpz_get_si(root) = 100) + /// Assert.IsTrue(gmp_lib.mpz_get_si([rem]) = 0) + /// + /// ' Release unmanaged memory allocated for root, rem, and op. + /// gmp_lib.mpz_clears(root, [rem], op, Nothing) + /// + /// + public static void mpz_sqrtrem(mpz_t rop1, mpz_t rop2, /*const*/ mpz_t op) + { + if (rop1 == null) throw new ArgumentNullException("rop1"); + if (rop2 == null) throw new ArgumentNullException("rop2"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpz_sqrtrem(rop1.ToIntPtr(), rop2.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set to - . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10000U); + /// + /// // Create, initialize, and set the value of y to 12222. + /// mpz_t y = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(y, 12222U); + /// + /// // Create, initialize, and set the value of z to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = x - y. + /// gmp_lib.mpz_sub(z, x, y); + /// + /// // Assert that z = x - y. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == -2222); + /// + /// // Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpz_clears(x, y, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10000UI) + /// + /// ' Create, initialize, and set the value of y to 12222. + /// Dim y As New mpz_t() + /// gmp_lib.mpz_init_set_ui(y, 12222UI) + /// + /// ' Create, initialize, and set the value of z to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = x - y. + /// gmp_lib.mpz_sub(z, x, y) + /// + /// ' Assert that z = x - y. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = -2222) + /// + /// ' Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpz_clears(x, y, z, Nothing) + /// + /// + public static void mpz_sub(mpz_t rop, /*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpz_sub(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Set to - . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10000U); + /// + /// // Create, initialize, and set the value of z to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = x - 12222. + /// gmp_lib.mpz_sub_ui(z, x, 12222U); + /// + /// // Assert that z = x - 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == -2222); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10000UI) + /// + /// ' Create, initialize, and set the value of z to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = x - 12222. + /// gmp_lib.mpz_sub_ui(z, x, 12222UI) + /// + /// ' Assert that z = x - 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = -2222) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, Nothing) + /// + /// + public static void mpz_sub_ui(mpz_t rop, /*const*/ mpz_t op1, uint /*unsigned long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpz_sub_ui(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Set to - . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10000U); + /// + /// // Create, initialize, and set the value of z to 0. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init(z); + /// + /// // Set z = 12222 - x. + /// gmp_lib.mpz_ui_sub(z, 12222U, x); + /// + /// // Assert that z = 12222 - x. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == 2222); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10000UI) + /// + /// ' Create, initialize, and set the value of z to 0. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init(z) + /// + /// ' Set z = 12222 - x. + /// gmp_lib.mpz_ui_sub(z, 12222UI, x) + /// + /// ' Assert that z = 12222 - x. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = 2222) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, Nothing) + /// + /// + public static void mpz_ui_sub(mpz_t rop, uint /*unsigned long int*/ op1, /*const*/ mpz_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpz_ui_sub(rop.ToIntPtr(), op1, op2.ToIntPtr()); + } + + /// + /// Set to - * . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to 10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 10000U); + /// + /// // Create, initialize, and set the value of y to 12222. + /// mpz_t y = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(y, 12222U); + /// + /// // Create, initialize, and set the value of z to 20000. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init_set_si(z, 20000); + /// + /// // Set z -= x * y. + /// gmp_lib.mpz_submul(z, x, y); + /// + /// // Assert that z has been decremented by 10000 * 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000 - 10000 * 12222); + /// + /// // Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpz_clears(x, y, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to 10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 10000UI) + /// + /// ' Create, initialize, and set the value of y to 12222. + /// Dim y As New mpz_t() + /// gmp_lib.mpz_init_set_ui(y, 12222UI) + /// + /// ' Create, initialize, and set the value of z to 20000. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init_set_si(z, 20000) + /// + /// ' Set z -= x * y. + /// gmp_lib.mpz_submul(z, x, y) + /// + /// ' Assert that z has been decremented by 10000 * 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = 20000 - 10000 * 12222) + /// + /// ' Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpz_clears(x, y, z, Nothing) + /// + /// + public static void mpz_submul(mpz_t rop, /*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpz_submul(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Set to - * . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Arithmetic + /// + /// + /// // Create, initialize, and set the value of x to -10000. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_si(x, -10000); + /// + /// // Create, initialize, and set the value of z to 20000. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init_set_si(z, 20000); + /// + /// // Set z -= x * 12222U. + /// gmp_lib.mpz_submul_ui(z, x, 12222U); + /// + /// // Assert that z has been decremented by -10000 * 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000 - -10000 * 12222); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, null); + /// + /// + /// ' Create, initialize, and set the value of x to -10000. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_si(x, -10000) + /// + /// ' Create, initialize, and set the value of z to 20000. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init_set_si(z, 20000) + /// + /// ' Set z -= x * 12222U. + /// gmp_lib.mpz_submul_ui(z, x, 12222UI) + /// + /// ' Assert that z has been decremented by -10000 * 12222. + /// Assert.IsTrue(gmp_lib.mpz_get_si(z) = 20000 - -10000 * 12222) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpz_clears(x, z, Nothing) + /// + /// + public static void mpz_submul_ui(mpz_t rop, /*const*/ mpz_t op1, uint /*unsigned long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpz_submul_ui(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Swap the values and efficiently. + /// + /// The first integer. + /// The second integer. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Integers + /// + /// + /// // Create, initialize, and set a new integer x to 10. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_si(x, 10); + /// + /// // Create, initialize, and set a new integer x to -210. + /// mpz_t y = new mpz_t(); + /// gmp_lib.mpz_init_set_si(y, -210); + /// + /// // Swap the values of x and y. + /// gmp_lib.mpz_swap(x, y); + /// + /// // Assert that the values have been swapped. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) == -210); + /// Assert.IsTrue(gmp_lib.mpz_get_si(y) == 10); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpz_clears(x, y, null); + /// + /// + /// ' Create, initialize, and set a new integer x to 10. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_si(x, 10) + /// + /// ' Create, initialize, and set a new integer x to -210. + /// Dim y As New mpz_t() + /// gmp_lib.mpz_init_set_si(y, -210) + /// + /// ' Swap the values of x and y. + /// gmp_lib.mpz_swap(x, y) + /// + /// ' Assert that the values have been swapped. + /// Assert.IsTrue(gmp_lib.mpz_get_si(x) = -210) + /// Assert.IsTrue(gmp_lib.mpz_get_si(y) = 10) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpz_clears(x, y, Nothing) + /// + /// + public static void mpz_swap(mpz_t rop1, mpz_t rop2) + { + if (rop1 == null) throw new ArgumentNullException("rop1"); + if (rop2 == null) throw new ArgumentNullException("rop2"); + SafeNativeMethods.__gmpz_swap(rop1.ToIntPtr(), rop2.ToIntPtr()); + } + + /// + /// Return the remainder |r| where r = - q * , and where q = trunc( / ). + /// + /// The numerator integer. + /// The denominator integer. + /// The remainder |r| where r = - q * , and where q = trunc( / ). + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Assert that returned value is |n - 3 * trunc(n / 3)|. + /// Assert.IsTrue(gmp_lib.mpz_tdiv_ui(n, 3U) == 1U); + /// + /// // Release unmanaged memory allocated for n. + /// gmp_lib.mpz_clear(n); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Assert that returned value is |n - 3 * trunc(n / 3)|. + /// Assert.IsTrue(gmp_lib.mpz_tdiv_ui(n, 3UI) = 1UI) + /// + /// ' Release unmanaged memory allocated for n. + /// gmp_lib.mpz_clear(n) + /// + /// + public static uint /*unsigned long int*/ mpz_tdiv_ui(/*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_tdiv_ui(n.ToIntPtr(), d); + } + + /// + /// Set the quotient to trunc( / ). + /// + /// The result quotient integer. + /// The numerator integer. + /// The denominator integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of d to 3. + /// mpz_t d = new mpz_t(); + /// gmp_lib.mpz_init_set_si(d, 3); + /// + /// // Create, initialize, and set the value of q to 0. + /// mpz_t q = new mpz_t(); + /// gmp_lib.mpz_init(q); + /// + /// // Set q = trunc(n / d). + /// gmp_lib.mpz_tdiv_q(q, n, d); + /// + /// // Assert that q is trunc(10000 / 3). + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + /// + /// // Release unmanaged memory allocated for n, d, and q. + /// gmp_lib.mpz_clears(n, d, q, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of d to 3. + /// Dim d As New mpz_t() + /// gmp_lib.mpz_init_set_si(d, 3) + /// + /// ' Create, initialize, and set the value of q to 0. + /// Dim q As New mpz_t() + /// gmp_lib.mpz_init(q) + /// + /// ' Set q = trunc(n / d). + /// gmp_lib.mpz_tdiv_q(q, n, d) + /// + /// ' Assert that q is trunc(10000 / 3). + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333) + /// + /// ' Release unmanaged memory allocated for n, d, and q. + /// gmp_lib.mpz_clears(n, d, q, Nothing) + /// + /// + public static void mpz_tdiv_q(mpz_t q, /*const*/ mpz_t n, /*const*/ mpz_t d) + { + if (q == null) throw new ArgumentNullException("q"); + if (n == null) throw new ArgumentNullException("n"); + if (d == null) throw new ArgumentNullException("d"); + SafeNativeMethods.__gmpz_tdiv_q(q.ToIntPtr(), n.ToIntPtr(), d.ToIntPtr()); + } + + /// + /// Set the quotient to trunc( / 2^). + /// + /// The result quotient integer. + /// The numerator integer. + /// The exponent of the power of two denominator. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10001. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10001); + /// + /// // Create, initialize, and set the value of q to 0. + /// mpz_t q = new mpz_t(); + /// gmp_lib.mpz_init(q); + /// + /// // Set q = trunc(n / 2^2). + /// gmp_lib.mpz_tdiv_q_2exp(q, n, 2U); + /// + /// // Assert that q is trunc(10001 / 4). + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 2500); + /// + /// // Release unmanaged memory allocated for n and q. + /// gmp_lib.mpz_clears(n, q, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10001. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10001) + /// + /// ' Create, initialize, and set the value of q to 0. + /// Dim q As New mpz_t() + /// gmp_lib.mpz_init(q) + /// + /// ' Set q = trunc(n / 2^2). + /// gmp_lib.mpz_tdiv_q_2exp(q, n, 2UI) + /// + /// ' Assert that q is trunc(10001 / 4). + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 2500) + /// + /// ' Release unmanaged memory allocated for n and q. + /// gmp_lib.mpz_clears(n, q, Nothing) + /// + /// + public static void mpz_tdiv_q_2exp(mpz_t q, /*const*/ mpz_t n, mp_bitcnt_t b) + { + if (q == null) throw new ArgumentNullException("q"); + if (n == null) throw new ArgumentNullException("n"); + SafeNativeMethods.__gmpz_tdiv_q_2exp(q.ToIntPtr(), n.ToIntPtr(), b); + } + + /// + /// Set the quotient to trunc( / ), and return the remainder r = | - * |. + /// + /// The result quotient integer. + /// The numerator integer. + /// The denominator integer. + /// Return the remainder r = | - * |. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of q to 0. + /// mpz_t q = new mpz_t(); + /// gmp_lib.mpz_init(q); + /// + /// // Set q = trunc(n / 3) and return r = n - 3 * q. + /// // Assert q and r values. + /// Assert.IsTrue(gmp_lib.mpz_tdiv_q_ui(q, n, 3U) == 1U); + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + /// + /// // Release unmanaged memory allocated for n and q. + /// gmp_lib.mpz_clears(n, q, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of q to 0. + /// Dim q As New mpz_t() + /// gmp_lib.mpz_init(q) + /// + /// ' Set q = trunc(n / 3) and return r = n - 3 * q. + /// ' Assert q and r values. + /// Assert.IsTrue(gmp_lib.mpz_tdiv_q_ui(q, n, 3UI) = 1UI) + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333) + /// + /// ' Release unmanaged memory allocated for n and q. + /// gmp_lib.mpz_clears(n, q, Nothing) + /// + /// + public static ulong mpz_tdiv_q_ui(mpz_t q, /*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (q == null) throw new ArgumentNullException("q"); + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_tdiv_q_ui(q.ToIntPtr(), n.ToIntPtr(), d); + } + + /// + /// Set the quotient to trunc( / ), and set the remainder to - * . + /// + /// The result quotient integer. + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of d to 3. + /// mpz_t d = new mpz_t(); + /// gmp_lib.mpz_init_set_si(d, 3); + /// + /// // Create, initialize, and set the values of q and r to 0. + /// mpz_t q = new mpz_t(); + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_inits(q, r, null); + /// + /// // Set q = trunc(n / 3) and r = n - d * q. + /// gmp_lib.mpz_tdiv_qr(q, r, n, d); + /// + /// // Assert that q is 3333, and that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + /// + /// // Release unmanaged memory allocated for n, d, q, and r. + /// gmp_lib.mpz_clears(n, d, q, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of d to 3. + /// Dim d As New mpz_t() + /// gmp_lib.mpz_init_set_si(d, 3) + /// + /// ' Create, initialize, and set the values of q and r to 0. + /// Dim q As New mpz_t() + /// Dim r As New mpz_t() + /// gmp_lib.mpz_inits(q, r, Nothing) + /// + /// ' Set q = trunc(n / 3) and r = n - d * q. + /// gmp_lib.mpz_tdiv_qr(q, r, n, d) + /// + /// ' Assert that q is 3333, and that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333) + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1) + /// + /// ' Release unmanaged memory allocated for n, d, q, and r. + /// gmp_lib.mpz_clears(n, d, q, r, Nothing) + /// + /// + public static void mpz_tdiv_qr(mpz_t q, mpz_t r, /*const*/ mpz_t n, /*const*/ mpz_t d) + { + if (q == null) throw new ArgumentNullException("q"); + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + if (d == null) throw new ArgumentNullException("d"); + SafeNativeMethods.__gmpz_tdiv_qr(q.ToIntPtr(), r.ToIntPtr(), n.ToIntPtr(), d.ToIntPtr()); + } + + /// + /// Set quotient to trunc( / ), set the remainder to - * , and return ||. + /// + /// The result quotient integer. + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// Return ||. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the values of q and r to 0. + /// mpz_t q = new mpz_t(); + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_inits(q, r, null); + /// + /// // Set q = trunc(n / 3), r = n - d * q, and return r. + /// Assert.IsTrue(gmp_lib.mpz_tdiv_qr_ui(q, r, n, 3U) == 1U); + /// + /// // Assert that q is 3333, and that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333); + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + /// + /// // Release unmanaged memory allocated for n, q, and r. + /// gmp_lib.mpz_clears(n, q, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the values of q and r to 0. + /// Dim q As New mpz_t() + /// Dim r As New mpz_t() + /// gmp_lib.mpz_inits(q, r, Nothing) + /// + /// ' Set q = trunc(n / 3), r = n - d * q, and return r. + /// Assert.IsTrue(gmp_lib.mpz_tdiv_qr_ui(q, r, n, 3UI) = 1UI) + /// + /// ' Assert that q is 3333, and that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333) + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1) + /// + /// ' Release unmanaged memory allocated for n, q, and r. + /// gmp_lib.mpz_clears(n, q, r, Nothing) + /// + /// + public static uint /*unsigned long int*/ mpz_tdiv_qr_ui(mpz_t q, mpz_t r, /*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (q == null) throw new ArgumentNullException("q"); + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_tdiv_qr_ui(q.ToIntPtr(), r.ToIntPtr(), n.ToIntPtr(), d); + } + + /// + /// Set the remainder to - q * where q = trunc( / ). + /// + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of d to 3. + /// mpz_t d = new mpz_t(); + /// gmp_lib.mpz_init_set_si(d, 3); + /// + /// // Create, initialize, and set the value of r to 0. + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_init(r); + /// + /// // Set r = n - d * trunc(n / d). + /// gmp_lib.mpz_tdiv_r(r, n, d); + /// + /// // Assert that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + /// + /// // Release unmanaged memory allocated for n, d, and r. + /// gmp_lib.mpz_clears(n, d, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of d to 3. + /// Dim d As New mpz_t() + /// gmp_lib.mpz_init_set_si(d, 3) + /// + /// ' Create, initialize, and set the value of r to 0. + /// Dim r As New mpz_t() + /// gmp_lib.mpz_init(r) + /// + /// ' Set r = n - d * trunc(n / d). + /// gmp_lib.mpz_tdiv_r(r, n, d) + /// + /// ' Assert that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1) + /// + /// ' Release unmanaged memory allocated for n, d, and r. + /// gmp_lib.mpz_clears(n, d, r, Nothing) + /// + /// + public static void mpz_tdiv_r(mpz_t r, /*const*/ mpz_t n, /*const*/ mpz_t d) + { + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + if (d == null) throw new ArgumentNullException("d"); + SafeNativeMethods.__gmpz_tdiv_r(r.ToIntPtr(), n.ToIntPtr(), d.ToIntPtr()); + } + + /// + /// Set the remainder to - q * 2^ where q = trunc( / 2^). + /// + /// The result remainder integer. + /// The numerator integer. + /// The exponent of the power of two denominator. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10001. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10001); + /// + /// // Create, initialize, and set the value of r to 0. + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_init(r); + /// + /// // Set r = n - 2^2 * trunc(n / 2^2) + /// gmp_lib.mpz_tdiv_r_2exp(r, n, 2U); + /// + /// // Assert that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + /// + /// // Release unmanaged memory allocated for n and r. + /// gmp_lib.mpz_clears(n, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10001. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10001) + /// + /// ' Create, initialize, and set the value of r to 0. + /// Dim r As New mpz_t() + /// gmp_lib.mpz_init(r) + /// + /// ' Set r = n - 2^2 * trunc(n / 2^2) + /// gmp_lib.mpz_tdiv_r_2exp(r, n, 2UI) + /// + /// ' Assert that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1) + /// + /// ' Release unmanaged memory allocated for n and r. + /// gmp_lib.mpz_clears(n, r, Nothing) + /// + /// + public static void mpz_tdiv_r_2exp(mpz_t r, /*const*/ mpz_t n, mp_bitcnt_t b) + { + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + SafeNativeMethods.__gmpz_tdiv_r_2exp(r.ToIntPtr(), n.ToIntPtr(), b); + } + + /// + /// Set the remainder to - q * where q = trunc( / ), and return ||. + /// + /// The result remainder integer. + /// The numerator integer. + /// The denominator integer. + /// Return ||. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Division + /// + /// + /// // Create, initialize, and set the value of n to 10000. + /// mpz_t n = new mpz_t(); + /// gmp_lib.mpz_init_set_si(n, 10000); + /// + /// // Create, initialize, and set the value of r to 0. + /// mpz_t r = new mpz_t(); + /// gmp_lib.mpz_init(r); + /// + /// // Set r = n - 3 * trunc(n / 3), and return |r|. + /// Assert.IsTrue(gmp_lib.mpz_tdiv_r_ui(r, n, 3U) == 1U); + /// + /// // Assert that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1); + /// + /// // Release unmanaged memory allocated for n and r. + /// gmp_lib.mpz_clears(n, r, null); + /// + /// + /// ' Create, initialize, and set the value of n to 10000. + /// Dim n As New mpz_t() + /// gmp_lib.mpz_init_set_si(n, 10000) + /// + /// ' Create, initialize, and set the value of r to 0. + /// Dim r As New mpz_t() + /// gmp_lib.mpz_init(r) + /// + /// ' Set r = n - 3 * trunc(n / 3), and return |r|. + /// Assert.IsTrue(gmp_lib.mpz_tdiv_r_ui(r, n, 3UI) = 1UI) + /// + /// ' Assert that r is 1. + /// Assert.IsTrue(gmp_lib.mpz_get_si(r) = 1) + /// + /// ' Release unmanaged memory allocated for n and r. + /// gmp_lib.mpz_clears(n, r, Nothing) + /// + /// + public static ulong mpz_tdiv_r_ui(mpz_t r, /*const*/ mpz_t n, uint /*unsigned long int*/ d) + { + if (r == null) throw new ArgumentNullException("r"); + if (n == null) throw new ArgumentNullException("n"); + return SafeNativeMethods.__gmpz_tdiv_r_ui(r.ToIntPtr(), n.ToIntPtr(), d); + } + + /// + /// Test bit in and return 0 or 1 accordingly. + /// + /// + /// + /// Test bit in and return 0 or 1 accordingly. + /// + /// + /// The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + /// The least significant bit is number 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Logic and Bit Fiddling + /// + /// + /// // Create, initialize, and set the value of rop to 70. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init_set_si(rop, 70); + /// + /// // Assert that bit 3 of rop is 0. + /// Assert.IsTrue(gmp_lib.mpz_tstbit(rop, 3U) == 0); + /// + /// // Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and set the value of rop to 70. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init_set_si(rop, 70) + /// + /// ' Assert that bit 3 of rop is 0. + /// Assert.IsTrue(gmp_lib.mpz_tstbit(rop, 3UI) = 0) + /// + /// ' Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop) + /// + /// + public static int mpz_tstbit(/*const*/ mpz_t op, mp_bitcnt_t bit_index) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpz_tstbit(op.ToIntPtr(), bit_index); + } + + /// + /// Set to ^. The case 0^0 yields 1. + /// + /// The result integer. + /// The base integer. + /// The exponent integer. + /// + /// + /// + /// + /// GNU MP - Integer Exponentiation + /// + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop = 2^4. + /// gmp_lib.mpz_ui_pow_ui(rop, 2U, 4U); + /// + /// // Assert that rop is 16. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 16); + /// + /// // Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop = 2^4. + /// gmp_lib.mpz_ui_pow_ui(rop, 2UI, 4UI) + /// + /// ' Assert that rop is 16. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 16) + /// + /// ' Release unmanaged memory allocated for rop. + /// gmp_lib.mpz_clear(rop) + /// + /// + public static void mpz_ui_pow_ui(mpz_t rop, uint /*unsigned long int*/ @base, uint /*unsigned long int*/ exp) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpz_ui_pow_ui(rop.ToIntPtr(), @base, exp); + } + + /// + /// Generate a uniformly distributed random integer in the range 0 to 2^ - 1, inclusive. + /// + /// The result integer. + /// The random number generator state. + /// The operand integer. + /// + /// + /// The variable must be initialized by calling one of the gmp_randinit + /// functions (GNU MP - Random State Initialization) before invoking this function. + /// + /// + /// The random number functions of GMP come in two groups; older function that rely on a global state, + /// and newer functions that accept a state parameter that is read and modified. + /// Please see the GNU MP - Random Number Functions + /// for more information on how to use and not to use random number functions. + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Random Numbers + /// + /// + /// // Create, initialize, and seed a new random number generator. + /// gmp_randstate_t state = new gmp_randstate_t(); + /// gmp_lib.gmp_randinit_mt(state); + /// gmp_lib.gmp_randseed_ui(state, 100000U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Generate a random integer in the range [0, (2^50)-1]. + /// gmp_lib.mpz_urandomb(rop, state, 50); + /// + /// // Free all memory occupied by state and rop. + /// gmp_lib.gmp_randclear(state); + /// gmp_lib.mpz_clear(rop); + /// + /// + /// ' Create, initialize, and seed a new random number generator. + /// Dim state As New gmp_randstate_t() + /// gmp_lib.gmp_randinit_mt(state) + /// gmp_lib.gmp_randseed_ui(state, 100000UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Generate a random integer in the range [0, (2^50)-1]. + /// gmp_lib.mpz_urandomb(rop, state, 50) + /// + /// ' Free all memory occupied by state and rop. + /// gmp_lib.gmp_randclear(state) + /// gmp_lib.mpz_clear(rop) + /// + /// + public static void mpz_urandomb(mpz_t rop, gmp_randstate_t state, mp_bitcnt_t n) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (state == null) throw new ArgumentNullException("state"); + SafeNativeMethods.__gmpz_urandomb(rop.ToIntPtr(), state.ToIntPtr(), n); + } + + /// + /// Generate a uniform random integer in the range 0 to - 1, inclusive. + /// + /// The result integer. + /// The random number generator state. + /// The operand integer. + /// + /// + /// The variable must be initialized by calling one of the gmp_randinit + /// functions (GNU MP - Random State Initialization) before invoking this function. + /// + /// + /// The random number functions of GMP come in two groups; older function that rely on a global state, + /// and newer functions that accept a state parameter that is read and modified. + /// Please see the GNU MP - Random Number Functions + /// for more information on how to use and not to use random number functions. + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Random Numbers + /// + /// + /// // Create, initialize, and seed a new random number generator. + /// gmp_randstate_t state = new gmp_randstate_t(); + /// gmp_lib.gmp_randinit_mt(state); + /// gmp_lib.gmp_randseed_ui(state, 100000U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Create, initialize, and set a large integer. + /// mpz_t n = new mpz_t(); + /// char_ptr value = new char_ptr("123 456 789 012 345 678 901"); + /// gmp_lib.mpz_init_set_str(n, value, 10); + /// + /// // Generate a random integer in the range [0, n-1]. + /// gmp_lib.mpz_urandomm(rop, state, n); + /// + /// // Free all memory occupied by state, rop, and n. + /// gmp_lib.gmp_randclear(state); + /// gmp_lib.mpz_clears(rop, n, null); + /// + /// + /// ' Create, initialize, and seed a new random number generator. + /// Dim state As New gmp_randstate_t() + /// gmp_lib.gmp_randinit_mt(state) + /// gmp_lib.gmp_randseed_ui(state, 100000UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Create, initialize, and set a large integer. + /// Dim n As New mpz_t() + /// Dim value As New char_ptr("123 456 789 012 345 678 901") + /// gmp_lib.mpz_init_set_str(n, value, 10) + /// + /// ' Generate a random integer in the range [0, n-1]. + /// gmp_lib.mpz_urandomm(rop, state, n) + /// + /// ' Free all memory occupied by state, rop, and n. + /// gmp_lib.gmp_randclear(state) + /// gmp_lib.mpz_clears(rop, n, Nothing) + /// + /// + public static void mpz_urandomm(mpz_t rop, gmp_randstate_t state, /*const*/ mpz_t n) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (state == null) throw new ArgumentNullException("state"); + if (n == null) throw new ArgumentNullException("n"); + SafeNativeMethods.__gmpz_urandomm(rop.ToIntPtr(), state.ToIntPtr(), n.ToIntPtr()); + } + + /// + /// Set to bitwise exclusive-or . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// + /// + /// The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + /// The least significant bit is number 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Logic and Bit Fiddling + /// + /// + /// // Create, initialize, and set the value of op1 to 63. + /// mpz_t op1 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op1, 63U); + /// + /// // Create, initialize, and set the value of op2 to 70. + /// mpz_t op2 = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(op2, 70U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpz_t rop = new mpz_t(); + /// gmp_lib.mpz_init(rop); + /// + /// // Set rop to the bitwise exclusive or of op1 and op2. + /// gmp_lib.mpz_xor(rop, op1, op2); + /// + /// // Assert that rop is 121. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 121); + /// + /// // Release unmanaged memory allocated for rop, op1, and op2. + /// gmp_lib.mpz_clears(rop, op1, op2, null); + /// + /// + /// ' Create, initialize, and set the value of op1 to 63. + /// Dim op1 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op1, 63UI) + /// + /// ' Create, initialize, and set the value of op2 to 70. + /// Dim op2 As New mpz_t() + /// gmp_lib.mpz_init_set_ui(op2, 70UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpz_t() + /// gmp_lib.mpz_init(rop) + /// + /// ' Set rop to the bitwise exclusive or of op1 and op2. + /// gmp_lib.mpz_xor(rop, op1, op2) + /// + /// ' Assert that rop is 121. + /// Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 121) + /// + /// ' Release unmanaged memory allocated for rop, op1, and op2. + /// gmp_lib.mpz_clears(rop, op1, op2, Nothing) + /// + /// + public static void mpz_xor(mpz_t rop, /*const*/ mpz_t op1, /*const*/ mpz_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpz_xor(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Return a pointer to the limb array representing the absolute value of . + /// + /// The integer. + /// A pointer to the limb array representing the absolute value of . + /// + /// + /// The size of the array is (x). Intended for read access only. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Special Functions + /// + /// + /// // Create and initialize new integer x. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// + /// // Set the value of x. + /// char_ptr value = new char_ptr("10000 00000000000000000000000000000000"); + /// gmp_lib.mpz_set_str(x, value, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4); + /// + /// // Get pointer to the limbs of x. + /// mp_ptr limbs = gmp_lib.mpz_limbs_read(x); + /// + /// // Assert the values of the limbs based on current architecture (x86 or x64). + /// Assert.IsTrue(limbs[0] == 0); + /// Assert.IsTrue(limbs[1] == (gmp_lib.mp_bytes_per_limb == 4 ? 16U : 256U)); + /// + /// // Release unmanaged memory allocated for x and value. + /// gmp_lib.mpz_clear(x); + /// gmp_lib.free(value); + /// + /// + /// ' Create and initialize new integer x. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init(x) + /// + /// ' Set the value of x. + /// Dim value As New char_ptr("10000 00000000000000000000000000000000") + /// gmp_lib.mpz_set_str(x, value, If(gmp_lib.mp_bytes_per_limb = 4, 2, 4)) + /// + /// ' Get pointer to the limbs of x. + /// Dim limbs As mp_ptr = gmp_lib.mpz_limbs_read(x) + /// + /// ' Assert the values of the limbs based on current architecture (x86 or x64). + /// Assert.IsTrue(limbs(0) = 0) + /// Assert.IsTrue(limbs(1) = (If(gmp_lib.mp_bytes_per_limb = 4, 16UI, 256UI))) + /// + /// ' Release unmanaged memory allocated for x and value. + /// gmp_lib.mpz_clear(x) + /// gmp_lib.free(value) + /// + /// + public static mp_ptr /*mp_limb_t**/ mpz_limbs_read(/*const*/ mpz_t x) + { + if (x == null) throw new ArgumentNullException("x"); + SafeNativeMethods.__gmpz_limbs_read(x.ToIntPtr()); + return x._mp_d; // new mp_ptr(SafeNativeMethods.__gmpz_limbs_read(x)); + } + + /// + /// Return a pointer to the limb array of , intended for write access. + /// + /// The operand integer. + /// The number of limbs. + /// A pointer to the limb array of , intended for write access. + /// + /// + /// The array is reallocated as needed, to make room for limbs. + /// Requires > 0. + /// The function may destroy the old value and + /// return an array with unspecified contents. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Special Functions + /// + /// + /// // Create and initialize new integer x. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// + /// // Resize x to 3 limbs, and get pointer to the limbs. + /// gmp_lib.mpz_set_ui(x, 2U); + /// mp_ptr limbs = gmp_lib.mpz_limbs_write(x, 3); + /// + /// // Set the values of the limbs. + /// limbs[0] = 0U; + /// limbs[1] = 0U; + /// limbs[2] = (gmp_lib.mp_bytes_per_limb == 4 ? 2U : 4U); + /// gmp_lib.mpz_limbs_finish(x, -3); + /// + /// // Assert the value of x based on current architecture (x86 or x64). + /// char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4, x); + /// Assert.IsTrue(s.ToString() == "-10 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", "")); + /// + /// // Release unmanaged memory allocated for x and s. + /// gmp_lib.mpz_clear(x); + /// gmp_lib.free(s); + /// + /// + /// ' Create and initialize new integer x. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init(x) + /// + /// ' Resize x to 3 limbs, and get pointer to the limbs. + /// gmp_lib.mpz_set_ui(x, 2UI) + /// Dim limbs As mp_ptr = gmp_lib.mpz_limbs_write(x, 3) + /// + /// ' Set the values of the limbs. + /// limbs(0) = 0UI + /// limbs(1) = 0UI + /// limbs(2) = (If(gmp_lib.mp_bytes_per_limb = 4, 2UI, 4UI)) + /// gmp_lib.mpz_limbs_finish(x, -3) + /// + /// ' Assert the value of x based on current architecture (x86 or x64). + /// Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, If(gmp_lib.mp_bytes_per_limb = 4, 2, 4), x) + /// Assert.IsTrue(s.ToString() = "-10 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", "")) + /// + /// ' Release unmanaged memory allocated for x and s. + /// gmp_lib.mpz_clear(x) + /// gmp_lib.free(s) + /// + /// + public static mp_ptr /*mp_limb_t**/ mpz_limbs_write(/*const*/ mpz_t x, mp_size_t n) + { + if (x == null) throw new ArgumentNullException("x"); + SafeNativeMethods.__gmpz_limbs_write(x.ToIntPtr(), n); + return x._mp_d; // new mp_ptr(SafeNativeMethods.__gmpz_limbs_write(x, n)); + } + + /// + /// Return a pointer to the limb array of , intended for write access. + /// + /// The operand integer. + /// The number of limbs. + /// A pointer to the limb array of , intended for write access. + /// + /// + /// The array is reallocated as needed, to make room for limbs. + /// Requires > 0. + /// The function returns an array that holds the old absolute + /// value of + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Special Functions + /// + /// + /// // Create, initialize, and set the value of x to 2. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(x, 2U); + /// + /// // Resize x to 3 limbs, and get pointer to the limbs. + /// mp_ptr limbs = gmp_lib.mpz_limbs_modify(x, 3); + /// + /// // Set the value of x. + /// limbs[0] = 0; + /// limbs[1] = 0; + /// limbs[2] = (IntPtr.Size == 4 ? 8U : 64U); + /// gmp_lib.mpz_limbs_finish(x, -3); + /// + /// // Assert the value of x based on current architecture (x86 or x64). + /// char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4, x); + /// Assert.IsTrue(s.ToString() == "-1000 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", "")); + /// + /// // Release unmanaged memory allocated for x and s. + /// gmp_lib.mpz_clear(x); + /// gmp_lib.free(s); + /// + /// + /// ' Create, initialize, and set the value of x to 2. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init_set_ui(x, 2UI) + /// + /// ' Resize x to 3 limbs, and get pointer to the limbs. + /// Dim limbs As mp_ptr = gmp_lib.mpz_limbs_modify(x, 3) + /// + /// ' Set the value of x. + /// limbs(0) = 0 + /// limbs(1) = 0 + /// limbs(2) = (If(IntPtr.Size = 4, 8UI, 64UI)) + /// gmp_lib.mpz_limbs_finish(x, -3) + /// + /// ' Assert the value of x based on current architecture (x86 or x64). + /// Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, If(gmp_lib.mp_bytes_per_limb = 4, 2, 4), x) + /// Assert.IsTrue(s.ToString() = "-1000 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", "")) + /// + /// ' Release unmanaged memory allocated for x and s. + /// gmp_lib.mpz_clear(x) + /// gmp_lib.free(s) + /// + /// + public static mp_ptr /*mp_limb_t**/ mpz_limbs_modify(/*const*/ mpz_t x, mp_size_t n) + { + if (x == null) throw new ArgumentNullException("x"); + SafeNativeMethods.__gmpz_limbs_modify(x.ToIntPtr(), n); + return x._mp_d; // new mp_ptr(SafeNativeMethods.__gmpz_limbs_modify(x, n)); + } + + /// + /// Updates the internal size field of . + /// + /// The operand integer. + /// The number of limbs and the sign of . + /// + /// + /// Used after writing to the limb array pointer returned by + /// or is completed. The array should contain || + /// valid limbs, representing the new absolute value for , and the sign of + /// is taken from the sign of . + /// This function never reallocates , so the limb pointer remains valid. + /// + /// + /// void foo (mpz_t x) + /// { + /// mp_size_t n, i; + /// mp_limb_t* xp; + /// + /// n = mpz_size(x); + /// xp = mpz_limbs_modify(x, 2 * n); + /// for (i = 0; i < n; i++) + /// xp[n + i] = xp[n - 1 - i]; + /// mpz_limbs_finish(x, mpz_sgn(x) < 0 ? - 2 * n : 2 * n); + /// } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Special Functions + public static void mpz_limbs_finish(/*const*/ mpz_t x, mp_size_t s) + { + if (x == null) throw new ArgumentNullException("x"); + SafeNativeMethods.__gmpz_limbs_finish(x.ToIntPtr(), s); + } + + /// + /// Special initialization of , using the given limb array and size. + /// + /// The operand integer. + /// The limbs array. + /// The number of limbs and the sign. + /// For convenience, the function returns , but cast to a const pointer type. + /// + /// + /// should be treated as readonly: it can be passed safely as input to any mpz function, but not as an output. + /// The array must point to at least a readable limb, its size is ||, and the + /// sign of is the sign of . + /// + /// + /// void foo (mpz_t x) + /// { + /// static const mp_limb_t y[3] = { 0x1, 0x2, 0x3 }; + /// mpz_t tmp; + /// mpz_add(x, x, mpz_roinit_n(tmp, y, 3)); + /// } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Integer Special Functions + /// + /// + /// // Create and initialize new integer x. + /// mpz_t x = new mpz_t(); + /// gmp_lib.mpz_init(x); + /// + /// // Prepare new limbs for x. + /// mp_ptr limbs; + /// if (gmp_lib.mp_bytes_per_limb == 4) + /// limbs = new mp_ptr(new uint[] { 0U, 0U, 2U }); + /// else + /// limbs = new mp_ptr(new ulong[] { 0UL, 0UL, 4UL }); + /// + /// // Assign new limbs to x, and make x negative. + /// x = gmp_lib.mpz_roinit_n(x, limbs, -3); + /// + /// // Assert new value of x. + /// char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4, x); + /// Assert.IsTrue(s.ToString() == "-10 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", "")); + /// + /// // Release unmanaged memory allocated for x and s. + /// gmp_lib.mpz_clear(x); + /// gmp_lib.free(s); + /// + /// + /// ' Create and initialize new integer x. + /// Dim x As New mpz_t() + /// gmp_lib.mpz_init(x) + /// + /// ' Prepare new limbs for x. + /// Dim limbs As mp_ptr + /// If gmp_lib.mp_bytes_per_limb = 4 Then + /// limbs = New mp_ptr(New UInteger() { 0UI, 0UI, 2UI}) + /// Else + /// limbs = New mp_ptr(New ULong() { 0UL, 0UL, 4UL}) + /// End If + /// + /// ' Assign new limbs to x, and make x negative. + /// x = gmp_lib.mpz_roinit_n(x, limbs, -3) + /// + /// ' Assert new value of x. + /// Dim s As char_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, If(gmp_lib.mp_bytes_per_limb = 4, 2, 4), x) + /// Assert.IsTrue(s.ToString() = "-10 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", "")) + /// + /// ' Release unmanaged memory allocated for x and s. + /// gmp_lib.mpz_clear(x) + /// gmp_lib.free(s) + /// + /// + public static /*const*/ mpz_t mpz_roinit_n(mpz_t x, /*const*/ mp_ptr /*mp_limb_t **/ xp, mp_size_t xs) + { + if (x == null) throw new ArgumentNullException("x"); + if (xp == null) throw new ArgumentNullException("xp"); + SafeNativeMethods.__gmpz_roinit_n(x.ToIntPtr(), xp.ToIntPtr(), xs); + return x; + } + + #endregion + + #region "Rational (i.e. Q) routines." + + /// + /// Set to the absolute value of . + /// + /// The result rational. + /// The operand rational. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Rational Arithmetic + /// + /// + /// + /// + /// + /// + public static void mpq_abs(mpq_t rop, /*const*/ mpq_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpq_abs(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set to + . + /// + /// The result rational. + /// The first operand rational. + /// The second operand rational. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Rational Arithmetic + /// + /// + /// + /// + /// + /// + public static void mpq_add(mpq_t sum, /*const*/ mpq_t addend1, /*const*/ mpq_t addend2) + { + if (sum == null) throw new ArgumentNullException("sum"); + if (addend1 == null) throw new ArgumentNullException("addend1"); + if (addend2 == null) throw new ArgumentNullException("addend2"); + SafeNativeMethods.__gmpq_add(sum.ToIntPtr(), addend1.ToIntPtr(), addend2.ToIntPtr()); + } + + /// + /// Remove any factors that are common to the numerator and denominator of , and make the denominator positive. + /// + /// The operand rational. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Rationals + /// + /// + /// + /// + /// + /// + public static void mpq_canonicalize(mpq_t op) + { + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpq_canonicalize(op.ToIntPtr()); + } + + /// + /// Free the space occupied by . + /// + /// The operand rational. + /// + /// + /// Make sure to call this function for all variables when you are done with them. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Rationals + /// + /// + /// // Create and initialize a new rational x. + /// mpq_t x = new mpq_t(); + /// gmp_lib.mpq_init(x); + /// + /// // Assert that the value of x is 0.0. + /// Assert.IsTrue(gmp_lib.mpq_get_d(x) == 0.0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpq_clear(x); + /// + /// + /// ' Create and initialize a new rational x. + /// Dim x As New mpq_t() + /// gmp_lib.mpq_init(x) + /// + /// ' Assert that the value of x is 0.0. + /// Assert.IsTrue(gmp_lib.mpq_get_d(x) = 0.0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpq_clear(x) + /// + /// + public static void mpq_clear(mpq_t x) + { + if (x == null) throw new ArgumentNullException("x"); + SafeNativeMethods.__gmpq_clear(x.ToIntPtr()); + } + + /// + /// Free the space occupied by a NULL-terminated list of variables. + /// + /// The operand rational. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Rationals + /// + /// + /// // Create new rationals x1, x2 and x3. + /// mpq_t x1 = new mpq_t(); + /// mpq_t x2 = new mpq_t(); + /// mpq_t x3 = new mpq_t(); + /// + /// // Initialize the rationals. + /// gmp_lib.mpq_inits(x1, x2, x3, null); + /// + /// // Assert that their value is 0.0. + /// Assert.IsTrue(gmp_lib.mpq_get_d(x1) == 0.0); + /// Assert.IsTrue(gmp_lib.mpq_get_d(x2) == 0.0); + /// Assert.IsTrue(gmp_lib.mpq_get_d(x3) == 0.0); + /// + /// // Release unmanaged memory allocated for the rationals. + /// gmp_lib.mpq_clears(x1, x2, x3, null); + /// + /// + /// ' Create new rationals x1, x2 and x3. + /// Dim x1 As New mpq_t() + /// Dim x2 As New mpq_t() + /// Dim x3 As New mpq_t() + /// + /// ' Initialize the rationals. + /// gmp_lib.mpq_inits(x1, x2, x3, Nothing) + /// + /// ' Assert that their value is 0.0. + /// Assert.IsTrue(gmp_lib.mpq_get_d(x1) = 0.0) + /// Assert.IsTrue(gmp_lib.mpq_get_d(x2) = 0.0) + /// Assert.IsTrue(gmp_lib.mpq_get_d(x3) = 0.0) + /// + /// ' Release unmanaged memory allocated for the rationals. + /// gmp_lib.mpq_clears(x1, x2, x3, Nothing) + /// + /// + public static void mpq_clears(params mpq_t[] x) + { + if (x == null) throw new ArgumentNullException("x"); + foreach (mpq_t a in x) { if (a != null) mpq_clear(a); } + } + + /// + /// Compare and . + /// + /// The first operand rational. + /// The second operand rational. + /// Return a positive value if > , zero if = , and a negative value if < . + /// + /// + /// To determine if two rationals are equal, is faster than . + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Comparing Rationals + /// + /// + /// // Create, initialize, and set the value of op1 to 1 / 2. + /// mpq_t op1 = new mpq_t(); + /// gmp_lib.mpq_init(op1); + /// gmp_lib.mpq_set_si(op1, 1, 2U); + /// + /// // Create, initialize, and set the value of op2 to 1 / 3. + /// mpq_t op2 = new mpq_t(); + /// gmp_lib.mpq_init(op2); + /// gmp_lib.mpq_set_si(op2, 1, 3U); + /// + /// // Assert that op1 > op2. + /// Assert.IsTrue(gmp_lib.mpq_cmp(op1, op2) > 0); + /// + /// // Release unmanaged memory allocated for op1 and op2. + /// gmp_lib.mpq_clears(op1, op2, null); + /// + /// + /// ' Create, initialize, and set the value of op1 to 1 / 2. + /// Dim op1 As New mpq_t() + /// gmp_lib.mpq_init(op1) + /// gmp_lib.mpq_set_si(op1, 1, 2UI) + /// + /// ' Create, initialize, and set the value of op2 to 1 / 3. + /// Dim op2 As New mpq_t() + /// gmp_lib.mpq_init(op2) + /// gmp_lib.mpq_set_si(op2, 1, 3UI) + /// + /// ' Assert that op1 > op2. + /// Assert.IsTrue(gmp_lib.mpq_cmp(op1, op2) > 0) + /// + /// ' Release unmanaged memory allocated for op1 and op2. + /// gmp_lib.mpq_clears(op1, op2, Nothing) + /// + /// + public static int mpq_cmp(/*const*/ mpq_t op1, /*const*/ mpq_t op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + return SafeNativeMethods.__gmpq_cmp(op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Compare and / . + /// + /// The first operand rational. + /// The second operand numerator integer. + /// The second operand denominator integer. + /// Return a positive value if > / , zero if = / , and a negative value if < / . + /// + /// + /// and are allowed to have common factors. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Comparing Rationals + /// + /// + /// // Create, initialize, and set the value of op1 to 1 / 2. + /// mpq_t op1 = new mpq_t(); + /// gmp_lib.mpq_init(op1); + /// gmp_lib.mpq_set_si(op1, 1, 2U); + /// + /// // Assert that op1 < 5/6. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op1, 5, 6U) < 0); + /// + /// // Release unmanaged memory allocated for op1. + /// gmp_lib.mpq_clear(op1); + /// + /// + /// ' Create, initialize, and set the value of op1 to 1 / 2. + /// Dim op1 As New mpq_t() + /// gmp_lib.mpq_init(op1) + /// gmp_lib.mpq_set_si(op1, 1, 2UI) + /// + /// ' Assert that op1 < 5/6. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op1, 5, 6UI) < 0) + /// + /// ' Release unmanaged memory allocated for op1. + /// gmp_lib.mpq_clear(op1) + /// + /// + public static int mpq_cmp_si(/*const*/ mpq_t op1, int /*long int*/ num2, uint /*unsigned long int*/ den2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + return SafeNativeMethods.__gmpq_cmp_si(op1.ToIntPtr(), num2, den2); + } + + /// + /// Compare and / . + /// + /// The first operand rational. + /// The second operand numerator integer. + /// The second operand denominator integer. + /// Return a positive value if > / , zero if = / , and a negative value if < / . + /// + /// + /// and are allowed to have common factors. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Comparing Rationals + /// + /// + /// // Create, initialize, and set the value of op1 to 1 / 2. + /// mpq_t op1 = new mpq_t(); + /// gmp_lib.mpq_init(op1); + /// gmp_lib.mpq_set_si(op1, 1, 2U); + /// + /// // Assert that op1 == 3/6. + /// Assert.IsTrue(gmp_lib.mpq_cmp_ui(op1, 3, 6U) == 0); + /// + /// // Release unmanaged memory allocated for op1. + /// gmp_lib.mpq_clear(op1); + /// + /// + /// ' Create, initialize, and set the value of op1 to 1 / 2. + /// Dim op1 As New mpq_t() + /// gmp_lib.mpq_init(op1) + /// gmp_lib.mpq_set_si(op1, 1, 2UI) + /// + /// ' Assert that op1 == 3/6. + /// Assert.IsTrue(gmp_lib.mpq_cmp_ui(op1, 3, 6UI) = 0) + /// + /// ' Release unmanaged memory allocated for op1. + /// gmp_lib.mpq_clear(op1) + /// + /// + public static int mpq_cmp_ui(/*const*/ mpq_t op1, uint /*unsigned long int*/ num2, uint /*unsigned long int*/ den2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + return SafeNativeMethods.__gmpq_cmp_ui(op1.ToIntPtr(), num2, den2); + } + + /// + /// Compare and . + /// + /// The first operand rational. + /// The second operand rational. + /// Return a positive value if > , zero if = , and a negative value if < . + /// + /// + /// To determine if two rationals are equal, is faster than . + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Comparing Rationals + /// + /// + /// // Create, initialize, and set the value of op1 to 1 / 2. + /// mpq_t op1 = new mpq_t(); + /// gmp_lib.mpq_init(op1); + /// gmp_lib.mpq_set_si(op1, 1, 2U); + /// + /// // Create, initialize, and set the value of op2 to 3. + /// mpz_t op2 = new mpz_t(); + /// gmp_lib.mpz_init(op2); + /// gmp_lib.mpz_set_si(op2, 3); + /// + /// // Assert that op1 < op2. + /// Assert.IsTrue(gmp_lib.mpq_cmp_z(op1, op2) < 0); + /// + /// // Release unmanaged memory allocated for op1 and op2. + /// gmp_lib.mpq_clear(op1); + /// gmp_lib.mpz_clear(op2); + /// + /// + /// ' Create, initialize, and set the value of op1 to 1 / 2. + /// Dim op1 As New mpq_t() + /// gmp_lib.mpq_init(op1) + /// gmp_lib.mpq_set_si(op1, 1, 2UI) + /// + /// ' Create, initialize, and set the value of op2 to 3. + /// Dim op2 As New mpz_t() + /// gmp_lib.mpz_init(op2) + /// gmp_lib.mpz_set_si(op2, 3) + /// + /// ' Assert that op1 < op2. + /// Assert.IsTrue(gmp_lib.mpq_cmp_z(op1, op2) < 0) + /// + /// ' Release unmanaged memory allocated for op1 and op2. + /// gmp_lib.mpq_clear(op1) + /// gmp_lib.mpz_clear(op2) + /// + /// + public static int mpq_cmp_z(/*const*/ mpq_t op1, /*const*/ mpz_t op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + return SafeNativeMethods.__gmpq_cmp_z(op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Return a reference to the denominator . + /// + /// The operand rational. + /// Return a reference to the denominator . + /// + /// + /// The mpz functions can be used on the returned reference. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Applying Integer Functions + /// + /// + /// // Create, initialize, and set the value of op to -1 / 3. + /// mpq_t op = new mpq_t(); + /// gmp_lib.mpq_init(op); + /// gmp_lib.mpq_set_si(op, -1, 3U); + /// + /// // Get reference to denominator, and increment it by 2. + /// mpz_t num = gmp_lib.mpq_denref(op); + /// gmp_lib.mpz_add_ui(num, num, 2U); + /// + /// // Assert that op is -1 / 5. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5U) == 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpq_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to -1 / 3. + /// Dim op As New mpq_t() + /// gmp_lib.mpq_init(op) + /// gmp_lib.mpq_set_si(op, -1, 3UI) + /// + /// ' Get reference to denominator, and increment it by 2. + /// Dim num As mpz_t = gmp_lib.mpq_denref(op) + /// gmp_lib.mpz_add_ui(num, num, 2UI) + /// + /// ' Assert that op is -1 / 5. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5UI) = 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpq_clear(op) + /// + /// + public static mpz_t mpq_denref(/*const*/ mpq_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return op._mp_den; + } + + /// + /// Set to / . + /// + /// The result rational. + /// The first operand rational. + /// The second operand rational. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Rational Arithmetic + /// + /// + /// + /// + /// + /// + public static void mpq_div(mpq_t quotient, /*const*/ mpq_t dividend, /*const*/ mpq_t divisor) + { + if (quotient == null) throw new ArgumentNullException("quotient"); + if (dividend == null) throw new ArgumentNullException("dividend"); + if (divisor == null) throw new ArgumentNullException("divisor"); + SafeNativeMethods.__gmpq_div(quotient.ToIntPtr(), dividend.ToIntPtr(), divisor.ToIntPtr()); + } + + /// + /// Set to / 2^. + /// + /// The result rational. + /// The first operand rational. + /// The second operand rational. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Rational Arithmetic + /// + /// + /// + /// + /// + /// + public static void mpq_div_2exp(mpq_t rop, /*const*/ mpq_t op1, uint /*mp_bitcnt_t*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpq_div_2exp(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Return non-zero if and are equal, zero if they are non-equal. + /// + /// The first operand rational. + /// The second operand rational. + /// Return non-zero if and are equal, zero if they are non-equal. + /// + /// + /// Although can be used for the same purpose, this function is much faster. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Comparing Rationals + /// + /// + /// // Create, initialize, and set the value of op1 to 1 / 2. + /// mpq_t op1 = new mpq_t(); + /// gmp_lib.mpq_init(op1); + /// gmp_lib.mpq_set_si(op1, 1, 2U); + /// + /// // Create, initialize, and set the value of op2 to 1 / 3. + /// mpq_t op2 = new mpq_t(); + /// gmp_lib.mpq_init(op2); + /// gmp_lib.mpq_set_si(op2, 1, 3U); + /// + /// // Assert that op1 != op2. + /// Assert.IsTrue(gmp_lib.mpq_equal(op1, op2) == 0); + /// + /// // Release unmanaged memory allocated for op1 and op2. + /// gmp_lib.mpq_clears(op1, op2, null); + /// + /// + /// ' Create, initialize, and set the value of op1 to 1 / 2. + /// Dim op1 As New mpq_t() + /// gmp_lib.mpq_init(op1) + /// gmp_lib.mpq_set_si(op1, 1, 2UI) + /// + /// ' Create, initialize, and set the value of op2 to 1 / 3. + /// Dim op2 As New mpq_t() + /// gmp_lib.mpq_init(op2) + /// gmp_lib.mpq_set_si(op2, 1, 3UI) + /// + /// ' Assert that op1 != op2. + /// Assert.IsTrue(gmp_lib.mpq_equal(op1, op2) = 0) + /// + /// ' Release unmanaged memory allocated for op1 and op2. + /// gmp_lib.mpq_clears(op1, op2, Nothing) + /// + /// + public static int mpq_equal(/*const*/ mpq_t op1, /*const*/ mpq_t op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + return SafeNativeMethods.__gmpq_equal(op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Set to the numerator of . + /// + /// The result integer. + /// The operand rational. + /// + /// + /// The function is equivalent to calling with . + /// Direct use of is recommended instead of this functions. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Applying Integer Functions + /// + /// + /// // Create, initialize, and set the value of op to -1 / 3. + /// mpq_t op = new mpq_t(); + /// gmp_lib.mpq_init(op); + /// gmp_lib.mpq_set_si(op, -1, 3U); + /// + /// // Create and initialize a new integer. + /// mpz_t num = new mpz_t(); + /// gmp_lib.mpz_init(num); + /// + /// // Set integer to numerator of rational, and increment integer by 2. + /// gmp_lib.mpq_get_num(num, op); + /// gmp_lib.mpz_add_ui(num, num, 2U); + /// + /// // Assert that num is 1, and op is -1 / 3. + /// Assert.IsTrue(gmp_lib.mpz_cmp_si(num, 1) == 0); + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 3U) == 0); + /// + /// // Release unmanaged memory allocated for op and num. + /// gmp_lib.mpq_clear(op); + /// gmp_lib.mpz_clear(num); + /// + /// + /// ' Create, initialize, and set the value of op to -1 / 3. + /// Dim op As New mpq_t() + /// gmp_lib.mpq_init(op) + /// gmp_lib.mpq_set_si(op, -1, 3UI) + /// + /// ' Create and initialize a new integer. + /// Dim num As New mpz_t() + /// gmp_lib.mpz_init(num) + /// + /// ' Set integer to numerator of rational, and increment integer by 2. + /// gmp_lib.mpq_get_num(num, op) + /// gmp_lib.mpz_add_ui(num, num, 2UI) + /// + /// ' Assert that num is 1, and op is -1 / 3. + /// Assert.IsTrue(gmp_lib.mpz_cmp_si(num, 1) = 0) + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 3UI) = 0) + /// + /// ' Release unmanaged memory allocated for op and num. + /// gmp_lib.mpq_clear(op) + /// gmp_lib.mpz_clear(num) + /// + /// + public static void mpq_get_num(mpz_t numerator, /*const*/ mpq_t rational) + { + if (numerator == null) throw new ArgumentNullException("numerator"); + if (rational == null) throw new ArgumentNullException("rational"); + SafeNativeMethods.__gmpq_get_num(numerator.ToIntPtr(), rational.ToIntPtr()); + } + + /// + /// Set to the denominator of . + /// + /// The result integer. + /// The operand rational. + /// + /// + /// The function is equivalent to calling with . + /// Direct use of is recommended instead of this functions. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Applying Integer Functions + /// + /// + /// // Create, initialize, and set the value of op to -1 / 3. + /// mpq_t op = new mpq_t(); + /// gmp_lib.mpq_init(op); + /// gmp_lib.mpq_set_si(op, -1, 3U); + /// + /// // Create and initialize a new integer. + /// mpz_t den = new mpz_t(); + /// gmp_lib.mpz_init(den); + /// + /// // Set integer to numerator of rational, and increment integer by 2.. + /// gmp_lib.mpq_get_den(den, op); + /// gmp_lib.mpz_add_ui(den, den, 2U); + /// + /// // Assert that num is 1, and op is -1 / 3. + /// Assert.IsTrue(gmp_lib.mpz_cmp_si(den, 5) == 0); + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 3U) == 0); + /// + /// // Release unmanaged memory allocated for op and num. + /// gmp_lib.mpq_clear(op); + /// gmp_lib.mpz_clear(den); + /// + /// + /// ' Create, initialize, and set the value of op to -1 / 3. + /// Dim op As New mpq_t() + /// gmp_lib.mpq_init(op) + /// gmp_lib.mpq_set_si(op, -1, 3UI) + /// + /// ' Create and initialize a new integer. + /// Dim den As New mpz_t() + /// gmp_lib.mpz_init(den) + /// + /// ' Set integer to numerator of rational, and increment integer by 2.. + /// gmp_lib.mpq_get_den(den, op) + /// gmp_lib.mpz_add_ui(den, den, 2UI) + /// + /// ' Assert that num is 1, and op is -1 / 3. + /// Assert.IsTrue(gmp_lib.mpz_cmp_si(den, 5) = 0) + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 3UI) = 0) + /// + /// ' Release unmanaged memory allocated for op and num. + /// gmp_lib.mpq_clear(op) + /// gmp_lib.mpz_clear(den) + /// + /// + public static void mpq_get_den(mpz_t denominator, /*const*/ mpq_t rational) + { + if (denominator == null) throw new ArgumentNullException("denominator"); + if (rational == null) throw new ArgumentNullException("rational"); + SafeNativeMethods.__gmpq_get_den(denominator.ToIntPtr(), rational.ToIntPtr()); + } + + /// + /// Convert to a , truncating if necessary (i.e. rounding towards zero). + /// + /// The operand rational. + /// The converted . + /// + /// + /// If the exponent from the conversion is too big or too small to fit a then the result is system dependent. + /// For too big an infinity is returned when available. + /// For too small 0.0 is normally returned. + /// Hardware overflow, underflow and denorm traps may or may not occur. + /// + /// + /// + /// + /// + /// GNU MP - Rational Conversions + /// + /// + /// // Create, initialize, and set the value of x to 10 / 11. + /// mpq_t x = new mpq_t(); + /// gmp_lib.mpq_init(x); + /// gmp_lib.mpq_set_si(x, 10, 11U); + /// + /// // Assert that the value of x is 10.0. + /// Assert.IsTrue(gmp_lib.mpq_get_d(x) == 10.0 / 11.0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpq_clear(x); + /// + /// + /// ' Create, initialize, and set the value of x to 10 / 11. + /// Dim x As New mpq_t() + /// gmp_lib.mpq_init(x) + /// gmp_lib.mpq_set_si(x, 10, 11UI) + /// + /// ' Assert that the value of x is 10.0. + /// Assert.IsTrue(gmp_lib.mpq_get_d(x) = 10.0 / 11.0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpq_clear(x) + /// + /// + public static double mpq_get_d(/*const*/ mpq_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpq_get_d(op.ToIntPtr()); + } + + /// + /// Convert to a string of digits in base . + /// + /// The result string. + /// The base. + /// The operand rational. + /// A pointer to the result string is returned, being either the allocated block, or the given . + /// + /// + /// The base may vary from 2 to 36. The string will be of the form "num/den", or if the denominator is 1 then just "num". + /// + /// + /// If is NULL, the result string is allocated using the current allocation function + /// (see GNU MP - Custom Allocation). + /// The block will be strlen() + 1 bytes, that being exactly enough for the string and null-terminator. + /// + /// + /// If is not NULL, it should point to a block of storage large enough for the result, that being + /// + /// + /// mpz_sizeinbase(mpq_numref(op), base) + mpz_sizeinbase(mpq_denref(op), base) + 3 + /// + /// + /// The three extra bytes are for a possible minus sign, possible slash, and the null-terminator. + /// + /// + /// + /// + /// + /// GNU MP - Rational Conversions + /// + /// + /// // Create, initialize, and set the value of x to -210 / 13. + /// mpq_t x = new mpq_t(); + /// gmp_lib.mpq_init(x); + /// gmp_lib.mpq_set_si(x, -210, 13U); + /// + /// // Retrieve the string value of x, and assert that it is "-210/13". + /// char_ptr s = gmp_lib.mpq_get_str(char_ptr.Zero, 10, x); + /// Assert.IsTrue(s.ToString() == "-210/13"); + /// + /// // Release unmanaged memory allocated for x and the string value. + /// gmp_lib.mpq_clear(x); + /// gmp_lib.free(s); + /// + /// + /// ' Create, initialize, and set the value of x to -210 / 13. + /// Dim x As New mpq_t() + /// gmp_lib.mpq_init(x) + /// gmp_lib.mpq_set_si(x, -210, 13UI) + /// + /// ' Retrieve the string value of x, and assert that it is "-210/13". + /// Dim s As char_ptr = gmp_lib.mpq_get_str(char_ptr.Zero, 10, x) + /// Assert.IsTrue(s.ToString() = "-210/13") + /// + /// ' Release unmanaged memory allocated for x and the string value. + /// gmp_lib.mpq_clear(x) + /// gmp_lib.free(s) + /// + /// + public static char_ptr mpq_get_str(char_ptr str, int @base, /*const*/ mpq_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return new Native.char_ptr(SafeNativeMethods.__gmpq_get_str(str.ToIntPtr(), @base, op.ToIntPtr())); + } + + /// + /// Initialize and set it to 0/1. + /// + /// The operand rational. + /// + /// + /// Each variable should normally only be initialized once, or at least cleared out + /// (using the function ) between each initialization. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Rationals + /// + /// + /// // Create and initialize a new rational x. + /// mpq_t x = new mpq_t(); + /// gmp_lib.mpq_init(x); + /// + /// // Assert that the value of x is 0. + /// char_ptr s = gmp_lib.mpq_get_str(char_ptr.Zero, 10, x); + /// Assert.IsTrue(s.ToString() == "0"); + /// + /// // Release unmanaged memory allocated for x and its string value. + /// gmp_lib.mpq_clear(x); + /// gmp_lib.free(s); + /// + /// + /// ' Create and initialize a new rational x. + /// Dim x As New mpq_t() + /// gmp_lib.mpq_init(x) + /// + /// ' Assert that the value of x is 0. + /// Dim s As char_ptr = gmp_lib.mpq_get_str(char_ptr.Zero, 10, x) + /// Assert.IsTrue(s.ToString() = "0") + /// + /// ' Release unmanaged memory allocated for x and its string value. + /// gmp_lib.mpq_clear(x) + /// gmp_lib.free(s) + /// + /// + public static void mpq_init(mpq_t x) + { + if (x == null) throw new ArgumentNullException("x"); + SafeNativeMethods.__gmpq_init(x.ToIntPtr()); + } + + /// + /// Initialize a NULL-terminated list of variables, and set their values to 0/1. + /// + /// The operand rational. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Rationals + /// + /// + /// // Create new rationals x1, x2 and x3. + /// mpq_t x1 = new mpq_t(); + /// mpq_t x2 = new mpq_t(); + /// mpq_t x3 = new mpq_t(); + /// + /// // Initialize the rationals. + /// gmp_lib.mpq_inits(x1, x2, x3); + /// + /// // Assert that their value is 0. + /// Assert.IsTrue(gmp_lib.mpq_get_d(x1) == 0.0); + /// Assert.IsTrue(gmp_lib.mpq_get_d(x2) == 0.0); + /// Assert.IsTrue(gmp_lib.mpq_get_d(x3) == 0.0); + /// + /// // Release unmanaged memory allocated for the rationals. + /// gmp_lib.mpq_clears(x1, x2, x3, null); + /// + /// + /// ' Create new rationals x1, x2 and x3. + /// Dim x1 As New mpq_t() + /// Dim x2 As New mpq_t() + /// Dim x3 As New mpq_t() + /// + /// ' Initialize the rationals. + /// gmp_lib.mpq_inits(x1, x2, x3) + /// + /// ' Assert that their value is 0. + /// Assert.IsTrue(gmp_lib.mpq_get_d(x1) = 0.0) + /// Assert.IsTrue(gmp_lib.mpq_get_d(x2) = 0.0) + /// Assert.IsTrue(gmp_lib.mpq_get_d(x3) = 0.0) + /// + /// ' Release unmanaged memory allocated for the rationals. + /// gmp_lib.mpq_clears(x1, x2, x3, Nothing) + /// + /// + public static void mpq_inits(params mpq_t[] x) + { + if (x == null) throw new ArgumentNullException("x"); + foreach (mpq_t a in x) { if (a != null) mpq_init(a); } + } + + /// + /// Read a string of digits from and convert them to a rational in . + /// + /// The result rational. + /// Pointer to file stream. + /// The base. + /// Return the number of characters read (including white space), or 0 if a rational could not be read. + /// + /// + /// Any initial white-space characters are read and discarded. + /// + /// + /// The input can be a fraction like "17/63" or just an integer like "123". + /// Reading stops at the first character not in this form, and white space is not permitted within the string. + /// If the input might not be in canonical form, then must be called + /// (see GNU MP - Rational Number Functions). + /// + /// + /// The base can be between 2 and 36, or can be 0 in which case the leading characters + /// of the string determine the base, "0x" or "0X" for hexadecimal, "0" for octal, or decimal otherwise. + /// The leading characters are examined separately for the numerator and denominator of a fraction, so for instance + /// "0x10/11" is 16/11, whereas "0x10/0x11" is 16/17. + /// + /// + /// + /// GNU MP - I/O of Rationals + /// + /// + /// // Create, initialize, and set the value of op to 123/456. + /// mpq_t op = new mpq_t(); + /// gmp_lib.mpq_init(op); + /// + /// // Write rational to a temporary file. + /// string pathname = System.IO.Path.GetTempFileName(); + /// System.IO.File.WriteAllText(pathname, "123/456"); + /// + /// // Read op from the temporary file, and assert that the number of bytes read is 7. + /// ptr<FILE> stream = new ptr<FILE>(); + /// _wfopen_s(out stream.Value.Value, pathname, "r"); + /// Assert.IsTrue(gmp_lib.mpq_inp_str(op, stream, 10) == 7); + /// fclose(stream.Value.Value); + /// + /// // Assert that op is 123/456. + /// Assert.IsTrue(gmp_lib.mpq_cmp_ui(op, 123, 456U) == 0); + /// + /// // Delete temporary file. + /// System.IO.File.Delete(pathname); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpq_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to 123/456. + /// Dim op As New mpq_t() + /// gmp_lib.mpq_init(op) + /// + /// ' Write rational to a temporary file. + /// Dim pathname As String = System.IO.Path.GetTempFileName() + /// System.IO.File.WriteAllText(pathname, "123/456") + /// + /// ' Read op from the temporary file, and assert that the number of bytes read is 7. + /// Dim stream As New ptr(Of FILE)() + /// _wfopen_s(stream.Value.Value, pathname, "r") + /// Assert.IsTrue(gmp_lib.mpq_inp_str(op, stream, 10) = 7) + /// fclose(stream.Value.Value) + /// + /// ' Assert that op is 123/456. + /// Assert.IsTrue(gmp_lib.mpq_cmp_ui(op, 123, 456UI) = 0) + /// + /// ' Delete temporary file. + /// System.IO.File.Delete(pathname) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpq_clear(op) + /// + /// + public static size_t mpq_inp_str(mpq_t rop, ptr stream, int @base) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (IntPtr.Size == 4) + return new size_t(SafeNativeMethods.__gmpq_inp_str_x86(rop.ToIntPtr(), stream.Value.Value, @base)); + else + return new size_t(SafeNativeMethods.__gmpq_inp_str_x64(rop.ToIntPtr(), stream.Value.Value, @base)); + } + + /// + /// Set to 1 / . + /// + /// The result rational. + /// The operand rational. + /// + /// + /// If the new denominator is zero, this routine will divide by zero. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Rational Arithmetic + /// + /// + /// + /// + /// + /// + public static void mpq_inv(mpq_t inverted_number, /*const*/ mpq_t number) + { + if (inverted_number == null) throw new ArgumentNullException("inverted_number"); + if (number == null) throw new ArgumentNullException("number"); + SafeNativeMethods.__gmpq_inv(inverted_number.ToIntPtr(), number.ToIntPtr()); + } + + /// + /// Set to * . + /// + /// The result rational. + /// The first operand rational. + /// The second operand rational. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Rational Arithmetic + /// + /// + /// + /// + /// + /// + public static void mpq_mul(mpq_t product, /*const*/ mpq_t multiplier, /*const*/ mpq_t multiplicand) + { + if (product == null) throw new ArgumentNullException("product"); + if (multiplier == null) throw new ArgumentNullException("multiplier"); + if (multiplicand == null) throw new ArgumentNullException("multiplicand"); + SafeNativeMethods.__gmpq_mul(product.ToIntPtr(), multiplier.ToIntPtr(), multiplicand.ToIntPtr()); + } + + /// + /// Set to * 2*. + /// + /// The result rational. + /// The first operand rational. + /// The second operand rational. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Rational Arithmetic + /// + /// + /// + /// + /// + /// + public static void mpq_mul_2exp(mpq_t rop, /*const*/ mpq_t op1, uint /*mp_bitcnt_t*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpq_mul_2exp(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Set to -. + /// + /// The result rational. + /// The operand rational. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Rational Arithmetic + /// + /// + /// + /// + /// + /// + public static void mpq_neg(mpq_t negated_operand, /*const*/ mpq_t operand) + { + if (negated_operand == null) throw new ArgumentNullException("negated_operand"); + if (operand == null) throw new ArgumentNullException("operand"); + SafeNativeMethods.__gmpq_neg(negated_operand.ToIntPtr(), operand.ToIntPtr()); + } + + /// + /// Return a reference to the numerator . + /// + /// The operand rational. + /// Return a reference to the numerator . + /// + /// + /// The mpz functions can be used on the returned reference. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Applying Integer Functions + /// + /// + /// // Create, initialize, and set the value of op to -1 / 3. + /// mpq_t op = new mpq_t(); + /// gmp_lib.mpq_init(op); + /// gmp_lib.mpq_set_si(op, -1, 3U); + /// + /// // Get reference to numerator, and increment it by 2. + /// mpz_t num = gmp_lib.mpq_numref(op); + /// gmp_lib.mpz_add_ui(num, num, 2U); + /// + /// // Assert that op is 1 / 3. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 1, 3U) == 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpq_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to -1 / 3. + /// Dim op As New mpq_t() + /// gmp_lib.mpq_init(op) + /// gmp_lib.mpq_set_si(op, -1, 3UI) + /// + /// ' Get reference to numerator, and increment it by 2. + /// Dim num As mpz_t = gmp_lib.mpq_numref(op) + /// gmp_lib.mpz_add_ui(num, num, 2UI) + /// + /// ' Assert that op is 1 / 3. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 1, 3UI) = 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpq_clear(op) + /// + /// + public static mpz_t mpq_numref(/*const*/ mpq_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return op._mp_num; + } + + /// + /// Output on stdio stream , as a string of digits in base . + /// + /// Pointer to file stream. + /// The base. + /// The operand rational. + /// Return the number of bytes written, or if an error occurred, return 0. + /// + /// + /// The may vary from 2 to 36. + /// Output is in the form "num/den" or if the denominator is 1 then just "num". + /// + /// + /// + /// GNU MP - I/O of Rationals + /// + /// + /// // Create, initialize, and set the value of op to 123/456. + /// mpq_t op = new mpq_t(); + /// gmp_lib.mpq_init(op); + /// gmp_lib.mpq_set_ui(op, 123, 456U); + /// + /// // Get a temporary file. + /// string pathname = System.IO.Path.GetTempFileName(); + /// + /// // Open temporary file for writing. + /// ptr<FILE> stream = new ptr<FILE>(); + /// _wfopen_s(out stream.Value.Value, pathname, "w"); + /// + /// // Write op to temporary file, and assert that the number of bytes written is 7. + /// Assert.IsTrue(gmp_lib.mpq_out_str(stream, 10, op) == 7); + /// + /// // Close temporary file. + /// fclose(stream.Value.Value); + /// + /// // Assert that the content of the temporary file is "123/456". + /// string result = System.IO.File.ReadAllText(pathname); + /// Assert.IsTrue(result == "123/456"); + /// + /// // Delete temporary file. + /// System.IO.File.Delete(pathname); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpq_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to 123/456. + /// Dim op As New mpq_t() + /// gmp_lib.mpq_init(op) + /// gmp_lib.mpq_set_ui(op, 123, 456UI) + /// + /// ' Get a temporary file. + /// Dim pathname As String = System.IO.Path.GetTempFileName() + /// + /// ' Open temporary file for writing. + /// Dim stream As New ptr(Of FILE)() + /// _wfopen_s(stream.Value.Value, pathname, "w") + /// + /// ' Write op to temporary file, and assert that the number of bytes written is 7. + /// Assert.IsTrue(gmp_lib.mpq_out_str(stream, 10, op) = 7) + /// + /// ' Close temporary file. + /// fclose(stream.Value.Value) + /// + /// ' Assert that the content of the temporary file is "123/456". + /// Dim result As String = System.IO.File.ReadAllText(pathname) + /// + /// Assert.IsTrue(result = "123/456") + /// + /// ' Delete temporary file. + /// System.IO.File.Delete(pathname) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpq_clear(op) + /// + /// + public static size_t mpq_out_str(ptr stream, int @base, /*const*/ mpq_t op) + { + if (op == null) throw new ArgumentNullException("op"); + if (IntPtr.Size == 4) + return new size_t(SafeNativeMethods.__gmpq_out_str_x86(stream.Value.Value, @base, op.ToIntPtr())); + else + return new size_t(SafeNativeMethods.__gmpq_out_str_x64(stream.Value.Value, @base, op.ToIntPtr())); + } + + /// + /// Assign from . + /// + /// The result rational. + /// The operand rational. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Rationals + /// + /// + /// // Create, initialize, and set a new rational x to 10 / 11. + /// mpq_t x = new mpq_t(); + /// gmp_lib.mpq_init(x); + /// gmp_lib.mpq_set_si(x, 10, 11); + /// + /// // Create, initialize, and set a new rational y to -210 / 13. + /// mpq_t y = new mpq_t(); + /// gmp_lib.mpq_init(y); + /// gmp_lib.mpq_set_si(y, -210, 13); + /// + /// // Assign the value of y to x. + /// gmp_lib.mpq_set(x, y); + /// + /// // Assert that the value of x is -210 / 13. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 13) == 0); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpq_clears(x, y, null); + /// + /// + /// ' Create, initialize, and set a new rational x to 10 / 11. + /// Dim x As New mpq_t() + /// gmp_lib.mpq_init(x) + /// gmp_lib.mpq_set_si(x, 10, 11) + /// + /// ' Create, initialize, and set a new rational y to -210 / 13. + /// Dim y As New mpq_t() + /// gmp_lib.mpq_init(y) + /// gmp_lib.mpq_set_si(y, -210, 13) + /// + /// ' Assign the value of y to x. + /// gmp_lib.mpq_set(x, y) + /// + /// ' Assert that the value of x is -210 / 13. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 13) = 0) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpq_clears(x, y, Nothing) + /// + /// + public static void mpq_set(mpq_t rop, /*const*/ mpq_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpq_set(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set to the value of . There is no rounding, this conversion is exact. + /// + /// The result rational. + /// The operand . + /// + /// + /// + /// + /// GNU MP - Rational Conversions + /// + /// + /// // Create and initialize a new rational. + /// mpq_t x = new mpq_t(); + /// gmp_lib.mpq_init(x); + /// + /// // Set the value of x to 10.0 / 11.0. + /// gmp_lib.mpq_set_d(x, 10.0D / 11.0); + /// + /// // Assert that the value of x is 10.0 / 11.0. + /// Assert.IsTrue(gmp_lib.mpq_get_d(x) == 10.0D / 11.0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpq_clear(x); + /// + /// + /// ' Create and initialize a new rational. + /// Dim x As New mpq_t() + /// gmp_lib.mpq_init(x) + /// + /// ' Set the value of x to 10.0 / 11.0. + /// gmp_lib.mpq_set_d(x, 10.0 / 11.0) + /// + /// ' Assert that the value of x is 10.0 / 11.0. + /// Assert.IsTrue(gmp_lib.mpq_get_d(x) = 10.0 / 11.0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpq_clear(x) + /// + /// + public static void mpq_set_d(mpq_t rop, double op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpq_set_d(rop.ToIntPtr(), op); + } + + /// + /// Set the denominator of to . + /// + /// The result rational. + /// The operand integer. + /// + /// The function is equivalent to calling with . + /// Direct use of is recommended instead of this functions. + /// + /// + /// + /// + /// + /// + /// GNU MP - Applying Integer Functions + /// + /// + /// // Create, initialize, and set the value of op to -1 / 3. + /// mpq_t op = new mpq_t(); + /// gmp_lib.mpq_init(op); + /// gmp_lib.mpq_set_si(op, -1, 3U); + /// + /// // Create, initialize, and set the value of a new integer to 5. + /// mpz_t den = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(den, 5U); + /// + /// // Set the denominator of op. + /// gmp_lib.mpq_set_den(op, den); + /// + /// // Assert that op is -1 / 5. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5U) == 0); + /// + /// // Release unmanaged memory allocated for op and num. + /// gmp_lib.mpq_clear(op); + /// gmp_lib.mpz_clear(den); + /// + /// + /// ' Create, initialize, and set the value of op to -1 / 3. + /// Dim op As New mpq_t() + /// gmp_lib.mpq_init(op) + /// gmp_lib.mpq_set_si(op, -1, 3UI) + /// + /// ' Create, initialize, and set the value of a new integer to 5. + /// Dim den As New mpz_t() + /// gmp_lib.mpz_init_set_ui(den, 5UI) + /// + /// ' Set the denominator of op. + /// gmp_lib.mpq_set_den(op, den) + /// + /// ' Assert that op is -1 / 5. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5UI) = 0) + /// + /// ' Release unmanaged memory allocated for op and num. + /// gmp_lib.mpq_clear(op) + /// gmp_lib.mpz_clear(den) + /// + /// + public static void mpq_set_den(mpq_t rational, /*const*/ mpz_t denominator) + { + if (rational == null) throw new ArgumentNullException("rational"); + if (denominator == null) throw new ArgumentNullException("denominator"); + SafeNativeMethods.__gmpq_set_den(rational.ToIntPtr(), denominator.ToIntPtr()); + } + + /// + /// Set to the value of . There is no rounding, this conversion is exact. + /// + /// The result rational. + /// The operand . + /// + /// + /// + /// GNU MP - Rational Conversions + /// + /// + /// // Create, initialize, and set a new rational x to 10 / 11. + /// mpq_t x = new mpq_t(); + /// gmp_lib.mpq_init(x); + /// gmp_lib.mpq_set_si(x, 10, 11); + /// + /// // Create, initialize, and set a new float y to -210. + /// mpf_t y = new mpf_t(); + /// gmp_lib.mpf_init(y); + /// gmp_lib.mpf_set_si(y, -210); + /// + /// // Assign the value of y to x. + /// gmp_lib.mpq_set_f(x, y); + /// + /// // Assert that the value of x is -210 / 1. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 1) == 0); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpq_clear(x); + /// gmp_lib.mpf_clear(y); + /// + /// + /// ' Create, initialize, and set a new rational x to 10 / 11. + /// Dim x As New mpq_t() + /// gmp_lib.mpq_init(x) + /// gmp_lib.mpq_set_si(x, 10, 11) + /// + /// ' Create, initialize, and set a new float y to -210. + /// Dim y As New mpf_t() + /// gmp_lib.mpf_init(y) + /// gmp_lib.mpf_set_si(y, -210) + /// + /// ' Assign the value of y to x. + /// gmp_lib.mpq_set_f(x, y) + /// + /// ' Assert that the value of x is -210 / 1. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 1) = 0) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpq_clear(x) + /// gmp_lib.mpf_clear(y) + /// + /// + public static void mpq_set_f(mpq_t rop, /*const*/ mpf_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpq_set_f(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set the numerator of to . + /// + /// The result rational. + /// The operand integer. + /// + /// + /// The function is equivalent to calling with . + /// Direct use of is recommended instead of this functions. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Applying Integer Functions + /// + /// + /// // Create, initialize, and set the value of op to -1 / 3. + /// mpq_t op = new mpq_t(); + /// gmp_lib.mpq_init(op); + /// gmp_lib.mpq_set_si(op, -1, 3U); + /// + /// // Create, initialize, and set the value of a new integer to 5. + /// mpz_t num = new mpz_t(); + /// gmp_lib.mpz_init_set_ui(num, 5U); + /// + /// // Set the numerator of op. + /// gmp_lib.mpq_set_num(op, num); + /// + /// // Assert that op is 5 / 3. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 5, 3U) == 0); + /// + /// // Release unmanaged memory allocated for op and num. + /// gmp_lib.mpq_clear(op); + /// gmp_lib.mpz_clear(num); + /// + /// + /// ' Create, initialize, and set the value of op to -1 / 3. + /// Dim op As New mpq_t() + /// gmp_lib.mpq_init(op) + /// gmp_lib.mpq_set_si(op, -1, 3UI) + /// + /// ' Create, initialize, and set the value of a new integer to 5. + /// Dim num As New mpz_t() + /// gmp_lib.mpz_init_set_ui(num, 5UI) + /// + /// ' Set the numerator of op. + /// gmp_lib.mpq_set_num(op, num) + /// + /// ' Assert that op is 5 / 3. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 5, 3UI) = 0) + /// + /// ' Release unmanaged memory allocated for op and num. + /// gmp_lib.mpq_clear(op) + /// gmp_lib.mpz_clear(num) + /// + /// + public static void mpq_set_num(mpq_t rational, /*const*/ mpz_t numerator) + { + if (rational == null) throw new ArgumentNullException("rational"); + if (numerator == null) throw new ArgumentNullException("numerator"); + SafeNativeMethods.__gmpq_set_num(rational.ToIntPtr(), numerator.ToIntPtr()); + } + + /// + /// Set the value of to / . + /// + /// The result rational. + /// The first operand rational. + /// The second operand rational. + /// + /// + /// Note that if and have common factors, + /// has to be passed to before any + /// operations are performed on . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Rationals + /// + /// + /// // Create and initialize a new rational x. + /// mpq_t x = new mpq_t(); + /// gmp_lib.mpq_init(x); + /// + /// // Set the value of x to -10 / 11. + /// gmp_lib.mpq_set_si(x, -10, 11); + /// + /// // Assert that the value of x is -10 / 1. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -10, 11U) == 0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpq_clear(x); + /// + /// + /// ' Create and initialize a new rational x. + /// Dim x As New mpq_t() + /// gmp_lib.mpq_init(x) + /// + /// ' Set the value of x to -10 / 11. + /// gmp_lib.mpq_set_si(x, -10, 11) + /// + /// ' Assert that the value of x is -10 / 1. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -10, 11UI) = 0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpq_clear(x) + /// + /// + public static void mpq_set_si(mpq_t rop, int /*long int*/ op1, uint /*unsigned long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpq_set_si(rop.ToIntPtr(), op1, op2); + } + + /// + /// Set from a null-terminated string in the given . + /// + /// The result rational. + /// The source string. + /// The base, + /// The return value is 0 if the entire string is a valid number, or -1 if not. + /// + /// + /// The string can be an integer like "41" or a fraction like "41/152". + /// The fraction must be in canonical form + /// (see GNU MP - Rational Number Functions), + /// or if not then must be called. + /// + /// + /// The numerator and optional denominator are parsed the same as in + /// (see GNU MP - Assigning Integers). + /// White space is allowed in the string, and is simply ignored. + /// The base can vary from 2 to 62, or if is 0 then the leading characters are used: + /// 0x or 0X for hex, 0b or 0B for binary, 0 for octal, or decimal otherwise. + /// Note that this is done separately for the numerator and denominator, so for instance 0xEF/100 is 239/100, + /// whereas 0xEF/0x100 is 239/256. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Rationals + /// + /// + /// // Create and initialize a new rational x. + /// mpq_t x = new mpq_t(); + /// gmp_lib.mpq_init(x); + /// + /// // Set the value of x. + /// char_ptr value = new char_ptr("12 345 678 909 876 543 211 234 567 890 987 654 321 / 234 567 890"); + /// gmp_lib.mpq_set_str(x, value, 10); + /// + /// // Assert the value of x. + /// char_ptr s = gmp_lib.mpq_get_str(char_ptr.Zero, 10, x); + /// Assert.IsTrue(s.ToString() == value.ToString().Replace(" ", "")); + /// + /// // Release unmanaged memory allocated for x and string values. + /// gmp_lib.mpq_clear(x); + /// gmp_lib.free(value); + /// gmp_lib.free(s); + /// + /// + /// + /// + public static int mpq_set_str(mpq_t rop, /*const*/ char_ptr str, int @base) + { + if (rop == null) throw new ArgumentNullException("rop"); + return SafeNativeMethods.__gmpq_set_str(rop.ToIntPtr(), str.ToIntPtr(), @base); + } + + /// + /// Set the value of to / . + /// + /// The result rational. + /// The first operand rational. + /// The second operand rational. + /// + /// + /// Note that if and have common factors, + /// has to be passed to before any + /// operations are performed on . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Rationals + /// + /// + /// // Create and initialize a new rational x. + /// mpq_t x = new mpq_t(); + /// gmp_lib.mpq_init(x); + /// + /// // Set the value of x to 10 / 11. + /// gmp_lib.mpq_set_ui(x, 10U, 11U); + /// + /// // Assert that the value of x is 10 / 11. + /// Assert.IsTrue(gmp_lib.mpq_cmp_ui(x, 10U, 11U) == 0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpq_clear(x); + /// + /// + /// ' Create and initialize a new rational x. + /// Dim x As New mpq_t() + /// gmp_lib.mpq_init(x) + /// + /// ' Set the value of x to 10 / 11. + /// gmp_lib.mpq_set_ui(x, 10UI, 11UI) + /// + /// ' Assert that the value of x is 10 / 11. + /// Assert.IsTrue(gmp_lib.mpq_cmp_ui(x, 10UI, 11UI) = 0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpq_clear(x) + /// + /// + public static void mpq_set_ui(mpq_t rop, uint /*unsigned long int*/ op1, uint /*unsigned long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpq_set_ui(rop.ToIntPtr(), op1, op2); + } + + /// + /// Assign from . + /// + /// The result rational. + /// The operand integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Rationals + /// + /// + /// // Create, initialize, and set a new rational x to 10 / 11. + /// mpq_t x = new mpq_t(); + /// gmp_lib.mpq_init(x); + /// gmp_lib.mpq_set_si(x, 10, 11); + /// + /// // Create, initialize, and set a new integer y to -210. + /// mpz_t y = new mpz_t(); + /// gmp_lib.mpz_init(y); + /// gmp_lib.mpz_set_si(y, -210); + /// + /// // Assign the value of y to x. + /// gmp_lib.mpq_set_z(x, y); + /// + /// // Assert that the value of x is -210 / 1. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 1) == 0); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpq_clear(x); + /// gmp_lib.mpz_clear(y); + /// + /// + /// ' Create, initialize, and set a new rational x to 10 / 11. + /// Dim x As New mpq_t() + /// gmp_lib.mpq_init(x) + /// gmp_lib.mpq_set_si(x, 10, 11) + /// + /// ' Create, initialize, and set a new integer y to -210. + /// Dim y As New mpz_t() + /// gmp_lib.mpz_init(y) + /// gmp_lib.mpz_set_si(y, -210) + /// + /// ' Assign the value of y to x. + /// gmp_lib.mpq_set_z(x, y) + /// + /// ' Assert that the value of x is -210 / 1. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 1) = 0) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpq_clear(x) + /// gmp_lib.mpz_clear(y) + /// + /// + public static void mpq_set_z(mpq_t rop, /*const*/ mpz_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpq_set_z(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Return +1 if > 0, 0 if = 0, and -1 if < 0. + /// + /// The operand rational. + /// Return +1 if > 0, 0 if = 0, and -1 if < 0. + /// + /// + /// + /// + /// + /// GNU MP - Comparing Rationals + /// + /// + /// // Create, initialize, and set a new rational x to -10 / 11. + /// mpq_t op = new mpq_t(); + /// gmp_lib.mpq_init(op); + /// gmp_lib.mpq_set_si(op, -10, 11); + /// + /// // Assert that op is negative. + /// Assert.IsTrue(gmp_lib.mpq_sgn(op) == -1); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpq_clear(op); + /// + /// + /// ' Create, initialize, and set a new rational x to -10 / 11. + /// Dim op As New mpq_t() + /// gmp_lib.mpq_init(op) + /// gmp_lib.mpq_set_si(op, -10, 11) + /// + /// ' Assert that op is negative. + /// Assert.IsTrue(gmp_lib.mpq_sgn(op) = -1) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpq_clear(op) + /// + /// + public static int mpq_sgn(/*const*/ mpq_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return op._mp_num._mp_size < 0 ? -1 : (op._mp_num._mp_size > 0 ? 1 : 0); + } + + /// + /// Set to - . + /// + /// The result rational. + /// The first operand rational. + /// The second operand rational. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Rational Arithmetic + /// + /// + /// + /// + /// + /// + public static void mpq_sub(mpq_t difference, /*const*/ mpq_t minuend, /*const*/ mpq_t subtrahend) + { + if (difference == null) throw new ArgumentNullException("difference"); + if (minuend == null) throw new ArgumentNullException("minuend"); + if (subtrahend == null) throw new ArgumentNullException("subtrahend"); + SafeNativeMethods.__gmpq_sub(difference.ToIntPtr(), minuend.ToIntPtr(), subtrahend.ToIntPtr()); + } + + /// + /// Swap the values and efficiently. + /// + /// The first rational. + /// The second rational. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Rationals + /// + /// + /// // Create, initialize, and set a new rational x to 10 / 11. + /// mpq_t x = new mpq_t(); + /// gmp_lib.mpq_init(x); + /// gmp_lib.mpq_set_si(x, 10, 11U); + /// + /// // Create, initialize, and set a new rational x to -210 / 13. + /// mpq_t y = new mpq_t(); + /// gmp_lib.mpq_init(y); + /// gmp_lib.mpq_set_si(y, -210, 13U); + /// + /// // Swap the values of x and y. + /// gmp_lib.mpq_swap(x, y); + /// + /// // Assert that the values have been swapped. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 13U) == 0); + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(y, 10, 11U) == 0); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpq_clears(x, y, null); + /// + /// + /// ' Create, initialize, and set a new rational x to 10 / 11. + /// Dim x As New mpq_t() + /// gmp_lib.mpq_init(x) + /// gmp_lib.mpq_set_si(x, 10, 11UI) + /// + /// ' Create, initialize, and set a new rational x to -210 / 13. + /// Dim y As New mpq_t() + /// gmp_lib.mpq_init(y) + /// gmp_lib.mpq_set_si(y, -210, 13UI) + /// + /// ' Swap the values of x and y. + /// gmp_lib.mpq_swap(x, y) + /// + /// ' Assert that the values have been swapped. + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 13UI) = 0) + /// Assert.IsTrue(gmp_lib.mpq_cmp_si(y, 10, 11UI) = 0) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpq_clears(x, y, Nothing) + /// + /// + public static void mpq_swap(mpq_t rop1, mpq_t rop2) + { + if (rop1 == null) throw new ArgumentNullException("rop1"); + if (rop2 == null) throw new ArgumentNullException("rop2"); + SafeNativeMethods.__gmpq_swap(rop1.ToIntPtr(), rop2.ToIntPtr()); + } + + #endregion + + #region "Float (i.e. F) routines." + + /// + /// Set to ||. + /// + /// The result float. + /// The operand. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to -10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, -10); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = |x|. + /// gmp_lib.mpf_neg(z, x); + /// + /// // Assert that the value of z is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to -10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, -10) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = |x|. + /// gmp_lib.mpf_neg(z, x) + /// + /// ' Assert that the value of z is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 10.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static void mpf_abs(mpf_t rop, /*const*/ mpf_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpf_abs(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set to + . + /// + /// The result float. + /// The first operand. + /// The second operand. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 10); + /// + /// // Create, initialize, and set a new floating-point number y to -210. + /// mpf_t y = new mpf_t(); + /// gmp_lib.mpf_init_set_si(y, -210); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = x + y. + /// gmp_lib.mpf_add(z, x, y); + /// + /// // Assert that the value of z is -200. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == -200.0); + /// + /// // Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpf_clears(x, y, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 10) + /// + /// ' Create, initialize, and set a new floating-point number y to -210. + /// Dim y As New mpf_t() + /// gmp_lib.mpf_init_set_si(y, -210) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = x + y. + /// gmp_lib.mpf_add(z, x, y) + /// + /// ' Assert that the value of z is -200. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = -200.0) + /// + /// ' Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpf_clears(x, y, z, Nothing) + /// + /// + public static void mpf_add(mpf_t rop, /*const*/ mpf_t op1, /*const*/ mpf_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpf_add(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Set to + . + /// + /// The result float. + /// The first operand. + /// The second operand. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 10); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = x + 210. + /// gmp_lib.mpf_add_ui(z, x, 210U); + /// + /// // Assert that the value of z is 220. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 220.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 10) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = x + 210. + /// gmp_lib.mpf_add_ui(z, x, 210UI) + /// + /// ' Assert that the value of z is 220. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 220.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static void mpf_add_ui(mpf_t rop, /*const*/ mpf_t op1, uint /*unsigned long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpf_add_ui(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Set to rounded to the next higher integer. + /// + /// The result float. + /// The operand float. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Float Functions + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10.4. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_d(x, 10.4); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = ceil(x). + /// gmp_lib.mpf_ceil(z, x); + /// + /// // Assert that the value of z is 11. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 11.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10.4. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_d(x, 10.4) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = ceil(x). + /// gmp_lib.mpf_ceil(z, x) + /// + /// ' Assert that the value of z is 11. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 11.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static void mpf_ceil(mpf_t rop, /*const*/ mpf_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpf_ceil(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Free the space occupied by . + /// + /// The operand float. + /// + /// + /// Make sure to call this function for all variables when you are done with them. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Floats + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create and initialize a new floating-point number x. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init(x); + /// + /// // Assert that the value of x is 0.0. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create and initialize a new floating-point number x. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init(x) + /// + /// ' Assert that the value of x is 0.0. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = 0.0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static void mpf_clear(mpf_t x) + { + if (x == null) throw new ArgumentNullException("x"); + x._initialized = false; + SafeNativeMethods.__gmpf_clear(x.ToIntPtr()); + } + + /// + /// Free the space occupied by a NULL-terminated list of variables. + /// + /// The operand float. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Floats + /// + /// + /// // Create new floating-point numbers x1, x2 and x3. + /// mpf_t x1 = new mpf_t(); + /// mpf_t x2 = new mpf_t(); + /// mpf_t x3 = new mpf_t(); + /// + /// // Initialize the floating-point numbers. + /// gmp_lib.mpf_inits(x1, x2, x3, null); + /// + /// // Assert that their value is 0. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x1) == 0.0); + /// Assert.IsTrue(gmp_lib.mpf_get_d(x2) == 0.0); + /// Assert.IsTrue(gmp_lib.mpf_get_d(x3) == 0.0); + /// + /// // Release unmanaged memory allocated for the floating-point numbers. + /// gmp_lib.mpf_clears(x1, x2, x3, null); + /// + /// + /// ' Create new floating-point numbers x1, x2 and x3. + /// Dim x1 As New mpf_t() + /// Dim x2 As New mpf_t() + /// Dim x3 As New mpf_t() + /// + /// ' Initialize the floating-point numbers. + /// gmp_lib.mpf_inits(x1, x2, x3, Nothing) + /// + /// ' Assert that their value is 0. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x1) = 0.0) + /// Assert.IsTrue(gmp_lib.mpf_get_d(x2) = 0.0) + /// Assert.IsTrue(gmp_lib.mpf_get_d(x3) = 0.0) + /// + /// ' Release unmanaged memory allocated for the floating-point numbers. + /// gmp_lib.mpf_clears(x1, x2, x3, Nothing) + /// + /// + public static void mpf_clears(params mpf_t[] x) + { + if (x == null) throw new ArgumentNullException("x"); + foreach (mpf_t a in x) { if (a != null) mpf_clear(a); } + } + + /// + /// Compare and . + /// + /// The first operand float. + /// The second operand float. + /// Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Comparison + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 512. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 512); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init_set_si(z, 128); + /// + /// // Assert that x > z. + /// Assert.IsTrue(gmp_lib.mpf_cmp(x, z) > 0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 512. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 512) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init_set_si(z, 128) + /// + /// ' Assert that x > z. + /// Assert.IsTrue(gmp_lib.mpf_cmp(x, z) > 0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static int mpf_cmp(/*const*/ mpf_t op1, /*const*/ mpf_t op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + return SafeNativeMethods.__gmpf_cmp(op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Compare and . + /// + /// The first operand float. + /// The second operand float. + /// Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2. + /// + /// + /// + /// + /// + /// + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 512. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 512); + /// + /// // Create and initialize a new floating-point number z. + /// mpz_t z = new mpz_t(); + /// gmp_lib.mpz_init_set_si(z, 128); + /// + /// // Assert that x > z. + /// Assert.IsTrue(gmp_lib.mpf_cmp_z(x, z) > 0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clear(x); + /// gmp_lib.mpz_clear(z); + /// /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 512. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 512) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpz_t() + /// gmp_lib.mpz_init_set_si(z, 128) + /// + /// ' Assert that x > z. + /// Assert.IsTrue(gmp_lib.mpf_cmp_z(x, z) > 0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clear(x) + /// gmp_lib.mpz_clear(z) + /// + /// + public static int mpf_cmp_z(/*const*/ mpf_t op1, /*const*/ mpz_t op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + return SafeNativeMethods.__gmpf_cmp_z(op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Compare and . + /// + /// The first operand float. + /// The second operand float. + /// Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2. + /// + /// + /// can be called with an infinity, but results are undefined for a NaN. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 512. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 512); + /// + /// // Assert that x > 128.0. + /// Assert.IsTrue(gmp_lib.mpf_cmp_d(x, 128.0) > 0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 512. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 512) + /// + /// ' Assert that x > 128.0. + /// Assert.IsTrue(gmp_lib.mpf_cmp_d(x, 128.0) > 0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static int mpf_cmp_d(/*const*/ mpf_t op1, double op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + return SafeNativeMethods.__gmpf_cmp_d(op1.ToIntPtr(), op2); + } + + /// + /// Compare and . + /// + /// The first operand float. + /// The second operand float. + /// Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2. + /// + /// + /// + /// + /// + /// + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 512. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 512); + /// + /// // Assert that x > 128. + /// Assert.IsTrue(gmp_lib.mpf_cmp_si(x, 128) > 0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 512. + /// Dim x As New mpf_t() + /// + /// gmp_lib.mpf_init_set_si(x, 512) + /// + /// ' Assert that x > 128. + /// Assert.IsTrue(gmp_lib.mpf_cmp_si(x, 128) > 0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static int mpf_cmp_si(/*const*/ mpf_t op1, int /*long int*/ op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + return SafeNativeMethods.__gmpf_cmp_si(op1.ToIntPtr(), op2); + } + + /// + /// Compare and . + /// + /// The first operand float. + /// The second operand float. + /// Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2. + /// + /// + /// + /// + /// + /// + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 512. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 512); + /// + /// // Assert that x > 128. + /// Assert.IsTrue(gmp_lib.mpf_cmp_ui(x, 128) > 0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 512. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 512) + /// + /// ' Assert that x > 128. + /// Assert.IsTrue(gmp_lib.mpf_cmp_ui(x, 128) > 0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static int mpf_cmp_ui(/*const*/ mpf_t op1, uint /*unsigned long int*/ op2) + { + if (op1 == null) throw new ArgumentNullException("op1"); + return SafeNativeMethods.__gmpf_cmp_ui(op1.ToIntPtr(), op2); + } + + /// + /// Set to / . + /// + /// The result float. + /// The first operand. + /// The second operand. + /// + /// + /// Division is undefined if the divisor is zero, and passing a zero divisor to the divide + /// functions will make it intentionally divide by zero. + /// This lets the user handle arithmetic exceptions in division functions in the same manner + /// as other arithmetic exceptions. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 10); + /// + /// // Create, initialize, and set a new floating-point number y to -210. + /// mpf_t y = new mpf_t(); + /// gmp_lib.mpf_init_set_si(y, -210); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = y / x. + /// gmp_lib.mpf_div(z, y, x); + /// + /// // Assert that the value of z is -21. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == -21.0); + /// + /// // Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpf_clears(x, y, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 10) + /// + /// ' Create, initialize, and set a new floating-point number y to -210. + /// Dim y As New mpf_t() + /// gmp_lib.mpf_init_set_si(y, -210) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = y / x. + /// gmp_lib.mpf_div(z, y, x) + /// + /// ' Assert that the value of z is -21. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = -21.0) + /// + /// ' Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpf_clears(x, y, z, Nothing) + /// + /// + public static void mpf_div(mpf_t rop, /*const*/ mpf_t op1, /*const*/ mpf_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpf_div(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Set to / 2^. + /// + /// The result float. + /// The fisrt operand. + /// The second operand. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 512. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 512); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = x / 2^8. + /// gmp_lib.mpf_div_2exp(z, x, 8U); + /// + /// // Assert that the value of z is 2. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 2.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 512. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 512) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = x / 2^8. + /// gmp_lib.mpf_div_2exp(z, x, 8UI) + /// + /// ' Assert that the value of z is 2. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 2.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static void mpf_div_2exp(mpf_t rop, /*const*/ mpf_t op1, uint /*mp_bitcnt_t*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpf_div_2exp(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Set to / . + /// + /// The result float. + /// The first operand. + /// The second operand. + /// + /// + /// Division is undefined if the divisor is zero, and passing a zero divisor to the divide + /// functions will make it intentionally divide by zero. + /// This lets the user handle arithmetic exceptions in division functions in the same manner + /// as other arithmetic exceptions. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number y to -210. + /// mpf_t y = new mpf_t(); + /// gmp_lib.mpf_init_set_si(y, -210); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = y / 10. + /// gmp_lib.mpf_div_ui(z, y, 10U); + /// + /// // Assert that the value of z is -21. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == -21.0); + /// + /// // Release unmanaged memory allocated for y and z. + /// gmp_lib.mpf_clears(y, z, null); + /// + /// + /// + /// + public static void mpf_div_ui(mpf_t rop, /*const*/ mpf_t op1, uint /*unsigned long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpf_div_ui(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Return non-zero if fits in a 32-bit integer, when truncated to an integer. + /// + /// The operand float. + /// Return non-zero if fits in a 32-bit integer, when truncated to an integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Float Functions + /// + /// + /// // Create, initialize, and set the value of op 4294967295. + /// mpf_t op = new mpf_t(); + /// gmp_lib.mpf_init_set_ui(op, uint.MaxValue); + /// + /// // Assert that op does not fit in int. + /// Assert.IsTrue(gmp_lib.mpf_fits_sint_p(op) == 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op 4294967295. + /// Dim op As New mpf_t() + /// gmp_lib.mpf_init_set_ui(op, UInteger.MaxValue) + /// + /// ' Assert that op does not fit in int. + /// Assert.IsTrue(gmp_lib.mpf_fits_sint_p(op) = 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op) + /// + /// + public static int mpf_fits_sint_p(/*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpf_fits_sint_p(op.ToIntPtr()); + } + + /// + /// Return non-zero if fits in a 32-bit integer, when truncated to an integer. + /// + /// The operand float. + /// Return non-zero if fits in a 32-bit integer, when truncated to an integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Float Functions + /// + /// + /// // Create, initialize, and set the value of op 4294967295. + /// mpf_t op = new mpf_t(); + /// gmp_lib.mpf_init_set_ui(op, uint.MaxValue); + /// + /// // Assert that op does not fit in long. + /// Assert.IsTrue(gmp_lib.mpf_fits_slong_p(op) == 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op 4294967295. + /// Dim op As New mpf_t() + /// gmp_lib.mpf_init_set_ui(op, UInteger.MaxValue) + /// + /// ' Assert that op does not fit in long. + /// Assert.IsTrue(gmp_lib.mpf_fits_slong_p(op) = 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op) + /// + /// + public static int mpf_fits_slong_p(/*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpf_fits_slong_p(op.ToIntPtr()); + } + + /// + /// Return non-zero if fits in a 16-bit integer, when truncated to an integer. + /// + /// The operand float. + /// Return non-zero if fits in a 16-bit integer, when truncated to an integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Float Functions + /// + /// + /// // Create, initialize, and set the value of op 4294967295. + /// mpf_t op = new mpf_t(); + /// gmp_lib.mpf_init_set_ui(op, uint.MaxValue); + /// + /// // Assert that op does not fit in short. + /// Assert.IsTrue(gmp_lib.mpf_fits_sshort_p(op) == 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op 4294967295. + /// Dim op As New mpf_t() + /// gmp_lib.mpf_init_set_ui(op, UInteger.MaxValue) + /// + /// ' Assert that op does not fit in short. + /// Assert.IsTrue(gmp_lib.mpf_fits_sshort_p(op) = 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op) + /// + /// + public static int mpf_fits_sshort_p(/*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpf_fits_sshort_p(op.ToIntPtr()); + } + + /// + /// Return non-zero if fits in an unsigned 32-bit integer, when truncated to an integer. + /// + /// The operand float. + /// Return non-zero if fits in an unsigned 32-bit integer, when truncated to an integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Float Functions + /// + /// + /// // Create, initialize, and set the value of op 4294967295. + /// mpf_t op = new mpf_t(); + /// gmp_lib.mpf_init_set_ui(op, uint.MaxValue); + /// + /// // Assert that op does not fit in uint. + /// Assert.IsTrue(gmp_lib.mpf_fits_uint_p(op) > 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op 4294967295. + /// Dim op As New mpf_t() + /// gmp_lib.mpf_init_set_ui(op, UInteger.MaxValue) + /// + /// ' Assert that op does not fit in uint. + /// Assert.IsTrue(gmp_lib.mpf_fits_uint_p(op) > 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op) + /// + /// + public static int mpf_fits_uint_p(/*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpf_fits_uint_p(op.ToIntPtr()); + } + + /// + /// Return non-zero if fits in an unsigned 32-bit integer, when truncated to an integer. + /// + /// The operand float. + /// Return non-zero if fits in an unsigned 32-bit integer, when truncated to an integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Float Functions + /// + /// + /// // Create, initialize, and set the value of op 4294967295. + /// mpf_t op = new mpf_t(); + /// gmp_lib.mpf_init_set_ui(op, uint.MaxValue); + /// + /// // Assert that op does not fit in int. + /// Assert.IsTrue(gmp_lib.mpf_fits_sint_p(op) == 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op 4294967295. + /// Dim op As New mpf_t() + /// gmp_lib.mpf_init_set_ui(op, UInteger.MaxValue) + /// + /// ' Assert that op does not fit in int. + /// Assert.IsTrue(gmp_lib.mpf_fits_sint_p(op) = 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op) + /// + /// + public static int mpf_fits_ulong_p(/*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpf_fits_ulong_p(op.ToIntPtr()); + } + + /// + /// Return non-zero if fits in an unsigned 16-bit integer, when truncated to an integer. + /// + /// The operand float. + /// Return non-zero if fits in an unsigned 16-bit integer, when truncated to an integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Float Functions + /// + /// + /// + /// + /// // Create, initialize, and set the value of op 4294967295. + /// mpf_t op = new mpf_t(); + /// gmp_lib.mpf_init_set_ui(op, uint.MaxValue); + /// + /// // Assert that op does not fit in ushort. + /// Assert.IsTrue(gmp_lib.mpf_fits_ushort_p(op) == 0); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op); + /// ' Create, initialize, and set the value of op 4294967295. + /// Dim op As New mpf_t() + /// gmp_lib.mpf_init_set_ui(op, UInteger.MaxValue) + /// + /// ' Assert that op does not fit in ushort. + /// Assert.IsTrue(gmp_lib.mpf_fits_ushort_p(op) = 0) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op) + /// + /// + public static int mpf_fits_ushort_p(/*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpf_fits_ushort_p(op.ToIntPtr()); + } + + /// + /// Set to rounded to the next lower integer. + /// + /// The result float. + /// The operand float. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Float Functions + /// + /// + /// / Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10.4. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_d(x, 10.4); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = floor(x). + /// gmp_lib.mpf_floor(z, x); + /// + /// // Assert that the value of z is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10.4. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_d(x, 10.4) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = floor(x). + /// gmp_lib.mpf_floor(z, x) + /// + /// ' Assert that the value of z is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 10.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static void mpf_floor(mpf_t rop, /*const*/ mpf_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpf_floor(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Convert to a , truncating if necessary (i.e. rounding towards zero). + /// + /// The operand float. + /// The cpnverted . + /// + /// + /// If the exponent in is too big or too small to fit a then the result is system dependent. + /// For too big an infinity is returned when available. + /// For too small 0.0 is normally returned. + /// Hardware overflow, underflow and denorm traps may or may not occur. + /// + /// + /// + /// + /// + /// + /// GNU MP - Converting Floats + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number to -123.0 + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_d(x, -123.0); + /// + /// // Assert that the value of x is -123.0. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number to -123.0 + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_d(x, -123.0) + /// + /// ' Assert that the value of x is -123.0. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = -123.0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static double mpf_get_d(/*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpf_get_d(op.ToIntPtr()); + } + + /// + /// Convert op to a double, truncating if necessary (i.e. rounding towards zero), and with an exponent returned separately. + /// + /// Pointer to 32-bit signed integer. + /// The operand float. + /// The return value is in the range 0.5 ≤ |d| < 1 and the exponent is stored at . d * 2^ is the (truncated) value. If is zero, the return is 0.0 and 0 is stored at . + /// + /// + /// This is similar to the standard C frexp function + /// (see GNU C - Normalization Functions in The GNU C Library Reference Manual). + /// + /// + /// + /// + /// + /// + /// GNU MP - Converting Floats + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number to -8.0 + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_d(x, -8.0); + /// + /// // Assert that the absolute value of x is 0.5 x 2^4. + /// ptr<int> exp = new ptr<int>(0); + /// Assert.IsTrue(gmp_lib.mpf_get_d_2exp(exp, x) == 0.5); + /// Assert.IsTrue(exp.Value == 4); + /// + /// // Release unmanaged memory allocated for x and exp. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number to -8.0 + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_d(x, -8.0) + /// + /// ' Assert that the absolute value of x is 0.5 x 2^4. + /// Dim exp As New ptr(Of Integer)(0) + /// Assert.IsTrue(gmp_lib.mpf_get_d_2exp(exp, x) = 0.5) + /// Assert.IsTrue(exp.Value = 4) + /// + /// ' Release unmanaged memory allocated for x and exp. + /// gmp_lib.mpf_clear(x) + /// + /// + public static double mpf_get_d_2exp(ptr /*long int **/ exp, /*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpf_get_d_2exp(ref exp.Value, op.ToIntPtr()); + } + + /// + /// Return the default precision actually used. + /// + /// The default precision actually used. + /// + /// + /// An object must be initialized before storing the first value in it. + /// The functions and are used for that purpose. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Floats + /// + /// + /// // Set default precision to 128 bits. + /// gmp_lib.mpf_set_default_prec(128U); + /// + /// // Assert that the value of x is 128 bits. + /// Assert.IsTrue(gmp_lib.mpf_get_default_prec() == 128U); + /// + /// + /// ' Set default precision to 128 bits. + /// gmp_lib.mpf_set_default_prec(128UI) + /// + /// ' Assert that the value of x is 128 bits. + /// Assert.IsTrue(gmp_lib.mpf_get_default_prec() = 128UI) + /// + /// + public static mp_bitcnt_t mpf_get_default_prec() + { + return new mp_bitcnt_t(SafeNativeMethods.__gmpf_get_default_prec()); + } + + /// + /// Return the current precision of , in bits. + /// + /// The operand float. + /// The current precision of , in bits. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Floats + /// + /// + /// // Create and initialize a new floating-point number x with 64-bit precision. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init2(x, 64U); + /// + /// // Assert that the value of x is 0.0, and that its precision is 64 bits. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0); + /// Assert.IsTrue(gmp_lib.mpf_get_prec(x) == 64U); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Create and initialize a new floating-point number x with 64-bit precision. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init2(x, 64UI) + /// + /// ' Assert that the value of x is 0.0, and that its precision is 64 bits. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = 0.0) + /// Assert.IsTrue(gmp_lib.mpf_get_prec(x) = 64UI) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static mp_bitcnt_t mpf_get_prec(/*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return new mp_bitcnt_t(SafeNativeMethods.__gmpf_get_prec(op.ToIntPtr())); + } + + /// + /// Convert to a 32-bit integer, truncating any fraction part. + /// + /// The operand float. + /// The converted integer. + /// + /// + /// If is too big for the return type, the result is undefined. + /// + /// + /// See also and + /// (see GNU MP - Miscellaneous Float Functions). + /// + /// + /// + /// + /// + /// + /// GNU MP - Converting Floats + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number to -8.0 + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_d(x, -8.0); + /// + /// // Assert that the value of x is -8. + /// Assert.IsTrue(gmp_lib.mpf_get_si(x) == -8); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number to -8.0 + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_d(x, -8.0) + /// + /// ' Assert that the value of x is -8. + /// Assert.IsTrue(gmp_lib.mpf_get_si(x) = -8) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static int /*long int*/ mpf_get_si(/*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpf_get_si(op.ToIntPtr()); + } + + /// + /// Convert to a string of digits in base . + /// + /// + /// + /// + /// + /// + /// A pointer to the result string is returned, being either the allocated block or the given . + /// + /// + /// The argument may vary from 2 to 62 or from -2 to -36. + /// Up to digits will be generated. + /// Trailing zeros are not returned. + /// No more digits than can be accurately represented by are ever generated. + /// If is 0 then that accurate maximum number of digits are generated. + /// + /// + /// For in the range 2..36, digits and lower-case letters are used; for -2..-36, + /// digits and upper-case letters are used; for 37..62, digits, upper-case letters, and lower-case letters + /// (in that significance order) are used. + /// + /// + /// If is NULL, the result string is allocated using the current allocation function + /// (see GNU MP - Custom Allocation). + /// The block will be strlen(str) + 1 bytes, that being exactly enough for the string and null-terminator. + /// + /// + /// If is not NULL, it should point to a block of + 2 bytes, + /// that being enough for the mantissa, a possible minus sign, and a null-terminator. + /// When is 0 to get all significant digits, an application won’t be able to know + /// the space required, and should be NULL in that case. + /// + /// + /// The generated string is a fraction, with an implicit radix point immediately to the left of the first digit. + /// The applicable exponent is written through the pointer. + /// For example, the number 3.1416 would be returned as string "31416" and exponent 1. + /// + /// + /// When is zero, an empty string is produced and the exponent returned is 0. + /// + /// + /// + /// + /// + /// + /// GNU MP - Converting Floats + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number to -8.0 + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_d(x, -8.0); + /// + /// // Assert that the value of x is -8. + /// ptr<mp_exp_t> exp = new ptr<mp_exp_t>(0); + /// char_ptr value = gmp_lib.mpf_get_str(char_ptr.Zero, exp, 10, 0, x); + /// Assert.IsTrue(value.ToString() == "-8"); + /// Assert.IsTrue(exp.Value == 1); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// gmp_lib.free(value); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number to -8.0 + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_d(x, -8.0) + /// + /// ' Assert that the value of x is -8. + /// Dim exp As New ptr(Of mp_exp_t)(0) + /// Dim value As char_ptr = gmp_lib.mpf_get_str(char_ptr.Zero, exp, 10, 0, x) + /// Assert.IsTrue(value.ToString() = "-8") + /// Assert.IsTrue(exp.Value = 1) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// gmp_lib.free(value) + /// + /// + public static char_ptr mpf_get_str(char_ptr str, ptr expptr, int @base, size_t n_digits, /*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + if (IntPtr.Size == 4) + return new char_ptr(SafeNativeMethods.__gmpf_get_str_x86(str.ToIntPtr(), ref expptr.Value._value, @base, (uint)n_digits, op.ToIntPtr())); + else + return new char_ptr(SafeNativeMethods.__gmpf_get_str_x64(str.ToIntPtr(), ref expptr.Value._value, @base, n_digits, op.ToIntPtr())); + } + + /// + /// Convert to an unsigned 32-bit integer, truncating any fraction part. + /// + /// The operand float. + /// The converted integer. + /// + /// + /// If is too big for the return type, the result is undefined. + /// + /// + /// See also and + /// (see GNU MP - Miscellaneous Float Functions). + /// + /// + /// + /// + /// + /// + /// GNU MP - Converting Floats + /// + /// + /// + /// + /// + /// + public static uint /*unsigned long int*/ mpf_get_ui(/*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpf_get_ui(op.ToIntPtr()); + } + + /// + /// Initialize to 0. + /// + /// The operand float. + /// + /// + /// Normally, a variable should be initialized once only or at least be cleared, using , + /// between initializations. The precision of is undefined unless a default precision has + /// already been established by a call to . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Floats + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create and initialize a new floating-point number x. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init(x); + /// + /// // Assert that the value of x is 0.0. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create and initialize a new floating-point number x. + /// Dim x As New mpf_t() + /// + /// gmp_lib.mpf_init(x) + /// + /// ' Assert that the value of x is 0.0. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = 0.0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static void mpf_init(mpf_t x) + { + if (x == null) throw new ArgumentNullException("x"); + SafeNativeMethods.__gmpf_init(x.ToIntPtr()); + x._initialized = true; + } + + /// + /// Initialize to 0 and set its precision to be at least bits. + /// + /// The operand float. + /// The minimum precision in bits. + /// + /// + /// Normally, a variable should be initialized once only or at least be cleared, using , between initializations. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Floats + /// + /// + /// // Create and initialize a new floating-point number x with 64-bit precision. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init2(x, 64U); + /// + /// // Assert that the value of x is 0.0, and that its precision is 64 bits. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0); + /// uint p = gmp_lib.mpf_get_prec(x); + /// Assert.IsTrue(gmp_lib.mpf_get_prec(x) == 64U); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Create and initialize a new floating-point number x with 64-bit precision. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init2(x, 64UI) + /// + /// ' Assert that the value of x is 0.0, and that its precision is 64 bits. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = 0.0) + /// Dim p As UInteger = gmp_lib.mpf_get_prec(x) + /// Assert.IsTrue(gmp_lib.mpf_get_prec(x) = 64UI) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static void mpf_init2(mpf_t x, mp_bitcnt_t prec) + { + if (x == null) throw new ArgumentNullException("x"); + SafeNativeMethods.__gmpf_init2(x.ToIntPtr(), prec); + x._initialized = true; + } + + /// + /// Initialize a NULL-terminated list of variables, and set their values to 0. + /// + /// The operand float. + /// + /// + /// The precision of the initialized variables is undefined unless a default precision has already + /// been established by a call to . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Floats + /// + /// + /// // Create new floating-point numbers x1, x2 and x3. + /// mpf_t x1 = new mpf_t(); + /// mpf_t x2 = new mpf_t(); + /// mpf_t x3 = new mpf_t(); + /// + /// // Initialize the floating-point numbers. + /// gmp_lib.mpf_inits(x1, x2, x3, null); + /// + /// // Assert that their value is 0. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x1) == 0.0); + /// Assert.IsTrue(gmp_lib.mpf_get_d(x2) == 0.0); + /// Assert.IsTrue(gmp_lib.mpf_get_d(x3) == 0.0); + /// + /// // Release unmanaged memory allocated for the floating-point numbers. + /// gmp_lib.mpf_clears(x1, x2, x3, null); + /// + /// + /// + /// + public static void mpf_inits(params mpf_t[] x) + { + if (x == null) throw new ArgumentNullException("x"); + foreach (mpf_t a in x) { if (a != null) mpf_init(a); } + } + + /// + /// Initialize and set its value from . + /// + /// The result float. + /// The operand. + /// + /// + /// The precision of will be taken from the active default precision, as set by . + /// + /// + /// + /// + /// + /// + /// GNU MP - Combined Float Initialization and Assignment + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 10); + /// + /// // Create, initialize, and set a new floating-point number y to x. + /// mpf_t y = new mpf_t(); + /// gmp_lib.mpf_init_set(y, x); + /// + /// // Assert that the value of y is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(y) == 10.0); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clears(x, y, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 10) + /// + /// ' Create, initialize, and set a new floating-point number y to x. + /// Dim y As New mpf_t() + /// gmp_lib.mpf_init_set(y, x) + /// + /// ' Assert that the value of y is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(y) = 10.0) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clears(x, y, Nothing) + /// + /// + public static void mpf_init_set(mpf_t rop, /*const*/ mpf_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpf_init_set(rop.ToIntPtr(), op.ToIntPtr()); + rop._initialized = true; + } + + /// + /// Initialize and set its value from . + /// + /// The result float. + /// The operand. + /// + /// + /// The precision of will be taken from the active default precision, as set by . + /// + /// + /// + /// + /// + /// + /// GNU MP - Combined Float Initialization and Assignment + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number to -123.0 + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_d(x, -123.0); + /// + /// // Assert that the value of x is -123.0. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number to -123.0 + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_d(x, -123.0) + /// + /// ' Assert that the value of x is -123.0. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = -123.0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static void mpf_init_set_d(mpf_t rop, double op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpf_init_set_d(rop.ToIntPtr(), op); + rop._initialized = true; + } + + /// + /// Initialize and set its value from . + /// + /// The result float. + /// The operand. + /// + /// + /// The precision of will be taken from the active default precision, as set by . + /// + /// + /// + /// + /// + /// + /// GNU MP - Combined Float Initialization and Assignment + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize and set a new floating-point number to -123. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, -123); + /// + /// // Assert that the value of x is -123. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize and set a new floating-point number to -123. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, -123) + /// + /// ' Assert that the value of x is -123. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = -123.0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static void mpf_init_set_si(mpf_t rop, int /*long int*/ op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpf_init_set_si(rop.ToIntPtr(), op); + rop._initialized = true; + } + + /// + /// Initialize and set its value from the string in . + /// + /// The result float. + /// The operand string. + /// The base. + /// This function returns 0 if the entire string is a valid number in base . Otherwise it returns -1. + /// + /// + /// See for details on the assignment operation. + /// + /// + /// Note that is initialized even if an error occurs. (I.e., you have to call for it.) + /// + /// + /// The precision of will be taken from the active default precision, as set by . + /// + /// + /// + /// + /// + /// + /// GNU MP - Combined Float Initialization and Assignment + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 0.0234. + /// char_ptr value = new char_ptr("234e-4"); + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_str(x, value, 10); + /// + /// // Assert that x is 40. + /// Assert.IsTrue(x.ToString() == "0.234e-1"); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clear(x); + /// gmp_lib.free(value); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 0.0234. + /// Dim value As New char_ptr("234e-4") + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_str(x, value, 10) + /// + /// ' Assert that x is 40. + /// Assert.IsTrue(x.ToString() = "0.234e-1") + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clear(x) + /// gmp_lib.free(value) + /// + /// + public static int mpf_init_set_str(mpf_t rop, /*const*/ char_ptr str, int @base) + { + if (rop == null) throw new ArgumentNullException("rop"); + int result = SafeNativeMethods.__gmpf_init_set_str(rop.ToIntPtr(), str.ToIntPtr(), @base); + rop._initialized = true; + return result; + } + + /// + /// Initialize and set its value from . + /// + /// The result float. + /// The operand. + /// + /// + /// The precision of will be taken from the active default precision, as set by . + /// + /// + /// + /// + /// + /// + /// GNU MP - Combined Float Initialization and Assignment + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number to 100. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_ui(x, 100U); + /// + /// // Assert that the value of x is 100. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == 100.0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number to 100. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_ui(x, 100UI) + /// + /// ' Assert that the value of x is 100. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = 100.0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static void mpf_init_set_ui(mpf_t rop, uint /*unsigned long int*/ op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpf_init_set_ui(rop.ToIntPtr(), op); + rop._initialized = true; + } + + /// + /// Read a string in base from , and put the read float in . + /// + /// The result float. + /// Pointer to file stream. + /// The base. + /// Return the number of bytes read, or if an error occurred, return 0. + /// + /// + /// The string is of the form "M@N" or, if the base is 10 or less, alternatively "MeN". + /// "M" is the mantissa and "N’" is the exponent. + /// The mantissa is always in the specified . + /// The exponent is either in the specified or, if is negative, in decimal. + /// The decimal point expected is taken from the current locale, on systems providing localeconv. + /// + /// + /// The argument may be in the ranges 2 to 36, or -36 to -2. + /// Negative values are used to specify that the exponent is in decimal. + /// + /// + /// Unlike the corresponding mpz function, the will not be determined from the leading + /// characters of the string if base is 0. + /// This is so that numbers like "0.23" are not interpreted as octal. + /// + /// + /// + /// GNU MP - I/O of Floats + /// + /// + /// // Create and initialize op. + /// mpf_t op = new mpf_t(); + /// gmp_lib.mpf_init(op); + /// + /// // Write op to a temporary file. + /// string pathname = System.IO.Path.GetTempFileName(); + /// System.IO.File.WriteAllText(pathname, "0.123456e6"); + /// + /// // Read op from the temporary file, and assert that the number of bytes read is 6. + /// ptr<FILE> stream = new ptr<FILE>(); + /// _wfopen_s(out stream.Value.Value, pathname, "r"); + /// Assert.IsTrue(gmp_lib.mpf_inp_str(op, stream, 10) == 10); + /// fclose(stream.Value.Value); + /// + /// // Assert that op is 123456. + /// Assert.IsTrue(gmp_lib.mpf_get_ui(op) == 123456U); + /// + /// // Delete temporary file. + /// System.IO.File.Delete(pathname); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op); + /// + /// + /// ' Create and initialize op. + /// Dim op As New mpf_t() + /// gmp_lib.mpf_init(op) + /// + /// ' Write op to a temporary file. + /// Dim pathname As String = System.IO.Path.GetTempFileName() + /// System.IO.File.WriteAllText(pathname, "0.123456e6") + /// + /// ' Read op from the temporary file, and assert that the number of bytes read is 6. + /// Dim stream As New ptr(Of FILE)() + /// _wfopen_s(stream.Value.Value, pathname, "r") + /// Assert.IsTrue(gmp_lib.mpf_inp_str(op, stream, 10) = 10) + /// fclose(stream.Value.Value) + /// + /// ' Assert that op is 123456. + /// Assert.IsTrue(gmp_lib.mpf_get_ui(op) = 123456UI) + /// + /// ' Delete temporary file. + /// System.IO.File.Delete(pathname) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op) + /// + /// + public static size_t mpf_inp_str(mpf_t rop, ptr stream, int @base) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (IntPtr.Size == 4) + return new size_t(SafeNativeMethods.__gmpf_inp_str_x86(rop.ToIntPtr(), stream.Value.Value, @base)); + else + return new size_t(SafeNativeMethods.__gmpf_inp_str_x64(rop.ToIntPtr(), stream.Value.Value, @base)); + } + + /// + /// Return non-zero if is an integer. + /// + /// The operand float. + /// Return non-zero if is an integer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Float Functions + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_d(x, 10); + /// + /// // Assert that s is an integer. + /// Assert.IsTrue(gmp_lib.mpf_integer_p(x) != 0); + /// + /// // Release unmanaged memory allocated for x. + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_d(x, 10) + /// + /// ' Assert that s is an integer. + /// Assert.IsTrue(gmp_lib.mpf_integer_p(x) <> 0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static int mpf_integer_p(/*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return SafeNativeMethods.__gmpf_integer_p(op.ToIntPtr()); + } + + /// + /// Set to * . + /// + /// The result float. + /// The first operand. + /// The second operand. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 10); + /// + /// // Create, initialize, and set a new floating-point number y to -210. + /// mpf_t y = new mpf_t(); + /// gmp_lib.mpf_init_set_si(y, -210); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = x * y. + /// gmp_lib.mpf_mul(z, x, y); + /// + /// // Assert that the value of z is -2100. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == -2100.0); + /// + /// // Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpf_clears(x, y, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 10) + /// + /// ' Create, initialize, and set a new floating-point number y to -210. + /// Dim y As New mpf_t() + /// gmp_lib.mpf_init_set_si(y, -210) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = x * y. + /// gmp_lib.mpf_mul(z, x, y) + /// + /// ' Assert that the value of z is -2100. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = -2100.0) + /// + /// ' Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpf_clears(x, y, z, Nothing) + /// + /// + public static void mpf_mul(mpf_t rop, /*const*/ mpf_t op1, /*const*/ mpf_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpf_mul(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Set to * 2^. + /// + /// The result float. + /// The first operand. + /// The second operand. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 100. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 100); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = x * 2^8. + /// gmp_lib.mpf_mul_2exp(z, x, 8U); + /// + /// // Assert that the value of z is 25600. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 25600.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 100. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 100) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = x * 2^8. + /// gmp_lib.mpf_mul_2exp(z, x, 8UI) + /// + /// ' Assert that the value of z is 25600. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 25600.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static void mpf_mul_2exp(mpf_t rop, /*const*/ mpf_t op1, mp_bitcnt_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpf_mul_2exp(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Set to * . + /// + /// The result float. + /// The first operand. + /// The second operand. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 10); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = x * 210. + /// gmp_lib.mpf_mul_ui(z, x, 210U); + /// + /// // Assert that the value of z is 2100. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 2100.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 10) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = x * 210. + /// gmp_lib.mpf_mul_ui(z, x, 210UI) + /// + /// ' Assert that the value of z is 2100. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 2100.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static void mpf_mul_ui(mpf_t rop, /*const*/ mpf_t op1, uint /*unsigned long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpf_mul_ui(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Set to -. + /// + /// The result float. + /// The operand. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 10); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = -x. + /// gmp_lib.mpf_neg(z, x); + /// + /// // Assert that the value of z is -10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == -10.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 10) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = -x. + /// gmp_lib.mpf_neg(z, x) + /// + /// ' Assert that the value of z is -10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = -10.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static void mpf_neg(mpf_t rop, /*const*/ mpf_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpf_neg(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Print to , as a string of digits. + /// + /// Pointer to file stream. + /// The base. + /// Maximum number fo digits to write. + /// The operand float. + /// Return the number of bytes written, or if an error occurred, return 0. + /// + /// + /// The mantissa is prefixed with an "0." and is in the given , + /// which may vary from 2 to 62 or from -2 to -36. + /// An exponent is then printed, separated by an "e", or if the + /// is greater than 10 then by an "@". + /// The exponent is always in decimal. + /// The decimal point follows the current locale, on systems providing localeconv. + /// + /// + /// For in the range 2..36, digits and lower-case letters are used; + /// for -2..-36, digits and upper-case letters are used; for 37..62, digits, + /// upper-case letters, and lower-case letters (in that significance order) are used. + /// + /// + /// Up to will be printed from the mantissa, except that no more + /// digits than are accurately representable by op will be printed. + /// can be 0 to select that accurate maximum. + /// + /// + /// + /// GNU MP - I/O of Floats + /// + /// + /// // Create, initialize, and set the value of op to 123456. + /// mpf_t op = new mpf_t(); + /// gmp_lib.mpf_init_set_ui(op, 123456U); + /// + /// // Get a temporary file. + /// string pathname = System.IO.Path.GetTempFileName(); + /// + /// // Open temporary file for writing. + /// ptr<FILE> stream = new ptr<FILE>(); + /// _wfopen_s(out stream.Value.Value, pathname, "w"); + /// + /// // Write op to temporary file, and assert that the number of bytes written is 10. + /// Assert.IsTrue(gmp_lib.mpf_out_str(stream, 10, 0, op) == 10); + /// + /// // Close temporary file. + /// fclose(stream.Value.Value); + /// + /// // Assert that the content of the temporary file is "123456". + /// string result = System.IO.File.ReadAllText(pathname); + /// Assert.IsTrue(result == "0.123456e6"); + /// + /// // Delete temporary file. + /// System.IO.File.Delete(pathname); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op); + /// + /// + /// + /// + public static size_t mpf_out_str(ptr stream, int @base, size_t n_digits, /*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + if (IntPtr.Size == 4) + return new size_t(SafeNativeMethods.__gmpf_out_str_x86(stream.Value.Value, @base, (uint)n_digits, op.ToIntPtr())); + else + return new size_t(SafeNativeMethods.__gmpf_out_str_x64(stream.Value.Value, @base, n_digits, op.ToIntPtr())); + } + + /// + /// Set to ^. + /// + /// The result float. + /// The first operand. + /// The second operand. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 10); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = sqrt(x). + /// gmp_lib.mpf_pow_ui(z, x, 3U); + /// + /// // Assert that the value of z is 1000. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 1000.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 10) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = sqrt(x). + /// gmp_lib.mpf_pow_ui(z, x, 3UI) + /// + /// ' Assert that the value of z is 1000. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 1000.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static void mpf_pow_ui(mpf_t rop, /*const*/ mpf_t op1, uint /*unsigned long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpf_pow_ui(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Generate a random float of at most limbs, with long strings of zeros and ones in the binary representation. + /// + /// The result float. + /// The maximum number of limbs. + /// The range of the random exponent. + /// + /// + /// The exponent of the number is in the interval - to (in limbs). + /// This function is useful for testing functions and algorithms, since these kind of random numbers have proven to be more + /// likely to trigger corner-case bugs. + /// Negative random numbers are generated when is negative. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Float Functions + /// + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpf_t rop = new mpf_t(); + /// gmp_lib.mpf_init(rop); + /// + /// // Generate a random floating-point number with at most 10 limbs and its exponent in [-5 5]. + /// gmp_lib.mpf_random2(rop, 10, 5); + /// + /// // Free all memory occupied by rop. + /// gmp_lib.mpf_clear(rop); + /// + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpf_t() + /// gmp_lib.mpf_init(rop) + /// + /// ' Generate a random floating-point number with at most 10 limbs and its exponent in [-5 5]. + /// gmp_lib.mpf_random2(rop, 10, 5) + /// + /// ' Free all memory occupied by rop. + /// gmp_lib.mpf_clear(rop) + /// + /// + public static void mpf_random2(mpf_t rop, mp_size_t max_size, mp_exp_t exp) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpf_random2(rop.ToIntPtr(), max_size, exp); + } + + /// + /// Compute the relative difference between and and store the result in . This is | - | / . + /// + /// The result float. + /// The first operand float. + /// The second operand float. + /// + /// + /// + /// + /// + /// + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 10); + /// + /// // Create, initialize, and set a new floating-point number y to -210. + /// mpf_t y = new mpf_t(); + /// gmp_lib.mpf_init_set_si(y, -210); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = |x - y| / x. + /// gmp_lib.mpf_reldiff(z, x, y); + /// + /// // Assert that the value of z is 22. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 22.0); + /// + /// // Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpf_clears(x, y, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 10) + /// + /// ' Create, initialize, and set a new floating-point number y to -210. + /// Dim y As New mpf_t() + /// gmp_lib.mpf_init_set_si(y, -210) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = |x - y| / x. + /// gmp_lib.mpf_reldiff(z, x, y) + /// + /// ' Assert that the value of z is 22. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 22.0) + /// + /// ' Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpf_clears(x, y, z, Nothing) + /// + /// + public static void mpf_reldiff(mpf_t rop, /*const*/ mpf_t op1, /*const*/ mpf_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpf_reldiff(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Set the value of from . + /// + /// The result float. + /// The operand. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Floats + /// + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init2(x, 128U); + /// gmp_lib.mpf_set_si(x, 10); + /// + /// // Create, initialize, and set a new floating-point number y to -210. + /// mpf_t y = new mpf_t(); + /// gmp_lib.mpf_init2(y, 128U); + /// gmp_lib.mpf_set_si(y, -210); + /// + /// // Assign the value of y to x. + /// gmp_lib.mpf_set(x, y); + /// + /// // Assert that the value of x is -210. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == -210.0); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clears(x, y, null); + /// + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init2(x, 128UI) + /// gmp_lib.mpf_set_si(x, 10) + /// + /// ' Create, initialize, and set a new floating-point number y to -210. + /// Dim y As New mpf_t() + /// gmp_lib.mpf_init2(y, 128UI) + /// gmp_lib.mpf_set_si(y, -210) + /// + /// ' Assign the value of y to x. + /// gmp_lib.mpf_set(x, y) + /// + /// ' Assert that the value of x is -210. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = -210.0) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clears(x, y, Nothing) + /// + /// + public static void mpf_set(mpf_t rop, /*const*/ mpf_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpf_set(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set the value of from . + /// + /// The result float. + /// The operand. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Floats + /// + /// + /// // Create and initialize a new floating-point number. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init2(x, 128U); + /// + /// // Set x to -123.0. + /// gmp_lib.mpf_set_d(x, -123.0); + /// + /// // Assert that the value of x is -123.0. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Create and initialize a new floating-point number. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init2(x, 128UI) + /// + /// ' Set x to -123.0. + /// gmp_lib.mpf_set_d(x, -123.0) + /// + /// ' Assert that the value of x is -123.0. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = -123.0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static void mpf_set_d(mpf_t rop, double op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpf_set_d(rop.ToIntPtr(), op); + } + + /// + /// Set the default precision to be at least bits. + /// + /// The minimum precision in bits. + /// + /// + /// All subsequent calls to will use this precision, but previously initialized variables are unaffected. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Floats + /// + /// + /// // Set default precision to 128 bits. + /// gmp_lib.mpf_set_default_prec(128U); + /// + /// // Assert that the value of x is 128 bits. + /// Assert.IsTrue(gmp_lib.mpf_get_default_prec() == 128U); + /// + /// + /// ' Set default precision to 128 bits. + /// gmp_lib.mpf_set_default_prec(128UI) + /// + /// ' Assert that the value of x is 128 bits. + /// Assert.IsTrue(gmp_lib.mpf_get_default_prec() = 128UI) + /// + /// + public static void mpf_set_default_prec(mp_bitcnt_t prec) + { + SafeNativeMethods.__gmpf_set_default_prec(prec); + } + + /// + /// Set the precision of to be at least bits. + /// + /// The result float. + /// The minimum precision in bits. + /// + /// + /// The value in rop will be truncated to the new precision. + /// + /// + /// This function requires a call to realloc, and so should not be used in a tight loop. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Floats + /// + /// + /// // Create and initialize a new floating-point number x. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init(x); + /// + /// // Set its precision to 64 bits. + /// gmp_lib.mpf_set_prec(x, 64U); + /// + /// // Assert that the value of x is 0.0, and that its precision is 64 bits. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0); + /// Assert.IsTrue(gmp_lib.mpf_get_prec(x) == 64U); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Create and initialize a new floating-point number x. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init(x) + /// + /// ' Set its precision to 64 bits. + /// gmp_lib.mpf_set_prec(x, 64UI) + /// + /// ' Assert that the value of x is 0.0, and that its precision is 64 bits. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = 0.0) + /// Assert.IsTrue(gmp_lib.mpf_get_prec(x) = 64UI) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static void mpf_set_prec(mpf_t rop, mp_bitcnt_t prec) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpf_set_prec(rop.ToIntPtr(), prec); + } + + /// + /// Set the precision of to be at least bits, without changing the memory allocated. + /// + /// The result float. + /// The minimum precision in bits. + /// + /// + /// must be no more than the allocated precision for , + /// that being the precision when was initialized, or in the most recent . + /// + /// + /// The value in is unchanged, and in particular if it had a higher precision than + /// it will retain that higher precision. New values written to will use the new . + /// + /// + /// Before calling or the full , another call + /// must be made to restore to its original allocated precision. Failing to do so will have unpredictable results. + /// + /// + /// can be used before to get the original allocated precision. + /// After it reflects the prec value set. + /// + /// + /// is an efficient way to use an variable at different precisions during a calculation, + /// perhaps to gradually increase precision in an iteration, or just to use various different precisions for different purposes during a calculation. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Initializing Floats + /// + /// + /// // Set default precision to 128 bits. + /// gmp_lib.mpf_set_default_prec(128U); + /// + /// // Create, initialize, and set a new rational y to 200 / 3. + /// mpq_t y = new mpq_t(); + /// gmp_lib.mpq_init(y); + /// gmp_lib.mpq_set_ui(y, 200, 3U); + /// + /// // Create, initialize, and set a new floating-point number x to y. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init(x); + /// gmp_lib.mpf_set_q(x, y); + /// + /// Assert.IsTrue(x.ToString() == "0.6666666666666666666666666666666666666667e2"); + /// + /// // Change precision of x, and set its value to 10000 / 3. + /// gmp_lib.mpf_set_prec_raw(x, 8U); + /// gmp_lib.mpq_set_ui(y, 10000, 3U); + /// gmp_lib.mpf_set_q(x, y); + /// + /// Assert.IsTrue(x.ToString() == "0.333333333333333333333e4"); + /// + /// // Restore precision of x. + /// gmp_lib.mpf_set_prec_raw(x, 128U); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clear(x); + /// gmp_lib.mpq_clear(y); + /// + /// + /// ' Set default precision to 128 bits. + /// gmp_lib.mpf_set_default_prec(128UI) + /// + /// ' Create, initialize, and set a new rational y to 200 / 3. + /// Dim y As New mpq_t() + /// gmp_lib.mpq_init(y) + /// gmp_lib.mpq_set_ui(y, 200, 3UI) + /// + /// ' Create, initialize, and set a new floating-point number x to y. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init(x) + /// gmp_lib.mpf_set_q(x, y) + /// Assert.IsTrue(x.ToString() = "0.6666666666666666666666666666666666666667e2") + /// + /// ' Change precision of x, and set its value to 10000 / 3. + /// gmp_lib.mpf_set_prec_raw(x, 8UI) + /// gmp_lib.mpq_set_ui(y, 10000, 3UI) + /// gmp_lib.mpf_set_q(x, y) + /// Assert.IsTrue(x.ToString() = "0.333333333333333333333e4") + /// + /// ' Restore precision of x. + /// gmp_lib.mpf_set_prec_raw(x, 128UI) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clear(x) + /// gmp_lib.mpq_clear(y) + /// + /// + public static void mpf_set_prec_raw(mpf_t rop, mp_bitcnt_t prec) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpf_set_prec_raw(rop.ToIntPtr(), prec); + } + + /// + /// Set the value of from . + /// + /// The result float. + /// The operand. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Floats + /// + /// + /// // Create, initialize, and set a new rational y to 200 / 5. + /// mpq_t y = new mpq_t(); + /// gmp_lib.mpq_init(y); + /// gmp_lib.mpq_set_ui(y, 200, 5U); + /// + /// // Create, initialize, and set a new floating-point number x to y. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init(x); + /// gmp_lib.mpf_set_q(x, y); + /// + /// // Assert that x is 40. + /// Assert.IsTrue(x.ToString() == "0.4e2"); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clear(x); + /// gmp_lib.mpq_clear(y); + /// + /// + /// ' Create, initialize, and set a new rational y to 200 / 5. + /// Dim y As New mpq_t() + /// gmp_lib.mpq_init(y) + /// gmp_lib.mpq_set_ui(y, 200, 5UI) + /// + /// ' Create, initialize, and set a new floating-point number x to y. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init(x) + /// gmp_lib.mpf_set_q(x, y) + /// + /// ' Assert that x is 40. + /// Assert.IsTrue(x.ToString() = "0.4e2") + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clear(x) + /// gmp_lib.mpq_clear(y) + /// + /// + public static void mpf_set_q(mpf_t rop, /*const*/ mpq_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpf_set_q(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set the value of from . + /// + /// The result float. + /// The operand. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Floats + /// + /// + /// // Create and initialize a new floating-point number. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init2(x, 128U); + /// + /// // Set x to -123. + /// gmp_lib.mpf_set_si(x, -123); + /// + /// // Assert that the value of x is -123. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Create and initialize a new floating-point number. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init2(x, 128UI) + /// + /// ' Set x to -123. + /// gmp_lib.mpf_set_si(x, -123) + /// + /// ' Assert that the value of x is -123. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = -123.0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static void mpf_set_si(mpf_t rop, int /*long int*/ op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpf_set_si(rop.ToIntPtr(), op); + } + + /// + /// Set the value of from the string in . + /// + /// The result float. + /// The input string. + /// The base. + /// This function returns 0 if the entire string is a valid number in base . Otherwise it returns -1. + /// + /// + /// The string is of the form "M@N" or, if the is 10 or less, + /// alternatively "MeN". + /// "M" is the mantissa and "N" is the exponent. + /// The mantissa is always in the specified . + /// The exponent is either in the specified or, if is negative, in decimal. + /// The decimal point expected is taken from the current locale, on systems providing localeconv. + /// + /// + /// The argument may be in the ranges 2 to 62, or -62 to -2. + /// Negative values are used to specify that the exponent is in decimal. + /// + /// + /// For bases up to 36, case is ignored; upper-case and lower-case letters have the same value; + /// for bases 37 to 62, upper-case letter represent the usual 10..35 while lower-case + /// letter represent 36..61. + /// + /// + /// Unlike the corresponding mpz function, the will not be determined from the leading characters + /// of the string if base is 0. This is so that numbers like "0.23" are not interpreted as octal. + /// + /// + /// White space is allowed in the string, and is simply ignored. + /// [This is not really true; white-space is ignored in the beginning of the string and within the mantissa, + /// but not in other places, such as after a minus sign or in the exponent. + /// We are considering changing the definition of this function, making it fail when there is any white-space + /// in the input, since that makes a lot of sense. + /// Please tell us your opinion about this change. + /// Do you really want it to accept "3 14" as meaning 314 as it does now?] + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Floats + /// + /// + /// // Create, initialize, and set a new floating-point number x to 0.0234. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init(x); + /// char_ptr value = new char_ptr("234e-4"); + /// gmp_lib.mpf_set_str(x, value, 10); + /// + /// // Assert that x is 40. + /// Assert.IsTrue(x.ToString() == "0.234e-1"); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clear(x); + /// gmp_lib.free(value); + /// + /// + /// ' Create, initialize, and set a new floating-point number x to 0.0234. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init(x) + /// Dim value As New char_ptr("234e-4") + /// gmp_lib.mpf_set_str(x, value, 10) + /// + /// ' Assert that x is 40. + /// Assert.IsTrue(x.ToString() = "0.234e-1") + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clear(x) + /// gmp_lib.free(value) + /// + /// + public static int mpf_set_str(mpf_t rop, /*const*/ char_ptr str, int @base) + { + if (rop == null) throw new ArgumentNullException("rop"); + return SafeNativeMethods.__gmpf_set_str(rop.ToIntPtr(), str.ToIntPtr(), @base); + } + + /// + /// Set the value of from . + /// + /// The result float. + /// The operand. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Floats + /// + /// + /// // Create and initialize a new floating-point number. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init2(x, 128U); + /// + /// // Set x to 100. + /// gmp_lib.mpf_set_ui(x, 100U); + /// + /// // Assert that the value of x is 100. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == 100.0); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Create and initialize a new floating-point number. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init2(x, 128UI) + /// + /// ' Set x to 100. + /// gmp_lib.mpf_set_ui(x, 100UI) + /// + /// ' Assert that the value of x is 100. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = 100.0) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static void mpf_set_ui(mpf_t rop, uint /*unsigned long int*/ op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpf_set_ui(rop.ToIntPtr(), op); + } + + /// + /// Set the value of from . + /// + /// The result float. + /// The operand. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Floats + /// + /// + /// // Create, initialize, and set a new integer y to 200. + /// mpz_t y = new mpz_t(); + /// gmp_lib.mpz_init(y); + /// gmp_lib.mpz_set_ui(y, 200U); + /// + /// // Create, initialize, and set a new floating-point number x to y. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init(x); + /// gmp_lib.mpf_set_z(x, y); + /// + /// // Assert that x is 200. + /// Assert.IsTrue(x.ToString() == "0.2e3"); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clear(x); + /// gmp_lib.mpz_clear(y); + /// + /// + /// ' Create, initialize, and set a new integer y to 200. + /// Dim y As New mpz_t() + /// gmp_lib.mpz_init(y) + /// gmp_lib.mpz_set_ui(y, 200UI) + /// + /// ' Create, initialize, and set a new floating-point number x to y. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init(x) + /// gmp_lib.mpf_set_z(x, y) + /// + /// ' Assert that x is 200. + /// Assert.IsTrue(x.ToString() = "0.2e3") + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clear(x) + /// gmp_lib.mpz_clear(y) + /// + /// + public static void mpf_set_z(mpf_t rop, /*const*/ mpz_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpf_set_z(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Return +1 if op > 0, 0 if op = 0, and -1 if op < 0. + /// + /// The operand float. + /// Return +1 if op > 0, 0 if op = 0, and -1 if op < 0. + /// + /// + /// + /// + /// + /// + /// + /// + /// // Create, initialize, and set the value of op to -10. + /// mpf_t op = new mpf_t(); + /// gmp_lib.mpf_init_set_si(op, -10); + /// + /// // Assert that the sign of op is -1. + /// Assert.IsTrue(gmp_lib.mpf_sgn(op) == -1); + /// + /// // Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op); + /// + /// + /// ' Create, initialize, and set the value of op to -10. + /// Dim op As New mpf_t() + /// gmp_lib.mpf_init_set_si(op, -10) + /// + /// ' Assert that the sign of op is -1. + /// Assert.IsTrue(gmp_lib.mpf_sgn(op) = -1) + /// + /// ' Release unmanaged memory allocated for op. + /// gmp_lib.mpf_clear(op) + /// + /// + public static int mpf_sgn(mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + return op._mp_size < 0 ? -1 : (op._mp_size > 0 ? 1 : 0); + } + + /// + /// Return the number of limbs currently in use. + /// + /// The operand float. + /// The number of limbs currently in use. + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x. + /// mpf_t x = "1.00000000000000000000001"; + /// + /// // Assert that the size of x is 1. + /// Assert.IsTrue(gmp_lib.mpf_size(x) == 4); + /// + /// // Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x. + /// Dim x As mpf_t = "1.00000000000000000000001" + /// + /// ' Assert that the size of x is 1. + /// Assert.IsTrue(gmp_lib.mpf_size(x) = 4) + /// + /// ' Release unmanaged memory allocated for x. + /// gmp_lib.mpf_clear(x) + /// + /// + public static size_t mpf_size(/*const*/ mpf_t op) + { + if (op == null) throw new ArgumentNullException("op"); + if (IntPtr.Size == 4) + return new size_t(SafeNativeMethods.__gmpf_size_x86(op.ToIntPtr())); + else + return new size_t(SafeNativeMethods.__gmpf_size_x64(op.ToIntPtr())); + } + + /// + /// Set to the square root of . + /// + /// The result float. + /// The operand. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 100. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 100); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = sqrt(x). + /// gmp_lib.mpf_sqrt(z, x); + /// + /// // Assert that the value of z is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 100. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 100) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = sqrt(x). + /// gmp_lib.mpf_sqrt(z, x) + /// + /// ' Assert that the value of z is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 10.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static void mpf_sqrt(mpf_t rop, /*const*/ mpf_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpf_sqrt(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set to the square root of . + /// + /// The result float. + /// The operand. + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = sqrt(100). + /// gmp_lib.mpf_sqrt_ui(z, 100U); + /// + /// // Assert that the value of z is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clear(z); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = sqrt(100). + /// gmp_lib.mpf_sqrt_ui(z, 100UI) + /// + /// ' Assert that the value of z is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 10.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clear(z) + /// + /// + public static void mpf_sqrt_ui(mpf_t rop, uint /*unsigned long int*/ op) + { + if (rop == null) throw new ArgumentNullException("rop"); + SafeNativeMethods.__gmpf_sqrt_ui(rop.ToIntPtr(), op); + } + + /// + /// Set to - . + /// + /// The result float. + /// The first operand. + /// The second operand. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 10); + /// + /// // Create, initialize, and set a new floating-point number y to -210. + /// mpf_t y = new mpf_t(); + /// gmp_lib.mpf_init_set_si(y, -210); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = x - y. + /// gmp_lib.mpf_sub(z, x, y); + /// + /// // Assert that the value of z is 220. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 220.0); + /// + /// // Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpf_clears(x, y, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// + /// gmp_lib.mpf_init_set_si(x, 10) + /// + /// ' Create, initialize, and set a new floating-point number y to -210. + /// Dim y As New mpf_t() + /// gmp_lib.mpf_init_set_si(y, -210) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = x - y. + /// gmp_lib.mpf_sub(z, x, y) + /// /// + /// ' Assert that the value of z is 220. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 220.0) + /// + /// ' Release unmanaged memory allocated for x, y, and z. + /// gmp_lib.mpf_clears(x, y, z, Nothing) + /// + /// + public static void mpf_sub(mpf_t rop, /*const*/ mpf_t op1, /*const*/ mpf_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpf_sub(rop.ToIntPtr(), op1.ToIntPtr(), op2.ToIntPtr()); + } + + /// + /// Set to - . + /// + /// The result float. + /// The first operand. + /// The second operand. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 10); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = x - 200. + /// gmp_lib.mpf_sub_ui(z, x, 200U); + /// + /// // Assert that the value of z is -190. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == -190.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 10) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = x - 200. + /// gmp_lib.mpf_sub_ui(z, x, 200UI) + /// + /// ' Assert that the value of z is -190. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = -190.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static void mpf_sub_ui(mpf_t rop, /*const*/ mpf_t op1, uint /*unsigned long int*/ op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op1 == null) throw new ArgumentNullException("op1"); + SafeNativeMethods.__gmpf_sub_ui(rop.ToIntPtr(), op1.ToIntPtr(), op2); + } + + /// + /// Swap and efficiently. + /// + /// The first result float. + /// The second result float. + /// + /// + /// Both the values and the precisions of the two variables are swapped. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Assigning Floats + /// + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init2(x, 128U); + /// gmp_lib.mpf_set_si(x, 10); + /// + /// // Create, initialize, and set a new floating-point number y to -210. + /// mpf_t y = new mpf_t(); + /// gmp_lib.mpf_init2(y, 128U); + /// gmp_lib.mpf_set_si(y, -210); + /// + /// // Swap the values of x and y. + /// gmp_lib.mpf_swap(x, y); + /// + /// // Assert that the value of x is -210. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) == -210.0); + /// + /// // Assert that the value of y is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(y) == 10.0); + /// + /// // Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clears(x, y, null); + /// + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init2(x, 128UI) + /// gmp_lib.mpf_set_si(x, 10) + /// + /// ' Create, initialize, and set a new floating-point number y to -210. + /// Dim y As New mpf_t() + /// gmp_lib.mpf_init2(y, 128UI) + /// gmp_lib.mpf_set_si(y, -210) + /// + /// ' Swap the values of x and y. + /// gmp_lib.mpf_swap(x, y) + /// + /// ' Assert that the value of x is -210. + /// Assert.IsTrue(gmp_lib.mpf_get_d(x) = -210.0) + /// + /// ' Assert that the value of y is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(y) = 10.0) + /// + /// ' Release unmanaged memory allocated for x and y. + /// gmp_lib.mpf_clears(x, y, Nothing) + /// + /// + public static void mpf_swap(mpf_t rop1, mpf_t rop2) + { + if (rop1 == null) throw new ArgumentNullException("rop1"); + if (rop2 == null) throw new ArgumentNullException("rop2"); + SafeNativeMethods.__gmpf_swap(rop1.ToIntPtr(), rop2.ToIntPtr()); + } + + /// + /// Set to rounded to the integer towards zero. + /// + /// The result float. + /// The operand float. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Float Functions + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10.4. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_d(x, 10.4); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = trunc(x). + /// gmp_lib.mpf_trunc(z, x); + /// + /// // Assert that the value of z is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10.4. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_d(x, 10.4) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = trunc(x). + /// gmp_lib.mpf_trunc(z, x) + /// + /// ' Assert that the value of z is 10. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 10.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static void mpf_trunc(mpf_t rop, /*const*/ mpf_t op) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op == null) throw new ArgumentNullException("op"); + SafeNativeMethods.__gmpf_trunc(rop.ToIntPtr(), op.ToIntPtr()); + } + + /// + /// Set to / . + /// + /// The result float. + /// The first operand. + /// The second operand. + /// + /// + /// Division is undefined if the divisor is zero, and passing a zero divisor to the divide + /// functions will make it intentionally divide by zero. + /// This lets the user handle arithmetic exceptions in division functions in the same manner + /// as other arithmetic exceptions. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number x to 10. + /// mpf_t x = new mpf_t(); + /// gmp_lib.mpf_init_set_si(x, 10); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = 210 / x. + /// gmp_lib.mpf_ui_div(z, 210U, x); + /// + /// // Assert that the value of z is 21. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 21.0); + /// + /// // Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number x to 10. + /// Dim x As New mpf_t() + /// gmp_lib.mpf_init_set_si(x, 10) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = 210 / x. + /// gmp_lib.mpf_ui_div(z, 210UI, x) + /// + /// ' Assert that the value of z is 21. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 21.0) + /// + /// ' Release unmanaged memory allocated for x and z. + /// gmp_lib.mpf_clears(x, z, Nothing) + /// + /// + public static void mpf_ui_div(mpf_t rop, uint /*unsigned long int*/ op1, /*const*/ mpf_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpf_ui_div(rop.ToIntPtr(), op1, op2.ToIntPtr()); + } + + /// + /// Set to - . + /// + /// The result float. + /// The first operand. + /// The second operand. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Float Arithmetic + /// + /// + /// // Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64U); + /// + /// // Create, initialize, and set a new floating-point number y to -210. + /// mpf_t y = new mpf_t(); + /// gmp_lib.mpf_init_set_si(y, -210); + /// + /// // Create and initialize a new floating-point number z. + /// mpf_t z = new mpf_t(); + /// gmp_lib.mpf_init(z); + /// + /// // Set z = 10 - y. + /// gmp_lib.mpf_ui_sub(z, 10U, y); + /// + /// // Assert that the value of z is 220. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) == 220.0); + /// + /// // Release unmanaged memory allocated for y, and z. + /// gmp_lib.mpf_clears(y, z, null); + /// + /// + /// ' Set default precision to 64 bits. + /// gmp_lib.mpf_set_default_prec(64UI) + /// + /// ' Create, initialize, and set a new floating-point number y to -210. + /// Dim y As New mpf_t() + /// gmp_lib.mpf_init_set_si(y, -210) + /// + /// ' Create and initialize a new floating-point number z. + /// Dim z As New mpf_t() + /// gmp_lib.mpf_init(z) + /// + /// ' Set z = 10 - y. + /// gmp_lib.mpf_ui_sub(z, 10UI, y) + /// + /// ' Assert that the value of z is 220. + /// Assert.IsTrue(gmp_lib.mpf_get_d(z) = 220.0) + /// + /// ' Release unmanaged memory allocated for y, and z. + /// gmp_lib.mpf_clears(y, z, Nothing) + /// + /// + public static void mpf_ui_sub(mpf_t rop, uint /*unsigned long int*/ op1, /*const*/ mpf_t op2) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (op2 == null) throw new ArgumentNullException("op2"); + SafeNativeMethods.__gmpf_ui_sub(rop.ToIntPtr(), op1, op2.ToIntPtr()); + } + + /// + /// Generate a uniformly distributed random float in , such that 0 ≤ rop < 1, with significant bits in the mantissa or less if the precision of is smaller. + /// + /// The result float. + /// The random number generator state. + /// Number of significant bits. + /// + /// + /// The variable state must be initialized by calling one of the gmp_randinit functions + /// (GNU MP - Random State Initialization) before invoking this function. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Miscellaneous Float Functions + /// + /// + /// // Create, initialize, and seed a new random number generator. + /// gmp_randstate_t state = new gmp_randstate_t(); + /// gmp_lib.gmp_randinit_mt(state); + /// gmp_lib.gmp_randseed_ui(state, 100000U); + /// + /// // Create, initialize, and set the value of rop to 0. + /// mpf_t rop = new mpf_t(); + /// gmp_lib.mpf_init(rop); + /// + /// // Generate a random integer in the range [0, 1) with 50 bits precision. + /// gmp_lib.mpf_urandomb(rop, state, 50); + /// + /// // Free all memory occupied by state and rop. + /// gmp_lib.gmp_randclear(state); + /// gmp_lib.mpf_clear(rop); + /// + /// + /// ' Create, initialize, and seed a new random number generator. + /// Dim state As New gmp_randstate_t() + /// gmp_lib.gmp_randinit_mt(state) + /// gmp_lib.gmp_randseed_ui(state, 100000UI) + /// + /// ' Create, initialize, and set the value of rop to 0. + /// Dim rop As New mpf_t() + /// gmp_lib.mpf_init(rop) + /// + /// ' Generate a random integer in the range [0, 1) with 50 bits precision. + /// gmp_lib.mpf_urandomb(rop, state, 50) + /// + /// ' Free all memory occupied by state and rop. + /// gmp_lib.gmp_randclear(state) + /// gmp_lib.mpf_clear(rop) + /// + /// + public static void mpf_urandomb(mpf_t rop, gmp_randstate_t state, mp_bitcnt_t nbits) + { + if (rop == null) throw new ArgumentNullException("rop"); + if (state == null) throw new ArgumentNullException("state"); + SafeNativeMethods.__gmpf_urandomb(rop.ToIntPtr(), state.ToIntPtr(), nbits); + } + + #endregion + + #region "Low level positive-integer (i.e. N) routines." + + /// + /// Add {, } and {, }, and write the least significant limbs of the result to . + /// + /// The result integer. + /// The first operand integer. + /// The number of limbs in . + /// The second operand integer. + /// The number of limbs in . + /// Return carry, either 0 or 1. + /// + /// + /// This function requires that is greater than or equal to . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + /// + /// // Set rp = s1 + s2. + /// mp_limb_t carry = gmp_lib.mpn_add(rp, s1p, s1p.Size, s2p, s2p.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(carry == 1); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H0, &H0}) + /// + /// ' Set rp = s1 + s2. + /// Dim carry As mp_limb_t = gmp_lib.mpn_add(rp, s1p, s1p.Size, s2p, s2p.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(carry = 1) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static mp_limb_t mpn_add(mp_ptr rp, /*const*/ mp_ptr s1p, mp_size_t s1n, /*const*/ mp_ptr s2p, mp_size_t s2n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_add_x86(rp.ToIntPtr(), s1p.ToIntPtr(), s1n, s2p.ToIntPtr(), s2n)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_add_x64(rp.ToIntPtr(), s1p.ToIntPtr(), s1n, s2p.ToIntPtr(), s2n)); + } + + /// + /// Add {, } and , and write the least significant limbs of the result to . + /// + /// The result integer. + /// The first operand integer. + /// The number of limbs in . + /// The second operand integer. + /// Return carry, either 0 or 1. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + /// + /// // Set rp = s1 + 1. + /// mp_limb_t carry = gmp_lib.mpn_add_1(rp, s1p, s1p.Size, 1); + /// + /// // Assert result of operation. + /// Assert.IsTrue(carry == 1); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H0, &H0}) + /// + /// ' Set rp = s1 + 1. + /// Dim carry As mp_limb_t = gmp_lib.mpn_add_1(rp, s1p, s1p.Size, 1) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(carry = 1) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, result) + /// + /// + public static mp_limb_t mpn_add_1(mp_ptr rp, /*const*/ mp_ptr s1p, mp_size_t n, mp_limb_t s2limb) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_add_1_x86(rp.ToIntPtr(), s1p.ToIntPtr(), n, (uint)s2limb)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_add_1_x64(rp.ToIntPtr(), s1p.ToIntPtr(), n, s2limb)); + } + + /// + /// Add {, } and {, }, and write the least significant limbs of the result to . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs in and . + /// Return carry, either 0 or 1. + /// + /// + /// This is the lowest-level function for addition. + /// It is the preferred function for addition, since it is written in assembly for most CPUs. + /// For addition of a variable to itself (i.e., equals ) + /// use with a count of 1 for optimal speed. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + /// + /// // Set rp = s1 + s2. + /// mp_limb_t carry = gmp_lib.mpn_add_n(rp, s1p, s2p, rp.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(carry == 1); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &H0}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H0, &H0}) + /// + /// ' Set rp = s1 + s2. + /// Dim carry As mp_limb_t = gmp_lib.mpn_add_n(rp, s1p, s2p, rp.Size) + /// + /// ' Assert result of operation. + /// + /// Assert.IsTrue(carry = 1) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static mp_limb_t mpn_add_n(mp_ptr rp, /*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_add_n_x86(rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_add_n_x64(rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n)); + } + + /// + /// Multiply {, } and , and add the least significant limbs of the product to {, } and write the result to . + /// + /// The result integer. + /// The first operand integer. + /// The number of limbs in . + /// The second operand integer. + /// Return the most significant limb of the product, plus carry-out from the addition. + /// + /// + /// {, } and {, } are allowed + /// to overlap provided . + /// + /// + /// This is a low-level function that is a building block for general multiplication as well as other operations in GMP. + /// It is written in assembly for most CPUs. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr rp = new mp_ptr(new uint[] { 0x00000002, 0x00000000 }); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + /// + /// // Set rp += s1 * 2. + /// mp_limb_t carry = gmp_lib.mpn_addmul_1(rp, s1p, s1p.Size, 2); + /// + /// // Assert result of operation. + /// Assert.IsTrue(carry == 0x02); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim rp As New mp_ptr(New UInteger() { &H2, &H0}) + /// Dim result As New mp_ptr(New UInteger() { &H0, &H0}) + /// + /// ' Set rp += s1 * 2. + /// Dim carry As mp_limb_t = gmp_lib.mpn_addmul_1(rp, s1p, s1p.Size, 2) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(carry = &H2) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, result) + /// + /// + public static mp_limb_t mpn_addmul_1(mp_ptr rp, /*const*/ mp_ptr s1p, mp_size_t n, mp_limb_t s2limb) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_addmul_1_x86(rp.ToIntPtr(), s1p.ToIntPtr(), n, (uint)s2limb)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_addmul_1_x64(rp.ToIntPtr(), s1p.ToIntPtr(), n, s2limb)); + } + + /// + /// Compare {, } and {, }. + /// + /// The first operand integer. + /// The second operand integer. + /// The number of limbs in and . + /// Return a positive value if s1 > s2, 0 if they are equal, or a negative value if s1 < s2. + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + /// + /// // Assert s1p > s2p. + /// Assert.IsTrue(gmp_lib.mpn_cmp(s1p, s2p, s1p.Size) > 0); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(s1p, s2p); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &H0}) + /// + /// ' Assert s1p > s2p. + /// Assert.IsTrue(gmp_lib.mpn_cmp(s1p, s2p, s1p.Size) > 0) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(s1p, s2p) + /// + /// + public static int mpn_cmp(/*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + return SafeNativeMethods.__gmpn_cmp(s1p.ToIntPtr(), s2p.ToIntPtr(), n); + } + + /// + /// Test {, } and return 1 if the operand is zero, 0 otherwise. + /// + /// The operand integer. + /// The number of limbs in . + /// Return 1 if the operand is zero, 0 otherwise. + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operand. + /// mp_ptr sp = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + /// + /// // Assert sp == 0. + /// Assert.IsTrue(gmp_lib.mpn_zero_p(sp, sp.Size) == 1); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(sp); + /// + /// + /// ' Create multi-precision operand. + /// Dim sp As New mp_ptr(New UInteger() { &H0, &H0}) + /// + /// ' Assert sp == 0. + /// Assert.IsTrue(gmp_lib.mpn_zero_p(sp, sp.Size) = 1) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(sp) + /// + /// + public static int mpn_zero_p(/*const*/ mp_ptr sp, mp_size_t n) + { + if (sp == null) throw new ArgumentNullException("sp"); + return SafeNativeMethods.__gmpn_zero_p(sp.ToIntPtr(), n); + } + + /// + /// Divide {, } by , expecting it to divide exactly, and writing the result to {r, }. + /// + /// The result integer. + /// The first operand integer. + /// The number of limbs in and . + /// The second operand integer. + /// + /// + /// If doesn’t divide exactly, the value written to {, } is undefined. + /// The areas at and have to be identical or completely separate, not partially overlapping. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x55555555, 0x00005555 }); + /// + /// // Set rp = sp / 3. + /// gmp_lib.mpn_divexact_1(rp, sp, sp.Size, 0x3); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, sp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim sp As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H55555555, &H5555}) + /// + /// ' Set rp = sp / 3. + /// gmp_lib.mpn_divexact_1(rp, sp, sp.Size, &H3) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, sp, result) + /// + /// + public static void mpn_divexact_1(mp_ptr rp, /*const*/ mp_ptr sp, mp_size_t n, mp_limb_t d) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (sp == null) throw new ArgumentNullException("sp"); + if (IntPtr.Size == 4) + SafeNativeMethods.__gmpn_divexact_1_x86(rp.ToIntPtr(), sp.ToIntPtr(), n, (uint)d); + else + SafeNativeMethods.__gmpn_divexact_1_x64(rp.ToIntPtr(), sp.ToIntPtr(), n, d); + } + + /// + /// Divide {, } by 3, expecting it to divide exactly, and writing the result to {, }. + /// + /// The result integer. + /// The operand integer. + /// The number of limbs in . + /// If 3 divides exactly, the return value is zero and the result is the quotient. If not, the return value is non-zero and the result won’t be anything useful. + /// + /// + /// takes an initial carry parameter, which can be the return value from a previous call, + /// so a large calculation can be done piece by piece from low to high. + /// is simply a macro calling with a 0 carry parameter. + /// + /// + /// These routines use a multiply-by-inverse and will be faster than on CPUs with + /// fast multiplication but slow division. + /// + /// + /// The source a, result q, size n, initial carry i, and return value c satisfy + /// c * b^n + a - i = 3 * q, where b = 2^. + /// The return c is always 0, 1 or 2, and the initial carry i must also be 0, + /// 1 or 2 (these are both borrows really). When c = 0 clearly q = (a - i) / 3. + /// When c != 0, the remainder (a - i) mod 3 is given by 3 - c, because + /// b ≡ 1 mod 3 (when is even, which is always so currently). + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x55555555, 0x00005555 }); + /// + /// // Set rp = sp / 3. + /// mp_limb_t remainder = gmp_lib.mpn_divexact_by3(rp, sp, sp.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(remainder == 0); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, sp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim sp As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H55555555, &H5555}) + /// + /// ' Set rp = sp / 3. + /// Dim remainder As mp_limb_t = gmp_lib.mpn_divexact_by3(rp, sp, sp.Size) + /// + /// ' Assert result of operation. + /// + /// Assert.IsTrue(remainder = 0) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, sp, result) + /// + /// + public static mp_limb_t mpn_divexact_by3(mp_ptr rp, /*const*/ mp_ptr sp, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (sp == null) throw new ArgumentNullException("sp"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_divexact_by3_x86(rp.ToIntPtr(), sp.ToIntPtr(), n)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_divexact_by3_x64(rp.ToIntPtr(), sp.ToIntPtr(), n)); + } + + /// + /// Divide {, } by 3, expecting it to divide exactly, and writing the result to {, }. + /// + /// The result integer. + /// The operand integer. + /// The number of limbs in . + /// The initial carry. + /// If 3 divides exactly, the return value is zero and the result is the quotient. If not, the return value is non-zero and the result won’t be anything useful. + /// + /// + /// takes an initial carry parameter, which can be the return value from a previous call, + /// so a large calculation can be done piece by piece from low to high. + /// is simply a macro calling with a 0 carry parameter. + /// + /// + /// These routines use a multiply-by-inverse and will be faster than on CPUs with + /// fast multiplication but slow division. + /// + /// + /// The source a, result q, size n, initial carry i, and return value c satisfy + /// c * b^n + a - i = 3 * q, where b = 2^. + /// The return c is always 0, 1 or 2, and the initial carry i must also be 0, + /// 1 or 2 (these are both borrows really). When c = 0 clearly q = (a - i) / 3. + /// When c != 0, the remainder (a - i) mod 3 is given by 3 - c, because + /// b ≡ 1 mod 3 (when is even, which is always so currently). + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xaaaaaaaa, 0x5555aaaa }); + /// + /// // Set rp = sp / 3. + /// mp_limb_t remainder = gmp_lib.mpn_divexact_by3c(rp, sp, sp.Size, 1); + /// + /// // Assert result of operation. + /// Assert.IsTrue(remainder == 1); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, sp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim sp As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &HaaaaaaaaUI, &H5555aaaa}) + /// + /// ' Set rp = sp / 3. + /// Dim remainder As mp_limb_t = gmp_lib.mpn_divexact_by3c(rp, sp, sp.Size, 1) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(remainder = 1) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, sp, result) + /// + /// + public static mp_limb_t mpn_divexact_by3c(mp_ptr rp, /*const*/ mp_ptr sp, mp_size_t n, mp_limb_t carry) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (sp == null) throw new ArgumentNullException("sp"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_divexact_by3c_x86(rp.ToIntPtr(), sp.ToIntPtr(), n, (uint)carry)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_divexact_by3c_x64(rp.ToIntPtr(), sp.ToIntPtr(), n, carry)); + } + + /// + /// Divide {, } by , and write the quotient at . + /// + /// + /// + /// + /// + /// + /// Return the remainder. + /// + /// + /// The integer quotient is written to { + , } + /// and in addition fraction limbs are developed and written to {, }. + /// Either or both and can be zero. + /// For most usages, will be zero. + /// + /// + /// exists for upward source compatibility and is simply a macro + /// calling with a of 0. + /// + /// + /// The areas at and have to be identical or + /// completely separate, not partially overlapping. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s2p = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + /// mp_ptr r1p = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x435e50d7, 0x00000d79 }); + /// + /// // Set r1p = s2p / 19. + /// mp_limb_t remainder = gmp_lib.mpn_divrem_1(r1p, 0, s2p, s2p.Size, 0x13); + /// + /// // Assert result of operation. + /// Assert.IsTrue(remainder == 10); + /// Assert.IsTrue(r1p.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(r1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s2p As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff}) + /// Dim r1p As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H435e50d7, &Hd79}) + /// + /// ' Set r1p = s2p / 19. + /// Dim remainder As mp_limb_t = gmp_lib.mpn_divrem_1(r1p, 0, s2p, s2p.Size, &H13) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(remainder = 10) + /// Assert.IsTrue(r1p.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(r1p, s2p, result) + /// + /// + public static mp_limb_t mpn_divrem_1(mp_ptr r1p, mp_size_t qxn, /*const*/ mp_ptr s2p, mp_size_t s2n, mp_limb_t s3limb) + { + if (r1p == null) throw new ArgumentNullException("r1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_divrem_1_x86(r1p.ToIntPtr(), qxn, s2p.ToIntPtr(), s2n, (uint)s3limb)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_divrem_1_x64(r1p.ToIntPtr(), qxn, s2p.ToIntPtr(), s2n, s3limb)); + } + + /// + /// Divide {, } by , and write the quotient at . + /// + /// + /// + /// + /// + /// Return the remainder. + /// + /// + /// The integer quotient is written to {, }. + /// can be zero. + /// + /// + /// exists for upward source compatibility and is simply a macro + /// calling with a qxn of 0. + /// + /// + /// The areas at and have to be identical or + /// completely separate, not partially overlapping. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s2p = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + /// mp_ptr r1p = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x435e50d7, 0x00000d79 }); + /// + /// // Set r1p = s2p / 19. + /// mp_limb_t remainder = gmp_lib.mpn_divmod_1(r1p, s2p, s2p.Size, 0x13); + /// + /// // Assert result of operation. + /// Assert.IsTrue(remainder == 10); + /// Assert.IsTrue(r1p.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(r1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s2p As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff}) + /// Dim r1p As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H435e50d7, &Hd79}) + /// + /// ' Set r1p = s2p / 19. + /// Dim remainder As mp_limb_t = gmp_lib.mpn_divmod_1(r1p, s2p, s2p.Size, &H13) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(remainder = 10) + /// Assert.IsTrue(r1p.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(r1p, s2p, result) + /// + /// + public static mp_limb_t mpn_divmod_1(mp_ptr r1p, /*const*/ mp_ptr s2p, mp_size_t s2n, mp_limb_t s3limb) + { + if (r1p == null) throw new ArgumentNullException("r1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_divrem_1_x86(r1p.ToIntPtr(), 0, s2p.ToIntPtr(), s2n, (uint)s3limb)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_divrem_1_x64(r1p.ToIntPtr(), 0, s2p.ToIntPtr(), s2n, s3limb)); + } + + ////obsolete + ////#define mpn_divrem __MPN(divrem) + ////public static mp_limb_t mpn_divrem(IntPtr /*mp_ptr*/, int /*mp_size_t*/, IntPtr /*mp_ptr*/, int /*mp_size_t*/, /*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/) + //{ + // return SafeNativeMethods.__gmpn_divrem(IntPtr /*mp_ptr*/, int /*mp_size_t*/, IntPtr /*mp_ptr*/, int /*mp_size_t*/, /*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/); + //} + + ////obsolete + ////#define mpn_divrem_1 __MPN(divrem_1) + ////public static mp_limb_t mpn_divrem_1(IntPtr /*mp_ptr*/ r1p, int /*mp_size_t*/ qxn, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ s2n, mp_limb_t s3limb) + //{ + // return SafeNativeMethods.__gmpn_divrem_1(IntPtr /*mp_ptr*/ r1p, int /*mp_size_t*/ qxn, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ s2n, mp_limb_t s3limb); + //} + + ////obsolete + ////#define mpn_divrem_2 __MPN(divrem_2) + ////public static mp_limb_t mpn_divrem_2(IntPtr /*mp_ptr*/, int /*mp_size_t*/, IntPtr /*mp_ptr*/, int /*mp_size_t*/, /*const*/ IntPtr /*mp_ptr*/) + //{ + // return SafeNativeMethods.__gmpn_divrem_2(IntPtr /*mp_ptr*/, int /*mp_size_t*/, IntPtr /*mp_ptr*/, int /*mp_size_t*/, /*const*/ IntPtr /*mp_ptr*/); + //} + + ////#define mpn_div_qr_1 __MPN(div_qr_1) + ////public static mp_limb_t mpn_div_qr_1(IntPtr /*mp_ptr*/, mp_limb_t*, /*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/, mp_limb_t) + //{ + // return SafeNativeMethods.__gmpn_div_qr_1(IntPtr /*mp_ptr*/, mp_limb_t*, /*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/, mp_limb_t); + //} + + ////#define mpn_div_qr_2 __MPN(div_qr_2) + ////public static mp_limb_t mpn_div_qr_2(IntPtr /*mp_ptr*/, IntPtr /*mp_ptr*/, /*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/, /*const*/ IntPtr /*mp_ptr*/) + //{ + // return SafeNativeMethods.__gmpn_div_qr_2(IntPtr /*mp_ptr*/, IntPtr /*mp_ptr*/, /*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/, /*const*/ IntPtr /*mp_ptr*/); + //} + + /// + /// Set {, retval} to the greatest common divisor of {, } and {, }. + /// + /// The result integer. + /// The first operand integer. + /// The number of limbs of . + /// The second operand integer. + /// The number of limbs of . + /// The result can be up to limbs, the return value is the actual number produced; i.e. the number of limbs of . + /// + /// + /// Both source operands are destroyed. + /// + /// + /// It is required that > 0, and the most significant limb + /// of {, } must be non-zero. + /// No overlap is permitted between {, } and {, }. + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr xp = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 }); + /// mp_ptr yp = new mp_ptr(new uint[] { 0xc2d24d55, 0x00000007 }); + /// mp_ptr rp = new mp_ptr(yp.Size); + /// mp_ptr result = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 }); + /// + /// // Set rp = gcd(xp, yp). + /// mp_size_t size = gmp_lib.mpn_gcd(rp, xp, xp.Size, yp, yp.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(size == result.Size); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, xp, yp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim xp As New mp_ptr(New UInteger() { &H964619c7UI, &H2}) + /// Dim yp As New mp_ptr(New UInteger() { &Hc2d24d55UI, &H7}) + /// Dim rp As New mp_ptr(yp.Size) + /// Dim result As New mp_ptr(New UInteger() { &H964619c7UI, &H2}) + /// + /// ' Set rp = gcd(xp, yp). + /// Dim size As mp_size_t = gmp_lib.mpn_gcd(rp, xp, xp.Size, yp, yp.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(size = result.Size) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, xp, yp, result) + /// + /// + public static mp_size_t mpn_gcd(mp_ptr rp, mp_ptr xp, mp_size_t xn, mp_ptr yp, mp_size_t yn) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (xp == null) throw new ArgumentNullException("xp"); + if (yp == null) throw new ArgumentNullException("yp"); + return new mp_size_t(SafeNativeMethods.__gmpn_gcd(rp.ToIntPtr(), xp.ToIntPtr(), xn, yp.ToIntPtr(), yn)); + } + + /// + /// Return the greatest common divisor of {, } and . + /// + /// The first operand integer. + /// The number of limbs of . + /// The second operand integer. + /// The greatest common divisor of {, } and . + /// + /// + /// Both operands must be non-zero. + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operand. + /// mp_ptr xp = new mp_ptr(new uint[] { 0x00000000, 0x00000001 }); + /// + /// // Assert result of operation. + /// Assert.IsTrue(gmp_lib.mpn_gcd_1(xp, xp.Size, 1073741824) == 1073741824); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(xp); + /// + /// + /// ' Create multi-precision operand. + /// Dim xp As New mp_ptr(New UInteger() { &H0, &H1}) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(gmp_lib.mpn_gcd_1(xp, xp.Size, 1073741824) = 1073741824) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(xp) + /// + /// + public static mp_limb_t mpn_gcd_1(/*const*/ mp_ptr xp, mp_size_t xn, mp_limb_t ylimb) + { + if (xp == null) throw new ArgumentNullException("xp"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_gcd_1_x86(xp.ToIntPtr(), xn, (uint)ylimb)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_gcd_1_x64(xp.ToIntPtr(), xn, ylimb)); + } + + ////#define mpn_gcdext_1 __MPN(gcdext_1) + ////public static mp_limb_t mpn_gcdext_1(mp_limb_signed_t*, mp_limb_signed_t*, mp_limb_t, mp_limb_t) + //{ + // return SafeNativeMethods.__gmpn_gcdext_1(mp_limb_signed_t*, mp_limb_signed_t*, mp_limb_t, mp_limb_t); + //} + + /// + /// Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT. + /// + /// The fisrt result operand. + /// The second result operand. + /// Pointer to the number of limbs of . + /// The first operand integer. + /// The number of limbs of . + /// The second operand integer. + /// The number of limbs of . + /// The number of limbs of . + /// + /// + /// Let U be defined by {, } + /// and let V be defined by {, }. + /// + /// + /// The second cofactor T is not computed but can easily be obtained from (G - U * S) / V (the division will be exact). + /// It is required that > 0, + /// and the most significant limb of {, } must be non-zero. + /// + /// + /// Store G at and let the return value define its limb count. + /// Store S at and let |.Value| define its limb count. + /// S can be negative; when this happens .Value will be negative. + /// The area at should have room for limbs + /// and the area at should have room for + 1 limbs. + /// + /// + /// Both source operands are destroyed. + /// + /// + /// Compatibility notes: GMP 4.3.0 and 4.3.1 defined S less strictly. + /// Earlier as well as later GMP releases define S as described here. + /// GMP releases before GMP 4.3.0 required additional space for both input and output areas. + /// More precisely, the areas {, + 1} and + /// {, + 1} were destroyed (i.e. the operands + /// plus an extra limb past the end of each), and the areas pointed to by + /// and should each have room for + 1 limbs. + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr up = new mp_ptr(new uint[] { 0x40000000, 0x00000000 }); + /// mp_ptr vp = new mp_ptr(new uint[] { 0x00000000, 0x00000001 }); + /// mp_ptr gp = new mp_ptr(new uint[vp.Size * (IntPtr.Size / 4)]); + /// mp_ptr sp = new mp_ptr(new uint[(vp.Size + 1) * (IntPtr.Size / 4)]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x40000000, 0x00000000 }); + /// mp_ptr cofactor = new mp_ptr(new uint[] { 0x00000001, 0x00000000, 0x00000000 }); + /// + /// // Set gp = gcd(up, vp). + /// ptr<mp_size_t> sn = new ptr<mp_size_t>(0); + /// mp_size_t size = gmp_lib.mpn_gcdext(gp, sp, sn, up, up.Size, vp, vp.Size); + /// + /// // Assert result. + /// Assert.IsTrue(size == 1); + /// Assert.IsTrue(gp.SequenceEqual(result)); + /// Assert.IsTrue(sn.Value == 1); + /// Assert.IsTrue(sp.SequenceEqual(cofactor)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(gp, up, vp, sp, result, cofactor); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim up As New mp_ptr(New UInteger() { &H40000000, &H0}) + /// Dim vp As New mp_ptr(New UInteger() { &H0, &H1}) + /// Dim gp As New mp_ptr(New UInteger(vp.Size* (IntPtr.Size / 4) - 1) {}) + /// Dim sp As New mp_ptr(New UInteger((vp.Size + 1) * (IntPtr.Size / 4) - 1) {}) + /// Dim result As New mp_ptr(New UInteger() { &H40000000, &H0}) + /// Dim cofactor As New mp_ptr(New UInteger() { &H1, &H0, &H0}) + /// + /// ' Set gp = gcd(up, vp). + /// Dim sn As New ptr(Of mp_size_t)(0) + /// Dim size As mp_size_t = gmp_lib.mpn_gcdext(gp, sp, sn, up, up.Size, vp, vp.Size) + /// + /// ' Assert result. + /// Assert.IsTrue(size = 1) + /// Assert.IsTrue(gp.SequenceEqual(result)) + /// Assert.IsTrue(sn.Value = 1) + /// Assert.IsTrue(sp.SequenceEqual(cofactor)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(gp, up, vp, sp, result, cofactor) + /// + /// + public static mp_size_t mpn_gcdext(mp_ptr gp, mp_ptr sp, ptr sn, mp_ptr up, mp_size_t un, mp_ptr vp, mp_size_t vn) + { + if (gp == null) throw new ArgumentNullException("gp"); + if (sp == null) throw new ArgumentNullException("sp"); + if (up == null) throw new ArgumentNullException("up"); + if (vp == null) throw new ArgumentNullException("vp"); + return new mp_size_t(SafeNativeMethods.__gmpn_gcdext(gp.ToIntPtr(), sp.ToIntPtr(), ref sn.Value._value, up.ToIntPtr(), un, vp.ToIntPtr(), vn)); + } + + /// + /// Convert {, } to a raw unsigned char array at in base , and return the number of characters produced. + /// + /// The result string. + /// The base. + /// The operand integer. + /// The number of limbs of . + /// The number of characters produced at . + /// + /// + /// There may be leading zeros in the string. + /// The string is not in ASCII; to convert it to printable format, add the ASCII codes for "0" or "A", + /// depending on the base and range. can vary from 2 to 256. + /// + /// + /// The most significant limb of the input {, } must be non-zero. + /// The input {, } is clobbered, except when base is a power of 2, + /// in which case it’s unchanged. + /// + /// + /// The area at has to have space for the largest possible number + /// represented by a long limb array, plus one extra character. + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0x00000001, 0x00000001 }); + /// char_ptr str = new char_ptr("xxxxxxxxxxxxxxxxx"); + /// + /// // Convert s1p to hex string. + /// size_t count = gmp_lib.mpn_get_str(str, 16, s1p, s1p.Size); + /// + /// // Copy out str to bytes. + /// byte[] s = new byte[count]; + /// Marshal.Copy(str.ToIntPtr(), s, 0, (int)count); + /// + /// // Assert the non-ASCII, hex representation of s1p. + /// Assert.IsTrue(s.SequenceEqual(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 1 })); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(s1p); + /// gmp_lib.free(str); + /// + /// + /// ' Create multi-precision operands. + /// Dim s1p As New mp_ptr(New UInteger() { &H1, &H1}) + /// Dim str As New char_ptr("xxxxxxxxxxxxxxxxx") + /// + /// ' Convert s1p to hex string. + /// Dim count As size_t = gmp_lib.mpn_get_str(str, 16, s1p, s1p.Size) + /// + /// ' Copy out str to bytes. + /// Dim s As Byte() = New Byte(count - 1) { } + /// Marshal.Copy(str.ToIntPtr(), s, 0, CInt(count)) + /// + /// ' Assert the non-ASCII, hex representation of s1p. + /// Assert.IsTrue(s.SequenceEqual(New Byte() { 1, 0, 0, 0, 0, 0, 0, 0, 1})) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(s1p) + /// gmp_lib.free(str) + /// + /// + public static size_t mpn_get_str(/*unsigned*/ char_ptr str, int @base, mp_ptr s1p, mp_size_t s1n) + { + if (s1p == null) throw new ArgumentNullException("s1p"); + if (IntPtr.Size == 4) + return new size_t(SafeNativeMethods.__gmpn_get_str_x86(str.ToIntPtr(), @base, s1p.ToIntPtr(), s1n)); + else + return new size_t(SafeNativeMethods.__gmpn_get_str_x64(str.ToIntPtr(), @base, s1p.ToIntPtr(), s1n)); + } + + /// + /// Compute the hamming distance between {, } and {, }, which is the number of bit positions where the two operands have different bit values. + /// + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// The hamming distance between {, } and {. + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0xffffffff }); + /// + /// // Assert hamming distance. + /// Assert.IsTrue(gmp_lib.mpn_hamdist(s1p, s2p, s1p.Size) == 31); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(s1p, s2p); + /// + /// + /// ' Create multi-precision operands. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &HffffffffUI}) + /// + /// ' Assert hamming distance. + /// Assert.IsTrue(gmp_lib.mpn_hamdist(s1p, s2p, s1p.Size) = 31) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(s1p, s2p) + /// + /// + public static mp_bitcnt_t mpn_hamdist(/*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + return new mp_bitcnt_t(SafeNativeMethods.__gmpn_hamdist(s1p.ToIntPtr(), s2p.ToIntPtr(), n)); + } + + /// + /// Shift {, } left by bits, and write the result to {, }. + /// + /// The result integer. + /// The operand integer. + /// The number of limbs of . + /// The number of bits ot shift. + /// The bits shifted out at the left are returned in the least significant count bits of the return value (the rest of the return value is zero). + /// + /// + /// must be in the range 1 to - 1. + /// The regions {, } and {, } may overlap, + /// provided . + /// + /// + /// This function is written in assembly for most CPUs. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr sp = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xfffffffc, 0xffffffff }); + /// + /// // Set rp = sp << 1. + /// mp_limb_t bits = gmp_lib.mpn_lshift(rp, sp, sp.Size, 1); + /// + /// // Assert result of operation. + /// Assert.IsTrue(bits == 1); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, sp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim sp As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &HfffffffcUI, &HffffffffUI}) + /// + /// ' Set rp = sp << 1. + /// Dim bits As mp_limb_t = gmp_lib.mpn_lshift(rp, sp, sp.Size, 1) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(bits = 1) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, sp, result) + /// + /// + public static mp_limb_t mpn_lshift(mp_ptr rp, /*const*/ mp_ptr sp, mp_size_t n, uint count) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (sp == null) throw new ArgumentNullException("sp"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_lshift_x86(rp.ToIntPtr(), sp.ToIntPtr(), n, count)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_lshift_x64(rp.ToIntPtr(), sp.ToIntPtr(), n, count)); + } + + /// + /// Divide {, } by , and return the remainder. + /// + /// The first operand integer. + /// The number of limbs of . + /// The second operand integer. + /// The remainder. + /// + /// + /// can be zero. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operand. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xfffffffe, 0x0000ffff }); + /// + /// // Assert s1p mod 3 is 2. + /// Assert.IsTrue(gmp_lib.mpn_mod_1(s1p, s1p.Size, 3) == 2); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(s1p); + /// + /// + /// ' Create multi-precision operand. + /// Dim s1p As New mp_ptr(New UInteger() { &HfffffffeUI, &Hffff}) + /// + /// ' Assert s1p mod 3 is 2. + /// Assert.IsTrue(gmp_lib.mpn_mod_1(s1p, s1p.Size, 3) = 2) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(s1p) + /// + /// + public static mp_limb_t mpn_mod_1(/*const*/ mp_ptr s1p, mp_size_t s1n, mp_limb_t s2limb) + { + if (s1p == null) throw new ArgumentNullException("s1p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_mod_1_x86(s1p.ToIntPtr(), s1n, (uint)s2limb)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_mod_1_x64(s1p.ToIntPtr(), s1n, s2limb)); + } + + /// + /// Multiply {, } and {, }, and write the ( + )-limb result to . + /// + /// The result integer. + /// The first operand integer. + /// The number of limbs of . + /// The first operand integer. + /// The number of limbs of . + /// Return the most significant limb of the result. + /// + /// + /// The destination has to have space for + limbs, + /// even if the product’s most significant limb is zero. + /// No overlap is permitted between the destination and either source. + /// + /// + /// This function requires that is greater than or equal to . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000002 }); + /// mp_ptr rp = new mp_ptr(new uint[3]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff, 0x00000001 }); + /// + /// // Set rp = s1 * s2. + /// gmp_lib.mpn_mul(rp, s1p, s1p.Size, s2p, s2p.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H2}) + /// Dim rp As New mp_ptr(New UInteger(2) { }) + /// Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI, &H1}) + /// + /// ' Set rp = s1 * s2. + /// gmp_lib.mpn_mul(rp, s1p, s1p.Size, s2p, s2p.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static mp_limb_t mpn_mul(mp_ptr rp, /*const*/ mp_ptr s1p, mp_size_t s1n, /*const*/ mp_ptr s2p, mp_size_t s2n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_mul_x86(rp.ToIntPtr(), s1p.ToIntPtr(), s1n, s2p.ToIntPtr(), s2n)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_mul_x64(rp.ToIntPtr(), s1p.ToIntPtr(), s1n, s2p.ToIntPtr(), s2n)); + } + + /// + /// Multiply {, } by , and write the least significant limbs of the product to . + /// + /// The result integer. + /// The first operand integer. + /// The number of limbs of . + /// The second operand integer. + /// Return the most significant limb of the product. + /// + /// + /// {, } and {, } + /// are allowed to overlap provided . + /// + /// + /// This is a low-level function that is a building block for general multiplication as well as + /// other operations in GMP. It is written in assembly for most CPUs. + /// + /// + /// Don’t call this function if is a power of 2; + /// use with a count equal to the logarithm of + /// instead, for optimal speed. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + /// + /// // Set rp = s1 * 2. + /// mp_limb_t carry = gmp_lib.mpn_mul_1(rp, s1p, s1p.Size, 2); + /// + /// // Assert result of operation. + /// Assert.IsTrue(carry == 1); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI}) + /// + /// ' Set rp = s1 * 2. + /// Dim carry As mp_limb_t = gmp_lib.mpn_mul_1(rp, s1p, s1p.Size, 2) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(carry = 1) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, result) + /// + /// + public static mp_limb_t mpn_mul_1(mp_ptr rp, /*const*/ mp_ptr s1p, mp_size_t n, mp_limb_t s2limb) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_mul_1_x86(rp.ToIntPtr(), s1p.ToIntPtr(), n, (uint)s2limb)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_mul_1_x64(rp.ToIntPtr(), s1p.ToIntPtr(), n, s2limb)); + } + + /// + /// Multiply {, } and {, }, and write the (2 * )-limb result to . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// + /// + /// The destination has to have space for 2 * limbs, even if the product’s + /// most significant limb is zero. No overlap is permitted between the destination and either source. + /// + /// + /// If the two input operands are the same, use . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000002, 0x00000000 }); + /// mp_ptr rp = new mp_ptr(new uint[4]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff, 0x00000001, 0x00000000 }); + /// + /// // Set rp = s1 * s2. + /// gmp_lib.mpn_mul_n(rp, s1p, s2p, s1p.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H2, &H0}) + /// Dim rp As New mp_ptr(New UInteger(3) { }) + /// Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI, &H1, &H0}) + /// + /// ' Set rp = s1 * s2. + /// gmp_lib.mpn_mul_n(rp, s1p, s2p, s1p.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static void mpn_mul_n(mp_ptr rp, /*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + SafeNativeMethods.__gmpn_mul_n(rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n); + } + + /// + /// Compute the square of {, } and write the (2 * )-limb result to . + /// + /// The result integer. + /// The operand integer. + /// The number of limbs of . + /// + /// + /// The destination has to have space for 2 * limbs, even if the result’s + /// most significant limb is zero. No overlap is permitted between the destination and the source. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr rp = new mp_ptr(new uint[4]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x00000000, 0xfffffffe, 0xffffffff }); + /// + /// // Set rp = s1^2. + /// gmp_lib.mpn_sqr(rp, s1p, s1p.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim rp As New mp_ptr(New UInteger(3) { }) + /// Dim result As New mp_ptr(New UInteger() { &H1, &H0, &HfffffffeUI, &HffffffffUI}) + /// + /// ' Set rp = s1^2. + /// gmp_lib.mpn_sqr(rp, s1p, s1p.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, result) + /// + /// + public static void mpn_sqr(mp_ptr rp, /*const*/ mp_ptr s1p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + SafeNativeMethods.__gmpn_sqr(rp.ToIntPtr(), s1p.ToIntPtr(), n); + } + + /// + /// Perform the negation of {, }, and write the result to {, }. + /// + /// The result integer. + /// The operand integer. + /// The number of limbs of and . + /// Return borrow, either 0 or 1. + /// + /// + /// This is equivalent to calling with a -limb + /// zero minuend and passing {, } as subtrahend. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x0000001, 0x00000000 }); + /// + /// // Set rp = -sp. + /// mp_limb_t borrow = gmp_lib.mpn_neg(rp, sp, sp.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(borrow == 1); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, sp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim sp As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H1, &H0}) + /// + /// ' Set rp = -sp. + /// Dim borrow As mp_limb_t = gmp_lib.mpn_neg(rp, sp, sp.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(borrow = 1) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, sp, result) + /// + /// + public static mp_limb_t mpn_neg(mp_ptr rp, /*const*/ mp_ptr sp, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (sp == null) throw new ArgumentNullException("sp"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_neg_x86(rp.ToIntPtr(), sp.ToIntPtr(), n)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_neg_x64(rp.ToIntPtr(), sp.ToIntPtr(), n)); + } + + /// + /// Perform the bitwise complement of {, }, and write the result to {, }. + /// + /// The result integer. + /// The operand integer. + /// The numbe rof limbs of and . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr sp = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x0f0f0f0f, 0x0f0f0f0f }); + /// + /// // Set rp = not(sp). + /// gmp_lib.mpn_com(rp, sp, sp.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, sp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim sp As New mp_ptr(New UInteger() { &Hf0f0f0f0UI, &Hf0f0f0f0UI}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &Hf0f0f0f, &Hf0f0f0f}) + /// + /// ' Set rp = not(sp). + /// gmp_lib.mpn_com(rp, sp, sp.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, sp, result) + /// + /// + public static void mpn_com(mp_ptr rp, /*const*/ mp_ptr sp, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (sp == null) throw new ArgumentNullException("sp"); + SafeNativeMethods.__gmpn_com(rp.ToIntPtr(), sp.ToIntPtr(), n); + } + + /// + /// Return non-zero iff {, } is a perfect square. + /// + /// The operand integer. + /// The numbe rof limbs of . + /// Non-zero iff {, } is a perfect square. + /// + /// + /// The most significant limb of the input {, } must be non-zero. + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operand. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// + /// // Assert s1p is not a perfect square. + /// Assert.IsTrue(gmp_lib.mpn_perfect_square_p(s1p, s1p.Size) == 0); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(s1p); + /// + /// + /// ' Create multi-precision operand. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// + /// ' Assert s1p is not a perfect square. + /// Assert.IsTrue(gmp_lib.mpn_perfect_square_p(s1p, s1p.Size) = 0) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(s1p) + /// + /// + public static int mpn_perfect_square_p(/*const*/ mp_ptr s1p, mp_size_t n) + { + if (s1p == null) throw new ArgumentNullException("s1p"); + return SafeNativeMethods.__gmpn_perfect_square_p(s1p.ToIntPtr(), n); + } + + /// + /// Return non-zero iff {, } is a perfect power. + /// + /// The operand integer. + /// The numbe rof limbs of . + /// Non-zero iff {, } is a perfect power. + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operand. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xd4a51000, 0x000000e8 }); + /// + /// // Assert s1p is a perfect power. + /// Assert.IsTrue(gmp_lib.mpn_perfect_power_p(s1p, s1p.Size) != 0); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(s1p); + /// + /// + /// ' Create multi-precision operand. + /// Dim s1p As New mp_ptr(New UInteger() { &Hd4a51000UI, &He8}) + /// + /// ' Assert s1p is a perfect power. + /// Assert.IsTrue(gmp_lib.mpn_perfect_power_p(s1p, s1p.Size) <> 0) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(s1p) + /// + /// + public static int mpn_perfect_power_p(/*const*/ mp_ptr sp, mp_size_t n) + { + if (sp == null) throw new ArgumentNullException("sp"); + return SafeNativeMethods.__gmpn_perfect_power_p(sp.ToIntPtr(), n); + } + + /// + /// Count the number of set bits in {, }. + /// + /// The operand integer. + /// The number of limbs of . + /// The number of set bits in {, }. + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operand. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0x0000001, 0x00000001 }); + /// + /// // Assert result of operation. + /// Assert.IsTrue(gmp_lib.mpn_popcount(s1p, s1p.Size) == 2); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(s1p); + /// + /// + /// ' Create multi-precision operand. + /// Dim s1p As New mp_ptr(New UInteger() { &H1, &H1}) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(gmp_lib.mpn_popcount(s1p, s1p.Size) = 2) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(s1p) + /// + /// + public static mp_bitcnt_t mpn_popcount(/*const*/ mp_ptr s1p, mp_size_t n) + { + if (s1p == null) throw new ArgumentNullException("s1p"); + return new mp_bitcnt_t(SafeNativeMethods.__gmpn_popcount(s1p.ToIntPtr(), n)); + } + + ////#define mpn_pow_1 __MPN(pow_1) + ////public static int /*mp_size_t*/ mpn_pow_1(IntPtr /*mp_ptr*/, /*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/, mp_limb_t, IntPtr /*mp_ptr*/) + //{ + // return SafeNativeMethods.__gmpn_pow_1(IntPtr /*mp_ptr*/, /*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/, mp_limb_t, IntPtr /*mp_ptr*/); + //} + + /////* undocumented now, but retained here for upward compatibility */ + ////#define mpn_preinv_mod_1 __MPN(preinv_mod_1) + ////public static mp_limb_t mpn_preinv_mod_1(/*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/, mp_limb_t, mp_limb_t) + //{ + // return SafeNativeMethods.__gmpn_preinv_mod_1(/*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/, mp_limb_t, mp_limb_t); + //} + + /// + /// Generate a random number of length and store it at . + /// + /// The result integer. + /// The number of limbs of . + /// + /// + /// The most significant limb is always non-zero. + /// generates uniformly distributed limb data, + /// generates long strings of zeros and ones in the binary representation. + /// + /// + /// is intended for testing the correctness of the mpn routines. + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operand. + /// mp_ptr r1p = new mp_ptr(new uint[2]); + /// + /// // Generate random number. + /// gmp_lib.mpn_random(r1p, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 1); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(r1p); + /// + /// + /// ' Create multi-precision operand. + /// Dim r1p As New mp_ptr(New UInteger(1) { }) + /// + /// ' Generate random number. + /// gmp_lib.mpn_random(r1p, If(gmp_lib.mp_bytes_per_limb = 4, 2, 1)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(r1p) + /// + /// + public static void mpn_random(mp_ptr r1p, mp_size_t r1n) + { + if (r1p == null) throw new ArgumentNullException("r1p"); + SafeNativeMethods.__gmpn_random(r1p.ToIntPtr(), r1n); + } + + /// + /// Generate a random number of length and store it at . + /// + /// The result integer. + /// The number of limbs of . + /// + /// + /// The most significant limb is always non-zero. + /// generates uniformly distributed limb data, + /// generates long strings of zeros and ones in the binary representation. + /// + /// + /// is intended for testing the correctness of the mpn routines. + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operand. + /// mp_ptr r1p = new mp_ptr(new uint[2]); + /// + /// // Generate random number. + /// gmp_lib.mpn_random2(r1p, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 1); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(r1p); + /// + /// + /// ' Create multi-precision operand. + /// Dim r1p As New mp_ptr(New UInteger(1) { }) + /// + /// ' Generate random number. + /// gmp_lib.mpn_random2(r1p, If(gmp_lib.mp_bytes_per_limb = 4, 2, 1)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(r1p) + /// + /// + public static void mpn_random2(mp_ptr r1p, mp_size_t r1n) + { + if (r1p == null) throw new ArgumentNullException("r1p"); + SafeNativeMethods.__gmpn_random2(r1p.ToIntPtr(), r1n); + } + + /// + /// Shift {, } right by bits, and write the result to {, }. + /// + /// The result integer. + /// The operand integer. + /// The number of limbs of and . + /// + /// The bits shifted out at the right are returned in the most significant bits of the return value (the rest of the return value is zero). + /// + /// + /// must be in the range 1 to - 1. + /// The regions {, } and {, } + /// may overlap, provided . + /// + /// + /// This function is written in assembly for most CPUs. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xffffffff, 0x7fffffff }); + /// + /// // Set rp = sp >> 1. + /// mp_limb_t bits = gmp_lib.mpn_rshift(rp, sp, sp.Size, 1); + /// + /// // Assert result of operation. + /// Assert.IsTrue(bits == (gmp_lib.mp_bytes_per_limb == 4 ? 0x80000000 : 0x8000000000000000)); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, sp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim sp As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &HffffffffUI, &H7fffffff}) + /// + /// ' Set rp = sp >> 1. + /// Dim bits As mp_limb_t = gmp_lib.mpn_rshift(rp, sp, sp.Size, 1) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(bits = (If(gmp_lib.mp_bytes_per_limb = 4, &H80000000UI, &H8000000000000000UL))) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, sp, result) + /// + /// + public static mp_limb_t mpn_rshift(mp_ptr rp, /*const*/ mp_ptr sp, mp_size_t n, uint count) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (sp == null) throw new ArgumentNullException("sp"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_rshift_x86(rp.ToIntPtr(), sp.ToIntPtr(), n, count)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_rshift_x64(rp.ToIntPtr(), sp.ToIntPtr(), n, count)); + } + + /// + /// Scan from bit position for the next clear bit. + /// + /// The operand integer. + /// The index of the starting bit. + /// The index of the next clear bit. + /// + /// + /// It is required that there be a clear bit within the area at + /// at or beyond bit position , so that the function has something to return. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operand. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0x0000001, 0x00000001 }); + /// + /// // Assert result of operation. + /// Assert.IsTrue(gmp_lib.mpn_scan0(s1p, 0) == 1); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(s1p); + /// + /// + /// ' Create multi-precision operand. + /// Dim s1p As New mp_ptr(New UInteger() { &H1, &H1}) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(gmp_lib.mpn_scan0(s1p, 0) = 1) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(s1p) + /// + /// + public static mp_bitcnt_t mpn_scan0(/*const*/ mp_ptr s1p, mp_bitcnt_t bit) + { + if (s1p == null) throw new ArgumentNullException("s1p"); + return new mp_bitcnt_t(SafeNativeMethods.__gmpn_scan0(s1p.ToIntPtr(), bit)); + } + + /// + /// Scan from bit position for the next set bit. + /// + /// The operand integer. + /// The index of the starting bit. + /// The index of the next set bit. + /// + /// + /// It is required that there be a set bit within the area at + /// at or beyond bit position , so that the function has something to return. + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operand. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0x0000001, 0x00000001 }); + /// + /// // Assert result of operation. + /// Assert.IsTrue(gmp_lib.mpn_scan1(s1p, 1) == 32); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(s1p); + /// + /// + /// ' Create multi-precision operand. + /// Dim s1p As New mp_ptr(New UInteger() { &H1, &H1}) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(gmp_lib.mpn_scan1(s1p, 1) = 32) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(s1p) + /// + /// + public static mp_bitcnt_t mpn_scan1(/*const*/ mp_ptr s1p, mp_bitcnt_t bit) + { + if (s1p == null) throw new ArgumentNullException("s1p"); + return new mp_bitcnt_t(SafeNativeMethods.__gmpn_scan1(s1p.ToIntPtr(), bit)); + } + + /// + /// Convert bytes {, } in the given to limbs at . + /// + /// The result integer. + /// The operand string. + /// The length of . + /// + /// The number of limbs of . + /// + /// + /// [0] is the most significant input byte and + /// [ - 1] is the least significant input byte. + /// Each byte should be a value in the range 0 to - 1, + /// not an ASCII character. base can vary from 2 to 256. + /// + /// + /// The converted value is {, rn} where rn is the return value. + /// If the most significant input byte [0] is non-zero, + /// then [rn - 1] will be non-zero, + /// else [rn - 1] and some number of subsequent limbs may be zero. + /// + /// + /// The area at has to have space for the largest possible number with + /// digits in the chosen , plus one extra limb. + /// + /// + /// The input must have at least one byte, and no overlap is permitted + /// between {, } and the result at . + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands. + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// byte[] s = new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 1 }; + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x00000001 }); + /// char_ptr str = new char_ptr("xxxxxxxxxxxxxxxxx"); + /// Marshal.Copy(s, 0, str.ToIntPtr(), 9); + /// + /// // Convert rp from str in hex base. + /// mp_size_t count = gmp_lib.mpn_set_str(rp, str, 9, 16); + /// + /// // Assert the non-ASCII, hex representation of s1p. + /// Assert.IsTrue(count == rp.Size); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp); + /// gmp_lib.free(str); + /// + /// + /// ' Create multi-precision operands. + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim s As Byte() = New Byte() { 1, 0, 0, 0, 0, 0, 0, 0, 1} + /// Dim result As New mp_ptr(New UInteger() { &H1, &H1}) + /// Dim str As New char_ptr("xxxxxxxxxxxxxxxxx") + /// Marshal.Copy(s, 0, str.ToIntPtr(), 9) + /// + /// ' Convert rp from str in hex base. + /// Dim count As mp_size_t = gmp_lib.mpn_set_str(rp, str, 9, 16) + /// + /// ' Assert the non-ASCII, hex representation of s1p. + /// Assert.IsTrue(count = rp.Size) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp) + /// gmp_lib.free(str) + /// + /// + public static mp_size_t mpn_set_str(mp_ptr rp, /*const unsigned*/ char_ptr str, size_t strsize, int @base) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (IntPtr.Size == 4) + return new mp_size_t(SafeNativeMethods.__gmpn_set_str_x86(rp.ToIntPtr(), str.ToIntPtr(), (uint)strsize, @base)); + else + return new mp_size_t(SafeNativeMethods.__gmpn_set_str_x64(rp.ToIntPtr(), str.ToIntPtr(), strsize, @base)); + } + + /// + /// Return the size of {, } measured in number of digits in the given . + /// + /// The operand integer. + /// The number of limbs of . + /// The base. + /// The size of {, } measured in number of digits in the given . + /// + /// + /// can vary from 2 to 62. + /// Requires > 0 and [ - 1] > 0. + /// The result will be either exact or 1 too big. + /// If base is a power of 2, the result is always exact. + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr xp = new mp_ptr(new uint[] { 0x00000001, 0x00000001 }); + /// + /// // Assert that the number of bits required is 33. + /// Assert.IsTrue(gmp_lib.mpn_sizeinbase(xp, xp.Size, 2) == 33); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(xp); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim xp As New mp_ptr(New UInteger() { &H1, &H1}) + /// + /// ' Assert that the number of bits required is 33. + /// Assert.IsTrue(gmp_lib.mpn_sizeinbase(xp, xp.Size, 2) = 33) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(xp) + /// + /// + public static size_t mpn_sizeinbase(/*const*/ mp_ptr xp, mp_size_t n, int @base) + { + if (xp == null) throw new ArgumentNullException("xp"); + if (IntPtr.Size == 4) + return new size_t(SafeNativeMethods.__gmpn_sizeinbase_x86(xp.ToIntPtr(), n, @base)); + else + return new size_t(SafeNativeMethods.__gmpn_sizeinbase_x64(xp.ToIntPtr(), n, @base)); + } + + /// + /// Compute the square root of {, } and put the result at {, ceil( / 2)} and the remainder at {, retval}. + /// + /// The first result integer. + /// The second result integer. + /// The operand integwer. + /// The number of limbs of . + /// The number of limbs of . + /// + /// + /// needs space for limbs, + /// but the return value indicates how many are produced. + /// + /// + /// The most significant limb of {, } must be non-zero. + /// The areas {, ceil( / 2)} and + /// {, } must be completely separate. + /// The areas {, } and {, } + /// must be either identical or completely separate. + /// + /// + /// If the remainder is not wanted then can be NULL, and in this case the return value + /// is zero or non-zero according to whether the remainder would have been zero or non-zero. + /// + /// + /// A return value of zero indicates a perfect square. See also . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr sp = new mp_ptr(new uint[] { 0x00000001, 0x00000001 }); + /// mp_ptr r1p = new mp_ptr(new uint[sp.Size * (gmp_lib.mp_bytes_per_limb / 4)]); + /// mp_ptr r2p = new mp_ptr(new uint[sp.Size * (gmp_lib.mp_bytes_per_limb / 4)]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00010000, 0x00000000 }); + /// mp_ptr remainder = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + /// + /// // Set r1p = trunc(sqrt(sp)), r2p = sp - r1p^2 + /// mp_size_t r2n = gmp_lib.mpn_sqrtrem(r1p, r2p, sp, sp.Size); + /// + /// // Assert result. + /// Assert.IsTrue(r2n == 1); + /// Assert.IsTrue(r1p.SequenceEqual(result)); + /// Assert.IsTrue(r2p.SequenceEqual(remainder)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(sp, r1p, r2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim sp As New mp_ptr(New UInteger() { &H1, &H1}) + /// Dim r1p As New mp_ptr(New UInteger(sp.Size * (gmp_lib.mp_bytes_per_limb / 4) - 1) {}) + /// Dim r2p As New mp_ptr(New UInteger(sp.Size * (gmp_lib.mp_bytes_per_limb / 4) - 1) {}) + /// Dim result As New mp_ptr(New UInteger() { &H10000, &H0}) + /// Dim remainder As New mp_ptr(New UInteger() { &H1, &H0}) + /// + /// ' Set r1p = trunc(sqrt(sp)), r2p = sp - r1p^2 + /// Dim r2n As mp_size_t = gmp_lib.mpn_sqrtrem(r1p, r2p, sp, sp.Size) + /// + /// ' Assert result. + /// Assert.IsTrue(r2n = 1) + /// Assert.IsTrue(r1p.SequenceEqual(result)) + /// Assert.IsTrue(r2p.SequenceEqual(remainder)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(sp, r1p, r2p, result) + /// + /// + public static mp_size_t mpn_sqrtrem(mp_ptr r1p, mp_ptr r2p, /*const*/ mp_ptr sp, mp_size_t n) + { + if (r1p == null) throw new ArgumentNullException("r1p"); + if (r2p == null) throw new ArgumentNullException("r2p"); + if (sp == null) throw new ArgumentNullException("sp"); + return new mp_size_t(SafeNativeMethods.__gmpn_sqrtrem(r1p.ToIntPtr(), r2p.ToIntPtr(), sp.ToIntPtr(), n)); + } + + /// + /// Subtract {, } from {, }, and write the least significant limbs of the result to . + /// + /// The result integer. + /// The first operand integer. + /// The number of limbs of . + /// The second operand integer. + /// The number of limbs of . + /// Return borrow, either 0 or 1. + /// + /// + /// This is the lowest-level function for subtraction. It is the preferred function for subtraction, since it is written in assembly for most CPUs. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + /// + /// // Set rp = s1 - s2. + /// mp_limb_t borrow = gmp_lib.mpn_sub(rp, s1p, s1p.Size, s2p, s2p.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(borrow == 0); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI}) + /// + /// ' Set rp = s1 - s2. + /// Dim borrow As mp_limb_t = gmp_lib.mpn_sub(rp, s1p, s1p.Size, s2p, s2p.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(borrow = 0) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static mp_limb_t mpn_sub(mp_ptr rp, /*const*/ mp_ptr s1p, mp_size_t s1n, /*const*/ mp_ptr s2p, mp_size_t s2n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_sub_x86(rp.ToIntPtr(), s1p.ToIntPtr(), s1n, s2p.ToIntPtr(), s2n)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_sub_x64(rp.ToIntPtr(), s1p.ToIntPtr(), s1n, s2p.ToIntPtr(), s2n)); + } + + /// + /// Subtract from {, }, and write the least significant limbs of the result to . + /// + /// The result integer. + /// The first operand integer. + /// The numbe rof limbs of . + /// The second operand integer. + /// Return borrow, either 0 or 1. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + /// + /// // Set rp = s1 - 1. + /// mp_limb_t borrow = gmp_lib.mpn_sub_1(rp, s1p, s1p.Size, 1); + /// + /// // Assert result of operation. + /// Assert.IsTrue(borrow == 0); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI}) + /// + /// ' Set rp = s1 - 1. + /// Dim borrow As mp_limb_t = gmp_lib.mpn_sub_1(rp, s1p, s1p.Size, 1) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(borrow = 0) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, result) + /// + /// + public static mp_limb_t mpn_sub_1(mp_ptr rp, /*const*/ mp_ptr s1p, mp_size_t n, mp_limb_t s2limb) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_sub_1_x86(rp.ToIntPtr(), s1p.ToIntPtr(), n, (uint)s2limb)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_sub_1_x64(rp.ToIntPtr(), s1p.ToIntPtr(), n, s2limb)); + } + + /// + /// Subtract {, } from {, }, and write the least significant limbs of the result to . + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The numbe rof limbs of and . + /// Return borrow, either 0 or 1. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + /// + /// // Set rp = s1 - s2. + /// mp_limb_t borrow = gmp_lib.mpn_sub_n(rp, s1p, s2p, rp.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(borrow == 0); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &H0}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI}) + /// + /// ' Set rp = s1 - s2. + /// Dim borrow As mp_limb_t = gmp_lib.mpn_sub_n(rp, s1p, s2p, rp.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(borrow = 0) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static mp_limb_t mpn_sub_n(mp_ptr rp, /*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_sub_n_x86(rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_sub_n_x64(rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n)); + } + + /// + /// Multiply {, } and , and subtract the least significant limbs of the product from {, } and write the result to . + /// + /// The result integer. + /// The first operand integer. + /// The number of limbs of + /// The second operand integer. + /// Return the most significant limb of the product, plus borrow-out from the subtraction. + /// + /// + /// {, } and {, } + /// are allowed to overlap provided . + /// + /// + /// This is a low-level function that is a building block for general multiplication and division + /// as well as other operations in GMP. It is written in assembly for most CPUs. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr rp = new mp_ptr(new uint[] { 0x00000002, 0x00000000 }); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000004, 0x00000000 }); + /// + /// // Set rp -= s1 * 2. + /// mp_limb_t borrow = gmp_lib.mpn_submul_1(rp, s1p, s1p.Size, 2); + /// + /// // Assert result of operation. + /// Assert.IsTrue(borrow == 0x02); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim rp As New mp_ptr(New UInteger() { &H2, &H0}) + /// Dim result As New mp_ptr(New UInteger() { &H4, &H0}) + /// + /// ' Set rp -= s1 * 2. + /// Dim borrow As mp_limb_t = gmp_lib.mpn_submul_1(rp, s1p, s1p.Size, 2) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(borrow = &H2) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, result) + /// + /// + public static mp_limb_t mpn_submul_1(mp_ptr rp, /*const*/ mp_ptr s1p, mp_size_t n, mp_limb_t s2limb) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_submul_1_x86(rp.ToIntPtr(), s1p.ToIntPtr(), n, (uint)s2limb)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_submul_1_x64(rp.ToIntPtr(), s1p.ToIntPtr(), n, s2limb)); + } + + /// + /// Divide {, } by {, } and put the quotient at {, - + 1} and the remainder at {, }. + /// + /// The result quotient integer. + /// The result remainder integer. + /// Must be 0. + /// The numerator operand integer. + /// The number of limbs of . + /// The denominator operand integer. + /// The number of limbs of . + /// + /// + /// The quotient is rounded towards 0. + /// + /// + /// No overlap is permitted between arguments, except that might + /// equal . + /// The dividend size must be greater than or equal to divisor + /// size . + /// The most significant limb of the divisor must be non-zero. + /// The operand must be zero. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr np = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + /// mp_ptr dp = new mp_ptr(new uint[] { 0x00000013 }); + /// mp_ptr qp = new mp_ptr(new uint[np.Size - dp.Size + 1]); + /// mp_ptr rp = new mp_ptr(new uint[dp.Size]); + /// mp_ptr quotient = new mp_ptr(new uint[] { 0x435e50d7, 0x00000d79 }); + /// mp_ptr remainder = new mp_ptr(new uint[] { 0x0000000a }); + /// + /// // Set rp = np / dp. + /// gmp_lib.mpn_tdiv_qr(qp, rp, 0, np, np.Size, dp, dp.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(qp.SequenceEqual(quotient)); + /// Assert.IsTrue(rp.SequenceEqual(remainder)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(qp, rp, np, dp, quotient, remainder); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim np As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff}) + /// Dim dp As New mp_ptr(New UInteger() { &H13}) + /// Dim qp As New mp_ptr(New UInteger(np.Size - dp.Size) { }) + /// Dim rp As New mp_ptr(New UInteger(dp.Size - 1) { }) + /// Dim quotient As New mp_ptr(New UInteger() { &H435e50d7, &Hd79}) + /// Dim remainder As New mp_ptr(New UInteger() { &Ha}) + /// + /// ' Set rp = np / dp. + /// gmp_lib.mpn_tdiv_qr(qp, rp, 0, np, np.Size, dp, dp.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(qp.SequenceEqual(quotient)) + /// Assert.IsTrue(rp.SequenceEqual(remainder)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(qp, rp, np, dp, quotient, remainder) + /// + /// + public static void mpn_tdiv_qr(mp_ptr qp, mp_ptr rp, mp_size_t qxn, /*const*/ mp_ptr np, mp_size_t nn, /*const*/ mp_ptr dp, mp_size_t dn) + { + if (qp == null) throw new ArgumentNullException("qp"); + if (rp == null) throw new ArgumentNullException("rp"); + if (np == null) throw new ArgumentNullException("np"); + if (dp == null) throw new ArgumentNullException("dp"); + SafeNativeMethods.__gmpn_tdiv_qr(qp.ToIntPtr(), rp.ToIntPtr(), qxn, np.ToIntPtr(), nn, dp.ToIntPtr(), dn); + } + + /// + /// Perform the bitwise logical and of {, } and {, }, and write the result to {, }. + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + /// + /// // Set rp = s1 and s2. + /// gmp_lib.mpn_and_n(rp, s1p, s2p, s1p.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H1, &H12345678}) + /// + /// ' Set rp = s1 and s2. + /// gmp_lib.mpn_and_n(rp, s1p, s2p, s1p.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static void mpn_and_n(mp_ptr rp, /*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + SafeNativeMethods.__gmpn_and_n(rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n); + } + + /// + /// Perform the bitwise logical and of {, } and the bitwise complement of {, }, and write the result to {, }. + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xedcba987 }); + /// + /// // Set rp = s1 and not s2. + /// gmp_lib.mpn_andn_n(rp, s1p, s2p, s1p.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &Hedcba987UI}) + /// + /// ' Set rp = s1 and not s2. + /// gmp_lib.mpn_andn_n(rp, s1p, s2p, s1p.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static void mpn_andn_n(mp_ptr rp, /*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + SafeNativeMethods.__gmpn_andn_n(rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n); + } + + /// + /// Perform the bitwise logical and of {, } and {, }, and write the bitwise complement of the result to {, }. + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + /// + /// // Set rp = not(s1 and s2). + /// gmp_lib.mpn_and_n(rp, s1p, s2p, s1p.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678}) + /// rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H1, &H12345678}) + /// + /// ' Set rp = not(s1 and s2). + /// gmp_lib.mpn_and_n(rp, s1p, s2p, s1p.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static void mpn_nand_n(mp_ptr rp, /*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + SafeNativeMethods.__gmpn_nand_n(rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n); + } + + /// + /// Perform the bitwise logical inclusive or of {, } and {, }, and write the result to {, }. + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// + /// // Set rp = s1 or s2. + /// gmp_lib.mpn_ior_n(rp, s1p, s2p, s1p.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// + /// ' Set rp = s1 or s2. + /// gmp_lib.mpn_ior_n(rp, s1p, s2p, s1p.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static void mpn_ior_n(mp_ptr rp, /*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + SafeNativeMethods.__gmpn_ior_n(rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n); + } + + /// + /// Perform the bitwise logical inclusive or of {, } and the bitwise complement of {, }, and write the result to {, }. + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// + /// // Set rp = s1 or not s2. + /// gmp_lib.mpn_iorn_n(rp, s1p, s2p, s1p.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// + /// ' Set rp = s1 or not s2. + /// gmp_lib.mpn_iorn_n(rp, s1p, s2p, s1p.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static void mpn_iorn_n(mp_ptr rp, /*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + SafeNativeMethods.__gmpn_iorn_n(rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n); + } + + /// + /// Perform the bitwise logical inclusive or of {, } and {, }, and write the bitwise complement of the result to {, }. + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + /// + /// // Set rp = not (s1 or s2). + /// gmp_lib.mpn_nior_n(rp, s1p, s2p, s1p.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H0, &H0}) + /// + /// ' Set rp = not (s1 or s2). + /// gmp_lib.mpn_nior_n(rp, s1p, s2p, s1p.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static void mpn_nior_n(mp_ptr rp, /*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + SafeNativeMethods.__gmpn_nior_n(rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n); + } + + /// + /// Perform the bitwise logical exclusive or of {, } and {, }, and write the result to {, }. + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xedcba987 }); + /// + /// // Set rp = s1 xor s2. + /// gmp_lib.mpn_xor_n(rp, s1p, s2p, s1p.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &Hedcba987UI}) + /// + /// ' Set rp = s1 xor s2. + /// gmp_lib.mpn_xor_n(rp, s1p, s2p, s1p.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static void mpn_xor_n(mp_ptr rp, /*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + SafeNativeMethods.__gmpn_xor_n(rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n); + } + + /// + /// Perform the bitwise logical exclusive or of {, } and {, }, and write the bitwise complement of the result to {, }. + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x12345678 }); + /// + /// // Set rp = not(s1 xor s2). + /// gmp_lib.mpn_xnor_n(rp, s1p, s2p, s1p.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &H12345678}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H1, &H12345678}) + /// + /// ' Set rp = not(s1 xor s2). + /// gmp_lib.mpn_xnor_n(rp, s1p, s2p, s1p.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static void mpn_xnor_n(mp_ptr rp, /*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + SafeNativeMethods.__gmpn_xnor_n(rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n); + } + + /// + /// Copy from {, } to {, }, increasingly. + /// + /// The result integer. + /// The operand integer. + /// The number of limbs of . + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr sp = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 }); + /// + /// // Set rp = sp. + /// gmp_lib.mpn_copyi(rp, sp, sp.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, sp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim sp As New mp_ptr(New UInteger() { &Hf0f0f0f0UI, &Hf0f0f0f0UI}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &Hf0f0f0f0UI, &Hf0f0f0f0UI}) + /// + /// ' Set rp = sp. + /// gmp_lib.mpn_copyi(rp, sp, sp.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, sp, result) + /// + /// + public static void mpn_copyi(mp_ptr rp, /*const*/ mp_ptr s1p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + SafeNativeMethods.__gmpn_copyi(rp.ToIntPtr(), s1p.ToIntPtr(), n); + } + + /// + /// Copy from {, } to {, }, decreasingly. + /// + /// The result integer. + /// The operand integer. + /// The number of limbs of . + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr sp = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 }); + /// + /// // Set rp = sp. + /// gmp_lib.mpn_copyd(rp, sp, sp.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, sp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim sp As New mp_ptr(New UInteger() { &Hf0f0f0f0UI, &Hf0f0f0f0UI}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &Hf0f0f0f0UI, &Hf0f0f0f0UI}) + /// + /// ' Set rp = sp. + /// gmp_lib.mpn_copyd(rp, sp, sp.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, sp, result) + /// + /// + public static void mpn_copyd(mp_ptr rp, /*const*/ mp_ptr s1p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + SafeNativeMethods.__gmpn_copyd(rp.ToIntPtr(), s1p.ToIntPtr(), n); + } + + /// + /// Zero {, }. + /// + /// The result integer. + /// The number of limbs of . + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operand, and expected result. + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + /// + /// // Set rp = sp. + /// gmp_lib.mpn_zero(rp, rp.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, result); + /// + /// + /// ' Create multi-precision operand, and expected result. + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H0, &H0}) + /// + /// ' Set rp = sp. + /// gmp_lib.mpn_zero(rp, rp.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, result) + /// + /// + public static void mpn_zero(mp_ptr rp, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + SafeNativeMethods.__gmpn_zero(rp.ToIntPtr(), n); + } + + /// + /// If is non-zero, it produces the same result as a regular , and if is zero, it copies {, } to the result area and returns zero. + /// + /// Conditonal value: non-zero for true, zero for false. + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// If is non-zero, return carry, either 0 or 1, and if is zero, return 0. + /// + /// + /// This function does conditional addition. + /// If is non-zero, it produces the same result as a regular , + /// and if is zero, it copies {, } to the result area and returns zero. + /// The functions is designed to have timing and memory access patterns depending only + /// on size and location of the data areas, but independent of the condition . + /// Like for , on most machines, the timing will also be independent + /// of the actual limb values. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + /// + /// // Set rp = s1 + s2. + /// mp_limb_t carry = gmp_lib.mpn_cnd_add_n(1, rp, s1p, s2p, rp.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(carry == 1); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &H0}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &H0, &H0}) + /// + /// ' Set rp = s1 + s2. + /// Dim carry As mp_limb_t = gmp_lib.mpn_cnd_add_n(1, rp, s1p, s2p, rp.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(carry = 1) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static mp_limb_t mpn_cnd_add_n(mp_limb_t cnd, mp_ptr rp, /*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_cnd_add_n_x86((uint)cnd, rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_cnd_add_n_x64(cnd, rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n)); + } + + + /// + /// If is non-zero, it produces the same result as a regular , and if is zero, it copies {, } to the result area and returns zero. + /// + /// Conditonal value: non-zero for true, zero for false. + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// If is non-zero, return borrow, either 0 or 1, and if is zero, return 0. + /// + /// + /// This function does conditional addition. + /// If is non-zero, it produces the same result as a regular , + /// and if is zero, it copies {, } to the result area and returns zero. + /// The functions is designed to have timing and memory access patterns depending only + /// on size and location of the data areas, but independent of the condition . + /// Like for , on most machines, the timing will also be independent + /// of the actual limb values. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + /// mp_ptr rp = new mp_ptr(new uint[2]); + /// mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + /// + /// // Set rp = s1 - s2. + /// mp_limb_t borrow = gmp_lib.mpn_cnd_sub_n(1, rp, s1p, s2p, rp.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(borrow == 0); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim s1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim s2p As New mp_ptr(New UInteger() { &H1, &H0}) + /// Dim rp As New mp_ptr(New UInteger(1) { }) + /// Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI}) + /// + /// ' Set rp = s1 - s2. + /// Dim borrow As mp_limb_t = gmp_lib.mpn_cnd_sub_n(1, rp, s1p, s2p, rp.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(borrow = 0) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, s1p, s2p, result) + /// + /// + public static mp_limb_t mpn_cnd_sub_n(mp_limb_t cnd, mp_ptr rp, /*const*/ mp_ptr s1p, /*const*/ mp_ptr s2p, mp_size_t n) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (s1p == null) throw new ArgumentNullException("s1p"); + if (s2p == null) throw new ArgumentNullException("s2p"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_cnd_sub_n_x86((uint)cnd, rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n)); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_cnd_sub_n_x64(cnd, rp.ToIntPtr(), s1p.ToIntPtr(), s2p.ToIntPtr(), n)); + } + + /// + /// Set R to A + b, where R = {, }, A = {, }, and is a single limb. + /// + /// The result integer. + /// The first operand integer. + /// The number of limbs of and . + /// The second operand integer. + /// The scratch operand integer. + /// Returns carry, either 0 or 1. + /// + /// + /// This function takes O(N) time, unlike the leaky functions which is O(1) on average. + /// It requires scratch space of (n) limbs, to be passed in the parameter. + /// The scratch space requirements are guaranteed to be at most limbs, and increase monotonously in the operand size. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 }); + /// mp_ptr rp = new mp_ptr(result.Size); + /// + /// // Create scratch space. + /// mp_size_t size = gmp_lib.mpn_sec_add_1_itch(ap.Size); + /// mp_ptr tp = new mp_ptr(size); + /// + /// // Set rp = ap + 1. + /// mp_limb_t carry = gmp_lib.mpn_sec_add_1(rp, ap, ap.Size, 1, tp); + /// + /// // Assert result of operation. + /// Assert.IsTrue(carry == 1); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, ap, tp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim result As New mp_ptr(New UInteger() { &H0, &H0}) + /// Dim rp As New mp_ptr(result.Size) + /// + /// ' Create scratch space. + /// Dim size As mp_size_t = gmp_lib.mpn_sec_add_1_itch(ap.Size) + /// Dim tp As New mp_ptr(size) + /// + /// ' Set rp = ap + 1. + /// Dim carry As mp_limb_t = gmp_lib.mpn_sec_add_1(rp, ap, ap.Size, 1, tp) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(carry = 1) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, ap, tp, result) + /// + /// + public static mp_limb_t mpn_sec_add_1(mp_ptr rp, /*const*/ mp_ptr ap, mp_size_t n, mp_limb_t b, mp_ptr tp) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (ap == null) throw new ArgumentNullException("ap"); + if (tp == null) throw new ArgumentNullException("tp"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_sec_add_1_x86(rp.ToIntPtr(), ap.ToIntPtr(), n, (uint)b, tp.ToIntPtr())); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_sec_add_1_x64(rp.ToIntPtr(), ap.ToIntPtr(), n, b, tp.ToIntPtr())); + } + + /// + /// Return the scratch space in number of limbs required by the function . + /// + /// The number of limbs of the operand. + /// The scratch space in number of limbs required by the function . + /// + /// GNU MP - Low-level Functions + public static mp_size_t mpn_sec_add_1_itch(mp_size_t n) + { + return new mp_size_t(SafeNativeMethods.__gmpn_sec_add_1_itch(n)); + } + + /// + /// Set R to A - b, where R = {, }, A = {, }, and is a single limb. + /// + /// The result integer. + /// The first operand integer. + /// The number of limbs of and . + /// The second operand integer. + /// The scratch operand integer. + /// Returns borrow, either 0 or 1. + /// + /// + /// This function takes O(N) time, unlike the leaky functions which is O(1) on average. + /// It requires scratch space of (n) limbs, to be passed in the parameter. + /// The scratch space requirements are guaranteed to be at most limbs, and increase monotonously in the operand size. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff }); + /// mp_ptr rp = new mp_ptr(result.Size); + /// + /// // Create scratch space. + /// mp_size_t size = gmp_lib.mpn_sec_sub_1_itch(ap.Size); + /// mp_ptr tp = new mp_ptr(size); + /// + /// // Set rp = ap - 1. + /// mp_limb_t borrow = gmp_lib.mpn_sec_sub_1(rp, ap, ap.Size, 1, tp); + /// + /// // Assert result of operation. + /// Assert.IsTrue(borrow == 0); + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, ap, tp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI}) + /// Dim rp As New mp_ptr(result.Size) + /// + /// ' Create scratch space. + /// Dim size As mp_size_t = gmp_lib.mpn_sec_sub_1_itch(ap.Size) + /// Dim tp As New mp_ptr(size) + /// + /// ' Set rp = ap - 1. + /// Dim borrow As mp_limb_t = gmp_lib.mpn_sec_sub_1(rp, ap, ap.Size, 1, tp) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(borrow = 0) + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, ap, tp, result) + /// + /// + public static mp_limb_t mpn_sec_sub_1(mp_ptr rp, /*const*/ mp_ptr ap, mp_size_t n, mp_limb_t b, mp_ptr tp) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (ap == null) throw new ArgumentNullException("ap"); + if (tp == null) throw new ArgumentNullException("tp"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_sec_sub_1_x86(rp.ToIntPtr(), ap.ToIntPtr(), n, (uint)b, tp.ToIntPtr())); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_sec_sub_1_x64(rp.ToIntPtr(), ap.ToIntPtr(), n, b, tp.ToIntPtr())); + } + + /// + /// Return the scratch space in number of limbs required by the function . + /// + /// The number of limbs of the operand. + /// The scratch space in number of limbs required by the function . + /// + /// GNU MP - Low-level Functions + public static mp_size_t mpn_sec_sub_1_itch(mp_size_t n) + { + return SafeNativeMethods.__gmpn_sec_sub_1_itch(n); + } + + /// + /// If is non-zero, swaps the contents of the areas {, } and {, }. Otherwise, the areas are left unmodified. + /// + /// Conditonal value: non-zero for true, zero for false. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// + /// + /// Implemented using logical operations on the limbs, with the same memory accesses independent of the value of . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr bp = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + /// mp_ptr a1p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 }); + /// mp_ptr b1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// + /// // Exchange ab and bp. + /// gmp_lib.mpn_cnd_swap(1, ap, bp, ap.Size); + /// + /// // Assert result of operation. + /// Assert.IsTrue(ap.SequenceEqual(a1p)); + /// Assert.IsTrue(bp.SequenceEqual(b1p)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(ap, bp, a1p, b1p); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim bp As New mp_ptr(New UInteger() { &H1, &H0}) + /// Dim a1p As New mp_ptr(New UInteger() { &H1, &H0}) + /// Dim b1p As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// + /// ' Exchange ab and bp. + /// gmp_lib.mpn_cnd_swap(1, ap, bp, ap.Size) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(ap.SequenceEqual(a1p)) + /// Assert.IsTrue(bp.SequenceEqual(b1p)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(ap, bp, a1p, b1p) + /// + /// + public static void mpn_cnd_swap(mp_limb_t cnd, /*volatile*/ mp_ptr /*mp_limb_t**/ ap, /*volatile*/ mp_ptr /*mp_limb_t**/ bp, mp_size_t n) + { + if (ap == null) throw new ArgumentNullException("ap"); + if (bp == null) throw new ArgumentNullException("bp"); + if (IntPtr.Size == 4) + SafeNativeMethods.__gmpn_cnd_swap_x86((uint)cnd, ap.ToIntPtr(), bp.ToIntPtr(), n); + else + SafeNativeMethods.__gmpn_cnd_swap_x64(cnd, ap.ToIntPtr(), bp.ToIntPtr(), n); + } + + /// + /// Set R to A * B, where A = {, }, B = {, }, and R = {, + }. + /// + /// The result integer. + /// The first operand integer. + /// The number of limbs of . + /// The second operand integer. + /// The number of limbs of . + /// The scratch operand integer. + /// + /// + /// It is required that ≥ bn > 0. + /// + /// + /// No overlapping between R and the input operands is allowed. + /// For A = B, use for optimal performance. + /// + /// + /// This function requires scratch space of (, ) + /// limbs to be passed in the tp parameter. The scratch space requirements are guaranteed to increase monotonously in the operand sizes. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr bp = new mp_ptr(new uint[] { 0x00000002 }); + /// mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff, 0x00000001 }); + /// mp_ptr rp = new mp_ptr(ap.Size + bp.Size); + /// + /// // Create scratch space. + /// mp_size_t size = gmp_lib.mpn_sec_mul_itch(ap.Size, bp.Size); + /// mp_ptr tp = new mp_ptr(size); + /// + /// // Set rp = ap * bp. + /// gmp_lib.mpn_sec_mul(rp, ap, ap.Size, bp, bp.Size, tp); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, ap, bp, tp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim bp As New mp_ptr(New UInteger() { &H2}) + /// Dim result As New mp_ptr(New UInteger() { &HfffffffeUI, &HffffffffUI, &H1}) + /// Dim rp As New mp_ptr(ap.Size + bp.Size) + /// + /// ' Create scratch space. + /// Dim size As mp_size_t = gmp_lib.mpn_sec_mul_itch(ap.Size, bp.Size) + /// Dim tp As New mp_ptr(size) + /// + /// ' Set rp = ap * bp. + /// gmp_lib.mpn_sec_mul(rp, ap, ap.Size, bp, bp.Size, tp) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, ap, bp, tp, result) + /// + /// + public static void mpn_sec_mul(mp_ptr rp, /*const*/ mp_ptr ap, mp_size_t an, /*const*/ mp_ptr bp, mp_size_t bn, mp_ptr tp) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (ap == null) throw new ArgumentNullException("ap"); + if (bp == null) throw new ArgumentNullException("bp"); + if (tp == null) throw new ArgumentNullException("tp"); + SafeNativeMethods.__gmpn_sec_mul(rp.ToIntPtr(), ap.ToIntPtr(), an, bp.ToIntPtr(), bn, tp.ToIntPtr()); + } + + /// + /// Return the scratch space in number of limbs required by the function . + /// + /// The number of limbs of the first operand. + /// The number of limbs of the second operand. + /// The scratch space in number of limbs required by the function . + /// + /// GNU MP - Low-level Functions + public static mp_size_t mpn_sec_mul_itch(mp_size_t an, mp_size_t bn) + { + return SafeNativeMethods.__gmpn_sec_mul_itch(an, bn); + } + + /// + /// Set R to A^2, where A = {, }, and R = {, 2 * }. + /// + /// The result operand. + /// The operand integer. + /// The number of limbs of . + /// The scratch operand integer. + /// + /// + /// It is required that > 0. + /// + /// + /// No overlapping between R and the input operands is allowed. + /// + /// + /// This function requires scratch space of () + /// limbs to be passed in the parameter. + /// The scratch space requirements are guaranteed to increase monotonously in the operand size. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff }); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x00000000, 0xfffffffe, 0xffffffff }); + /// mp_ptr rp = new mp_ptr(2 * ap.Size); + /// + /// // Create scratch space. + /// mp_size_t size = gmp_lib.mpn_sec_sqr_itch(ap.Size); + /// mp_ptr tp = new mp_ptr(size); + /// + /// // Set rp = s1^2. + /// gmp_lib.mpn_sec_sqr(rp, ap, ap.Size, tp); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, ap, tp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim ap As New mp_ptr(New UInteger() { &HffffffffUI, &HffffffffUI}) + /// Dim result As New mp_ptr(New UInteger() { &H1, &H0, &HfffffffeUI, &HffffffffUI}) + /// Dim rp As New mp_ptr(2 * ap.Size) + /// + /// ' Create scratch space. + /// Dim size As mp_size_t = gmp_lib.mpn_sec_sqr_itch(ap.Size) + /// Dim tp As New mp_ptr(size) + /// + /// ' Set rp = s1^2. + /// gmp_lib.mpn_sec_sqr(rp, ap, ap.Size, tp) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, ap, tp, result) + /// + /// + public static void mpn_sec_sqr(mp_ptr rp, /*const*/ mp_ptr ap, mp_size_t an, mp_ptr tp) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (ap == null) throw new ArgumentNullException("ap"); + if (tp == null) throw new ArgumentNullException("tp"); + SafeNativeMethods.__gmpn_sec_sqr(rp.ToIntPtr(), ap.ToIntPtr(), an, tp.ToIntPtr()); + } + + /// + /// Return the scratch space in number of limbs required by the function . + /// + /// The number of limbs of the operand. + /// The scratch space in number of limbs required by the function . + /// + /// GNU MP - Low-level Functions + public static mp_size_t mpn_sec_sqr_itch(mp_size_t an) + { + return SafeNativeMethods.__gmpn_sec_sqr_itch(an); + } + + /// + /// Set R to (B^E) modulo M, where R = {, }, M = {, }, and E = {, ceil( / )}. + /// + /// The result operand. + /// The first operand integer. + /// The number of limbs of . + /// The second operand integer. + /// The number of limbs of . + /// The third operand integer. + /// The number of limbs of . + /// The scratch operand integer. + /// + /// + /// It is required that B > 0, that M > 0 is odd, and that E < 2^. + /// + /// + /// No overlapping between R and the input operands is allowed. + /// + /// + /// This function requires scratch space of (, , ) + /// limbs to be passed in the parameter. + /// The scratch space requirements are guaranteed to increase monotonously in the operand sizes. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr bp = new mp_ptr(new uint[] { 0x00000002 }); + /// mp_ptr ep = new mp_ptr(new uint[] { 0x00000004 }); + /// mp_ptr mp = new mp_ptr(new uint[] { 0x00000003 }); + /// mp_ptr result = new mp_ptr(new uint[] { 0x00000001 }); + /// mp_ptr rp = new mp_ptr(bp.Size); + /// + /// // Create scratch space. + /// mp_size_t size = gmp_lib.mpn_sec_powm_itch(bp.Size, 3, mp.Size); + /// mp_ptr tp = new mp_ptr(size); + /// + /// // Set rp = bp^ep mod mp. + /// gmp_lib.mpn_sec_powm(rp, bp, bp.Size, ep, 3, mp, mp.Size, tp); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(rp, bp, ep, mp, tp, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim bp As New mp_ptr(New UInteger() { &H2}) + /// Dim ep As New mp_ptr(New UInteger() { &H4}) + /// Dim mp As New mp_ptr(New UInteger() { &H3}) + /// Dim result As New mp_ptr(New UInteger() { &H1}) + /// Dim rp As New mp_ptr(bp.Size) + /// + /// ' Create scratch space. + /// Dim size As mp_size_t = gmp_lib.mpn_sec_powm_itch(bp.Size, 3, mp.Size) + /// Dim tp As New mp_ptr(size) + /// + /// ' Set rp = bp^ep mod mp. + /// gmp_lib.mpn_sec_powm(rp, bp, bp.Size, ep, 3, mp, mp.Size, tp) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(rp, bp, ep, mp, tp, result) + /// + /// + public static void mpn_sec_powm(mp_ptr rp, /*const*/ mp_ptr bp, mp_size_t bn, /*const*/ mp_ptr ep, mp_bitcnt_t enb, /*const*/ mp_ptr mp, mp_size_t n, mp_ptr tp) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (bp == null) throw new ArgumentNullException("bp"); + if (ep == null) throw new ArgumentNullException("ep"); + if (mp == null) throw new ArgumentNullException("mp"); + if (tp == null) throw new ArgumentNullException("tp"); + SafeNativeMethods.__gmpn_sec_powm(rp.ToIntPtr(), bp.ToIntPtr(), bn, ep.ToIntPtr(), enb, mp.ToIntPtr(), n, tp.ToIntPtr()); + } + + /// + /// Return the scratch space in number of limbs required by the function . + /// + /// The number of limbs of the first operand. + /// The number of limbs of the second operand. + /// The number of limbs of the third operand. + /// The scratch space in number of limbs required by the function . + /// + /// GNU MP - Low-level Functions + public static mp_size_t mpn_sec_powm_itch(mp_size_t bn, mp_bitcnt_t enb, mp_size_t n) + { + return SafeNativeMethods.__gmpn_sec_powm_itch(bn, enb, n); + } + + /// + /// Select entry from table , which has entries, each limbs. Store the selected entry at . + /// + /// The result integer. + /// The table of operand integers. + /// The number of limbs in each entry of the table. + /// The number of entries in the table. + /// The zero-based index of the entry to select. + /// + /// + /// This function reads the entire table to avoid side-channel information leaks. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr tab = new mp_ptr(new uint[] { 0x11111111, 0x22222222, 0x33333333, 0x44444444, 0x33333333, 0x00000000 }); + /// mp_ptr result = new mp_ptr(new uint[] { 0x33333333 }); + /// mp_ptr rp = new mp_ptr(result.Size); + /// + /// // Set rp to third entry in tab. + /// gmp_lib.mpn_sec_tabselect(rp, tab, 1, tab.Size, 2); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(tab, result); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim tab As New mp_ptr(New UInteger() { &H11111111, &H22222222, &H33333333, &H44444444, &H33333333, &H0}) + /// Dim result As New mp_ptr(New UInteger() { &H33333333}) + /// Dim rp As New mp_ptr(result.Size) + /// + /// ' Set rp to third entry in tab. + /// gmp_lib.mpn_sec_tabselect(rp, tab, 1, tab.Size, 2) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(rp.SequenceEqual(result)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(tab, result) + /// + /// + public static void mpn_sec_tabselect(/*volatile*/ mp_ptr /*mp_limb_t**/ rp, /*volatile const*/ mp_ptr /*mp_limb_t**/ tab, mp_size_t n, mp_size_t nents, mp_size_t which) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (tab == null) throw new ArgumentNullException("tab"); + SafeNativeMethods.__gmpn_sec_tabselect(rp.ToIntPtr(), tab.ToIntPtr(), n, nents, which); + } + + /// + /// Set Q to the truncated quotient N / D and R to N modulo D, where N = {, }, D = {, }, Q’s most significant limb is the function return value and the remaining limbs are {, - }, and R = {, }. + /// + /// The quotient result operand. + /// The first operand and remainder result integer. + /// The number of limbs of . + /// The second operand integer. + /// The number of limbs of . + /// The scratch operand integer. + /// Q’s most significant limb. + /// + /// + /// It is required that ≥ 1, and that [ - 1] ≠ 0. + /// This does not imply that N ≥ D since N might be zero-padded. + /// + /// + /// Note the overlapping between N and R. + /// No other operand overlapping is allowed. + /// The entire space occupied by N is overwritten. + /// + /// + /// This function requires scratch space of (, ) + /// limbs to be passed in the parameter. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr np = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + /// mp_ptr dp = new mp_ptr(new uint[] { 0x00000003 }); + /// mp_ptr remainder = new mp_ptr(new uint[] { 0x00000000 }); + /// mp_ptr qp = new mp_ptr(new uint[np.Size]); + /// + /// // Create scratch space. + /// mp_size_t size = gmp_lib.mpn_sec_div_qr_itch(np.Size, dp.Size); + /// mp_ptr tp = new mp_ptr(size); + /// + /// // Set qp = floor(np / dp) and rp = np mod dp. + /// mp_limb_t mslimb = gmp_lib.mpn_sec_div_qr(qp, np, np.Size, dp, dp.Size, tp); + /// + /// // Assert result of operation. + /// Assert.IsTrue(mslimb == (ulong)(gmp_lib.mp_bytes_per_limb == 4 ? 0x00005555 : 0x0000555555555555)); + /// Assert.IsTrue(qp[0] == (ulong)(gmp_lib.mp_bytes_per_limb == 4 ? 0x55555555 : 0x0000000000000000)); + /// Assert.IsTrue(np[0] == remainder[0]); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(qp, np, dp, remainder, tp); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim np As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff}) + /// Dim dp As New mp_ptr(New UInteger() { &H3}) + /// Dim remainder As New mp_ptr(New UInteger() { &H0}) + /// Dim qp As New mp_ptr(New UInteger(np.Size - 1) { }) + /// + /// ' Create scratch space. + /// Dim size As mp_size_t = gmp_lib.mpn_sec_div_qr_itch(np.Size, dp.Size) + /// Dim tp As New mp_ptr(size) + /// + /// ' Set qp = floor(np / dp) and rp = np mod dp. + /// Dim mslimb As mp_limb_t = gmp_lib.mpn_sec_div_qr(qp, np, np.Size, dp, dp.Size, tp) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(mslimb = CULng(If(gmp_lib.mp_bytes_per_limb = 4, &H5555, &H555555555555L))) + /// Assert.IsTrue(qp(0) = CULng(If(gmp_lib.mp_bytes_per_limb = 4, &H55555555, &H0))) + /// Assert.IsTrue(np(0) = remainder(0)) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(qp, np, dp, remainder, tp) + /// + /// + public static mp_limb_t mpn_sec_div_qr(mp_ptr qp, mp_ptr np, mp_size_t nn, /*const*/ mp_ptr dp, mp_size_t dn, mp_ptr tp) + { + if (qp == null) throw new ArgumentNullException("qp"); + if (np == null) throw new ArgumentNullException("np"); + if (dp == null) throw new ArgumentNullException("dp"); + if (tp == null) throw new ArgumentNullException("tp"); + if (IntPtr.Size == 4) + return new mp_limb_t(SafeNativeMethods.__gmpn_sec_div_qr_x86(qp.ToIntPtr(), np.ToIntPtr(), nn, dp.ToIntPtr(), dn, tp.ToIntPtr())); + else + return new mp_limb_t(SafeNativeMethods.__gmpn_sec_div_qr_x64(qp.ToIntPtr(), np.ToIntPtr(), nn, dp.ToIntPtr(), dn, tp.ToIntPtr())); + } + + /// + /// Return the scratch space in number of limbs required by the function . + /// + /// The number of limbs of the first operand. + /// The number of limbs of the second operand. + /// The scratch space in number of limbs required by the function . + /// + /// GNU MP - Low-level Functions + public static mp_size_t mpn_sec_div_qr_itch(mp_size_t nn, mp_size_t dn) + { + return new mp_size_t(SafeNativeMethods.__gmpn_sec_div_qr_itch(nn, dn)); + } + + /// + /// Set R to N modulo D, where N = {, }, D = {, }, and R = {, }. + /// + /// The first operand and result integer. + /// The number of limbs of . + /// The second operand integer + /// The number of limbs of . + /// The scratch operand integer. + /// + /// + /// It is required that ≥ 1, + /// and that [ - 1] ≠ 0. + /// This does not imply that N ≥ D since N might be zero-padded. + /// + /// + /// Note the overlapping between N and R. + /// No other operand overlapping is allowed. + /// The entire space occupied by N is overwritten. + /// + /// + /// This function requires scratch space of (, ) + /// limbs to be passed in the parameter. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr np = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff }); + /// mp_ptr dp = new mp_ptr(new uint[] { 0x00000004 }); + /// + /// // Create scratch space. + /// mp_size_t size = gmp_lib.mpn_sec_div_r_itch(np.Size, dp.Size); + /// mp_ptr tp = new mp_ptr(size); + /// + /// // Set np = np mod dp. + /// gmp_lib.mpn_sec_div_r(np, np.Size, dp, dp.Size, tp); + /// + /// // Assert result of operation. + /// Assert.IsTrue(np[0] == 3); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(np, dp, tp); + /// + /// + /// ' Create multi-precision operands, and expected result. + /// Dim np As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff}) + /// Dim dp As New mp_ptr(New UInteger() { &H4}) + /// + /// ' Create scratch space. + /// Dim size As mp_size_t = gmp_lib.mpn_sec_div_r_itch(np.Size, dp.Size) + /// Dim tp As New mp_ptr(size) + /// + /// ' Set np = np mod dp. + /// gmp_lib.mpn_sec_div_r(np, np.Size, dp, dp.Size, tp) + /// + /// ' Assert result of operation. + /// Assert.IsTrue(np(0) = 3) + /// + /// ' Release unmanaged memory. + /// gmp_lib.free(np, dp, tp) + /// + /// + public static void mpn_sec_div_r(mp_ptr np, mp_size_t nn, /*const*/ mp_ptr dp, mp_size_t dn, mp_ptr tp) + { + if (np == null) throw new ArgumentNullException("np"); + if (dp == null) throw new ArgumentNullException("dp"); + if (tp == null) throw new ArgumentNullException("tp"); + SafeNativeMethods.__gmpn_sec_div_r(np.ToIntPtr(), nn, dp.ToIntPtr(), dn, tp.ToIntPtr()); + } + + /// + /// Return the scratch space in number of limbs required by the function . + /// + /// The number of limbs of the first operand. + /// The number of limbs of the second operand. + /// The scratch space in number of limbs required by the function . + /// + /// GNU MP - Low-level Functions + public static mp_size_t mpn_sec_div_r_itch(mp_size_t nn, mp_size_t dn) + { + return new mp_size_t(SafeNativeMethods.__gmpn_sec_div_r_itch(nn, dn)); + } + + /// + /// Set R to the inverse of A modulo M, where R = {, }, A = {, }, and M = {, }. This function’s interface is preliminary. + /// + /// The result integer. + /// The first operand integer. + /// The second operand integer. + /// The number of limbs of and . + /// The third operand integer. + /// The scratch operand integer. + /// If an inverse exists, return 1, otherwise return 0 and leave R undefined. + /// + /// + /// If an inverse exists, return 1, otherwise return 0 and leave R undefined. + /// In either case, the input A is destroyed. + /// + /// + /// It is required that M is odd, and that ≥ ceil(log(A + 1)) + ceil(log(M + 1)). + /// A safe choice is = 2 * * , + /// but a smaller value might improve performance if M or A are known to have leading zero bits. + /// + /// + /// This function requires scratch space of () + /// limbs to be passed in the parameter. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// GNU MP - Low-level Functions + /// + /// + /// // Create multi-precision operands, and expected result. + /// mp_ptr ap = new mp_ptr(new uint[] { 3 }); + /// mp_ptr mp = new mp_ptr(new uint[] { 11 }); + /// mp_ptr rp = new mp_ptr(ap.Size); + /// mp_ptr result = new mp_ptr(new uint[] { 4 }); + /// + /// // Create scratch space. + /// mp_size_t size = gmp_lib.mpn_sec_invert_itch(ap.Size); + /// mp_ptr tp = new mp_ptr(size); + /// + /// // Set rp = ap^-1 mod mp. + /// gmp_lib.mpn_sec_invert(rp, ap, mp, ap.Size, (uint)(2 * ap.Size* gmp_lib.mp_bits_per_limb), tp); + /// + /// // Assert result of operation. + /// Assert.IsTrue(rp[0] == result[0]); + /// + /// // Release unmanaged memory. + /// gmp_lib.free(ap, mp, rp, result, tp); + /// + /// + /// + /// + public static int mpn_sec_invert(mp_ptr rp, mp_ptr ap, /*const*/ mp_ptr mp, mp_size_t n, mp_bitcnt_t nbcnt, mp_ptr tp) + { + if (rp == null) throw new ArgumentNullException("rp"); + if (ap == null) throw new ArgumentNullException("ap"); + if (mp == null) throw new ArgumentNullException("mp"); + if (tp == null) throw new ArgumentNullException("tp"); + return SafeNativeMethods.__gmpn_sec_invert(rp.ToIntPtr(), ap.ToIntPtr(), mp.ToIntPtr(), n, nbcnt, tp.ToIntPtr()); + } + + /// + /// Return the scratch space in number of limbs required by the function . + /// + /// The number of limbs of the first operand. + /// The scratch space in number of limbs required by the function . + /// + /// GNU MP - Low-level Functions + public static mp_size_t mpn_sec_invert_itch(mp_size_t n) + { + return new mp_size_t(SafeNativeMethods.__gmpn_sec_invert_itch(n)); + } + +#endregion + + [SuppressUnmanagedCodeSecurity] + private static class SafeNativeMethods + { + + #region "Win32 functions." + + [DllImport("kernel32", CharSet = CharSet.Unicode)] + public static extern IntPtr LoadLibrary(string lpFileName); + + [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)] + public static extern IntPtr GetProcAddress(IntPtr hModule, string procName); + + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool FreeLibrary(IntPtr hModule); + + [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SetDllDirectory(string directory); + + [DllImport("kernel32.dll")] + public static extern void RtlZeroMemory(IntPtr dst, int length); + +#endregion + + #region "Memory allocation functions." + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmp_get_memory_functions(ref IntPtr /*void*(**) (size_t)*/ alloc_func_ptr, ref IntPtr /*void*(**) (void*, size_t, size_t)*/ realloc_func_ptr, ref IntPtr /*void (**) (void*, size_t)*/ free_func_ptr); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmp_set_memory_functions(IntPtr /*void*(*) (size_t)*/ alloc_func_ptr, IntPtr /*void*(*) (void*, size_t, size_t)*/ realloc_func_ptr, IntPtr /*void (*) (void*, size_t)*/ free_func_ptr); + +#endregion + + #region "Random number routines." + + ///* obsolete */ + //[DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + //public static extern void __gmp_randinit(IntPtr /*gmp_randstate_t*/, gmp_randalg_t, ...); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmp_randinit_default(IntPtr /*gmp_randstate_t*/ state); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmp_randinit_lc_2exp(IntPtr /*gmp_randstate_t*/ state, /*const*/ IntPtr /*mpz_t*/ a, uint /*unsigned long int*/ c, uint /*mp_bitcnt_t*/ m2exp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmp_randinit_lc_2exp_size(IntPtr /*gmp_randstate_t*/ state, uint /*mp_bitcnt_t*/ size); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmp_randinit_mt(IntPtr /*gmp_randstate_t*/ state); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmp_randinit_set(IntPtr /*gmp_randstate_t*/ state, /*const*/ IntPtr /*gmp_randstate_t*/ /*__gmp_randstate_struct **/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmp_randseed(IntPtr /*gmp_randstate_t*/ state, /*const*/ IntPtr /*mpz_t*/ seed); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmp_randseed_ui(IntPtr /*gmp_randstate_t*/ state, uint /*unsigned long int*/ seed); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmp_randclear(IntPtr /*gmp_randstate_t*/ state); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmp_urandomb_ui(IntPtr /*gmp_randstate_t*/ state, uint /*unsigned long int*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmp_urandomm_ui(IntPtr /*gmp_randstate_t*/ state, uint /*unsigned long int*/ n); + +#endregion + + #region "Formatted output routines." + + //#define gmp_asprintf __gmp_asprintf + //__GMP_DECLSPEC int gmp_asprintf (char **, const char *, ...); + + //#define gmp_fprintf __gmp_fprintf + //# ifdef _GMP_H_HAVE_FILE + //__GMP_DECLSPEC int gmp_fprintf (FILE *, const char *, ...); + //#endif + + //#define gmp_obstack_printf __gmp_obstack_printf + //#if defined (_GMP_H_HAVE_OBSTACK) + //__GMP_DECLSPEC int gmp_obstack_printf (struct obstack *, const char *, ...); + //#endif + + //#define gmp_obstack_vprintf __gmp_obstack_vprintf + //#if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST) + //__GMP_DECLSPEC int gmp_obstack_vprintf (struct obstack *, const char *, va_list); + //#endif + + //#define gmp_printf __gmp_printf + // __GMP_DECLSPEC int gmp_printf(const char*, ...); + + //#define gmp_snprintf __gmp_snprintf + // __GMP_DECLSPEC int gmp_snprintf(char*, size_t, const char*, ...); + + //#define gmp_sprintf __gmp_sprintf + // __GMP_DECLSPEC int gmp_sprintf(char*, const char*, ...); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmp_vasprintf(ref IntPtr /*char ***/ pp, /*const*/ IntPtr /*char **/ fmt, IntPtr /*va_list*/ args); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmp_vfprintf(IntPtr /*FILE **/ pp, /*const*/ IntPtr /*char **/ fmt, IntPtr /*va_list*/ args); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmp_vprintf(/*const*/ IntPtr /*char **/ fmt, IntPtr /*va_list*/ args); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmp_vsnprintf")] + public static extern int __gmp_vsnprintf_x86(IntPtr /*char **/ buf, uint /*size_t*/ size, /*const*/ IntPtr /*char **/ fmt, IntPtr /*va_list*/ args); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmp_vsnprintf")] + public static extern int __gmp_vsnprintf_x64(IntPtr /*char **/ buf, ulong /*size_t*/ size, /*const*/ IntPtr /*char **/ fmt, IntPtr /*va_list*/ args); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmp_vsprintf(IntPtr /*char **/ buf, /*const*/ IntPtr /*char **/ fmt, IntPtr /*va_list*/ args); + +#endregion + + #region "Formatted input routines." + + //#define gmp_fscanf __gmp_fscanf + //# ifdef _GMP_H_HAVE_FILE + // __GMP_DECLSPEC int gmp_fscanf(FILE*, const char*, ...); + //#endif + + //#define gmp_scanf __gmp_scanf + // __GMP_DECLSPEC int gmp_scanf(const char*, ...); + + //#define gmp_sscanf __gmp_sscanf + // __GMP_DECLSPEC int gmp_sscanf(const char*, const char*, ...); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmp_vfscanf(IntPtr /*FILE **/ fp, /*const*/ IntPtr /*char **/ fmt, IntPtr /*va_list*/ ap); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmp_vscanf(/*const*/ IntPtr /*char **/ fmt, IntPtr /*va_list*/ ap); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmp_vsscanf(/*const*/ IntPtr /*char **/ s, /*const*/ IntPtr /*char **/ fmt, IntPtr /*va_list*/ ap); + +#endregion + + #region "Integer (i.e. Z) routines." + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void_ptr /*void **/ __gmpz_realloc(IntPtr /*mpz_t*/ integer, int /*mp_size_t*/ new_alloc); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_abs(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_add(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_add_ui(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_addmul(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_addmul_ui(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_and(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + //[DllImport(@"libgmp-10.dll")] /* OBSOLETE */ + //public static extern void __gmpz_array_init(IntPtr /*mpz_t*/ integer_array, int /*mp_size_t*/ array_size, int /*mp_size_t*/ fixed_num_bits); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_bin_ui(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ k); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_bin_uiui(IntPtr /*mpz_t*/ rop, uint /*unsigned long int*/ n, uint /*unsigned long int*/ k); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_cdiv_q(IntPtr /*mpz_t*/ q, /*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_cdiv_q_2exp(IntPtr /*mpz_t*/ q, /*const*/ IntPtr /*mpz_t*/ n, uint /*mp_bitcnt_t*/ b); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_cdiv_q_ui(IntPtr /*mpz_t*/ q, /*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_cdiv_qr(IntPtr /*mpz_t*/ q, IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_cdiv_qr_ui(IntPtr /*mpz_t*/ q, IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_cdiv_r(IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_cdiv_r_2exp(IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, uint /*mp_bitcnt_t*/ b); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_cdiv_r_ui(IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_cdiv_ui(/*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_clear(IntPtr /*mpz_t*/ x); + + //[DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + //public static extern void __gmpz_clears(mpz_t[] x); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_clrbit(IntPtr /*mpz_t*/ rop, uint /*mp_bitcnt_t*/ bit_index); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_cmp(/*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_cmp_d(/*const*/ IntPtr /*mpz_t*/ op1, double op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_cmp_si(/*const*/ IntPtr /*mpz_t*/ op1, int /*long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_cmp_ui(/*const*/ IntPtr /*mpz_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_cmpabs(/*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_cmpabs_d(/*const*/ IntPtr /*mpz_t*/ op1, double op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_cmpabs_ui(/*const*/ IntPtr /*mpz_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_com(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_combit(IntPtr /*mpz_t*/ rop, uint /*mp_bitcnt_t*/ bit_index); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_congruent_p(/*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ c, /*const*/ IntPtr /*mpz_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_congruent_2exp_p(/*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ c, uint /*mp_bitcnt_t*/ b); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_congruent_ui_p(/*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ c, uint /*unsigned long int*/ b); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_divexact(IntPtr /*mpz_t*/ q, /*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_divexact_ui(IntPtr /*mpz_t*/ q, /*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_divisible_p(/*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_divisible_ui_p(/*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_divisible_2exp_p(/*const*/ IntPtr /*mpz_t*/ n, uint /*mp_bitcnt_t*/ b); + + //[DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + //public static extern void __gmpz_dump(/*const*/ IntPtr /*mpz_t*/ x); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_export")] + public static extern IntPtr /*void **/ __gmpz_export_x86(IntPtr /*void **/ rop, ref uint /*size_t **/ countp, int order, uint /*size_t*/ size, int endian, uint /*size_t*/ nails, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_export")] + public static extern IntPtr /*void **/ __gmpz_export_x64(IntPtr /*void **/ rop, ref ulong /*size_t **/ countp, int order, ulong /*size_t **/ size, int endian, ulong /*size_t **/ nails, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_fac_ui(IntPtr /*mpz_t*/ rop, uint /*unsigned long int*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_2fac_ui(IntPtr /*mpz_t*/ rop, uint /*unsigned long int*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_mfac_uiui(IntPtr /*mpz_t*/ rop, uint /*unsigned long int*/ n, uint /*unsigned long int*/ m); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_primorial_ui(IntPtr /*mpz_t*/ rop, uint /*unsigned long int*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_fdiv_q(IntPtr /*mpz_t*/ q, /*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_fdiv_q_2exp(IntPtr /*mpz_t*/ q, /*const*/ IntPtr /*mpz_t*/ n, uint /*mp_bitcnt_t*/ b); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_fdiv_q_ui(IntPtr /*mpz_t*/ q, /*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_fdiv_qr(IntPtr /*mpz_t*/ q, IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_fdiv_qr_ui(IntPtr /*mpz_t*/ q, IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_fdiv_r(IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_fdiv_r_2exp(IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, uint /*mp_bitcnt_t*/ b); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_fdiv_r_ui(IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_fdiv_ui(/*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_fib_ui(IntPtr /*mpz_t*/ fn, uint /*unsigned long int*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_fib2_ui(IntPtr /*mpz_t*/ fn, IntPtr /*mpz_t*/ fnsub1, uint /*unsigned long int*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_fits_sint_p(/*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_fits_slong_p(/*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_fits_sshort_p(/*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_fits_uint_p(/*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_fits_ulong_p(/*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_fits_ushort_p(/*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_gcd(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_gcd_ui(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_gcdext(IntPtr /*mpz_t*/ g, IntPtr /*mpz_t*/ s, IntPtr /*mpz_t*/ t, /*const*/ IntPtr /*mpz_t*/ a, /*const*/ IntPtr /*mpz_t*/ b); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern double __gmpz_get_d(/*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern double __gmpz_get_d_2exp(ref int /*long int*/ exp, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*long int*/ __gmpz_get_si(/*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr /*char **/ __gmpz_get_str(IntPtr /*char **/ str, int @base, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_get_ui(/*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_getlimbn")] + public static extern uint /*mp_limb_t*/ __gmpz_getlimbn_x86(/*const*/ IntPtr /*mpz_t*/ op, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_getlimbn")] + public static extern ulong /*mp_limb_t*/ __gmpz_getlimbn_x64(/*const*/ IntPtr /*mpz_t*/ op, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*mp_bitcnt_t*/ __gmpz_hamdist(/*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_import")] + public static extern void __gmpz_import_x86(IntPtr /*mpz_t*/ rop, uint /*size_t*/ count, int order, uint /*size_t*/ size, int endian, uint /*size_t*/ nails, IntPtr /*void **/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_import")] + public static extern void __gmpz_import_x64(IntPtr /*mpz_t*/ rop, ulong /*size_t*/ count, int order, ulong /*size_t*/ size, int endian, ulong /*size_t*/ nails, IntPtr /*void **/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_init(IntPtr /*mpz_t*/ x); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_init2(IntPtr /*mpz_t*/ x, uint /*mp_bitcnt_t*/ n); + + //[DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + //public static extern void __gmpz_inits(IntPtr /*mpz_t*/ x, ...); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_init_set(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_init_set_d(IntPtr /*mpz_t*/ rop, double op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_init_set_si(IntPtr /*mpz_t*/ rop, int /*long int*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_init_set_str(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr str, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_init_set_ui(IntPtr /*mpz_t*/ rop, uint /*unsigned long int*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_inp_raw")] + public static extern uint /*size_t*/ __gmpz_inp_raw_x86(IntPtr /*mpz_t*/ rop, IntPtr /*FILE **/ stream); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_inp_raw")] + public static extern ulong /*size_t*/ __gmpz_inp_raw_x64(IntPtr /*mpz_t*/ rop, IntPtr /*FILE **/ stream); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_inp_str")] + public static extern uint /*size_t*/ __gmpz_inp_str_x86(IntPtr /*mpz_t*/ rop, IntPtr /*FILE **/ stream, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_inp_str")] + public static extern ulong /*size_t*/ __gmpz_inp_str_x64(IntPtr /*mpz_t*/ rop, IntPtr /*FILE **/ stream, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_invert(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_ior(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_jacobi(/*const*/ IntPtr /*mpz_t*/ a, /*const*/ IntPtr /*mpz_t*/ b); + + //#define mpz_kronecker mpz_jacobi /* alias */ + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_kronecker_si(/*const*/ IntPtr /*mpz_t*/ a, int /*long int*/ b); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_kronecker_ui(/*const*/ IntPtr /*mpz_t*/ a, uint /*unsigned long int*/ b); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_si_kronecker(int /*long int*/ a, /*const*/ IntPtr /*mpz_t*/ b); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_ui_kronecker(uint /*unsigned long int*/ a, /*const*/ IntPtr /*mpz_t*/ b); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_lcm(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_lcm_ui(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_legendre(/*const*/ IntPtr /*mpz_t*/ a, /*const*/ IntPtr /*mpz_t*/ p); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_lucnum_ui(IntPtr /*mpz_t*/ ln, uint /*unsigned long int*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_lucnum2_ui(IntPtr /*mpz_t*/ ln, IntPtr /*mpz_t*/ lnsub1, uint /*unsigned long int*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_millerrabin(/*const*/ IntPtr /*mpz_t*/ n, int reps); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_mod(IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ d); + + //#define mpz_mod_ui mpz_fdiv_r_ui /* same as fdiv_r because divisor unsigned */ + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_mul(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_mul_2exp(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, uint /*mp_bitcnt_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_mul_si(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, int /*long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_mul_ui(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_neg(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_nextprime(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_out_raw")] + public static extern uint /*size_t*/ __gmpz_out_raw_x86(IntPtr /*FILE **/stream, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_out_raw")] + public static extern ulong /*size_t*/ __gmpz_out_raw_x64(IntPtr /*FILE **/stream, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_out_str")] + public static extern uint /*size_t*/ __gmpz_out_str_x86(IntPtr /*FILE **/stream, int @base, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_out_str")] + public static extern ulong /*size_t*/ __gmpz_out_str_x64(IntPtr /*FILE **/stream, int @base, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_perfect_power_p(/*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_perfect_square_p(/*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*mp_bitcnt_t*/ __gmpz_popcount(/*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_pow_ui(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ @base, uint /*unsigned long int*/ exp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_powm(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ @base, /*const*/ IntPtr /*mpz_t*/ exp, /*const*/ IntPtr /*mpz_t*/ mod); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_powm_sec(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ @base, /*const*/ IntPtr /*mpz_t*/ exp, /*const*/ IntPtr /*mpz_t*/ mod); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_powm_ui(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ @base, uint /*unsigned long int*/ exp, /*const*/ IntPtr /*mpz_t*/ mod); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_probab_prime_p(/*const*/ IntPtr /*mpz_t*/ n, int reps); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] // OBSOLETE + public static extern void __gmpz_random(IntPtr /*mpz_t*/ rop, int /*mp_size_t*/ max_size); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] // OBSOLETE + public static extern void __gmpz_random2(IntPtr /*mpz_t*/ rop, int /*mp_size_t*/ max_size); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_realloc2(IntPtr /*mpz_t*/ x, uint /*mp_bitcnt_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*mp_bitcnt_t*/ __gmpz_remove(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op, /*const*/ IntPtr /*mpz_t*/ f); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_root(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op, uint /*unsigned long int*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_rootrem(IntPtr /*mpz_t*/ root, IntPtr /*mpz_t*/ rem, /*const*/ IntPtr /*mpz_t*/ u, uint /*unsigned long int*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_rrandomb(IntPtr /*mpz_t*/ rop, IntPtr /*gmp_randstate_t*/ state, uint /*mp_bitcnt_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*mp_bitcnt_t*/ __gmpz_scan0(/*const*/ IntPtr /*mpz_t*/ op, uint /*mp_bitcnt_t*/ starting_bit); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*mp_bitcnt_t*/ __gmpz_scan1(/*const*/ IntPtr /*mpz_t*/ op, uint /*mp_bitcnt_t*/ starting_bit); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_set(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_set_d(IntPtr /*mpz_t*/ rop, double op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_set_f(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_set_q(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpq_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_set_si(IntPtr /*mpz_t*/ rop, int /*long int*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_set_str(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*char **/ str, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_set_ui(IntPtr /*mpz_t*/ rop, uint /*unsigned long int*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_setbit(IntPtr /*mpz_t*/ rop, uint /*mp_bitcnt_t*/ bit_index); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*mp_size_t*/ __gmpz_size(/*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_sizeinbase")] + public static extern uint /*size_t*/ __gmpz_sizeinbase_x86(/*const*/ IntPtr /*mpz_t*/ op, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpz_sizeinbase")] + public static extern ulong /*size_t*/ __gmpz_sizeinbase_x64(/*const*/ IntPtr /*mpz_t*/ op, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_sqrt(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_sqrtrem(IntPtr /*mpz_t*/ rop1, IntPtr /*mpz_t*/ rop2, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_sub(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_sub_ui(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_ui_sub(IntPtr /*mpz_t*/ rop, uint /*unsigned long int*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_submul(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_submul_ui(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_swap(IntPtr /*mpz_t*/ rop1, IntPtr /*mpz_t*/ rop2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_tdiv_ui(/*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_tdiv_q(IntPtr /*mpz_t*/ q, /*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_tdiv_q_2exp(IntPtr /*mpz_t*/ q, /*const*/ IntPtr /*mpz_t*/ n, uint /*mp_bitcnt_t*/ b); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_tdiv_q_ui(IntPtr /*mpz_t*/ q, /*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_tdiv_qr(IntPtr /*mpz_t*/ q, IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_tdiv_qr_ui(IntPtr /*mpz_t*/ q, IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_tdiv_r(IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, /*const*/ IntPtr /*mpz_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_tdiv_r_2exp(IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, uint /*mp_bitcnt_t*/ b); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpz_tdiv_r_ui(IntPtr /*mpz_t*/ r, /*const*/ IntPtr /*mpz_t*/ n, uint /*unsigned long int*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpz_tstbit(/*const*/ IntPtr /*mpz_t*/ op, uint /*mp_bitcnt_t*/ bit_index); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_ui_pow_ui(IntPtr /*mpz_t*/ rop, uint /*unsigned long int*/ @base, uint /*unsigned long int*/ exp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_urandomb(IntPtr /*mpz_t*/ rop, IntPtr /*gmp_randstate_t*/ state, uint /*mp_bitcnt_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_urandomm(IntPtr /*mpz_t*/ rop, IntPtr /*gmp_randstate_t*/ state, /*const*/ IntPtr /*mpz_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_xor(IntPtr /*mpz_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr /*mp_limb_t**/ __gmpz_limbs_read(/*const*/ IntPtr /*mpz_t*/ x); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr /*mp_limb_t**/ __gmpz_limbs_write(/*const*/ IntPtr /*mpz_t*/ x, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr /*mp_limb_t**/ __gmpz_limbs_modify(/*const*/ IntPtr /*mpz_t*/ x, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpz_limbs_finish(/*const*/ IntPtr /*mpz_t*/ x, int /*mp_size_t*/ s); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern /*const*/ IntPtr /*mpz_t*/ __gmpz_roinit_n(IntPtr /*mpz_t*/ x, /*const*/ IntPtr /*mp_limb_t*/ xp, int /*mp_size_t*/ xs); + +#endregion + + #region "Rational (i.e. Q) routines." + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_abs(IntPtr /*mpq_t*/ rop, /*const*/ IntPtr /*mpq_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_add(IntPtr /*mpq_t*/ sum, /*const*/ IntPtr /*mpq_t*/ addend1, /*const*/ IntPtr /*mpq_t*/ addend2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_canonicalize(IntPtr /*mpq_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_clear(IntPtr /*mpq_t*/ x); + + //[DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + //public static extern void __gmpq_clears(IntPtr /*mpq_t*/, ...); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpq_cmp(/*const*/ IntPtr /*mpq_t*/ op1, /*const*/ IntPtr /*mpq_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpq_cmp_si(/*const*/ IntPtr /*mpq_t*/ op1, int /*long int*/ num2, uint /*unsigned long int*/ den2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpq_cmp_ui(/*const*/ IntPtr /*mpq_t*/ op1, uint /*unsigned long int*/ num2, uint /*unsigned long int*/ den2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpq_cmp_z(/*const*/ IntPtr /*mpq_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_div(IntPtr /*mpq_t*/ quotient, /*const*/ IntPtr /*mpq_t*/ dividend, /*const*/ IntPtr /*mpq_t*/ divisor); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_div_2exp(IntPtr /*mpq_t*/ rop, /*const*/ IntPtr /*mpq_t*/ op1, uint /*mp_bitcnt_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpq_equal(/*const*/ IntPtr /*mpq_t*/ op1, /*const*/ IntPtr /*mpq_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_get_num(IntPtr /*mpz_t*/ numerator, /*const*/ IntPtr /*mpq_t*/ rational); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_get_den(IntPtr /*mpz_t*/ denominator, /*const*/ IntPtr /*mpq_t*/ rational); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern double __gmpq_get_d(/*const*/ IntPtr /*mpq_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr /*char **/ __gmpq_get_str(IntPtr /*char **/ str, int @base, /*const*/ IntPtr /*mpq_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_init(IntPtr /*mpq_t*/ x); + + //[DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + //public static extern void __gmpq_inits(IntPtr /*mpq_t*/, ...); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpq_inp_str")] + public static extern uint /*size_t*/ __gmpq_inp_str_x86(IntPtr /*mpq_t*/ rop, IntPtr /*FILE **/ stream, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpq_inp_str")] + public static extern ulong /*size_t*/ __gmpq_inp_str_x64(IntPtr /*mpq_t*/ rop, IntPtr /*FILE **/ stream, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_inv(IntPtr /*mpq_t*/ inverted_number, /*const*/ IntPtr /*mpq_t*/ number); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_mul(IntPtr /*mpq_t*/ product, /*const*/ IntPtr /*mpq_t*/ multiplier, /*const*/ IntPtr /*mpq_t*/ multiplicand); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_mul_2exp(IntPtr /*mpq_t*/ rop, /*const*/ IntPtr /*mpq_t*/ op1, uint /*mp_bitcnt_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_neg(IntPtr /*mpq_t*/ negated_operand, /*const*/ IntPtr /*mpq_t*/ operand); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpq_out_str")] + public static extern uint /*size_t*/ __gmpq_out_str_x86(IntPtr /*FILE **/ stream, int @base, /*const*/ IntPtr /*mpq_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpq_out_str")] + public static extern ulong /*size_t*/ __gmpq_out_str_x64(IntPtr /*FILE **/ stream, int @base, /*const*/ IntPtr /*mpq_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_set(IntPtr /*mpq_t*/ rop, /*const*/ IntPtr /*mpq_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_set_d(IntPtr /*mpq_t*/ rop, double op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_set_den(IntPtr /*mpq_t*/ rational, /*const*/ IntPtr /*mpz_t*/ denominator); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_set_f(IntPtr /*mpq_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_set_num(IntPtr /*mpq_t*/ rational, /*const*/ IntPtr /*mpz_t*/ numerator); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_set_si(IntPtr /*mpq_t*/ rop, int /*long int*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpq_set_str(IntPtr /*mpq_t*/ rop, /*const*/ IntPtr /*char **/ str, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_set_ui(IntPtr /*mpq_t*/ rop, uint /*unsigned long int*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_set_z(IntPtr /*mpq_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_sub(IntPtr /*mpq_t*/ difference, /*const*/ IntPtr /*mpq_t*/ minuend, /*const*/ IntPtr /*mpq_t*/ subtrahend); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpq_swap(IntPtr /*mpq_t*/ rop1, IntPtr /*mpq_t*/ rop2); + +#endregion + + #region "Float (i.e. F) routines." + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_abs(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_add(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op1, /*const*/ IntPtr /*mpf_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_add_ui(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_ceil(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_clear(IntPtr /*mpf_t*/ x); + + //[DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + //public static extern void __gmpf_clears(IntPtr /*mpf_t*/, ...); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_cmp(/*const*/ IntPtr /*mpf_t*/ op1, /*const*/ IntPtr /*mpf_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_cmp_z(/*const*/ IntPtr /*mpf_t*/ op1, /*const*/ IntPtr /*mpz_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_cmp_d(/*const*/ IntPtr /*mpf_t*/ op1, double op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_cmp_si(/*const*/ IntPtr /*mpf_t*/ op1, int /*long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_cmp_ui(/*const*/ IntPtr /*mpf_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_div(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op1, /*const*/ IntPtr /*mpf_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_div_2exp(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op1, uint /*mp_bitcnt_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_div_ui(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op1, uint /*unsigned long int*/ op2); + + //[DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + //public static extern void __gmpf_dump(/*const*/ IntPtr /*mpf_t*/ op); + + //[DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + //public static extern int __gmpf_eq(/*const*/ IntPtr /*mpf_t*/ op1, /*const*/ IntPtr /*mpf_t*/ op2, uint /*mp_bitcnt_t*/ op3); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_fits_sint_p(/*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_fits_slong_p(/*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_fits_sshort_p(/*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_fits_uint_p(/*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_fits_ulong_p(/*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_fits_ushort_p(/*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_floor(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern double __gmpf_get_d(/*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern double __gmpf_get_d_2exp(ref int /*long int **/ exp, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*mp_bitcnt_t*/ __gmpf_get_default_prec(/*void*/); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*mp_bitcnt_t*/ __gmpf_get_prec(/*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*long int*/ __gmpf_get_si(/*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpf_get_str")] + public static extern IntPtr /*char **/ __gmpf_get_str_x86(IntPtr /*char **/ str, ref int /*mp_exp_t **/ expptr, int @base, uint /*size_t*/ n_digits, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpf_get_str")] + public static extern IntPtr /*char **/ __gmpf_get_str_x64(IntPtr /*char **/ str, ref int /*mp_exp_t **/ expptr, int @base, ulong /*size_t*/ n_digits, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*unsigned long int*/ __gmpf_get_ui(/*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_init(IntPtr /*mpf_t*/ x); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_init2(IntPtr /*mpf_t*/ x, uint /*mp_bitcnt_t*/ prec); + + //[DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + //public static extern void __gmpf_inits(IntPtr /*mpf_t*/, ...); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_init_set(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_init_set_d(IntPtr /*mpf_t*/ rop, double op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_init_set_si(IntPtr /*mpf_t*/ rop, int /*long int*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_init_set_str(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*char **/ str, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_init_set_ui(IntPtr /*mpf_t*/ rop, uint /*unsigned long int*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpf_inp_str")] + public static extern uint /*size_t*/ __gmpf_inp_str_x86(IntPtr /*mpf_t*/ rop, IntPtr /*FILE **/ stream, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpf_inp_str")] + public static extern ulong /*size_t*/ __gmpf_inp_str_x64(IntPtr /*mpf_t*/ rop, IntPtr /*FILE **/ stream, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_integer_p(/*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_mul(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op1, /*const*/ IntPtr /*mpf_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_mul_2exp(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op1, uint /*mp_bitcnt_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_mul_ui(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_neg(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpf_out_str")] + public static extern uint /*size_t*/ __gmpf_out_str_x86(IntPtr /*FILE **/ stream, int @base, uint /*size_t*/ n_digits, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpf_out_str")] + public static extern ulong /*size_t*/ __gmpf_out_str_x64(IntPtr /*FILE **/ stream, int @base, ulong /*size_t*/ n_digits, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_pow_ui(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_random2(IntPtr /*mpf_t*/ rop, int /*mp_size_t*/ max_size, int /*mp_exp_t*/ exp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_reldiff(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op1, /*const*/ IntPtr /*mpf_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_set(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_set_d(IntPtr /*mpf_t*/ rop, double op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_set_default_prec(uint /*mp_bitcnt_t*/ prec); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_set_prec(IntPtr /*mpf_t*/ rop, uint /*mp_bitcnt_t*/ prec); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_set_prec_raw(IntPtr /*mpf_t*/ rop, uint /*mp_bitcnt_t*/ prec); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_set_q(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpq_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_set_si(IntPtr /*mpf_t*/ rop, int /*long int*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpf_set_str(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*char **/ str, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_set_ui(IntPtr /*mpf_t*/ rop, uint /*unsigned long int*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_set_z(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpz_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpf_size")] + public static extern uint /*size_t*/ __gmpf_size_x86(/*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpf_size")] + public static extern ulong /*size_t*/ __gmpf_size_x64(/*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_sqrt(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_sqrt_ui(IntPtr /*mpf_t*/ rop, uint /*unsigned long int*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_sub(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op1, /*const*/ IntPtr /*mpf_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_sub_ui(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op1, uint /*unsigned long int*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_swap(IntPtr /*mpf_t*/ rop1, IntPtr /*mpf_t*/ rop2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_trunc(IntPtr /*mpf_t*/ rop, /*const*/ IntPtr /*mpf_t*/ op); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_ui_div(IntPtr /*mpf_t*/ rop, uint /*unsigned long int*/ op1, /*const*/ IntPtr /*mpf_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_ui_sub(IntPtr /*mpf_t*/ rop, uint /*unsigned long int*/ op1, /*const*/ IntPtr /*mpf_t*/ op2); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpf_urandomb(IntPtr /*mpf_t*/ rop, IntPtr /*gmp_randstate_t*/ state, uint /*mp_bitcnt_t*/ nbits); + +#endregion + + #region "Low level positive-integer (i.e. N) routines." + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_add")] + public static extern uint /*mp_limb_t*/ __gmpn_add_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ s1n, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ s2n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_add")] + public static extern ulong /*mp_limb_t*/ __gmpn_add_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ s1n, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ s2n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_add_1")] + public static extern uint /*mp_limb_t*/ __gmpn_add_1_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n, uint /*mp_limb_t*/ s2limb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_add_1")] + public static extern ulong /*mp_limb_t*/ __gmpn_add_1_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n, ulong /*mp_limb_t*/ s2limb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_add_n")] + public static extern uint /*mp_limb_t*/ __gmpn_add_n_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_add_n")] + public static extern ulong /*mp_limb_t*/ __gmpn_add_n_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_addmul_1")] + public static extern uint /*mp_limb_t*/ __gmpn_addmul_1_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n, uint /*mp_limb_t*/ s2limb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_addmul_1")] + public static extern ulong /*mp_limb_t*/ __gmpn_addmul_1_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n, ulong /*mp_limb_t*/ s2limb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpn_cmp(/*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpn_zero_p(/*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_divexact_1")] + public static extern void __gmpn_divexact_1_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n, uint /*mp_limb_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_divexact_1")] + public static extern void __gmpn_divexact_1_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n, ulong /*mp_limb_t*/ d); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_divexact_by3")] + public static extern uint /*mp_limb_t*/ __gmpn_divexact_by3_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_divexact_by3")] + public static extern ulong /*mp_limb_t*/ __gmpn_divexact_by3_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_divexact_by3c")] + public static extern uint /*mp_limb_t*/ __gmpn_divexact_by3c_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n, uint /*mp_limb_t*/ carry); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_divexact_by3c")] + public static extern ulong /*mp_limb_t*/ __gmpn_divexact_by3c_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n, ulong /*mp_limb_t*/ carry); + + //obsolete + //#define mpn_divrem __MPN(divrem) + //public static extern mp_limb_t __gmpn_divrem(IntPtr /*mp_ptr*/, int /*mp_size_t*/, IntPtr /*mp_ptr*/, int /*mp_size_t*/, /*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_divrem_1")] + public static extern uint /*mp_limb_t*/ __gmpn_divrem_1_x86(IntPtr /*mp_ptr*/ r1p, int /*mp_size_t*/ qxn, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ s2n, uint /*mp_limb_t*/ s3limb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_divrem_1")] + public static extern ulong /*mp_limb_t*/ __gmpn_divrem_1_x64(IntPtr /*mp_ptr*/ r1p, int /*mp_size_t*/ qxn, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ s2n, ulong /*mp_limb_t*/ s3limb); + + //obsolete + //#define mpn_divrem_2 __MPN(divrem_2) + //public static extern mp_limb_t __gmpn_divrem_2(IntPtr /*mp_ptr*/, int /*mp_size_t*/, IntPtr /*mp_ptr*/, int /*mp_size_t*/, /*const*/ IntPtr /*mp_ptr*/); + + //#define mpn_div_qr_1 __MPN(div_qr_1) + //public static extern mp_limb_t __gmpn_div_qr_1(IntPtr /*mp_ptr*/, mp_limb_t*, /*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/, mp_limb_t); + + //#define mpn_div_qr_2 __MPN(div_qr_2) + //public static extern mp_limb_t __gmpn_div_qr_2(IntPtr /*mp_ptr*/, IntPtr /*mp_ptr*/, /*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/, /*const*/ IntPtr /*mp_ptr*/); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*mp_size_t*/ __gmpn_gcd(IntPtr /*mp_ptr*/ rp, IntPtr /*mp_ptr*/ xp, int /*mp_size_t*/ xn, IntPtr /*mp_ptr*/ yp, int /*mp_size_t*/ yn); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_gcd_1")] + public static extern uint /*mp_limb_t*/ __gmpn_gcd_1_x86(/*const*/ IntPtr /*mp_ptr*/ xp, int /*mp_size_t*/ xn, uint /*mp_limb_t*/ ylimb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_gcd_1")] + public static extern ulong /*mp_limb_t*/ __gmpn_gcd_1_x64(/*const*/ IntPtr /*mp_ptr*/ xp, int /*mp_size_t*/ xn, ulong /*mp_limb_t*/ ylimb); + + //#define mpn_gcdext_1 __MPN(gcdext_1) + //public static extern mp_limb_t __gmpn_gcdext_1(mp_limb_signed_t*, mp_limb_signed_t*, mp_limb_t, mp_limb_t); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*mp_size_t*/ __gmpn_gcdext(IntPtr /*mp_ptr*/ gp, IntPtr /*mp_ptr*/ sp, ref int /*mp_size_t**/ sn, IntPtr /*mp_ptr*/ up, int /*mp_size_t*/ un, IntPtr /*mp_ptr*/ vp, int /*mp_size_t*/ vn); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_get_str")] + public static extern uint /*size_t*/ __gmpn_get_str_x86(IntPtr /*unsigned char **/ str, int @base, IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ s1n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_get_str")] + public static extern ulong /*size_t*/ __gmpn_get_str_x64(IntPtr /*unsigned char **/ str, int @base, IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ s1n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*mp_bitcnt_t*/ __gmpn_hamdist(/*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_lshift")] + public static extern uint /*mp_limb_t*/ __gmpn_lshift_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n, uint count); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_lshift")] + public static extern ulong /*mp_limb_t*/ __gmpn_lshift_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n, uint count); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_mod_1")] + public static extern uint /*mp_limb_t*/ __gmpn_mod_1_x86(/*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ s1n, uint /*mp_limb_t*/ s2limb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_mod_1")] + public static extern ulong /*mp_limb_t*/ __gmpn_mod_1_x64(/*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ s1n, ulong /*mp_limb_t*/ s2limb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_mul")] + public static extern uint /*mp_limb_t*/ __gmpn_mul_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ s1n, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ s2n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_mul")] + public static extern ulong /*mp_limb_t*/ __gmpn_mul_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ s1n, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ s2n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_mul_1")] + public static extern uint /*mp_limb_t*/ __gmpn_mul_1_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n, uint /*mp_limb_t*/ s2limb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_mul_1")] + public static extern ulong /*mp_limb_t*/ __gmpn_mul_1_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n, ulong /*mp_limb_t*/ s2limb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_mul_n(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_sqr(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_neg")] + public static extern uint /*mp_limb_t*/ __gmpn_neg_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_neg")] + public static extern ulong /*mp_limb_t*/ __gmpn_neg_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_com(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpn_perfect_square_p(/*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpn_perfect_power_p(/*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*mp_bitcnt_t*/ __gmpn_popcount(/*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n); + + //#define mpn_pow_1 __MPN(pow_1) + //public static extern int /*mp_size_t*/ __gmpn_pow_1(IntPtr /*mp_ptr*/, /*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/, mp_limb_t, IntPtr /*mp_ptr*/); + + ///* undocumented now, but retained here for upward compatibility */ + //#define mpn_preinv_mod_1 __MPN(preinv_mod_1) + //public static extern mp_limb_t __gmpn_preinv_mod_1(/*const*/ IntPtr /*mp_ptr*/, int /*mp_size_t*/, mp_limb_t, mp_limb_t); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_random(IntPtr /*mp_ptr*/ r1p, int /*mp_size_t*/ r1n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_random2(IntPtr /*mp_ptr*/ r1p, int /*mp_size_t*/ r1n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_rshift")] + public static extern uint /*mp_limb_t*/ __gmpn_rshift_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n, uint count); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_rshift")] + public static extern ulong /*mp_limb_t*/ __gmpn_rshift_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n, uint count); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*mp_bitcnt_t*/ __gmpn_scan0(/*const*/ IntPtr /*mp_ptr*/ s1p, uint /*mp_bitcnt_t*/ bit); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern uint /*mp_bitcnt_t*/ __gmpn_scan1(/*const*/ IntPtr /*mp_ptr*/ s1p, uint /*mp_bitcnt_t*/ bit); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_set_str")] + public static extern int /*mp_size_t*/ __gmpn_set_str_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*unsigned char **/ str, uint /*size_t*/ strsize, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_set_str")] + public static extern int /*mp_size_t*/ __gmpn_set_str_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*unsigned char **/ str, ulong /*size_t*/ strsize, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sizeinbase")] + public static extern uint /*size_t*/ __gmpn_sizeinbase_x86(/*const*/ IntPtr /*mp_ptr*/ xp, int /*mp_size_t*/ n, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sizeinbase")] + public static extern ulong /*size_t*/ __gmpn_sizeinbase_x64(/*const*/ IntPtr /*mp_ptr*/ xp, int /*mp_size_t*/ n, int @base); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*mp_size_t*/ __gmpn_sqrtrem(IntPtr /*mp_ptr*/ r1p, IntPtr /*mp_ptr*/ r2p, /*const*/ IntPtr /*mp_ptr*/ sp, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sub")] + public static extern uint /*mp_limb_t*/ __gmpn_sub_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ s1n, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ s2n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sub")] + public static extern ulong /*mp_limb_t*/ __gmpn_sub_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ s1n, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ s2n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sub_1")] + public static extern uint /*mp_limb_t*/ __gmpn_sub_1_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n, uint /*mp_limb_t*/ s2limb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sub_1")] + public static extern ulong /*mp_limb_t*/ __gmpn_sub_1_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n, ulong /*mp_limb_t*/ s2limb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sub_n")] + public static extern uint /*mp_limb_t*/ __gmpn_sub_n_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sub_n")] + public static extern ulong /*mp_limb_t*/ __gmpn_sub_n_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_submul_1")] + public static extern uint /*mp_limb_t*/ __gmpn_submul_1_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n, uint /*mp_limb_t*/ s2limb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_submul_1")] + public static extern ulong /*mp_limb_t*/ __gmpn_submul_1_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n, ulong /*mp_limb_t*/ s2limb); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_tdiv_qr(IntPtr /*mp_ptr*/ qp, IntPtr /*mp_ptr*/ rp, int /*mp_size_t*/ qxn, /*const*/ IntPtr /*mp_ptr*/ np, int /*mp_size_t*/ nn, /*const*/ IntPtr /*mp_ptr*/ dp, int /*mp_size_t*/ dn); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_and_n(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_andn_n(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_nand_n(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_ior_n(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_iorn_n(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_nior_n(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_xor_n(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_xnor_n(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_copyi(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_copyd(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_zero(IntPtr /*mp_ptr*/ rp, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_cnd_add_n")] + public static extern uint /*mp_limb_t*/ __gmpn_cnd_add_n_x86(uint /*mp_limb_t*/ cnd, IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_cnd_add_n")] + public static extern ulong /*mp_limb_t*/ __gmpn_cnd_add_n_x64(ulong /*mp_limb_t*/ cnd, IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_cnd_sub_n")] + public static extern uint /*mp_limb_t*/ __gmpn_cnd_sub_n_x86(uint /*mp_limb_t*/ cnd, IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_cnd_sub_n")] + public static extern ulong /*mp_limb_t*/ __gmpn_cnd_sub_n_x64(ulong /*mp_limb_t*/ cnd, IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ s1p, /*const*/ IntPtr /*mp_ptr*/ s2p, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sec_add_1")] + public static extern uint /*mp_limb_t*/ __gmpn_sec_add_1_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ ap, int /*mp_size_t*/ n, uint /*mp_limb_t*/ b, IntPtr /*mp_ptr*/ tp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sec_add_1")] + public static extern ulong /*mp_limb_t*/ __gmpn_sec_add_1_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ ap, int /*mp_size_t*/ n, ulong /*mp_limb_t*/ b, IntPtr /*mp_ptr*/ tp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*mp_size_t*/ __gmpn_sec_add_1_itch(int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sec_sub_1")] + public static extern uint /*mp_limb_t*/ __gmpn_sec_sub_1_x86(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ ap, int /*mp_size_t*/ n, uint /*mp_limb_t*/ b, IntPtr /*mp_ptr*/ tp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sec_sub_1")] + public static extern ulong /*mp_limb_t*/ __gmpn_sec_sub_1_x64(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ ap, int /*mp_size_t*/ n, ulong /*mp_limb_t*/ b, IntPtr /*mp_ptr*/ tp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*mp_size_t*/ __gmpn_sec_sub_1_itch(int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_cnd_swap")] + public static extern void __gmpn_cnd_swap_x86(uint /*mp_limb_t*/ cnd, /*volatile*/ IntPtr /*mp_limb_t**/ ap, /*volatile*/ IntPtr /*mp_limb_t**/ bp, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_cnd_swap")] + public static extern void __gmpn_cnd_swap_x64(ulong /*mp_limb_t*/ cnd, /*volatile*/ IntPtr /*mp_limb_t**/ ap, /*volatile*/ IntPtr /*mp_limb_t**/ bp, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_sec_mul(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ ap, int /*mp_size_t*/ an, /*const*/ IntPtr /*mp_ptr*/ b, int /*mp_size_t*/ bn, IntPtr /*mp_ptr*/ tp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*mp_size_t*/ __gmpn_sec_mul_itch(int /*mp_size_t*/ an, int /*mp_size_t*/ bn); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_sec_sqr(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ ap, int /*mp_size_t*/ an, IntPtr /*mp_ptr*/ tp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*mp_size_t*/ __gmpn_sec_sqr_itch(int /*mp_size_t*/ an); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_sec_powm(IntPtr /*mp_ptr*/ rp, /*const*/ IntPtr /*mp_ptr*/ bp, int /*mp_size_t*/ bn, /*const*/ IntPtr /*mp_ptr*/ ep, uint /*mp_bitcnt_t*/ enb, /*const*/ IntPtr /*mp_ptr*/ mp, int /*mp_size_t*/ n, IntPtr /*mp_ptr*/ tp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*mp_size_t*/ __gmpn_sec_powm_itch(int /*mp_size_t*/ bn, uint /*mp_bitcnt_t*/ enb, int /*mp_size_t*/ n); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_sec_tabselect(/*volatile*/ IntPtr /*mp_limb_t**/ rp, /*volatile const*/ IntPtr /*mp_limb_t**/ tab, int /*mp_size_t*/ n, int /*mp_size_t*/ nents, int /*mp_size_t*/ which); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sec_div_qr")] + public static extern uint /*mp_limb_t*/ __gmpn_sec_div_qr_x86(IntPtr /*mp_ptr*/ qp, IntPtr /*mp_ptr*/ np, int /*mp_size_t*/ nn, /*const*/ IntPtr /*mp_ptr*/ dp, int /*mp_size_t*/ dn, IntPtr /*mp_ptr*/ tp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "__gmpn_sec_div_qr")] + public static extern ulong /*mp_limb_t*/ __gmpn_sec_div_qr_x64(IntPtr /*mp_ptr*/ qp, IntPtr /*mp_ptr*/ np, int /*mp_size_t*/ nn, /*const*/ IntPtr /*mp_ptr*/ dp, int /*mp_size_t*/ dn, IntPtr /*mp_ptr*/ tp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*mp_size_t*/ __gmpn_sec_div_qr_itch(int /*mp_size_t*/ nn, int /*mp_size_t*/ dn); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void __gmpn_sec_div_r(IntPtr /*mp_ptr*/ np, int /*mp_size_t*/ nn, /*const*/ IntPtr /*mp_ptr*/ dp, int /*mp_size_t*/ dn, IntPtr /*mp_ptr*/ tp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*mp_size_t*/ __gmpn_sec_div_r_itch(int /*mp_size_t*/ nn, int /*mp_size_t*/ dn); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int __gmpn_sec_invert(IntPtr /*mp_ptr*/ rp, IntPtr /*mp_ptr*/ ap, /*const*/ IntPtr /*mp_ptr*/ mp, int /*mp_size_t*/ n, uint /*mp_bitcnt_t*/ nbcnt, IntPtr /*mp_ptr*/ tp); + + [DllImport(@"libgmp-10.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int /*mp_size_t*/ __gmpn_sec_invert_itch(int /*mp_size_t*/ n); + +#endregion + + } + + private class SafeHandle : SafeHandleZeroOrMinusOneIsInvalid + { + public SafeHandle(IntPtr handle) + : base(true) + { + SetHandle(handle); + } + + public IntPtr Handle + { + get + { + return handle; + } + } + + [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] + protected override bool ReleaseHandle() + { + gmp_lib.SafeNativeMethods.FreeLibrary(handle); + return true; + } + } + + } +} diff --git a/Math.Gmp.Native/gmp_randstate_t.cs b/Math.Gmp.Native/gmp_randstate_t.cs new file mode 100644 index 0000000..1948b5d --- /dev/null +++ b/Math.Gmp.Native/gmp_randstate_t.cs @@ -0,0 +1,39 @@ + +using System; +using System.Runtime.InteropServices; +using System.Diagnostics; + +namespace Math.Gmp.Native +{ + + /// + /// Represents the state of a random number generator. + /// + /// + public class gmp_randstate_t + { + + private IntPtr _pointer; + + /// + /// Creates a new random number generator state. + /// + /// + /// + /// When done with the random number generator state, unmanaged memory must be released with . + /// + /// + public gmp_randstate_t() + { + // Allocation sizes take into account the members alignment done by the C compiler. + _pointer = gmp_lib.allocate(IntPtr.Size == 4 ? 20U : 32U).ToIntPtr(); + } + + internal IntPtr ToIntPtr() + { + return _pointer; + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/mp_base.cs b/Math.Gmp.Native/mp_base.cs new file mode 100644 index 0000000..278ed4f --- /dev/null +++ b/Math.Gmp.Native/mp_base.cs @@ -0,0 +1,97 @@ + +using System; +using System.Diagnostics; + +namespace Math.Gmp.Native +{ + + /// + /// Provides common functionality to , , and . + /// + public class mp_base + { + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + internal IntPtr _pointer; + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + internal mp_size_t _size; + + /// + /// The number of limbs. + /// + /// + public virtual mp_size_t _mp_size + { + get + { + return _size; + } + } + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + internal virtual IntPtr _mp_d_intptr + { + get + { + return _pointer; + } + set + { + _pointer = value; + } + } + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private mp_ptr __mp_d = null; + + /// + /// A pointer to an array of limbs which is the magnitude. + /// + /// + /// + /// In : + /// + /// + /// A pointer to an array of limbs which is the magnitude. + /// These are stored “little endian” as per the mpn functions, so [0] + /// is the least significant limb and [ABS() - 1] + /// is the most significant. + /// Whenever is non-zero, the most significant limb is non-zero. + /// + /// + /// Currently there’s always at least one limb allocated, so for instance + /// never needs to reallocate, and can fetch [0] + /// unconditionally (though its value is then only wanted if is non-zero). + /// + /// + /// In : + /// + /// + /// A pointer to the array of limbs which is the absolute value of the mantissa. + /// These are stored "little endian" as per the mpn functions, so _mp_d[0] is the least + /// significant limb and _mp_d[ABS(_mp_size)-1] the most significant. + /// + /// + /// The most significant limb is always non-zero, but there are no other restrictions on its value, + /// in particular the highest 1 bit can be anywhere within the limb. + /// + /// + /// _mp_prec + 1 limbs are allocated to , the extra limb being for + /// convenience (see below). + /// There are no reallocations during a calculation, only in a change of precision with . + /// + /// + public virtual mp_ptr _mp_d + { + get + { + if (__mp_d == null) + __mp_d = new mp_ptr(this); + return __mp_d; + } + } + + } + +} diff --git a/Math.Gmp.Native/mp_bitcnt_t.cs b/Math.Gmp.Native/mp_bitcnt_t.cs new file mode 100644 index 0000000..eade308 --- /dev/null +++ b/Math.Gmp.Native/mp_bitcnt_t.cs @@ -0,0 +1,272 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Math.Gmp.Native +{ + + /// + /// Represents a count of bits. + /// + /// + /// + /// Counts of bits of a multi-precision number are represented in the C type . + /// Currently this is always an unsigned long, but on some systems it will be an unsigned long long in the future. + /// + /// + /// In .NET, this is an unsigned 32-bit integer. + /// + /// + /// + /// + /// + public struct mp_bitcnt_t + { + + internal uint _value; + + /// + /// Creates a new , and sets its . + /// + /// The value of the new . + public mp_bitcnt_t(uint value) + { + _value = value; + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_bitcnt_t(byte value) + { + return new mp_bitcnt_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static explicit operator mp_bitcnt_t(sbyte value) + { + if (value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_bitcnt_t data type.", value)); + return new mp_bitcnt_t((uint)value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_bitcnt_t(ushort value) + { + return new mp_bitcnt_t(value); + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator mp_bitcnt_t(short value) + { + if (value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_bitcnt_t data type.", value)); + return new mp_bitcnt_t((uint)value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_bitcnt_t(uint value) + { + return new mp_bitcnt_t(value); + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator mp_bitcnt_t(int value) + { + //if (value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_bitcnt_t data type.", value)); + return new mp_bitcnt_t(unchecked((uint)value)); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static explicit operator mp_bitcnt_t(ulong value) + { + if (value > uint.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_bitcnt_t data type.", value)); + return new mp_bitcnt_t((uint)value); + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// An value. + public static explicit operator mp_bitcnt_t(long value) + { + if (value < 0 || value > uint.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_bitcnt_t data type.", value)); + return new mp_bitcnt_t((uint)value); + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator byte(mp_bitcnt_t value) + { + if (value._value > byte.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Byte data type.", value)); + return (byte)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator sbyte(mp_bitcnt_t value) + { + if (value._value > sbyte.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the SByte data type.", value)); + return (sbyte)value._value; + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator ushort(mp_bitcnt_t value) + { + if (value._value > ushort.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt16 data type.", value)); + return (ushort)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator short(mp_bitcnt_t value) + { + if (value._value > short.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Int16 data type.", value)); + return (short)value._value; + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static implicit operator uint(mp_bitcnt_t value) + { + return value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator int(mp_bitcnt_t value) + { + //if (value._value > int.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Int32 data type.", value)); + return unchecked((int)value._value); + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static implicit operator ulong(mp_bitcnt_t value) + { + return value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static implicit operator long(mp_bitcnt_t value) + { + return value._value; + } + + /// + /// Gets the string representation of the . + /// + /// The string representation of the . + public override string ToString() + { + return _value.ToString(System.Globalization.CultureInfo.InvariantCulture); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified object. + /// + /// An object to compare with this instance. + /// True if is an instance of and equals the value of this instance; otherwise, False. + public override bool Equals(object obj) + { + if (!(obj is mp_bitcnt_t)) + return false; + + return Equals((mp_bitcnt_t)obj); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified value. + /// + /// A value to compare to this instance. + /// True if has the same value as this instance; otherwise, False. + public bool Equals(mp_bitcnt_t other) + { + return _value == other._value; + } + + /// + /// Returns the hash code for this instance. + /// + /// A 32-bit signed integer hash code. + public override int GetHashCode() + { + return _value.GetHashCode(); + } + + /// + /// Gets a value that indicates whether the two argument values are equal. + /// + /// A value. + /// A value. + /// True if the two values are equal, and False otherwise. + public static bool operator ==(mp_bitcnt_t value1, mp_bitcnt_t value2) + { + return value1.Equals(value2); + } + + /// + /// Gets a value that indicates whether the two argument values are different. + /// + /// A value. + /// A value. + /// True if the two values are different, and False otherwise. + public static bool operator !=(mp_bitcnt_t value1, mp_bitcnt_t value2) + { + return !value1.Equals(value2); + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/mp_exp_t (conflict).cs b/Math.Gmp.Native/mp_exp_t (conflict).cs new file mode 100644 index 0000000..2069c0e --- /dev/null +++ b/Math.Gmp.Native/mp_exp_t (conflict).cs @@ -0,0 +1,268 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Math.Gmp.Native +{ + + /// + /// Represents the exponent of a floating-point number. + /// + /// + /// + /// The floating point functions accept and return exponents in the C type . + /// Currently this is usually a long, but on some systems it’s an int for efficiency. + /// + /// + /// In .Net, this is a 32-bit integer. + /// + /// + public struct mp_exp_t + { + + internal int _value; + + /// + /// Creates a new , and sets its . + /// + /// The value of the new . + public mp_exp_t(int value) + { + _value = value; + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_exp_t(byte value) + { + return new mp_exp_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_exp_t(sbyte value) + { + return new mp_exp_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_exp_t(ushort value) + { + return new mp_exp_t(value); + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static implicit operator mp_exp_t(short value) + { + return new mp_exp_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static explicit operator mp_exp_t(uint value) + { + if (value > int.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_exp_t data type.", value)); + return new mp_exp_t((int)value); + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static implicit operator mp_exp_t(int value) + { + return new mp_exp_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static explicit operator mp_exp_t(ulong value) + { + if (value > int.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_exp_t data type.", value)); + return new mp_exp_t((int)value); + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// An value. + public static explicit operator mp_exp_t(long value) + { + if (value < uint.MinValue || value > uint.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_exp_t data type.", value)); + return new mp_exp_t((int)value); + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator byte(mp_exp_t value) + { + if (value._value > byte.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Byte data type.", value)); + return (byte)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator sbyte(mp_exp_t value) + { + if (value._value < sbyte.MinValue || value._value > sbyte.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the SByte data type.", value)); + return (sbyte)value._value; + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator ushort(mp_exp_t value) + { + if (value._value > ushort.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt16 data type.", value)); + return (ushort)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator short(mp_exp_t value) + { + if (value._value < short.MinValue || value._value > short.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Int16 data type.", value)); + return (short)value._value; + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator uint(mp_exp_t value) + { + if (value._value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt32 data type.", value)); + return (uint)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static implicit operator int(mp_exp_t value) + { + return value._value; + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator ulong(mp_exp_t value) + { + if (value._value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt64 data type.", value)); + return (ulong)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static implicit operator long(mp_exp_t value) + { + return value._value; + } + + /// + /// Gets the string representation of the . + /// + /// The string representation of the . + public override string ToString() + { + return _value.ToString(System.Globalization.CultureInfo.InvariantCulture); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified object. + /// + /// An object to compare with this instance. + /// True if is an instance of and equals the value of this instance; otherwise, False. + public override bool Equals(object obj) + { + if (!(obj is mp_exp_t)) + return false; + + return Equals((mp_exp_t)obj); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified value. + /// + /// A value to compare to this instance. + /// True if has the same value as this instance; otherwise, False. + public bool Equals(mp_exp_t other) + { + return _value == other._value; + } + + /// + /// Returns the hash code for this instance. + /// + /// A 32-bit signed integer hash code. + public override int GetHashCode() + { + return _value.GetHashCode(); + } + + /// + /// Gets a value that indicates whether the two argument values are equal. + /// + /// A value. + /// A value. + /// True if the two values are equal, and False otherwise. + public static bool operator ==(mp_exp_t value1, mp_exp_t value2) + { + return value1.Equals(value2); + } + + /// + /// Gets a value that indicates whether the two argument values are different. + /// + /// A value. + /// A value. + /// True if the two values are different, and False otherwise. + public static bool operator !=(mp_exp_t value1, mp_exp_t value2) + { + return !value1.Equals(value2); + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/mp_exp_t.cs b/Math.Gmp.Native/mp_exp_t.cs new file mode 100644 index 0000000..2069c0e --- /dev/null +++ b/Math.Gmp.Native/mp_exp_t.cs @@ -0,0 +1,268 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Math.Gmp.Native +{ + + /// + /// Represents the exponent of a floating-point number. + /// + /// + /// + /// The floating point functions accept and return exponents in the C type . + /// Currently this is usually a long, but on some systems it’s an int for efficiency. + /// + /// + /// In .Net, this is a 32-bit integer. + /// + /// + public struct mp_exp_t + { + + internal int _value; + + /// + /// Creates a new , and sets its . + /// + /// The value of the new . + public mp_exp_t(int value) + { + _value = value; + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_exp_t(byte value) + { + return new mp_exp_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_exp_t(sbyte value) + { + return new mp_exp_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_exp_t(ushort value) + { + return new mp_exp_t(value); + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static implicit operator mp_exp_t(short value) + { + return new mp_exp_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static explicit operator mp_exp_t(uint value) + { + if (value > int.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_exp_t data type.", value)); + return new mp_exp_t((int)value); + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static implicit operator mp_exp_t(int value) + { + return new mp_exp_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static explicit operator mp_exp_t(ulong value) + { + if (value > int.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_exp_t data type.", value)); + return new mp_exp_t((int)value); + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// An value. + public static explicit operator mp_exp_t(long value) + { + if (value < uint.MinValue || value > uint.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_exp_t data type.", value)); + return new mp_exp_t((int)value); + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator byte(mp_exp_t value) + { + if (value._value > byte.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Byte data type.", value)); + return (byte)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator sbyte(mp_exp_t value) + { + if (value._value < sbyte.MinValue || value._value > sbyte.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the SByte data type.", value)); + return (sbyte)value._value; + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator ushort(mp_exp_t value) + { + if (value._value > ushort.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt16 data type.", value)); + return (ushort)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator short(mp_exp_t value) + { + if (value._value < short.MinValue || value._value > short.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Int16 data type.", value)); + return (short)value._value; + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator uint(mp_exp_t value) + { + if (value._value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt32 data type.", value)); + return (uint)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static implicit operator int(mp_exp_t value) + { + return value._value; + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator ulong(mp_exp_t value) + { + if (value._value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt64 data type.", value)); + return (ulong)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static implicit operator long(mp_exp_t value) + { + return value._value; + } + + /// + /// Gets the string representation of the . + /// + /// The string representation of the . + public override string ToString() + { + return _value.ToString(System.Globalization.CultureInfo.InvariantCulture); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified object. + /// + /// An object to compare with this instance. + /// True if is an instance of and equals the value of this instance; otherwise, False. + public override bool Equals(object obj) + { + if (!(obj is mp_exp_t)) + return false; + + return Equals((mp_exp_t)obj); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified value. + /// + /// A value to compare to this instance. + /// True if has the same value as this instance; otherwise, False. + public bool Equals(mp_exp_t other) + { + return _value == other._value; + } + + /// + /// Returns the hash code for this instance. + /// + /// A 32-bit signed integer hash code. + public override int GetHashCode() + { + return _value.GetHashCode(); + } + + /// + /// Gets a value that indicates whether the two argument values are equal. + /// + /// A value. + /// A value. + /// True if the two values are equal, and False otherwise. + public static bool operator ==(mp_exp_t value1, mp_exp_t value2) + { + return value1.Equals(value2); + } + + /// + /// Gets a value that indicates whether the two argument values are different. + /// + /// A value. + /// A value. + /// True if the two values are different, and False otherwise. + public static bool operator !=(mp_exp_t value1, mp_exp_t value2) + { + return !value1.Equals(value2); + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/mp_limb_t.cs b/Math.Gmp.Native/mp_limb_t.cs new file mode 100644 index 0000000..2cc97e0 --- /dev/null +++ b/Math.Gmp.Native/mp_limb_t.cs @@ -0,0 +1,271 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Math.Gmp.Native +{ + + /// + /// Represents a part of a multiple precision number. + /// + /// + /// + /// A limb means the part of a multi-precision number that fits in a single machine word. + /// (We chose this word because a limb of the human body is analogous to a digit, only larger, + /// and containing several digits.) Normally a limb is 32 or 64 bits. + /// + /// + /// + /// + /// + public struct mp_limb_t + { + + internal ulong _value; + + /// + /// Creates a new , and sets its . + /// + /// The value of the new . + public mp_limb_t(ulong value) + { + _value = value; + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_limb_t(byte value) + { + return new mp_limb_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static explicit operator mp_limb_t(sbyte value) + { + if (value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_limb_t data type.", value)); + return new mp_limb_t((ulong)value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_limb_t(ushort value) + { + return new mp_limb_t(value); + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator mp_limb_t(short value) + { + if (value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_limb_t data type.", value)); + return new mp_limb_t((ulong)value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_limb_t(uint value) + { + return new mp_limb_t(value); + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator mp_limb_t(int value) + { + //if (value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_limb_t data type.", value)); + return new mp_limb_t(unchecked((ulong)(uint)value)); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_limb_t(ulong value) + { + return new mp_limb_t(value); + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator mp_limb_t(long value) + { + //if (value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_limb_t data type.", value)); + return new mp_limb_t(unchecked((ulong)value)); + } + + /// + /// Converts a value to a value. + /// + /// An value. + /// A value. + public static explicit operator byte(mp_limb_t value) + { + if (value._value > byte.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Byte data type.", value)); + return (byte)value._value; + } + + /// + /// Converts a value to an value. + /// + /// An value. + /// An value. + public static explicit operator sbyte(mp_limb_t value) + { + if (value._value > (ulong)sbyte.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the SByte data type.", value)); + return (sbyte)value._value; + } + + /// + /// Converts a value to a value. + /// + /// An value. + /// A value. + public static explicit operator ushort(mp_limb_t value) + { + if (value._value > ushort.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt16 data type.", value)); + return (ushort)value._value; + } + + /// + /// Converts a value to an value. + /// + /// An value. + /// An value. + public static explicit operator short(mp_limb_t value) + { + if (value._value > (ulong)short.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Int16 data type.", value)); + return (short)value._value; + } + + /// + /// Converts a value to a value. + /// + /// An value. + /// A value. + public static explicit operator uint(mp_limb_t value) + { + if (value._value > uint.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt32 data type.", value)); + return (uint)value._value; + } + + /// + /// Converts a value to an value. + /// + /// An value. + /// An value. + public static explicit operator int(mp_limb_t value) + { + //if (value._value > int.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Int32 data type.", value)); + return unchecked((int)value._value); + } + + /// + /// Converts a value to a value. + /// + /// An value. + /// A value. + public static implicit operator ulong(mp_limb_t value) + { + return value._value; + } + + /// + /// Converts a value to an value. + /// + /// An value. + /// An value. + public static explicit operator long(mp_limb_t value) + { + //if (value._value > long.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Int64 data type.", value)); + return unchecked((long)value._value); + } + + /// + /// Gets the string representation of the . + /// + /// The string representation of the . + public override string ToString() + { + return "0x" + _value.ToString(gmp_lib.mp_bytes_per_limb == 4 ? "x8" : "x16", System.Globalization.CultureInfo.InvariantCulture); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified object. + /// + /// An object to compare with this instance. + /// True if is an instance of and equals the value of this instance; otherwise, False. + public override bool Equals(object obj) + { + if (!(obj is mp_limb_t)) + return false; + + return Equals((mp_limb_t)obj); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified value. + /// + /// A value to compare to this instance. + /// True if has the same value as this instance; otherwise, False. + public bool Equals(mp_limb_t other) + { + return _value == other._value; + } + + /// + /// Returns the hash code for this instance. + /// + /// A 32-bit signed integer hash code. + public override int GetHashCode() + { + return _value.GetHashCode(); + } + + /// + /// Gets a value that indicates whether the two argument values are equal. + /// + /// A value. + /// A value. + /// True if the two values are equal, and False otherwise. + public static bool operator ==(mp_limb_t value1, mp_limb_t value2) + { + return value1.Equals(value2); + } + + /// + /// Gets a value that indicates whether the two argument values are different. + /// + /// A value. + /// A value. + /// True if the two values are different, and False otherwise. + public static bool operator !=(mp_limb_t value1, mp_limb_t value2) + { + return !value1.Equals(value2); + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/mp_ptr.cs b/Math.Gmp.Native/mp_ptr.cs new file mode 100644 index 0000000..f178544 --- /dev/null +++ b/Math.Gmp.Native/mp_ptr.cs @@ -0,0 +1,259 @@ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Diagnostics; + +namespace Math.Gmp.Native +{ + + /// + /// Represents a pointer to an array of values in unmanaged memory, + /// + /// + /// + /// + /// + public class mp_ptr : IEnumerable + { + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + internal mp_base mp; + + /// + /// Creates a new array of limbs in unmanaged memory. + /// + /// The number of limbs. + /// + /// + /// When done with the array, you must release the unmanaged memory by calling . + /// + /// + public mp_ptr(mp_size_t size) : this(new uint[size * gmp_lib.mp_uint_per_limb]) + { + } + + /// + /// Creates a new array of limbs initialized with in unmanaged memory. + /// + /// The values of the limbs. + /// + /// + /// If there is not enough bytes to fill out the most significant limb, it is padded with zeroes. + /// + /// + /// When done with the array, you must release the unmanaged memory by calling . + /// + /// + public mp_ptr(byte[] values) + { + if (values == null) throw new ArgumentNullException("values"); + mp = new mp_base(); + if (values.GetLength(0) == 0) + { + mp._size = 0; + mp._pointer = IntPtr.Zero; + } + else + { + mp._size = (values.Length + IntPtr.Size - 1) / IntPtr.Size; + mp._pointer = gmp_lib.allocate((size_t)(mp._size * IntPtr.Size)).ToIntPtr(); + Marshal.Copy(new Int32[] { 0, 0 }, 0, (IntPtr)(mp._pointer.ToInt64() + IntPtr.Size * (mp._size - 1)), IntPtr.Size >> 2); + Marshal.Copy(values, 0, mp._pointer, values.Length); + } + } + + /// + /// Creates a new array of limbs initialized with in unmanaged memory. + /// + /// The values of the limbs. + /// + /// + /// If there is not enough 16-bit words to fill out the most significant limb, it is padded with zeroes. + /// + /// + /// When done with the array, you must release the unmanaged memory by calling . + /// + /// + public mp_ptr(ushort[] values) + { + if (values == null) throw new ArgumentNullException("values"); + mp = new mp_base(); + mp._size = (2 * values.Length + IntPtr.Size - 1) / IntPtr.Size; + mp._pointer = gmp_lib.allocate((size_t)(mp._size * IntPtr.Size)).ToIntPtr(); + Marshal.Copy(new Int32[] { 0, 0 }, 0, (IntPtr)(mp._pointer.ToInt64() + IntPtr.Size * (mp._size - 1)), IntPtr.Size >> 2); + Marshal.Copy((short[])(object)values, 0, mp._pointer, values.Length); + } + + /// + /// Creates a new array of limbs initialized with in unmanaged memory. + /// + /// The values of the limbs. + /// + /// + /// If there is not enough 32-bit words to fill out the most significant limb, it is padded with zeroes. + /// + /// + /// When done with the array, you must release the unmanaged memory by calling . + /// + /// + public mp_ptr(uint[] values) + { + if (values == null) throw new ArgumentNullException("values"); + mp = new mp_base(); + mp._size = (4 * values.Length + IntPtr.Size - 1) / IntPtr.Size; + mp._pointer = gmp_lib.allocate((size_t)(mp._size * IntPtr.Size)).ToIntPtr(); + Marshal.Copy(new Int32[] { 0, 0 }, 0, (IntPtr)(mp._pointer.ToInt64() + IntPtr.Size * (mp._size - 1)), IntPtr.Size >> 2); + Marshal.Copy((int[])(object)values, 0, mp._pointer, values.Length); + } + + /// + /// Creates a new array of limbs initialized with in unmanaged memory. + /// + /// The values of the limbs. + /// + /// + /// If limbs size is 32 bits, the 64-bit values are split into 32-bit limbs. + /// + /// + /// When done with the array, you must release the unmanaged memory by calling . + /// + /// + public mp_ptr(ulong[] values) + { + if (values == null) throw new ArgumentNullException("values"); + mp = new mp_base(); + mp._size = (8 * values.Length + IntPtr.Size - 1) / IntPtr.Size; + mp._pointer = gmp_lib.allocate((size_t)(mp._size * IntPtr.Size)).ToIntPtr(); + Marshal.Copy(new Int32[] { 0, 0 }, 0, (IntPtr)(mp._pointer.ToInt64() + IntPtr.Size * (mp._size - 1)), IntPtr.Size >> 2); + Marshal.Copy((long[])(object)values, 0, mp._pointer, values.Length); + } + + internal mp_ptr(mp_base mp) + { + this.mp = mp; + } + + /// + /// The number of limbs. + /// + /// + public mp_size_t Size + { + get + { + return mp._mp_size; + } + } + + /// + /// Gets or sets the value of the limb at . + /// + /// The zero-based index of the limb to get or set. + /// + public mp_limb_t this[int index] + { + get + { + if (index < 0) throw new ArgumentOutOfRangeException("index", "Index cannot be negative."); + if (IntPtr.Size == 4) + { + const int max_index = int.MaxValue / sizeof(int); + if (index > max_index) throw new ArgumentOutOfRangeException("index", "Index must be less than or equal to " + max_index.ToString(System.Globalization.CultureInfo.InvariantCulture) + "."); + return new mp_limb_t((uint)Marshal.ReadInt32(mp._mp_d_intptr, index * sizeof(int))); + } + else + { + const int max_index = int.MaxValue / sizeof(long); + if (index > max_index) throw new ArgumentOutOfRangeException("index", "Index must be less than or equal to " + max_index.ToString(System.Globalization.CultureInfo.InvariantCulture) + "."); + return new mp_limb_t((ulong)Marshal.ReadInt64(mp._mp_d_intptr, index * sizeof(long))); + } + } + set + { + if (index < 0) throw new ArgumentOutOfRangeException("index", "Index cannot be negative."); + if (IntPtr.Size == 4) + { + const int max_index = int.MaxValue / sizeof(int); + if (index > max_index) throw new ArgumentOutOfRangeException("index", "Index must be less than or equal to " + max_index.ToString(System.Globalization.CultureInfo.InvariantCulture) + "."); + Marshal.WriteInt32(mp._mp_d_intptr, index * sizeof(int), (int)(value._value)); + } + else + { + const int max_index = int.MaxValue / sizeof(long); + if (index > max_index) throw new ArgumentOutOfRangeException("index", "Index must be less than or equal to " + max_index.ToString(System.Globalization.CultureInfo.InvariantCulture) + "."); + Marshal.WriteInt64(mp._mp_d_intptr, index * sizeof(long), (long)(value._value)); + } + } + } + + internal IntPtr ToIntPtr() + { + return mp._mp_d_intptr; + } + + /// + /// Returns an enumerator that iterates through the array of limbs. + /// + /// An enumerator that iterates through the array of limbs. + public IEnumerator GetEnumerator() + { + return new _limb_enumerator(this); + } + + /// + /// Returns an enumerator that iterates through the array of limbs. + /// + /// An enumerator that iterates through the array of limbs. + IEnumerator IEnumerable.GetEnumerator() + { + return new _limb_enumerator(this); + } + + private class _limb_enumerator : IEnumerator + { + int index; + mp_ptr limbs; + + public _limb_enumerator(mp_ptr limbs) + { + this.limbs = limbs; + Reset(); + } + + public mp_limb_t Current + { + get + { + return this.limbs[index]; + } + } + + object IEnumerator.Current + { + get + { + return (object)Current; + } + } + + public void Dispose() + { + } + + public bool MoveNext() + { + index++; + return index < System.Math.Abs(limbs.Size); + } + + public void Reset() + { + index = -1; + } + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/mp_size_t.cs b/Math.Gmp.Native/mp_size_t.cs new file mode 100644 index 0000000..348d46f --- /dev/null +++ b/Math.Gmp.Native/mp_size_t.cs @@ -0,0 +1,273 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Math.Gmp.Native +{ + + /// + /// Represents a count of limbs. + /// + /// + /// + /// Counts of limbs of a multi-precision number represented in the C type . + /// Currently this is normally a long, but on some systems it’s an int for efficiency, + /// and on some systems it will be long long in the future. + /// + /// + /// In .Net, this is a 32-bit integer. + /// + /// + /// + /// + /// + /// + public struct mp_size_t + { + + internal int _value; + + /// + /// Creates a new , and sets its . + /// + /// The value of the new . + public mp_size_t(int value) + { + _value = value; + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_size_t(byte value) + { + return new mp_size_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_size_t(sbyte value) + { + return new mp_size_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static implicit operator mp_size_t(ushort value) + { + return new mp_size_t(value); + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static implicit operator mp_size_t(short value) + { + return new mp_size_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static explicit operator mp_size_t(uint value) + { + if (value > int.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_size_t data type.", value)); + return new mp_size_t((int)value); + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static implicit operator mp_size_t(int value) + { + return new mp_size_t(value); + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + public static explicit operator mp_size_t(ulong value) + { + if (value > int.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_size_t data type.", value)); + return new mp_size_t((int)value); + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// An value. + public static explicit operator mp_size_t(long value) + { + if (value < uint.MinValue || value > uint.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the mp_size_t data type.", value)); + return new mp_size_t((int)value); + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator byte(mp_size_t value) + { + if (value._value > byte.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Byte data type.", value)); + return (byte)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator sbyte(mp_size_t value) + { + if (value._value < sbyte.MinValue || value._value > sbyte.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the SByte data type.", value)); + return (sbyte)value._value; + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator ushort(mp_size_t value) + { + if (value._value > ushort.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt16 data type.", value)); + return (ushort)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static explicit operator short(mp_size_t value) + { + if (value._value < short.MinValue || value._value > short.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Int16 data type.", value)); + return (short)value._value; + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator uint(mp_size_t value) + { + if (value._value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt32 data type.", value)); + return (uint)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static implicit operator int(mp_size_t value) + { + return value._value; + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator ulong(mp_size_t value) + { + if (value._value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt64 data type.", value)); + return (ulong)value._value; + } + + /// + /// Converts an value to an value. + /// + /// An value. + /// An value. + public static implicit operator long(mp_size_t value) + { + return value._value; + } + + /// + /// Gets the string representation of the . + /// + /// The string representation of the . + public override string ToString() + { + return _value.ToString(System.Globalization.CultureInfo.InvariantCulture); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified object. + /// + /// An object to compare with this instance. + /// True if is an instance of and equals the value of this instance; otherwise, False. + public override bool Equals(object obj) + { + if (!(obj is mp_size_t)) + return false; + + return Equals((mp_size_t)obj); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified value. + /// + /// A value to compare to this instance. + /// True if has the same value as this instance; otherwise, False. + public bool Equals(mp_size_t other) + { + return _value == other._value; + } + + /// + /// Returns the hash code for this instance. + /// + /// A 32-bit signed integer hash code. + public override int GetHashCode() + { + return _value.GetHashCode(); + } + + /// + /// Gets a value that indicates whether the two argument values are equal. + /// + /// A value. + /// A value. + /// True if the two values are equal, and False otherwise. + public static bool operator ==(mp_size_t value1, mp_size_t value2) + { + return value1.Equals(value2); + } + + /// + /// Gets a value that indicates whether the two argument values are different. + /// + /// A value. + /// A value. + /// True if the two values are different, and False otherwise. + public static bool operator !=(mp_size_t value1, mp_size_t value2) + { + return !value1.Equals(value2); + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/mpf_t.cs b/Math.Gmp.Native/mpf_t.cs new file mode 100644 index 0000000..e3f2fcc --- /dev/null +++ b/Math.Gmp.Native/mpf_t.cs @@ -0,0 +1,169 @@ + +using System; +using System.Runtime.InteropServices; +using System.Diagnostics; + +namespace Math.Gmp.Native +{ + + /// + /// Represents a multiple precision floating-point number. + /// + /// + /// + /// The floating point functions accept and return exponents in the C type . + /// Currently this is usually a long, but on some systems it’s an int for efficiency. + /// + /// + /// In .NET, this is a 32-bit integer. + /// + /// + /// + /// + /// + /// + public class mpf_t : mp_base + { + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + internal bool _initialized = false; + + /// + /// Creates a new multiple precision floating-point number. + /// + public mpf_t() + { + size_t length = /*sizeof(int) + sizeof(int) + sizeof(int)*/ 12U + (size_t)IntPtr.Size; + _pointer = gmp_lib.allocate(length).ToIntPtr(); + gmp_lib.ZeroMemory(_pointer, (int)length); + } + + /// + /// The number of limbs currently in use, or the negative of that when representing a negative value. + /// + /// + /// + /// Zero is represented by and both set to zero, + /// and in that case the data is unused. + /// (In the future might be undefined when representing zero.) + /// + /// + public override mp_size_t _mp_size + { + get + { + return Marshal.ReadInt32(_pointer, /*sizeof(int)*/ 4); + } + } + + /// + /// The precision of the mantissa, in limbs. + /// + /// + /// + /// In any calculation the aim is to produce limbs of result (the most significant being non-zero). + /// + /// + public int _mp_prec + { + get + { + return Marshal.ReadInt32(_pointer, 0); + } + } + + /// + /// The exponent, in limbs, determining the location of the implied radix point. + /// + /// + /// + /// Zero means the radix point is just above the most significant limb. + /// Positive values mean a radix point offset towards the lower limbs and hence a value ≥ 1, as for example in the diagram above. + /// Negative exponents mean a radix point further above the highest limb. + /// + /// + /// Naturally the exponent can be any value, it doesn’t have to fall within the limbs as the diagram shows, + /// it can be a long way above or a long way below. + /// Limbs other than those included in the {, } data are treated as zero. + /// + /// + public int _mp_exp + { + get + { + return Marshal.ReadInt32(_pointer, /*sizeof(int) + sizeof(int)*/ 8); + } + } + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + internal override IntPtr _mp_d_intptr + { + get + { + return Marshal.ReadIntPtr(_pointer, /*sizeof(int) + sizeof(int) + sizeof(int)*/ 12); + } + set + { + Marshal.WriteIntPtr(_pointer, /*sizeof(int) + sizeof(int) + sizeof(int)*/ 12, value); + } + } + + /// + /// Gets the unmanaged memory pointer of the multiple precision floating-point number. + /// + /// The unmanaged memory pointer of the multiple precision floating-point number. + public IntPtr ToIntPtr() + { + return _pointer; + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + /// + /// + /// Base is assumed to be 10 unless the first character of the string is B + /// followed by the base 2 to 62 or -62 to -2 followed + /// by a space and then the floating-point number. + /// Negative values are used to specify that the exponent is in decimal. + /// + /// + public static implicit operator mpf_t(string value) + { + int @base = 10; + mpf_t x = new mpf_t(); + gmp_lib.mpf_init(x); + if (value != null && value.Substring(0, 1).ToUpperInvariant() == "B") + { + int pos = value.IndexOf(' ', 1); + if (pos != -1 && int.TryParse(value.Substring(1, pos - 1), out @base) == true) + value = value.Substring(pos + 1); + } + char_ptr s = new char_ptr(value); + gmp_lib.mpf_set_str(x, s, @base); + gmp_lib.free(s); + return x; + } + + /// + /// Return the string representation of the float. + /// + /// The string representation of the float. + public override string ToString() + { + if (!_initialized) return null; + ptr exp = new ptr(0); + char_ptr s_ptr = gmp_lib.mpf_get_str(char_ptr.Zero, exp, 10, 0, this); + string s = s_ptr.ToString(); + gmp_lib.free(s_ptr); + if (s.StartsWith("-", StringComparison.Ordinal)) + return "-0." + s.Substring(1) + "e" + exp.Value._value.ToString(System.Globalization.CultureInfo.InvariantCulture); + else + return "0." + s + "e" + exp.Value._value.ToString(System.Globalization.CultureInfo.InvariantCulture); + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/mpq_t.cs b/Math.Gmp.Native/mpq_t.cs new file mode 100644 index 0000000..e0cea02 --- /dev/null +++ b/Math.Gmp.Native/mpq_t.cs @@ -0,0 +1,102 @@ + +using System; +using System.Runtime.InteropServices; +using System.Diagnostics; + +namespace Math.Gmp.Native +{ + + /// + /// Represents a multiple precision rational number. + /// + /// + /// + /// + public class mpq_t + { + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IntPtr _pointer; + + /// + /// Creates a new multiple precision rational. + /// + public mpq_t() + { + size_t length = /*2 * (sizeof(int) + sizeof(int))*/ 16 + 2 * (size_t)IntPtr.Size; + _pointer = gmp_lib.allocate(length).ToIntPtr(); + gmp_lib.ZeroMemory(_pointer, (int)length); + } + + /// + /// Get the numerator integer of the rational. + /// + /// The numerator integer of the rational. + public mpz_t _mp_num + { + get + { + return new mpz_t(_pointer); + } + } + + /// + /// Get the denominator integer of the rational. + /// + /// The denominator integer of the rational. + public mpz_t _mp_den + { + get + { + return new mpz_t((IntPtr)(_pointer.ToInt64() /*+ sizeof(int) + sizeof(int)*/ + 8 + IntPtr.Size)); + } + } + + /// + /// Gets the unmanaged memory pointer of the multiple precision rational. + /// + /// The unmanaged memory pointer of the multiple precision rational. + public IntPtr ToIntPtr() + { + return _pointer; + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + /// + /// + /// The leading characters are used: 0x and 0X for hexadecimal, + /// 0b and 0B for binary, 0 for octal, or decimal otherwise. + /// Note that this is done separately for the numerator and denominator, so for + /// instance 0xEF/100 is 239/100, whereas 0xEF/0x100 is + /// 239/256. + /// + /// + public static implicit operator mpq_t(string value) + { + mpq_t x = new mpq_t(); + gmp_lib.mpq_init(x); + char_ptr s = new char_ptr(value); + gmp_lib.mpq_set_str(x, s, 0); + gmp_lib.free(s); + return x; + } + + /// + /// Return the string representation of the rational. + /// + /// The string representation of the rational. + public override string ToString() + { + char_ptr s_ptr = gmp_lib.mpq_get_str(char_ptr.Zero, 10, this); + string s = s_ptr.ToString(); + gmp_lib.free(s_ptr); + return s; + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/mpz_t.cs b/Math.Gmp.Native/mpz_t.cs new file mode 100644 index 0000000..fe7341a --- /dev/null +++ b/Math.Gmp.Native/mpz_t.cs @@ -0,0 +1,128 @@ + +using System; +using System.Runtime.InteropServices; +using System.Diagnostics; + +namespace Math.Gmp.Native +{ + + /// + /// Represents a multiple precision integer. + /// + /// + /// + /// + /// + public class mpz_t : mp_base + { + + /// + /// Creates a new multiple precision integer. + /// + public mpz_t() + { + size_t length = /*sizeof(int) + sizeof(int)*/ 8 + (size_t)IntPtr.Size; + _pointer = gmp_lib.allocate(length).ToIntPtr(); + gmp_lib.ZeroMemory(_pointer, (int)length); + } + + internal mpz_t(IntPtr pointer) + { + _pointer = pointer; + } + + /// + /// The number of limbs currently allocated at . + /// + /// + /// + /// is the number of limbs currently allocated at , + /// and naturally >= ABS(). + /// When an mpz routine is about to (or might be about to) increase , it checks + /// to see whether there’s enough space, and reallocates if not. + /// + /// + public int _mp_alloc + { + get + { + return Marshal.ReadInt32(_pointer, 0); + } + } + + /// + /// The number of limbs, or the negative of that when representing a negative integer. + /// + /// + /// + /// The number of limbs, or the negative of that when representing a negative integer. + /// Zero is represented by set to zero, in which case + /// the data is unused. + /// + /// + public override mp_size_t _mp_size + { + get + { + return Marshal.ReadInt32(_pointer, sizeof(int)); + } + } + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + internal override IntPtr _mp_d_intptr + { + get + { + return Marshal.ReadIntPtr(_pointer, sizeof(int) + sizeof(int)); + } + set + { + Marshal.WriteIntPtr(_pointer, sizeof(int) + sizeof(int), value); + } + } + + /// + /// Gets the unmanaged memory pointer of the multiple precision integer. + /// + /// The unmanaged memory pointer of the multiple precision integer. + public IntPtr ToIntPtr() + { + return _pointer; + } + + /// + /// Converts a value to an value. + /// + /// A value. + /// An value. + /// + /// + /// The leading characters are used: 0x and 0X for hexadecimal, + /// 0b and 0B for binary, 0 for octal, or decimal otherwise. + /// + /// + public static implicit operator mpz_t(string value) + { + mpz_t x = new mpz_t(); + gmp_lib.mpz_init(x); + char_ptr s = new char_ptr(value); + gmp_lib.mpz_set_str(x, s, 0); + gmp_lib.free(s); + return x; + } + + /// + /// Return the string representation of the integer. + /// + /// The string representation of the integer. + public override string ToString() + { + char_ptr s_ptr = gmp_lib.mpz_get_str(char_ptr.Zero, 10, this); + string s = s_ptr.ToString(); + gmp_lib.free(s_ptr); + return s; + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/packages.config b/Math.Gmp.Native/packages.config new file mode 100644 index 0000000..7a74fc1 --- /dev/null +++ b/Math.Gmp.Native/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Math.Gmp.Native/ptr.cs b/Math.Gmp.Native/ptr.cs new file mode 100644 index 0000000..bd16c7d --- /dev/null +++ b/Math.Gmp.Native/ptr.cs @@ -0,0 +1,47 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Math.Gmp.Native +{ + + /// + /// Represents a pointer to a value of type . + /// + /// A value type. + /// + /// + /// Mimics the C address-of (&) construct to pass the address of a value type variable + /// to a function of the GMP library. + /// + /// + /// Note that this is only for value types. Strings and arrays have their own "pointer" + /// types defined with names ending in _ptr. + /// + /// + public class ptr where T : struct + { + /// + /// The value that is "pointed to". + /// + public T Value; + + /// + /// Creates a new pointer with default value. + /// + public ptr() + { + } + + /// + /// Creates a new pointer with set to . + /// + /// The initial value. + public ptr(T value) + { + this.Value = value; + } + + } + +} diff --git a/Math.Gmp.Native/reallocate_function.cs b/Math.Gmp.Native/reallocate_function.cs new file mode 100644 index 0000000..59a7e95 --- /dev/null +++ b/Math.Gmp.Native/reallocate_function.cs @@ -0,0 +1,17 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Math.Gmp.Native +{ + + /// + /// Resize a previously allocated block ptr of bytes to be bytes. + /// + /// Pointer to previously allocated block. + /// Number of bytes of previously allocated block. + /// New number of bytes of previously allocated block. + /// A previously allocated block ptr of bytes to be bytes. + public delegate void_ptr reallocate_function(void_ptr ptr, size_t old_size, size_t new_size); + +} diff --git a/Math.Gmp.Native/size_t.cs b/Math.Gmp.Native/size_t.cs new file mode 100644 index 0000000..d90aa06 --- /dev/null +++ b/Math.Gmp.Native/size_t.cs @@ -0,0 +1,266 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Math.Gmp.Native +{ + + /// + /// Represents a count of characters or bytes. + /// + /// + /// + /// In .NET, this is an unsigned 64-bit integer. + /// + /// + public struct size_t + { + + internal ulong _value; + + /// + /// Creates a new , and sets its . + /// + /// The value of the new . + public size_t(ulong value) + { + _value = value; + } + + /// + /// Converts a value to a value. + /// + /// A value. + /// A value. + public static implicit operator size_t(byte value) + { + return new size_t(value); + } + + /// + /// Converts a value to a value. + /// + /// A value. + /// A value. + public static explicit operator size_t(sbyte value) + { + if (value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the size_t data type.", value)); + return new size_t((uint)value); + } + + /// + /// Converts a value to a value. + /// + /// A value. + /// A value. + public static implicit operator size_t(ushort value) + { + return new size_t(value); + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator size_t(short value) + { + if (value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the size_t data type.", value)); + return new size_t((uint)value); + } + + /// + /// Converts a value to a value. + /// + /// A value. + /// A value. + public static implicit operator size_t(uint value) + { + return new size_t(value); + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator size_t(int value) + { + //if (value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the size_t data type.", value)); + return new size_t(unchecked((ulong)(uint)value)); + } + + /// + /// Converts a value to a value. + /// + /// A value. + /// A value. + public static implicit operator size_t(ulong value) + { + return new size_t(value); + } + + /// + /// Converts an value to a value. + /// + /// An value. + /// A value. + public static explicit operator size_t(long value) + { + //if (value < 0) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the size_t data type.", value)); + return new size_t(unchecked((ulong)value)); + } + + /// + /// Converts a value to a value. + /// + /// An value. + /// A value. + public static explicit operator byte(size_t value) + { + if (value._value > byte.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Byte data type.", value)); + return (byte)value._value; + } + + /// + /// Converts a value to an value. + /// + /// An value. + /// An value. + public static explicit operator sbyte(size_t value) + { + if (value._value > (ulong)sbyte.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the SByte data type.", value)); + return (sbyte)value._value; + } + + /// + /// Converts a value to a value. + /// + /// An value. + /// A value. + public static explicit operator ushort(size_t value) + { + if (value._value > ushort.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt16 data type.", value)); + return (ushort)value._value; + } + + /// + /// Converts a value to an value. + /// + /// An value. + /// An value. + public static explicit operator short(size_t value) + { + if (value._value > (ulong)short.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Int16 data type.", value)); + return (short)value._value; + } + + /// + /// Converts a value to a value. + /// + /// An value. + /// A value. + public static explicit operator uint(size_t value) + { + if (value._value > uint.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the UInt32 data type.", value)); + return (uint)value._value; + } + + /// + /// Converts a value to an value. + /// + /// An value. + /// An value. + public static explicit operator int(size_t value) + { + //if (value._value > int.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Int32 data type.", value)); + return unchecked((int)value._value); + } + + /// + /// Converts a value to a value. + /// + /// An value. + /// A value. + public static implicit operator ulong(size_t value) + { + return value._value; + } + + /// + /// Converts a value to an value. + /// + /// An value. + /// An value. + public static explicit operator long(size_t value) + { + //if (value._value > long.MaxValue) throw new System.OverflowException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is out of range of the Int64 data type.", value)); + return unchecked((long)value._value); + } + + /// + /// Gets the string representation of the . + /// + /// The string representation of the . + public override string ToString() + { + return _value.ToString(System.Globalization.CultureInfo.InvariantCulture); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified object. + /// + /// An object to compare with this instance. + /// True if is an instance of and equals the value of this instance; otherwise, False. + public override bool Equals(object obj) + { + if (!(obj is size_t)) + return false; + + return Equals((size_t)obj); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified value. + /// + /// A value to compare to this instance. + /// True if has the same value as this instance; otherwise, False. + public bool Equals(size_t other) + { + return _value == other._value; + } + + /// + /// Returns the hash code for this instance. + /// + /// A 32-bit signed integer hash code. + public override int GetHashCode() + { + return _value.GetHashCode(); + } + + /// + /// Gets a value that indicates whether the two argument values are equal. + /// + /// A value. + /// A value. + /// True if the two values are equal, and False otherwise. + public static bool operator ==(size_t value1, size_t value2) + { + return value1.Equals(value2); + } + + /// + /// Gets a value that indicates whether the two argument values are different. + /// + /// A value. + /// A value. + /// True if the two values are different, and False otherwise. + public static bool operator !=(size_t value1, size_t value2) + { + return !value1.Equals(value2); + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/va_list.cs b/Math.Gmp.Native/va_list.cs new file mode 100644 index 0000000..e77244c --- /dev/null +++ b/Math.Gmp.Native/va_list.cs @@ -0,0 +1,562 @@ + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + +namespace Math.Gmp.Native +{ + + internal class va_list + { + + private IntPtr arguments; + + private struct va_arg + { + //public int arg_size; + //public int data_size; + public int arg_offset; + public int data_offset; + public Action write; // Write to unmanaged memory. + public Action read; // Read from unmanaged memory. + } + + private va_arg[] va_args; + private int args_size = 0; + private int data_size = 0; + + private Stack readables = new Stack(); + + /// + /// Creates a variable list of arguments in unmanaged memory. + /// + /// + public va_list(params object[] args) + { + va_args = new va_arg[args.Length]; + + for (int j = 0; j < args.Length; j++) + { + string name = args[j].GetType().Name; + if (name == "ptr`1") + name = name.Replace("`1", "<" + args[j].GetType().GetGenericArguments()[0].Name + ">"); + + va_args[j].arg_offset = args_size; + va_args[j].data_offset = data_size; + + switch (name) + { + case "Char": + args_size += 1; + va_args[j].write = (i) => Marshal.WriteByte(arguments, va_args[i].arg_offset, System.Text.Encoding.ASCII.GetBytes(new Char[] { (Char)args[i] })[0]); + break; + + case "Byte": + case "SByte": + args_size += 1; + va_args[j].write = (i) => Marshal.WriteByte(arguments, va_args[i].arg_offset, (Byte)args[i]); + break; + + case "Int16": + case "UInt16": + args_size += 2; + va_args[j].write = (i) => Marshal.WriteInt16(arguments, va_args[i].arg_offset, (Int16)args[i]); + break; + + case "Int32": + case "UInt32": + args_size += 4; + va_args[j].write = (i) => Marshal.WriteInt32(arguments, va_args[i].arg_offset, (Int32)args[i]); + break; + + case "Single": + args_size += 8; + va_args[j].write = (i) => Marshal.Copy(BitConverter.GetBytes((Double)(Single)args[i]), 0, (IntPtr)(arguments.ToInt64() + va_args[i].arg_offset), 8); + break; + + case "mp_bitcnt_t": + args_size += 4; + va_args[j].write = (i) => Marshal.WriteInt32(arguments, va_args[i].arg_offset, (Int32)(mp_bitcnt_t)args[i]); + break; + + case "mp_size_t": + args_size += 4; + va_args[j].write = (i) => Marshal.WriteInt32(arguments, va_args[i].arg_offset, (Int32)(mp_size_t)args[i]); + break; + + case "mp_exp_t": + args_size += 4; + va_args[j].write = (i) => Marshal.WriteInt32(arguments, va_args[i].arg_offset, (Int32)(mp_exp_t)args[i]); + break; + + case "Int64": + case "UInt64": + args_size += 8; + va_args[j].write = (i) => Marshal.WriteInt64(arguments, va_args[i].arg_offset, (Int64)args[i]); + break; + + case "Double": + args_size += 8; + va_args[j].write = (i) => Marshal.Copy(BitConverter.GetBytes((Double)args[i]), 0, (IntPtr)(arguments.ToInt64() + va_args[i].arg_offset), 8); + break; + + case "IntPtr": + case "UIntPtr": + args_size += IntPtr.Size; + va_args[j].write = (i) => Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, (IntPtr)args[i]); + break; + + case "mpz_t": + args_size += IntPtr.Size; + va_args[j].write = (i) => Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, ((mpz_t)args[i]).ToIntPtr()); + break; + + case "mpq_t": + args_size += IntPtr.Size; + va_args[j].write = (i) => Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, ((mpq_t)args[i]).ToIntPtr()); + break; + + case "mpf_t": + args_size += IntPtr.Size; + va_args[j].write = (i) => Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, ((mpf_t)args[i]).ToIntPtr()); + break; + + case "mp_ptr": + args_size += IntPtr.Size; + va_args[j].write = (i) => Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, ((mp_ptr)args[i]).ToIntPtr()); + break; + + case "mp_limb_t": + args_size += IntPtr.Size; + va_args[j].write = (i) => + { + if (IntPtr.Size == 4) + Marshal.WriteInt32(arguments, va_args[i].arg_offset, (Int32)(mp_limb_t)args[i]); + else + Marshal.WriteInt64(arguments, va_args[i].arg_offset, (Int64)(mp_limb_t)args[i]); + }; + break; + + case "char_ptr": + args_size += IntPtr.Size; + va_args[j].write = (i) => Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, ((char_ptr)args[i]).ToIntPtr()); + break; + + case "size_t": + args_size += IntPtr.Size; + va_args[j].write = (i) => + { + if (IntPtr.Size == 4) + Marshal.WriteInt32(arguments, va_args[i].arg_offset, (Int32)(size_t)args[i]); + else + Marshal.WriteInt64(arguments, va_args[i].arg_offset, (Int64)(size_t)args[i]); + }; + break; + + case "String": + args_size += IntPtr.Size; + data_size += ((string)args[j]).Length + 1; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + string data = (string)args[i]; + Marshal.Copy(Encoding.ASCII.GetBytes(data), 0, data_ptr, data.Length); + data_ptr += data.Length; + Marshal.Copy(new Byte[] { 0 }, 0, data_ptr, 1); + }; + break; + + case "StringBuilder": + args_size += IntPtr.Size; + data_size += ((StringBuilder)args[j]).Capacity + 1; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + StringBuilder data = (StringBuilder)args[i]; + Marshal.Copy(Encoding.ASCII.GetBytes(data.ToString()), 0, data_ptr, data.Length); + Marshal.Copy(new Byte[] { 0 }, 0, data_ptr + data.Length, 1); + data_ptr += data.Capacity + 1; + }; + va_args[j].read = (i) => + { + StringBuilder data = (StringBuilder)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Clear(); + data.Append(Marshal.PtrToStringAnsi(data_ptr)); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 1; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + Char data = ((ptr)args[i]).Value; + Marshal.WriteByte(data_ptr, 0, Encoding.ASCII.GetBytes(new Char[] { data })[0]); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Value = Encoding.ASCII.GetChars(new byte[] { Marshal.ReadByte(data_ptr) })[0]; + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 1; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + Byte data = ((ptr)args[i]).Value; + Marshal.WriteByte(data_ptr, 0, data); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Value = (Byte)Marshal.ReadByte(data_ptr); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 1; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + SByte data = ((ptr)args[i]).Value; + Marshal.WriteByte(data_ptr, 0, (Byte)data); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Value = (SByte)Marshal.ReadByte(data_ptr); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 2; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + Int16 data = ((ptr)args[i]).Value; + Marshal.WriteInt16(data_ptr, 0, data); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Value = (Int16)Marshal.ReadInt16(data_ptr); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 2; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + UInt16 data = ((ptr)args[i]).Value; + Marshal.WriteInt16(data_ptr, 0, (Int16)data); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Value = (UInt16)Marshal.ReadInt16(data_ptr); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 4; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + Int32 data = ((ptr)args[i]).Value; + Marshal.WriteInt32(data_ptr, 0, data); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Value = (Int32)Marshal.ReadInt32(data_ptr); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 4; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + UInt32 data = ((ptr)args[i]).Value; + Marshal.WriteInt32(data_ptr, 0, (Int32)data); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Value = (UInt32)Marshal.ReadInt32(data_ptr); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 4; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + Single data = ((ptr)args[i]).Value; + Marshal.Copy(BitConverter.GetBytes((Single)data), 0, data_ptr, 4); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Byte[] bytes = new Byte[4]; + Marshal.Copy(data_ptr, bytes, 0, 4); + data.Value = BitConverter.ToSingle(bytes, 0); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 4; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + mp_bitcnt_t data = ((ptr)args[i]).Value; + Marshal.WriteInt32(data_ptr, 0, (Int32)data._value); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Value._value = (uint)Marshal.ReadInt32(data_ptr); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 4; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + mp_size_t data = ((ptr)args[i]).Value; + Marshal.WriteInt32(data_ptr, 0, data._value); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Value._value = Marshal.ReadInt32(data_ptr); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 4; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + mp_exp_t data = ((ptr)args[i]).Value; + Marshal.WriteInt32(data_ptr, 0, data._value); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Value._value = Marshal.ReadInt32(data_ptr); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 8; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + Int64 data = ((ptr)args[i]).Value; + Marshal.WriteInt64(data_ptr, 0, data); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Value = (Int64)Marshal.ReadInt64(data_ptr); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 8; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + UInt64 data = ((ptr)args[i]).Value; + Marshal.WriteInt64(data_ptr, 0, (Int64)data); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Value = (UInt64)Marshal.ReadInt64(data_ptr); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += 8; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + Double data = ((ptr)args[i]).Value; + Marshal.Copy(BitConverter.GetBytes(data), 0, data_ptr, 8); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Byte[] bytes = new Byte[8]; + Marshal.Copy(data_ptr, bytes, 0, 8); + data.Value = BitConverter.ToDouble(bytes, 0); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += IntPtr.Size; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + mp_limb_t data = ((ptr)args[i]).Value; + if (IntPtr.Size == 4) + Marshal.WriteInt32(data_ptr, 0, (Int32)data._value); + else + Marshal.WriteInt64(data_ptr, 0, (Int64)data._value); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + if (IntPtr.Size == 4) + data.Value._value = (UInt32)Marshal.ReadInt32(data_ptr); + else + data.Value._value = (UInt64)Marshal.ReadInt64(data_ptr); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += IntPtr.Size; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + size_t data = ((ptr)args[i]).Value; + if (IntPtr.Size == 4) + Marshal.WriteInt32(data_ptr, 0, (Int32)data._value); + else + Marshal.WriteInt64(data_ptr, 0, (Int64)data._value); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + if (IntPtr.Size == 4) + data.Value._value = (UInt32)Marshal.ReadInt32(data_ptr); + else + data.Value._value = (UInt64)Marshal.ReadInt64(data_ptr); + }; + readables.Push(j); + break; + + case "ptr": + args_size += IntPtr.Size; + data_size += IntPtr.Size; + va_args[j].write = (i) => + { + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + Marshal.WriteIntPtr(arguments, va_args[i].arg_offset, data_ptr); + IntPtr data = ((ptr)args[i]).Value; + Marshal.WriteIntPtr(data_ptr, 0, data); + }; + va_args[j].read = (i) => + { + ptr data = (ptr)args[i]; + IntPtr data_ptr = (IntPtr)(arguments.ToInt64() + args_size + va_args[i].data_offset); + data.Value = Marshal.ReadIntPtr(data_ptr); + }; + readables.Push(j); + break; + + default: + throw new System.InvalidOperationException("Unsupported variable argument type '" + name + "'"); + + } + } + + // Write arguments to unmanaged memory. + arguments = gmp_lib.allocate((size_t)(args_size + data_size)).ToIntPtr(); + for (int i = 0; i < args.Length; i++) + va_args[i].write(i); + + } + + public IntPtr ToIntPtr() + { + return arguments; + } + + /// + /// Retrieves argument values from unmanaged memory. + /// + public void RetrieveArgumentValues() + { + foreach (int i in readables) + va_args[i].read(i); + gmp_lib.free(arguments); + } + + } + +} \ No newline at end of file diff --git a/Math.Gmp.Native/void_ptr.cs b/Math.Gmp.Native/void_ptr.cs new file mode 100644 index 0000000..663c5d7 --- /dev/null +++ b/Math.Gmp.Native/void_ptr.cs @@ -0,0 +1,103 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Math.Gmp.Native +{ + + /// + /// Represents a pointer to a block of unmanaged memory. + /// + /// + public struct void_ptr + { + + private IntPtr _pointer; + + internal void_ptr(IntPtr pointer) + { + _pointer = pointer; + } + + /// + /// Gets a from a pointer to a block of unmanaged memory. + /// + /// A pointer to a block of unmanaged memory. + /// A from a pointer to a block of unmanaged memory. + public void_ptr FromIntPtr(IntPtr value) + { + _pointer = value; + return this; + } + + /// + /// Gets pointer to block of unmanaged memory. + /// + /// Pointer to block of unmanaged memory. + public IntPtr ToIntPtr() + { + return _pointer; + } + + /// + /// Gets a null . + /// + public static readonly void_ptr Zero = new void_ptr(IntPtr.Zero); + + /// + /// Returns a value indicating whether this instance is equal to a specified object. + /// + /// An object to compare with this instance. + /// True if is an instance of and equals the value of this instance; otherwise, False. + public override bool Equals(object obj) + { + if (!(obj is void_ptr)) + return false; + + return Equals((void_ptr)obj); + } + + /// + /// Returns a value indicating whether this instance is equal to a specified value. + /// + /// A value to compare to this instance. + /// True if has the same value as this instance; otherwise, False. + public bool Equals(void_ptr other) + { + return _pointer == other._pointer; + } + + /// + /// Returns the hash code for this instance. + /// + /// A 32-bit signed integer hash code. + public override int GetHashCode() + { + return _pointer.GetHashCode(); + } + + /// + /// Gets a value that indicates whether the two argument values are equal. + /// + /// A value. + /// A value. + /// True if the two values are equal, and False otherwise. + public static bool operator ==(void_ptr value1, void_ptr value2) + { + return value1.Equals(value2); + } + + /// + /// Gets a value that indicates whether the two argument values are different. + /// + /// A value. + /// A value. + /// True if the two values are different, and False otherwise. + public static bool operator !=(void_ptr value1, void_ptr value2) + { + return !value1.Equals(value2); + } + + } + +} \ No newline at end of file diff --git a/NuGet/Gmp.Native.nuspec b/NuGet/Gmp.Native.nuspec new file mode 100644 index 0000000..7ce400f --- /dev/null +++ b/NuGet/Gmp.Native.nuspec @@ -0,0 +1,28 @@ + + + + Gmp.Native.NET + 1.1 + GMP Native Interface for .NET) + Robert Baron (Machine Cognitis) + Robert Baron (Machine Cognitis) + https://github.com/MachineCognitis/Gmp.Native.NET/blob/master/LICENSE.md + https://github.com/MachineCognitis/Gmp.Native.NET/ + false + This package contains the C.math.NET library that implements several C Standard mathematical functions that are missing from the .NET framework. Functions include among others: frexp, ilogb, ldexp, logb, scalbn, copysign, nextafter, isunordered, and fpclassify. Both double and single precision functions are implemented. All functions are static and their names follow the C Standard. + +All functions have been thoroughly tested using a large set of unit tests that cover all limit cases to guarantee that all functions behave as specified by the C standard. + +Supported Platform: .NET Framework 2.0+ + C math (in .NET) + Initial release. + Copyright (c) 2016 Robert Baron, Machine Cognitis + fpclassify isfinite isinf isnan isnormal signbit frexp ilogb ldexp logb scalbn scalbln copysign nextafter nexttoward significand isunordered + + + + + + + + \ No newline at end of file diff --git a/NuGet/NuGet.nuproj b/NuGet/NuGet.nuproj new file mode 100644 index 0000000..b7888e1 --- /dev/null +++ b/NuGet/NuGet.nuproj @@ -0,0 +1,23 @@ + + + + b51a83d0-21f1-454a-a62c-8173db309348 + Bin\ + v4.0 + Manual + False + False + True + NuGet + + + + + + + + Code + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..0306c1a --- /dev/null +++ b/README.md @@ -0,0 +1,76 @@ +# Welcome to the C.math.NET Library +The C.math.NET library implements several [C Standard](http://en.cppreference.com/w/c/numeric/math) mathematical +functions that are missing from the .NET framework. +Functions include among others: +[frexp](https://machinecognitis.github.io/C.math.NET/html/b4d6cd51-2441-999a-18c2-8d18dc2a2c3c.htm), +[ilogb](https://machinecognitis.github.io/C.math.NET/html/6c69efac-8d3c-7c31-f0c5-930b73593c0e.htm), +[ldexp](https://machinecognitis.github.io/C.math.NET/html/35eead45-7bb4-88c5-0f75-278b2cbc94a7.htm), +[logb](https://machinecognitis.github.io/C.math.NET/html/5f67d96e-daa3-cd30-9384-1cda9ebf3f8a.htm), +[scalbn](https://machinecognitis.github.io/C.math.NET/html/bedc19b9-8091-4a47-c967-9092577c1dd7.htm), +[copysign](https://machinecognitis.github.io/C.math.NET/html/cd5217b7-7396-95ed-e4b7-0702efbd860d.htm), +[nextafter](https://machinecognitis.github.io/C.math.NET/html/65f00e22-a956-ec37-9e75-4594cb42d6d2.htm), +[isunordered](https://machinecognitis.github.io/C.math.NET/html/e64fb421-ebf8-8796-d5d0-159ce7435c91.htm), and +[fpclassify](https://machinecognitis.github.io/C.math.NET/html/63a4a916-1492-dedf-c8fe-0e01aff401f4.htm). +Both double and single precision functions are implemented. +All functions are static and their names follow the +[C Standard](http://en.cppreference.com/w/c/numeric/math). + +All functions have been thoroughly tested using a large set of unit tests that cover all +limit cases to guarantee that all functions behave as specified by the C standard. + +### Documentation + +- On-line help is available [here](https://machinecognitis.github.io/C.math.NET/). + +### NuGet + +The C.math.NET library can be installed in your Visual Studio solution or project with this +[NuGet package](https://www.nuget.org/packages/C.math.NET/). + +### Latest Build + +The build file includes the compiled library and the help file (.chm) ready to be included in your project. +The library targets the .NET Framework 2.0, so it can be used with all newer versions of the .NET Framework. +For other builds, see the [Releases](https://github.com/MachineCognitis/C.math.NET/releases) page. + +- [C.math.NET.v1.1.build.zip](https://github.com/MachineCognitis/C.math.NET/releases/download/v1.1/C.math.NET.v1.1.build.zip). + +**NOTE**: On some systems, the content of the ZIP file may be blocked. To unblock it, right click on the +ZIP file, select Properties, and click on the Unblock button, if it is present. + +### Making a Donation + +You can make a donation to support this project by clicking on the PayPal Donate button below. +PayPal guarantees your privacy and security. I will not receive any details about your payment +other than the amount, and your name. + +PayPal - The safer, easier way to pay online! + +Thanks to those who have made a donation. This is much appreciated! + +### Sharing + +
+ + + Email + + + + Facebook + + + + Google + + + + LinkedIn + + + + Twitter + +
+ + diff --git a/docs/Gmp.Native.chm b/docs/Gmp.Native.chm new file mode 100644 index 0000000..c27ef77 Binary files /dev/null and b/docs/Gmp.Native.chm differ diff --git a/docs/SearchHelp.aspx b/docs/SearchHelp.aspx new file mode 100644 index 0000000..6e2a17b --- /dev/null +++ b/docs/SearchHelp.aspx @@ -0,0 +1,233 @@ +<%@ Page Language="C#" EnableViewState="False" %> + + diff --git a/docs/SearchHelp.inc.php b/docs/SearchHelp.inc.php new file mode 100644 index 0000000..b905e13 --- /dev/null +++ b/docs/SearchHelp.inc.php @@ -0,0 +1,173 @@ +filename = $file; + $this->pageTitle = $title; + $this->rank = $rank; + } +} + + +/// +/// Split the search text up into keywords +/// +/// The keywords to parse +/// A list containing the words for which to search +function ParseKeywords($keywords) +{ + $keywordList = array(); + $words = preg_split("/[^\w]+/", $keywords); + + foreach($words as $word) + { + $checkWord = strtolower($word); + $first = substr($checkWord, 0, 1); + if(strlen($checkWord) > 2 && !ctype_digit($first) && !in_array($checkWord, $keywordList)) + { + array_push($keywordList, $checkWord); + } + } + + return $keywordList; +} + + +/// +/// Search for the specified keywords and return the results as a block of +/// HTML. +/// +/// The keywords for which to search +/// The file list +/// The dictionary used to find the words +/// True to sort by title, false to sort by +/// ranking +/// A block of HTML representing the search results. +function Search($keywords, $fileInfo, $wordDictionary, $sortByTitle) +{ + $sb = "
    "; + $matches = array(); + $matchingFileIndices = array(); + $rankings = array(); + + $isFirst = true; + + foreach($keywords as $word) + { + if (!array_key_exists($word, $wordDictionary)) + { + return "Nothing found"; + } + $occurrences = $wordDictionary[$word]; + + $matches[$word] = $occurrences; + $occurrenceIndices = array(); + + // Get a list of the file indices for this match + foreach($occurrences as $entry) + array_push($occurrenceIndices, ($entry >> 16)); + + if($isFirst) + { + $isFirst = false; + foreach($occurrenceIndices as $i) + { + array_push($matchingFileIndices, $i); + } + } + else + { + // After the first match, remove files that do not appear for + // all found keywords. + for($idx = 0; $idx < count($matchingFileIndices); $idx++) + { + if (!in_array($matchingFileIndices[$idx], $occurrenceIndices)) + { + array_splice($matchingFileIndices, $idx, 1); + $idx--; + } + } + } + } + + if(count($matchingFileIndices) == 0) + { + return "Nothing found"; + } + + // Rank the files based on the number of times the words occurs + foreach($matchingFileIndices as $index) + { + // Split out the title, filename, and word count + $fileIndex = explode("\x00", $fileInfo[$index]); + + $title = $fileIndex[0]; + $filename = $fileIndex[1]; + $wordCount = intval($fileIndex[2]); + $matchCount = 0; + + foreach($keywords as $words) + { + $occurrences = $matches[$word]; + + foreach($occurrences as $entry) + { + if(($entry >> 16) == $index) + $matchCount += $entry & 0xFFFF; + } + } + + $r = new Ranking($filename, $title, $matchCount * 1000 / $wordCount); + array_push($rankings, $r); + + if(count($rankings) > 99) + break; + } + + // Sort by rank in descending order or by page title in ascending order + if($sortByTitle) + { + usort($rankings, "cmprankbytitle"); + } + else + { + usort($rankings, "cmprank"); + } + + // Format the file list and return the results + foreach($rankings as $r) + { + $f = $r->filename; + $t = $r->pageTitle; + $sb .= "
  1. $t
  2. "; + } + + $sb .= "rank - $x->rank; +} + +function cmprankbytitle($x, $y) +{ + return strcmp($x->pageTitle, $y->pageTitle); +} + +?> diff --git a/docs/SearchHelp.php b/docs/SearchHelp.php new file mode 100644 index 0000000..eaa1e11 --- /dev/null +++ b/docs/SearchHelp.php @@ -0,0 +1,58 @@ + + Nothing found + $val) + { + $wordDictionary[$ftiWord] = $val; + } + } + } + } + + // Perform the search and return the results as a block of HTML + $results = Search($keywords, $fileList, $wordDictionary, $sortByTitle); + echo $results; +?> \ No newline at end of file diff --git a/docs/Web.Config b/docs/Web.Config new file mode 100644 index 0000000..26672e8 --- /dev/null +++ b/docs/Web.Config @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/WebKI.xml b/docs/WebKI.xml new file mode 100644 index 0000000..ba25330 --- /dev/null +++ b/docs/WebKI.xml @@ -0,0 +1,1142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/WebTOC.xml b/docs/WebTOC.xml new file mode 100644 index 0000000..4bb5f33 --- /dev/null +++ b/docs/WebTOC.xml @@ -0,0 +1,708 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/docs.projitems b/docs/docs.projitems new file mode 100644 index 0000000..80c34cf --- /dev/null +++ b/docs/docs.projitems @@ -0,0 +1,461 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 71f0daac-bc93-44f3-a717-11eff0bad683 + + + docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/docs.shproj b/docs/docs.shproj new file mode 100644 index 0000000..df33dca --- /dev/null +++ b/docs/docs.shproj @@ -0,0 +1,13 @@ + + + + 39b1e62e-d491-495f-8e90-b7d09b76d8a1 + 14.0 + + + + + + + + diff --git a/docs/fti/FTI_100.json b/docs/fti/FTI_100.json new file mode 100644 index 0000000..478d6d5 --- /dev/null +++ b/docs/fti/FTI_100.json @@ -0,0 +1 @@ +{"default":[1,196610,589825,1835009,2490371,3145730,3670017,3735555,3801089,3866626,4259844,5505026,5963779,7929858,8060930,8126465,8388610,8912898,9306117,9830402,10027010,11665410,12451842,12713986,12845058,13172738,13303811,14483458,15007745,15335427,18087938,18415618,18612226,21561347,24051714,24182787,25493507,25427970,25886722,27328514,27918337,28114946,29163522,30539779,31850498,32899074,34930690,35323906,37748738,37879810,38928387,40566786,40632322,41353218],"determining":[7864321,11599873,41091073],"details":[13303809,30867457],"divisor":[5898241,5963783,7733249,7929858,8126466,10616833,11403270,12845058,13041667,13893633,15335431,17956866,19529729,20971523,21626881,24379393,25231362,37289988],"dll":[196609,262145,393217,458753,524289,589825,655361,786433,851969,917505,983041,1114113,1179649,1245185,1310721,1376257,1441793,1507329,1572865,1638401,1835009,1966081,2031617,2097153,2162689,2228225,2293761,2359297,2424833,2490369,2555905,2686977,2818049,2883585,2949121,3014657,3080193,3145729,3211265,3276801,3342337,3407873,3538945,3604481,3670017,3735553,3866625,3932161,3997697,4063233,4128769,4194305,4259841,4325377,4456449,4521985,4587521,4653057,4718593,4784129,4849665,4980737,5046273,5111809,5177345,5242881,5373953,5439489,5505025,5570561,5636097,5701633,5767169,5832705,5898241,6029313,6160385,6225921,6356993,6488065,6553601,6619137,6684673,6750209,6815745,6881281,7012353,7077889,7143425,7208961,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7798785,7864321,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8519681,8650753,8716289,8781825,8847361,8912897,8978433,9043969,9175041,9240577,9306113,9371649,9437185,9502721,9568257,9633793,9699329,9764865,9830401,9895937,9961473,10027009,10092545,10158081,10223617,10289153,10354689,10420225,10485761,10551297,10616833,10682369,10747905,10813441,10878977,10944513,11010049,11075585,11206657,11272193,11337729,11403265,11468801,11534337,11665409,11730945,11796481,11862017,11927553,11993089,12058625,12124161,12189697,12255233,12320769,12386305,12451841,12582913,12648449,12713985,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13434881,13500417,13565953,13631489,13762561,13828097,13893633,13959169,14024705,14155777,14221313,14286849,14352385,14417921,14483457,14548993,14614529,14680065,14745601,14811137,14942209,15007745,15073281,15138817,15204353,15269889,15335425,15466497,15532033,15597569,15663105,15728641,15794177,15859713,15925249,15990785,16056321,16121857,16187393,16318465,16384001,16449537,16515073,16580609,16646145,16711681,16777217,16842753,16908289,16973825,17039361,17104897,17170433,17235969,17301505,17367041,17432577,17498113,17563649,17629185,17694721,17760257,17825793,17891329,17956865,18022401,18087937,18153473,18219009,18284545,18350081,18415617,18546689,18612225,18743297,18808833,18874369,19005441,19070977,19136513,19202049,19333121,19398657,19464193,19529729,19595265,19660801,19726337,19791873,19857409,19922945,19988481,20054017,20119553,20185089,20250625,20316161,20381697,20447233,20512769,20578305,20643841,20709377,20774913,20840449,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21364737,21430273,21495809,21561345,21626881,21692417,21757953,21823489,21954561,22020097,22085633,22151169,22216705,22282241,22347777,22478849,22544385,22675457,22740993,22806529,22872065,22937601,23003137,23134209,23265281,23330817,23396353,23461889,23592961,23658497,23724033,23855105,23920641,23986177,24051713,24117249,24182785,24313857,24444929,24510465,24576001,24707073,24379393,24838145,24903681,24969217,25034753,25100289,25165825,25231361,25296897,25362433,25427969,25493505,25559041,25624577,25690113,25755649,25821185,25886721,25952257,26017793,26083329,26148865,26214401,26279937,26411009,26476545,26542081,26607617,26673153,26738689,26804225,26869761,26935297,27000833,27066369,27131905,27197441,27262977,27328513,27394049,27459585,27525121,27590657,27656193,27721729,27852801,27918337,27983873,28049409,28114945,28180481,28246017,28311553,28377089,28442625,28508161,28573697,28639233,28704769,28770305,28835841,28901377,28966913,29032449,29097985,29163521,29229057,29294593,29360129,29425665,29556737,29622273,29687809,29753345,29818881,29884417,29949953,30015489,30081025,30146561,30212097,30277633,30343169,30408705,30474241,30539777,30605313,30670849,30736385,30801921,30867457,30998529,31064065,31129601,31195137,31260673,31391745,31457281,31522817,31653889,31784961,31850497,31916033,31981569,32047105,32112641,32178177,32243713,32374785,32440321,32505857,32636929,32702465,32833537,32899073,32964609,33030145,33095681,33161217,33226753,33292289,33357825,33423361,33488897,33554433,33619969,33685505,33751041,33816577,33882113,33947649,34013185,34078721,34144257,34209793,34275329,34340865,34471937,34537473,34603009,34668545,34799617,34865153,34930689,34996225,35061761,35192833,35258369,35323905,35389441,35454977,35520513,35651585,35717121,35782657,35848193,35913729,35979265,36044801,36110337,36175873,36241409,36306945,36372481,36438017,36503553,36569089,36634625,36700161,36765697,36831233,36896769,36962305,37027841,37093377,37158913,37224449,37289985,37355521,37421057,37486593,37552129,37617665,37683201,37748737,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38273025,38338561,38404097,38469633,38535169,38600705,38666241,38731777,38797313,38862849,38928385,38993921,39059457,39124993,39190529,39256065,39321601,39387137,39452673,39518209,39583745,39649281,39714817,39780353,39845889,39976961,40108033,40173569,40239105,40304641,40370177,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41091073,41156609,41222145,41287681,41353217,41418753],"divisible":[5963779,12320774,13369347,15335427,17301510],"decrease":[5701633],"desired":[1835009,24576001,40173569],"decreasingly":[5963777,15335425,20905985],"documentation":[15335425,34406401],"dependent":[18415617,21102593,35192833],"distance":[5963778,12910597,15335426,28966916],"default_allocate":[9306118],"difference":[5963778,15335426,36569094,37748737],"defines":[13041665,16908289],"dbl":[4128774,6619142,8323078,14024710,21692422,32833542],"degenerate":[35061761],"direct":[12976129,13828097,15859713,27394049],"dividend":[5963777,11403270,15335425,25231361],"decreasing":[1245185],"divide":[5111811,5963786,7929858,8126466,9240577,12845058,15335434,19791874,25231361,26607617,27721729,28573697,34209793,36044802,40501249],"denominator":[983041,1376257,2293761,2621441,3932162,5963783,7077889,7143428,7340033,8192001,8978433,9240577,11206657,11862017,11927553,12320769,12386305,13369345,13828105,14352385,15335431,15466497,16842753,17301505,19005441,19333121,19660801,20381697,20709377,21626881,21954561,22085633,24969217,24379393,26935297,25231361,27197441,27394055,28704769,28770305,32964609,33947649,34078721,34668546,35520514,36241409,36306945,36438017,36634625,37814273,38207489,39649281],"destroy":[21168129],"divides":[5963778,7340033,11206657,15335426,19791873,31260674,36044801,37289985],"double":[393222,1310721,1638402,3735553,3997701,4128771,4784132,5177345,5963782,6619139,7274497,7602178,8257537,8323075,9502721,10354690,13172741,13303809,14024707,14483457,15335430,17235969,18415623,18612225,20250630,20447233,21102598,21037057,21561345,21692419,22020101,22413313,23265281,24707074,24444929,25165825,24903681,25690113,27852806,28114945,28246017,29687809,30277633,30539780,30867457,31064065,32833539,34930689,35192840,35323909,36306945,37355522,37421058,37748737,38928385,39518209,40108037,40763393,41287681],"determined":[8781825,24444929,40173569],"definitely":[14155778,29884417,39845889],"determines":[6291457,7864321,11141121,13434881,15007745,15400961,16842753,21430273,22282241,23199745,29884417,31588353,34603009,35127297,39845889,40042497],"destination":[5177345,7274497,9502721,16121858,17235969,20447233,21037057,22020097,25165825,24903681,30867457,38666242,40108033,40173569,40697858,41287681],"define":[19529731,37289985],"den2":[983050,5963778,11927562,15335426],"device":[29884417,39845889],"digit":[27328513,34537473],"delegate":[6881285,32702469,34406401,37093381],"don":[1835009,3670017,4128769,6619137,8323073,14024705,21692417,30015489,32833537],"denorm":[18415617,35192833],"divisions":[14155777],"definition":[6356993,24444929,30408705],"determine":[5963779,8978433,10682369,14155777,15138817,15335427,22478849,27000833,33423361],"doesn":[5111809,7536641,26607617,27721729,29360129,35061762,38338561,41091073],"directcast":[14417921,29032449],"designed":[2555905,7012353,24576001,29556737,31195137],"discard":[40173569],"dfd1c04p":[7667714,15794178,16318466,17039362,21757954,29360130,33161218,38338562],"depending":[5046273,7012353,31195137],"described":[19529729],"data":[2097153,3080193,5963778,7012353,15335426,18022401,21823504,29884417,31195137,34471937,34865153,39845889,40173582,41091073],"dim":[196610,393217,524290,851969,983041,1114118,1245188,1310721,1376258,1507331,1966081,2097153,2162692,2293762,2424835,2490369,2555906,2818049,2883588,3014657,3145729,3276806,3342337,3407874,3538946,3735554,3866626,3997697,4128774,4325380,4718594,4784129,5046276,5111811,5177345,5439489,5505026,5570562,5636097,5701635,5832706,5898245,6356993,6488066,6619142,6815748,7012357,7077889,7143426,7274498,7340035,7405569,7536641,7602177,7667717,7733251,7929858,7995395,8060931,8192004,8257538,8323080,8388610,8650754,8781827,8912897,8978435,9043973,9306123,9502722,9568257,9699329,9830402,9895937,9961475,10027010,10158084,10223617,10289155,10354690,10420225,10616833,10682370,11206658,11272193,11337731,11665409,11730945,11862019,11927553,12058625,12124161,12255234,12320770,12386307,12451841,12648450,12713986,12845059,12910594,12976130,13041667,13107202,13172737,13238274,13303810,13369345,13500419,13828098,13893634,13959169,14024712,14155777,14286852,14417921,14483458,14548995,14745601,14811138,15138817,15466499,15532033,15597570,15728644,15794181,15859714,15925250,16056321,16121860,16187395,16318469,16384002,16449537,16777220,16908289,17039366,17235971,17301505,17629185,17694723,17825793,17956865,18022401,18087939,18350083,18415617,18612225,18743303,18808833,18874372,19005442,19070978,19333122,19529736,19660802,19791876,19988482,20250627,20316164,20381699,20447233,20512772,20578306,20709380,20774914,20905987,20971521,21037057,21102593,21168131,21233667,21299202,21561345,21626882,21692422,21757957,21954563,22020097,22085633,22347777,22478849,22675458,22740997,22806531,23265282,23396353,23658497,23986178,24051714,24117252,21823491,24313857,24510466,24576004,24707073,24444930,24838145,24969218,25034756,25362433,25559046,25427970,24379395,25821185,25165825,25886722,26017795,26083329,24903682,26279937,26411012,26476546,26607620,26673154,26738690,25690114,25493505,26935298,27000834,25231366,27197442,27328515,27394050,27590658,27656193,27721731,27852801,28114946,28246018,28311555,28377089,28573700,28704770,28770307,28966914,29032449,29097986,29229058,29294594,29360133,29425666,29556738,29622273,29687809,29753346,29884417,30015492,30146561,30277634,30408705,30474243,30539777,30605313,30736386,30867459,30998531,31064065,31195141,31260675,31522819,31850497,32112643,32178177,32374788,32440321,32505857,32833542,32899075,32964611,27066373,33161222,33357825,33423361,33751044,33882114,33947652,34078724,34209793,34275335,34865153,34930689,34996228,35061763,35192833,35323906,35389443,35454980,35717121,35979265,36044804,36241410,36306946,36438019,36503553,36634625,36962307,37289989,37355522,37421057,37617667,37748739,37814274,37879810,37945349,38010883,38076419,38141958,38207491,38338565,38404098,38469637,38600705,38666244,38797315,38928385,38993924,39059457,39124993,39256067,39387138,39518209,39583745,39649282,39714820,39780357,39845890,40108033,40173573,40370177,40501252,40566786,40632322,40697859,40763394,40894465,41025538,41156612,41222145,41287682,41353218],"distributed":[524289,2097153,5963780,15335428,18022401,19988481,20774913,30736385],"den":[13828104,27394062,34078721,36306945],"delete":[1245188,8781828,8978436,11337732,18874372,22806532,34078724,39976962],"dev":[29884417,39845889],"detects":[22413313],"discarded":[8978433],"decimal":[1179649,8781827,8978433,14352385,17235969,22806529,24444931,32243713,35520513,39976962],"division":[1376257,2293761,7077889,7340033,7733251,7929858,8126466,8192001,10616835,11206657,11862017,12320770,12386305,12845058,13369345,13893634,15466497,17301506,19005441,19333121,19529729,19660801,19791873,20381697,20709377,21626881,21954561,22085633,24969217,25034753,24379393,26935297,27197441,28704769,28770305,32964609,33947649,36044801,36241409,36438017,36634625,37814273,38207489,39649281],"digits":[5963785,8978433,15335433,15925252,18874372,22478850,27328520,27066369,34078721,34537473,36306945,39059458,39976966],"destroyed":[5898241,15073281,19529730],"diagram":[41091074],"different":[1441793,4063233,4456449,5963777,12910594,13631489,13697025,15335425,16252929,19595266,22478850,22609921,23068673,23330818,23789569,27262978,27787265,28442626,28966913,29491201,29818882,29884417,29949954,30801922,31653889,33685506,34013185,34537473,34734081,35782657,39845889,40632323],"dst":[33554437],"defining":[2555905,29556737],"default_reallocate":[9306118],"decremented":[29229058,31522818],"description":[131073,327681,720897,1048577,1441796,1703937,1769473,1900545,2621441,2752513,3473409,3801089,4063235,4390913,4456451,4915201,5308417,5963777,6094849,6291457,6422529,6946817,7864324,8585217,9109505,11141121,11599873,12517377,12779521,13434883,13631491,13697025,14090241,14876673,15007747,15335427,15400961,16252929,16842756,18481153,18677761,18939905,19267585,21430276,21889025,22282243,22609921,23068673,23199745,23527425,23789569,24248321,24772609,24641537,26345473,27787265,29491201,30932993,31326209,31588353,31653891,31719425,32309249,32571393,32768001,34013187,34406403,34537475,34603010,34734081,35127297,35586049,35782659,39911425,40042497,40435713],"defined":[3538945,8650753,15007745,19529731,29753345],"declaration":[262145,786433,1179649,1572865,2228225,3604481,4194305,4849665,5767169,6225921,6684673,6750209,7208961,8716289,8847361,9371649,9437185,9633793,10551297,10878977,10944513,11534337,11796481,12582913,13565953,14352385,14614529,14942209,15663105,15990785,16515073,16580609,16646145,16711681,16973825,17170433,17367041,17498113,17563649,17760257,18153473,18219009,19202049,19398657,20643841,20840449,21364737,21495809,22544385,22937601,23003137,23461889,23855105,23920641,25100289,25296897,26214401,26542081,26804225,28180481,30081025,31129601,31457281,31981569,32243713,33226753,33488897,34799617,35258369,35651585,36175873,36372481,36765697,37027841,37224449,37486593,38273025,38535169,38731777,38862849,39190529,40239105,40304641],"delegates":[34406401],"developed":[40501249],"default_free":[9306118]} \ No newline at end of file diff --git a/docs/fti/FTI_101.json b/docs/fti/FTI_101.json new file mode 100644 index 0000000..15ae76c --- /dev/null +++ b/docs/fti/FTI_101.json @@ -0,0 +1 @@ +{"examples":[196609,393217,524289,589825,851969,983041,1114113,1245185,1310721,1376257,1507329,1638401,1966081,2097153,2162689,2293761,2424833,2490369,2555905,2818049,2883585,3014657,3145729,3276801,3342337,3407873,3538945,3735553,3866625,3932161,3997697,4128769,4259841,4325377,4718593,4784129,5046273,5111809,5177345,5242881,5439489,5505025,5570561,5636097,5701633,5832705,5898241,6356993,6488065,6619137,6815745,7012353,7077889,7143425,7274497,7340033,7405569,7536641,7602177,7667713,7733249,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8650753,8781825,8912897,8978433,9043969,9240577,9306113,9502721,9568257,9699329,9830401,9895937,9961473,10027009,10158081,10223617,10289153,10354689,10420225,10616833,10682369,11206657,11272193,11337729,11403265,11665409,11730945,11862017,11927553,12058625,12124161,12255233,12320769,12386305,12451841,12648449,12713985,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13500417,13828097,13893633,13959169,14024705,14155777,14286849,14417921,14483457,14548993,14745601,14811137,15073281,15138817,15466497,15532033,15597569,15728641,15794177,15859713,15925249,16056321,16121857,16187393,16318465,16384001,16449537,16777217,16908289,17039361,17235969,17301505,17629185,17694721,17825793,17956865,18022401,18087937,18284545,18350081,18415617,18612225,18743297,18808833,18874369,19005441,19070977,19333121,19529729,19660801,19791873,19988481,20250625,20316161,20381697,20447233,20512769,20578305,20709377,20774913,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21561345,21626881,21692417,21757953,21954561,22020097,22085633,22347777,22478849,22675457,22740993,22806529,23265281,23396353,23592961,23658497,23986177,24051713,24117249,21823489,24182785,24313857,24510465,24576001,24707073,24444929,24838145,24969217,25034753,25362433,25559041,25427969,24379393,25821185,25165825,25886721,26017793,26083329,24903681,26279937,26411009,26476545,26607617,26673153,26738689,25690113,25493505,26935297,27000833,25231361,27197441,27328513,27394049,27590657,27656193,27721729,27852801,28114945,28246017,28311553,28377089,28573697,28704769,28770305,28966913,29032449,29097985,29229057,29294593,29360129,29425665,29556737,29622273,29687809,29753345,29884417,30015489,30146561,30277633,30408705,30474241,30539777,30605313,30736385,30867457,30998529,31064065,31195137,31260673,31522817,31850497,32112641,32178177,32374785,32440321,32505857,32833537,32899073,32964609,33095681,27066369,33161217,33357825,33423361,33751041,33882113,33947649,34078721,34209793,34275329,34340865,34865153,34930689,34996225,35061761,35192833,35323905,35389441,35454977,35520513,35717121,35979265,36044801,36241409,36306945,36438017,36503553,36569089,36634625,36831233,36962305,37289985,37355521,37421057,37617665,37748737,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38338561,38404097,38469633,38600705,38666241,38797313,38928385,38993921,39059457,39124993,39256065,39387137,39518209,39583745,39649281,39714817,39780353,39845889,39976961,40108033,40173569,40370177,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41156609,41222145,41287681,41353217],"easily":[19529729],"equal":[131074,655361,1048578,1441795,1703938,1769474,1900546,4063235,4456451,4915202,5963778,6094850,6291457,6946818,7274498,7733249,7798785,7864321,8519682,9175041,9764865,10616833,10682369,10747906,11141121,11993090,12779522,13238273,13434881,13631491,13697025,14221314,15007745,15335426,15400961,16121857,16252929,16842753,18677762,18939906,19136513,19857409,20185089,20250626,20578308,20774914,20971521,21430273,21889026,22282241,22609921,23068673,23199745,23789569,24641538,27000833,25231362,27131906,27787265,27983874,28049409,28508161,28639233,28835842,29491201,30015489,30343169,30670849,31260674,31588353,31653891,31719426,31784962,32571394,32636929,33816577,34013187,34537475,34603009,34734081,35127297,35586050,35782659,35848193,39321601,39780353,40042497],"extension":[851970,1966082,5963781,15335429,15597570,28377090,32440322],"exceptions":[7929858,8126466,12845058],"ending":[15007745],"expected":[1114114,1507330,2162690,2883586,3276802,4325378,5111810,5898242,6815746,7012354,8781825,9043970,9961474,13238274,14286850,15073281,16121858,16777218,18350082,18743298,19529730,19791874,20316162,20905986,22740994,24444929,25034754,25559042,26411010,25231362,28573698,29294594,30015490,30998530,31195138,32374786,33751042,34275330,34996226,35454978,36044802,37945346,38141954,38469634,38666242,38993922,39059458,39714818,39780354,40501250,40697858,41156610],"exponentiation":[16449537,24576001,26607617,27590657,27721729],"error":[1245185,8781825,11337729,12189697,12517377,13303809,15335425,15728641,17039361,18874369,20512769,22806529,30867458,33161217,34078721,39976961],"exceptional":[37289985],"explicit":[786434,1572866,2228226,4194306,4849666,5767170,6225922,6750210,7208962,8716290,9437186,9633794,10878978,10944514,11534338,11796482,14942210,15990786,16515074,16711682,16973826,17170434,17367042,17498114,17563650,18153474,18219010,19202050,19398658,22937602,23003138,23920642,25296898,26804226,28180482,30081026,31129602,31457282,31981570,33226754,34799618,35258370,36765698,37027842,37486594,38273026,38535170,38731778,39190530,40304642],"expecting":[5111809,5963779,15335427,19791873,36044801],"exchange":[34996226],"element":[21823489],"exists":[7733249,10616833,12320769,13369345,13893633,15073282,17301505,26607617,27721729,28573697,35061762,40501249],"entry":[5963778,9961478,15335426,24576001],"equals":[131075,655368,1048580,1441795,1703939,1769476,1900547,4063235,4456451,4915203,6094852,6291457,6946820,7798790,7864321,9043969,9175048,9764872,11141121,12779524,13434881,13631491,15007745,15400961,16842753,18677764,18939907,19136520,19857416,20185096,21430273,21889027,22282241,23199745,24641539,28049414,28508166,28639238,30343176,30670854,31588353,31653891,31719428,32571395,32636936,33816582,34013187,34537475,34603009,35127297,35586052,35782659,35848198,39321606,40042497],"equivalent":[1441793,4980738,12976129,13828097,15859713,18939905,26411009,27394049],"exp":[5963781,15335429,16449542,20250638,24576021,26607637,27328518,27590662,27721735,35323920,36503559],"exported":[40173569],"enumerator":[13434881,35127297,36110338],"examined":[8978433],"efficiency":[7864321,13631489,34013185],"exponent":[1179649,5963778,7864321,8781827,11599873,13369345,13893633,15335426,16449537,18415617,19660801,20250627,21102593,24576001,24444932,26607617,26935297,27197441,27328515,27590657,27721729,34013185,34406401,35192833,35323906,36241409,36503556,37814273,39649281,39976962,41091074],"entries":[5963777,9961474,15335425],"equality":[1441793,4063233,4456449,8519681,10747905,11993089,13631489,13697025,14221313,16252929,22609921,23068673,23789569,27131905,27787265,27983873,28835841,29491201,31653889,31784961,34013185,34537473,34734081,35782657],"endianness":[21823490,40173570],"example":[196610,393218,524290,589826,851970,983042,1114114,1245186,1310722,1376258,1507330,1638402,1966082,2097154,2162690,2293762,2424834,2490370,2555906,2818050,2883586,3014658,3145730,3276802,3342338,3407874,3538946,3735554,3866626,3932162,3997698,4128770,4259842,4325378,4718594,4784130,5046274,5111810,5177346,5242882,5439490,5505026,5570562,5636098,5701634,5832706,5898242,6356994,6488066,6619138,6815746,7012354,7077890,7143426,7274498,7340034,7405570,7536642,7602178,7667714,7733250,7929858,7995394,8060930,8126466,8192002,8257538,8323074,8388610,8650754,8781826,8912898,8978434,9043970,9240578,9306114,9502722,9568258,9699330,9830402,9895938,9961474,10027010,10158082,10223618,10289154,10354690,10420226,10616834,10682370,11206658,11272194,11337730,11403266,11665410,11730946,11862018,11927554,12058626,12124162,12255234,12320770,12386306,12451842,12648450,12713986,12845058,12910594,12976130,13041666,13107202,13172738,13238274,13303810,13369346,13500418,13828098,13893634,13959170,14024706,14155778,14286850,14417922,14483458,14548994,14745602,14811138,15073282,15138818,15466498,15532034,15597570,15728642,15794178,15859714,15925250,16056322,16121858,16187394,16318466,16384002,16449538,16777218,16908290,17039362,17235970,17301506,17629186,17694722,17825794,17956866,18022402,18087938,18284546,18350082,18415618,18612226,18743298,18808834,18874370,19005442,19070978,19333122,19529730,19660802,19791874,19988482,20250626,20316162,20381698,20447234,20512770,20578306,20709378,20774914,20905986,20971522,21037058,21102594,21168130,21233666,21299202,21561346,21626882,21692418,21757954,21954562,22020098,22085634,22347778,22413313,22478850,22675458,22740994,22806530,23265282,23396354,23592962,23658498,23986178,24051714,24117250,21823492,24182786,24313858,24510466,24576002,24707074,24444930,24838146,24969218,25034754,25362434,25559042,24379394,25427970,25821186,25165826,25886722,26017794,26083330,24903682,26279938,26411010,26476546,26607618,26673154,26738690,25690114,25493506,26935298,27000834,25231362,27197442,27328515,27394050,27590658,27656194,27721730,27852802,28114946,28246018,28311554,28377090,28573698,28704770,28770306,28966914,29032450,29097986,29229058,29294594,29360130,29425666,29556738,29622274,29687810,29753346,29884418,30015490,30146562,30277634,30408706,30474242,30539778,30605314,30736386,30867458,30998530,31064066,31195138,31260674,31522818,31850498,32112642,32178178,32374786,32440322,32505858,32833538,32899074,32964610,33095682,27066370,33161218,33357826,33423362,33751042,33882114,33947650,34078722,34209794,34275330,34340866,34865154,34930690,34996226,35061762,35192834,35323906,35389442,35454978,35520514,35717122,35979266,36044802,36241410,36306946,36438018,36503554,36569090,36634626,36831234,36962306,37289986,37355522,37421058,37617666,37748738,37814274,37879810,37945346,38010882,38076418,38141954,38207490,38338562,38404098,38469634,38600706,38666242,38797314,38928386,38993922,39059458,39124994,39256066,39387138,39518210,39583746,39649282,39714818,39780354,39845890,39976962,40108034,40173570,40370178,40501250,40566786,40632322,40697858,40763394,40828930,40894466,40960002,41025538,41091073,41156610,41222146,41287682,41353218],"export":[21823489,40173571],"endian":[1245185,21823494,33030146,40173574],"exist":[5963777,15335425,26607617,27721729,30408706,35061762],"efficiently":[3407873,5963779,15335427,23265281,25690113],"extremely":[21299201],"empty":[27328513],"expptr":[27328518],"enb":[5963777,15335425,25755653,34275336],"earlier":[19529729],"extra":[5046273,15925249,19529729,22478849,33030145,27066369,36306945],"easy":[29884417,39845889],"end":[1441793,4063233,4456449,5832705,7864321,9306115,10223618,12058626,13434881,13631489,15007745,15335425,16187393,16842753,19529729,21430273,22282241,26476545,31653889,34013185,34537473,34603009,35782657],"entire":[2162689,9961473,13303809,17235969,18743297,24444929,35520513],"exclusive":[2883585,5963779,6815745,15335427,38797315],"excluding":[7667713,15794177,16318465,21757953,29360129,38338561],"exact":[3997697,5963778,6488065,15335426,19529729,22478850,39059458,40763393],"exposes":[131073,1441793,1703937,1900545,2621441,3473409,4063233,4390913,4456449,4915201,5963777,6291457,6422529,7864321,9109505,11141121,11599873,12517377,13434881,13631489,13697025,14090241,14876673,15007745,15335425,15400961,16252929,16842753,18939905,19267585,21430273,21889025,22282241,22413313,22609921,23068673,23199745,23527425,23789569,24641537,27787265,29491201,30932993,31588353,31653889,32571393,34013185,34537473,34603009,34734081,35127297,35782657,39911425,40042497,40435713],"established":[589825,2490369],"exponents":[7864321,34013185,41091073],"exactly":[5111810,5963782,7733249,10616833,12320770,13369346,15335430,15925249,17301506,19791874,27328513,36044802,36306945],"exceeding":[15794177,21757953],"efficient":[40632321]} \ No newline at end of file diff --git a/docs/fti/FTI_102.json b/docs/fti/FTI_102.json new file mode 100644 index 0000000..8b6faf0 --- /dev/null +++ b/docs/fti/FTI_102.json @@ -0,0 +1 @@ +{"fit":[3014658,5439490,9568258,9895938,14745602,15532034,17629186,18415617,20971523,27656194,30605314,32178178,33357826,35192833,38600706,41222146],"feature":[21823489],"framework":[22413313],"formatted":[4128771,6619139,7667715,8323075,14024707,15728643,15794179,16318467,17039363,20512771,21692419,21757955,29360131,32833539,33161219,38338563],"filename":[8323074,14024706],"fall":[41091073],"failing":[40632321],"following":[131073,1441793,1703937,1900545,2621441,3473409,4063233,4390913,4456449,4915201,5963777,6291457,6422529,7733249,7864321,9109505,10616833,11141121,11599873,12320769,12517377,13434881,13631489,13697025,14090241,14876673,15007745,15335425,15400961,16252929,16842753,17301505,18939905,19267585,21299202,21430273,21889025,22282241,22609921,23068673,23199745,23527425,23789569,24641537,27787265,29491201,30932993,31588353,31653889,32571393,34013185,34537473,34603009,34734081,35127297,35782657,39911425,40042497,40173569,40435713],"free":[524290,1114114,1507330,1835009,2097154,2162690,2883586,3276802,3670023,4325378,5046276,5111810,5373953,5570562,5701636,5832706,5898242,5963788,6160385,6291457,6815746,7012354,7405570,7471105,7536642,7667714,7864321,8912897,9043970,9306118,9699330,9961474,10158092,11141121,12255234,12648450,13238274,13303810,13434881,13500418,13959169,14286850,15007745,15073281,15204353,15335436,15400961,15794178,15925250,16056322,16121858,16187394,16318466,16777218,16842753,17235972,17956866,18022402,18350082,18743298,19529730,19726343,19791874,19988482,20250626,20316162,20774914,20905986,21168130,21233666,21430273,21757954,22282241,22740994,22872065,23199745,23658498,24117250,21823492,24444930,25034754,25362434,25559042,26279938,26345478,26411010,26476546,26869761,25493506,25231362,27328514,28573698,28966914,29294594,29360130,29884418,30015490,30146562,30474241,30736386,30867460,30998530,31195138,31391751,31588353,32047111,32374786,32505857,27066372,33619969,33751042,34209794,34275330,34603009,34865154,34996226,35127297,35389441,35454978,35520514,36044802,36306946,36503554,36962305,37158919,37552129,37945346,38141954,38338562,38404098,38469634,38666242,38993922,39059458,39256068,39387138,39714818,39780354,39845890,40042497,40173572,40370178,40501250,40697858,41156610,41418753],"form":[5963782,7667713,8781825,8978434,10420225,15335431,15794177,16318465,21757953,24444929,29360129,34078721,35520513,36306945,38338561,40435713],"first":[393217,851969,983041,1114113,1179649,1638401,1966081,2162689,2424833,2883585,3276801,3407873,3538945,4259841,4325377,4587521,5111809,5505025,5898241,6488065,6815745,7012353,7602177,7667713,7929857,7995393,8060929,8126465,8650753,8978433,9043969,10223619,10289153,10354689,10682369,11272193,11403265,11927553,12058627,12713985,12845057,12910593,13041665,13107201,13172737,13238273,14286849,14483457,14548993,14811137,15073281,15597569,16121858,16318465,16777217,17694721,17956865,18087937,18284545,18612225,18743297,18808833,19529729,20316161,20578305,20971521,22675457,22740993,23265281,23592961,21823501,25034753,25559041,25755649,25427969,25886721,25952257,26017793,26083329,26148865,25690113,27000833,27328513,27852801,28114945,28377089,28966913,29229057,29425665,29622273,29753345,30015489,30998529,31195137,31522817,32374785,32440321,32899073,33751041,33882113,34209793,34275329,34340865,34930689,34996225,35061761,36569089,36700161,37289986,37355521,37421057,37748737,37879809,38010881,38076417,38141953,38469633,38666241,38797313,38993921,39714817,39780353,40173580,40566785,40828929,40894465,40960001,41025537],"filled":[5963777,15335425,33554434],"free_function":[6881285,9306124,10158088,34406401],"fibonacci":[2555906,5963777,15335425,17825797,25821186,29556741],"fields":[1441793,3473410,4128771,4456449,6619139,8323075,14024707,14090242,15007745,15335425,19267586,21692419,32833539,35782657,39911426,40435714],"fits":[3014658,5439490,5701633,5963788,9568258,14745602,15335436,15532034,17629186,27656194,30605314,32178177,33357826,34537473,35979268,38600706,39256065,41222146],"file":[131077,1245213,4128769,4456458,5963777,6619137,8323086,8781844,8978452,11337750,12779524,13697027,14024718,15335425,15728641,17039378,18874396,19267588,19595279,21692417,21757953,22806550,25624578,30343171,31784974,32833537,33161234,34078746,34406402,35848202,39452675,39976977],"friends":[1835009,3670017],"followed":[1179650],"fills":[5963777,15335425,33554433],"fail":[24444929],"free_func_ptr":[9306117,10158085],"fiddling":[2424833,5636097,10223617,10289153,12058625,12124161,12910593,16384001,22347777,23396353,38797313,39583745],"format":[1245186,4128769,5046273,5963778,6619137,7667713,8323073,11337729,14024705,15335426,15728641,15794177,16318465,17039361,20512769,21692417,21757953,21823489,29360129,32833537,33161217,38338561,40173569],"float":[196610,393217,589825,1310721,2490369,3014658,3145730,3735554,3866626,3997697,4784130,5439490,5505026,5963779,6291457,7864321,7929858,8060930,8126466,8257537,8388610,8781826,8912897,9830402,10027011,11665410,11730945,12451842,12713986,12845058,13172739,13303810,14483458,14745602,15335427,17629186,18087938,18415618,18612226,19922946,19988483,20250625,21102593,21561346,22020097,24051715,24444929,24838145,25427970,25886722,24903682,25690114,27852801,28114947,28246017,29097985,30277633,30539779,30605314,31064065,31850498,32899074,34930690,35192833,35323906,36503555,36831234,36962305,37748739,37879810,38600706,38928386,39518209,39976961,40108033,40566786,40632321,40763394,41353219],"fmt":[4128773,6619141,7667718,8323077,14024709,15728645,15794182,16318470,17039365,20512773,21692421,21757958,29360133,32833541,33161221,38338565],"factor":[5963777,15335425,31260674],"fnsub1":[5963777,15335425,29556760],"faster":[10682369,19791873,20578305,27000833,36044801],"function":[393217,458753,524289,655361,851969,917505,983041,1114113,1245185,1376257,1638401,1835010,1966081,2031619,2162689,2293761,2359297,2424833,2555905,2818049,2949121,3014657,3145729,3276802,3670017,4128769,4259841,4521987,4587523,4653057,4980737,5046273,5439489,5636098,5701634,5832705,5898241,5963789,6291457,6356993,6488065,6619137,7012354,7077889,7143425,7405569,7471105,7536642,7602177,7667713,7733249,7798785,7864321,8323073,8454145,8650753,8781826,8912897,8978433,9043971,9175041,9306124,9568257,9699329,9764865,9895937,9961473,10158084,10223618,10289153,10354689,10485761,10616833,10682369,11075585,11141121,11337729,11730945,11862017,11927553,12058626,12124161,12320769,12451841,12648450,12910594,12976129,13041665,13172737,13238273,13303810,13369345,13434881,13500417,13828097,13893633,13959169,14024705,14155778,14286849,14483457,14680065,14745601,15007746,15073283,15138817,15335437,15400961,15532033,15597569,15728641,15794177,15859713,15925250,16056321,16121858,16187395,16318465,16384001,16842753,16908289,17039361,17104897,17235970,17301505,17432577,17629185,17956865,18415617,18546689,18612225,18743299,18874369,19005441,19136513,19333121,19529729,19791873,19857409,19922945,19988481,20054017,20185089,20250626,20316162,20381697,20512769,20578306,20774913,20971521,21102593,21168130,21233666,21299201,21430273,21626881,21692417,21757953,22085633,22216705,22282241,22347777,22478850,22740995,22806529,23134211,23199745,23396354,23658498,24117250,24444932,24576004,24707073,24838145,24969217,25034754,25362433,25559042,25755651,25952259,26148867,26279938,25624577,26411009,26476545,26673153,27000833,27066369,27328514,27394049,27656193,27852801,28049409,28114945,28377089,28508161,28573697,28639233,28704769,28901377,28966913,29360131,29556737,29753345,30015491,30146562,30343169,30408705,30605313,30670849,30736386,30867458,31064065,31195138,31260673,31588353,31850497,31916033,32178178,32440321,32505857,32636929,32702465,32833537,32964609,33161217,33292289,33357825,33423361,33816577,34078721,34144257,34209793,34275329,34603009,34865153,34930689,35061762,35127297,35192833,35323906,35454978,35520513,35848193,35913729,35979265,36044801,36110337,36306946,36503553,36634625,36700163,36831233,36896769,37093377,37355521,37421057,37683201,37945345,38141953,38338563,38404097,38469633,38600705,38797313,39059457,39124994,39321601,39583745,39714817,39780354,39976961,40042497,40173570,40501249,41156610,41222145],"fully":[131073,4456449,32571393,35782657],"fast":[19791873,36044801,40370177],"functions":[851969,1114113,1507329,1835009,1966081,2031617,2097153,2162689,2555905,2883585,3014657,3145729,3276802,3342337,3670017,4128769,4259841,4325377,4521985,4587521,5046273,5111809,5439489,5832705,5898241,5963778,6619137,6815745,7012354,7143426,7405569,7536644,7667713,7733249,7864321,7929858,8126466,8323073,8454145,8650753,8978433,9043969,9306121,9568257,9699329,9961473,10027009,10158083,10616833,11272193,12320769,12648454,12845058,12976130,13041665,13238273,13500417,13828098,14024705,14155777,14286849,14745601,15073281,15138817,15335426,15532033,15597569,15728641,15794178,15859714,16056321,16121857,16187393,16318465,16777217,17039361,17301505,17629185,17825793,17956865,18022401,18350081,18743297,19529729,19791873,19988482,20316161,20512769,20905985,20971521,21168129,21233665,21299201,21692417,21757954,22413318,22478851,22740993,23134209,23658497,24051713,24117253,24313857,25034753,25362433,25559042,25755649,25821185,25952257,26148865,26279937,26411009,26476545,26673154,25231361,27394050,27656193,28377089,28573697,28966913,29294593,29360129,29425665,29556737,29687809,29753345,30015489,30146565,30605313,30736389,30998529,31195138,31260673,31850497,32374785,32440321,32833537,33030146,27066369,33161217,33357825,33423361,33751041,34013185,34209793,34275329,34996225,35061761,35323905,35454977,35520513,35979265,36044801,36503554,36700161,36831233,37289985,37945345,38076417,38141953,38338561,38469633,38600705,38666241,38993921,39059457,39124993,39256065,39714817,39780353,40501249,40697857,40894465,40960001,41156609,41222145,41353217],"floats":[589825,1310721,2490369,4259841,4784129,8257537,8781825,8912897,11730945,18415617,24182785,24444929,24838145,25690113,27328513,28246017,29097985,30277633,31850497,35323905,36831233,36962305,39518209,39976961,40632321],"fromintptr":[18546693,32571393,35782657],"factors":[983041,3932161,5963777,11927553,15335425,26083329,29622273],"frexp":[20250625,35323905],"floating":[196612,589827,1179649,1310722,2490370,2686977,3145730,3735556,3866628,4784130,5505028,6291457,7864324,7929860,8060934,8126466,8257540,8388612,8912898,9830404,10027012,11665410,11730946,12451842,12713988,12845062,13172738,13303810,14483460,18087942,18415618,18612226,21561346,24051716,24444930,24838146,25427972,25886724,25690116,27328514,28114948,28246018,29097986,30277634,30539778,31850498,32899078,33292290,34013186,34406402,34930690,35323906,36503554,36962310,37748742,37879812,38928386,39518210,40566788,40632322,41353220],"finalize":[6291457,7864321,11141121,13434881,15007745,15400961,16842753,21430273,22282241,23199745,31588353,34603009,35127297,40042497],"floor":[2293763,5963785,11862019,15335433,15466499,18743298,19333124,22085636,33947651,36438021,37814275,39649285,41353218],"follow":[1,22413313],"fetch":[33030145],"future":[4063233,13631489,34471937],"fraction":[5963778,8978434,15335426,27328513,31850497,35520514,36831233,40501249],"factorial":[3342337,5963779,15335427,29687809,40894465],"fat":[22413313],"fclose":[1245186,8323074,8781826,8978434,11337732,14024706,17039362,18874370,22806530,33161218,34078722,39976961],"functionality":[22282241,22413313,34406401],"field":[5963777,8454145,10420226,11010050,11468802,14417922,15335425,20119554,29032450,35717122,39452674],"formulas":[2555905,17825793,25821185,29556737],"fisrt":[8388609,19529729],"false":[655361,7012353,7798785,8519681,9175041,9764865,10747905,11993089,14221313,19136513,19595265,19857409,20185089,23330817,27131905,27262977,27983873,28049409,28442625,28508161,28639233,28835841,29818881,29949953,30343169,30670849,30801921,31195137,31784961,32636929,33685505,33816577,34996225,35848193,39124993,39321601],"foo":[8454145,16187393],"follows":[39976961]} \ No newline at end of file diff --git a/docs/fti/FTI_103.json b/docs/fti/FTI_103.json new file mode 100644 index 0000000..c4c4ef5 --- /dev/null +++ b/docs/fti/FTI_103.json @@ -0,0 +1 @@ +{"garbage":[6291457,7864321,11141121,13434881,15007745,15400961,16842753,21430273,22282241,23199745,31588353,34603009,35127297,40042497],"gmp_get_memory_functions":[5963777,9306117,10158087,15335425],"gmp_vsnprintf":[5963777,7667719,15335425,16318465],"gmp_version":[10420231,15335425,40435713],"generator":[524291,5373954,5570564,12255236,12648451,19988483,20774915,24117251,25493508,29884420,30736387,34406401,34603010,34865156,39845892,40370180],"gmp_vasprintf":[5963777,15335425,29360136,38338561],"grow":[16908289],"guess":[29884417,39845889],"gmp_lib":[196630,393231,524299,589840,851981,983055,1114132,1245195,1310737,1376282,1507336,1638412,1835012,1966093,2031619,2097161,2162708,2293785,2424857,2490387,2555917,2818063,2883598,3014675,3145748,3276820,3342348,3407900,3538965,3670020,3735568,3866646,3932171,3997710,4128781,4259855,4325390,4521987,4587523,4718609,4784145,5046282,5111834,5177361,5242890,5439507,5505047,5570575,5636115,5701657,5832733,5898248,5963779,6357005,6488081,6619149,6815758,7012369,7077910,7143443,7274512,7340053,7405577,7471108,7536652,7602191,7667725,7733268,7929880,7995415,8060953,8126482,8192030,8257559,8323085,8388632,8454153,8650763,8781835,8912915,8978443,9043993,9240586,9306123,9502743,9568272,9699339,9830421,9895948,9961490,10027033,10158085,10223635,10289177,10354705,10420228,10616848,10682387,11206675,11272203,11337743,11403274,11665428,11730965,11862044,11927567,12058643,12124180,12189698,12255247,12320786,12386332,12451848,12517379,12648466,12714006,12845082,12910613,12976153,13041680,13107219,13172752,13238281,13303822,13369360,13500439,13828117,13893650,13959181,14024717,14155786,14286873,14417926,14483476,14549014,14745619,14811157,15073298,15138834,15335432,15466524,15532048,15597583,15728653,15794189,15859733,15925262,16056329,16121882,16187415,16318479,16384023,16449550,16777230,16908301,17039371,17235989,17301520,17629203,17694741,17825803,17956872,18022409,18087961,18284554,18350095,18415630,18612240,18743320,18808851,18874379,19005466,19070995,19333146,19529736,19660826,19726339,19791898,19988505,20250638,20316186,20381724,20447249,20512779,20578323,20709406,20774923,20905992,20971530,21037068,21102604,21168155,21233687,21299213,21561358,21626899,21692429,21757969,21823505,21954588,22020113,22085654,22347797,22478870,22675476,22741018,22806541,22872071,23134211,23265301,23396370,23592970,23658507,23986204,24051737,24117268,24182799,24313866,24444945,24576020,24510490,24707087,24379413,24838163,24903699,24969242,25034778,25165836,25231386,25362441,25427991,25493515,25559060,25690137,25755651,25821195,25886741,25952259,26017811,26083348,26148867,26279947,26345474,26411034,26476567,26607636,26673171,26738706,26935322,27000853,27066378,27197466,27328528,27394074,27590672,27656208,27721746,27852815,28114963,28246037,28311574,28377101,28573722,28704794,28770332,28966923,29032454,29098005,29229075,29294600,29360141,29425677,29556749,29622292,29687820,29753355,29884425,30015514,30146572,30277653,30408717,30474262,30539790,30605331,30736402,30867472,30998542,31064078,31195153,31260686,31391747,31522837,31850510,32047107,32112657,32178188,32374798,32440333,32505874,32833549,32899096,32964636,33095690,33161229,33357840,33423378,33554434,33751054,33882132,33947678,34078731,34209818,34275348,34340874,34406401,34865163,34930704,34996241,35061774,35192845,35323918,35389457,35454989,35520530,35717126,35979280,36044826,36241434,36306959,36438044,36503571,36569098,36634646,36700163,36831238,36962325,37158915,37290004,37355537,37421070,37617683,37748758,37814298,37879831,37945364,38010901,38076431,38141982,38207516,38338575,38404116,38469658,38600723,38666266,38797337,38928398,38993934,39059464,39125001,39256092,39387151,39518225,39583765,39649306,39714842,39780377,39845901,39976966,40108044,40173583,40370187,40435715,40501274,40566807,40632353,40697882,40763413,40828938,40894476,40960003,41025557,41156619,41222160,41287699,41353241],"gmp_snprintf":[5963777,7667713,15335425,16318471,21757953,38338561],"guaranteed":[1114113,3276801,25559041,34275329,37945345],"general":[20316161,25034753,30015489],"gmp_scanf":[5963777,6619137,14024705,15335425,21692423,32833537],"greater":[5963777,15335425,16121857,21299201,25231361,31260674,39780353,39976961],"gmp_randseed_ui":[524290,5963777,12648450,15335425,19988482,20774914,24117250,29884423,30736386,39845889],"gmp_randstate_t":[524297,3014657,3145729,5373958,5439489,5570574,5963778,7536645,10027009,12255253,12648458,14745601,15335426,17629185,19988488,20774921,22282241,22872075,23199747,24051713,24117258,25493519,26345473,29884425,30146564,30605313,30736394,34406402,34603016,34865167,36503553,37158918,38600705,39845897,40370190,41353217],"greatest":[5898241,5963782,13041667,15335430,17956866,19529729,20971523,37289987],"good":[40370177],"gmp_randinit_mt":[524290,5570561,5963777,12255235,12648450,15335425,19988482,20774914,22872065,24117250,25493506,29884418,30736386,34865153,39845890,40370183],"guarantee":[22413313],"generating":[29884417,39845889],"gmp_randclear":[524290,5570563,5963777,12255237,12648450,15335425,19988482,20774914,22872069,24117250,25493507,29884418,30736386,34865155,39845890,40370179],"generic":[14090241,15007745,40042497],"gmp_vprintf":[5963777,15335425,15728641,20512775],"gnu":[196609,393217,524289,589825,851969,983041,1114113,1245185,1310721,1376257,1507329,1638401,1835009,1966081,2031617,2097153,2162689,2293761,2424833,2490369,2555906,2818049,2883585,3014657,3145729,3276801,3342337,3407873,3538945,3735553,3670017,3866625,3932161,3997697,4128770,4259841,4325377,4521985,4587521,4718593,4784129,5046273,5111809,5177345,5242881,5439489,5505025,5570561,5636097,5701633,5832705,5898241,6356993,6488065,6619138,6815745,7012353,7077889,7143425,7274497,7340033,7405569,7471105,7536642,7602177,7667714,7733249,7929857,7995393,8060929,8126465,8192001,8257537,8323074,8388609,8454145,8650753,8781825,8912897,8978434,9043969,9240577,9306113,9502721,9568257,9699329,9830401,9895937,9961473,10027009,10158081,10223617,10289153,10354689,10420225,10616833,10682369,11206657,11272193,11337729,11403265,11665409,11730945,11862017,11927553,12058625,12124161,12255233,12320769,12386305,12451841,12648451,12713985,12845057,12910593,12976129,13041665,13107201,13238273,13303809,13369345,13500417,13828097,13893633,13959169,14024706,14155777,14286849,14548993,14745601,14811137,15073281,15138817,15466497,15532033,15597569,15728642,15794178,15859713,15925249,16056321,16121857,16187393,16318466,16384001,16449537,16777217,16908289,17039362,17235969,17301505,17629185,17694721,17825794,17956865,18022401,18087937,18284545,18350081,18415617,18743297,18808833,18874369,19005441,19070977,19333121,19529729,19660801,19791873,19988482,20250625,20316161,20381697,20447233,20512770,20578305,20709377,20774913,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21561345,21626881,21692418,21757954,21954561,22020097,22085633,22347777,22413315,22478850,22675457,22740993,22806529,22872065,23134209,23265281,23396353,23592961,23658497,23986177,24051713,24117251,21823489,24182785,24313857,24510465,24576001,24707073,24444929,24838145,24969217,25034753,25362433,25559041,25755649,24379393,25427969,25821186,25165825,25886721,25952257,26017793,26083329,26148865,24903681,26279937,26411009,26476545,26607617,26673153,26738689,25690113,25493505,26935297,27000833,25231361,27197441,27328514,27394049,27590657,27656193,27721729,27852801,28114945,28246017,28311553,28377089,28573697,28704769,28770305,28966913,29097985,29229057,29294593,29360130,29425665,29556738,29622273,29687809,29753345,29884417,30015489,30146562,30277633,30408705,30474241,30539777,30605313,30736387,30867457,30998529,31195137,31260673,31522817,31850498,32112641,32178177,32374785,32440321,32505857,32833538,32899073,32964609,33095681,27066369,33161218,33357825,33423361,33751041,33882113,33947649,34078721,34209793,34275329,34340865,34865153,34996225,35061761,35192833,35323907,35389441,35454977,35520515,35717121,35979265,36044801,36241409,36306946,36438017,36503553,36569089,36634625,36700161,36831234,36962305,37289985,37355521,37421057,37617665,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38338562,38404097,38469633,38600705,38666241,38797313,38928385,38993921,39059457,39124993,39256065,39387137,39518209,39583745,39649281,39714817,39780353,39845889,39976961,40108033,40173571,40370177,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41156609,41222145,41287681,41353217],"github":[22413313],"gmp_sprintf":[5963777,15335425,15728641,15794177,16318465,21757959,33161217,38338561],"global":[7536641,12189697,12517377,12648449,15335425,24117249,30146561,30736385],"gets":[131073,458753,1441798,1703938,1900546,2359297,3473409,4063236,4456451,4915202,4980737,6291458,7864322,8519681,10485761,10747905,11010049,11075585,11141122,11993089,12189697,12517377,13434882,13631492,13697026,14221313,15007745,15335425,15400962,16252930,16842754,18546689,18939907,19595265,20054017,20119553,21430274,21889026,22282241,22609922,23068674,23199745,23330817,23527425,23789570,24641538,27131905,27262977,27787266,27983873,28442625,28835841,28901377,29163521,29491202,29818881,29949953,30801921,31588353,31653892,31784961,31916033,32571395,33292289,33685505,34013188,34144257,34537476,34603009,34734082,35127297,35782662,37683201,39911425,40042497],"gmp_randinit":[12648449,19988481,24117249,30736385],"gethashcode":[131074,917510,1441794,1703938,1900546,2949126,4063234,4456450,4653062,4915202,6291457,7864321,11141121,13434881,13631490,14680070,15007745,15400961,16842753,17104902,18939906,21430273,21889026,22216710,22282241,23199745,24641538,25624582,31588353,31653890,32571394,34013186,34537474,34603009,35127297,35782658,36896774,40042497],"gmp_randinit_lc_2exp_size":[5570561,5963777,12255233,15335425,22872065,25493505,34865159,40370177],"gmp_printf":[5963777,15335425,15728647,20512769,21757953,33161217],"gcd":[5898242,13041665,19529730],"gettype":[131073,1441793,1703937,1900545,4063233,4456449,4915201,6291457,7864321,11141121,13434881,13631489,15007745,15400961,16842753,18939905,21430273,21889025,22282241,23199745,24641537,31588353,31653889,32571393,34013185,34537473,34603009,35127297,35782657,40042497],"gmp_fprintf":[5963777,15335425,15728641,17039361,21757953,33161223],"given":[5963783,10158081,15335431,15925249,16187393,19791873,22478850,21823489,27066369,27328513,29884417,33554433,35520513,36044801,36306945,39059458,39845889,39976961],"generate":[524291,2097155,5963787,7536643,12648451,15335435,18022403,19988483,20774915,24117251,29884417,30146563,30736387,36503555,39845889],"glibc":[7667713,16318465],"gmp_urandomm_ui":[524295,5963777,15335425,20774913],"gmp_vsprintf":[5963777,15335425,15794183,21757953],"gmp_randinit_default":[5570561,5963777,12255233,15335425,22872065,25493511,34865153,40370177],"gmp_errno":[12189701,12517377,15335425],"gmp_vscanf":[4128769,5963777,8323073,15335425,21692417,32833543],"generates":[2097154,18022402],"getenumerator":[13434881,35127297,36110343],"generated":[524289,5570561,7536642,20774913,27328516,29884417,30146561,36503553,39845889],"greateast":[37289985],"gmp_urandomb_ui":[524289,5963777,15335425,20774919],"gmp_sscanf":[4128769,5963777,6619143,14024705,15335425,21692417],"gmp_vsscanf":[4128775,5963777,6619137,8323073,15335425,32833537],"going":[2555905,17825793,25821185,29556737],"gmp_randinit_lc_2exp":[5570567,5963778,12255233,15335426,22872065,25493505,34865154,40370177],"gmp_randseed":[5963777,15335425,29884417,39845895],"gmp_fscanf":[5963777,6619137,8323073,14024711,15335425,21692417],"gradually":[40632321],"gmp_vfprintf":[5963777,15335425,17039367,33161217],"gmp_asprintf":[5963777,15335425,16318465,21757953,29360129,38338568],"groups":[7536641,12648449,24117249,30146561,30736385],"gettempfilename":[1245186,8323074,8781826,8978434,11337730,14024706,17039362,18874370,22806530,33161218,34078722,39976961],"gmp_vfscanf":[4128769,5963777,8323079,14024705,15335425,32833537],"gmp_randinit_set":[5570561,5963777,12255239,15335425,22872065,25493505,34865153,40370177],"gmp":[65537,131074,196615,262150,327682,393222,458757,524294,589830,655365,720898,786437,851974,917509,983046,1048578,1114123,1179653,1245192,1310726,1376263,1441797,1507336,1572869,1638406,1703938,1769474,1835016,1900546,1966086,2031622,2097159,2162698,2228230,2293767,2359301,2424840,2490374,2555911,2621442,2686981,2752514,2818054,2883593,2949125,3014662,3080197,3145734,3211269,3276810,3342342,3407879,3473410,3538952,3604485,3670023,3735559,3801090,3866631,3932166,3997702,4063240,4128773,4194310,4259845,4325385,4390914,4456453,4521990,4587527,4653061,4718599,4784134,4849670,4915202,4980741,5046280,5111817,5177350,5242887,5308418,5373957,5439494,5505032,5570568,5636103,5701640,5767173,5832711,5898250,5963778,6029317,6094850,6160389,6225925,6291458,6356998,6422530,6488071,6553605,6619141,6684678,6750214,6815753,6881287,6946818,7012362,7077894,7143430,7208965,7274503,7340040,7405575,7471110,7536648,7602182,7667719,7733256,7798790,7864331,7929863,7995400,8060936,8126471,8192009,8257543,8323078,8388615,8454151,8519687,8585218,8650759,8716294,8781831,8847365,8912902,8978439,9043977,9109506,9175045,9240583,9306124,9371653,9437190,9502727,9568262,9633797,9699335,9764869,9830407,9895942,9961482,10027015,10092549,10158090,10223623,10289160,10354695,10420230,10485765,10551302,10616838,10682375,10747911,10813445,10878982,10944518,11010053,11075589,11141122,11206663,11272198,11337736,11403272,11468805,11534341,11599874,11665414,11730951,11796486,11862024,11927558,11993095,12058631,12124167,12189702,12255239,12320775,12386312,12451847,12517379,12582917,12648457,12713991,12779522,12845064,12910599,12976135,13041672,13107207,13172742,13238280,13303815,13369351,13434886,13500422,13565957,13631497,13697026,13762565,13828103,13893640,13959174,14024710,14090242,14155782,14221319,14286857,14352389,14417925,14483463,14549000,14614533,14680069,14745606,14811143,14876674,14942214,15007751,15073291,15138822,15204357,15269893,15335433,15400962,15466504,15532038,15597575,15663110,15728645,15794182,15859719,15925255,15990789,16056327,16121866,16187400,16252930,16318471,16384007,16449542,16515078,16580614,16646149,16711685,16777225,16842760,16908298,16973829,17039366,17104901,17170437,17235975,17301510,17367045,17432581,17498118,17563654,17629190,17694728,17760261,17825798,17891333,17956872,18022407,18087944,18153478,18219014,18284552,18350088,18415622,18481154,18546693,18612230,18677762,18743307,18808839,18874375,18939906,19005447,19070983,19136517,19202054,19267586,19333127,19398661,19464197,19529744,19595271,19660808,19726342,19791880,19857413,19922949,19988488,20054021,20119557,20185093,20250630,20316170,20381704,20447238,20512773,20578311,20643845,20709385,20774918,20840453,20905992,20971527,21037062,21102598,21168135,21233671,21299207,21364742,21430282,21495813,21561350,21626887,21692421,21757958,21823498,21889026,21954568,22020102,22085638,22151173,22216709,22282248,22347783,22413315,22478854,22544389,22609922,22675463,22741002,22806535,22872070,22937606,23003141,23068674,23134214,23199746,23265287,23330823,23396358,23461893,23527426,23592967,23658503,23724037,23789570,23855109,23920646,23986183,24051719,24117257,24182790,24248322,24313862,24444935,24576009,24772610,24510471,24641538,24379400,24707078,24838150,24903687,24969223,25034762,25100293,25165830,25231372,25296902,25362439,25427975,25493510,25559050,25624581,25690119,25755656,25821190,25886727,25952263,26017800,26083334,26148871,26214406,26279943,26345474,26411016,26476550,26542085,26607625,26673158,26738695,26804230,26869765,26935304,27000839,27066376,27131911,27197448,27262983,27328521,27394055,27459589,27525125,27590663,27656198,27721736,27787266,27852806,27918341,27983879,28049414,28114951,28180486,28246023,28311558,28377094,28442631,28508166,28573705,28639238,28704775,28770312,28835847,28901381,28966920,29032453,29097991,29163525,29229063,29294599,29360134,29425671,29491202,29556743,29622278,29687814,29753351,29818887,29884422,29949959,30015498,30081030,30146568,30212101,30277639,30343173,30408710,30474246,30539782,30605318,30670854,30736393,30801927,30867463,30932994,30998537,31064070,31129606,31195146,31260680,31326210,31391750,31457285,31522824,31588354,31653893,31719426,31784967,31850502,31916037,31981574,32047110,32112646,32178182,32243717,32309250,32374793,32440326,32505862,32571394,32636933,32702470,32768002,32833541,32899080,32964616,33030149,33095687,33161222,33226757,33292293,33357830,33423366,33488901,33554437,33619974,33685511,33751049,33816582,33882119,33947657,34013189,34078727,34144261,34209800,34275341,34340871,34406403,34471941,34537480,34603014,34668549,34734082,34799622,34865159,34930694,34996233,35061768,35127298,35192838,35258374,35323911,35389446,35454984,35520519,35586050,35651589,35717125,35782661,35848198,35913733,35979270,36044809,36110341,36175878,36241416,36306951,36372485,36438024,36503560,36569096,36634630,36700166,36765702,36831238,36896773,36962310,37027845,37093384,37158918,37224454,37289994,37355527,37421062,37486597,37552133,37617672,37683205,37748744,37814280,37879815,37945353,38010888,38076424,38141961,38207496,38273030,38338566,38404102,38469641,38535174,38600710,38666249,38731782,38797320,38862853,38928390,38993929,39059463,39124998,39190534,39256071,39321606,39387142,39452677,39518214,39583751,39649288,39714825,39780362,39845895,39911426,39976968,40042498,40108038,40173579,40239109,40304645,40370182,40435715,40501258,40566791,40632327,40697864,40763399,40828936,40894470,40960007,41025543,41091077,41156616,41222150,41287687,41353223,41418757],"gcnew":[15007745],"gmp_set_memory_functions":[5963777,9306121,10158081,15335425]} \ No newline at end of file diff --git a/docs/fti/FTI_104.json b/docs/fti/FTI_104.json new file mode 100644 index 0000000..d2bc527 --- /dev/null +++ b/docs/fti/FTI_104.json @@ -0,0 +1 @@ +{"hamming":[5963778,12910597,15335426,28966916],"h55555555":[5111809,18743297,19791873],"h8000000000000000":[35454977],"h40000000":[19529730],"hex":[5046276,27066372,35520513],"h11111111":[9961473],"hc2d24d55":[5898241],"holds":[21233665],"heap":[5701633],"h5555":[5111809,18743297,19791873],"h80":[21823489,40173569],"h435e50d7":[25231361,28573697,40501249],"h22222222":[9961473],"h13":[25231361,28573697,40501249],"h80000000":[35454977],"hfffffffc":[41156609],"hfffffffe":[1114113,2883585,16121857,22740993,25559041,30015489,31195137,32374785,34209793,37945345,38469633,38666241,39714817,40697857,41156609],"hffffffff":[1114115,2162689,2883586,3276802,4325380,5111809,6815746,7012354,9043970,13238274,14286850,16121859,16777218,18743297,19791873,20316162,22740995,25034754,25362434,25559043,26411010,25231361,28573697,28966915,30015491,30998530,31195139,32374786,33751042,34996228,35454979,36044801,37945347,38469635,38666243,38993924,39714819,39780354,40501249,40697859,41156610],"hardware":[18415617,21102593,35192833],"hexadecimal":[8978433,14352385,17235969,22806529,32243713],"hf0f0f0f":[18350082],"hierarchy":[7864321,13434881,15007745,15335425,16842753,21430273,22282241,34603009],"handle":[7929857,8126465,12845057,21823489,29360129,38338561,40173569],"hd79":[25231361,28573697,40501249],"habcd1234":[5832705],"h40":[1245185],"he8":[16056321],"hf0f0f0f0":[1507332,18350082,20905988],"high":[5570561,19791873,36044801],"highest":[33030145,41091073],"higher":[5963777,14155777,15335425,24051713,40632322],"h7ab824fd":[5832705],"h10000":[38141953],"hd4a51000":[16056321],"habcd12347ab824fd":[5832705],"hedcba987":[2883585,32374785],"hffff":[2162689,5111809,18743297,19791873,25231361,28573697,34209793,36044801,40501249],"h555555555555":[18743297],"h44444444":[9961473],"h5555aaaa":[36044801],"host":[21823491,40173570],"happens":[19529729],"h964619c7":[5898242],"h12345678":[2883585,4325377,6815746,16777218,30998530,32374785,33751041,38993921],"human":[34537473],"haaaaaaaa":[36044801],"he2":[1245185],"happen":[10223617,12058625],"h33333333":[9961475],"handled":[5701633,16908289],"h1e240":[1245185],"h1000":[5832706],"h7fffffff":[35454977],"hhc":[4128770,6619138,8323074,14024706,21692418,32833538],"half":[5570561],"hash":[131073,917506,1441793,1703937,1900545,2949122,4063233,4456449,4653058,4915201,6291457,7864321,11141121,13434881,13631489,14680066,15007745,15400961,16842753,17104898,18939905,21430273,21889025,22216706,22282241,23199745,24641537,25624578,31588353,31653889,32571393,34013185,34537473,34603009,35127297,35782657,36896770,40042497]} \ No newline at end of file diff --git a/docs/fti/FTI_105.json b/docs/fti/FTI_105.json new file mode 100644 index 0000000..2a3640a --- /dev/null +++ b/docs/fti/FTI_105.json @@ -0,0 +1 @@ +{"identity":[29425665],"included":[41091073],"index":[5832705,9961473,10223619,12058627,12124161,13434881,22347777,23527425,23658498,26279938,29163528,39583745],"ignored":[1835009,3670017,5832705,9895937,17235970,21626881,22478849,22806529,24444931,24379393,35520513,40173569],"iterates":[13434881,35127297,36110338],"implicit":[262146,1179650,3604482,6684674,8847362,9371650,10551298,12582914,13565954,14352386,14614530,15663106,16580610,16646146,17760258,20643842,20840450,21364738,21495810,22544386,23461890,23855106,25100290,26214402,26542082,27328513,32243714,33488898,35651586,36175874,36372482,37224450,38862850,40239106],"inherited":[131074,1441793,1703937,1900545,4063233,4456450,4915201,6291461,7864326,11141125,11599873,13434886,13631489,14876673,15007750,15400965,16842757,18939905,21430278,21889025,22282246,23199750,24641537,31588358,31653889,32571394,34013185,34537473,34603014,35127302,35782658,40042502],"increment":[7143426,12976130,18808834,26673154,27394050],"implementation":[1835009,2424833,3670017,5636097,5963777,10223617,10289153,12058625,12124161,12910593,15335425,16384001,22347777,23396353,38797313,39124993,39583745],"identical":[851969,1966081,5111809,15597569,21626881,24576001,28377089,28573697,29753345,32440321,38141953,40501249],"ienumerable":[13434888,36110337],"initialize":[196612,393218,524290,589826,851970,983042,1245186,1310722,1376260,1638401,1966082,2293764,2424838,2490371,2555906,2818050,3014658,3145730,3342338,3407876,3538948,3735557,3866628,3997698,4718596,4784130,5177346,5439490,5505028,5570564,5636098,5701634,5832706,5963799,6356994,6488068,7077890,7143426,7274501,7340038,7536642,7602178,7733254,7929860,7995398,8060934,8126466,8192006,8257540,8388612,8650756,8781826,8912898,8978434,9502724,9568258,9830404,9895938,10027012,10223618,10289158,10354692,10616834,10682372,11206660,11272194,11337730,11665410,11730946,11862020,11927554,12058626,12124162,12255238,12320772,12386310,12451842,12648452,12713988,12845062,12910596,12976132,13041670,13107204,13172738,13303811,13369346,13500418,13828100,13893636,13959170,14155778,14483460,14548998,14745602,14811140,15138818,15335447,15466502,15532034,15597572,15859716,15925250,16187394,16384004,16449538,16908291,17235970,17301506,17629186,17694726,17825794,18087942,18415618,18612226,18808834,18874370,19005444,19070980,19333124,19660804,19988484,20250626,20381700,20447234,20578308,20709382,20774914,20971522,21037059,21102594,21168130,21233666,21299204,21561347,21626884,21954566,22020098,22085634,22347778,22478850,22675460,22806530,23265284,23396354,23986180,24051716,24117254,21823491,24313858,24510468,24576008,24707074,24444930,24838146,24969220,25165827,25493508,25427972,24379398,25821186,25886724,26017796,26083330,24903682,26476546,26607624,26673154,26738692,25690116,26935300,27000836,27197444,27328514,27394052,27590660,27656194,27721732,27852802,28114948,28246020,28311555,28377090,28704772,28770310,29097987,29229060,29425668,29556738,29622274,29687810,29753348,29884418,30146562,30277636,30408706,30474242,30539779,30605314,30736388,30867459,31064066,31260678,31522822,31850498,32112643,32178178,32440322,32505858,32899078,32964612,33357826,33423362,33882116,33947654,34078722,34865156,34930690,35061766,35192834,35323906,35389442,35520513,35979266,36241412,36306946,36438022,36503554,36634626,36962306,37289990,37355524,37421058,37617668,37748742,37814276,37879812,38010886,38076422,38207494,38404099,38600706,38797318,38928387,39124994,39256066,39387139,39518210,39583746,39649284,39845890,39976961,40108035,40173570,40370180,40566788,40632324,40763396,40894466,41025540,41222146,41287682,41353220],"initializing":[589825,2490369,3407873,3932161,4259841,5701633,8912897,11730945,13959169,16908289,23986177,24182785,24510465,24838145,26083329,28311553,29097985,29622273,30474241,32112641,32505857,35389441,35520513,36962305,38404097,39387137,40632321],"indicating":[131074,655361,1048578,1441794,1703938,1769474,1900546,4063234,4456450,4915202,6094850,6946818,7798785,9175041,9764865,12779522,13631490,18677762,18939906,19136513,19857409,20185089,21889026,21823489,24641538,28049409,28508161,28639233,30343169,30670849,31653890,31719426,32571394,32636929,33816577,34013186,34537474,35586050,35782658,35848193,39321601],"indicates":[1441794,4063234,4456450,8519681,10747905,11993089,13631490,13697026,14221313,16252930,19595265,22609922,23068674,23330817,23789570,27131905,27262977,27787266,27983873,28442625,28835841,29491202,29818881,29949953,30801921,31653890,31784961,33685505,34013186,34537474,34734082,35782658,38141954,39124993],"inherit":[7864321,21430273],"information":[1245185,7536641,9961473,12648449,24117249,30146561,30736385],"interpreted":[8781825,24444929],"implements":[13434881,36110337],"invoking":[12648449,19988481,24117249,30736385],"inclusive":[524289,2424835,4325377,5963784,12648449,15335432,20774913,24117249,30736385,33751041,38993921],"inheritance":[7864321,13434881,15007745,15335425,16842753,21430273,22282241,34603009],"identified":[14155778],"implemented":[22413313,34996225],"inequality":[1441793,4063233,4456449,13631489,13697025,16252929,19595265,22609921,23068673,23330817,23789569,27262977,27787265,28442625,29491201,29818881,29949953,30801921,31653889,33685505,34013185,34537473,34734081,35782657],"include":[22413313],"ienumerator":[36110342],"internal":[5963777,8454145,15335425,39124994],"improve":[15073281],"integer":[262145,393220,458754,524290,851972,917506,983043,1114116,1245186,1376260,1507330,1572865,1638404,1966083,2097153,2162691,2293764,2424836,2555905,2621442,2818049,2883587,2949122,3014661,3080194,3145733,3276804,3342338,3538948,4063233,4128769,4325379,4653058,4718596,5046274,5111811,5177349,5439493,5636098,5701637,5832708,5898243,5963812,6029313,6225921,6356997,6488070,6619137,6815747,7012355,7077891,7143425,7274503,7340036,7405570,7536645,7602181,7667713,7733253,7864321,7995396,8192005,8323073,8454146,8650755,8781825,8978434,9043971,9306113,9502726,9568261,9699329,9895937,9961473,10027009,10223618,10289156,10354692,10616837,10682369,10813442,11141122,11206660,11272195,11796481,11862021,11927556,12058626,12124162,12189697,12320773,12386308,12582913,12648454,12910595,12976136,13041667,13107204,13172737,13238275,13303810,13369349,13500420,13631489,13828100,13893636,13959171,14024705,14155779,14286851,14483457,14548996,14680066,14745605,14811140,14876673,15073286,15138819,15335460,15466500,15532037,15597571,15728641,15794177,15859716,15925251,16056322,16121859,16187396,16318465,16384003,16449540,16580609,16777219,16842754,16908291,17039361,17104898,17235974,17301509,17367041,17432578,17629189,17694724,17825793,17956866,18022401,18219009,18350082,18612225,18743299,18808836,18874370,19005444,19070979,19333124,19464193,19529730,19660803,19791874,19988482,20250627,20316163,20381701,20447236,20512769,20578305,20709381,20774915,20905986,20971523,21037059,21102593,21168132,21233666,21299202,21430277,21626884,21692417,21757953,21954564,22020101,22085635,22216706,22347778,22478851,22675460,22740995,22806531,23265286,23396354,23658497,23724033,23986179,24051713,24117256,21823494,24313858,24444930,24576005,24707075,24969220,25034755,25100289,25165828,25362434,25559044,24379396,25821185,26017798,24903685,26279937,25624578,26411010,26476548,26607621,26673153,26738691,26935299,27000833,25231364,27066370,27197443,27328513,27394056,27459585,27590660,27656197,27721733,27852804,28114945,28377092,28573697,28704772,28770308,28966914,29163521,29229060,29294593,29360129,29425667,29556737,29622273,29687810,29753347,30015491,30146565,30212097,30277634,30408707,30605317,30736390,30867461,30998531,31064065,31195139,31260677,31522820,31653889,31850499,32178178,32374787,32440323,32833537,32964613,33161217,33357829,33423363,33554433,33751043,33882116,33947653,34013185,34078721,34209794,34275332,34406401,34668546,34865153,34930690,34996226,35061764,35323907,35454978,35520515,35717122,35979269,36044802,36241411,36306945,36438020,36634627,36765697,36831234,36896770,37289986,37355524,37421060,37617669,37814275,37945346,38010884,38076419,38141954,38207492,38338561,38469635,38600709,38666243,38797316,38928385,38993923,39059458,39124995,39256077,39387139,39518209,39583746,39649283,39714819,39780355,39976961,40108036,40173574,40501249,40697858,40894467,40960003,41025541,41091073,41156610,41222149,41287685,41353217],"including":[8978433],"intptr":[458757,5963777,10485765,11075589,14417922,15335425,18546693,19529732,21233666,29032450,31916037,33292293,33554438,35717122,39452677],"infinite":[12910593,23396353],"invoke":[22413313],"iteration":[40632321],"independent":[7012354,31195138,34996225],"initialization":[3735553,5570561,5963777,7274497,12255233,12648449,13303809,15335425,16187393,19988481,21037057,21561345,22872065,24117249,25165825,25493505,30539777,30736385,30867457,34865153,38404097,38928385,40108033,40370177],"initializations":[2490369,29097985],"interval":[36503553],"input":[1114113,4128771,5046274,5963780,6619139,8323075,8978434,11337729,13041665,14024707,15073281,15335428,16187393,19529729,21692422,22806529,24444930,25362433,32833542,27066372,34275329,37945345,38666241],"integwer":[38141953],"int64":[720898,786436,2293762,2752514,4063236,5308420,6684676,13631492,15990788,17170436,17498116,18481154,19333122,22085634,23068676,23789572,24248322,24772610,26214404,27787268,29491204,31326210,31653892,32309252,33226756,34013188,34537476,34734084,36175876,39190532,40304644],"initonly":[10420225,11010049,14417921,20119553,29032449,35717121],"inverse":[5963778,15073283,15335426,19791873,26607618,27721730,35061767,36044801],"important":[29884417,39845889],"implied":[7864321,11599873,41091073],"infinity":[393217,13172737,18415617,21102593,27852801,35192833],"inherits":[7864321,21430273],"instead":[7536641,12976129,13828097,15859713,16908289,27394049,30015489,30146561],"intended":[2097153,5963778,13500417,15335426,18022401,21168130,21233666,24576001],"iso":[7667713,16318465],"import":[21823491,40173569],"initialized":[589825,2490369,4259841,8585220,12648449,13303809,13434884,15204353,19988481,24117249,24182785,26869761,29097985,30736385,30867457,37552129,38404097,40632321,41418753],"iterate":[2555905,29556737],"isnot":[10158083],"incremented":[13107202,17694722],"istrue":[196610,393218,589827,851970,983042,1114114,1245188,1310722,1376260,1507330,1638401,1966082,2162690,2293764,2424834,2490370,2555908,2818050,2883586,3014658,3145730,3276804,3342338,3407876,3538946,3735554,3866626,3997698,4128782,4259842,4325378,4718594,4784130,5046274,5111810,5177346,5439490,5505026,5636098,5701636,5832714,5898244,6356994,6488066,6619150,6815746,7012356,7077890,7143426,7274498,7340034,7405570,7602178,7667716,7733250,7929858,7995394,8060930,8126465,8192004,8257538,8323086,8388610,8650754,8781828,8912898,8978436,9043972,9306118,9502722,9568258,9699330,9830402,9895938,9961474,10027010,10158082,10223618,10289154,10354690,10616834,10682370,11206658,11272194,11337734,11665410,11730948,11862022,11927554,12058626,12124162,12320770,12386306,12451842,12713986,12845058,12910594,12976132,13041666,13107202,13172738,13238274,13303810,13369346,13500420,13828098,13893634,13959170,14024718,14155778,14286852,14483458,14548994,14745602,14811138,15073281,15138820,15466498,15532034,15597570,15728642,15794180,15859714,15925250,16056322,16121858,16187394,16318468,16384002,16449538,16777218,16908290,17039364,17235970,17301506,17629186,17694722,17825794,17956866,18087938,18350082,18415618,18612226,18743302,18808834,18874372,19005444,19070978,19333124,19529736,19660802,19791876,20250628,20316164,20381702,20447234,20512770,20578306,20709380,20905986,20971522,21037058,21102594,21168130,21233666,21299202,21561346,21626884,21692430,21757956,21954562,22020098,22085634,22347778,22478856,22675458,22740996,22806532,23265284,23396354,23658498,23986178,24051714,21823490,24182786,24313858,24510466,24576002,24707074,24444930,24838148,24969220,25034756,25362434,25559044,25427970,24379394,25821186,25165826,25886722,26017796,26083330,24903682,26279938,26411012,26476548,26607618,26673154,26738690,25690116,26935298,27000834,25231364,27197442,27328516,27394052,27590658,27656194,27721730,27852802,28114946,28246018,28311558,28377090,28573700,28704772,28770306,28966914,29097988,29229058,29294594,29360132,29425666,29556740,29622274,29687810,29753346,30015492,30277634,30408706,30474246,30539778,30605314,30867458,30998530,31064066,31195140,31260676,31522818,31850498,32112646,32178178,32374786,32440322,32505858,32833550,32899074,32964614,27066372,33161220,33357826,33423364,33751042,33882114,33947652,34078724,34209794,34275330,34930690,34996228,35061762,35192834,35323908,35389446,35454980,35520513,35979266,36044804,36241410,36306946,36438018,36634626,36962310,37289990,37355522,37421058,37617668,37748738,37814274,37879810,37945346,38010882,38076418,38141958,38207490,38338564,38404098,38469636,38600706,38666242,38797314,38928386,38993922,39059458,39124994,39256068,39387138,39518210,39583746,39649282,39714820,39780356,39976962,40108034,40173592,40501252,40566786,40632324,40697858,40763394,40894466,41025538,41156612,41222146,41287682,41353218],"isolated":[2555905,29556737],"iff":[5963784,9568258,15335432,15532034,16056322,25362434,27656194,33357826,35979266,41222146],"int":[262146,393219,524290,851974,917508,983045,1310721,1376258,1572866,1638404,1966084,2293761,2555905,2818051,2949124,3014659,3145731,3342337,4128771,4653060,5046276,5177347,5439491,5570561,5636099,6225922,6356995,6488068,6619139,7077889,7405571,7602182,7667715,7733251,7864321,7929857,8126465,8323075,8388609,8650755,8781827,8978435,9306113,9568259,9895937,10354691,10616837,10682371,11206657,11272194,11665409,11796482,11862018,11927559,12189701,12320771,12582914,12713985,13107201,13172739,13238275,13303814,13369347,13631489,13893635,14024707,14155782,14483459,14680068,14745605,14811137,15073283,15138819,15532035,15597571,15728643,15794179,15925251,16056323,16318467,16449538,16580610,16646145,17039363,17104900,17235974,17301508,17367042,17563649,17629187,17825793,17891329,18219010,18612228,18808833,18874371,19005441,19333121,19398657,19464196,20250628,20381698,20447233,20512771,20578307,20774914,20971523,21037057,21561345,21626882,21692419,21757955,21823496,22085633,22216708,22478851,22675457,22806531,23592961,23724036,24313857,24444934,24707075,24969217,25100290,25165827,25362435,25427969,25821185,25886721,26017793,26083330,25624580,27000835,27066371,27328515,27459587,27590657,27656197,27721729,27852803,28114947,28377094,28704770,29163524,29229057,29360131,29425665,29556737,29622276,29687809,29753347,29884417,30212099,30408707,30605317,30867462,31064067,31850499,31981569,32178181,32440324,32833539,32964610,33161219,33357827,33423363,33554435,33882113,34013185,34078723,34340865,34865155,34930694,35061763,35258369,35323909,35454977,35520518,35651585,35717124,35979267,36306947,36634626,36765698,36831233,36896772,37027841,37224449,37355523,37421060,37879809,38273025,38338563,38600707,38862849,38928387,39059459,39124998,39518211,39976963,40173574,40566785,40894466,40960001,41025539,41091076,41156609,41222147,41418753],"initializes":[1441793,6160385,10092545,22282241],"integers":[1245185,5177345,5701633,5963777,9502721,9895937,9961473,11337729,13959169,15335426,15925249,16908289,17235969,18874369,20250625,20447233,21102593,22020097,22806529,23265281,24903681,29032449,30408706,32112647,32178177,35389447,35520513,39387137,40435713,41287681],"inverted_number":[5963777,9240582,15335425],"imply":[2162689,18743297],"int_bit":[21823489],"instance":[131077,655364,917505,1048578,1441796,1703940,1769474,1835009,1900548,2949121,3670017,4063236,4456453,4653057,4915204,6094850,6291457,6946818,7798787,7864321,8978433,9175044,9764868,10092545,11141121,12779522,13434881,13631492,14352385,14680065,15007745,15400961,16842753,17104897,18677762,18939908,19136516,19857412,20185092,21430273,21889028,22216705,22282242,23199745,21823490,24641540,25624577,28049411,28508163,28639235,30343172,30670851,31588353,31653892,31719426,32571397,32636932,33030145,33816579,34013188,34537476,34603009,35127297,35586050,35520513,35782661,35848195,36896769,39321603,40042497],"identify":[21299201],"iterations":[5570561],"increase":[1114113,3276801,5701633,23724033,25559041,34275329,37945345,40632321],"initial":[5963782,7274497,8978433,15335430,16908289,19791875,21037057,25165825,27525121,29884417,36044804,39845889,40108033],"increasingly":[1507329,5963777,15335425],"inline":[8519681,10747905,11993089,14221313,19595265,23330817,27131905,27262977,27983873,28442625,28835841,29818881,29949953,30801921,31784961,33685505],"immediately":[27328513],"item":[13434881,23527425,29163523],"inputs":[13041665,37289985],"irrespective":[38076417,40960001],"int32":[262148,393218,851971,917505,983042,1245186,1310722,1572868,1638402,1966083,2752516,2818050,2949121,3014657,3145729,3407874,3538945,3735554,3932162,3997697,4063236,4128769,4653057,4784130,5046275,5177346,5308420,5439489,5636097,5963778,6225924,6356993,6488065,6619137,7274498,7405569,7602178,7667713,7733249,7995393,8257538,8323073,8650753,8781826,8978434,9502722,9568258,9895938,10354690,10616833,10682370,11337730,11796484,11927554,12189697,12320769,12582916,13172738,13238273,13303812,13369345,13631492,13893633,14024705,14155779,14483458,14680065,14745601,14811137,15073281,15138818,15335426,15532034,15597571,15728641,15794177,15925251,16056321,16318465,16580612,17039361,17104897,17235971,17301505,17367044,17629185,18219012,18415618,18612226,18874370,19464193,20250626,20447234,20512769,20578306,21037058,21102594,21299201,21561346,21692417,21757953,22020098,22216705,22478850,22806530,23068676,23265282,23724033,23789572,23986178,21823492,24772612,24444931,24510466,24707074,25100292,25362433,25165826,26083330,24903682,25624577,25690114,27000834,27328514,27459585,27656194,27787268,27852802,28114946,28246018,28311554,28377091,29163521,29360129,29491204,29622274,29753345,30212097,30277634,30408705,30474242,30539778,30605313,30867461,31064066,31326212,31653892,31850499,32178179,32309252,32440323,32505858,32833537,27066371,33161217,33357826,33423362,33554434,34013188,34078722,34537476,34734084,34865153,34930690,35061761,35192833,35323906,35520516,35717121,35979266,36306945,36765700,36831234,36896769,37355522,37421058,37748737,38338561,38404098,38600705,38928386,39059459,39124996,39518210,39976962,40108034,40173573,40763393,41025537,41091073,41222146,41287682],"interface":[65537,131073,196609,262145,327681,393217,458753,524289,589825,655361,720897,786433,851969,917505,983041,1048577,1114113,1179649,1245185,1310721,1376257,1441793,1507329,1572865,1638401,1703937,1769473,1835009,1900545,1966081,2031617,2097153,2162689,2228225,2293761,2359297,2424833,2490369,2555905,2621441,2686977,2752513,2818049,2883585,2949121,3014657,3080193,3145729,3211265,3276801,3342337,3407873,3473409,3538945,3604481,3670017,3735553,3801089,3866625,3932161,3997697,4063233,4128769,4194305,4259841,4325377,4390913,4456449,4521985,4587521,4653057,4718593,4784129,4849665,4915201,4980737,5046273,5111809,5177345,5242881,5308417,5373953,5439489,5505025,5570561,5636097,5701633,5767169,5832705,5898241,5963778,6029313,6094849,6160385,6225921,6291457,6356993,6422529,6488065,6553601,6619137,6684673,6750209,6815745,6881281,6946817,7012353,7077889,7143425,7208961,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7798785,7864321,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8519681,8585217,8650753,8716289,8781825,8847361,8912897,8978433,9043969,9109505,9175041,9240577,9306113,9371649,9437185,9502721,9568257,9633793,9699329,9764865,9830401,9895937,9961473,10027009,10092545,10158081,10223617,10289153,10354689,10420225,10485761,10551297,10616833,10682369,10747905,10813441,10878977,10944513,11010049,11075585,11141121,11206657,11272193,11337729,11403265,11468801,11534337,11599873,11665409,11730945,11796481,11862017,11927553,11993089,12058625,12124161,12189697,12255233,12320769,12386305,12451841,12517377,12582913,12648449,12713985,12779521,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13434883,13500417,13565953,13631489,13697025,13762561,13828097,13893633,13959169,14024705,14090241,14155777,14221313,14286849,14352385,14417921,14483457,14548993,14614529,14680065,14745601,14811137,14876673,14942209,15007745,15073282,15138817,15204353,15269889,15335426,15400961,15466497,15532033,15597569,15663105,15728641,15794177,15859713,15925249,15990785,16056321,16121857,16187393,16252929,16318465,16384001,16449537,16515073,16580609,16646145,16711681,16777217,16842753,16908289,16973825,17039361,17104897,17170433,17235969,17301505,17367041,17432577,17498113,17563649,17629185,17694721,17760257,17825793,17891329,17956865,18022401,18087937,18153473,18219009,18284545,18350081,18415617,18481153,18546689,18612225,18677761,18743297,18808833,18874369,18939905,19005441,19070977,19136513,19202049,19267585,19333121,19398657,19464193,19529729,19595265,19660801,19726337,19791873,19857409,19922945,19988481,20054017,20119553,20185089,20250625,20316161,20381697,20447233,20512769,20578305,20643841,20709377,20774913,20840449,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21364737,21430273,21495809,21561345,21626881,21692417,21757953,21823489,21889025,21954561,22020097,22085633,22151169,22216705,22282241,22347777,22413315,22478849,22544385,22609921,22675457,22740993,22806529,22872065,22937601,23003137,23068673,23134209,23199745,23265281,23330817,23396353,23461889,23527425,23592961,23658497,23724033,23789569,23855105,23920641,23986177,24051713,24117249,24182785,24248321,24313857,24444929,24576001,24772609,24510465,24641537,24707073,24379393,24838145,24903681,24969217,25034753,25100289,25165825,25231361,25296897,25362433,25427969,25493505,25559041,25624577,25690113,25755649,25821185,25886721,25952257,26017793,26083329,26148865,26214401,26279937,26345473,26411009,26476545,26542081,26607617,26673153,26738689,26804225,26869761,26935297,27000833,27066369,27131905,27197441,27262977,27328513,27394049,27459585,27525121,27590657,27656193,27721729,27787265,27852801,27918337,27983873,28049409,28114945,28180481,28246017,28311553,28377089,28442625,28508161,28573697,28639233,28704769,28770305,28835841,28901377,28966913,29032449,29097985,29163521,29229057,29294593,29360129,29425665,29491201,29556737,29622273,29687809,29753345,29818881,29884417,29949953,30015489,30081025,30146561,30212097,30277633,30343169,30408705,30474241,30539777,30605313,30670849,30736385,30801921,30867457,30932993,30998529,31064065,31129601,31195137,31260673,31326209,31391745,31457281,31522817,31588353,31653889,31719425,31784961,31850497,31916033,31981569,32047105,32112641,32178177,32243713,32309249,32374785,32440321,32505857,32571393,32636929,32702465,32768001,32833537,32899073,32964609,33030145,33095681,33161217,33226753,33292289,33357825,33423361,33488897,33554433,33619969,33685505,33751041,33816577,33882113,33947649,34013185,34078721,34144257,34209793,34275329,34340865,34406401,34471937,34537473,34603009,34668545,34734081,34799617,34865153,34930689,34996225,35061761,35127297,35192833,35258369,35323905,35389441,35454977,35520513,35586049,35651585,35717121,35782657,35848193,35913729,35979265,36044801,36110337,36175873,36241409,36306945,36372481,36438017,36503553,36569089,36634625,36700161,36765697,36831233,36896769,36962305,37027841,37093377,37158913,37224449,37289985,37355521,37421057,37486593,37552129,37617665,37683201,37748737,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38273025,38338561,38404097,38469633,38535169,38600705,38666241,38731777,38797313,38862849,38928385,38993921,39059457,39124993,39190529,39256065,39321601,39387137,39452673,39518209,39583745,39649281,39714817,39780353,39845889,39911425,39976961,40042497,40108033,40173569,40239105,40304641,40370177,40435713,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41091073,41156609,41222145,41287681,41353217,41418753],"intentionally":[7929857,8126465,12845057],"int16":[720898,2228228,2752514,4063236,5308420,7208964,8716292,10878980,13631492,14942212,21495812,22544388,23003140,23068676,23789572,24248322,24772612,27787268,29491204,31129604,31326210,31457284,31653892,32309252,34013188,34537476,34734084]} \ No newline at end of file diff --git a/docs/fti/FTI_106.json b/docs/fti/FTI_106.json new file mode 100644 index 0000000..26021ee --- /dev/null +++ b/docs/fti/FTI_106.json @@ -0,0 +1 @@ +{"just":[1835009,5832705,8978433,9895937,22478849,34078721,36306945,40173570,40632321,41091073],"jacobi":[851972,1966084,5963782,8650756,15335430,15597572,28377092,29753345,32440324]} \ No newline at end of file diff --git a/docs/fti/FTI_107.json b/docs/fti/FTI_107.json new file mode 100644 index 0000000..6da507b --- /dev/null +++ b/docs/fti/FTI_107.json @@ -0,0 +1 @@ +{"kronecker":[851973,1966085,5963781,15335429,15597573,28377093,32440325],"kind":[12648449,30146561,36503553],"known":[5963778,7340033,11206657,15073281,15335426,16908289],"know":[21823489,27328513],"knut":[5963777,15335425,39124993],"keys":[29884417,39845889],"knuth":[29425665,39124993]} \ No newline at end of file diff --git a/docs/fti/FTI_108.json b/docs/fti/FTI_108.json new file mode 100644 index 0000000..e486ffa --- /dev/null +++ b/docs/fti/FTI_108.json @@ -0,0 +1 @@ +{"lower":[5963777,15335425,15925250,17235970,18874370,22806530,24444930,27328514,39976962,41091073,41353217],"likely":[12648449,30146561,36503553],"limb":[2097154,3276801,5046274,5832708,5898241,5963791,7012353,7274497,8454146,13434881,13500418,14417921,15204353,15335442,16121859,16187394,16908289,18022402,18743298,19529732,20316161,21037057,21168130,21233666,23527425,25034753,25165825,25362433,25559041,26411009,26869761,25231361,29032449,29163522,30015489,31195137,33030151,27066369,34537475,35717121,38141953,38666242,39256066,40108033,40435715,40697858,41091074,41418753],"logical":[2883585,4325377,5963784,6815745,15335432,16777217,22478849,30998529,32374785,33751041,34996225,38993921],"logic":[2424833,5636097,10223617,10289153,12058625,12124161,12910593,16384001,22347777,23396353,38797313,39583745],"lot":[24444929],"locale":[8781825,24444929,39976961],"locate":[22478849],"long":[786436,2097153,2293764,4063235,5046273,5767170,5963781,6684676,7077890,7864321,9895939,10551298,11534338,12648449,13631491,13762562,15335429,15663106,15990788,16973826,17170436,17498116,17629186,18022401,19005442,19333124,20774913,21364738,22085636,22151170,23855106,21823491,24969218,26214404,26804226,28180482,30146561,32178180,33226756,34013185,36175876,36503553,37552130,39190532,40239106,40304644,41091074,41222146],"location":[1835010,7012353,7864321,11599873,31195137,41091073],"loads":[22413313],"let":[8519681,10747905,11993089,14221313,19529732,19595265,23330817,27131905,27262977,27983873,28442625,28835841,29818881,29949953,30801921,31784961,33685505],"letters":[15925252,17235969,18874372,22806529,24444929,27328516,39976964],"large":[15925249,19791873,22413313,24117250,36044801,36306945],"limit":[22413313],"limbs":[1114115,1245186,1507329,2031619,2097153,2162691,2883585,3080194,3211265,3276803,4325377,4521987,4587524,5046273,5111809,5832707,5898244,5963802,6815745,7012353,7405569,7536642,7864324,8454146,8585221,9043970,9699329,9961474,11599876,12451842,13238273,13434887,13500426,13631490,14286850,14876675,15073282,15204354,15269889,15335450,16056321,16121859,16187406,16777217,17956865,18022401,18350081,18743300,19464194,19529735,19791873,20316162,20905985,21168144,21233678,21430275,22282242,22740995,23134211,23527425,23724034,25034754,25362433,25559043,25755653,25952260,26148868,26411009,26476548,26869762,25231362,27066371,28966913,29294593,30015490,30146562,30932994,30998529,31195137,32374785,33030148,33619970,33751041,34209793,34275332,34406401,34471937,34996226,35127297,35454977,36044801,36110338,36503557,36700163,37552132,37945346,38141955,38469634,38666242,38993921,39059457,39256069,39714818,39780355,40501249,40697858,41091076,41156609,41418754],"lucas":[2555910,5963777,15335425,17825795,25821190,29556739],"link":[1],"like":[5963778,7012353,8781825,8978434,15335426,24444929,30867457,31195137,35520514,37617665,39256065,40173569],"leave":[15073282],"lets":[7929857,8126465,12845057,29360129,38338561],"leading":[5046273,8781825,8978434,14352385,15073281,17235969,22806529,24444929,32243713,35520513],"lnsub1":[2555928,5963777,15335425],"loop":[11730945],"linear":[5570563,5963778,15335426,34865155],"list":[327681,589825,720897,1048577,1769473,2752513,3801089,5308417,5963782,6094849,6946817,8585217,12779521,15335430,18481153,18677761,24248321,24772609,26345473,28311553,30474241,31326209,31719425,32112642,32309249,32768001,35389442,35586049,36962305],"library":[7667713,15007745,16318465,22413316,29360129,35323905,38338561],"little":[33030146],"lsb":[21823490,40173570],"language":[196610,393218,524290,589826,851970,983042,1114114,1245186,1310722,1376258,1507330,1638402,1966082,2097154,2162690,2293762,2424834,2490370,2555906,2818050,2883586,3014658,3145730,3276802,3342338,3407874,3538946,3735554,3866626,3932162,3997698,4128770,4259842,4325378,4718594,4784130,5046274,5111810,5177346,5242882,5439490,5505026,5570562,5636098,5701634,5832706,5898242,6356994,6488066,6619138,6815746,7012354,7077890,7143426,7274498,7340034,7405570,7536642,7602178,7667714,7733250,7929858,7995394,8060930,8126466,8192002,8257538,8323074,8388610,8650754,8781826,8912898,8978434,9043970,9240578,9306114,9502722,9568258,9699330,9830402,9895938,9961474,10027010,10158082,10223618,10289154,10354690,10420226,10616834,10682370,11206658,11272194,11337730,11403266,11665410,11730946,11862018,11927554,12058626,12124162,12255234,12320770,12386306,12451842,12648450,12713986,12845058,12910594,12976130,13041666,13107202,13172738,13238274,13303810,13369346,13500418,13828098,13893634,13959170,14024706,14155778,14286850,14417922,14483458,14548994,14745602,14811138,15073282,15138818,15466498,15532034,15597570,15728642,15794178,15859714,15925250,16056322,16121858,16187394,16318466,16384002,16449538,16777218,16908290,17039362,17235970,17301506,17629186,17694722,17825794,17956866,18022402,18087938,18284546,18350082,18415618,18612226,18743298,18808834,18874370,19005442,19070978,19333122,19529730,19660802,19791874,19988482,20250626,20316162,20381698,20447234,20512770,20578306,20709378,20774914,20905986,20971522,21037058,21102594,21168130,21233666,21299202,21561346,21626882,21692418,21757954,21954562,22020098,22085634,22347778,22413313,22478850,22675458,22740994,22806530,23265282,23396354,23592962,23658498,23986178,24051714,24117250,21823490,24182786,24313858,24510466,24576002,24707074,24444930,24838146,24969218,25034754,25362434,25559042,25427970,24379394,25821186,25165826,25886722,26017794,26083330,24903682,26279938,26411010,26476546,26607618,26673154,26738690,25690114,25493506,26935298,27000834,25231362,27197442,27328514,27394050,27590658,27656194,27721730,27852802,28114946,28246018,28311554,28377090,28573698,28704770,28770306,28966914,29032450,29097986,29229058,29294594,29360130,29425666,29556738,29622274,29687810,29753346,29884418,30015490,30146562,30277634,30408706,30474242,30539778,30605314,30736386,30867458,30998530,31064066,31195138,31260674,31522818,31850498,32112642,32178178,32374786,32440322,32505858,32833538,32899074,32964610,33095682,27066370,33161218,33357826,33423362,33751042,33882114,33947650,34078722,34209794,34275330,34340866,34865154,34930690,34996226,35061762,35192834,35323906,35389442,35454978,35520514,35717122,35979266,36044802,36241410,36306946,36438018,36503554,36569090,36634626,36831234,36962306,37289986,37355522,37421058,37617666,37748738,37814274,37879810,37945346,38010882,38076418,38141954,38207490,38338562,38404098,38469634,38600706,38666242,38797314,38928386,38993922,39059458,39124994,39256066,39387138,39518210,39583746,39649282,39714818,39780354,39845890,39976962,40108034,40173570,40370178,40501250,40566786,40632322,40697858,40763394,40828930,40894466,40960002,41025538,41156610,41222146,41287682,41353218],"legendre":[5963777,15335425,29753348],"left":[3538945,5963778,15335426,27328513,34996225,41156610],"largest":[5046273,10223617,12058625,12910593,23396353,31260674,27066369],"locations":[5963777,10158081,15335425],"larger":[34537473],"lowest":[9043969,22740993],"length":[2097153,5963779,15335427,18022401,27066369,33554438],"leaks":[9961473],"leaky":[3276801,25559041],"localeconv":[8781825,24444929,39976961],"logarithm":[30015489],"level":[1114113,1507329,2031617,2097153,2162689,2883585,3276801,4325377,4521985,4587521,5046273,5111809,5898241,6815745,7012353,7405569,9043970,9699329,9961473,13238273,14286849,15073281,16056321,16121857,16777217,17956865,18022401,18350081,18743297,19529729,19791873,20316162,20905985,22740994,23134209,23658497,25034754,25362433,25559041,25755649,25952257,26148865,26279937,26411009,25231361,28573697,28966913,29294593,30015490,30998529,31195137,32374785,27066369,33751041,34209793,34275329,34996225,35454977,36044801,36700161,37945345,38141953,38469633,38666241,38993921,39059457,39714817,39780353,40501249,40697857,41156609],"log":[15073282],"low":[1114113,1507329,2031617,2097153,2162689,2883585,3276801,4325377,4521985,4587521,5046273,5111809,5570561,5898241,6815745,7012353,7405569,9043969,9699329,9961473,13238273,14286849,15073281,16056321,16121857,16777217,17956865,18022401,18350081,18743297,19529729,19791874,20316162,20905985,22740993,23134209,23658497,25034754,25362433,25559041,25755649,25952257,26148865,26279937,26411009,25231361,28573697,28966913,29294593,29884417,30015490,30998529,31195137,32374785,27066369,33751041,34209793,34275329,34996225,35454977,36044802,36700161,37945345,38141953,38469633,38666241,38993921,39059457,39714817,39780353,39845889,40501249,40697857,41156609],"letter":[17235970,22806530,24444930]} \ No newline at end of file diff --git a/docs/fti/FTI_109.json b/docs/fti/FTI_109.json new file mode 100644 index 0000000..6959df4 --- /dev/null +++ b/docs/fti/FTI_109.json @@ -0,0 +1 @@ +{"mpz_rrandomb":[5963777,7536641,12648455,15335425,24117249,30146562,30736385],"mpz_tdiv_qr":[1376257,2293761,5963777,7077889,7340033,7733249,8192007,10616833,11206657,11862017,12320769,12386305,13369345,13893633,15335425,15466497,17301505,19005441,19333121,19660801,20381697,20709377,21626881,21954561,22085633,24969217,24379393,26935297,27197441,28704769,28770305,32964609,33947649,36241409,36438017,36634625,37814273,38207489,39649281],"mpn_lshift":[5963777,9043969,9699329,15335425,23658497,26279937,28966913,30015489,35454977,41156615],"mpq_get_d":[3997699,5963777,15335425,28311558,30474246,32505858,35192839,36306945,40763393],"mpz_congruent_ui_p":[5963777,7733249,10616839,13893633,15335425],"mpn_sec_sub_1":[1114113,2031620,2162689,3276801,5963778,7012353,9961473,15073281,15335426,18743297,25559047,31195137,34275329,34996225,37945345],"mpf_set_default_prec":[196610,589826,2490372,3145730,3735555,3866626,4259843,5505026,5963777,7929858,8060930,8126465,8388610,8912899,9830402,10027010,11665410,11730945,12451842,12713986,12845058,13172738,13303811,14483458,15335425,18087938,18415618,18612226,21561347,24051714,24182791,24838145,25427970,25886722,27328514,28114946,29097985,30539779,31850498,32899074,34930690,35323906,36962305,37748738,37879810,38928387,40566786,40632323,41353218],"mpz_sqrt":[4718599,5963778,6356993,6488065,15335426,26017793,30408705,37617666],"mpf_neg":[196609,3866627,5505025,5963777,7929857,8060929,8126465,8388609,9830407,11665409,12713985,12845057,15335425,18087937,25427969,25886721,32899073,37879809,40566785],"mpz_sizeinbase":[5963777,9568257,15138817,15335425,15532033,15925249,22478863,27656193,33357825,33423361,35979265,36306946,40173570,41222145],"mpz_urandomb":[5963777,7536642,12648449,15335425,24117249,30146561,30736391],"mpq_inits":[3407873,3932161,5963777,15335425,23986177,24510465,26083329,28311559,29622273,30474243,32505857,35520513,38404097],"mpn_zero_p":[5963777,7405575,13238273,15335425,16056321,25362433],"mpf_random2":[3014657,3145729,5439489,5963777,10027009,14745601,15335425,17629185,19988481,24051713,30605313,36503559,38600705,41353217],"mpz_divisible_2exp_p":[5963777,12320769,13369351,15335425,17301505],"mpz_t":[393234,458754,851984,983041,1245196,1310721,1376311,1638416,1966096,2293812,2424873,2555927,2818049,3080194,3342346,3407873,3538983,3932161,4063233,4128770,4390917,4718618,4784129,5177361,5570568,5636123,5701645,5832721,5963783,6029317,6357011,6488090,6619138,7077936,7143435,7274516,7340078,7536656,7602193,7667714,7733295,7864321,7995438,8192069,8257537,8323074,8454159,8650770,9502744,9568272,9895948,10223645,10289193,10354712,10616865,10682369,10813446,11141123,11206695,11272202,11337741,11862078,11927553,12058653,12124187,12255233,12320807,12386366,12648461,12910626,12976141,13041695,13107235,13172737,13369376,13500432,13631489,13828109,13893672,13959182,14024706,14155787,14483464,14549036,14811175,14876675,15138832,15335431,15466558,15532048,15597591,15728642,15794178,15859725,15925261,16187414,16318466,16384034,16449557,16842753,16908304,17039362,17235985,17301536,17432578,17694762,17825806,18612225,18808864,18874379,19005495,19071011,19333175,19660855,20250636,20381758,20447249,20512770,20578305,20709445,20971541,21037069,21102604,21168144,21233680,21299217,21430282,21626924,21692418,21757954,21823499,21954622,22020114,22085680,22282242,22347803,22478865,22675493,22806539,22872065,23265304,23396379,23724034,23986184,24117268,24313864,24576042,24510465,24707089,24379438,24444929,24903698,24969271,25165837,25821198,26017825,26083329,26476559,26607661,26673163,26738721,25690113,25493505,26935351,27000840,27197495,27394062,27590684,27656208,27721766,27852818,28114945,28246017,28311553,28377104,28704823,28770366,29229091,29360130,29425683,29556759,29622273,29687818,29753362,29884417,30146574,30277640,30408723,30474241,30736397,30867471,31064065,31260696,31522858,32112661,32178189,32243721,32440336,32505857,32833538,32964670,33030148,33161218,33357840,33423376,33882149,33947717,34406402,34537473,34668550,34865154,34930689,35061784,35389461,35520514,35979280,36241463,36438078,36634672,37290029,37355544,37421072,37617699,37748737,37814327,38010922,38076442,38207550,38338562,38404097,38797353,39125002,39256084,39387149,39518209,39583771,39649335,39845896,40108046,40173579,40370177,40894474,40960013,41025575,41222160,41287698],"mpz_fdiv_r_ui":[2293761,5963777,11862017,15335425,15466497,19333127,21626881,22085633,33947649,36438017,37814273,39649281],"mpz_limbs_modify":[5832705,5963777,8454147,13500417,15335425,16187393,21168129,21233672,26476545,39256065],"mpz_import":[5963777,15335425,21823496,40173569],"mpn_gcd":[5898247,5963777,15335425,17956865,19529729],"mpq_equal":[983041,2818049,5963777,10682370,11927553,15335425,20578311,27000834],"mpn_rshift":[5963777,9699329,15335425,23658497,26279937,28966913,35454983,41156609],"mpz_neg":[3538945,5963777,7995393,13107201,14548993,14811137,15335425,17694721,18808833,19070984,22675457,21823489,26738689,29229057,31522817,33882113,38010881,41025537],"mpq_clear":[983042,2818050,3407873,3997698,4128770,5963777,6619138,7143426,7667714,8323074,8978434,11927554,12976130,13828098,14024706,15335425,15728642,15794178,15859714,16318466,17039362,20512770,21692418,21757954,23986179,24510465,26083331,26673154,27000834,27394050,28246018,28311553,29360130,29622275,30474241,32505863,32833538,33161218,34078722,35192834,35520514,36306946,38338562,38404100,40632322,40763394,41287682],"mpz_congruent_p":[1376257,2293761,5963777,7077889,7340033,7733255,8192001,10616833,11206657,11862017,12320769,12386305,13369345,13893633,15335425,15466497,17301505,19005441,19333121,19660801,20381697,20709377,21626881,21954561,22085633,24969217,24379393,26935297,27197441,28704769,28770305,32964609,33947649,36241409,36438017,36634625,37814273,38207489,39649281],"mpn_com":[2883585,4325377,5963777,6815745,15335425,16777217,18350088,30998529,32374785,33751041,38993921],"mpf_ui_div":[5963777,7929863,8126465,8388609,12845057,15335425],"mpq_set_d":[3997703,5963777,15335425,35192833,36306945,40763393],"mpq_set_f":[3997697,5963777,15335425,35192833,36306945,40763399],"mpn_sqrtrem":[5111809,5963777,9043969,14286849,15335425,16121857,19791873,20316161,22740993,25034753,26411009,25231361,28573697,30015489,34209793,36044801,38141959,38469633,38666241,39714817,39780353,40501249,40697857],"mpq_set_z":[3407873,3932161,5963777,15335425,23986183,24510465,26083329,28311553,29622273,30474241,32505857,35520513,38404097],"mpz_sub":[3538945,5963777,7995393,13107201,14548999,14811137,15335425,17694721,18808833,19070977,22675457,26738689,29229057,31522817,33882113,38010881,41025537],"mpz_fits_sshort_p":[5963777,9568257,15138817,15335425,15532033,22478849,27656193,33357831,33423361,35979265,41222145],"mpz_kronecker_ui":[851970,1966088,5963777,15335425,15597570,28377090,32440322],"matches":[22413313],"mpn_andn_n":[2883585,4325377,5963777,6815745,15335425,16777217,18350081,30998529,32374791,33751041,38993921],"mpn":[2097153,18022401,33030146],"mpz_init_set_d":[5963777,7274497,15335425,21037057,21102594,25165825,30867457,40108040],"mpn_divexact_by3":[5111809,5963777,9043969,14286849,15335425,16121857,19791880,20316161,22740993,25034753,26411009,25231361,28573697,30015489,34209793,36044802,38141953,38469633,38666241,39714817,39780353,40501249,40697857],"mpz_powm":[5963777,15335425,16449537,24576001,26607623,27590657,27721729],"mixed":[851969,1966081,15597569,28377089,32440321],"mpz_perfect_power_p":[4718593,5963777,6356993,6488065,15335425,26017793,30408711,37617665],"mpf_init2":[589825,1310722,2490369,4259842,4784130,5963777,8257540,8912897,11730945,15335425,24182785,24838147,25690116,29097991,36962305,39518210,40632321],"mpn_sec_add_1":[1114113,2162689,3276807,5963778,7012353,9961473,15073281,15335426,18743297,23134212,25559041,31195137,34275329,34996225,37945345],"mpq_inv":[5242881,5963777,9240581,11403265,15335425,18284545,23592961,33095681,34340865,36569089,40828929],"mpz_inp_raw":[1245187,5963777,11337735,15335425,18874369,22806529],"mpf_abs":[196609,3866630,5505025,5963777,7929857,8060929,8126465,8388609,9830401,11665409,12713985,12845057,15335425,18087937,25427969,25886721,32899073,37879809,40566785],"mpf_inits":[589830,2490369,4259841,5963777,8912897,11730945,15335425,24182785,24838145,29097985,36962307,40632321],"mpn_add":[5111809,5963777,9043969,14286849,15335425,16121857,19791873,20316161,22740993,25034753,26411009,25231361,28573697,30015489,34209793,36044801,38141953,38469633,38666241,39714817,39780359,40501249,40697857],"mpf_clear":[589825,1310722,2490372,3014658,3145729,4128770,4259841,4784130,5439490,5963777,6619138,7667714,8323074,8781826,8912903,11665410,11730947,12451842,13172738,13303811,14024706,14483458,14745602,15335425,15728642,15794178,16318466,17039362,17629186,18415618,18612226,19988482,20512770,21561346,21692418,21757954,24182785,24444930,24838147,24903682,27328514,28246018,29097988,29360130,30277634,30539778,30605314,31064066,31850498,32833538,33161218,34930690,35323906,36503554,36962305,38338562,38600706,38928386,39518210,39976961,40632324,40763394],"memory":[196610,393218,458754,524290,589825,851970,983042,1114114,1245186,1310722,1376258,1441795,1507330,1638401,1966082,2097154,2162690,2293762,2424834,2490370,2555906,2818050,2883586,3014658,3145730,3276802,3342338,3407874,3538946,3735554,3866626,3997698,4128770,4325378,4456449,4718594,4784130,5046274,5111810,5177346,5373953,5439490,5505026,5570562,5636098,5701635,5832706,5898242,5963783,6160386,6291457,6356994,6488066,6619138,6815746,7012355,7077890,7143426,7274498,7340034,7405570,7536642,7602178,7667714,7733250,7864321,7929858,7995394,8060930,8126465,8192002,8257538,8323074,8388610,8585221,8650754,8781826,8912898,8978434,9043970,9306125,9502722,9568258,9699330,9830402,9895938,9961474,10027010,10158087,10223618,10289154,10354690,10485762,10616834,10682370,11075586,11141121,11206658,11272194,11337730,11665410,11730946,11862018,11927554,12058626,12124162,12255234,12320770,12386306,12451842,12648450,12713986,12845058,12910594,12976130,13041666,13107202,13172738,13238274,13303810,13369346,13434886,13500418,13828098,13893634,13959170,14024706,14155778,14286850,14483458,14548994,14745602,14811138,15073281,15138818,15204354,15335431,15400961,15466498,15532034,15597570,15728642,15794178,15859714,15925250,16056322,16121858,16187394,16318466,16384002,16449538,16777218,16842753,16908290,17039362,17235970,17301506,17629186,17694722,17825794,17956866,18022402,18087938,18350082,18415618,18546691,18612226,18743298,18808834,18874370,18939905,19005442,19070978,19267585,19333122,19529730,19660802,19726337,19791874,19988482,20250626,20316162,20381698,20447234,20512770,20578306,20709378,20774914,20905986,20971522,21037058,21102594,21168130,21233666,21299202,21430273,21561346,21626882,21692418,21757954,21954562,22020098,22085634,22347778,22478850,22675458,22740994,22806530,22872065,23265282,23396354,23658498,23986178,24051714,24117250,21823490,24313858,24510466,24576002,24707074,24444930,24838146,24969218,25034754,25362434,25559042,25427970,24379394,25821186,25165826,25886722,26017794,26083330,24903682,26279938,26411010,26476546,26607618,26673154,26738690,25690114,26869762,25493506,26935298,27000834,25231362,27197442,27328514,27394050,27590658,27656194,27721730,27852802,28114946,28246018,28311554,28377090,28573698,28704770,28770306,28966914,29097986,29229058,29294594,29360135,29425666,29556738,29622274,29687810,29753346,29884418,30015490,30146562,30277634,30408706,30474242,30539778,30605314,30736386,30867458,30998530,31064066,31195139,31260674,31391745,31522818,31850498,31916034,32047105,32112642,32178178,32374786,32440322,32505858,32571394,32833538,32899074,32964610,27066370,33161218,33292290,33357826,33423362,33554434,33619970,33751042,33882114,33947650,34078722,34209794,34275330,34406403,34865154,34930690,34996227,35061762,35192834,35323906,35389442,35454978,35520513,35782659,35979266,36044802,36241410,36306946,36438018,36503554,36634626,36962306,37158913,37289986,37355522,37421058,37552130,37617666,37748738,37814274,37879810,37945346,38010882,38076418,38141954,38207490,38338567,38404098,38469634,38600706,38666242,38797314,38928386,38993922,39059458,39124994,39256066,39387138,39452673,39518210,39583746,39649282,39714818,39780354,39845890,39976961,40108034,40173570,40370178,40501250,40566786,40632323,40697858,40763394,40894466,41025538,41156610,41222146,41287682,41353218,41418754],"mod":[2162690,5570561,5963782,7733252,10616836,13893635,15073281,15335430,18743298,19791874,21626887,24576023,24379398,26607639,27721749,34209794,34275330,35061764,36044802],"mpz_init2":[5701633,5963777,13959169,15335425,16908296,32112641,35389441,39387137],"mpn_cmp":[5963777,7405569,13238279,15335425,16056321,25362433],"mpf_sqrt_ui":[196609,5963777,11665415,15335425],"mpz_abs":[3538945,5963777,7995393,13107201,14548993,14811137,15335425,17694721,18808833,19070977,22675457,26738695,29229057,31522817,33882113,38010881,41025537],"mpz_inits":[2555906,5701633,5963777,8192002,11862018,13959169,15335425,16908290,20381698,20709378,26017794,29556738,32112647,32964610,33947650,35389443,37289986,37617666,39387137],"mpn_submul_1":[5111809,5963777,9043969,14286849,15335425,16121857,19791873,20316161,22740993,25034759,26411009,25231361,28573697,30015489,34209793,36044801,38141953,38469633,38666241,39714817,39780353,40501249,40697857],"mpz_clear":[393218,851970,1245186,1638401,1966082,3342338,4128770,5177346,5570562,5636098,5701635,5832706,5963777,6356994,6619138,7077890,7536642,7602178,7667714,8323074,9568258,9895938,10223618,10616834,11272194,11337730,12058626,12124161,12648450,12976130,13369346,13500418,13828098,13959175,14024706,14155778,14483458,15138818,15335425,15532034,15728642,15794178,15859714,15925250,16187394,16318466,16449538,16908291,17039362,17235970,17301506,17825794,18808834,18874370,20250626,20447234,20512770,20971522,21037058,21102594,21168130,21233666,21692418,21757954,22020098,22085634,22347778,22478850,22806530,23986178,21823490,24313858,24707074,25821186,25165826,24903682,26476546,27000834,27394050,27656194,27852802,28377090,29360130,29687810,30146562,30277634,30408706,30736386,30867458,32112641,32178178,32440322,32833538,33161218,33357826,33423362,35389441,35979266,36634626,37421058,38338562,39124994,39256066,39387139,39583746,39845890,40108034,40173570,40894466,41222146,41287682],"multiplication":[19791873,20316161,25034753,30015489,36044801],"mpz_sub_ui":[5963777,14548993,15335425,22675457,33882119],"mp_base":[3211266,7864327,10092550,11599874,14876674,21430279,22282249,30932995,31588355,33030146,34406401],"mpf_set":[1310721,4784129,5963777,8257543,15335425,24444929,25690113,28246017,30277633,39518209],"macros":[10420225,35717121],"mpq_canonicalize":[3407873,3932165,3997697,5963777,8978433,15335425,23986177,24510465,26083330,28311553,29622274,30474241,32505857,35520514,38404097],"mpz_tdiv_r_2exp":[5963777,8192001,12386305,15335425,19005441,19660801,24969217,28770305,32964609,36241415,36634625],"mpz_fits_slong_p":[5963777,9568257,15138817,15335425,15532033,22478849,27656193,32178177,33357825,33423361,35979265,41222151],"mpf_fits_slong_p":[3014657,3145729,5439489,5963777,10027009,14745601,15335425,17629191,19988481,24051713,30605313,31850497,36503553,36831233,38600705,41353217],"mpq_swap":[3407879,3932161,5963777,15335425,23986177,24510465,26083329,28311553,29622273,30474241,32505857,35520513,38404097],"mpf_get_ui":[5963777,8781826,15335425,18415617,27328513,31850497,35323905,36831237],"mp_ptr":[1114185,1507350,2031628,2097164,2162748,2883634,3276865,4325426,4521996,4587535,5046282,5111875,5832705,5898272,5963812,6815794,7012424,7405580,8454145,8585223,9044042,9699344,9961528,13238291,13434892,13500424,14286913,15073345,15204359,15269890,15335460,16056332,16121930,16187403,16777266,17956879,18022412,18350125,18743366,19529770,19726342,19791947,20316227,20906006,21168136,21233672,22741066,23134220,23527427,23658512,25034819,25231444,25362444,25559105,25755678,25952276,26148884,26279952,26345473,26411078,26476545,26869767,27066381,28573767,28966935,29163522,29294607,30015557,30998578,31195208,32374834,33030151,33619975,33751090,34209849,34275405,34406401,34996283,35127299,35455002,36044875,36110338,36700176,37552135,37945407,38142030,38469706,38666316,38993970,39059466,39256065,39714883,39780424,40501319,40697923,41156634,41418759],"mpf_fits_ushort_p":[3014657,3145729,5439489,5963777,10027009,14745601,15335425,17629185,19988481,24051713,30605313,36503553,38600711,41353217],"mpn_addmul_1":[5111809,5963777,9043969,14286849,15335425,16121857,19791873,20316167,22740993,25034753,26411009,25231361,28573697,30015489,34209793,36044801,38141953,38469633,38666241,39714817,39780353,40501249,40697857],"mpf_get_si":[5963777,15335425,18415617,27328513,31850503,35323905,36831233],"mpn_cnd_sub_n":[1114113,2162689,3276801,5963777,7012353,9961473,15073281,15335425,18743297,25559041,31195143,34275329,34996225,37945345],"mpf_get_default_prec":[589825,2490369,4259847,5963777,8912897,11730945,15335425,24182787,24838145,29097985,36962305,40632321],"mpz_submul_ui":[5963777,15335425,29229063,31522817],"mpz_lcm":[5963777,15335425,38076423,40960001],"mpz_and":[2424833,5636097,5963777,10223617,10289159,12058625,12124161,12910593,15335425,16384001,22347777,23396353,38797313,39583745],"mpz_rootrem":[4718593,5963777,6356993,6488065,15335425,26017799,30408705,37617665],"mpz_set":[5177345,5963777,9502727,12976129,13828097,15335425,15859713,17235969,20447233,22020097,23265281,24903681,27394049,41287681],"mpf_sqrt":[196615,3866625,5505025,5963777,7929857,8060929,8126465,8388609,9830401,11665409,12713985,12845057,15335425,18087937,25427969,25886721,32899073,37879809,40566785],"mpz_combit":[2424833,5636097,5963777,10223617,10289153,12058625,12124167,12910593,15335425,16384001,22347777,23396353,38797313,39583745],"mpn_get_str":[5046279,5963777,15335425,27066369,39059457],"mpz_kronecker_si":[851975,1966081,5963777,15335425,15597569,28377089,32440321],"mpf_ceil":[3014657,3145729,5439489,5963777,10027009,14745601,15335425,17629185,19988481,24051719,30605313,36503553,38600705,41353217],"mp_limb_t":[327692,786441,1114117,1572873,2031620,2162693,3276817,4653058,4915206,5111822,5832709,5898241,5963778,7012368,7667714,7864321,8454145,8519694,9043984,9175043,9437193,9633801,9961477,13434885,13565961,13631489,14286868,15073285,15335426,15728642,15794178,16121871,16187393,16318466,16515081,16908289,17039362,17498121,17956874,18219017,18743308,19529729,19791892,20054020,20316181,20512770,20643849,21364745,21430273,21757954,22151175,22741009,23068707,23134212,23855113,25034773,25559057,26411025,25231370,27262990,28049418,28573719,29163527,29360130,30015509,31129609,31195152,31457289,32309272,33161218,34209811,34275333,34406402,34537515,34799625,34996233,35454983,35586052,36044824,36110342,37945349,38141962,38273033,38338562,38469649,38666250,38862857,39714837,39780368,40501271,40697866,41156615],"mpz_get_ui":[5963777,9895943,11337730,13959170,15335425,15925249,18808834,20250625,20447234,21037058,21102593,22806530,32178177,33030145,38010882],"manner":[7929857,8126465,12845057],"mpz_get_si":[1376258,2293762,2424834,2555908,3342338,3538946,4718594,5177346,5701634,5963777,6488066,7274498,7340034,7995394,8192004,9502722,9895937,10289154,11206658,11272194,11862020,12124162,12386306,13041666,13107202,14548994,14811138,15335425,15466498,15925249,16384002,16449538,16908290,17694722,17825794,19005442,19070978,19333122,19660802,20250625,20381700,20709380,21102593,21299202,21626882,21954562,22020098,22347778,22675458,23265284,24313858,24576002,24969218,24379394,25821186,25165826,26017796,24903682,26607618,26738690,26935298,27197442,27590658,27721730,28704770,28770306,29229058,29425666,29556740,29687810,31260674,31522818,32112646,32178183,32964612,33882114,33947652,35061762,35389446,36241410,36438018,37289990,37617668,37814274,38076418,38207490,38797314,39256066,39583746,39649282,40108034,40894466,41025538,41287682],"mpf_div_ui":[5963777,7929857,8126470,8388609,12845057,15335425],"minimum":[7471105,11730945,24182785,29097985,32702465,40632321],"mpf_integer_p":[3014657,3145735,5439489,5963777,10027009,14745601,15335425,17629185,19988481,24051713,30605313,36503553,38600705,41353217],"mpf_fits_uint_p":[3014657,3145729,5439495,5963777,10027009,14745601,15335425,17629185,19988481,24051713,30605313,36503553,38600705,41353217],"mpf_out_str":[5963777,8781825,15335425,39976966],"mpz_clrbit":[2424833,5636097,5963777,10223617,10289153,12058625,12124161,12910593,15335425,16384001,22347783,23396353,38797313,39583745],"miller":[14155778],"mpz_init_set_ui":[851970,1245186,1966082,2424836,5570562,5963777,7274497,7340036,7602178,7733254,7995396,8650756,9568258,9895938,10223618,10289156,10354690,10616834,11206658,11337730,12058626,12320772,12910596,13041668,13369346,13828098,13893636,14155778,14548996,15138818,15335425,15532034,15597572,15859714,16384002,17301506,17694726,18874370,20971522,21037063,21233666,21299202,21626882,22675458,23396354,24576006,24379396,25165825,26607622,27590658,27656194,27721732,27852802,28377090,29753348,30867457,31260676,31522820,32440322,33357826,33423362,33882114,35061764,35979266,37289988,37355524,37421058,38010884,38076420,38797316,39124994,39845890,40108033,41222146],"mpz_cdiv_r":[1376257,5963777,7077889,15335425,20381697,20709377,21954561,26935297,27197441,28704769,38207495],"mpn_sec_mul_itch":[1114116,5963777,15335425,25952261],"mpz_ui_pow_ui":[5963777,15335425,16449543,24576001,26607617,27590657,27721729],"mpq_out_str":[5963777,8978433,15335425,34078727],"mpn_sub_n":[5111809,5963778,9043969,14286849,15335426,16121857,19791873,20316161,22740993,25034753,26411010,25231361,28573697,30015489,31195139,34209793,36044801,38141953,38469639,38666241,39714817,39780353,40501249,40697857],"mp_size_t":[1114145,1507335,1769476,2031630,2097161,2162720,2752528,2883597,3014657,3080199,3145729,3211271,3276827,4128771,4194313,4325389,4521998,4587545,5046278,5111839,5439489,5832715,5898261,5963790,6619139,6684681,6815757,7012377,7405576,7536646,8323075,8454157,8585217,8716297,9043999,9371657,9699336,9961504,10027009,11534345,12582921,12648450,13238280,13434881,13500422,13631532,14024707,14286878,14417929,14745601,15073305,15269894,15335438,16056328,16121891,16187402,16580617,16777229,17629185,17956874,18022409,18153481,18350094,18743328,19136515,19529756,19791908,19988481,20316191,20840457,20905991,21168139,21233675,21692419,22544393,22741027,23134222,23658500,23789603,23920649,24051713,24117250,24248340,24641542,25034783,25231399,25362440,25559067,25755675,25952281,26148889,26279940,26411040,26476555,26804233,27066377,27459591,28573730,28835854,28966920,29032457,29294599,30015520,30146566,30605313,30736386,30801934,30998541,31195161,32374797,32833539,33488905,33619974,33751053,33816586,34209823,34275360,34406401,34471943,34996246,35258377,35454984,36044836,36503557,36700174,36896770,37027849,37683204,37945370,38141991,38469663,38600705,38666272,38993933,39059462,39256076,39714847,39780386,40304649,40501286,40697887,41156616,41353217],"mpf_swap":[1310721,4784129,5963777,8257537,15335425,24444929,25690119,28246017,30277633,39518209],"maxvalue":[3014658,5439490,9568258,14745602,15532034,17629186,27656194,30605314,33357826,35979266,38600706,41222146],"mpz_out_str":[1245185,5963777,11337729,15335425,18874375,22806529],"mpf_set_si":[1310721,4784129,5963777,8257541,15335425,24444929,25690117,28246017,30277633,39518215,40763394],"mpf_set_ui":[1310727,4784129,5963777,8257537,15335425,24444929,25690113,28246017,30277633,39518209],"mpn_sub_1":[5111809,5963777,9043969,14286849,15335425,16121857,19791873,20316161,22740993,25034753,25559041,26411009,25231361,28573697,30015489,34209793,36044801,38141953,38469633,38666241,39714823,39780353,40501249,40697857],"mpn_sizeinbase":[5046273,5963777,15335425,27066369,39059463],"mpf_sub":[196609,3866625,5505025,5963777,7929857,8060929,8126465,8388609,9830401,11665409,12713985,12845057,15335425,18087943,25427969,25886721,32899073,37879809,40566785],"mpz_ui_sub":[5963777,14548993,15335425,22675463,33882113],"mpz_fdiv_r":[2293761,5963777,11862017,15335425,15466503,19333121,22085633,33947649,36438017,37814273,39649281],"mpz_swap":[5177345,5963777,9502721,15335425,17235969,20447233,22020097,23265287,24903681,41287681],"mpn_set_str":[5046273,5963777,15335425,27066375,39059457],"mpf_sgn":[5963777,13172737,14483457,15335425,18612225,28114945,31064071,34930689,37748737],"mpq_div_2exp":[5242881,5963777,9240577,11403265,15335425,18284545,23592965,33095681,34340865,36569089,40828929],"mantissa":[5963777,7864321,8781826,11599873,15335425,19464193,19988481,24444931,27328513,33030145,39976962],"mpz_invert":[5963777,15335425,26607617,27721729,35061767],"mpz_fits_ushort_p":[5963777,9568257,15138817,15335425,15532039,22478849,27656193,33357825,33423361,35979265,41222145],"moved":[1835010],"mpz_root":[4718593,5963777,6356993,6488071,15335425,26017793,30408705,37617665],"mpz_set_si":[5177351,5963777,7274498,9502725,15335425,17235969,20447233,22020097,23265281,23986178,24903681,27000834,41287681],"mpz_set_ui":[5177345,5963777,9502721,15335425,17235969,20447239,21168130,22020097,23265281,24903681,30277634,33030145,41287681],"mpz_hamdist":[2424833,5636097,5963777,10223617,10289153,12058625,12124161,12910599,15335425,16384001,22347777,23396353,38797313,39583745],"mpz_mfac_uiui":[3342337,5963777,15335425,29687809,40894471],"mpz_fdiv_q_2exp":[2293761,5963777,11862017,15335425,15466497,19333121,22085633,33947649,36438017,37814273,39649287],"mpq_t":[983055,1310721,2621443,2818063,3407899,3932176,3997708,4063233,4128770,4784129,5177345,5242910,5963778,6422533,6553605,6619138,7143437,7667714,7864321,8257537,8323074,8978442,9240606,9502721,10682394,10813442,11403298,11927567,12976143,13631489,13828111,14024706,14352393,15335426,15400963,15728642,15794178,15859727,16318466,16842762,17039362,17235969,18284578,20447233,20512770,20578328,21430273,21692418,21757954,22020097,23265281,23592990,23986196,24510491,24444929,26083349,24903681,26673165,25690113,27000851,27394064,28246024,28311579,29360130,29622293,30277633,30474267,31916034,32505877,32833538,33095710,33161218,34078729,34340894,34406401,34537473,34668546,35192843,35520532,35913730,36306955,36569122,38338562,38404117,39518209,40632323,40763403,40828962,41287688],"mpz_cdiv_q_ui":[1376263,5963777,7077889,15335425,20381697,20709377,21954561,26935297,27197441,28704769,38207489],"mpz_sgn":[393217,1638401,5963777,7602177,8454145,10354689,15335425,24707079,27852801,37355521,37421057,40173569],"mpz_cmpabs_ui":[393217,1638406,5963777,7602177,10354689,15335425,24707073,27852801,37355521],"mpf_init_set_si":[196610,3735555,3866626,5505026,5963777,7929858,8060932,8126465,8388610,9830402,12713986,12845060,13172738,13303809,14483458,15335425,18087940,18612226,21561345,25427970,25886722,28114948,30539777,31064066,32899076,34930690,37748740,37879810,38928391,40566786],"mpz_divisible_ui_p":[5963777,12320769,13369345,15335425,17301511],"mpf_cmp_si":[5963777,13172737,14483457,15335425,18612225,28114945,31064065,34930695,37748737],"mpf_cmp_ui":[5963777,13172737,14483457,15335425,18612231,28114945,31064065,34930689,37748737],"mpn_random2":[2097161,5963777,15335425,18022403],"makes":[16908289,24444929],"mpn_mul_1":[5111809,5963777,9043969,14286849,15335425,16121857,19791873,20316161,22740993,25034753,26411009,25231361,28573697,30015495,34209793,36044801,38141953,38469633,38666241,39714817,39780353,40501249,40697857],"mp_bitcnt_t":[589829,1114114,1376258,1900550,2162690,2293762,2359300,2424838,2490373,3014657,3145729,3276802,3538949,3735553,4063276,4259850,4849673,5439489,5505029,5570566,5636106,5701638,5767177,5963779,7012354,7077890,7208969,7536643,7733249,7798794,7995393,8060929,8192002,8912900,9699335,9961475,10027009,10223634,10289158,10616833,11730952,11862018,12058642,12124170,12255234,12320769,12386306,12648454,12910604,13303809,13369349,13893637,13959170,14614537,14680066,14745601,14811137,14942217,15073286,15335427,15466498,15663113,15990793,16384006,16646153,16908295,17301505,17367049,17629185,17891335,18481166,18743298,19005442,19333122,19660806,19988485,20185091,20381698,20709378,21561345,21954562,22085634,22347786,22872066,23396364,23658507,24051713,24117250,24182792,24772630,24838153,24969218,25559042,25755659,25427969,26214409,26279947,26542089,25493506,26935302,27197446,27983886,28704770,28770306,28966919,29097992,29949966,30146563,30539777,30605313,30736390,31195138,31260677,31719428,32112642,32964610,33030145,33947650,34275336,34406401,34734115,34865159,34996226,35389442,35454978,36241414,36438018,36503553,36634626,36700164,36765705,36962308,37224457,37486601,37814278,37945346,38207490,38535176,38600705,38731785,38797318,38928385,39256067,39387138,39583754,39649286,40370178,40632334,41025537,41156610,41353217],"mpz_roinit_n":[5832705,5963777,8454145,13500417,15335425,16187400,21168129,21233665,26476545,39256065],"meaning":[24444929],"mpz_limbs_finish":[5832705,5963777,8454150,13500417,15335425,16187393,21168131,21233667,26476545,39256065],"mpz_limbs_write":[5832705,5963777,8454146,13500417,15335425,16187393,21168136,21233665,26476545,39256065],"mpn_mul_n":[5111809,5963777,9043969,14286849,15335425,16121857,19791873,20316161,22740993,25034753,26411009,25231361,28573697,30015489,34209793,36044801,38141953,38469633,38666247,39714817,39780353,40501249,40697857],"mpf_sub_ui":[5963777,15335425,18087937,37879809,40566791],"mpn_sec_invert":[1114113,2162689,3276801,5963778,7012353,9961473,15073286,15335426,18743297,25559041,31195137,34275329,34996225,36700164,37945345],"mpn_gcdext":[5898241,5963777,15335425,17956865,19529735],"mpz_cmp_si":[393217,1638401,5963777,7602183,10354689,12976130,15335425,24707073,27394050,27852801,37355521,37421057],"mpz_cmp_ui":[393217,1638401,5963777,7602177,10354689,15335425,24707073,27852801,37355521,37421063],"mpn_sqr":[5111809,5963777,9043969,14286849,15335425,16121857,19791873,20316161,22740993,25034753,26411009,25231361,28573697,30015489,34209793,36044801,38141953,38469633,38666242,39714817,39780353,40501249,40697863],"methods":[131074,1441793,1703938,1900546,4063233,4456449,4915202,5963778,6291458,7864321,11141122,13434881,13631489,15007745,15335425,15400962,16842753,18939906,21430273,21889026,22282241,23199746,24641538,31588354,31653889,32571394,34013185,34537473,34603009,35127298,35782657,40042498],"mpz_mul_2exp":[3538951,5963777,7995393,14811137,15335425,41025537],"mpn_sec_mul":[1114119,2162689,3276801,5963778,7012353,9961473,15073281,15335426,18743297,25559041,25952261,31195137,34275329,34996225,37945345],"multiply":[5963781,15335429,16121857,19791873,20316161,25034753,30015489,36044801,38666241],"mpz_lcm_ui":[5963777,15335425,38076417,40960005],"mpn_add_1":[3276801,5111809,5963777,9043969,14286855,15335425,16121857,19791873,20316161,22740993,25034753,26411009,25231361,28573697,30015489,34209793,36044801,38141953,38469633,38666241,39714817,39780353,40501249,40697857],"make":[3932161,5832705,5963777,7929857,8126465,8912897,12845057,15335425,16187394,16908289,21168129,21233665,22020097,24903681,32505857,40108033,41287681],"mpz_limbs_read":[5832705,5963777,8454145,13500423,15335425,16187393,21168129,21233665,26476545,39256065],"mpz_cdiv_r_ui":[1376257,5963777,7077889,15335425,20381697,20709377,21954561,26935297,27197441,28704775,38207489],"mpz_tdiv_r":[5963777,8192001,12386305,15335425,19005441,19660801,24969217,28770311,32964609,36241409,36634625],"mpn_add_n":[5111809,5963778,7012355,9043975,14286849,15335426,16121857,19791873,20316161,22740993,25034753,26411009,25231361,28573697,30015489,34209793,36044801,38141953,38469633,38666241,39714817,39780353,40501249,40697857],"mpf_reldiff":[5963777,13172737,14483457,15335425,18612225,28114945,31064065,34930689,37748743],"mpn_sec_sub_1_itch":[2031621,5963777,15335425,25559044],"mpn_xnor_n":[2883585,4325377,5963777,6815751,15335425,16777217,18350081,30998529,32374785,33751041,38993921],"mpz_sqrtrem":[4718593,5963777,6356993,6488065,15335425,26017793,30408705,37617671],"mpz_init_set_str":[5832706,5963777,7274497,15335425,20250626,21037057,24117250,25165825,26476546,30867463,40108033,40173570],"minus":[15925249,22478849,24444929,27328513,36306945],"mpn_nior_n":[2883585,4325377,5963777,6815745,15335425,16777217,18350081,30998529,32374785,33751047,38993921],"machine":[24576001,34537473],"mpz_random":[5963777,7536647,12648449,15335425,24117249,30146563,30736385],"mpf_mul":[196609,3866625,5505025,5963777,7929857,8060935,8126465,8388609,9830401,11665409,12713985,12845057,15335425,18087937,25427969,25886721,32899073,37879809,40566785],"mpz_fits_sint_p":[5963777,9568257,15138817,15335425,15532033,22478849,27656199,33357825,33423361,35979265,41222145],"mean":[41091074],"mpq_neg":[5242881,5963777,9240577,11403265,15335425,18284545,23592961,33095685,34340865,36569089,40828929],"means":[34537473,41091073],"mpn_divexact_by3c":[5111809,5963777,9043969,14286849,15335425,16121857,19791875,20316161,22740993,25034753,26411009,25231361,28573697,30015489,34209793,36044809,38141953,38469633,38666241,39714817,39780353,40501249,40697857],"mpf_trunc":[3014657,3145729,5439489,5963777,10027015,14745601,15335425,17629185,19988481,24051713,30605313,36503553,38600705,41353217],"mpq_mul":[5242881,5963777,9240577,11403265,15335425,18284549,23592961,33095681,34340865,36569089,40828929],"mpz_ior":[2424839,5636097,5963777,10223617,10289153,12058625,12124161,12910593,15335425,16384001,22347777,23396353,38797313,39583745],"mpf_fits_sint_p":[3014657,3145729,5439489,5963777,10027009,14745607,15335425,17629185,19988481,24051713,30605315,36503553,38600705,41353217],"measured":[5963779,15335427,22478850,26476546,39059458],"mpz_xor":[2424833,5636097,5963777,10223617,10289153,12058625,12124161,12910593,15335425,16384001,22347777,23396353,38797319,39583745],"mpz_lucnum2_ui":[2555913,5963777,15335425,17825793,25821186,29556737],"mpz_mul":[3538945,5963777,7995399,13107201,14548993,14811137,15335425,17694721,18808833,19070977,22675457,26738689,29229057,31522817,33882113,38010881,41025537],"mpq_clears":[3407875,3932161,5963777,10682370,15335425,20578306,23986177,24510467,26083329,28311555,29622273,30474247,32505857,35520513,38404097],"macro":[19791873,28573697,36044801,40501249],"mpq_mul_2exp":[5242881,5963777,9240577,11403265,15335425,18284545,23592961,33095681,34340869,36569089,40828929],"m2exp":[5570567,5963777,15335425,34865154],"mpn_sec_div_r_itch":[2162692,4587525,5963777,15335425],"mpn_sec_div_qr":[1114113,2162689,3276801,5963778,7012353,9961473,15073281,15335426,18743303,25559041,26148869,31195137,34275329,34996225,37945345],"mpn_ior_n":[2883585,4325377,5963777,6815745,15335425,16777217,18350081,30998529,32374785,33751041,38993927],"mpf_t":[196643,589843,1179657,1310737,2490384,2686981,3014678,3145750,3735572,3866660,3997697,4063233,4128770,4259851,4784145,5177345,5439510,5505062,5963778,6291459,6619138,7667714,7864330,7929896,8060973,8126502,8257560,8323074,8388648,8781833,8912912,9109509,9502721,9830434,10027037,11599875,11665436,11730959,12451848,12714020,12845103,13172754,13303823,13631489,14024706,14483473,14745622,15335426,15728642,15794178,16318466,16842753,17039362,17235969,17629206,18087981,18415628,18612241,19464194,19922946,19988502,20447233,20512770,21430273,21561357,21692418,21757954,22020097,22282242,23265281,24051741,24182793,24444945,24838159,24903688,25428006,25690136,25886754,27328524,28114970,28246033,29098000,29360130,30277649,30539789,30605334,31064081,31850510,32833538,32899115,33030145,33161218,33292290,34406402,34471938,34537473,34930705,35192833,35323916,36306945,36503574,36831243,36962326,37748767,37879846,38338562,38600726,38928397,39518225,39976968,40566822,40632344,40763400,41091074,41287681,41353245],"missing":[15335425,22413313,34406401],"manual":[35323905],"mpq_set":[3407873,3932161,5963777,15335425,23986177,24510471,26083329,28311553,29622273,30474241,32505857,35520513,38404097],"mpz_lucnum_ui":[2555905,5963777,15335425,25821191],"modular":[35061762],"mpn_divrem_1":[5111809,5963777,9043969,14286849,15335425,16121857,19791874,20316161,22740993,25034753,26411009,25231361,28573698,30015489,34209793,36044802,38141953,38469633,38666241,39714817,39780353,40501256,40697857],"mpz_nextprime":[5963777,14155777,15335425,21299207],"mpz_gcd":[5963777,13041671,15335425,20971521,37289985],"mpf_mul_ui":[5505025,5963777,8060929,15335425,25427975],"monotonously":[1114113,3276801,25559041,34275329,37945345],"mpn_sec_invert_itch":[5963777,15073283,15335425,36700165],"mpz_legendre":[851969,1966081,5963777,8650753,15335425,15597569,28377089,29753351,32440321],"memberwiseclone":[6291457,7864321,11141121,13434881,15007745,15400961,16842753,21430273,22282241,23199745,31588353,34603009,35127297,40042497],"mpf_set_prec_raw":[589825,2490369,4259841,5963777,8912897,11730945,15335425,24182785,24838145,29097985,36962305,40632333],"mpz_fits_ulong_p":[5963777,9568257,15138817,15335425,15532033,22478849,27656193,33357825,33423361,35979271,41222145],"mpn_divmod_1":[5111809,5963777,9043969,14286849,15335425,16121857,19791873,20316161,22740993,25034753,26411009,25231361,28573704,30015489,34209793,36044801,38141953,38469633,38666241,39714817,39780353,40501250,40697857],"mpf_fits_ulong_p":[3014657,3145729,5439489,5963777,10027009,14745601,15335425,17629185,19988481,24051713,30605317,31850497,36503553,36831233,38600705,41353217],"mpz_si_kronecker":[851969,1966081,5963777,15335425,15597569,28377095,32440321],"mpz_fdiv_qr_ui":[2293761,5963777,11862023,15335425,15466497,19333121,22085633,33947649,36438017,37814273,39649281],"mpz_probab_prime_p":[5963777,14155783,15335425,21299201,39124993],"mpn_copyd":[1507329,5963777,15335425,20905991,29294593],"mpn_copyi":[1507335,5963777,15335425,20905985,29294593],"mpn_perfect_power_p":[5963777,7405569,13238273,15335425,16056327,25362433],"mpz_fdiv_r_2exp":[2293761,5963777,11862017,15335425,15466497,19333121,22085633,33947649,36438017,37814279,39649281],"mpz_com":[2424833,5636097,5963777,10223617,10289153,12058625,12124161,12910593,15335425,16384007,22347777,23396353,38797313,39583745],"mpf_clears":[196610,589826,2490369,3735554,3866626,4259841,5505026,5963777,7929858,8060930,8126465,8257538,8388610,8912897,9830402,10027010,11730945,12713986,12845058,15335425,18087938,24051714,24182785,24838145,25427970,25886722,25690114,28114946,29097985,32899074,36962311,37748738,37879810,40566786,40632321,41353218],"mpz_mul_si":[3538945,5963777,7995393,14811137,15335425,41025543],"mpf_urandomb":[3014657,3145729,5439489,5963777,10027009,14745601,15335425,17629185,19988487,24051713,30605313,36503553,38600705,41353217],"mpz_mul_ui":[3538945,5963777,7995393,14811143,15335425,41025537],"mpf_get_str":[5963777,15335425,18415617,27328519,31850497,35323905,36831233],"mpn_cnd_swap":[1114113,2162689,3276801,5963777,7012353,9961473,15073281,15335425,18743297,25559041,31195137,34275329,34996231,37945345],"mpz_divexact":[1376257,2293761,5963777,7077889,7340039,7733249,8192001,10616833,11206657,11862017,12320769,12386305,13369345,13893633,15335425,15466497,17301505,19005441,19333121,19660801,20381697,20709377,21626881,21954561,22085633,24969217,24379393,26935297,27197441,28704769,28770305,32964609,33947649,36241409,36438017,36634625,37814273,38207489,39649281],"mpf_add":[196609,3866625,5505025,5963777,7929857,8060929,8126465,8388609,9830401,11665409,12713985,12845057,15335425,18087937,25427969,25886721,32899079,37879809,40566785],"mpn_perfect_square_p":[5963777,7405569,13238273,15335425,16056321,25362439,38141953],"mpz_bin_ui":[5963777,11272193,15335425,29425672],"mersenne":[5963777,12255234,15335425,29884418,39845890,40370179],"machines":[1245185,7012353,11337729,31195137],"mpz_getlimbn":[5832720,5963777,8454145,13500417,15335425,16187393,21168129,21233665,26476545,39256065],"mpf_cmp":[5963777,13172737,14483457,15335425,18612225,28114952,31064065,34930689,37748737],"mpq_get_str":[3997697,5963777,15335425,35192833,35520513,36306951,38404098,40763393],"mslimb":[18743300],"mpz_get_str":[5701634,5963777,9895937,15335425,15925255,16187394,17235970,20250625,21102593,21168130,21233666,21823490,30867458,32178177,39256066,39387138],"mpq_div":[5242881,5963777,9240577,11403269,15335425,18284545,23592961,33095681,34340865,36569089,40828929],"mpz_submul":[3538945,5963777,7995393,13107201,14548993,14811137,15335425,17694721,18808833,19070977,22675457,26738689,29229057,31522823,33882113,38010881,41025537],"mpn_hamdist":[5963777,9699329,15335425,23658497,26279937,28966919,35454977,41156609],"mpz_clears":[1376258,2293762,2424834,2555906,3538946,4718594,5701633,5963777,6488066,7274498,7340034,7733250,7995394,8192002,8650754,9502722,10289154,10354690,11206658,11862018,12320770,12386306,12910594,13041666,13107202,13893634,13959169,14548994,14811138,15335425,15466498,15597570,16384002,16908289,17694722,19005442,19070978,19333122,19660802,20381698,20709378,21299202,21626882,21954562,22675458,23265282,23396353,24117250,24576002,24969218,24379394,26017794,26607618,26738690,26935298,27197442,27590658,27721730,28704770,28770306,29229058,29425666,29556738,29753346,31260674,31522818,32112643,32964610,33882114,33947650,35061762,35389447,36241410,36438018,37289986,37355522,37617666,37814274,38010882,38076418,38207490,38797314,39387137,39649282,41025538],"mpz_kronecker":[851969,1966081,5963777,15335425,15597575,28377089,32440321],"mpz_export":[5963777,15335425,21823489,40173575],"mpz_add":[3538945,5963777,7995393,13107201,14548993,14811137,15335425,16187393,17694721,18808833,19070977,22675457,26738689,29229057,31522817,33882113,38010887,41025537],"mpn_xor_n":[2883591,4325377,5963777,6815745,15335425,16777217,18350081,30998529,32374785,33751041,38993921],"mpz_cmp":[393217,1638401,5963777,7602177,10354691,15335425,24707073,27852801,37355527,37421057],"mpn_divexact_1":[5111815,5963777,15335425,16121857,19791873,20316161,22740993,25034753,26411009,25231361,28573697,30015489,34209793,36044801,38141953,38469633,38666241,39714817,40501249,40697857],"mp_uint_per_limb":[14417921,15335425,29032455,35717121,40435713],"mpq_add":[5242881,5963777,9240577,11403265,15335425,18284545,23592961,33095681,34340865,36569089,40828933],"mpf_cmp_z":[5963777,13172737,14483463,15335425,18612225,28114945,31064065,34930689,37748737],"mpz_tdiv_q_ui":[5963777,8192001,12386305,15335425,19005447,19660801,24969217,28770305,32964609,36241409,36634625],"mpz_fib2_ui":[2555905,5963777,15335425,17825794,25821185,29556745],"mpf_cmp_d":[5963777,13172744,14483457,15335425,18612225,28114945,31064065,34930689,37748737],"mpz_cdiv_q":[1376257,5963777,7077889,15335425,20381697,20709377,21954567,26935297,27197441,28704769,38207489],"mpq_set_si":[983042,2818050,3407877,3932161,5963777,7143426,10682372,11927554,12976130,13828098,15335425,15859714,20578308,23986179,24510469,26083329,26673154,27000834,27394050,28311553,29622279,30474241,32505857,35192834,35520513,36306946,38404097,40763394],"mpq_set_ui":[3407873,3932161,5963777,15335425,23986177,24510465,26083335,28246018,28311553,29622273,30474241,32505857,34078722,35520513,38404097,40632324],"mpz_powm_sec":[5963777,15335425,16449537,24576007,26607617,27590657,27721729],"mpq_get_num":[5963777,7143425,12976135,13828097,15335425,15859713,26673153,27394049],"mpz_popcount":[2424833,5636097,5963777,10223617,10289153,12058625,12124161,12910593,15335425,16384001,22347777,23396359,38797313,39583745],"mpz":[7143425,8781825,16187393,23724033,24444929,26673153],"mpz_random2":[5963777,7536641,12648449,15335425,24117249,30146565,30736385],"mpf_init_set_d":[3145730,3735553,5963777,10027010,13303809,15335425,18415618,21561345,24051714,27328514,30539783,31850498,35323906,38928385,41353218],"mpf_init_set_ui":[3014658,3735553,5439490,5963777,13303809,14745602,15335425,17629186,21561351,30539777,30605314,38600706,38928385,39976961],"mpq_numref":[5963777,7143425,12976131,13828097,15335425,15859715,26673159,27394049,36306945],"mpf_set_str":[1310721,4784129,5963777,8257537,13303809,15335425,24444935,25690113,28246017,30277633,39518209],"multiplier":[5963777,15335425,18284550],"mpq_get_den":[5963777,7143425,12976129,13828097,15335425,15859713,26673153,27394056],"mpz_cmp_d":[393217,1638401,5963777,7602177,10354689,15335425,24707073,27852808,37355521,37421057],"miscellaneous":[524289,3014657,3145729,5439489,9568257,10027009,14745601,15138817,15532033,17629185,19988481,20774913,22478849,24051713,27656193,30605313,31850497,33357825,33423361,35979265,36503553,36831233,38600705,41222145,41353217],"mpn_sec_tabselect":[1114113,2162689,3276801,5963777,7012353,9961479,15073281,15335425,18743297,25559041,31195137,34275329,34996225,37945345],"mpn_gcd_1":[5898241,5963777,15335425,17956871,19529729],"math":[131073,196614,262149,327681,393221,458756,524293,589829,655364,720897,786436,851973,917508,983045,1048577,1114122,1179652,1245190,1310725,1376262,1441796,1507335,1572868,1638405,1703937,1769473,1835015,1900545,1966085,2031621,2097158,2162697,2228229,2293766,2359300,2424839,2490373,2555910,2621441,2686980,2752513,2818053,2883592,2949124,3014661,3080196,3145733,3211268,3276809,3342341,3407878,3473409,3538951,3604484,3670022,3735558,3801089,3866630,3932165,3997701,4063239,4128772,4194309,4259844,4325384,4390913,4456452,4521989,4587526,4653060,4718598,4784133,4849669,4915201,4980740,5046279,5111816,5177349,5242886,5308417,5373956,5439493,5505031,5570567,5636102,5701638,5767172,5832710,5898249,5963777,6029316,6094849,6160388,6225924,6291457,6356997,6422529,6488070,6553604,6619140,6684677,6750213,6815752,6881286,6946817,7012361,7077893,7143429,7208964,7274502,7340039,7405574,7471109,7536646,7602181,7667718,7733255,7798789,7864330,7929862,7995399,8060935,8126470,8192008,8257542,8323077,8388614,8454150,8519686,8585217,8650758,8716293,8781830,8847364,8912901,8978438,9043976,9109505,9175044,9240582,9306119,9371652,9437189,9502726,9568261,9633796,9699334,9764868,9830406,9895941,9961481,10027014,10092548,10158087,10223622,10289159,10354694,10420228,10485764,10551301,10616837,10682374,10747910,10813444,10878981,10944517,11010052,11075588,11141121,11206662,11272197,11337734,11403271,11468804,11534340,11599873,11665413,11730950,11796485,11862023,11927557,11993094,12058630,12124166,12189700,12255238,12320774,12386311,12451846,12517377,12582916,12648455,12713990,12779521,12845063,12910598,12976134,13041671,13107206,13172741,13238279,13303814,13369350,13434885,13500421,13565956,13631496,13697025,13762564,13828102,13893639,13959173,14024709,14090241,14155781,14221318,14286856,14352388,14417924,14483462,14548999,14614532,14680068,14745605,14811142,14876673,14942213,15007749,15073290,15138821,15204356,15269892,15335430,15400961,15466503,15532037,15597574,15663109,15728644,15794181,15859718,15925254,15990788,16056326,16121865,16187399,16252929,16318470,16384006,16449541,16515077,16580613,16646148,16711684,16777224,16842759,16908294,16973828,17039365,17104900,17170436,17235974,17301509,17367044,17432580,17498117,17563653,17629189,17694727,17760260,17825797,17891332,17956871,18022406,18087943,18153477,18219013,18284551,18350087,18415621,18481153,18546692,18612229,18677761,18743306,18808838,18874374,18939905,19005446,19070982,19136516,19202053,19267585,19333126,19398660,19464196,19529739,19595270,19660807,19726341,19791879,19857412,19922948,19988487,20054020,20119556,20185092,20250629,20316168,20381703,20447237,20512772,20578310,20643844,20709384,20774917,20840452,20905991,20971526,21037061,21102597,21168134,21233670,21299206,21364741,21430281,21495812,21561349,21626886,21692420,21757957,21823497,21889025,21954567,22020101,22085637,22151172,22216708,22282247,22347782,22413313,22478853,22544388,22609921,22675462,22741001,22806534,22872069,22937605,23003140,23068673,23134213,23199745,23265286,23330822,23396357,23461892,23527425,23592966,23658502,23724036,23789569,23855108,23920645,23986182,24051718,24117255,24182789,24248321,24313861,24510470,24444934,24576008,24772609,24707077,24379399,24641537,24838149,24903686,24969222,25034760,25100292,25165829,25231371,25296901,25362438,25427974,25493509,25559049,25624580,25690118,25755655,25821189,25886726,25952262,26017799,26083333,26148870,26214405,26279942,26345473,26411015,26476549,26542084,26607624,26673157,26738694,26804229,26869764,26935303,27000838,27066375,27131910,27197447,27262982,27328520,27394054,27459588,27525124,27590662,27656197,27721735,27787265,27852805,27918340,27983878,28049413,28114950,28180485,28246022,28311557,28377093,28442630,28508165,28573704,28639237,28704774,28770311,28835846,28901380,28966919,29032452,29097990,29163524,29229062,29294598,29360133,29425670,29491201,29556742,29622277,29687813,29753350,29818886,29884421,29949958,30015496,30081029,30146566,30212100,30277638,30343172,30408709,30474245,30539781,30605317,30670853,30736391,30801926,30867462,30932993,30998536,31064069,31129605,31195145,31260679,31326209,31391749,31457284,31522823,31588353,31653892,31719425,31784966,31850501,31916036,31981573,32047109,32112645,32178181,32243716,32309249,32374792,32440325,32505861,32571393,32636932,32702469,32768001,32833540,32899079,32964615,33030148,33095686,33161221,33226756,33292292,33357829,33423365,33488900,33554436,33619973,33685510,33751048,33816581,33882118,33947656,34013188,34078726,34144260,34209799,34275340,34340870,34406402,34471940,34537479,34603013,34668548,34734081,34799621,34865158,34930693,34996232,35061767,35127297,35192837,35258373,35323910,35389445,35454983,35520518,35586049,35651588,35717124,35782660,35848197,35913732,35979269,36044808,36110340,36175877,36241415,36306950,36372484,36438023,36503559,36569095,36634629,36700165,36765701,36831237,36896772,36962309,37027844,37093383,37158917,37224453,37289993,37355526,37421061,37486596,37552132,37617671,37683204,37748743,37814279,37879814,37945352,38010887,38076423,38141960,38207495,38273029,38338565,38404101,38469640,38535173,38600709,38666248,38731781,38797319,38862852,38928389,38993928,39059462,39124997,39190533,39256070,39321605,39387141,39452676,39518213,39583750,39649287,39714824,39780361,39845894,39911425,39976967,40042497,40108037,40173577,40239108,40304644,40370181,40435713,40501257,40566790,40632326,40697863,40763398,40828935,40894469,40960006,41025542,41091076,41156615,41222149,41287686,41353222,41418756],"mpf_div_2exp":[5963777,7929857,8126465,8388615,12845057,15335425],"mpz_remove":[5963777,15335425,31260679],"mpz_setbit":[2424833,5636097,5963777,10223617,10289153,12058625,12124161,12910593,15335425,16384001,22347777,23396353,38797313,39583751],"mpq_set_str":[3407873,3932161,5963777,15335425,23986177,24510465,26083329,28311553,29622273,30474241,32505857,35520518,38404097],"mpz_fdiv_q":[5963777,11862017,15335425,15466497,19333121,22085633,33947649,36438023,37814273,39649281],"manipulation":[22478849],"mp_exp_t":[262153,720916,2228233,2949122,3014657,3145729,5439489,6750217,7864322,8847369,10027009,11993102,14745601,16973833,17170441,17563657,17629185,18415617,18677764,19398665,19988481,21495817,21889030,22937609,23330830,23461897,24051713,25100297,25296905,27328520,28180489,28639242,28901380,29491235,30212103,30605313,31326224,31850497,32636931,34013228,34406401,35323905,36175881,36372489,36503557,36831233,38600705,41353217],"mpf_init_set":[3735559,5963777,13303809,15335425,21561345,30539777,38928385],"mpf_get_d":[196610,589827,1310722,2490370,3735554,3866626,4784130,5505026,5963777,7929858,8060930,8126465,8257538,8388610,8912898,9830402,10027010,11665410,11730946,12713986,12845058,15335425,18087938,18415623,21561346,24051714,24838146,25427970,25886722,25690116,27328513,29097986,30539778,31850497,32899074,35323905,36831233,36962310,37748738,37879810,38928386,39518210,40566786,41353218],"msb":[21823490,40173570],"mpz_set_str":[5177345,5701634,5963778,9502721,13500418,15335426,17235975,20447233,22020097,23265281,24903681,30867458,35520513,39256066,41287681],"members":[131073,1441793,1703937,1900545,2621441,3473409,4063233,4390913,4456449,4915201,5963777,6291457,6422529,7864321,9109505,11141121,11599873,12517377,13434881,13631489,13697025,14090241,14876673,15007745,15335425,15400961,16252929,16842753,18939905,19267585,21430273,21889025,22282241,22609921,23068673,23199745,23527425,23789569,24641537,27787265,29491201,30932993,31588353,31653889,32571393,34013185,34537473,34603009,34734081,35127297,35782657,39911425,40042497,40435713],"mpq_init":[983042,2818050,3407877,3932161,3997698,5963777,7143426,8978434,10682372,11927554,12976130,13828098,15335425,15859714,20578308,23986179,24510469,26083331,26673154,27000834,27394050,28246018,28311553,29622275,30474241,32505859,34078722,35192834,35520514,36306946,38404103,40632322,40763394],"mpz_tdiv_r_ui":[5963777,8192001,12386305,15335425,19005441,19660801,24969223,28770305,32964609,36241409,36634625],"men":[8781825,24444929],"mpz_gcd_ui":[5963777,13041665,15335425,20971527,37289985],"mp_bits_per_limb":[5963777,14417921,15073282,15335426,19791874,29032449,34275329,35454977,35717127,36044802,40435713,41156609],"mpf_pow_ui":[196609,3866625,5505025,5963777,7929857,8060929,8126465,8388609,9830401,11665409,12713985,12845057,15335425,18087937,25427969,25886727,32899073,37879809,40566785],"multi":[1114114,1507330,2097154,2162690,2883586,3276802,4063233,4325378,5046274,5111810,5898242,5963777,6815746,7012354,7405570,9043970,9699330,9961474,13238274,13631489,14286850,15073281,15335425,16056322,16121858,16777218,17956866,18022402,18350082,18743298,19529730,19791874,20316162,20905986,22740994,23658498,25034754,25362434,25559042,26279938,26411010,25231362,28573698,28966914,29294594,30015490,30998530,31195138,32374786,27066370,33751042,34209794,34275330,34537473,34996226,35454978,36044802,37945346,38141954,38469634,38666242,38993922,39059458,39714818,39780354,40501250,40697858,40894465,41156610],"mpq_set_num":[5963777,7143425,12976129,13828097,15335425,15859719,26673153,27394049],"mpq_cmp_si":[983041,2818049,3407876,5963777,7143426,10682369,11927559,12976130,13828098,15335425,15859714,20578305,23986178,24510466,26673154,27000833,27394050,29622274,40763394],"mpq_cmp_ui":[983047,2818049,5963777,8978434,10682369,11927553,15335425,20578305,26083330,27000833],"mpz_divisible_p":[1376257,2293761,5963777,7077889,7340033,7733249,8192001,10616833,11206657,11862017,12320775,12386305,13369345,13893633,15335425,15466497,17301505,19005441,19333121,19660801,20381697,20709377,21626881,21954561,22085633,24969217,24379393,26935297,27197441,28704769,28770305,32964609,33947649,36241409,36438017,36634625,37814273,38207489,39649281],"mpn_sec_powm_itch":[5963777,9961473,15335425,25755653,34275332],"mpz_get_d":[5963777,9895937,15335425,15925249,20250625,21102599,32178177],"mimics":[15007745],"mpz_cdiv_q_2exp":[1376257,5963777,7077889,15335425,20381697,20709377,21954561,26935303,27197441,28704769,38207489],"mpn_sec_div_r":[1114113,2162695,3276801,4587525,5963778,7012353,9961473,15073281,15335426,18743297,25559041,31195137,34275329,34996225,37945345],"mpq_set_den":[5963777,7143425,12976129,13828103,15335425,15859713,26673153,27394049],"mpz_odd_p":[5963777,9568257,15138823,15335425,15532033,22478849,27656193,33357825,33423363,35979265,41222145],"maximum":[7536641,7667713,16318465,16908289,27328513,30146561,36503553,39976962],"mpz_millerrabin":[5963777,14155777,15335425,39125000],"malloc":[1835009,3670017,40173570],"mpz_bin_uiui":[5963777,11272199,15335425,29425665],"mpz_pow_ui":[5963777,15335425,16449537,24576001,26607617,27590663,27721729],"mpz_congruent_2exp_p":[5963777,7733249,10616833,13893639,15335425],"mpz_2fac_ui":[3342337,5963777,15335425,29687815,40894465],"mpn_sec_sqr":[1114114,2162689,3276801,4521988,5963778,7012353,9961473,15073281,15335426,18743297,25559041,31195137,34275329,34996225,37945351],"mpf_inp_str":[5963777,8781831,15335425,39976961],"mpz_cmpabs":[393217,1638401,5963777,7602177,10354693,15335425,24707073,27852801,37355521,37421057],"mpf_set_d":[1310721,4784135,5963777,8257537,15335425,24444929,25690113,28246017,30277633,39518209],"mpf_set_q":[1310721,4784129,5963777,8257537,15335425,24444929,25690113,28246023,30277633,39518209,40632324],"mpf_set_z":[1310721,4784129,5963777,8257537,15335425,24444929,25690113,28246017,30277639,39518209],"mpn_and_n":[2883585,4325377,5963777,6815745,15335425,16777223,18350081,30998531,32374785,33751041,38993921],"mpf_div":[196609,3866625,5505025,5963777,7929857,8060929,8126465,8388609,9830401,11665409,12713985,12845063,15335425,18087937,25427969,25886721,32899073,37879809,40566785],"mpf_init_set_str":[3735553,5963777,13303815,15335425,21561345,30539777,38928385],"mpz_urandomm":[5963777,7536642,12648449,15335425,24117255,30146561,30736385],"mpq_inp_str":[5963777,8978439,15335425,34078721],"max_size":[5963779,7536647,15335427,30146567,36503559],"mpn_scan1":[5963777,9699329,15335425,23658503,26279937,28966913,35454977,41156609],"mpn_scan0":[5963777,9699329,15335425,23658497,26279943,28966913,35454977,41156609],"mpz_tstbit":[2424833,5636103,5963777,10223617,10289153,12058625,12124161,12910593,15335425,16384001,22347777,23396353,38797313,39583745],"mpz_primorial_ui":[5963777,15335425,24313863],"mpz_powm_ui":[5963777,15335425,16449537,24576001,26607617,27590657,27721735],"mpz_tdiv_q":[5963777,8192001,12386311,15335425,19005441,19660801,24969217,28770305,32964609,36241409,36634625],"mpz_set_d":[5177345,5963777,9502721,15335425,17235969,20447233,22020104,23265281,24903681,41287681],"mpf_init":[196610,589825,2490375,3866626,4259842,5505026,5963777,7929858,8060930,8126465,8388610,8781826,8912899,9830402,10027010,11665410,11730947,12713986,12845058,15335425,18087938,19988482,24051714,24182786,24444930,24838145,25427970,25886722,28246018,29097985,30277634,32899074,36503554,36962305,37748738,37879810,40566786,40632323,40763394,41353218],"mpz_set_f":[5177345,5963777,9502721,15335425,17235969,20447233,22020097,23265281,24903688,41287681],"mpz_get_d_2exp":[5963777,9895937,15335425,15925249,20250631,21102593,32178177],"mpz_set_q":[5177345,5963777,9502721,15335425,17235969,20447233,22020097,23265281,24903681,41287688],"mpz_perfect_square_p":[4718593,5963777,6356999,6488065,15335425,26017793,30408705,37617665],"mpn_popcount":[5963777,9699335,15335425,23658497,26279937,28966913,35454977,41156609],"multiplicand":[5963777,15335425,18284550],"mpz_cdiv_ui":[1376257,5963777,7077895,15335425,20381697,20709377,21954561,26935297,27197441,28704769,38207489],"mpz_addmul":[3538945,5963777,7995393,13107201,14548993,14811137,15335425,17694727,18808833,19070977,22675457,26738689,29229057,31522817,33882113,38010881,41025537],"mpn_sec_powm":[1114113,2162689,3276801,5963778,7012353,9961473,15073281,15335426,18743297,25559041,25755654,31195137,34275335,34996225,37945345],"mpf_mul_2exp":[5505031,5963777,8060929,15335425,25427969],"mpz_init":[1376258,2293762,2424834,3342338,3538946,4718594,5177346,5701635,5963777,6488066,7274498,7340034,7536642,7995394,9502724,10289154,11206658,11272194,12386306,12648450,12976130,13041666,13500418,13959171,14548994,14811138,15335425,15466498,16187394,16384002,16449538,16908290,17235970,17825794,18808834,19005442,19070978,19333122,19660802,20447234,21168130,21299202,21626882,21954562,22020098,22675458,22806530,23986178,24117250,21823490,24313858,24576002,24969218,24379394,25821186,24903682,26607618,26738690,26935298,27000834,27197442,27394050,27590658,27721730,28704770,28770306,29425666,29687810,30146562,30277634,30736386,31260674,32112641,33882114,35061762,35389441,36241410,36438018,37814274,38010882,38076418,38207490,38797314,39256066,39387143,39649282,40894466,41025538,41287682],"mpn_zero":[1507329,5963777,15335425,20905985,29294599],"magnitude":[2424833,5636097,7864321,10223617,10289153,11599873,12058625,12124161,12910593,14876673,16384001,21430273,22282241,22347777,23396353,30932993,33030146,38797313,39583745],"mpz_out_raw":[1245191,5963778,11337733,15335426,18874369,22806529],"mpn_tdiv_qr":[5111809,5963777,9043969,14286849,15335425,16121857,19791873,20316161,22740993,25034753,25231367,26411009,28573697,30015489,34209793,36044801,38141953,38469633,38666241,39714817,39780353,40501249,40697857],"mpf_get_prec":[589825,2490369,4259841,5963777,8912897,11730947,15335425,24182785,24838151,29097989,36962305,40632322],"mpf_size":[5963777,12451847,15335425],"mpn_neg":[5111809,5963777,9043969,14286849,15335425,16121857,19791873,20316161,22740993,25034753,26411015,25231361,28573697,30015489,34209793,36044801,38141953,38469633,38666241,39714817,39780353,40501249,40697857],"minuend":[5963777,15335425,26411009,36569094],"mpz_jacobi":[5963777,8650759,15335425,29753345],"mpn_cnd_add_n":[1114113,2162689,3276801,5963777,7012359,9961473,15073281,15335425,18743297,25559041,31195137,34275329,34996225,37945345],"mpn_nand_n":[2883585,4325377,5963777,6815745,15335425,16777217,18350081,30998533,32374785,33751041,38993921],"mpz_cdiv_qr":[1376257,2293761,5963777,7077889,7340033,7733249,8192001,10616833,11206657,11862017,12320769,12386305,13369345,13893633,15335425,15466497,17301505,19005441,19333121,19660801,20381697,20709383,21626881,21954561,22085633,24969217,24379393,26935297,27197441,28704769,28770305,32964609,33947649,36241409,36438017,36634625,37814273,38207489,39649281],"mpq_sgn":[983041,2818055,5963777,10682369,11927553,15335425,20578305,27000833],"mpz_realloc2":[5701641,5963777,13959169,15335425,16908289,32112641,35389441,39256067,39387137],"mpz_divexact_ui":[5963777,7340033,11206663,15335425],"mpz_fac_ui":[3342343,5963777,15335425,29687809,40894465],"mpq_abs":[5242885,5963777,9240577,11403265,15335425,18284545,23592961,33095681,34340865,36569089,40828929],"mpz_fib_ui":[5963777,15335425,17825799,29556737],"mpq_sub":[5242881,5963777,9240577,11403265,15335425,18284545,23592961,33095681,34340865,36569093,40828929],"mpz_fdiv_ui":[2293761,5963777,11862017,15335425,15466497,19333121,21626881,22085639,33947649,36438017,37814273,39649281],"mpz_size":[5832707,5963777,8454146,13500418,15335425,16187393,21168129,21233665,26476553,39256065],"mpz_cmpabs_d":[393224,1638401,5963777,7602177,10354689,15335425,24707073,27852801,37355521,37421057],"mpf_get_d_2exp":[5963777,15335425,18415617,27328513,31850497,35323911,36831233],"multiple":[458754,2686977,5570561,5963778,6029313,6291457,6553601,7864323,11141121,15335426,15400961,16842755,21430275,31916034,33292290,34406404,34537473,38076419,40960001],"mpz_gcdext":[5963777,13041665,15335425,20971521,37289991],"mpz_mod":[1376257,2293761,5963777,7077889,7340033,7733249,8192001,10616833,11206657,11862017,12320769,12386305,13369345,13893633,15335425,15466497,17301505,19005441,19333121,19660801,20381697,20709377,21626881,21954561,22085633,24379399,24969217,26935297,27197441,28704769,28770305,32964609,33947649,36241409,36438017,36634625,37814273,38207489,39649281],"mpf_add_ui":[5963777,12713991,15335425,32899073],"mpn_sub":[5111809,5963777,9043969,14286849,15335425,16121857,19791873,20316161,22740999,25034753,26411009,25231361,28573697,30015489,34209793,36044801,38141953,38469633,38666241,39714817,39780353,40501249,40697857],"mpn_sec_add_1_itch":[3276804,5963777,15335425,23134213],"mp_bytes_per_limb":[2097154,5832708,13500420,14417927,15335425,16187396,18022402,18743300,21168132,21233666,26476548,29032449,35454978,35717121,38141956,40435713],"mpf_floor":[3014657,3145729,5439489,5963777,10027009,14745601,15335425,17629185,19988481,24051713,30605313,36503553,38600705,41353223],"modulo":[2162689,5963787,7733250,10616834,13893634,15073281,15335435,18743297,24576002,26607619,27721731,34275329,35061761],"mutable":[11468801,39452673],"mpz_fdiv_qr":[1376257,2293761,5963777,7077889,7340033,7733249,8192001,10616833,11206657,11862017,12320769,12386305,13369345,13893633,15335425,15466497,17301505,19005441,19333121,19660801,20381697,20709377,21626881,21954561,22085633,24969217,24379393,26935297,27197441,28704769,28770305,32964609,33947655,36241409,36438017,36634625,37814273,38207489,39649281],"mpq_denref":[5963777,7143431,12976129,13828099,15335425,15859713,26673153,27394051,36306945],"mpz_addmul_ui":[5963777,13107207,15335425,17694721],"mpn_mod_1":[5111809,5963777,9043969,14286849,15335425,16121857,19791873,20316161,22740993,25034753,26411009,25231361,28573697,30015489,34209799,36044801,38141953,38469633,38666241,39714817,39780353,40501249,40697857],"modified":[7536641,12648449,24117249,30146561,30736385],"mpz_add_ui":[5963777,7143426,12976130,15335425,18808841,26673154,27394050,38010881],"mpz_init_set":[5963777,7274503,15335425,21037057,25165825,30867457,40108033],"making":[24444929],"mpf_set_prec":[589825,2490369,4259841,5963777,8912897,11730951,15335425,24182785,24838145,29097985,33030145,36962305,40632323],"mpz_cdiv_qr_ui":[1376257,5963777,7077889,15335425,20381703,20709377,21954561,26935297,27197441,28704769,38207489],"mpz_tdiv_qr_ui":[5963777,8192001,12386305,15335425,19005441,19660801,24969217,28770305,32964615,36241409,36634625],"mpq_cmp":[983041,2818049,5963777,10682376,11927553,15335425,20578306,27000834],"mpz_even_p":[5963777,9568257,15138819,15335425,15532033,22478849,27656193,33423367,33357825,35979265,41222145],"mpz_cdiv_r_2exp":[1376257,5963777,7077889,15335425,20381697,20709377,21954561,26935297,27197447,28704769,38207489],"mpn_sec_sqr_itch":[4521989,5963777,15335425,37945348],"mpf_ui_sub":[5963777,15335425,18087937,37879815,40566785],"marshal":[5046274,21823490,27066370,40173570],"mpz_ui_kronecker":[851969,1966081,5963777,15335425,15597569,28377089,32440327],"mpn_random":[2097154,5963777,15335425,18022408],"method":[196609,393217,458753,524289,589825,655361,851969,917505,983041,1048577,1114113,1245185,1310721,1376257,1507329,1638401,1769473,1835009,1966081,2031617,2097153,2162689,2293761,2359297,2424833,2490369,2555905,2818049,2883585,2949121,3014657,3145729,3276801,3342337,3407873,3538945,3670017,3735553,3866625,3932161,3997697,4128769,4259841,4325377,4521985,4587521,4653057,4718593,4784129,4980737,5046273,5111809,5177345,5242881,5439489,5505025,5570561,5636097,5701633,5832705,5898241,6094849,6356993,6488065,6619137,6815745,6946817,7012353,7077889,7143425,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7798785,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8650753,8781825,8912897,8978433,9043969,9175041,9240577,9306113,9502721,9568257,9699329,9764865,9830401,9895937,9961473,10027009,10158081,10223617,10289153,10354689,10485761,10616833,10682369,11075585,11206657,11272193,11337729,11403265,11665409,11730945,11862017,11927553,12058625,12124161,12255233,12320769,12386305,12451841,12648449,12713985,12779521,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13500417,13828097,13893633,13959169,14024705,14155777,14286849,14483457,14548993,14680065,14745601,14811137,15073281,15138817,15466497,15532033,15597569,15728641,15794177,15859713,15925249,16056321,16121857,16187393,16318465,16384001,16449537,16777217,16908289,17039361,17104897,17235969,17301505,17432577,17629185,17694721,17825793,17956865,18022401,18087937,18284545,18350081,18415617,18546689,18612225,18677761,18743297,18808833,18874369,19005441,19070977,19136513,19333121,19529729,19660801,19726337,19791873,19857409,19922945,19988481,20054017,20185089,20250625,20316161,20381697,20447233,20512769,20578305,20709377,20774913,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21561345,21626881,21692417,21757953,21823489,21954561,22020097,22085633,22216705,22347777,22478849,22675457,22740993,22806529,22872065,23134209,23265281,23396353,23592961,23658497,23986177,24051713,24117249,24182785,24313857,24444929,24576001,24510465,24379393,24707073,24838145,24903681,24969217,25034753,25165825,25231361,25362433,25427969,25493505,25559041,25624577,25690113,25755649,25821185,25886721,25952257,26017793,26083329,26148865,26279937,26345473,26411009,26476545,26607617,26673153,26738689,26935297,27000833,27066369,27197441,27328513,27394049,27590657,27656193,27721729,27852801,28049409,28114945,28246017,28311553,28377089,28508161,28573697,28639233,28704769,28770305,28901377,28966913,29097985,29229057,29294593,29360129,29425665,29556737,29622273,29687809,29753345,29884418,30015489,30146561,30277633,30343169,30408705,30474241,30539777,30605313,30670849,30736385,30867457,30998529,31064065,31195137,31260673,31391745,31522817,31719425,31850497,31916033,32047105,32112641,32178177,32374785,32440321,32505857,32636929,32833537,32899073,32964609,33095681,33161217,33292289,33357825,33423361,33554433,33751041,33816577,33882113,33947649,34078721,34144257,34209793,34275329,34340865,34865153,34930689,34996225,35061761,35192833,35323905,35389441,35454977,35520513,35586049,35848193,35913729,35979265,36044801,36110337,36241409,36306945,36438017,36503553,36569089,36634625,36700161,36831233,36896769,36962305,37158913,37289985,37355521,37421057,37617665,37683201,37748737,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38338561,38404097,38469633,38600705,38666241,38797313,38928385,38993921,39059457,39124993,39256065,39321601,39387137,39518209,39583745,39649281,39714817,39780353,39845890,39976961,40108033,40173569,40370177,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41156609,41222145,41287681,41353217],"mpq_cmp_z":[983041,2818049,5963777,10682369,11927553,15335425,20578305,27000839],"mpz_tdiv_ui":[5963777,8192001,12386305,15335425,19005441,19660801,24969217,28770305,32964609,36241409,36634631],"mpz_inp_str":[1245185,5963777,11337729,15335425,18874369,22806535],"mpz_mod_ui":[5963777,15335425,21626888,24379393],"mpn_sec_div_qr_itch":[5963777,15335425,18743300,26148869],"mpn_iorn_n":[2883585,4325383,5963777,6815745,15335425,16777217,18350081,30998529,32374785,33751041,38993921],"mpf_fits_sshort_p":[3014663,3145729,5439489,5963777,10027009,14745601,15335425,17629185,19988481,24051713,30605313,36503553,38600705,41353217],"mpz_fdiv_q_ui":[2293767,5963777,11862017,15335425,15466497,19333121,22085633,33947649,36438017,37814273,39649281],"mpz_init_set_si":[393218,1376258,1638401,2293762,3538946,4718594,5636098,5963777,6356994,6488066,7077890,7274497,8192004,10354690,11862018,12124162,12386308,13107204,14483458,14811138,15335425,15466500,15925250,19005442,19070978,19333122,19660802,20381698,20709380,21037057,21954564,22085634,22347778,22478850,23265284,24707074,24969218,25165831,26017794,26738690,26935298,27197442,28704770,28770308,29229060,29425666,30408706,30867457,31522818,32178178,32964610,33947652,36241410,36438020,36634626,37617666,37814274,38207492,39583746,39649282,40108033,41025538],"mpz_tdiv_q_2exp":[5963777,8192001,12386305,15335425,19005441,19660807,24969217,28770305,32964609,36241409,36634625],"mpn_mul":[5111809,5963777,9043969,14286849,15335425,16121863,19791873,20316161,22740993,25034753,26411009,25231361,28573697,30015489,34209793,36044801,38141953,38469633,38666241,39714817,39780353,40501249,40697857],"mpz_fits_uint_p":[5963777,9568263,15138817,15335425,15532033,22478849,27656193,33357825,33423361,35979265,41222145],"mpz_scan1":[2424833,5636097,5963777,10223618,10289153,12058632,12124161,12910593,15335425,16384001,22347777,23396353,38797313,39583745],"member":[196609,393217,458753,524289,589825,851969,983041,1114113,1245185,1310721,1376257,1507329,1638401,1835009,1966081,2031617,2097153,2162689,2293761,2424833,2490369,2555905,2818049,2883585,3014657,3145729,3276801,3342337,3407873,3538945,3670017,3735553,3866625,3932161,3997697,4128769,4259841,4325377,4521985,4587521,4718593,4784129,5046273,5111809,5177345,5242881,5439489,5505025,5570561,5636097,5701633,5832705,5898241,6356993,6488065,6619137,6815745,7012353,7077889,7143425,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7798785,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8650753,8781825,8912897,8978433,9043969,9240577,9306113,9502721,9568257,9699329,9830401,9895937,9961473,10027009,10158081,10223617,10289153,10354689,10485761,10616833,10682369,10813441,11075585,11206657,11272193,11337729,11403265,11665409,11730945,11862017,11927553,12058625,12124161,12189697,12255233,12320769,12386305,12451841,12648449,12713985,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13500417,13828097,13893633,13959169,14024705,14155777,14286849,14483457,14548993,14745601,14811137,15073281,15138817,15269889,15466497,15532033,15597569,15728641,15794177,15859713,15925249,16056321,16121857,16187393,16318465,16384001,16449537,16777217,16908289,17039361,17235969,17301505,17629185,17694721,17825793,17956865,18022401,18087937,18284545,18350081,18415617,18546689,18612225,18743297,18808833,18874369,19005441,19070977,19333121,19464193,19529729,19660801,19726337,19791873,19988481,20250625,20316161,20381697,20447233,20512769,20578305,20709377,20774913,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21561345,21626881,21692417,21757953,21954561,22020097,22085633,22347777,22478849,22675457,22740993,22806529,22872065,23134209,23265281,23396353,23592961,23658497,23724033,23986177,24051713,24117249,21823489,24182785,24313857,24510465,24576001,24444929,24707073,24379393,24838145,24903681,24969217,25034753,25165825,25231361,25362433,25493505,25559041,25690113,25427969,25755649,25821185,25886721,25952257,26017793,26083329,26148865,26279937,26411009,26476545,26607617,26673153,26738689,26935297,27000833,27197441,27328513,27394049,27590657,27656193,27721729,27852801,28049409,28114945,28246017,28311553,28377089,28508161,28573697,28639233,28704769,28770305,28966913,29097985,29163521,29229057,29294593,29360129,29425665,29556737,29622273,29687809,29753345,29884417,30015489,30146561,30277633,30408705,30474241,30539777,30605313,30670849,30736385,30867457,30998529,31064065,31195137,31260673,31391745,31522817,31850497,31916033,32047105,32112641,32178177,32374785,32440321,32505857,32833537,32899073,32964609,33095681,27066369,33161217,33292289,33357825,33423361,33554433,33751041,33816577,33882113,33947649,34078721,34209793,34275329,34340865,34668545,34865153,34930689,34996225,35061761,35192833,35323905,35389441,35454977,35520513,35848193,35979265,36044801,36241409,36306945,36438017,36503553,36569089,36634625,36700161,36831233,36962305,37158913,37289985,37355521,37421057,37617665,37748737,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38338561,38404097,38469633,38600705,38666241,38797313,38928385,38993921,39059457,39124993,39256065,39321601,39387137,39518209,39583745,39649281,39714817,39780353,39845889,39976961,40108033,40173569,40370177,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41091073,41156609,41222145,41287681,41353217],"mpz_scan0":[2424833,5636097,5963777,10223624,10289153,12058626,12124161,12910593,15335425,16384001,22347777,23396353,38797313,39583745]} \ No newline at end of file diff --git a/docs/fti/FTI_110.json b/docs/fti/FTI_110.json new file mode 100644 index 0000000..19b4cdf --- /dev/null +++ b/docs/fti/FTI_110.json @@ -0,0 +1 @@ +{"num2":[983050,5963778,11927562,15335426],"necessary":[1245185,1835009,2555905,5701633,5963781,11337729,15335429,16908290,17825793,18415617,20250626,21102594,25821185,29556737,35192833,35323905,40173569],"new_free":[9306116],"need":[16908289],"new":[196616,262145,393218,524292,589828,786433,851970,983042,1114128,1179649,1245188,1310724,1376260,1441793,1507340,1572865,1638401,1835011,1966082,2097156,2162698,2228225,2293764,2424838,2490372,2555908,2686979,2818052,2883600,3014658,3145732,3276812,3342338,3407880,3538948,3604481,3735560,3801090,3866632,3997700,4063233,4128774,4194305,4325392,4718596,4784132,4849665,5046282,5111820,5177348,5373955,5439490,5505032,5570566,5636098,5701638,5767169,5832710,5898254,6029315,6160388,6225921,6356994,6488068,6553603,6619142,6684673,6750209,6815760,7012368,7077890,7143426,7208961,7274504,7340038,7405572,7536642,7602178,7667714,7733254,7864321,7929864,7995398,8060940,8126468,8192008,8257544,8323080,8388616,8454145,8585221,8650756,8716289,8781828,8847361,8912900,8978436,9043984,9240577,9306117,9371649,9437185,9502728,9568258,9633793,9699332,9830408,9895938,9961482,10027016,10092547,10223618,10289158,10354692,10551297,10616834,10682372,10878977,10944513,11206660,11272194,11337732,11534337,11665412,11730949,11796481,11862022,11927554,12058626,12124162,12255240,12320772,12386310,12451842,12582913,12648454,12713992,12845068,12910596,12976134,13041670,13107204,13172740,13238280,13303814,13369346,13434885,13500422,13565953,13631489,13762564,13828102,13893636,13959172,14024712,14155778,14286860,14352385,14483464,14548998,14614529,14745602,14811140,14942209,15007749,15073288,15138818,15204355,15466502,15532034,15597572,15663105,15794178,15859718,15925250,15990785,16056324,16121872,16187410,16318466,16384004,16449538,16515073,16580609,16646145,16711681,16777232,16842753,16908292,16973825,17039362,17170433,17235974,17301506,17367041,17498113,17563649,17629186,17694726,17760257,17825794,17891332,17956868,18022404,18087948,18153473,18219009,18350092,18415620,18612228,18743314,18808834,18874372,19005444,19070980,19202049,19333124,19398657,19529754,19660804,19791884,19988486,20250628,20316172,20381702,20447236,20578308,20643841,20709384,20774916,20840449,20905996,20971522,21037058,21102594,21168132,21233666,21299204,21364737,21430273,21495809,21561348,21626884,21692422,21757954,21954566,22020100,22085634,22151172,22282241,22347778,22478850,22544385,22675460,22741008,22806532,22937601,23003137,23265288,23396354,23461889,23658500,23855105,23920641,23986184,24051720,24117258,21823492,24313858,24510472,24576008,24707074,24444934,24838148,24969220,25034764,25100289,25296897,25362436,25559052,25427976,24379398,25821186,25165826,25886728,26017798,26083332,24903684,26214401,26279940,26411020,26476550,26542081,26607624,26673154,26738692,25690120,26804225,26869763,25493508,26935300,27000836,25231384,27197444,27328518,27394054,27459588,27525123,27590660,27656194,27721734,27852802,27918339,28114952,28180481,28246024,28311560,28377090,28573708,28704772,28770310,28966920,29097988,29229060,29294600,29360130,29425668,29556740,29622276,29687810,29753348,29884420,30015500,30081025,30146562,30212100,30277640,30408706,30474248,30539780,30605314,30736390,30867460,30998544,31064066,31129601,31195152,31260678,31457281,31522822,31653889,31850500,31981569,32112648,32178178,32243713,32374800,32440322,32505860,32833542,32899084,32964614,27066380,33161218,33226753,33357826,33423362,33488897,33619971,33751056,33882116,33947656,34013185,34078724,34209796,34275348,34537473,34603009,34799617,34865156,34930692,34996240,35061766,35192834,35258369,35323910,35389448,35454988,35520515,35651585,35979266,36044812,36175873,36241412,36306946,36372481,36438022,36503554,36634626,36765697,36962312,37027841,37093377,37224449,37289994,37355524,37421058,37486593,37552131,37617670,37748748,37814276,37879816,37945356,38010886,38076422,38141972,38207494,38273025,38338562,38404100,38469648,38535169,38600706,38666256,38731777,38797318,38862849,38928388,38993936,39059460,39124994,39190529,39256071,39387140,39518212,39583746,39649284,39714828,39780368,39845894,39976962,40108034,40173574,40239105,40304641,40370180,40501260,40566792,40632330,40697868,40763400,40894466,41025540,41156620,41222146,41287684,41353224,41418755],"needed":[1835009,3670017,5701633,16908290,21168129,21233665,40173569],"new_allocate":[9306116],"numerator":[983041,1376257,2293761,2621441,3932161,5963782,7077889,7340033,8192001,8978433,10813442,11206657,11862017,11927553,12320769,12386305,12976137,13369345,14352385,15335430,15466497,15859721,16842753,17301505,19005441,19333121,19660801,20381697,20709377,21626881,21954561,22085633,24969217,24379393,26673156,26935297,25231361,27197441,27394050,28704769,28770305,32964609,33947649,35520514,36241409,36438017,36634625,37814273,38207489,39649281],"num":[7143430,12976146,13828098,15859722,26673158,27394052,34078722,36306946],"negative":[393217,983041,1179649,1638401,2818050,3080196,7536642,7602177,7864322,8781826,10223617,10354689,10682369,11599874,11927553,12058625,13041665,13172737,13238273,14483457,14876674,16187394,18612225,19529730,21430274,21626881,24444930,24379393,26607617,27000833,27721729,27852801,28114945,29425665,30146562,30408705,34471938,34930689,36503554,37289985,37355521,37421057,41091073],"nan":[393217,13172737,27852801],"numbers":[589827,2555908,5963778,7536642,8781825,12648450,15335426,16908289,17825795,24117249,24313857,24444929,25821187,29556742,29884419,30146563,30736385,36503554,36962310,39845891],"nail":[40173569],"native":[65537,131074,196615,262150,327682,393222,458757,524294,589830,655365,720898,786437,851974,917509,983046,1048578,1114123,1179653,1245191,1310726,1376263,1441797,1507336,1572869,1638406,1703938,1769474,1835016,1900546,1966086,2031622,2097159,2162698,2228230,2293767,2359301,2424840,2490374,2555911,2621442,2686981,2752514,2818054,2883593,2949125,3014662,3080197,3145734,3211269,3276810,3342342,3407879,3473410,3538952,3604485,3670023,3735559,3801090,3866631,3932166,3997702,4063240,4128773,4194310,4259845,4325385,4390914,4456453,4521990,4587527,4653061,4718599,4784134,4849670,4915202,4980741,5046280,5111817,5177350,5242887,5308418,5373957,5439494,5505032,5570568,5636103,5701639,5767173,5832711,5898250,5963778,6029317,6094850,6160389,6225925,6291458,6356998,6422530,6488071,6553605,6619141,6684678,6750214,6815753,6881287,6946818,7012362,7077894,7143430,7208965,7274503,7340040,7405575,7471110,7536647,7602182,7667719,7733256,7798790,7864331,7929863,7995400,8060936,8126471,8192009,8257543,8323078,8388615,8454151,8519687,8585218,8650759,8716294,8781831,8847365,8912902,8978439,9043977,9109506,9175045,9240583,9306120,9371653,9437190,9502727,9568262,9633797,9699335,9764869,9830407,9895942,9961482,10027015,10092549,10158088,10223623,10289160,10354695,10420229,10485765,10551302,10616838,10682375,10747911,10813445,10878982,10944518,11010053,11075589,11141122,11206663,11272198,11337735,11403272,11468805,11534341,11599874,11665414,11730951,11796486,11862024,11927558,11993095,12058631,12124167,12189701,12255239,12320775,12386312,12451847,12517378,12582917,12648456,12713991,12779522,12845064,12910599,12976135,13041672,13107207,13172742,13238280,13303815,13369351,13434886,13500422,13565957,13631497,13697026,13762565,13828103,13893640,13959174,14024710,14090242,14155782,14221319,14286857,14352389,14417925,14483463,14549000,14614533,14680069,14745606,14811143,14876674,14942214,15007750,15073291,15138822,15204357,15269893,15335431,15400962,15466504,15532038,15597575,15663110,15728645,15794182,15859719,15925255,15990789,16056327,16121866,16187400,16252930,16318471,16384007,16449542,16515078,16580614,16646149,16711685,16777225,16842760,16908295,16973829,17039366,17104901,17170437,17235975,17301510,17367045,17432581,17498118,17563654,17629190,17694728,17760261,17825798,17891333,17956872,18022407,18087944,18153478,18219014,18284552,18350088,18415622,18481154,18546693,18612230,18677762,18743307,18808839,18874375,18939906,19005447,19070983,19136517,19202054,19267586,19333127,19398661,19464197,19529740,19595271,19660808,19726342,19791880,19857413,19922949,19988488,20054021,20119557,20185093,20250630,20316169,20381704,20447238,20512773,20578311,20643845,20709385,20774918,20840453,20905992,20971527,21037062,21102598,21168135,21233671,21299207,21364742,21430282,21495813,21561350,21626887,21692421,21757958,21823500,21889026,21954568,22020102,22085638,22151173,22216709,22282248,22347783,22413315,22478854,22544389,22609922,22675463,22741002,22806535,22872070,22937606,23003141,23068674,23134214,23199746,23265287,23330823,23396358,23461893,23527426,23592967,23658503,23724037,23789570,23855109,23920646,23986183,24051719,24117256,24182790,24248322,24313862,24444935,24576009,24772610,24510471,24641538,24707078,24379400,24838150,24903687,24969223,25034761,25100293,25165830,25231372,25296902,25362439,25427975,25493510,25559050,25624581,25690119,25755656,25821190,25886727,25952263,26017800,26083334,26148871,26214406,26279943,26345474,26411016,26476550,26542085,26607625,26673158,26738695,26804230,26869765,26935304,27000839,27066376,27131911,27197448,27262983,27328521,27394055,27459589,27525125,27590663,27656198,27721736,27787266,27852806,27918341,27983879,28049414,28114951,28180486,28246023,28311558,28377094,28442631,28508166,28573705,28639238,28704775,28770312,28835847,28901381,28966920,29032453,29097991,29163525,29229063,29294599,29360134,29425671,29491202,29556743,29622278,29687814,29753351,29818887,29884422,29949959,30015497,30081030,30146567,30212101,30277639,30343173,30408710,30474246,30539782,30605318,30670854,30736392,30801927,30867463,30932994,30998537,31064070,31129606,31195146,31260680,31326210,31391750,31457285,31522824,31588354,31653893,31719426,31784967,31850502,31916037,31981574,32047110,32112646,32178182,32243717,32309250,32374793,32440326,32505862,32571394,32636933,32702470,32768002,32833541,32899080,32964616,33030149,33095687,33161222,33226757,33292293,33357830,33423366,33488901,33554437,33619974,33685511,33751049,33816582,33882119,33947657,34013189,34078727,34144261,34209800,34275341,34340871,34406403,34471941,34537480,34603014,34668549,34734082,34799622,34865159,34930694,34996233,35061768,35127298,35192838,35258374,35323911,35389446,35454984,35520519,35586050,35651589,35717125,35782661,35848198,35913733,35979270,36044809,36110341,36175878,36241416,36306951,36372485,36438024,36503560,36569096,36634630,36700166,36765702,36831238,36896773,36962310,37027845,37093384,37158918,37224454,37289994,37355527,37421062,37486597,37552133,37617672,37683205,37748744,37814280,37879815,37945353,38010888,38076424,38141961,38207496,38273030,38338566,38404102,38469641,38535174,38600710,38666249,38731782,38797320,38862853,38928390,38993929,39059463,39124998,39190534,39256071,39321606,39387142,39452677,39518214,39583751,39649288,39714825,39780362,39845895,39911426,39976968,40042498,40108038,40173580,40239109,40304645,40370182,40435714,40501258,40566791,40632327,40697864,40763399,40828936,40894470,40960007,41025543,41091077,41156616,41222150,41287687,41353223,41418757],"nonnegative":[10223617,12058625],"new_reallocate":[9306116],"needs":[29884417,33030145,38141953,39845889],"net":[65537,131073,196609,262145,327681,393217,458753,524289,589825,655361,720897,786433,851969,917505,983041,1048577,1114113,1179649,1245185,1310721,1376257,1441794,1507329,1572865,1638401,1703937,1769473,1835009,1900545,1966081,2031617,2097153,2162689,2228225,2293761,2359297,2424833,2490369,2555905,2621441,2686977,2752513,2818049,2883585,2949121,3014657,3080193,3145729,3211265,3276801,3342337,3407873,3473409,3538945,3604481,3670017,3735553,3801089,3866625,3932161,3997697,4063234,4128769,4194305,4259841,4325377,4390913,4456449,4521985,4587521,4653057,4718593,4784129,4849665,4915201,4980739,5046273,5111809,5177345,5242881,5308417,5373953,5439489,5505025,5570561,5636097,5701633,5767169,5832705,5898241,5963777,6029313,6094849,6160385,6225921,6291457,6356993,6422529,6488065,6553601,6619137,6684673,6750209,6815745,6881281,6946817,7012353,7077889,7143425,7208961,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7798785,7864322,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8519681,8585217,8650753,8716289,8781825,8847361,8912897,8978433,9043969,9109505,9175041,9240577,9306114,9371649,9437185,9502721,9568257,9633793,9699329,9764865,9830401,9895937,9961473,10027009,10092545,10158081,10223617,10289153,10354689,10420225,10485761,10551297,10616833,10682369,10747905,10813441,10878977,10944513,11010049,11075585,11141121,11206657,11272193,11337729,11403265,11468801,11534337,11599873,11665409,11730945,11796481,11862017,11927553,11993089,12058625,12124161,12189697,12255233,12320769,12386305,12451841,12517377,12582913,12648449,12713985,12779521,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13434881,13500417,13565953,13631490,13697025,13762561,13828097,13893633,13959169,14024705,14090241,14155777,14221313,14286849,14352385,14417921,14483457,14548993,14614529,14680065,14745601,14811137,14876673,14942209,15007745,15073281,15138817,15204353,15269889,15335425,15400961,15466497,15532033,15597569,15663105,15728641,15794177,15859713,15925249,15990785,16056321,16121857,16187393,16252929,16318465,16384001,16449537,16515073,16580609,16646145,16711681,16777217,16842753,16908289,16973825,17039361,17104897,17170433,17235969,17301505,17367041,17432577,17498113,17563649,17629185,17694721,17760257,17825793,17891329,17956865,18022401,18087937,18153473,18219009,18284545,18350081,18415617,18481153,18546689,18612225,18677761,18743297,18808833,18874369,18939906,19005441,19070977,19136513,19202049,19267585,19333121,19398657,19464193,19529729,19595265,19660801,19726337,19791873,19857409,19922945,19988481,20054017,20119553,20185089,20250625,20316161,20381697,20447233,20512769,20578305,20643841,20709377,20774914,20840449,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21364737,21430273,21495809,21561345,21626881,21692417,21757953,21823489,21889025,21954561,22020097,22085633,22151169,22216705,22282241,22347777,22413319,22478849,22544385,22609921,22675457,22740993,22806529,22872065,22937601,23003137,23068673,23134209,23199745,23265281,23330817,23396353,23461889,23527425,23592961,23658497,23724033,23789569,23855105,23920641,23986177,24051713,24117249,24182785,24248321,24313857,24444929,24576001,24772609,24510465,24641537,24707073,24379393,24838145,24903681,24969217,25034753,25100289,25165825,25231361,25296897,25362433,25427969,25493505,25559041,25624577,25690113,25755649,25821185,25886721,25952257,26017793,26083329,26148865,26214401,26279937,26345473,26411009,26476545,26542081,26607617,26673153,26738689,26804225,26869761,26935297,27000833,27066369,27131905,27197441,27262977,27328513,27394049,27459585,27525121,27590657,27656193,27721729,27787265,27852801,27918337,27983873,28049409,28114945,28180481,28246017,28311553,28377089,28442625,28508161,28573697,28639233,28704769,28770305,28835841,28901377,28966913,29032449,29097985,29163521,29229057,29294593,29360129,29425665,29491201,29556737,29622273,29687809,29753345,29818881,29884417,29949953,30015489,30081025,30146561,30212097,30277633,30343169,30408705,30474241,30539777,30605313,30670849,30736385,30801921,30867457,30932993,30998529,31064065,31129601,31195137,31260673,31326209,31391745,31457281,31522817,31588353,31653890,31719425,31784961,31850497,31916033,31981569,32047105,32112641,32178177,32243713,32309249,32374785,32440321,32505857,32571393,32636929,32702465,32768001,32833537,32899073,32964609,33030145,33095681,33161217,33226753,33292289,33357825,33423361,33488897,33554433,33619969,33685505,33751041,33816577,33882113,33947649,34013186,34078721,34144257,34209793,34275329,34340865,34406401,34471937,34537473,34603009,34668545,34734081,34799617,34865153,34930689,34996225,35061761,35127297,35192833,35258369,35323905,35389441,35454977,35520513,35586049,35651585,35717121,35782657,35848193,35913729,35979265,36044801,36110337,36175873,36241409,36306945,36372481,36438017,36503553,36569089,36634625,36700161,36765697,36831233,36896769,36962305,37027841,37093377,37158913,37224449,37289985,37355521,37421057,37486593,37552129,37617665,37683201,37748737,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38273025,38338561,38404097,38469633,38535169,38600705,38666241,38731777,38797313,38862849,38928385,38993921,39059457,39124993,39190529,39256065,39321601,39387137,39452673,39518209,39583745,39649281,39714817,39780353,39845889,39911425,39976961,40042497,40108033,40173569,40239105,40304641,40370177,40435713,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41091073,41156609,41222145,41287681,41353217,41418753],"nunbers":[2555906],"negation":[5963777,15335425,26411009],"n_digits":[27328521,39976967],"names":[15007745,22413313],"namespace":[131073,196610,262146,327681,393218,458754,524290,589826,655362,720897,786434,851970,917506,983042,1048577,1114114,1179650,1245186,1310722,1376258,1441794,1507330,1572866,1638402,1703937,1769473,1835010,1900545,1966082,2031618,2097154,2162690,2228226,2293762,2359298,2424834,2490370,2555906,2621441,2686978,2752513,2818050,2883586,2949122,3014658,3080194,3145730,3211266,3276802,3342338,3407874,3473409,3538946,3604482,3670018,3735554,3801089,3866626,3932162,3997698,4063234,4128770,4194306,4259842,4325378,4390913,4456450,4521986,4587522,4653058,4718594,4784130,4849666,4915201,4980738,5046274,5111810,5177346,5242882,5308417,5373954,5439490,5505026,5570562,5636098,5701634,5767170,5832706,5898242,5963777,6029314,6094849,6160386,6225922,6291457,6356994,6422529,6488066,6553602,6619138,6684674,6750210,6815746,6881282,6946817,7012354,7077890,7143426,7208962,7274498,7340034,7405570,7471106,7536642,7602178,7667714,7733250,7798786,7864322,7929858,7995394,8060930,8126466,8192002,8257538,8323074,8388610,8454146,8519682,8585217,8650754,8716290,8781826,8847362,8912898,8978434,9043970,9109505,9175042,9240578,9306114,9371650,9437186,9502722,9568258,9633794,9699330,9764866,9830402,9895938,9961474,10027010,10092546,10158082,10223618,10289154,10354690,10420226,10485762,10551298,10616834,10682370,10747906,10813442,10878978,10944514,11010050,11075586,11141121,11206658,11272194,11337730,11403266,11468802,11534338,11599873,11665410,11730946,11796482,11862018,11927554,11993090,12058626,12124162,12189698,12255234,12320770,12386306,12451842,12517377,12582914,12648450,12713986,12779521,12845058,12910594,12976130,13041666,13107202,13172738,13238274,13303810,13369346,13434882,13500418,13565954,13631490,13697025,13762562,13828098,13893634,13959170,14024706,14090241,14155778,14221314,14286850,14352386,14417922,14483458,14548994,14614530,14680066,14745602,14811138,14876673,14942210,15007746,15073282,15138818,15204354,15269890,15335426,15400961,15466498,15532034,15597570,15663106,15728642,15794178,15859714,15925250,15990786,16056322,16121858,16187394,16252929,16318466,16384002,16449538,16515074,16580610,16646146,16711682,16777218,16842754,16908290,16973826,17039362,17104898,17170434,17235970,17301506,17367042,17432578,17498114,17563650,17629186,17694722,17760258,17825794,17891330,17956866,18022402,18087938,18153474,18219010,18284546,18350082,18415618,18481153,18546690,18612226,18677761,18743298,18808834,18874370,18939905,19005442,19070978,19136514,19202050,19267585,19333122,19398658,19464194,19529730,19595266,19660802,19726338,19791874,19857410,19922946,19988482,20054018,20119554,20185090,20250626,20316162,20381698,20447234,20512770,20578306,20643842,20709378,20774914,20840450,20905986,20971522,21037058,21102594,21168130,21233666,21299202,21364738,21430274,21495810,21561346,21626882,21692418,21757954,21823490,21889025,21954562,22020098,22085634,22151170,22216706,22282242,22347778,22478850,22544386,22609921,22675458,22740994,22806530,22872066,22937602,23003138,23068673,23134210,23199745,23265282,23330818,23396354,23461890,23527425,23592962,23658498,23724034,23789569,23855106,23920642,23986178,24051714,24117250,24182786,24248321,24313858,24510466,24444930,24576002,24772609,24707074,24379394,24641537,24838146,24903682,24969218,25034754,25100290,25165826,25231362,25296898,25362434,25427970,25493506,25559042,25624578,25690114,25755650,25821186,25886722,25952258,26017794,26083330,26148866,26214402,26279938,26345473,26411010,26476546,26542082,26607618,26673154,26738690,26804226,26869762,26935298,27000834,27066370,27131906,27197442,27262978,27328514,27394050,27459586,27525122,27590658,27656194,27721730,27787265,27852802,27918338,27983874,28049410,28114946,28180482,28246018,28311554,28377090,28442626,28508162,28573698,28639234,28704770,28770306,28835842,28901378,28966914,29032450,29097986,29163522,29229058,29294594,29360130,29425666,29491201,29556738,29622274,29687810,29753346,29818882,29884418,29949954,30015490,30081026,30146562,30212098,30277634,30343170,30408706,30474242,30539778,30605314,30670850,30736386,30801922,30867458,30932993,30998530,31064066,31129602,31195138,31260674,31326209,31391746,31457282,31522818,31588353,31653890,31719425,31784962,31850498,31916034,31981570,32047106,32112642,32178178,32243714,32309249,32374786,32440322,32505858,32571393,32636930,32702466,32768001,32833538,32899074,32964610,33030146,33095682,33161218,33226754,33292290,33357826,33423362,33488898,33554434,33619970,33685506,33751042,33816578,33882114,33947650,34013186,34078722,34144258,34209794,34275330,34340866,34406401,34471938,34537474,34603010,34668546,34734081,34799618,34865154,34930690,34996226,35061762,35127297,35192834,35258370,35323906,35389442,35454978,35520514,35586049,35651586,35717122,35782658,35848194,35913730,35979266,36044802,36110338,36175874,36241410,36306946,36372482,36438018,36503554,36569090,36634626,36700162,36765698,36831234,36896770,36962306,37027842,37093378,37158914,37224450,37289986,37355522,37421058,37486594,37552130,37617666,37683202,37748738,37814274,37879810,37945346,38010882,38076418,38141954,38207490,38273026,38338562,38404098,38469634,38535170,38600706,38666242,38731778,38797314,38862850,38928386,38993922,39059458,39124994,39190530,39256066,39321602,39387138,39452674,39518210,39583746,39649282,39714818,39780354,39845890,39911425,39976962,40042497,40108034,40173570,40239106,40304642,40370178,40435713,40501250,40566786,40632322,40697858,40763394,40828930,40894466,40960002,41025538,41091074,41156610,41222146,41287682,41353218,41418754],"notinheritable":[15335425],"newly":[5963777,7471106,15335425,29360130,32702466,34406401,38338562],"normal":[16908289],"newer":[7536641,12648449,24117249,30146561,30736385],"naturally":[23724033,41091073],"number":[196612,524293,851969,1114114,1179649,1245187,1310722,1507329,1835010,1966081,2031619,2097156,2162690,2424833,2490370,2555905,2686977,2883585,3080194,3145730,3211265,3276801,3342337,3670017,3735556,3866628,4063233,4128769,4325377,4521987,4587524,4784130,5046276,5111809,5373954,5505028,5570565,5636097,5701633,5832707,5898244,5963799,6291457,6619137,6815745,6881281,7012353,7405569,7471105,7536645,7667714,7864324,7929860,8060934,8126466,8257540,8323073,8388612,8454145,8650753,8781827,8912898,8978436,9043969,9240582,9306114,9699331,9830404,9961474,10027012,10223619,10289153,10420225,11272193,11337731,11599873,11665410,11730946,12058627,12124161,12189697,12255236,12451844,12517377,12648455,12713988,12845062,12910595,13041665,13172738,13238273,13303811,13434881,13631489,14024705,14155781,14286849,14417921,14483460,14876674,15073281,15269889,15335452,15597569,15728641,15794177,16121858,16187393,16318466,16384001,16777217,16842753,16908290,17039361,17235969,17825796,17956865,18022404,18087942,18415618,18612226,18743298,18874371,19529732,19791873,19988484,20316161,20512769,20774919,20905985,20971521,21168129,21233665,21299201,21430274,21561346,21692417,21757953,22282241,22347777,22478850,22740994,22806531,23134211,23396355,23527425,23724034,24051716,24117254,21823491,24313857,24444931,24838146,25034753,25559041,25755653,25427972,25821188,25886724,25952260,26148868,26411009,26476546,25690116,25493508,25231362,27328516,28114948,28246018,28377089,28966914,29032449,29097986,29294593,29360129,29425665,29556737,29687809,29753345,29884421,30015489,30146564,30277634,30539778,30736390,30867457,30932993,30998529,31195137,31260673,31850498,32374785,32440321,32702465,32833537,32899078,27066371,33161217,33292290,33554433,33619969,33751041,34013185,34078723,34209793,34275331,34406405,34471937,34537474,34603010,34865156,34930690,34996225,35061761,35323906,35454977,35520514,35717121,36044801,36503556,36700163,37093378,37289985,37748742,37879812,37945345,38076417,38141954,38338561,38666241,38797313,38928386,38993921,39059461,39124997,39256065,39518210,39583745,39780354,39845893,39976963,40173572,40370180,40435716,40566788,40632322,40697857,40894465,40960001,41156610,41353220],"numeric":[5963780,7274497,15335428,21037057,25165825,40108033],"numb":[40173571],"normally":[2490369,13631489,18415617,22478849,29097985,34537473,35192833,37289985,38404097],"numbe":[16056321,18350081,20774913,25362433,38469633,39714817],"new_alloc":[5963777,15335425,39256070],"notice":[7667713,16318465],"normalization":[35323905],"nents":[5963777,9961478,15335425],"null":[196609,589827,1376257,1441793,1835009,2293761,2424833,2555906,3407873,3473409,3538945,3735553,3866625,4128769,4718593,5505025,5963793,6488065,6619137,7274497,7340033,7667716,7733249,7929857,7995393,8060929,8126465,8192002,8257537,8388609,8650753,9306122,9502721,9830401,10027009,10158086,10289153,10354689,10682369,11010049,11206657,11862018,12320769,12386305,12713985,12845057,12910593,13041665,13107201,13893633,14548993,14811137,15335441,15466497,15597569,15794178,15925250,16318468,16384001,17235969,17694721,18087937,19005441,19070977,19333121,19660801,20119553,20381698,20578305,20709378,20971522,21299201,21626881,21757954,21954561,22478849,22675457,23265281,24051713,24117249,24510465,24576001,24969217,25427969,24379393,25886721,26017794,26607617,26738689,25690113,26935297,27197441,27328517,27590657,27721729,28114945,28311554,28704769,28770305,29229057,29360131,29425665,29556738,29753345,30474243,31260673,31522817,32112644,32899073,32964610,33882113,33947650,35061761,35389444,35520513,35782657,36241409,36306948,36438017,36962307,37289987,37355521,37617665,37748737,37814273,37879809,38010881,38076417,38141953,38207489,38338563,38797313,39649281,39911425,40173572,40566785,41025537,41353217],"negativeinfinity":[393217,27852801],"narrowing":[786433,1572865,2228225,4194305,4849665,5767169,6225921,6750209,7208961,8716289,9437185,9633793,10878977,10944513,11534337,11796481,14942209,15990785,16515073,16711681,16973825,17170433,17367041,17498113,17563649,18153473,18219009,19202049,19398657,22937601,23003137,23920641,25296897,26804225,28180481,30081025,31129601,31457281,31981569,33226753,34799617,35258369,36765697,37027841,37486593,38273025,38535169,38731777,39190529,40304641],"new_size":[1835017,5963777,9306116,15335425,34406401,37093383],"notes":[19529729],"noted":[22478849,21823489],"nails":[21823495,40173574],"negated_operand":[5963777,15335425,33095686],"nbcnt":[15073287],"nbits":[5963777,15335425,19988486]} \ No newline at end of file diff --git a/docs/fti/FTI_111.json b/docs/fti/FTI_111.json new file mode 100644 index 0000000..4d1e7ca --- /dev/null +++ b/docs/fti/FTI_111.json @@ -0,0 +1 @@ +{"overload":[262145,327681,655361,720897,786433,1048577,1572865,1769473,2228225,2752513,3604481,3670017,3801089,4194305,4849665,5308417,5767169,6094849,6225921,6684673,6750209,6946817,7208961,7798785,8585217,8716289,8847361,9175041,9371649,9437185,9633793,9764865,10551297,10878977,10944513,11534337,11796481,12582913,12779521,13565953,14614529,14942209,15204353,15663105,15990785,16515073,16580609,16646145,16711681,16973825,17170433,17367041,17498113,17563649,17760257,18153473,18219009,18481153,18677761,19136513,19202049,19398657,19726337,19857409,20185089,20643841,20840449,21364737,21495809,22544385,22937601,23003137,23461889,23855105,23920641,24248321,24772609,25100289,25296897,26214401,26345473,26542081,26804225,26869761,27525121,27918337,28049409,28180481,28508161,28639233,30081025,30343169,30670849,31129601,31326209,31391745,31457281,31719425,31981569,32047105,32309249,32636929,32768001,33226753,33488897,33619969,33816577,34799617,35258369,35586049,35651585,35848193,36175873,36372481,36765697,37027841,37158913,37224449,37486593,37552129,38273025,38535169,38731777,38862849,39190529,39321601,40239105,40304641,41418753],"overlap":[5898241,7667713,15794177,16121857,16318465,20316161,21757953,25034753,25231361,30015489,27066369,35454977,38666241,40697857,41156609],"operands":[1114115,1507330,2162690,2883586,3276802,4325378,5046274,5111810,5898243,5963778,6815746,7012354,9043970,9961474,12910595,13041665,13238274,14286850,15073281,15335426,16121858,16777218,17956865,18350082,18743298,19529732,19791874,20316162,20905986,22740994,25034754,25559042,26411010,25231362,28573698,28966915,30015490,30998530,31195138,32374786,27066370,33751042,34275331,34996226,35454978,36044802,37945347,38141954,38469634,38666243,38993922,39059458,39714818,39780354,40501250,40697858,41156610],"occurrences":[5963777,15335425,31260674],"obsolete":[7536641,30146561],"old":[21168129,21233665],"occurred":[1245185,8781825,11337729,15728641,17039361,18874369,20512769,22806529,33161217,34078721,39976961],"optional":[35520513],"older":[7536641,7667713,12648449,16318465,24117249,30146561,30736385],"obj":[655367,9175047,9764871,19136519,19857415,20185095,30343175,32636935],"operators":[262145,327681,720897,786433,1179649,1441793,1572865,2228225,2752513,3604481,4063233,4194305,4390913,4456449,4849665,5308417,5767169,6225921,6422529,6684673,6750209,7208961,7864321,8716289,8847361,9109505,9371649,9437185,9633793,10551297,10878977,10944513,11534337,11796481,12582913,13565953,13631489,13697026,14352385,14614529,14942209,15663105,15990785,16252930,16515073,16580609,16646145,16711681,16842753,16973825,17170433,17367041,17498113,17563649,17760257,18153473,18219009,18481153,19202049,19398657,20643841,20840449,21364737,21430273,21495809,22544385,22609922,22937601,23003137,23068674,23461889,23789570,23855105,23920641,24248321,24772609,25100289,25296897,26214401,26542081,26804225,27787266,28180481,29491202,30081025,31129601,31326209,31457281,31653889,31981569,32309249,32243713,32768001,33226753,33488897,34013185,34537473,34734082,34799617,35258369,35651585,35782657,36175873,36372481,36765697,37027841,37224449,37486593,38273025,38535169,38731777,38862849,39190529,40239105,40304641],"obtained":[5963778,15335426,19529729,29360129,38338561],"operations":[6291457,7864321,11141121,13434881,15007745,15400961,16842753,20316161,21430273,22282241,23199745,25034753,26083329,29622273,30015489,31588353,34603009,34996225,35127297,40042497],"octal":[8781825,8978433,14352385,17235969,22806529,24444929,32243713,35520513],"override":[655363,917507,2359299,2949123,3080195,3211265,4653059,4980739,9175043,9764867,14680067,17104899,17432579,19136515,19857411,19922947,20054019,20185091,22216707,25624579,28901379,30343171,32636931,33030145,34144259,34471939,35913731,36110337,36896771,37683203],"op2":[393225,1638409,2424852,3538951,5505030,5963831,7602185,7929862,7995398,8060934,8126470,8388614,10289172,10354711,10682393,12713990,12845062,12910613,13041684,13107206,13172745,14483465,14548998,14811142,15335479,17694726,18087942,18612233,18808838,20578327,20971527,22675462,23592966,25427974,25886726,26083335,27000857,27852809,28114953,29229062,29622279,31522822,32899078,33882118,34340870,34930697,35061783,37289986,37355543,37421065,37748743,37879814,38010886,38076438,38797332,40566790,40960008,41025542],"overflow":[18415617,21102593,35192833],"open":[1245186,17039362,18874370,33161218,34078722,39976961],"occurs":[13303809,30867458],"output":[1245187,5963781,7667717,11337729,15335429,15728646,15794179,16187393,16318469,17039363,18874369,19529729,20512774,21757955,29360131,33161219,34078722,38338563],"outside":[5832705],"one":[5046273,5963777,12648449,12910593,13041665,15335425,16384001,16908289,19988481,22478850,23396354,24117249,30736385,33030145,27066370,37289985,40173569],"optimal":[1114113,9043969,22413313,30015489],"overrides":[131074,655361,917505,1048577,1441795,1703939,1769473,1900547,2359297,2949121,3080193,4063235,4456450,4653057,4915203,4980737,6094849,6291457,6946817,7864322,9175041,9764865,11141121,11599873,12779521,13631491,14680065,14876673,15400961,16842753,17104897,17432577,18677761,18939907,19136513,19857409,19922945,20054017,20185089,21430274,21889027,22216705,24641539,25624577,28901377,30343169,31653891,31719425,32571394,32636929,34013187,34144257,34471937,34537475,35586049,35782658,35913729,36896769,37683201],"operanf":[12910594],"object":[131076,655369,1048579,1441796,1703940,1769475,1900548,4063236,4128776,4259841,4456452,4915204,6094851,6291466,6619144,6946819,7667718,7864331,8323080,9175049,9764873,11141130,12779523,13434892,13631492,14024712,15007756,15335425,15400970,15728648,15794182,16318472,16842763,17039366,18677763,18939908,19136521,19857417,20185097,20512774,21430283,21692424,21757962,21889028,22282252,23199755,24641540,29360135,30343177,31588363,31653892,31719427,32571396,32636937,32833544,33161224,34013188,34537476,34603020,35127307,35586051,35782660,38338569,40042507],"optimization":[22413313],"overlapping":[1114113,2162690,5111809,18743298,28573697,34275329,37945345,40501249],"op1":[393239,983065,1638416,2424852,3538950,5505030,5963834,7602199,7929862,7995398,8060934,8126470,8388614,10289172,10354711,10682393,11927577,12713990,12845062,12910613,13041684,13107206,13172745,14483465,14548998,14811142,15335482,17694726,18087942,18612233,18808838,20578327,20971541,22675462,23592966,25427974,25886726,26083335,27000857,27852823,28114953,29229062,29622279,31522822,32899078,33882118,34340870,34930697,35061784,37289986,37355543,37421079,37748744,37879814,38010886,38076438,38797332,40566790,40960008,41025542],"original":[40632322],"operator":[262147,786435,1179651,1572867,2228227,3604483,4194307,4849667,5767171,6225923,6684675,6750211,7208963,8519684,8716291,8847363,9371651,9437187,9633795,10551299,10747908,10878979,10944515,11534339,11796483,11993092,12582915,13565955,14221316,14352387,14614531,14942211,15663107,15990787,16515075,16580611,16646147,16711683,16973827,17170435,17367043,17498115,17563651,17760259,18153475,18219011,19202051,19398659,19595268,20643843,20840451,21364739,21495811,22544387,22937603,23003139,23330820,23461891,23855107,23920643,25100291,25296899,26214403,26542083,26804227,27131908,27262980,27983876,28180483,28442628,28835844,29818884,29949956,30081027,30801924,31129603,31457283,31784964,31981571,32243715,33226755,33488899,33685508,34799619,35258371,35651587,36175875,36372483,36765699,37027843,37224451,37486595,38273027,38535171,38731779,38862851,39190531,40239107,40304643],"ones":[2097153,5963779,12648449,15335427,18022401,30146561,36503553],"opinion":[24444929],"operation":[1114114,1507330,2162690,2883586,3276802,3538945,4325378,5111810,5898242,6815746,7012354,9043970,9699330,9961474,13303809,14286850,15073281,16121858,16777218,16908289,17956866,18350082,18743298,19791874,20316162,20905986,22740994,23658498,25034754,25559042,26279938,26411010,25231362,28573698,29294594,30015490,30998530,31195138,32374786,33751042,34275330,34996226,35454978,36044802,37945346,38469634,38666242,38993922,39714818,39780354,40501250,40697858,41156610],"order":[1245185,5701633,15925249,18874369,21823495,27328513,39976961,40173574],"old_size":[1835018,5963777,9306116,15335425,34406401,37093383],"occupied":[524290,2162689,5570562,5963783,7536642,8912897,12255234,12648450,13959169,15335431,18743297,19988482,20774914,22872065,24117250,25493506,29884418,30146562,30474241,30736386,32505857,34865154,35389441,36503554,36962305,39845890,40370178],"offset":[41091073],"overwritten":[2162689,18743297],"overridable":[3211265,33030145],"operand":[196609,393218,589825,851970,983043,1114116,1245185,1310721,1507329,1638402,1966082,2031617,2097154,2162692,2424834,2490369,2555905,2818049,2883586,3014657,3145729,3276804,3342337,3538946,3735553,3866625,3932161,3997697,4325378,4521985,4587522,4718593,4784129,5046273,5111810,5242881,5439489,5505026,5832705,5898242,5963778,6356993,6488066,6815746,7012354,7143425,7405573,7602178,7733250,7929858,7995394,8060930,8126466,8257537,8388610,8454145,8650754,8912897,9043970,9240577,9568257,9699331,9830401,9961473,10027009,10223617,10289154,10354690,10616834,10682370,11272194,11337729,11403266,11665409,11927555,12058625,12451841,12648449,12713986,12845058,12910593,12976129,13041667,13107202,13172738,13238274,13303809,13828097,13893633,14155777,14286850,14483458,14548994,14745601,14811138,15073284,15138817,15335426,15532033,15597570,15859713,16056323,16121858,16187393,16384001,16777218,17629185,17694722,17825793,17956868,18022402,18087938,18284546,18350081,18415617,18612226,18743301,18808834,18874370,19070977,19529732,19791873,20316162,20578306,20905985,20971523,21168129,21233665,21299201,21561345,22478849,22675458,22740994,22806529,23134209,23396353,23592962,23658499,23986177,24051713,24117249,21823489,24313857,24510465,24707073,24838145,25034754,25362435,25559044,25755651,25427970,25821185,25886722,25952258,26017794,26083330,26148866,26279939,26411009,26476545,26673153,26738689,27000834,25231363,27394049,27656193,27852802,28114946,28246017,28311553,28377090,28966914,29097985,29229058,29294594,29425666,29556737,29622274,29687809,29753346,30015490,30277633,30408705,30474241,30539777,30605313,30736385,30998530,31064065,31195138,31260674,31522818,31850497,32374786,32440322,32505857,32899074,33095687,27066369,33357825,33423361,33751042,33882114,34078721,34209796,34275334,34340866,34930690,34996226,35061762,35192833,35323905,35454977,35979265,36044801,36306945,36569090,36700161,36831233,36962305,37289986,37355522,37421058,37617665,37748738,37879810,37945348,38010882,38076418,38141953,38404097,38469634,38600705,38666242,38797314,38928385,38993922,39059457,39124993,39518209,39714818,39780354,39976961,40173569,40566786,40697857,40763393,40828930,40894466,40960002,41025538,41156609,41222145,41353217],"occur":[18415617,21102593,35192833],"ought":[7667713,16318465],"odd":[851971,1966083,5963782,8650753,15073281,15138820,15335430,15597571,24576001,28377091,29753345,30408705,32440323,33423363,34275329]} \ No newline at end of file diff --git a/docs/fti/FTI_112.json b/docs/fti/FTI_112.json new file mode 100644 index 0000000..e05b1f9 --- /dev/null +++ b/docs/fti/FTI_112.json @@ -0,0 +1 @@ +{"parameters":[196609,262145,393217,524289,589825,655361,786433,851969,983041,1114113,1179649,1245185,1310721,1376257,1507329,1572865,1638401,1835009,1966081,2031617,2097153,2162689,2228225,2293761,2424833,2490369,2555905,2818049,2883585,3014657,3145729,3276801,3342337,3407873,3538945,3604481,3670017,3735553,3866625,3932161,3997697,4128769,4194305,4325377,4521985,4587521,4718593,4784129,4849665,5046273,5111809,5177345,5242881,5439489,5505025,5570561,5636097,5701633,5767169,5832705,5898241,6160385,6225921,6356993,6488065,6619137,6684673,6750209,6815745,6881281,7012353,7077889,7143425,7208961,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7798785,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8519681,8650753,8716289,8781825,8847361,8912897,8978433,9043969,9175041,9240577,9306113,9371649,9437185,9502721,9568257,9633793,9699329,9764865,9830401,9895937,9961473,10027009,10158081,10223617,10289153,10354689,10551297,10616833,10682369,10747905,10878977,10944513,11206657,11272193,11337729,11403265,11534337,11665409,11730945,11796481,11862017,11927553,11993089,12058625,12124161,12255233,12320769,12386305,12451841,12582913,12648449,12713985,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13500417,13565953,13762561,13828097,13893633,13959169,14024705,14155777,14221313,14286849,14352385,14483457,14548993,14614529,14745601,14811137,14942209,15007745,15073281,15138817,15204353,15466497,15532033,15597569,15663105,15728641,15794177,15859713,15925249,15990785,16056321,16121857,16187393,16318465,16384001,16449537,16515073,16580609,16646145,16711681,16777217,16908289,16973825,17039361,17170433,17235969,17301505,17367041,17498113,17563649,17629185,17694721,17760257,17825793,17891329,17956865,18022401,18087937,18153473,18219009,18284545,18350081,18415617,18546689,18612225,18743297,18808833,18874369,19005441,19070977,19136513,19202049,19333121,19398657,19529729,19595265,19660801,19726337,19791873,19857409,19988481,20185089,20250625,20316161,20381697,20447233,20512769,20578305,20643841,20709377,20774913,20840449,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21364737,21495809,21561345,21626881,21692417,21757953,21954561,22020097,22085633,22151169,22347777,22478849,22544385,22675457,22740993,22806529,22872065,22937601,23003137,23134209,23265281,23330817,23396353,23461889,23592961,23658497,23855105,23920641,23986177,24051713,24117249,21823490,24182785,24313857,24510465,24576001,24444929,24707073,24838145,24969217,25034753,25100289,25296897,25362433,25559041,25755649,25427969,24379393,25821185,25165825,25886721,25952257,26017793,26083329,26148865,24903681,26214401,26279937,26411009,26476545,26542081,26607617,26673153,26738689,25690113,26804225,26869761,25493505,26935297,27000833,25231361,27131905,27197441,27262977,27328513,27394049,27459585,27525121,27590657,27656193,27721729,27852801,27983873,28049409,28114945,28180481,28246017,28311553,28377089,28442625,28508161,28573697,28639233,28704769,28770305,28835841,28966913,29097985,29163521,29229057,29294593,29360129,29425665,29556737,29622273,29687809,29753345,29818881,29884417,29949953,30015489,30081025,30146561,30212097,30277633,30343169,30408705,30474241,30539777,30605313,30670849,30736385,30801921,30867457,30998529,31064065,31129601,31195137,31260673,31391745,31457281,31522817,31784961,31850497,31981569,32047105,32112641,32178177,32243713,32374785,32440321,32505857,32636929,32702465,32833537,32899073,32964609,33095681,27066369,33161217,33226753,33357825,33423361,33488897,33554433,33619969,33685505,33751041,33816577,33882113,33947649,34078721,34209793,34275329,34340865,34799617,34865153,34930689,34996225,35061761,35192833,35258369,35323905,35389441,35454977,35520513,35651585,35848193,35979265,36044801,36175873,36241409,36306945,36372481,36438017,36503553,36569089,36634625,36700161,36765697,36831233,36962305,37027841,37093377,37158913,37224449,37289985,37355521,37421057,37486593,37552129,37617665,37748737,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38273025,38338561,38404097,38469633,38535169,38600705,38666241,38731777,38797313,38862849,38928385,38993921,39059457,39124993,39190529,39256065,39321601,39387137,39518209,39583745,39649281,39714817,39780353,39845889,39976961,40108033,40173570,40239105,40304641,40370177,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41156609,41222145,41287681,41353217,41418753],"population":[5963777,15335425,23396354],"params":[589825,4128769,6619137,7667713,8323073,14024705,15728641,15794177,16318465,17039361,19726337,20512769,21692417,21757953,28311553,29360129,30474241,32112641,32833537,33161217,35389441,36962305,38338561],"positiveinfinity":[393217,27852801],"protection":[15794177,21757953],"preceded":[5963777,15335425,22806529],"preserved":[5701633,39256065],"ptr":[1245196,1835017,3670022,3801092,4128778,5898241,5963782,6619146,6881286,8323090,8781833,8978441,9306120,11337741,11468802,14024722,14090243,15007753,15335430,15728641,16318465,17039369,17956865,18415618,18874379,19529736,21692426,21757954,22806539,26345476,27328521,27525126,27918342,29360144,31391750,31850498,32047110,32833546,33161225,34078729,34406403,35323913,36831234,37093383,37158918,38338570,39976968,40042499],"paramarray":[589825,4128769,6619137,7667713,8323073,14024705,15728641,15794177,16318465,17039361,19726337,20512769,21692417,21757953,28311553,29360129,30474241,32112641,32833537,33161217,35389441,36962305,38338561],"probably":[14155778,32178177,39124993],"pathname":[1245192,8323078,8781832,8978440,11337736,14024710,17039368,18874376,22806536,33161224,34078728,39976964],"pointed":[3670017,5963781,6881281,11468801,14090241,15007745,15335429,19529729,19726337,26345477,31391745,32047105,34406401,37158913],"power":[5046273,5963778,6488065,13369345,13893633,15335426,16056324,19660801,22478849,26935297,27197441,30015489,30408708,36241409,37814273,39059457,39649281],"preferred":[9043969,22740993,39256065],"performed":[26083329,29622273],"parameter":[1114113,1835009,2162689,3276801,3670017,5570563,7536641,12648449,15073281,18743297,19791874,24117249,25559041,30146561,30736385,34275329,36044802,37945345],"produces":[5963778,7012354,15335426,31195138],"passes":[39124995],"providing":[8781825,22413313,24444929,39976961],"property":[3080196,3211268,10813443,12189700,15269892,19464196,23724036,29163523,33030148,34471940,34668547,41091076],"passed":[1114113,1835009,2162689,3276801,3670017,15073281,16187393,18743297,25559041,26083329,29622273,34275329,37945345],"printable":[5046273],"particular":[6291457,7536641,7864321,11141121,13434881,15007745,15400961,16842753,21430273,22282241,23199745,31588353,33030145,34603009,35127297,40042497,40632321],"primality":[5963777,14155778,15335425,39124993],"possibly":[5963777,15335425,22806529],"ptrs":[5963777,15335425,19726342,26345473],"previously":[1835014,3670018,5963777,6881282,15335425,19726337,24182785,31391745,32047105,34406401,37093381,37158913],"partially":[5111809,28573697,40501249],"produce":[19464193,40173569],"preparation":[16908289],"precisely":[19529729],"primes":[21299201],"piece":[19791874,36044802],"projects":[22413313],"prec":[5963780,11730950,15335428,24182790,29097990,40632330],"patterns":[7012353,24576001,31195137],"proven":[12648449,30146561,36503553],"precision":[196610,458754,589826,851969,1114114,1507330,1966081,2097154,2162690,2490372,2686977,2883586,3145730,3276802,3735556,3866626,4063233,4259844,4325378,5046274,5111810,5505026,5898242,5963783,6029313,6291457,6553601,6815746,7012354,7405570,7864324,7929858,8060930,8126465,8388610,8912898,9043970,9699330,9830402,9961474,10027010,11141121,11599873,11665410,11730951,12451842,12713986,12845058,13172738,13238274,13303812,13631489,14286850,14483458,15073281,15335431,15400961,15597569,16056322,16121858,16777218,16842755,17956866,18022402,18087938,18350082,18415618,18612226,18743298,19464193,19529730,19791874,19988483,20316162,20905986,21430275,21561348,22413313,22740994,23658498,24051714,24182789,24838150,25034754,25362434,25559042,25427970,25886722,26279938,26411010,25231362,27328514,28114946,28377089,28573698,28966914,29097990,29294594,30015490,30539780,30998530,31195138,31850498,31916034,32374786,32440321,32899074,33030145,27066370,33292290,33751042,34209794,34275330,34406404,34537474,34930690,34996226,35323906,35454978,36044802,37748738,37879810,37945346,38141954,38469634,38666242,38928388,38993922,39059458,39714818,39780354,40501250,40566786,40632335,40697858,41156610,41353218],"position":[5963778,10223617,12058625,15335426,23658498,24576001,26279938],"provides":[22282241,29884417,34406401,34865153,39845889],"preliminary":[5963777,15073281,15335425],"performance":[1114113,15073281,22413313],"pointer":[458754,1245185,1441794,1835010,3670017,3801090,4456449,5963781,6291457,6881281,7471106,7864322,8323074,8454146,8781825,8978433,10485762,11075586,11141121,11337729,11599873,13434881,13500420,14024706,14876673,15007748,15335429,15400961,15925249,16187393,16842753,17039362,18546691,18874369,18939905,19267585,19529729,21168132,21233668,21430274,22282241,22806529,27328514,27525121,27918337,29360132,30932993,31391745,31916034,32047105,32571394,32702466,33030147,33161218,33292290,33554434,34078721,34406405,35323905,35782659,36306945,37093377,37158913,38338565,39452673,39976961],"parsed":[4128769,6619137,8323073,14024705,21692417,32833537,35520513],"past":[10223618,12058626,19529729],"powers":[30408706],"purpose":[4259841,20578305],"produced":[5046274,5898241,5963777,7667713,15335425,16318465,27328513,29360129,38141953,38338561,40173572],"problems":[40173569],"primorial":[5963777,15335425,24313857],"perfect":[5963781,6356997,15335429,16056324,25362436,30408710,37617665,38141953],"public":[196611,262146,393219,458755,524291,589827,655363,786434,851971,917507,983043,1114115,1179650,1245187,1310723,1376259,1441795,1507331,1572866,1638403,1835011,1966083,2031619,2097155,2162691,2228226,2293763,2359299,2424835,2490371,2555907,2686979,2818051,2883587,2949123,3014659,3080195,3145731,3211267,3276803,3342339,3407875,3538947,3604482,3670019,3735555,3866627,3932163,3997699,4063235,4128771,4194306,4259843,4325379,4456451,4521987,4587523,4653059,4718595,4784131,4849666,4980739,5046275,5111811,5177347,5242883,5373955,5439491,5505027,5570563,5636099,5701635,5767170,5832707,5898243,6029315,6160387,6225922,6356995,6488067,6553603,6619139,6684674,6750210,6815747,6881283,7012355,7077891,7143427,7208962,7274499,7340035,7405571,7471107,7536643,7602179,7667715,7733251,7798787,7864324,7929859,7995395,8060931,8126467,8192003,8257539,8323075,8388611,8454147,8519683,8650755,8716290,8781827,8847362,8912899,8978435,9043971,9175043,9240579,9306115,9371650,9437186,9502723,9568259,9633794,9699331,9764867,9830403,9895939,9961475,10027011,10092547,10158083,10223619,10289155,10354691,10420227,10485763,10551298,10616835,10682371,10747907,10813443,10878978,10944514,11010051,11075587,11206659,11272195,11337731,11403267,11468803,11534338,11665411,11730947,11796482,11862019,11927555,11993091,12058627,12124163,12189699,12255235,12320771,12386307,12451843,12582914,12648451,12713987,12845059,12910595,12976131,13041667,13107203,13172739,13238275,13303811,13369347,13434883,13500419,13565954,13631491,13762563,13828099,13893635,13959171,14024707,14155779,14221315,14286851,14352386,14417923,14483459,14548995,14614530,14680067,14745603,14811139,14942210,15007747,15073283,15138819,15204355,15269891,15335427,15466499,15532035,15597571,15663106,15728643,15794179,15859715,15925251,15990786,16056323,16121859,16187395,16318467,16384003,16449539,16515074,16580610,16646146,16711682,16777219,16842755,16908291,16973826,17039363,17104899,17170434,17235971,17301507,17367042,17432579,17498114,17563650,17629187,17694723,17760258,17825795,17891331,17956867,18022403,18087939,18153474,18219010,18284547,18350083,18415619,18546691,18612227,18743299,18808835,18874371,19005443,19070979,19136515,19202050,19333123,19398658,19464195,19529731,19595267,19660803,19726339,19791875,19857411,19922947,19988483,20054019,20119555,20185091,20250627,20316163,20381699,20447235,20512771,20578307,20643842,20709379,20774915,20840450,20905987,20971523,21037059,21102595,21168131,21233667,21299203,21364738,21430276,21495810,21561347,21626883,21692419,21757955,21823491,21954563,22020099,22085635,22151171,22216707,22282243,22347779,22478851,22544386,22675459,22740995,22806531,22872067,22937602,23003138,23134211,23265283,23330819,23396355,23461890,23592963,23658499,23724035,23855106,23920642,23986179,24051715,24117251,24182787,24313859,24510467,24444931,24576003,24707075,24379395,24838147,24903683,24969219,25034755,25100290,25165827,25231363,25296898,25362435,25427971,25493507,25559043,25624579,25690115,25755651,25821187,25886723,25952259,26017795,26083331,26148867,26214402,26279939,26411011,26476547,26542082,26607619,26673155,26738691,26804226,26869763,26935299,27000835,27066371,27131907,27197443,27262979,27328515,27394051,27459587,27525123,27590659,27656195,27721731,27852803,27918339,27983875,28049411,28114947,28180482,28246019,28311555,28377091,28442627,28508163,28573699,28639235,28704771,28770307,28835843,28901379,28966915,29032451,29097987,29163523,29229059,29294595,29360131,29425667,29556739,29622275,29687811,29753347,29818883,29884419,29949955,30015491,30081026,30146563,30212099,30277635,30343171,30408707,30474243,30539779,30605315,30670851,30736387,30801923,30867459,30998531,31064067,31129602,31195139,31260675,31391747,31457282,31522819,31653891,31784963,31850499,31916035,31981570,32047107,32112643,32178179,32243714,32374787,32440323,32505859,32636931,32702467,32833539,32899075,32964611,33030147,33095683,33161219,33226754,33292291,33357827,33423363,33488898,33554435,33619971,33685507,33751043,33816579,33882115,33947651,34013187,34078723,34144259,34209795,34275331,34340867,34471939,34537475,34603011,34668547,34799618,34865155,34930691,34996227,35061763,35192835,35258370,35323907,35389443,35454979,35520515,35651586,35717123,35782659,35848195,35913731,35979267,36044803,36110339,36175874,36241411,36306947,36372482,36438019,36503555,36569091,36634627,36700163,36765698,36831235,36896771,36962307,37027842,37093379,37158915,37224450,37289987,37355523,37421059,37486594,37552131,37617667,37683203,37748739,37814275,37879811,37945347,38010883,38076419,38141955,38207491,38273026,38338563,38404099,38469635,38535170,38600707,38666243,38731778,38797315,38862850,38928387,38993923,39059459,39124995,39190530,39256067,39321603,39387139,39452675,39518211,39583747,39649283,39714819,39780355,39845891,39976963,40108035,40173571,40239106,40304642,40370179,40501251,40566787,40632323,40697859,40763395,40828931,40894467,40960003,41025539,41091075,41156611,41222147,41287683,41353219,41418755],"path":[1245186,8323074,8781826,8978434,11337730,14024706,17039362,18874370,22806530,33161218,34078722,39976961],"pass":[15007745],"perform":[2883585,4325377,5963786,6291457,6815745,7864321,11141121,13434881,14155777,15007745,15335434,15400961,16777217,16842753,16908289,18350081,21430273,22282241,23199745,26411009,30998529,31588353,32374785,33751041,34603009,35127297,38993921,40042497],"permitted":[5898241,7667713,8978433,15794177,16121857,16318465,21757953,25231361,27066369,38666241,40697857],"passing":[7929857,8126465,12845057,21299201,21823489,26411009],"purposes":[21299201,24576001,40632321],"positions":[5963777,12910593,15335425,28966913],"portability":[40173569],"probability":[14155777,39124993],"practical":[21299201],"padded":[2162689,15204353,18743297,26869761,41418753],"period":[5570561],"product":[5963781,7995394,14811138,15335429,16121857,18284550,20316162,24313857,25034754,30015490,38666241,41025538],"probabilistic":[5963777,14155778,15335425,21299201,39124995],"portable":[1245185],"placed":[24576001],"print":[5963781,7667715,15335429,15728643,15794179,16318467,17039363,20512771,21757955,29360130,33161219,38338562,39976961],"places":[24444929],"part":[4718593,5963782,6488065,15335430,26017793,29425665,31850497,32178177,34406401,34537474,36831233,37617665],"pointers":[5963777,10158081,15335425,19726337],"provided":[20316161,25034753,30015489,35454977,41156609],"positive":[393217,983041,1638401,3932161,5963778,7602177,10354689,10682369,11927553,13041665,13172737,13238273,14483457,15335426,18612225,21823489,24313857,27000833,27852801,28114945,29753345,34930689,37289985,37355521,37421057,38076417,39124993,40960001,41091073],"performs":[14155777],"prepare":[16187394],"prime":[5963779,14155783,15335427,21299202,24313857,29753345,39124994],"printed":[39976963],"point":[196612,589827,1179649,1310722,2490370,2686977,3145730,3735556,3866628,4784130,5505028,6291457,7864325,7929860,8060934,8126466,8257540,8388612,8781825,8912898,9830404,10027012,11599873,11665410,11730946,12451842,12713988,12845062,13172738,13303810,14483460,15925249,16187393,18087942,18415618,18612226,21561346,24051716,24444931,24838146,25427972,25886724,25690116,27328516,28114948,28246018,29097986,30277634,30539778,31850498,32899078,33292290,34013186,34406402,34930690,35323906,36306945,36503554,36962310,37748742,37879812,38928386,39518210,39976961,40566788,40632322,41091076,41353220],"possible":[5046273,10223617,12058625,12910593,15925249,16908289,23396353,27328513,29884417,27066369,35061761,36306946,39845889],"plus":[5046273,19529729,20316161,25034753,27066369],"prefixed":[39976961],"previous":[19791873,29884417,36044801,39845889],"precisions":[25690113,40632322],"properties":[2621442,7864321,11599874,12517378,13434881,14876674,15335425,16842753,21430273,22282241,23527426,30932994,40370177]} \ No newline at end of file diff --git a/docs/fti/FTI_113.json b/docs/fti/FTI_113.json new file mode 100644 index 0000000..e230ac3 --- /dev/null +++ b/docs/fti/FTI_113.json @@ -0,0 +1 @@ +{"qxn":[25231366,28573697,40501259],"qualified":[131073,4456449,32571393,35782657],"quotient":[1376258,2293762,5963796,7340033,8192002,11206657,11403270,11862018,12386306,15335444,18743298,19005442,19660802,19791873,20381698,20709378,21954562,25231369,26935298,28573698,32964610,33947650,36044801,36438018,39649282,40501250],"quality":[29884417,39845889],"quite":[29884417,39845889]} \ No newline at end of file diff --git a/docs/fti/FTI_114.json b/docs/fti/FTI_114.json new file mode 100644 index 0000000..fa0fe96 --- /dev/null +++ b/docs/fti/FTI_114.json @@ -0,0 +1 @@ +{"raised":[26607617,27721729],"rem":[5963777,15335425,26017816,37617682],"root":[196609,4718594,5963786,6356994,6488066,11665409,15335434,26017821,37617686,38141953],"room":[19529731,21168129,21233665],"reps":[14155785,39124999],"remove":[3932161,5963778,15335426,31260673],"ring":[35061761],"readallbytes":[1245186],"returned":[5963777,7077890,7143425,8454145,9895937,10223618,12058626,15335425,15925249,18415618,20250625,20971522,21102593,22085634,22478849,26476545,26673153,27328516,32178177,35192834,35323905,35454977,36306945,36634626,38338561,40173570,41156609],"really":[19791873,24444930,36044801],"releases":[19529730],"repeated":[5701633,29884417,39845889],"rabin":[14155778],"r2p":[5963777,15335425,38141972],"redirected":[1],"rationals":[983041,2818049,3407873,3932161,8978433,10682370,11927553,20578305,23986177,24510465,26083329,27000834,28311559,29622273,30474247,32505857,34078721,35520513,38404097],"retval":[5898241,5963778,7667713,15335426,16318465,38141953],"retain":[40632321],"remaining":[5963777,15335425,18743297],"resilience":[24576001],"required":[1114113,2031618,2162689,4521986,4587522,5898241,5963784,15073281,15335432,18743297,19529730,22478849,23134210,23658497,24576001,25755650,25952258,26148866,26279937,27328513,29884417,34275329,36700162,37945345,39059458,39845889,40173569],"resources":[6291457,7864321,11141121,13434881,15007745,15400961,16842753,21430273,22282241,22413313,23199745,31588353,34603009,35127297,40042497],"remains":[8454145],"reallocations":[5701633,16908289,33030145],"resized":[1835009],"routines":[2097153,18022401,19791873,36044801],"recommended":[12976129,13828097,15794177,15859713,21757953,25493505,27394049],"reflects":[40632321],"reclaimed":[6291457,7864321,11141121,13434881,15007745,15400961,16842753,21430273,22282241,23199745,31588353,34603009,35127297,40042497],"released":[5373953,6160385],"regular":[5963778,7012354,15335426,31195138],"radix":[7864321,11599873,27328513,41091076],"returns":[131076,655361,917505,1048578,1441795,1703939,1769474,1900547,2949121,3276801,4063235,4456452,4653057,4915203,5832705,5963778,6094850,6946818,7012354,7798785,9175041,9764865,12779522,13303810,13434882,13631491,14680065,15007745,15335426,16187393,17104897,17235970,18677762,18939907,19136513,19857409,20185089,21233665,21889027,22216705,22282241,23199745,24444930,24641539,25559041,25624577,28049409,28508161,28639233,30343169,30670849,30867458,31195138,31588353,31653891,31719426,32571396,32636929,33816577,34013187,34537475,34603009,35127298,35586050,35782660,35848193,36110337,36896769,39124994,39321601,40042497,40173569],"results":[393217,5570561,13172737,27852801,40632321],"removed":[31260673],"rof":[16056321,18350081,20774913,25362433,38469633,39714817],"rational":[983041,2621442,2818051,3407878,3932161,3997700,5242883,5963781,6553601,7143425,8978438,9240579,10682370,10813442,11403268,11927553,12976137,13828103,15335429,15400962,15859719,16842758,18284548,20578306,23592964,23986179,24510470,26083333,26673153,27000834,27394057,28246018,28311553,29622277,30474241,31916034,32505859,33095683,34078721,34340868,34406401,34668546,35192834,35520515,35913730,36306946,36569092,38404099,40632322,40763396,40828932,41287682],"routine":[5963777,9240577,11337729,15335425,23724033,33554433],"readable":[16187393],"replace":[5701634,5963777,9306113,15335425,16187394,17235970,21168130,21233666,30867458,35520513,39256066],"readalltext":[17039362,18874370,33161218,34078722,39976961],"random":[524296,2097155,5373954,5570567,5963787,7536649,12255237,12648461,15335435,18022403,19988487,20774920,22872065,24117259,25493509,29884424,30146569,30736395,34406401,34603010,34865157,36503558,39845896,40370181],"rand":[524290,20774914],"reverse":[2555905,17825793,25821185,29556737],"readonly":[3080193,3211265,10420226,10813441,11010050,14417922,15269889,16187393,19464193,20119554,23724033,29032450,33030145,34471937,34668545,35717122,41091073],"reasonable":[14155777,39124993],"ref":[7864321,9306118,10158086,13434881,15007745,15335425,16842753,20250626,21430273,22282241,34603009,40173570],"representable":[39976961],"rounded":[5963779,10027009,15335427,24051713,25231361,41353217],"rounding":[3997697,5963783,15335431,18415617,20250626,21102594,35192833,35323905,40763393],"reallocation":[5701633,9306113,10158081,16908290],"resolution":[29884417,39845889],"result":[196609,1114123,1310721,1376257,1507339,2097153,2162693,2293761,2424833,2555906,2883596,3276813,3342337,3538945,3735553,3866625,3997697,4325388,4718593,4784129,5046273,5111820,5242881,5505025,5898254,5963814,6488065,6815756,7012367,7340033,7536641,7929857,7995393,8060929,8126465,8192002,8257537,8388609,8781825,8978433,9043980,9240577,9699330,9830401,9961485,10027009,10289153,11206657,11272194,11337730,11403265,11665409,11730945,11862018,12124161,12386305,12648449,12713985,12845057,12976129,13041666,13107201,13238274,13303809,13828097,14286860,14548993,14811137,15073286,15335462,15466497,15859713,15925251,16121869,16384001,16449537,16777228,17694721,17825793,17956866,18022401,18087937,18284545,18350092,18415617,18743302,18808833,18874372,19005441,19070977,19333121,19464193,19529740,19660801,19791887,19988481,20316172,20381698,20709378,20905995,20971526,21102593,21299201,21561345,21626882,21954561,22347777,22478850,22675457,22741004,22806529,23592961,23658498,23986177,24051713,24117249,21823489,24313857,24444929,24510465,24576001,24969217,25034764,25559053,25427969,24379394,25821185,25886721,26017794,26083329,26279938,26411020,26607617,26738689,25690114,26935297,25231366,27197441,27328514,27394049,27590657,27721729,28246017,28573706,28704769,28770305,29229057,29294603,29425666,29556738,29622273,29687809,30015499,30146561,30277633,30539777,30736385,30998540,31195151,31260674,31522817,31850497,32178177,32374796,32899073,32964610,33095681,27066374,33751052,33882113,33947650,34078724,34275339,34340865,34996228,35061762,35192833,35454988,35520513,36044815,36241409,36306948,36438017,36503553,36569089,36831233,37289986,37617666,37748738,37814273,37879809,37945355,38010881,38076417,38141965,38207489,38469644,38666252,38797313,38928385,38993932,39059460,39518209,39583745,39649281,39714828,39780364,39976962,40173600,40501258,40566785,40632321,40697869,40763393,40828929,40894465,40960001,41025537,41156620,41353217],"retrieve":[9306116,9895938,10158082,15925250,32178178,36306946],"represent":[17235970,22806530,24444930],"recent":[40632321],"return":[262145,393218,458753,524289,655361,786433,851969,917505,983042,1179649,1245187,1376261,1572865,1638402,1835010,1966081,2031618,2228225,2293765,2359297,2818051,2949121,3014659,3145731,3276801,3604481,4128771,4194305,4259842,4521986,4587522,4653057,4849665,4980737,5046274,5439491,5636099,5767169,5832706,5898242,5963852,6225921,6291457,6356994,6488066,6619139,6684673,6750209,7012355,7077890,7143427,7208961,7405571,7471106,7602178,7667715,7733250,7798785,7864322,8323075,8519681,8650753,8716289,8781827,8847361,8978434,9043970,9175041,9306116,9371649,9437185,9568261,9633793,9699329,9764865,9895938,10223619,10354690,10485761,10551297,10616834,10682370,10747905,10813441,10878977,10944513,11075585,11141121,11337731,11534337,11796481,11862021,11927554,11993089,12058627,12320770,12451842,12582913,12910596,13172738,13238274,13303809,13369346,13500418,13565953,13893634,14024707,14155780,14221313,14286850,14352385,14483458,14614529,14680065,14745603,14942209,15073285,15138818,15335500,15400961,15532037,15597569,15663105,15728642,15794178,15925249,15990785,16056322,16121858,16187393,16318467,16515073,16580609,16646145,16711681,16842753,16973825,17039362,17104897,17170433,17235969,17301506,17367041,17432578,17498113,17563649,17629187,17760257,17956866,18153473,18219009,18415617,18546689,18612226,18743298,18874371,19005445,19136513,19202049,19333126,19398657,19529730,19595265,19791878,19857409,19922946,20054017,20185089,20250627,20316162,20381701,20512770,20578307,20643841,20774913,20840449,20971523,21102593,21168131,21233666,21364737,21430273,21495809,21626884,21692419,21757954,22085634,22216705,22478851,22544385,22740994,22806531,22937601,23003137,23134210,23330817,23396356,23461889,23658498,23855105,23920641,24444929,24707075,24838146,24969221,25034754,25100289,25362434,25296897,25559041,25755650,25952258,26148866,26214401,26279938,25624577,26411010,26476546,26542081,26673155,26804225,27000834,27131905,27262977,27328513,27656197,27852802,27983873,28049409,28114946,28180481,28377089,28442625,28508161,28573698,28639233,28704773,28835841,28901377,28966913,29163521,29360131,29753345,29818881,29949953,30015490,30081025,30343169,30408706,30605315,30670849,30801921,30867457,31064067,31129601,31195139,31260676,31457281,31784961,31850498,31916033,31981569,32178180,32243713,32440321,32636929,32702466,32833539,32964613,27066370,33161218,33226753,33292289,33357829,33423362,33488897,33685505,33816577,34013185,34078723,34144257,34209794,34406401,34668545,34799617,34865155,34930690,35061765,35192833,35258369,35323907,35454979,35520514,35651585,35848193,35913730,35979269,36044806,36110337,36175873,36306945,36372481,36634626,36700162,36765697,36831234,36896769,37027841,37093377,37224449,37355522,37421058,37486593,37683201,38141956,38273025,38338563,38469634,38535169,38600707,38731777,38862849,39059458,39124993,39190529,39321601,39714818,39780354,39976963,40173570,40239105,40304641,40501250,41156611,41222149],"runtime":[22413313],"reallocate":[1835014,3670017,5963777,7471105,9306118,10158088,15335425,33030145],"r1n":[2097158,5963778,15335426,18022406],"reading":[8978433],"restrictions":[21823489,33030145,40173569],"read":[1245186,4128770,5963786,6619138,7536641,8323078,8781831,8978440,11337734,12648449,13500417,14024710,15335434,21692422,22806534,24117249,21823490,30146561,30736385,32833542],"represents":[1441793,4063233,4456449,7864321,13434882,13631489,15007746,16842753,21430273,22282241,23199745,31588353,31653889,34013185,34406414,34537473,34603010,35127297,35782657,40042497],"ranges":[8781825,24444929],"returning":[5963777,15335425,20250625,21626881],"rely":[7536641,12648449,24117249,30146561,30736385],"rop":[196614,1310726,2424856,3342360,3538950,3735559,3866630,3997702,4718616,4784134,5177350,5242886,5505030,5636110,5963889,6488089,7274502,7536657,7929862,7995398,8060934,8126470,8257542,8388614,8781830,8978438,9502726,9830406,10027014,10289176,11272216,11337734,11665414,11730951,12124183,12255246,12648465,12713990,12845062,13041688,13107207,13303816,14548998,14811142,15335537,16384024,16449560,17235974,17694727,18087942,18808838,19070982,19988500,20447238,20971526,21037062,21299224,21561351,21823513,22020102,22347800,22675462,22806534,23592966,23986182,24051718,24117265,24313880,24576024,24444934,24510470,24903686,25165830,25427974,25886726,26083336,26607640,26738694,27590680,27721752,28246022,29229063,29425688,29622280,29687832,30146577,30277638,30539783,30736401,30867463,31260696,31522823,32899078,33882118,34340870,35061788,35520518,36503569,37748742,37879814,38010886,38076442,38797336,38928391,39518214,39583768,40108038,40173583,40566790,40632331,40763398,40894488,40960008,41025542,41287686,41353222],"release":[196610,393218,589825,851970,983042,1114114,1245186,1310722,1376258,1507330,1638401,1966082,2097154,2162690,2293762,2424834,2490370,2555906,2818050,2883586,3014658,3145730,3276802,3342338,3407874,3538946,3735554,3866626,3997698,4128770,4325378,4718594,4784130,5046274,5111810,5177346,5439490,5505026,5636098,5701634,5832706,5898242,6356994,6488066,6619138,6815746,7012354,7077890,7143426,7274498,7340034,7405570,7602178,7667714,7733250,7929858,7995394,8060930,8126465,8192002,8257538,8323074,8388610,8650754,8781826,8912898,8978434,9043970,9502722,9568258,9699330,9830402,9895938,9961474,10027010,10223618,10289154,10354690,10420225,10616834,10682370,11206658,11272194,11337730,11665410,11730946,11862018,11927554,12058626,12124162,12320770,12386306,12451842,12713986,12845058,12910594,12976130,13041666,13107202,13172738,13238274,13303810,13369346,13500418,13828098,13893634,13959170,14024706,14155778,14286850,14483458,14548994,14745602,14811138,15073281,15138818,15204353,15335425,15466498,15532034,15597570,15728642,15794178,15859714,15925250,16056322,16121858,16187394,16318466,16384002,16449538,16777218,16908290,17039362,17235970,17301506,17629186,17694722,17825794,17956866,18022402,18087938,18350082,18415618,18612226,18743298,18808834,18874370,19005442,19070978,19333122,19529730,19660802,19791874,20250626,20316162,20381698,20447234,20512770,20578306,20709378,20905986,20971522,21037058,21102594,21168130,21233666,21299202,21561346,21626882,21692418,21757954,21954562,22020098,22085634,22347778,22478850,22675458,22740994,22806530,23265282,23396354,23658498,23986178,24051714,21823490,24313858,24510466,24576002,24707074,24444930,24838146,24969218,25034754,25362434,25559042,25427970,24379394,25821186,25165826,25886722,26017794,26083330,24903682,26279938,26411010,26476546,26607618,26673154,26738690,25690114,26869761,26935298,27000834,25231362,27197442,27328514,27394050,27590658,27656194,27721730,27852802,28114946,28246018,28311554,28377090,28573698,28704770,28770306,28966914,29097986,29229058,29294594,29360130,29425666,29556738,29622274,29687810,29753346,30015490,30277634,30408706,30474242,30539778,30605314,30867458,30998530,31064066,31195138,31260674,31522818,31850498,32112642,32178178,32374786,32440322,32505858,32833538,32899074,32964610,27066370,33161218,33357826,33423362,33619969,33751042,33882114,33947650,34078722,34209794,34275330,34930690,34996226,35061762,35192834,35323906,35389442,35454978,35520513,35979266,36044802,36241410,36306946,36438018,36634626,36962306,37289986,37355522,37421058,37552129,37617666,37748738,37814274,37879810,37945346,38010882,38076418,38141954,38207490,38338562,38404098,38469634,38600706,38666242,38797314,38928386,38993922,39059458,39124994,39256066,39387138,39518210,39583746,39649282,39714818,39780354,39976961,40108034,40173570,40435713,40501250,40566786,40632322,40697858,40763394,40894466,41025538,41156610,41222146,41287682,41353218,41418753],"rop2":[3407878,5963780,15335428,23265286,25690118,37617670],"reallocates":[8454145,23724033],"regions":[35454977,41156609],"reallocate_function":[9306124,10158088,34406401,37093381],"raw":[1245185,5046273,5963778,15335426],"randomness":[7536641,25493505,29884418,39845890,40370177],"requires":[1114113,2162689,3276801,11730945,15073281,16121857,18743297,21168129,21233665,25559041,34275329,37945345,39059457,39780353],"representation":[1703937,1900545,2097153,2359298,4063233,4915201,5046274,5963779,6291457,7864321,11141121,12648449,13631489,15335427,15400961,16842753,17432578,18022401,19922946,20054018,21430273,21889025,23396353,24641537,28901378,30146561,31653889,27066370,34013185,34144258,34537473,35913730,36503553,37683202],"relations":[37289985],"represented":[3080193,4063233,5046273,13631489,27328513,34471937],"respectively":[2555908,29556740,37289986],"relative":[5963777,15335425,37748737],"reduce":[14155777],"right":[5963777,15335425,22478849,35454978],"resize":[1835009,5701636,5963777,15335425,21168130,21233666,34406401,37093377,39256069],"reason":[5570561],"r1p":[2097165,5963781,15335429,18022413,28573714,38141971,40501267],"requirements":[1114113,3276801,7536641,25559041,25493505,34275329,37945345],"rule":[7733249,10616833,12320769,17301505],"remainder":[1376258,2293762,5963802,7077890,7733249,8192002,10616833,11862018,13893633,15335450,15466498,18743303,19005442,19333122,19791877,20381698,20709378,21626883,22085634,24969218,25231368,24379393,26017794,27197442,28573701,28704770,28770306,32964610,33947650,34209794,36044805,36241410,36634626,37617666,37814274,38141959,38207490,40501253],"realloc_func_ptr":[9306117,10158085],"representing":[3080194,5963777,7864321,8454145,11599873,13500418,14876673,15335425,21430273,34471938],"rop1":[3407878,5963782,15335430,23265286,25690118,37617672],"regiom":[7667713,16318465],"roots":[4718593,6356993,6488065,26017793,30408705,37617665],"realloc":[11730945],"reads":[9961473],"restore":[9306114,40632323],"related":[2555905,17825793,25821185,29556737],"range":[524292,5046273,5832705,5963780,12648451,15335428,15925249,18874369,19988482,20250625,20774915,24117251,27328513,30736387,27066369,35323905,35454977,36503553,39976961,41156609],"reference":[131073,196609,262145,327681,393217,458753,524289,589825,655361,720897,786433,851969,917505,983041,1048577,1114113,1179649,1245185,1310721,1376257,1441793,1507329,1572865,1638401,1703937,1769473,1835009,1900545,1966081,2031617,2097153,2162689,2228225,2293761,2359297,2424833,2490369,2555905,2621441,2686977,2752513,2818049,2883585,2949121,3014657,3080193,3145729,3211265,3276801,3342337,3407873,3473409,3538945,3604481,3670017,3735553,3801089,3866625,3932161,3997697,4063233,4128769,4194305,4259841,4325377,4390913,4456449,4521985,4587521,4653057,4718593,4784129,4849665,4915201,4980737,5046273,5111809,5177345,5242881,5308417,5373953,5439489,5505025,5570561,5636097,5701633,5767169,5832705,5898241,5963779,6029313,6094849,6160385,6225921,6291457,6356993,6422529,6488065,6553601,6619137,6684673,6750209,6815745,6881281,6946817,7012353,7077889,7143430,7208961,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7798785,7864321,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8519681,8585217,8650753,8716289,8781825,8847361,8912897,8978433,9043969,9109505,9175041,9240577,9306113,9371649,9437185,9502721,9568257,9633793,9699329,9764865,9830401,9895937,9961473,10027009,10092545,10158081,10223617,10289153,10354689,10420225,10485761,10551297,10616833,10682369,10747905,10813441,10878977,10944513,11010049,11075585,11141121,11206657,11272193,11337729,11403265,11468801,11534337,11599873,11665409,11730945,11796481,11862017,11927553,11993089,12058625,12124161,12189697,12255233,12320769,12386305,12451841,12517377,12582913,12648449,12713985,12779521,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13434881,13500417,13565953,13631489,13697025,13762561,13828097,13893633,13959169,14024705,14090241,14155777,14221313,14286849,14352385,14417921,14483457,14548993,14614529,14680065,14745601,14811137,14876673,14942209,15007745,15073281,15138817,15204353,15269889,15335427,15400961,15466497,15532033,15597569,15663105,15728641,15794177,15859713,15925249,15990785,16056321,16121857,16187393,16252929,16318465,16384001,16449537,16515073,16580609,16646145,16711681,16777217,16842753,16908289,16973825,17039361,17104897,17170433,17235969,17301505,17367041,17432577,17498113,17563649,17629185,17694721,17760257,17825793,17891329,17956865,18022401,18087937,18153473,18219009,18284545,18350081,18415617,18481153,18546689,18612225,18677761,18743297,18808833,18874369,18939905,19005441,19070977,19136513,19202049,19267585,19333121,19398657,19464193,19529729,19595265,19660801,19726337,19791873,19857409,19922945,19988481,20054017,20119553,20185089,20250625,20316161,20381697,20447233,20512769,20578305,20643841,20709377,20774913,20840449,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21364737,21430273,21495809,21561345,21626881,21692417,21757953,21889025,21954561,22020097,22085633,22151169,22216705,22282241,22347777,22478849,22544385,22609921,22675457,22740993,22806529,22872065,22937601,23003137,23068673,23134209,23199745,23265281,23330817,23396353,23461889,23527425,23592961,23658497,23724033,23789569,23855105,23920641,23986177,24051713,24117249,21823489,24182785,24248321,24313857,24772609,24510465,24576001,24707073,24641537,24444929,24838145,24969217,25034753,25100289,25296897,25362433,25559041,25755649,25427969,24379393,25821185,25165825,25886721,25952257,26017793,26083329,26148865,24903681,26214401,26279937,25624577,26345473,26411009,26476545,26542081,26607617,26673158,26738689,25690113,26804225,26869761,25493505,26935297,27000833,25231361,27131905,27197441,27262977,27328513,27394049,27459585,27525121,27590657,27656193,27721729,27787265,27852801,27918337,27983873,28049409,28114945,28180481,28246017,28311553,28377089,28442625,28508161,28573697,28639233,28704769,28770305,28835841,28901377,28966913,29032449,29097985,29163521,29229057,29294593,29360129,29491201,29425665,29556737,29622273,29687809,29753345,29818881,29884417,29949953,30015489,30081025,30146561,30212097,30277633,30343169,30408705,30474241,30539777,30605313,30670849,30736385,30801921,30867457,30932993,30998529,31064065,31129601,31195137,31260673,31326209,31391745,31457281,31522817,31588353,31653889,31719425,31784961,31850497,31916033,31981569,32047105,32112641,32178177,32243713,32309249,32374785,32440321,32505857,32571393,32636929,32702465,32768001,32833537,32899073,32964609,33030145,33095681,27066369,33161217,33226753,33292289,33357825,33423361,33488897,33554433,33619969,33685505,33751041,33816577,33882113,33947649,34013185,34078721,34144257,34209793,34275329,34340865,34471937,34537473,34603009,34668545,34734081,34799617,34865153,34930689,34996225,35061761,35127297,35192833,35258369,35323906,35389441,35454977,35586049,35520513,35651585,35717121,35782657,35848193,35913729,35979265,36044801,36110337,36175873,36241409,36306945,36372481,36438017,36503553,36569089,36634625,36700161,36765697,36831233,36896769,36962305,37027841,37093377,37158913,37224449,37289985,37355521,37421057,37486593,37552129,37617665,37683201,37748737,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38273025,38338561,38404097,38469633,38535169,38600705,38666241,38731777,38797313,38862849,38928385,38993921,39059457,39124993,39190529,39256065,39321601,39387137,39452673,39518209,39583745,39649281,39714817,39780353,39845889,39911425,39976961,40042497,40108033,40173569,40239105,40304641,40370177,40435713,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41091073,41156609,41222145,41287681,41353217,41418753],"recurrence":[5570561],"rest":[35454977,41156609],"r2n":[38141956],"reallocated":[21168129,21233665],"remarks":[393217,589825,851969,983041,1114113,1179649,1245185,1441793,1835009,1966081,2097153,2162689,2424833,2490369,2555905,3080193,3211265,3276801,3538945,3670017,3735553,4063233,4259841,4456449,5046273,5111809,5373953,5570561,5636097,5701633,5832705,5898241,6160385,6356993,7012353,7143425,7471105,7536641,7667713,7733249,7864321,7929857,8126465,8454145,8650753,8781825,8912897,8978433,9043969,9240577,9306113,9895937,9961473,10223617,10289153,10616833,10682369,11337729,11730945,11927553,12058625,12124161,12320769,12648449,12845057,12910593,12976129,13041665,13172737,13303809,13369345,13434881,13500417,13631489,13828097,13893633,13959169,14155777,14352385,15007745,15073281,15204353,15269889,15335425,15597569,15794177,15859713,15925249,16121857,16187393,16318465,16384001,16842753,16908289,17235969,17301505,17825793,17956865,18022401,18415617,18743297,18874369,19464193,19529729,19726337,19791873,19988481,20250625,20316161,20578305,20774913,20971521,21102593,21168129,21233665,21299201,21430273,21561345,21626881,21757953,22020097,22347777,22478849,22740993,22806529,23396353,23658497,23724033,24117249,21823489,24182785,24576001,24444929,25034753,25362433,25559041,24379393,25821185,26083329,24903681,26279937,26411009,26476545,26607617,26673153,25690113,26869761,25493505,27000833,25231361,27328513,27394049,27721729,27852801,28377089,28573697,29097985,29360129,29425665,29556737,29622273,29753345,29884417,30015489,30146561,30408705,30539777,30736385,30867457,31195137,31391745,31653889,31850497,32047105,32178177,32243713,32440321,32505857,33030145,27066369,33619969,34013185,34078721,34209793,34275329,34471937,34537473,34603009,34865153,34996225,35061761,35192833,35323905,35454977,35520513,35782657,36044801,36306945,36503553,36831233,37158913,37289985,37552129,37945345,38076417,38141953,38338561,38404097,38666241,38797313,38928385,39059457,39124993,39256065,39583745,39780353,39845889,39976961,40108033,40173569,40370177,40501249,40632321,40697857,40960001,41091073,41156609,41287681,41418753]} \ No newline at end of file diff --git a/docs/fti/FTI_115.json b/docs/fti/FTI_115.json new file mode 100644 index 0000000..7a8194c --- /dev/null +++ b/docs/fti/FTI_115.json @@ -0,0 +1 @@ +{"selects":[22413313],"serves":[6291457,7864321,11141121,13434881,15007745,15400961,16842753,21430273,22282241,23199745,31588353,34603009,35127297,40042497],"stored":[4128769,6619137,8323073,14024705,16908289,20250626,21692417,21823489,29360129,32833537,33030146,35323906,38338561],"signed":[917505,2949121,4653057,5963780,6750209,8847361,9371649,9437185,9633793,10944513,14680065,15335428,16711681,17104897,22216705,23920641,25624577,27656194,32178180,33357826,35323905,35979265,36896769,37486593,38535169,41222146],"start":[2555905,10223617,12058625,22478849,29556737],"skipped":[21823489],"sqrt":[196610,4718594,11665410,25886722,37617666,38141954],"starting":[10223619,12058627,23658497,26279937],"swap":[3407875,5963779,15335427,23265283,25690115],"strictly":[19529729],"str":[1441793,5046290,5963782,6160390,7667720,13303814,15335430,15794184,15925257,16318472,17235974,21757960,24444934,27066389,27328522,29360136,30867461,35520518,36306953,38338568],"smaller":[1835010,5963777,15073281,15335425,19988481],"search":[65537],"sequence":[2555905,29556737,29884417,39845889],"sbyte":[720898,2752513,4063235,5308420,6750214,8847364,9371652,9437190,9633798,10944518,13631491,16711686,23068676,23789571,23920646,24248322,24772611,27787268,29491203,31326209,31653892,32309252,34013187,34537476,34734083,37486596,38535174],"s3limb":[5963778,15335426,28573702,40501254],"swaps":[5963777,15335425,34996225],"size":[1114128,1245186,1507330,2162700,2883586,3276811,3670022,4325378,5046274,5111810,5898252,5963781,6815746,6881285,7012355,7405570,7667722,8454145,8585217,9043970,9306116,9699330,9961476,12451842,13238274,13434882,13500417,14286850,14417922,15073286,15269893,15335429,16056322,16121860,16187394,16318474,16777218,16908291,17956866,18350082,18743310,19529744,19791875,20316162,20905986,21233666,21823494,22478852,22740996,23527425,24576001,25034754,25362434,25559051,26411010,26476546,25231372,28573698,28966914,29032450,29294594,29360129,29884417,30015490,30998530,31195139,32374786,27066370,33619974,33751042,34209794,34275342,34865160,34996226,35454978,35717122,36044803,37552129,37945355,38141958,38338561,38469634,38666242,38993922,39059460,39256065,39714818,39780356,39845889,40173578,40501250,40697858,41156610],"sort":[65537],"stdin":[5963778,15335426,21692417,32833537],"stdio":[1245185,5963781,11337729,15335429,18874369,22806529,34078721],"seed":[524290,5963778,12648450,15335426,19988482,20774914,24117250,29884434,30736386,39845916],"s2p":[2883597,4325389,5963794,6815757,7012364,9043982,13238287,15335442,16121871,16777229,22741007,28573713,28966926,30998541,31195148,32374797,33751053,38469645,38666253,38993933,39780367,40501265],"storage":[15925249,36306945],"shifted":[35454977,41156609],"significant":[2097153,2424833,5046273,5570561,5636097,5832705,5898241,5963787,9043969,9895937,10223618,10289153,12058626,12124161,12910593,14286849,15204353,15335435,16121858,16384001,18022401,18743298,19464193,19529729,19988482,20316162,22347777,22478849,22740993,23396353,21823499,25034754,25362433,26869761,25231361,27328513,30015490,32178177,33030150,27066371,35454977,38141953,38469633,38666241,38797313,39583745,39714817,39780353,40173579,40697857,41091073,41156609,41418753],"selected":[5963777,9961473,15335425,34865153],"signs":[38076417,40960001],"swapped":[3407874,23265282,25690113],"style":[7667714,16318466],"stops":[8978433],"sealedattribute":[1441793,4063233,4456449,13631489,15335425,31653889,34013185,34537473,35782657],"sequences":[2555905,17825793,25821185,29556737,29884418,39845890],"system":[393217,524289,655361,786433,851969,983042,1179649,1245190,1310721,1376257,1572865,1638401,1966081,2293761,2555905,3342337,3604481,3997697,4128771,4784129,5046273,5177345,5570561,5767169,6160385,6225921,6488065,6619139,7077889,7208961,7602177,7667714,7864321,7929857,8126465,8323078,8388609,8781831,8847361,8978439,9175041,9371649,9633793,9764865,10616834,11206657,11272194,11337732,11534337,11665409,11862017,11927554,12582913,12713985,13107201,13172737,13303809,13434881,13565953,13762561,14024710,14155777,14352385,14614529,14811137,15007745,15204353,15335425,15728642,15794178,15925249,15990785,16318466,16449538,16646145,16711681,16842753,16973825,17039366,17170433,17235969,17301505,17367041,17760257,17825793,17891329,18415617,18546689,18612225,18808833,18874375,19005441,19136513,19333121,19398657,19857409,20185089,20250625,20381697,20447233,20512770,20643841,20774913,20840449,20971521,21037057,21102593,21430273,21495809,21561345,21626881,21692418,21757954,22020097,22085633,22151169,22282241,22478849,22544385,22675457,22806535,23003137,23461889,23592961,23855105,21823490,24313857,24444929,24969217,25100289,25427969,25821185,25165825,25886721,26017793,26083330,26542081,26869761,27328513,27459585,27590657,27721729,27852801,28377089,28704769,29163521,29229057,29360130,29425665,29556737,29622274,29687809,29884420,30212097,30343169,30539777,30867457,31457281,32243713,32440321,32636929,32833538,32964609,27066369,33161222,33226753,33488897,33554434,33882113,34078727,34340865,34603009,34930689,35192833,35454977,35520513,35651585,36306945,36372481,36634625,37027841,37421057,37486593,37552129,37879809,38338562,38862849,38928385,39059457,39124993,39518209,39845891,39976964,40108033,40173570,40239105,40304641,40566785,40894466,40960001,41025537,41156609,41418753],"strings":[2097153,4128770,5963779,6619138,7667714,8323074,12648449,14024706,15007745,15335427,15728642,15794178,16318466,17039362,18022401,20512770,21692418,21757954,29360130,30146561,32833538,33161218,36503553,38338562],"symbols":[851969,1966081,15597569,28377089,32440321],"sought":[10223617,12058625],"select":[5963777,9961474,15335425,39976961],"safe":[15073281],"seeding":[29884417,39845889],"subtract":[5963780,15335428,22740993,25034753,38469633,39714817],"sum":[5963777,15335425,38010882,40828934],"straightforward":[2555905,17825793,25821185,29556737],"stream":[1245199,4456449,5963793,8323084,8781839,8978447,11337750,14024716,15335441,17039372,18874384,21692418,22806544,32833538,33161228,34078736,34406401,39976971],"spite":[11337729],"subsequent":[16908289,24182785,27066369],"sizes":[1114113,34275329],"small":[18415618,20971521,21299201,35192834],"strsize":[5963777,15335425,27066377],"setting":[21626881],"structure":[131073,262145,327681,655361,720897,786433,917505,1048577,1441794,1572865,1703937,1769473,1900545,2228225,2359297,2752513,2949121,3473409,3604481,4063234,4194305,4456450,4653057,4849665,4915201,4980737,5308417,5767169,6094849,6160385,6225921,6684673,6750209,6946817,7208961,7798785,8519681,8716289,8847361,9175041,9371649,9437185,9633793,9764865,10485761,10551297,10747905,10878977,10944513,11010049,11075585,11534337,11796481,11993089,12582913,12779521,13565953,13631490,13697025,13762561,14221313,14614529,14680065,14942209,15007745,15663105,15990785,16252929,16515073,16580609,16646145,16711681,16973825,17104897,17170433,17367041,17498113,17563649,17760257,17891329,18153473,18219009,18481153,18546689,18677761,18939905,19136513,19202049,19267585,19398657,19595265,19857409,20054017,20119553,20185089,20643841,20840449,21364737,21495809,21889025,22151169,22216705,22544385,22609921,22937601,23003137,23068673,23330817,23461889,23789569,23855105,23920641,24248321,24772609,24641537,25100289,25296897,26214401,25624577,26542081,26804225,27131905,27262977,27459585,27787265,27983873,28049409,28180481,28442625,28508161,28639233,28835841,28901377,29491201,29818881,29949953,30081025,30212097,30343169,30670849,30801921,31129601,31326209,31457281,31653890,31719425,31784961,31981569,32309249,32571393,32636929,32768001,33226753,33488897,33685505,33816577,34013186,34144257,34406401,34537474,34734081,34799617,35258369,35586049,35651585,35782658,35848193,36175873,36372481,36765697,36896769,37027841,37224449,37486593,37683201,38273025,38535169,38731777,38862849,39190529,39321601,39452673,39911425,40239105,40304641],"significance":[1245185,15925249,18874369,27328513,39976961],"set":[196615,393218,589825,851970,983042,1114115,1245186,1310723,1376263,1507330,1638401,1966082,2162691,2293767,2424841,2490370,2555908,2818050,2883586,3014658,3080193,3145732,3276803,3342341,3407876,3538951,3735560,3801089,3866631,3997699,4259842,4325378,4718599,4784131,5111810,5177347,5242881,5439490,5505031,5636098,5701635,5898243,5963937,6356994,6488071,6815746,7012354,7077890,7143426,7274501,7340041,7536642,7602178,7733254,7929863,7995401,8060937,8126468,8192010,8257541,8388615,8650756,8912898,8978434,9043970,9240577,9306114,9502725,9568258,9699330,9830407,9895938,9961474,10027015,10223618,10289161,10354692,10616834,10682372,11206663,11272196,11337730,11403265,11665413,11730947,11862024,11927554,12058626,12124162,12189700,12320772,12386313,12451844,12648450,12713991,12845065,12910596,12976133,13041673,13107207,13172740,13303814,13369346,13500418,13828103,13893636,14155778,14286850,14483460,14549001,14745602,14811143,15007745,15073282,15138818,15335585,15466505,15532034,15597572,15859719,15925250,16121858,16384007,16449541,16777218,16908289,17235971,17301506,17629186,17694729,17825796,18087945,18284545,18350082,18415620,18612228,18743299,18808835,18874370,19005447,19070983,19333128,19529730,19660807,19791874,19988482,20250626,20316162,20381704,20447235,20578308,20709386,20905986,20971522,21037059,21102594,21168130,21233668,21299207,21561350,21626887,21823491,21954569,22020099,22085634,22347778,22413313,22478850,22675463,22740994,23265284,23396354,23592961,23658499,23986180,24051719,24117252,24182787,24313861,24576011,24444931,24510468,24379401,24707074,24903683,24969223,25034754,25165827,25427975,25559043,25821188,25886727,26017800,26083331,26411010,26607627,26673154,26738695,25690116,26935303,27000836,25231362,27197447,27328516,27394053,27525121,27590663,27656194,27721735,27852802,28114948,28246021,28311553,28377090,28573698,28704775,28770313,29097985,29163525,29229063,29294594,29425670,29556740,29622275,29687813,29753348,29884417,30015490,30146562,30277637,30408706,30539782,30605314,30736386,30867459,30998530,31064066,31195138,31260680,31522825,31850500,32112641,32178178,32374786,32440322,32899081,32964616,33095681,33357826,33423362,33751042,33882119,33947658,34078722,34275331,34340865,34471937,34930692,35061768,35192834,35323908,35454978,35520514,35979266,36044802,36241415,36306946,36438025,36503554,36569089,36634626,37289996,37355524,37421058,37617672,37748744,37814279,37879815,37945347,38010889,38076425,38141954,38207497,38404097,38469634,38600706,38666242,38797321,38928390,38993922,39124994,39256067,39387137,39518211,39583750,39649287,39714818,39780354,39845889,39976961,40108035,40173571,40501250,40566791,40632330,40697858,40763397,40828929,40894469,40960001,41025543,41156610,41222146,41287683,41353223],"strlen":[15925249,27328513,36306945],"shallow":[6291457,7864321,11141121,13434881,15007745,15400961,16842753,21430273,22282241,23199745,31588353,34603009,35127297,40042497],"slash":[36306945],"satisfying":[5963777,7733249,10616833,12320769,13369345,13893633,15335425,17301505,37289985],"size_t":[1245189,1703942,1835020,3604489,3670025,5046280,5308440,5963777,6094852,6225929,6881285,7471112,7667718,8781830,8978437,9306120,9764867,10551305,10878985,10944521,11337733,11796489,12451845,13762567,14221326,15335425,16318470,16711689,17104898,17760265,18415617,18874373,19202057,19726337,21757953,21823506,22478853,22806533,23003145,26345473,27066373,27328517,27787299,28442638,28508170,30081033,31391745,31653931,31850497,31981577,32047105,32702469,32768012,33226761,34078725,34144260,34406401,35323905,35651593,36831233,37093386,37158913,38338561,39059462,39190537,39976970,40173588,40239113],"streama":[1245185],"split":[37552129],"square":[196609,4718594,5963786,6356998,11665409,15335434,25362436,37617667,38141954,40697857],"sub":[196609,589825,1114113,1310721,1507329,2097153,2162689,2424833,2490369,2555905,2686977,2883585,3342337,3407873,3538945,3670017,3735553,3866625,3932161,3997697,4325377,4718593,4784129,5111809,5177345,5242881,5373953,5505025,5570561,5701633,6029313,6160385,6553601,6815745,6881281,7274497,7340033,7536641,7929857,7995393,8060929,8126465,8192001,8257537,8388609,8454145,8912897,9240577,9306113,9502721,9830401,9961473,10027009,10092545,10158081,10289153,11206657,11272193,11403265,11665409,11730945,12124161,12255233,12386305,12648449,12713985,12845057,12976129,13041665,13107201,13762561,13828097,13959169,14548993,14811137,15204353,15466497,15859713,16384001,16449537,16777217,16908289,17694721,17825793,17891329,18022401,18087937,18284545,18350081,18808833,19070977,19660801,19726337,19988481,20447233,20709377,20905985,21037057,21299201,21561345,21954561,22020097,22151169,22347777,22675457,22872065,23265281,23592961,23986177,24051713,24117249,21823489,24182785,24313857,24576001,24510465,24379393,24903681,25165825,25231361,25427969,25493505,25690113,25821185,25886721,26017793,26083329,26607617,26738689,26869761,26935297,27197441,27394049,27459585,27525121,27590657,27721729,27918337,28246017,28311553,28770305,29097985,29229057,29294593,29425665,29556737,29622273,29687809,29884417,30146561,30212097,30277633,30474241,30539777,30736385,30998529,31391745,31522817,32047105,32112641,32374785,32505857,32899073,33095681,33554433,33619969,33751041,33882113,33947649,34275329,34340865,34996225,35389441,36241409,36438017,36503553,36569089,36962305,37158913,37289985,37552129,37617665,37748737,37814273,37879809,37945345,38010881,38076417,38207489,38404097,38666241,38797313,38928385,38993921,39256065,39387137,39518209,39583745,39649281,39845889,40108033,40370177,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41287681,41353217,41418753],"seeds":[29884417,39845889],"sure":[8912897,16908289,32505857],"sgn":[37289987],"special":[5832705,5963777,8454145,13500417,15335425,16187394,21168129,21233665,26476545,25493505,29884417,39256065,39845889],"source":[5177345,5898241,7274497,9502721,12255233,16121857,17235969,19529729,19791873,20447233,21037057,22020097,25165825,24903681,28573697,29884417,30867457,35520513,36044801,38666241,39845889,40108033,40501249,40697857,41287681],"satisfy":[7536641,19791873,35061761,36044801],"sizeof":[21823492],"space":[1114116,1179649,2031618,2162692,3276804,3670017,4521986,4587522,5046273,5701634,5963804,6881281,7274497,7471106,8912897,8978435,13959169,15073282,15335452,15794178,16121857,16908290,17235969,18743300,19529729,19726337,21037057,21757954,22478849,22806529,23134210,23724033,24444931,25165825,25559044,25755650,25952258,26148866,26345477,27328513,30474241,31391745,32047105,32505857,32702466,27066369,34275332,34406402,35389441,35520513,36700162,36962305,37158913,37945348,38141953,38666241,39256065,40108033,40173571,40697857],"standard":[5963780,15335428,15728643,20250625,20512771,21692419,22413316,32833539,35323905],"successful":[34865153],"string":[1179656,1245186,1441797,1703937,1900545,2359304,4063233,4128785,4390914,4915201,4980746,5046277,5701634,5963797,6160392,6291457,6422530,6619153,7667727,7864323,8323086,8781829,8978437,9109506,10420231,11075586,11141121,11337730,13303811,13434881,13631489,14024718,14352391,15007745,15335445,15400961,15728649,15794190,15925256,16318481,16842755,17039369,17235973,17432584,18874373,18939907,19922952,20054024,20250626,20512775,21430275,21692426,21757970,21889025,22282241,22478849,22806531,23199745,24444935,24641537,27328519,28901384,29360142,30867459,31588353,31653889,32243719,32833546,27066369,33161227,34013185,34078725,34144264,34406401,34537473,34603009,35127297,35520518,35913736,36306954,37683208,38338577,38404098,39256066,39387138,39976963,40042497],"separated":[39976961],"storing":[4259841,5963777,10158081,15335425],"shift":[3538945,5963778,15335426,35454977,41156610],"skip":[21823489,40173569],"symbol":[851974,1966086,5963783,8650756,15335431,15597574,28377094,29753349,32440326],"safely":[16187393],"sets":[2555905,4063233,5963780,12189697,12517377,13434881,13631489,13762561,15335429,17825793,17891329,22151169,23527425,25821185,27459585,29163521,29556737,30212097,31653889,34013185,34537473],"squares":[6356993],"second":[393217,851969,983042,1114113,1638401,1966081,2162689,2424833,2883585,3276801,3407873,3538945,4325377,4587521,5111809,5505025,5570561,5898241,6488065,6815745,7012353,7602177,7929857,7995393,8060929,8126465,8388609,8650753,9043969,10289153,10354689,10682369,11272193,11403265,11927554,12713985,12845057,12910593,13041665,13107201,13172737,13238273,14286849,14483457,14548993,14811137,15073281,15597569,16777217,17694721,17956865,18087937,18284545,18612225,18743297,18808833,19529731,20316161,20578305,20971521,22675457,22740993,23265281,23592961,25034753,25559041,25755649,25427969,25886721,25952257,26017793,26083329,26148865,25690113,27000833,27852801,28114945,28377089,28966913,29229057,29425665,29622273,29753345,30015489,30998529,31195137,31522817,32374785,32440321,32899073,33751041,33882113,34209793,34275329,34340865,34930689,34996225,35061761,36569089,37289986,37355521,37421057,37748737,37879809,38010881,38076417,38141953,38469633,38666241,38797313,38993921,39714817,39780353,40566785,40828929,40894465,40960001,41025537],"simply":[17235969,19791873,21823489,24444929,28573697,35520513,36044801,40501249],"support":[262145,786433,1179649,1572865,2228225,3604481,4194305,4849665,5767169,6225921,6684673,6750209,7208961,8716289,8847361,9371649,9437185,9633793,10551297,10878977,10944513,11534337,11796481,12582913,13565953,14352385,14614529,14942209,15663105,15990785,16515073,16580609,16646145,16711681,16973825,17170433,17367041,17498113,17563649,17760257,18153473,18219009,19202049,19398657,20643841,20840449,21364737,21495809,22544385,22937601,23003137,23461889,23855105,23920641,25100289,25296897,26214401,26542081,26804225,28180481,30081025,31129601,31457281,31981569,32243713,33226753,33488897,34799617,35258369,35651585,36175873,36372481,36765697,37027841,37224449,37486593,38273025,38535169,38731777,38862849,39190529,40239105,40304641],"sealed":[15335425,36110337],"s1n":[5046281,5963784,15335432,16121865,22740999,34209799,39780360],"sequenceequal":[1114114,1507330,2883586,3276802,4325378,5046274,5111810,5898242,6815746,7012354,9043970,9961474,14286850,16121858,16777218,18350082,19529732,19791874,20316162,20905986,22740994,25034754,25559042,26411010,25231364,28573698,29294594,30015490,30998530,31195138,32374786,27066370,33751042,34275330,34996228,35454978,36044802,37945346,38141956,38469634,38666242,38993922,39714818,39780354,40501250,40697858,41156610],"specified":[131074,655361,1048578,1441794,1703938,1769474,1900546,4063234,4456450,4915202,6094850,6291457,6946818,7798785,7864321,8781826,9175041,9764865,11141121,12779522,13434881,13631490,15007745,15400961,16842753,18677762,18939906,19136513,19857409,20185089,21430273,21889026,22282241,22413313,23199745,24444930,24641538,28049409,28508161,28639233,30343169,30670849,31588353,31653890,31719426,32571394,32636929,33816577,34013186,34537474,34603009,35127297,35586050,35782658,35848193,39321601,40042497],"short":[2228227,3014658,3604481,4194305,7208963,8716291,10878979,13565953,14614529,14942211,15204353,19202049,20840449,21495811,22544387,22937601,23003139,23461889,21823489,31129603,31457283,33357826,34799617,38731777],"snprintf":[7667713,16318465],"supported":[196610,393218,524290,589826,851970,983042,1114114,1245186,1310722,1376258,1507330,1638402,1966082,2097154,2162690,2293762,2424834,2490370,2555906,2818050,2883586,3014658,3145730,3276802,3342338,3407874,3538946,3735554,3866626,3932162,3997698,4128770,4259842,4325378,4718594,4784130,5046274,5111810,5177346,5242882,5439490,5505026,5570562,5636098,5701634,5832706,5898242,6356994,6488066,6619138,6815746,7012354,7077890,7143426,7274498,7340034,7405570,7536642,7602178,7667714,7733250,7929858,7995394,8060930,8126466,8192002,8257538,8323074,8388610,8650754,8781826,8912898,8978434,9043970,9240578,9306114,9502722,9568258,9699330,9830402,9895938,9961474,10027010,10158082,10223618,10289154,10354690,10420226,10616834,10682370,11206658,11272194,11337730,11403266,11665410,11730946,11862018,11927554,12058626,12124162,12255234,12320770,12386306,12451842,12648450,12713986,12845058,12910594,12976130,13041666,13107202,13172738,13238274,13303810,13369346,13500418,13828098,13893634,13959170,14024706,14155778,14286850,14417922,14483458,14548994,14745602,14811138,15073282,15138818,15466498,15532034,15597570,15728642,15794178,15859714,15925250,16056322,16121858,16187394,16318466,16384002,16449538,16777218,16908290,17039362,17235970,17301506,17629186,17694722,17825794,17956866,18022402,18087938,18284546,18350082,18415618,18612226,18743298,18808834,18874370,19005442,19070978,19333122,19529730,19660802,19791874,19988482,20250626,20316162,20381698,20447234,20512770,20578306,20709378,20774914,20905986,20971522,21037058,21102594,21168130,21233666,21299202,21561346,21626882,21692418,21757954,21954562,22020098,22085634,22347778,22478850,22675458,22740994,22806530,23265282,23396354,23592962,23658498,23986178,24051714,24117250,21823490,24182786,24313858,24510466,24576002,24707074,24444930,24838146,24969218,25034754,25362434,25559042,25427970,24379394,25821186,25165826,25886722,26017794,26083330,24903682,26279938,26411010,26476546,26607619,26673154,26738690,25690114,25493506,26935298,27000834,25231362,27197442,27328514,27394050,27590658,27656194,27721731,27852802,28114946,28246018,28311554,28377090,28573698,28704770,28770306,28966914,29032450,29097986,29229058,29294594,29360130,29425667,29556738,29622274,29687810,29753346,29884418,30015490,30146562,30277634,30408706,30474242,30539778,30605314,30736386,30867458,30998530,31064066,31195138,31260674,31522818,31850498,32112642,32178178,32374786,32440322,32505858,32833538,32899074,32964610,33095682,27066370,33161218,33357826,33423362,33751042,33882114,33947650,34078722,34209794,34275330,34340866,34865154,34930690,34996226,35061762,35192834,35323906,35389442,35454978,35520514,35717122,35979266,36044802,36241410,36306946,36438018,36503554,36569090,36634626,36831234,36962306,37289986,37355522,37421058,37617666,37748738,37814274,37879810,37945346,38010882,38076418,38141954,38207490,38338562,38404098,38469634,38600706,38666242,38797314,38928386,38993922,39059458,39124994,39256066,39387138,39518210,39583746,39649282,39714818,39780354,39845890,39976962,40108034,40173570,40370178,40501250,40566786,40632322,40697858,40763394,40828930,40894466,40960002,41025538,41156610,41222146,41287682,41353218],"systems":[4063233,7864321,8781825,13631490,21823489,24444929,29884417,34013185,39845889,39976961],"speed":[9043969,25493505,30015489],"seminumerical":[5963777,15335425,39124993],"starting_bit":[10223624,12058632],"static":[196611,262146,393219,524291,589827,786434,851971,983043,1114115,1179650,1245187,1310723,1376259,1507331,1572866,1638403,1835011,1966083,2031619,2097155,2162691,2228226,2293763,2424835,2490371,2555907,2818051,2883587,3014659,3145731,3276803,3342339,3407875,3538947,3604482,3670019,3735555,3866627,3932163,3997699,4128771,4194306,4259843,4325379,4521987,4587523,4718595,4784131,4849666,5046275,5111811,5177347,5242883,5439491,5505027,5570563,5636099,5701635,5767170,5832707,5898243,6225922,6356995,6488067,6619139,6684674,6750210,6815747,7012355,7077891,7143427,7208962,7274499,7340035,7405571,7471107,7536643,7602179,7667715,7733251,7929859,7995395,8060931,8126467,8192003,8257539,8323075,8388611,8454147,8519683,8650755,8716290,8781827,8847362,8912899,8978435,9043971,9240579,9306115,9371650,9437186,9502723,9568259,9633794,9699331,9830403,9895939,9961475,10027011,10158083,10223619,10289155,10354691,10420227,10551298,10616835,10682371,10747907,10878978,10944514,11010051,11206659,11272195,11337731,11403267,11534338,11665411,11730947,11796482,11862019,11927555,11993091,12058627,12124163,12189699,12255235,12320771,12386307,12451843,12582914,12648451,12713987,12845059,12910595,12976131,13041667,13107203,13172739,13238275,13303811,13369347,13500419,13565954,13828099,13893635,13959171,14024707,14155779,14221315,14286851,14352386,14417923,14483459,14548995,14614530,14745603,14811139,14942210,15073283,15138819,15335425,15466499,15532035,15597571,15663106,15728643,15794179,15859715,15925251,15990786,16056323,16121859,16187396,16318467,16384003,16449539,16515074,16580610,16646146,16711682,16777219,16908291,16973826,17039363,17170434,17235971,17301507,17367042,17498114,17563650,17629187,17694723,17760258,17825795,17956867,18022403,18087939,18153474,18219010,18284547,18350083,18415619,18612227,18743299,18808835,18874371,19005443,19070979,19202050,19333123,19398658,19529731,19595267,19660803,19726339,19791875,19988483,20119555,20250627,20316163,20381699,20447235,20512771,20578307,20643842,20709379,20774915,20840450,20905987,20971523,21037059,21102595,21168131,21233667,21299203,21364738,21495810,21561347,21626883,21692419,21757955,21823491,21954563,22020099,22085635,22347779,22413313,22478851,22544386,22675459,22740995,22806531,22872067,22937602,23003138,23134211,23265283,23330819,23396355,23461890,23592963,23658499,23855106,23920642,23986179,24051715,24117251,24182787,24313859,24444931,24576003,24510467,24707075,24379395,24838147,24903683,24969219,25034755,25100290,25165827,25231363,25296898,25362435,25427971,25493507,25559043,25690115,25755651,25821187,25886723,25952259,26017795,26083331,26148867,26214402,26279939,26411011,26476547,26542082,26607619,26673155,26738691,26804226,26935299,27000835,27066371,27131907,27197443,27262979,27328515,27394051,27590659,27656195,27721731,27852803,27983875,28114947,28180482,28246019,28311555,28377091,28442627,28573699,28704771,28770307,28835843,28966915,29032451,29097987,29229059,29294595,29360131,29425667,29556739,29622275,29687811,29753347,29818883,29884419,29949955,30015491,30081026,30146563,30277635,30408707,30474243,30539779,30605315,30736387,30801923,30867459,30998531,31064067,31129602,31195139,31260675,31391747,31457282,31522819,31784963,31850499,31981570,32047107,32112643,32178179,32243714,32374787,32440323,32505859,32833539,32899075,32964611,33095683,33161219,33226754,33357827,33423363,33488898,33554435,33685507,33751043,33882115,33947651,34078723,34209795,34275331,34340867,34799618,34865155,34930691,34996227,35061763,35192835,35258370,35323907,35389443,35454979,35520515,35651586,35717123,35979267,36044803,36175874,36241411,36306947,36372482,36438019,36503555,36569091,36634627,36700163,36765698,36831235,36962307,37027842,37158915,37224450,37289987,37355523,37421059,37486594,37617667,37748739,37814275,37879811,37945347,38010883,38076419,38141955,38207491,38273026,38338563,38404099,38469635,38535170,38600707,38666243,38731778,38797315,38862850,38928387,38993923,39059459,39124995,39190530,39256067,39387139,39518211,39583747,39649283,39714819,39780355,39845891,39976963,40108035,40173571,40239106,40304642,40370179,40501251,40566787,40632323,40697859,40763395,40828931,40894467,40960003,41025539,41156611,41222147,41287683,41353219],"section":[29425665],"subtraction":[22740994,25034753],"structures":[34406401],"single":[3276801,5963778,15335426,22413313,25559041,34537473,40763393],"scan":[5963780,10223618,12058626,15335428,23658497,26279937],"sign":[2424833,5636097,5832705,8454147,9895937,10223617,10289153,12058625,12124161,12910593,15925249,16187395,16384001,21626881,22347777,22478850,23396353,21823490,24444929,24707074,24379393,27328513,31064066,32178177,36306945,38797313,39583745,40173570],"specify":[1179649,8781825,21823489,24444929,40173569],"separately":[5963778,8978433,14352385,15335426,20250625,35323905,35520513],"summary":[15335425,34406401],"state":[524307,5373954,5570580,5963784,7536644,12255244,12648470,15335432,19988500,20774931,22872072,24117270,24576001,25493524,29884438,30146562,30736406,34406401,34603010,34865172,39845910,40370196],"subtrahend":[5963777,15335425,26411009,36569094],"s1p":[1507335,2883599,4325391,5046293,5963808,6815759,7012366,9043982,9699344,13238289,14286863,15335456,16056330,16121871,16777231,20316177,20905991,22741007,23658509,25034769,25362451,26279949,28966928,30015505,30998543,31195150,32374799,27066370,33751055,34209809,38469645,38666255,38993935,39714831,39780367,40697871],"somewhat":[35061761],"shared":[196609,262145,393217,524289,589825,786433,851969,983041,1114113,1179649,1245185,1310721,1376257,1507329,1572865,1638401,1835009,1966081,2031617,2097153,2162689,2228225,2293761,2424833,2490369,2555905,2818049,2883585,3014657,3145729,3276801,3342337,3407873,3538945,3604481,3670017,3735553,3866625,3932161,3997697,4128769,4194305,4259841,4325377,4521985,4587521,4718593,4784129,4849665,5046273,5111809,5177345,5242881,5439489,5505025,5570561,5636097,5701633,5767169,5832705,5898241,6225921,6356993,6488065,6619137,6684673,6750209,6815745,7012353,7077889,7143425,7208961,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8519681,8650753,8716289,8781825,8847361,8912897,8978433,9043969,9240577,9306113,9371649,9437185,9502721,9568257,9633793,9699329,9830401,9895937,9961473,10027009,10158081,10223617,10289153,10354689,10420225,10551297,10616833,10682369,10747905,10878977,10944513,11010049,11206657,11272193,11337729,11403265,11534337,11665409,11730945,11796481,11862017,11927553,11993089,12058625,12124161,12189697,12255233,12320769,12386305,12451841,12582913,12648449,12713985,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13500417,13565953,13828097,13893633,13959169,14024705,14155777,14221313,14286849,14352385,14417921,14483457,14548993,14614529,14745601,14811137,14942209,15073281,15138817,15466497,15532033,15597569,15663105,15728641,15794177,15859713,15925249,15990785,16056321,16121857,16187393,16318465,16384001,16449537,16515073,16580609,16646145,16711681,16777217,16908289,16973825,17039361,17170433,17235969,17301505,17367041,17498113,17563649,17629185,17694721,17760257,17825793,17956865,18022401,18087937,18153473,18219009,18284545,18350081,18415617,18612225,18743297,18808833,18874369,19005441,19070977,19202049,19333121,19398657,19529729,19595265,19660801,19726337,19791873,19988481,20119553,20250625,20316161,20381697,20447233,20512769,20578305,20643841,20709377,20774913,20840449,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21364737,21495809,21561345,21626881,21692417,21757953,21954561,22020097,22085633,22347777,22478849,22544385,22675457,22740993,22806529,22872065,22937601,23003137,23134209,23265281,23330817,23396353,23461889,23592961,23658497,23855105,23920641,23986177,24051713,24117249,21823489,24182785,24313857,24576001,24510465,24444929,24707073,24379393,24838145,24903681,24969217,25034753,25100289,25165825,25231361,25296897,25362433,25427969,25493505,25559041,25690113,25755649,25821185,25886721,25952257,26017793,26083329,26148865,26214401,26279937,26411009,26476545,26542081,26607617,26673153,26738689,26804225,26935297,27000833,27066369,27131905,27197441,27262977,27328513,27394049,27590657,27656193,27721729,27852801,27983873,28114945,28180481,28246017,28311553,28377089,28442625,28573697,28704769,28770305,28835841,28966913,29032449,29097985,29229057,29294593,29360129,29425665,29556737,29622273,29687809,29753345,29818881,29884417,29949953,30015489,30081025,30146561,30277633,30408705,30474241,30539777,30605313,30736385,30801921,30867457,30998529,31064065,31129601,31195137,31260673,31391745,31457281,31522817,31784961,31850497,31981569,32047105,32112641,32178177,32243713,32374785,32440321,32505857,32833537,32899073,32964609,33095681,33161217,33226753,33357825,33423361,33488897,33554433,33685505,33751041,33882113,33947649,34078721,34209793,34275329,34340865,34799617,34865153,34930689,34996225,35061761,35192833,35258369,35323905,35389441,35454977,35520513,35651585,35717121,35979265,36044801,36175873,36241409,36306945,36372481,36438017,36503553,36569089,36634625,36700161,36765697,36831233,36962305,37027841,37158913,37224449,37289985,37355521,37421057,37486593,37617665,37748737,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38273025,38338561,38404097,38469633,38535169,38600705,38666241,38731777,38797313,38862849,38928385,38993921,39059457,39124993,39190529,39256065,39387137,39518209,39583745,39649281,39714817,39780353,39845889,39976961,40108033,40173569,40239105,40304641,40370177,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41156609,41222145,41287681,41353217],"slow":[19791873,36044801],"s2limb":[5963782,14286854,15335430,20316166,25034758,30015496,34209798,39714822],"similar":[2555905,20250625,29556737,35323905],"stdout":[5963778,15335426,15728641,20512769],"successfully":[4128769,6619137,8323073,14024705,21692417,32833537],"struct":[1441794,4063234,4456450,13631490,15007746,31653890,34013186,34537474,35782658],"scratch":[1114117,2031618,2162692,3276805,4521986,4587522,5963784,15073283,15335432,18743300,23134210,25559045,25755650,25952258,26148866,34275333,36700162,37945349],"store":[2097153,5963784,9961473,11272193,15335432,18022401,19529730,20971521,29425665,31260673,37748737],"suited":[29884417,39845889],"separate":[5111809,28573697,29884417,38141954,39845889,40501249],"studio":[22413313],"sense":[24444929],"shows":[41091073],"suppressed":[4128769,6619137,8323073,14024705,21692417,32833537],"s2n":[5963782,15335430,16121865,22740998,28573704,39780359,40501256],"syntax":[196609,262145,393217,458753,524289,589825,655361,786433,851969,917505,983041,1114113,1179649,1245185,1310721,1376257,1441793,1507329,1572865,1638401,1835009,1966081,2031617,2097153,2162689,2228225,2293761,2359297,2424833,2490369,2555905,2686977,2818049,2883585,2949121,3014657,3080193,3145729,3211265,3276801,3342337,3407873,3538945,3604481,3670017,3735553,3866625,3932161,3997697,4063233,4128769,4194305,4259841,4325377,4456449,4521985,4587521,4653057,4718593,4784129,4849665,4980737,5046273,5111809,5177345,5242881,5373953,5439489,5505025,5570561,5636097,5701633,5767169,5832705,5898241,6029313,6160385,6225921,6356993,6488065,6553601,6619137,6684673,6750209,6815745,6881281,7012353,7077889,7143425,7208961,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7798785,7864321,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8519681,8650753,8716289,8781825,8847361,8912897,8978433,9043969,9175041,9240577,9306113,9371649,9437185,9502721,9568257,9633793,9699329,9764865,9830401,9895937,9961473,10027009,10092545,10158081,10223617,10289153,10354689,10420225,10485761,10551297,10616833,10682369,10747905,10813441,10878977,10944513,11010049,11075585,11206657,11272193,11337729,11403265,11468801,11534337,11665409,11730945,11796481,11862017,11927553,11993089,12058625,12124161,12189697,12255233,12320769,12386305,12451841,12582913,12648449,12713985,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13434881,13500417,13565953,13631489,13762561,13828097,13893633,13959169,14024705,14155777,14221313,14286849,14352385,14417921,14483457,14548993,14614529,14680065,14745601,14811137,14942209,15007745,15073281,15138817,15204353,15269889,15335425,15466497,15532033,15597569,15663105,15728641,15794177,15859713,15925249,15990785,16056321,16121857,16187393,16318465,16384001,16449537,16515073,16580609,16646145,16711681,16777217,16842753,16908289,16973825,17039361,17104897,17170433,17235969,17301505,17367041,17432577,17498113,17563649,17629185,17694721,17760257,17825793,17891329,17956865,18022401,18087937,18153473,18219009,18284545,18350081,18415617,18546689,18612225,18743297,18808833,18874369,19005441,19070977,19136513,19202049,19333121,19398657,19464193,19529729,19595265,19660801,19726337,19791873,19857409,19922945,19988481,20054017,20119553,20185089,20250625,20316161,20381697,20447233,20512769,20578305,20643841,20709377,20774913,20840449,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21364737,21430273,21495809,21561345,21626881,21692417,21757953,21823489,21954561,22020097,22085633,22151169,22216705,22282241,22347777,22478849,22544385,22675457,22740993,22806529,22872065,22937601,23003137,23134209,23265281,23330817,23396353,23461889,23592961,23658497,23724033,23855105,23920641,23986177,24051713,24117249,24182785,24313857,24444929,24510465,24576001,24707073,24379393,24838145,24903681,24969217,25034753,25100289,25165825,25231361,25296897,25362433,25427969,25493505,25559041,25624577,25690113,25755649,25821185,25886721,25952257,26017793,26083329,26148865,26214401,26279937,26411009,26476545,26542081,26607617,26673153,26738689,26804225,26869761,26935297,27000833,27066369,27131905,27197441,27262977,27328513,27394049,27459585,27525121,27590657,27656193,27721729,27852801,27918337,27983873,28049409,28114945,28180481,28246017,28311553,28377089,28442625,28508161,28573697,28639233,28704769,28770305,28835841,28901377,28966913,29032449,29097985,29163521,29229057,29294593,29360129,29425665,29556737,29622273,29687809,29753345,29818881,29884417,29949953,30015489,30081025,30146561,30212097,30277633,30343169,30408705,30474241,30539777,30605313,30670849,30736385,30801921,30867457,30998529,31064065,31129601,31195137,31260673,31391745,31457281,31522817,31653889,31784961,31850497,31916033,31981569,32047105,32112641,32178177,32243713,32374785,32440321,32505857,32636929,32702465,32833537,32899073,32964609,33030145,33095681,33161217,33226753,33292289,33357825,33423361,33488897,33554433,33619969,33685505,33751041,33816577,33882113,33947649,34013185,34078721,34144257,34209793,34275329,34340865,34471937,34537473,34603009,34668545,34799617,34865153,34930689,34996225,35061761,35192833,35258369,35323905,35389441,35454977,35520513,35651585,35717121,35782657,35848193,35913729,35979265,36044801,36110337,36175873,36241409,36306945,36372481,36438017,36503553,36569089,36634625,36700161,36765697,36831233,36896769,36962305,37027841,37093377,37158913,37224449,37289985,37355521,37421057,37486593,37552129,37617665,37683201,37748737,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38273025,38338561,38404097,38469633,38535169,38600705,38666241,38731777,38797313,38862849,38928385,38993921,39059457,39124993,39190529,39256065,39321601,39387137,39452673,39518209,39583745,39649281,39714817,39780353,39845889,39976961,40108033,40173569,40239105,40304641,40370177,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41091073,41156609,41222145,41287681,41353217,41418753]} \ No newline at end of file diff --git a/docs/fti/FTI_116.json b/docs/fti/FTI_116.json new file mode 100644 index 0000000..78801e9 --- /dev/null +++ b/docs/fti/FTI_116.json @@ -0,0 +1 @@ +{"twice":[18808834],"typename":[15007745],"timing":[7012354,31195138],"tests":[14155778,22413313],"two":[1441794,4063234,4456450,5963778,7536641,8519682,10682369,10747906,11993090,12648449,12910595,13369345,13631490,13697026,13893633,14221314,15335426,15925249,16252930,19595266,19660801,22478849,22609922,23068674,23330818,23789570,24117249,24576001,25690113,26935297,27000833,27131906,27197441,27262978,27787266,27983874,28442626,28835842,28966913,29491202,29818882,29949954,30146561,30736385,30801922,31653890,31784962,33685506,34013186,34537474,34734082,35782658,36241409,37814273,38666241,39649281],"times":[9306114],"twister":[5963777,12255234,15335425,29884418,39845890,40370179],"types":[15007746,22413313],"trap":[21102593],"tointptr":[458757,1441793,5046274,6291457,7864321,10485765,11075589,11141121,15400961,16842753,18939905,21430273,21823490,31916037,32571393,27066370,33292293,35782657,40173570],"twos":[2424833,5636097,10223617,10289153,12058625,12124161,12910593,16384001,22347777,23396353,38797313,39583745],"treated":[16187393,41091073],"tostring":[131073,1441794,1703938,1900546,2359302,4063234,4128774,4456449,4915202,4980742,5701634,6291458,6619142,7667714,7864322,8323078,11141122,13303810,13434881,13631490,14024710,15007745,15400962,15794178,15925250,16187394,16318466,16842754,17235972,17432582,18939906,19922950,20054022,21168130,21233666,21430274,21692422,21757954,21889026,22282241,23199745,21823490,24641538,24444930,27328514,28246018,28901382,29360130,30277634,30867460,31588353,31653890,32571393,32833542,34013186,34144262,34537474,34603009,35127297,35520514,35782657,35913734,36306946,37683206,38338562,38404098,39256066,39387138,40042497,40632324],"three":[36306945],"true":[655361,7012353,7798785,8519681,9175041,9764865,10747905,11993089,14221313,19136513,19595265,19857409,20185089,23330817,21823490,24444929,27131905,27262977,27983873,28049409,28442625,28508161,28639233,28835841,29818881,29949953,30343169,30670849,30801921,31195137,31784961,32636929,33685505,33816577,34996225,35848193,39321601],"thoroughly":[22413313],"taken":[3735553,8454145,8781825,13303809,21561345,21823489,24444929,29884417,30539777,38928385,39845889],"takes":[3276801,19791873,25559041,36044801,39256065],"traps":[18415617,35192833],"truncation":[22020098,24903682,40108034,41287682],"truncated":[3014658,4718593,5439490,5963787,6488065,7667713,11730945,14745602,15335435,16318465,17629186,18743297,20250625,26017793,30605314,35323905,37617665,38600706],"trunc":[4718594,5963785,6488066,8192003,10027010,12386309,15335433,19005443,19660805,24969219,26017794,28770307,32964611,36241411,36634628,37617666,38141954],"tell":[24444929],"terminated":[589825,4128769,5963792,6619137,7667713,15335440,15794177,16318465,17235969,21757953,28311553,29360129,30474241,32112642,35389442,35520513,36962305,38338561],"total":[7667713,16318465],"truncate":[22020097,24903681,40108033,41287681],"terminator":[7667713,15925250,16318465,22478849,27328514,29360130,36306946,38338562],"trial":[14155777],"traditionally":[29884417,39845889],"title":[65537],"time":[3276801,24576001,25559041,29884418,39845890],"temporary":[1245196,8781830,8978438,11337734,18874380,22806534,34078732,39976966],"theoretic":[851969,1966081,2555905,3342337,8650753,11272193,13041665,14155777,15597569,17825793,20971521,21299201,24313857,25821185,28377089,29425665,29556737,29687809,29753345,31260673,32440321,35061761,37289985,38076417,39124993,40894465,40960001],"try":[6291457,7864321,11141121,13434881,15007745,15400961,16842753,21430273,22282241,23199745,31588353,34603009,35127297,40042497],"top":[131073,327681,720897,1048577,1441796,1703937,1769473,1900545,2621441,2752513,3473409,3801089,4063235,4390913,4456451,4915201,5308417,5963777,6094849,6291457,6422529,6946817,7864324,8585217,9109505,11141121,11599873,12517377,12779521,13434883,13631491,13697025,14090241,14876673,15007747,15335427,15400961,16252929,16842756,18481153,18677761,18939905,19267585,21430276,21889025,22282243,22609921,23068673,23199745,23527425,23789569,24248321,24772609,24641537,26345473,27787265,29491201,30932993,31326209,31588353,31653891,31719425,32309249,32571393,32768001,34013187,34537475,34603010,34734081,35127297,35586049,35782659,39911425,40042497,40435713],"trailing":[27328513],"testing":[2097153,12648449,18022401,30146561,36503553],"table":[5963777,9961477,15335425,34865154],"tab":[5963777,9961488,15335425],"tight":[11730945],"third":[9961474,15073281,25755649,34275329],"trigger":[12648449,30146561,36503553],"tested":[22413313],"terminating":[7667713,15794177,16318465,21757953],"topic":[1],"type":[131075,196610,262146,393219,458753,524291,589825,655362,786434,851971,917505,983044,1114118,1179650,1245187,1310722,1376260,1441795,1507331,1572866,1638403,1703938,1835012,1900546,1966083,2031618,2097154,2162693,2228226,2293764,2359297,2424835,2490369,2555907,2621441,2818050,2883588,2949121,3014658,3080193,3145730,3211265,3276806,3342338,3407874,3473409,3538947,3604482,3670018,3735554,3866626,3932161,3997698,4063236,4128772,4194306,4259841,4325380,4390914,4456452,4521986,4587523,4653057,4718594,4784130,4849666,4915202,4980737,5046277,5111812,5177346,5242882,5439490,5505027,5570564,5636099,5701634,5767170,5832707,5898246,5963777,6160385,6225922,6291459,6356994,6422530,6488068,6619140,6684674,6750210,6815748,6881283,7012358,7077891,7143426,7208962,7274498,7340035,7405571,7471106,7536642,7602179,7667717,7733252,7798786,7864325,7929859,7995395,8060931,8126467,8192004,8257538,8323076,8388611,8454146,8519683,8650755,8716290,8781828,8847362,8912897,8978436,9043973,9109506,9175042,9240578,9306115,9371650,9437186,9502722,9568258,9633794,9699331,9764866,9830402,9895938,9961477,10027010,10158083,10223619,10289155,10354691,10420225,10485761,10551298,10616836,10682371,10747907,10813441,10878978,10944514,11010049,11075585,11141123,11206659,11272195,11337731,11403267,11468801,11534338,11599873,11665410,11730946,11796482,11862021,11927556,11993091,12058627,12124162,12189697,12255234,12320771,12386307,12451842,12517377,12582914,12648451,12713987,12845059,12910595,12976130,13041667,13107203,13172739,13238276,13303812,13369347,13434884,13500418,13565954,13631492,13697025,13762561,13828098,13893636,13959169,14024708,14090241,14155779,14221315,14286853,14352386,14417921,14483459,14548995,14614530,14680065,14745602,14811139,14876673,14942210,15007752,15073287,15138818,15204353,15269889,15335426,15400963,15466499,15532034,15597571,15663106,15728643,15794180,15859714,15925252,15990786,16056323,16121862,16187397,16252929,16318469,16384002,16449539,16515074,16580610,16646146,16711682,16777220,16842756,16908290,16973826,17039364,17104897,17170434,17235972,17301507,17367042,17432577,17498114,17563650,17629186,17694723,17760258,17825794,17891329,17956868,18022402,18087939,18153474,18219010,18284547,18350083,18415618,18546690,18612227,18743303,18808835,18874372,18939906,19005444,19070978,19136514,19202050,19267585,19333124,19398658,19464193,19529736,19595267,19660803,19726337,19791876,19857410,19922945,19988483,20054017,20119553,20185090,20250627,20316165,20381701,20447234,20512771,20578307,20643842,20709380,20774915,20840450,20905987,20971524,21037058,21102594,21168131,21233667,21299202,21364738,21430276,21495810,21561346,21626884,21692419,21757956,21889026,21954563,22020098,22085635,22151169,22216705,22282244,22347778,22413313,22478851,22544386,22609921,22675459,22740998,22806532,22872065,22937602,23003138,23068674,23134210,23199747,23265282,23330819,23396354,23461890,23527425,23592963,23658499,23724033,23789570,23855106,23920642,23986178,24051714,24117251,21823496,24182785,24313858,24510466,24576004,24444932,24641538,24707074,24838146,24969220,25034757,25100290,25296898,25362435,25559046,25755652,25427971,24379395,25821186,25165826,25886723,25952259,26017796,26083331,26148867,24903682,26214402,26279939,25624577,26411012,26476546,26542082,26607620,26673154,26738690,25690114,26804226,26869761,25493505,26935299,27000835,25231367,27131907,27197443,27262979,27328518,27394050,27459585,27525121,27590659,27656194,27721732,27787266,27852803,27983875,28049410,28114947,28180482,28246018,28311553,28377091,28442627,28508162,28573701,28639234,28704772,28770307,28835843,28901377,28966916,29032449,29097986,29163522,29229059,29294594,29360132,29425667,29491202,29556739,29622275,29687810,29753347,29818883,29884418,29949955,30015493,30081026,30146562,30212097,30277634,30343170,30408706,30474241,30539778,30605314,30670850,30736387,30801923,30867460,30932993,30998532,31064066,31129602,31195142,31260676,31391745,31457282,31522819,31588355,31653891,31784963,31850499,31916033,31981570,32047105,32112641,32178178,32243714,32374788,32440323,32505857,32571395,32636930,32702467,32833539,32899075,32964613,33030145,33095682,27066373,33161220,33226754,33292289,33357826,33423362,33488898,33554434,33619969,33685507,33751044,33816578,33882115,33947652,34013188,34078724,34144257,34209796,34275336,34340867,34406401,34471937,34537475,34603012,34668545,34734082,34799618,34865155,34930691,34996228,35061764,35127299,35192834,35258370,35323907,35389441,35454981,35520516,35651586,35717121,35782660,35848194,35913729,35979266,36044805,36110337,36175874,36241411,36306948,36372482,36438019,36503555,36569091,36634627,36700162,36765698,36831235,36896769,36962305,37027842,37093381,37158913,37224450,37289989,37355523,37421059,37486594,37552129,37617667,37683201,37748739,37814275,37879811,37945348,38010883,38076419,38141957,38207491,38273026,38338564,38404097,38469637,38535170,38600706,38666244,38731778,38797315,38862850,38928386,38993924,39059460,39124995,39190530,39256066,39321602,39387137,39452673,39518210,39583746,39649283,39714821,39780358,39845890,39911425,39976965,40042499,40108034,40173576,40239106,40304642,40370177,40435713,40501254,40566787,40632322,40697859,40763394,40828931,40894467,40960003,41025539,41091073,41156613,41222146,41287682,41353218,41418753],"tmp":[16187394],"test":[5636098,5963779,7405569,15335427,39124993],"truncating":[5963783,15335431,18415617,20250626,21102594,31850497,35192833,35323905,36831233]} \ No newline at end of file diff --git a/docs/fti/FTI_117.json b/docs/fti/FTI_117.json new file mode 100644 index 0000000..eac9dc2 --- /dev/null +++ b/docs/fti/FTI_117.json @@ -0,0 +1 @@ +{"unique":[8323074,14024706,17039362,33161218],"usual":[17235969,22806529,24444929],"unit":[196609,458753,589825,917506,1114113,1310721,1507329,2097153,2162689,2359298,2424833,2490369,2555905,2686977,2883585,2949122,3342337,3407873,3538945,3670017,3735553,3866625,3932161,3997697,4259841,4325377,4653058,4718593,4784129,4980738,5111809,5177345,5242881,5373953,5505025,5570561,5701633,6029313,6553601,6815745,6881281,7274497,7340033,7536641,7929857,7995393,8060929,8126465,8192001,8257537,8388609,8454145,8912897,9240577,9306113,9502721,9830401,9961473,10027009,10092545,10158081,10289153,10485761,11075585,11206657,11272193,11403265,11665409,11730945,12124161,12255233,12386305,12648449,12713985,12845057,12976129,13041665,13107201,13828097,13959169,14548993,14680066,14811137,15466497,15859713,16384001,16449537,16777217,16908289,17104898,17432578,17694721,17825793,18022401,18087937,18284545,18350081,18808833,19070977,19660801,19726337,19922946,19988481,20054018,20447233,20709377,20905985,21037057,21299201,21561345,21954561,22020097,22216706,22347777,22413313,22675457,22872065,23265281,23592961,23986177,24051713,24117249,21823489,24182785,24313857,24510465,24576001,24379393,25427969,25821185,25165825,25886721,26017793,26083329,24903681,25624578,26607617,26738689,25690113,25493505,26935297,25231361,27197441,27394049,27590657,27721729,27918337,28246017,28311553,28770305,28901378,29097985,29229057,29294593,29425665,29556737,29622273,29687809,29884417,30146561,30277633,30474241,30539777,30736385,30998529,31391745,31522817,31916033,32047105,32112641,32374785,32505857,32899073,33095681,33292289,33554433,33751041,33882113,33947649,34144258,34275329,34340865,34996225,35389441,35913730,36110338,36241409,36438017,36503553,36569089,36896770,36962305,37158913,37289985,37617665,37683202,37748737,37814273,37879809,37945345,38010881,38076417,38207489,38404097,38666241,38797313,38928385,38993921,39256065,39387137,39518209,39583745,39649281,39845889,40108033,40370177,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41287681,41353217],"uint16":[327682,720898,2752514,3604484,4063236,4194308,5308418,8585217,13434881,13565956,13631492,14614532,15204355,18481154,19202052,20840452,22937604,23068676,23461892,23789572,24248322,24772610,27787268,29491204,31326210,31653892,32309250,32768002,34013188,34537476,34734084,34799620,38731780],"updates":[5963777,8454145,15335425],"unconditionally":[33030145],"unmanaged":[196610,393218,458754,589825,851970,983042,1114114,1245186,1310722,1376258,1441796,1507330,1638401,1966082,2097154,2162690,2293762,2424834,2490370,2555906,2818050,2883586,3014658,3145730,3276802,3342338,3407874,3538946,3735554,3866626,3997698,4128770,4325378,4456449,4718594,4784130,4980738,5046274,5111810,5177346,5373953,5439490,5505026,5636098,5701634,5832706,5898242,6160386,6291457,6356994,6488066,6619138,6815746,7012354,7077890,7143426,7274498,7340034,7405570,7602178,7667716,7733250,7864321,7929858,7995394,8060930,8126465,8192002,8257538,8323074,8388610,8585221,8650754,8781826,8912898,8978434,9043970,9502722,9568258,9699330,9830402,9895938,9961474,10027010,10223618,10289154,10354690,10485762,10616834,10682370,11075586,11141121,11206658,11272194,11337730,11665410,11730946,11862018,11927554,12058626,12124162,12320770,12386306,12451842,12713986,12845058,12910594,12976130,13041666,13107202,13172738,13238274,13303810,13369346,13434886,13500418,13828098,13893634,13959170,14024706,14155778,14286850,14483458,14548994,14745602,14811138,15073281,15138818,15204354,15400961,15466498,15532034,15597570,15728642,15794180,15859714,15925250,16056322,16121858,16187394,16318468,16384002,16449538,16777218,16842753,16908290,17039362,17235970,17301506,17629186,17694722,17825794,17956866,18022402,18087938,18350082,18415618,18546691,18612226,18743298,18808834,18874370,18939906,19005442,19070978,19267585,19333122,19529730,19660802,19791874,20250626,20316162,20381698,20447234,20512770,20578306,20709378,20905986,20971522,21037058,21102594,21168130,21233666,21299202,21430273,21561346,21626882,21692418,21757956,21954562,22020098,22085634,22347778,22478850,22675458,22740994,22806530,23265282,23396354,23658498,23986178,24051714,21823490,24313858,24510466,24576002,24707074,24444930,24838146,24969218,25034754,25362434,25559042,25427970,24379394,25821186,25165826,25886722,26017794,26083330,24903682,26279938,26411010,26476546,26607618,26673154,26738690,25690114,26869762,26935298,27000834,25231362,27197442,27328514,27394050,27590658,27656194,27721730,27852802,28114946,28246018,28311554,28377090,28573698,28704770,28770306,28966914,29097986,29229058,29294594,29360134,29425666,29556738,29622274,29687810,29753346,30015490,30277634,30408706,30474242,30539778,30605314,30867458,30998530,31064066,31195138,31260674,31522818,31850498,31916034,32112642,32178178,32374786,32440322,32505858,32571394,32833538,32899074,32964610,27066370,33161218,33292290,33357826,33423362,33619970,33751042,33882114,33947650,34078722,34209794,34275330,34406403,34930690,34996226,35061762,35192834,35323906,35389442,35454978,35520513,35782659,35979266,36044802,36241410,36306946,36438018,36634626,36962306,37289986,37355522,37421058,37552130,37617666,37748738,37814274,37879810,37945346,38010882,38076418,38141954,38207490,38338566,38404098,38469634,38600706,38666242,38797314,38928386,38993922,39059458,39124994,39256066,39387138,39452673,39518210,39583746,39649282,39714818,39780354,39976961,40108034,40173570,40501250,40566786,40632322,40697858,40763394,40894466,41025538,41156610,41222146,41287682,41353218,41418754],"unpredictable":[40632321],"uniquely":[37289985],"unaffected":[24182785],"underflow":[18415617,35192833],"unsigned":[524290,983042,1310721,1376258,1638401,1966081,2293761,2555905,3342337,3604481,4063235,4194305,4849665,5046273,5439490,5570561,5767169,5963785,6488065,7077890,7929857,8126465,8388609,9568258,9895940,10551297,10616834,11206657,11272194,11534337,11665409,11862018,11927553,12713985,13107201,13565953,13762561,14614529,14811137,15204353,15335434,15532034,15663105,16449538,16515073,16646145,16973825,17301505,17563649,17760257,17825793,17891329,18153473,18612225,18808833,19005442,19202049,19333121,19398657,20381698,20447233,20643841,20774916,20840449,20971523,21037057,21364737,21561345,21626882,22085633,22151169,22675457,22937601,23461889,23592961,23855105,21823491,24313857,24969218,25296897,25427969,25821185,25886721,26017793,26083330,26542081,26804225,26869761,27590657,27721729,28180481,28704770,29032449,29229057,29425665,29556737,29622273,29687809,29884417,30081025,30605314,31653889,31981569,32440321,32964610,33488897,33882113,34340865,34799617,35258369,35454977,35651585,35979265,36372481,36634626,36831234,37027841,37224449,37421057,37552129,37879809,38273025,38600706,38731777,38862849,40239105,40435713,40566785,40894466,40960001,41156609,41418753],"upward":[28573697,40501249],"uint":[524291,983042,1114115,1310721,1376258,1507331,1638401,1966081,2097153,2162690,2293761,2555905,2883588,3014657,3276802,3342337,4325380,5046273,5111811,5439491,5570561,5898243,6488065,6815748,7012356,7077889,7405569,7929857,8126465,8388609,9043972,9568259,9699329,9895937,9961474,10616834,11206657,11272194,11665409,11862018,11927553,12713985,13107201,13238274,14286851,14745601,14811137,15073284,15532033,16056321,16121860,16187393,16449538,16646145,16777220,17301505,17563649,17629185,17825793,17891329,17956865,18022401,18350083,18612225,18743300,18808833,19005441,19333121,19398657,19529734,19791875,20316163,20381698,20447233,20774915,20905987,20971522,21037057,21561345,21626882,22085633,22675457,22740996,23592961,23658497,24313857,24969217,25034755,25362433,25427969,25559042,25821185,25886721,26017793,26083330,26279937,26411011,25231366,27590657,27656193,27721729,28573699,28704770,28966914,29097985,29229057,29294594,29425665,29556737,29622273,29687809,29884417,30015491,30605313,30998532,31195140,31981569,32374788,32440321,32964610,27066370,33357825,33751044,33882113,34209793,34275332,34340865,34996228,35258369,35454980,35651585,35979265,36044803,36634626,36831233,37027841,37224449,37421057,37879809,37945346,38141957,38273025,38469636,38600705,38666244,38862849,38993924,39059457,39714819,39780356,40501251,40566785,40697859,40894466,40960001,41156612,41222145,41418753],"uniform":[5963777,15335425,24117249],"usually":[7864321,21823489,34013185],"unless":[589825,1179649,2490369],"useful":[10420225,12648449,19791873,30146561,32178177,35717121,36044801,36503553],"unchanged":[5046273,40632321],"unmodified":[5963777,15335425,34996225],"used":[851969,1179649,1966081,2424833,4259843,5570562,5636097,5701633,5832706,5963777,7143425,8454145,8781825,9306113,9895937,10223617,10289153,11730945,12058625,12124161,12910593,14352385,15335425,15597569,15925251,16384001,17235969,18874371,20578305,22347777,22478851,22806529,23396353,21823489,24444929,26673153,27328515,28377089,29884419,32243713,32440321,34865153,35520513,38797313,39583745,39845891,39976963,40173569,40632321],"ushort":[3604482,4194306,13565954,14614530,15204354,15532034,19202050,20840450,22937602,23461890,34799618,38600706,38731778],"uinteger":[524291,983042,1114115,1310721,1376258,1507331,1638401,1966081,2097153,2162690,2293761,2555905,2883588,3014657,3276802,3342337,4325380,5046273,5111811,5439489,5570561,5898243,6488065,6815748,7012356,7077889,7405569,7929857,8126465,8388609,9043972,9568257,9699329,9895937,9961474,10616834,11206657,11272194,11665409,11862018,11927553,12713985,13107201,13238274,14286851,14745601,14811137,15532033,16056321,16121860,16187393,16449538,16646145,16777220,17301505,17563649,17629185,17825793,17891329,17956865,18022401,18350083,18612225,18743300,18808833,19005441,19333121,19398657,19529734,19791875,20316163,20381698,20447233,20774915,20905987,20971522,21037057,21561345,21626882,22085633,22675457,22740996,23592961,23658497,24313857,24969217,25034755,25362433,25427969,25559042,25821185,25886721,26017793,26083330,26279937,26411011,25231366,27590657,27656193,27721729,28573699,28704770,28966914,29097985,29229057,29294594,29425665,29556737,29622273,29687809,29884417,30015491,30605313,30998532,31195140,31981569,32374788,32440321,32964610,27066370,33357825,33751044,33882113,34209793,34275332,34340865,34996228,35258369,35454980,35651585,35979265,36044803,36634626,36831233,37027841,37224449,37421057,37879809,37945346,38141957,38273025,38469636,38600705,38666244,38862849,38993924,39059457,39714819,39780356,40501251,40566785,40697859,40894466,40960001,41156612,41222145,41418753],"uint32":[196610,327682,393218,524293,720900,851971,983045,1310722,1376263,1638403,1966084,2293765,2555910,2818051,3342341,3407875,3538945,3735553,3866625,3932163,4063236,4718594,4784129,5177345,5242882,5308418,5505026,5570562,5963777,6356994,6488067,7077893,7274497,7340033,7602178,7733250,7929861,7995393,8060930,8126469,8192004,8257537,8388613,8585217,9043969,9240578,9502721,9699330,9830401,9895938,10354690,10616836,10682371,11206658,11272197,11403266,11665411,11862023,11927556,12255233,12320769,12386308,12713987,12845060,13041665,13107202,13172737,13303809,13369345,13434881,13631492,13893634,14483457,14548994,14811138,15335425,15466500,15597571,16449542,16646148,17235969,17301506,17563652,17694721,17825797,17891330,18087939,18284546,18481156,18612226,18808834,19005445,19333125,19398660,19660804,20381703,20447234,20578307,20709380,20774917,20971524,21037058,21561346,21626887,21954564,22020097,22085637,22675459,22872065,23068676,23265281,23592963,23658498,23789572,23986179,24248324,24313858,24510467,24576004,24707074,24444929,24969221,25427971,24379393,25821189,25165825,25886722,26017795,26083333,24903681,26279938,26607620,25690113,25493505,26935300,27000835,27197444,27590661,27721733,27787268,27852802,28114945,28246017,28311555,28377091,28704775,28770308,28966914,29229058,29425669,29491204,29556742,29622276,29687813,29884418,30015489,30277633,30408706,30474243,30539777,30867457,31064065,31522817,31653892,31981572,32309250,32440324,32505859,32768002,32899074,32964615,33030145,33095682,33882115,33947652,34013188,34340867,34537476,34734084,34865154,34930689,35258372,35454979,35520515,35651588,36241412,36438020,36569090,36634631,36831234,37027844,37224452,37289985,37355522,37421058,37617666,37748737,37814276,37879812,38010881,38076417,38207492,38273028,38404099,38862852,38928385,39518209,39649284,39845889,40108033,40370177,40566788,40828930,40894470,40960002,41025537,41156611,41287681,41418755],"ultimately":[16908289],"uses":[21299201],"unspecified":[21168129],"using":[1835009,2490369,3670017,5963777,15335425,15925249,16187393,22413313,27328513,29097985,29425665,34996225,36306945,38404097,40173569],"usages":[40501249],"upper":[524289,15925250,17235970,18874370,22806530,24444930,27328514,39976962],"uniformly":[524289,2097153,5963780,15335428,18022401,19988481,20774913,30736385],"unpredictability":[29884417,39845889],"unused":[3080193,34471937,40173569],"user":[7929857,8126465,12845057],"uint64":[327684,720900,4063236,5767172,7077890,8585217,10551300,11534340,13434881,13631492,13762562,15663108,16973828,18481154,19005442,21364740,22151170,23068676,23789572,23855108,24248324,24772610,24969218,26804228,27787268,28180484,29491204,31653892,32768004,34013188,34537476,34734084,37552131,40239108],"uintsperlimb":[29032452],"undefined":[393217,589825,2490369,5111809,7929857,8126465,12845057,13172737,15073282,27852801,31850497,34471937,35061762,36831233],"unlike":[3276801,7733249,8781825,10616833,12320769,17301505,22478849,24444929,25559041,29360129,38338561],"ulong":[5767170,7077890,10551298,11534338,13762562,15663106,16187394,16973826,18743298,19005442,21364738,22151170,23855106,24969218,26804226,28180482,35979266,37552130,40239106]} \ No newline at end of file diff --git a/docs/fti/FTI_118.json b/docs/fti/FTI_118.json new file mode 100644 index 0000000..14cf30b --- /dev/null +++ b/docs/fti/FTI_118.json @@ -0,0 +1 @@ +{"variable":[2490369,5701633,9043969,12648449,15007745,19988481,24117249,29097985,30736385,38404097,40632321],"vsnprintf":[7667713,16318465],"vary":[5046273,15925249,17235969,18874369,22478849,22806529,27328513,27066369,34078721,35520513,36306945,39059457,39976961],"valid":[8454146,13303809,17235969,24444929,35520513],"value2":[8519685,10747909,11993093,14221317,19595269,23330821,27131909,27262981,27983877,28442629,28835845,29818885,29949957,30801925,31784965,33685509],"volume":[29425665],"vector":[21823489],"variables":[589826,5963782,8912897,13959169,15335430,24182785,25690113,28311553,30474241,32112642,32505857,35389442,36962305],"value1":[8519685,10747909,11993093,14221317,19595269,23330821,27131909,27262981,27983877,28442629,28835845,29818885,29949957,30801925,31784965,33685509],"void":[196610,589826,1114114,1310722,1507330,2097154,2162690,2424834,2490370,2555906,2883586,3342338,3407874,3538946,3670018,3735554,3866626,3932162,3997698,4325378,4718594,4784130,5111810,5177346,5242882,5505026,5570562,5701634,6815746,6881282,7274498,7340034,7536642,7929858,7995394,8060930,8126466,8192002,8257538,8388610,8454147,8912898,9240578,9306114,9502722,9830402,9961474,10027010,10158082,10289154,11206658,11272194,11403266,11665410,11730946,12124162,12189697,12255234,12386306,12648450,12713986,12845058,12976130,13041666,13107202,13828098,13959170,14548994,14811138,15466498,15859714,16187393,16384002,16449538,16777218,16908290,17694722,17825794,18022402,18087938,18284546,18350082,18808834,19070978,19660802,19726338,19988482,20447234,20709378,20905986,21037058,21299202,21561346,21823490,21954562,22020098,22347778,22675458,22872066,23265282,23592962,23986178,24051714,24117250,24182786,24313858,24576002,24510466,24379394,24903682,25165826,25231362,25427970,25493506,25690114,25821186,25886722,26017794,26083330,26607618,26738690,26935298,27197442,27394050,27590658,27721730,28246018,28311554,28770306,29097986,29163521,29229058,29294594,29425666,29556738,29622274,29687810,29884418,30146562,30277634,30474242,30539778,30736386,30998530,31391746,31522818,32047106,32112642,32374786,32505858,32899074,33095682,33554434,33751042,33882114,33947650,34275330,34340866,34996226,35389442,36241410,36438018,36503554,36569090,36962306,37158914,37289986,37617666,37748738,37814274,37879810,37945346,38010882,38076418,38207490,38404098,38666242,38797314,38928386,38993922,39256066,39387138,39518210,39583746,39649282,39845890,40108034,40370178,40566786,40632322,40697858,40763394,40828930,40894466,40960002,41025538,41287682,41353218],"values":[393217,589825,1179649,1376258,1441794,1638401,2293762,2555907,3407877,4063234,4456450,5701634,5963785,7012353,8192002,8323076,8519682,8585220,8781825,10354689,10747906,11862018,11993090,12910593,13434885,13500418,13631490,13697026,14024708,14155777,14221314,15204359,15335433,16252930,16908289,17235970,19005442,19595265,20381698,20709378,21168130,21692420,22609922,23068674,23265285,23330818,23789570,24444929,26017794,25690115,26869767,27131906,27262978,27787266,27983874,28311553,28442626,28835842,28966913,29425665,29491202,29556739,29818882,29949954,30408705,30801922,30867458,31195137,31653890,31784962,32112641,32833540,32964610,33685506,33947650,34013186,34406401,34537474,34734082,35520513,35782658,37289987,37552136,37617666,39256066,40632321,41091073,41418759],"vasprintf":[29360129],"visual":[22413313],"various":[40632321],"version":[196609,262145,393217,458753,524289,589825,655361,786433,851969,917505,983041,1114113,1179649,1245185,1310721,1376257,1441793,1507329,1572865,1638401,1835009,1966081,2031617,2097153,2162689,2228225,2293761,2359297,2424833,2490369,2555905,2686977,2818049,2883585,2949121,3014657,3080193,3145729,3211265,3276801,3342337,3407873,3538945,3604481,3670017,3735553,3866625,3932161,3997697,4063233,4128769,4194305,4259841,4325377,4456449,4521985,4587521,4653057,4718593,4784129,4849665,4980737,5046273,5111809,5177345,5242881,5373953,5439489,5505025,5570561,5636097,5701633,5767169,5832705,5898241,6029313,6160385,6225921,6356993,6488065,6553601,6619137,6684673,6750209,6815745,6881281,7012353,7077889,7143425,7208961,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7798785,7864321,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8519681,8650753,8716289,8781825,8847361,8912897,8978433,9043969,9175041,9240577,9306113,9371649,9437185,9502721,9568257,9633793,9699329,9764865,9830401,9895937,9961473,10027009,10092545,10158081,10223617,10289153,10354689,10420230,10485761,10551297,10616833,10682369,10747905,10813441,10878977,10944513,11010049,11075585,11206657,11272193,11337729,11403265,11468801,11534337,11665409,11730945,11796481,11862017,11927553,11993089,12058625,12124161,12189697,12255233,12320769,12386305,12451841,12582913,12648449,12713985,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13434881,13500417,13565953,13631489,13762561,13828097,13893633,13959169,14024705,14155777,14221313,14286849,14352385,14417921,14483457,14548993,14614529,14680065,14745601,14811137,14942209,15007745,15073281,15138817,15204353,15269889,15335426,15466497,15532033,15597569,15663105,15728641,15794177,15859713,15925249,15990785,16056321,16121857,16187393,16318465,16384001,16449537,16515073,16580609,16646145,16711681,16777217,16842753,16908289,16973825,17039361,17104897,17170433,17235969,17301505,17367041,17432577,17498113,17563649,17629185,17694721,17760257,17825793,17891329,17956865,18022401,18087937,18153473,18219009,18284545,18350081,18415617,18546689,18612225,18743297,18808833,18874369,19005441,19070977,19136513,19202049,19333121,19398657,19464193,19529729,19595265,19660801,19726337,19791873,19857409,19922945,19988481,20054017,20119553,20185089,20250625,20316161,20381697,20447233,20512769,20578305,20643841,20709377,20774913,20840449,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21364737,21430273,21495809,21561345,21626881,21692417,21757953,21823489,21954561,22020097,22085633,22151169,22216705,22282241,22347777,22413313,22478849,22544385,22675457,22740993,22806529,22872065,22937601,23003137,23134209,23265281,23330817,23396353,23461889,23592961,23658497,23724033,23855105,23920641,23986177,24051713,24117249,24182785,24313857,24444929,24510465,24576001,24707073,24379393,24838145,24903681,24969217,25034753,25100289,25165825,25231361,25296897,25362433,25427969,25493505,25559041,25624577,25690113,25755649,25821185,25886721,25952257,26017793,26083329,26148865,26214401,26279937,26411009,26476545,26542081,26607617,26673153,26738689,26804225,26869761,26935297,27000833,27066369,27131905,27197441,27262977,27328513,27394049,27459585,27525121,27590657,27656193,27721729,27852801,27918337,27983873,28049409,28114945,28180481,28246017,28311553,28377089,28442625,28508161,28573697,28639233,28704769,28770305,28835841,28901377,28966913,29032449,29097985,29163521,29229057,29294593,29360129,29425665,29556737,29622273,29687809,29753345,29818881,29884417,29949953,30015489,30081025,30146561,30212097,30277633,30343169,30408705,30474241,30539777,30605313,30670849,30736385,30801921,30867457,30998529,31064065,31129601,31195137,31260673,31391745,31457281,31522817,31653889,31784961,31850497,31916033,31981569,32047105,32112641,32178177,32243713,32374785,32440321,32505857,32636929,32702465,32833537,32899073,32964609,33030145,33095681,33161217,33226753,33292289,33357825,33423361,33488897,33554433,33619969,33685505,33751041,33816577,33882113,33947649,34013185,34078721,34144257,34209793,34275329,34340865,34471937,34537473,34603009,34668545,34799617,34865153,34930689,34996225,35061761,35192833,35258369,35323905,35389441,35454977,35520513,35651585,35717121,35782657,35848193,35913729,35979265,36044801,36110337,36175873,36241409,36306945,36372481,36438017,36503553,36569089,36634625,36700161,36765697,36831233,36896769,36962305,37027841,37093377,37158913,37224449,37289985,37355521,37421057,37486593,37552129,37617665,37683201,37748737,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38273025,38338561,38404097,38469633,38535169,38600705,38666241,38731777,38797313,38862849,38928385,38993921,39059457,39124993,39190529,39256065,39321601,39387137,39452673,39518209,39583745,39649281,39714817,39780353,39845889,39976961,40108033,40173569,40239105,40304641,40370177,40435713,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41091073,41156609,41222145,41287681,41353217,41418753],"value":[131075,196610,262153,327690,393221,458753,524289,589825,655363,720914,786441,851971,917505,983045,1048579,1179657,1245195,1310723,1376261,1441798,1572873,1638404,1703939,1769475,1835010,1900547,1966083,2031617,2228233,2293765,2359297,2424838,2490370,2752526,2818049,2949121,3014659,3080193,3145729,3211265,3276801,3342338,3538948,3604489,3735555,3801091,3866626,3997701,4063271,4128777,4194313,4259844,4390914,4456455,4521985,4587521,4653057,4718596,4784131,4849673,4915203,4980737,5046273,5111809,5177349,5242881,5308438,5439491,5505026,5636099,5701645,5767177,5832716,5898242,5963820,6094851,6160385,6225929,6356995,6422530,6488069,6619145,6684681,6750217,6946819,7012354,7077893,7143427,7208969,7274501,7340038,7405569,7471105,7536642,7602181,7667715,7733255,7798789,7864323,7929858,7995398,8060930,8126465,8192004,8257541,8323089,8388610,8454145,8519684,8650757,8716297,8781833,8847369,8912898,8978443,9043969,9109506,9175043,9371657,9437193,9502725,9568261,9633801,9699329,9764867,9830402,9895944,10027010,10223619,10289158,10354695,10420225,10485761,10551305,10616835,10682375,10747908,10813441,10878985,10944521,11010049,11075585,11206660,11272194,11337747,11468807,11534345,11599873,11665410,11730947,11796489,11862019,11927557,11993092,12058627,12124162,12189698,12320773,12386310,12451841,12582921,12648450,12713986,12779523,12845058,12910598,12976130,13041670,13107204,13172739,13238275,13303816,13369347,13434881,13500429,13565961,13631527,13697026,13762567,13828100,13893637,13959170,14024721,14090242,14155780,14221316,14286849,14352393,14417921,14483459,14548998,14614537,14680065,14745603,14811140,14942217,15007754,15073282,15138819,15269889,15335468,15466502,15532037,15597573,15663113,15728641,15794177,15859716,15925255,15990793,16056321,16121857,16187395,16252930,16318467,16384004,16449538,16515081,16580617,16646153,16711689,16842754,16908291,16973833,17039369,17104897,17170441,17235983,17301507,17367049,17432577,17498121,17563657,17629187,17694726,17760265,17825794,17891335,17956865,18087938,18153481,18219017,18415619,18481164,18546694,18612227,18677763,18743298,18808834,18874379,18939907,19005445,19070980,19136515,19202057,19267585,19333125,19398665,19464193,19529734,19595268,19660804,19791877,19857411,19922945,19988482,20054017,20119553,20185091,20250638,20316161,20381699,20447237,20512769,20578309,20643849,20709380,20774913,20840457,20971523,21037061,21102597,21168132,21233672,21299204,21364745,21430274,21495817,21561347,21626886,21692425,21757953,21889027,21954566,22020101,22085637,22151175,22216705,22347778,22478854,22544393,22609922,22675460,22740993,22806538,22937609,23003145,23068706,23134209,23330820,23396356,23461897,23527425,23658497,23724033,23789602,23855113,23920649,23986180,24051714,24117254,21823503,24182786,24248338,24313858,24444937,24772628,24510468,24576008,24641539,24707075,24838147,24903685,24969221,25034753,25100297,25165829,25296905,25362433,25559041,25755649,24379398,25427970,25821186,25886722,25952257,26017794,26083333,26148865,26214409,26279937,25624577,26411009,26476556,26542089,26607624,26673155,26738693,25690116,26804233,26935300,27000839,27131908,27197444,27262980,27328523,27394050,27459591,27525128,27590660,27656197,27721732,27787298,27852805,27918337,27983876,28049413,28114947,28180489,28246017,28311554,28377091,28442628,28508165,28573697,28639237,28704773,28770310,28835844,28901377,28966913,29032449,29097986,29163523,29229060,29360134,29491234,29425668,29622277,29687810,29753349,29818884,29884418,29949956,30015489,30081033,30146562,30212103,30277633,30343171,30408707,30474242,30539779,30605315,30670853,30736386,30801924,30867470,31064067,31129609,31195138,31260680,31326222,31457289,31522822,31653927,31719427,31784964,31850499,31916033,31981577,32112642,32178185,32243721,32309270,32440323,32505858,32571395,32636931,32702465,32768010,32833545,32899074,32964611,33030148,27066372,33161225,33226761,33292289,33357829,33423363,33488905,33685508,33816581,33882116,33947652,34013223,34078731,34144257,34209793,34406401,34471938,34537511,34668545,34734114,34799625,34865155,34930691,34996226,35061771,35192837,35258377,35323911,35389442,35454979,35520520,35586051,35651593,35717121,35782662,35848197,35913729,35979269,36044805,36110337,36175881,36241412,36306951,36372489,36438022,36503554,36634629,36700161,36765705,36831233,36896769,36962306,37027849,37093377,37224457,37289990,37355527,37421061,37486601,37617666,37683201,37748738,37814276,37879810,38010886,38076422,38141956,38207494,38273033,38338566,38404100,38469633,38535177,38600707,38731785,38797318,38862857,38928387,39059457,39124995,39190537,39256077,39321605,39387141,39452678,39518211,39583746,39649284,39714817,39780353,39845890,39976966,40108037,40173581,40239113,40304649,40501249,40566786,40632324,40763397,40894466,41025540,41091075,41156611,41222149,41287685,41353218],"valuetype":[131075,1048577,1441795,1703939,1769473,1900547,4063235,4456451,4915203,6094849,6946817,12779521,13631491,18677761,18939907,21889027,24641539,31653891,31719425,32571395,34013187,34537475,35586049,35782659],"virtual":[655361,917505,2359297,2949121,3080193,3211266,4653057,4980737,9175041,9764865,14680065,17104897,17432577,19136513,19857409,19922945,20054017,20185089,22216705,25624577,28901377,30343169,32636929,33030146,34144257,34471937,35913729,36110337,36896769,37683201],"val":[10420225,11010049,11468801,14417921,20119553,29032449,35717121,39452673],"void_ptr":[655363,917506,1048580,1835019,3473412,3670023,5963778,6881285,7471111,9306118,10158082,10485762,10747918,11010056,15335426,16252931,18546697,19726337,21823496,26345474,29818894,30670858,31391745,32047111,32571398,32702469,34406401,35782666,37093386,37158913,40173581]} \ No newline at end of file diff --git a/docs/fti/FTI_119.json b/docs/fti/FTI_119.json new file mode 100644 index 0000000..a6ece58 --- /dev/null +++ b/docs/fti/FTI_119.json @@ -0,0 +1 @@ +{"way":[16908289,39256065,40632321,41091074],"write":[1245186,2883585,4325377,5963804,6815745,7667713,8323074,8781826,8978434,9043969,11337730,14024706,14286849,15335452,16121857,16318465,16777217,18350081,18874370,20316161,21168130,21233666,22740993,22806530,25034753,26411009,28573697,30015489,30998529,32374785,33751041,34078722,35454977,38469633,38666241,38993921,39714817,39780353,39976962,40501249,40697857,41156609],"word":[5963778,15335426,21823498,34537474,40173580],"widening":[262145,1179649,3604481,6684673,8847361,9371649,10551297,12582913,13565953,14352385,14614529,15663105,16580609,16646145,17760257,20643841,20840449,21364737,21495809,22544385,23461889,23855105,25100289,26214401,26542081,32243713,33488897,35651585,36175873,36372481,37224449,38862849,40239105],"want":[24444929],"won":[19791873,27328513,36044801],"writing":[1245186,5111809,5963779,8454145,15335427,18874370,19791873,34078722,36044801,39976961],"welcome":[22413313],"white":[5963777,8978435,15335425,17235969,22806529,24444931,35520513],"wanted":[2555905,21626881,29556737,33030145,38141953],"written":[1245189,5111809,5963777,7667713,9043969,11337729,15335425,15728641,15794177,16318465,17039361,18874371,20316161,20512769,21757953,22740993,25034753,27328513,28573697,30015489,33161217,34078723,35454977,39976962,40173571,40501250,40632321,41156609],"writealltext":[8323074,8781826,8978434,14024706,22806530],"words":[15204353,21823493,40173573,41418753]} \ No newline at end of file diff --git a/docs/fti/FTI_120.json b/docs/fti/FTI_120.json new file mode 100644 index 0000000..e8feac3 --- /dev/null +++ b/docs/fti/FTI_120.json @@ -0,0 +1 @@ +{"xor":[2883586,6815746],"x64":[13500418,21168130,21233666,22413313],"x86":[13500418,21168130,21233666,22413313],"xxxxxxxxxxxxxxxxx":[5046274,27066370]} \ No newline at end of file diff --git a/docs/fti/FTI_121.json b/docs/fti/FTI_121.json new file mode 100644 index 0000000..775d0c1 --- /dev/null +++ b/docs/fti/FTI_121.json @@ -0,0 +1 @@ +{"ylimb":[5963777,15335425,17956871],"yields":[5963778,15335426,16449537,27590657]} \ No newline at end of file diff --git a/docs/fti/FTI_122.json b/docs/fti/FTI_122.json new file mode 100644 index 0000000..898d2f3 --- /dev/null +++ b/docs/fti/FTI_122.json @@ -0,0 +1 @@ +{"zero":[393217,983041,1441793,1638401,2097153,2162689,3014658,3080194,3145730,3473409,5046273,5439490,5701634,5832706,5898241,5963823,6356994,6488065,7012362,7405570,7602177,7733250,7929859,8126467,9240578,9568260,9961473,10027009,10354689,10616834,10682369,11010053,11927553,12320770,12845059,13041665,13172737,13369346,13893634,14483457,14745602,15073281,15138818,15335471,15532036,15925252,16056322,16121857,16187394,17235970,17301506,17629186,17956865,18022401,18415617,18612225,18743297,19464193,19529729,19791874,20119557,20250627,20578308,20971521,21102594,21168130,21233666,22478849,21823490,25362435,26411009,26476546,26607617,27000833,25231362,27328515,27656196,27721729,27852801,28114945,28573697,29163521,29294593,30408706,30605314,30867458,31195146,33030148,27066371,33357828,33423362,34209793,34471939,34865154,34930689,34996227,35061766,35192833,35323906,35454977,35520513,35782657,35979268,36044802,36306946,37289986,37355521,37421057,37617665,38076418,38141958,38404098,38600706,38666241,39256066,39387138,39911425,40173574,40501250,40697857,40960002,41091074,41156609,41222148],"zeros":[2097153,5046273,5963780,12648449,15335428,18022401,27328513,30146561,33554435,36503553],"zeroes":[15204353,26869761,41418753],"zeromemory":[5963778,15335426,33554438]} \ No newline at end of file diff --git a/docs/fti/FTI_95.json b/docs/fti/FTI_95.json new file mode 100644 index 0000000..cd109c2 --- /dev/null +++ b/docs/fti/FTI_95.json @@ -0,0 +1 @@ +{"_mpz_realloc":[5832705,5963777,8454145,13500417,15335425,16187393,21168129,21233665,26476545,39256075],"_ptr":[15007745],"_mp_size":[3080199,3211270,7864322,11599874,14876674,21430274,22282241,23724034,30932993,33030148,34471943,41091073],"_mp_den":[2621441,16842753,34668549],"_mp_num":[2621441,10813445,16842753],"_mp_d":[3080193,7864321,11599873,14876674,21430274,22282241,23724034,30932993,33030156,34471937,41091073],"_wfopen_s":[1245186,8323074,8781826,8978434,11337732,14024706,17039362,18874370,22806530,33161218,34078722,39976961],"_mp_alloc":[14876673,21430273,23724040],"_mp_prec":[7864321,11599873,19464198,33030145],"_mp_exp":[7864321,11599873,34471938,41091077]} \ No newline at end of file diff --git a/docs/fti/FTI_97.json b/docs/fti/FTI_97.json new file mode 100644 index 0000000..461a8b8 --- /dev/null +++ b/docs/fti/FTI_97.json @@ -0,0 +1 @@ +{"allows":[6291457,7864321,11141121,13434881,15007745,15400961,16842753,21430273,22282241,23199745,31588353,34603009,35127297,40042497],"alignment":[21823489,40173569],"applications":[25493505,29884417,39845889],"avoids":[40173569],"accepted":[7733249,10616833,12320769,17301505,30408705],"anycpu":[22413313],"applicable":[27328513],"assumed":[1179649],"array":[589825,4128769,5046274,5963782,6619137,7667713,7864321,8323073,8454146,8585221,11599873,13434887,13500419,14024705,14876673,15204355,15335430,15728641,15794177,16187395,16318465,17039361,19726337,20512769,21168132,21233668,21430273,21692417,21757953,21823490,22282241,26869763,28311553,29360129,30474241,30932993,32112641,32833537,33030147,33161217,33619970,34406401,35127297,35389441,36110338,36962305,37552131,38338561,40173569,41418755],"algorithm":[2555905,5570567,5963781,12255235,15335429,17825793,21299201,25493507,25821185,29556737,29884418,34865155,39124994,39845890,40370180],"according":[38141953],"abstract":[655361,917505,2359297,2949121,3080193,3211265,4653057,4980737,9175041,9764865,14680065,15335425,17104897,17432577,19136513,19857409,19922945,20054017,20185089,22216705,25624577,28901377,30343169,32636929,33030145,34144257,34471937,35913729,36110337,36896769,37683201],"attacks":[24576001],"automatic":[5701633],"alloc_size":[5963777,7471111,9306116,15335425,32702471,34406401],"alternatively":[8781825,24444929],"alloc_func_ptr":[9306117,10158085],"affects":[29884417,39845889],"assumes":[21823489],"access":[5963778,7012353,13500417,15335426,21168130,21233666,24576001,31195137],"ascii":[5046276,27066371],"accordingly":[5636098,5963777,15335425],"abstractclassattribute":[15335425],"accurate":[27328513,39976961],"allowing":[22413313],"areequal":[10420226,14417922,29032450,35717122],"able":[27328513],"applying":[7143425,12976129,13828097,15859713,26673153,27394049],"args":[15728645,16318469,21757957,33161221,38338565],"accurately":[27328513,39976961],"active":[3735553,13303809,21561345,30539777,38928385],"accesses":[34996225],"assign":[5963778,8257538,9502722,15335426,16187394,23986179,24510467,40763394],"architecture":[13500418,21168130,21233666,22413313],"allocation":[1835009,3670017,5963780,7471105,9306124,10158086,15335428,15925249,22478849,27328514,29360130,36306946,38338562,39256065,40173570],"andalso":[1245190,10158082],"addend1":[5963777,15335425,40828934],"arrays":[15007745],"actually":[4259842,5570561,5963777,15335425,40173569],"allowed":[983041,1114113,2162689,11927553,17235969,18743297,20316161,21823489,24444929,25034753,30015489,34275329,35520513,37945345,40173569],"actual":[2424833,5636097,5898241,7012353,7667713,10223617,10289153,12058625,12124161,12910593,16318465,16384001,22347777,23396353,31195137,38797313,39583745],"additional":[19529729],"apply":[21823489],"addition":[5963777,7012353,9043971,15335425,20316161,31195137,37289985,40501249],"advance":[5963778,7340033,11206657,15335426,16908289],"area":[5046273,5963778,7012354,15335426,19529730,23658497,26279937,31195138,27066369],"aim":[19464193],"avoid":[5701633,9961473,16908289],"allocate_function":[9306124,10158088,32702469,34406401],"accomplish":[39256065],"adequate":[21299201],"areas":[5111809,5963778,7012353,15335426,19529731,28573697,31195137,34996226,38141954,40501249],"assert":[196612,393220,589828,851972,983044,1114116,1245192,1310724,1376262,1507332,1638402,1966084,2162692,2293766,2424836,2490372,2555910,2818052,2883588,3014660,3145732,3276806,3342340,3407878,3538948,3735556,3866628,3997700,4128782,4259844,4325380,4718596,4784132,5046276,5111812,5177348,5439492,5505028,5636100,5701640,5832716,5898246,6356996,6488068,6619150,6815748,7012358,7077892,7143428,7274500,7340036,7405572,7602180,7667716,7733252,7929860,7995396,8060932,8126466,8192006,8257540,8323088,8388612,8650756,8781832,8912900,8978440,9043974,9306120,9502724,9568260,9699332,9830404,9895940,9961476,10027012,10158082,10223620,10289156,10354692,10420226,10616836,10682372,11206660,11272196,11337738,11665412,11730950,11862024,11927556,12058628,12124164,12320772,12386308,12451844,12713988,12845060,12910596,12976134,13041668,13107204,13172740,13238276,13303812,13369346,13500422,13828100,13893636,13959172,14024720,14155780,14286854,14417922,14483460,14548996,14745604,14811140,15073282,15138822,15466500,15532036,15597572,15728642,15794180,15859716,15925252,16056324,16121860,16187396,16318468,16384004,16449540,16777220,16908292,17039364,17235972,17301508,17629188,17694724,17825796,17956868,18087940,18350084,18415620,18612228,18743304,18808836,18874376,19005446,19070980,19333126,19529738,19660804,19791878,20250630,20316166,20381704,20447236,20512770,20578308,20709382,20905988,20971522,21037060,21102596,21168132,21233668,21299204,21561348,21626886,21692432,21757956,21954564,22020100,22085636,22347780,22478858,22675460,22740998,22806536,23265286,23396356,23658500,23986180,24051716,21823492,24182788,24313860,24510468,24576004,24707076,24444932,24838150,24969222,25034758,25362436,25559046,25427972,24379396,25821188,25165828,25886724,26017798,26083332,24903684,26279940,26411014,26476550,26607620,26673156,26738692,25690120,26935300,27000836,25231366,27197444,27328518,27394054,27590660,27656196,27721732,27852804,28114948,28246020,28311560,28377092,28573702,28704774,28770308,28966916,29032450,29097990,29229060,29294596,29360132,29425668,29556742,29622276,29687812,29753348,30015494,30277636,30408708,30474248,30539780,30605316,30867460,30998532,31064068,31195142,31260678,31522820,31850500,32112648,32178180,32374788,32440324,32505860,32833552,32899076,32964616,27066374,33161220,33357828,33423366,33751044,33882116,33947654,34078728,34209796,34275332,34930692,34996230,35061764,35192836,35323910,35389448,35454982,35520514,35717122,35979268,36044806,36241412,36306948,36438020,36634628,36962312,37289992,37355524,37421060,37617670,37748740,37814276,37879812,37945348,38010884,38076420,38141960,38207492,38338564,38404100,38469638,38600708,38666244,38797316,38928388,38993924,39059460,39124996,39256072,39387140,39518212,39583748,39649284,39714822,39780358,39976964,40108036,40173594,40501254,40566788,40632324,40697860,40763396,40894468,41025540,41156614,41222148,41287684,41353220],"a1p":[34996230],"addend2":[5963777,15335425,40828934],"absolute":[393217,1638401,5242881,5832705,5963782,8454145,9895937,10354689,13500418,15335430,21233665,22478849,26738689,33030145,35323906,40173569],"appended":[7667713,16318465],"argument":[1441794,4063234,4456450,8519681,8781825,9306113,10747905,11993089,13631490,13697026,14221313,15925249,16252930,18874369,19595265,20971521,22609922,23068674,23330817,23789570,24444929,27131905,27262977,27328513,27787266,27983873,28442625,28835841,29491202,29818881,29949953,30801921,31653890,31784961,33685505,34013186,34537474,34734082,35782658],"abs":[23724033,33030146],"analogous":[34537473],"allocating":[40173569],"accept":[7536641,7864321,12648449,24117249,24444929,30146561,30736385,34013185],"automatically":[1,5701633,16908290,22413314],"address":[15007746,21823489,29360129,38338561,40173569],"account":[21823489],"assigning":[1310721,4784129,5177345,8257537,9502721,17235969,20447233,22020097,23265281,24444929,24903681,25690113,28246017,30277633,35520513,39518209,41287681],"average":[3276801,25559041],"assignment":[3735553,7274497,13303810,21037057,21561345,25165825,30539777,30867457,38928385,40108033],"allocated":[196610,393218,589825,851970,983042,1245186,1310722,1376258,1638401,1835014,1966082,2293762,2424834,2490370,2555906,2818050,3014658,3145730,3342338,3407874,3538946,3670018,3735554,3866626,3997698,4718594,4784130,5177346,5439490,5505026,5636098,5701635,5832706,5963780,6356994,6488066,6881282,7077890,7143426,7274498,7340034,7471106,7602178,7733250,7929858,7995394,8060930,8126465,8192002,8257538,8388610,8650754,8781826,8912898,8978434,9502722,9568258,9830402,9895938,10027010,10223618,10289154,10354690,10616834,10682370,11206658,11272194,11337730,11665410,11730946,11862018,11927554,12058626,12124162,12320770,12386306,12451842,12713986,12845058,12910594,12976130,13041666,13107202,13172738,13303810,13369346,13500418,13828098,13893634,13959170,14155778,14483458,14548994,14745602,14811138,14876673,15138818,15335428,15466498,15532034,15597570,15859714,15925252,16187394,16384002,16449538,16908290,17235970,17301506,17629186,17694722,17825794,18087938,18415618,18612226,18808834,18874370,19005442,19070978,19333122,19660802,19726337,20250626,20381698,20447234,20578306,20709378,20971522,21037058,21102594,21168130,21233666,21299202,21430273,21561346,21626882,21954562,22020098,22085634,22347778,22478850,22675458,22806530,23265282,23396354,23724034,23986178,24051714,21823490,24313858,24510466,24576002,24707074,24444930,24838146,24969218,25427970,24379394,25821186,25165826,25886722,26017794,26083330,24903682,26476546,26607618,26673154,26738690,25690114,26935298,27000834,27197442,27328516,27394050,27590658,27656194,27721730,27852802,28114946,28246018,28311554,28377090,28704770,28770306,29097986,29229058,29360130,29425666,29556738,29622274,29687810,29753346,30277634,30408706,30474242,30539778,30605314,30867458,31064066,31260674,31391745,31522818,31850498,32047105,32112642,32178178,32440322,32505858,32702466,32899074,32964610,33030146,33357826,33423362,33882114,33947650,34078722,34406402,34930690,35061762,35192834,35323906,35389442,35520513,35979266,36241410,36306948,36438018,36634626,36962306,37093381,37158913,37289986,37355522,37421058,37617666,37748738,37814274,37879810,38010882,38076418,38207490,38338563,38404098,38600706,38797314,38928386,39124994,39256066,39387138,39518210,39583746,39649282,39976961,40108034,40173574,40566786,40632326,40763394,40894466,41025538,41222146,41287682,41353218],"algorithms":[5963777,12648449,15335425,30146561,36503553,39124993],"allocates":[16908289],"abcd":[5832706,26476546],"arguments":[4128769,5963778,6619137,7667713,8323073,9306113,10158081,14024705,15335426,15728641,15794177,16318465,17039361,20512769,21692417,21757953,24576002,25231361,29360129,32833537,33161217,38338561],"asprintf":[38338561],"assembly":[196609,262145,393217,458753,524289,589825,655361,786433,851969,917505,983041,1114113,1179649,1245185,1310721,1376257,1441793,1507329,1572865,1638401,1835009,1966081,2031617,2097153,2162689,2228225,2293761,2359297,2424833,2490369,2555905,2686977,2818049,2883585,2949121,3014657,3080193,3145729,3211265,3276801,3342337,3407873,3538945,3604481,3670017,3735553,3866625,3932161,3997697,4063233,4128769,4194305,4259841,4325377,4456449,4521985,4587521,4653057,4718593,4784129,4849665,4980737,5046273,5111809,5177345,5242881,5373953,5439489,5505025,5570561,5636097,5701633,5767169,5832705,5898241,6029313,6160385,6225921,6356993,6488065,6553601,6619137,6684673,6750209,6815745,6881281,7012353,7077889,7143425,7208961,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7798785,7864321,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8519681,8650753,8716289,8781825,8847361,8912897,8978433,9043970,9175041,9240577,9306113,9371649,9437185,9502721,9568257,9633793,9699329,9764865,9830401,9895937,9961473,10027009,10092545,10158081,10223617,10289153,10354689,10420225,10485761,10551297,10616833,10682369,10747905,10813441,10878977,10944513,11010049,11075585,11206657,11272193,11337729,11403265,11468801,11534337,11665409,11730945,11796481,11862017,11927553,11993089,12058625,12124161,12189697,12255233,12320769,12386305,12451841,12582913,12648449,12713985,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13434881,13500417,13565953,13631489,13762561,13828097,13893633,13959169,14024705,14155777,14221313,14286849,14352385,14417921,14483457,14548993,14614529,14680065,14745601,14811137,14942209,15007745,15073281,15138817,15204353,15269889,15335425,15466497,15532033,15597569,15663105,15728641,15794177,15859713,15925249,15990785,16056321,16121857,16187393,16318465,16384001,16449537,16515073,16580609,16646145,16711681,16777217,16842753,16908289,16973825,17039361,17104897,17170433,17235969,17301505,17367041,17432577,17498113,17563649,17629185,17694721,17760257,17825793,17891329,17956865,18022401,18087937,18153473,18219009,18284545,18350081,18415617,18546689,18612225,18743297,18808833,18874369,19005441,19070977,19136513,19202049,19333121,19398657,19464193,19529729,19595265,19660801,19726337,19791873,19857409,19922945,19988481,20054017,20119553,20185089,20250625,20316162,20381697,20447233,20512769,20578305,20643841,20709377,20774913,20840449,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21364737,21430273,21495809,21561345,21626881,21692417,21757953,21823489,21954561,22020097,22085633,22151169,22216705,22282241,22347777,22413313,22478849,22544385,22675457,22740994,22806529,22872065,22937601,23003137,23134209,23265281,23330817,23396353,23461889,23592961,23658497,23724033,23855105,23920641,23986177,24051713,24117249,24182785,24313857,24510465,24444929,24576001,24707073,24379393,24838145,24903681,24969217,25034754,25100289,25165825,25231361,25296897,25362433,25427969,25493505,25559041,25624577,25690113,25755649,25821185,25886721,25952257,26017793,26083329,26148865,26214401,26279937,26411009,26476545,26542081,26607617,26673153,26738689,26804225,26869761,26935297,27000833,27066369,27131905,27197441,27262977,27328513,27394049,27459585,27525121,27590657,27656193,27721729,27852801,27918337,27983873,28049409,28114945,28180481,28246017,28311553,28377089,28442625,28508161,28573697,28639233,28704769,28770305,28835841,28901377,28966913,29032449,29097985,29163521,29229057,29294593,29360129,29425665,29556737,29622273,29687809,29753345,29818881,29884417,29949953,30015490,30081025,30146561,30212097,30277633,30343169,30408705,30474241,30539777,30605313,30670849,30736385,30801921,30867457,30998529,31064065,31129601,31195137,31260673,31391745,31457281,31522817,31653889,31784961,31850497,31916033,31981569,32047105,32112641,32178177,32243713,32374785,32440321,32505857,32636929,32702465,32833537,32899073,32964609,33030145,33095681,33161217,33226753,33292289,33357825,33423361,33488897,33554433,33619969,33685505,33751041,33816577,33882113,33947649,34013185,34078721,34144257,34209793,34275329,34340865,34471937,34537473,34603009,34668545,34799617,34865153,34930689,34996225,35061761,35192833,35258369,35323905,35389441,35454978,35520513,35651585,35717121,35782657,35848193,35913729,35979265,36044801,36110337,36175873,36241409,36306945,36372481,36438017,36503553,36569089,36634625,36700161,36765697,36831233,36896769,36962305,37027841,37093377,37158913,37224449,37289985,37355521,37421057,37486593,37552129,37617665,37683201,37748737,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38273025,38338561,38404097,38469633,38535169,38600705,38666241,38731777,38797313,38862849,38928385,38993921,39059457,39124993,39190529,39256065,39321601,39387137,39452673,39518209,39583745,39649281,39714817,39780353,39845889,39976961,40108033,40173569,40239105,40304641,40370177,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41091073,41156610,41222145,41287681,41353217,41418753],"application":[21823489,27328513,29884417,39845889,40173570],"arithmetic":[196609,2424833,3538945,3866625,5242881,5505025,5636097,7929859,7995393,8060929,8126467,8388609,9240577,9830401,10223617,10289153,11403265,11665409,12058625,12124161,12451841,12713985,12845059,12910593,13107201,14548993,14811137,16384001,17694721,18087937,18284545,18808833,19070977,22347777,22675457,23396353,23592961,25427969,25886721,26738689,29229057,31522817,32899073,33095681,33882113,34340865,36569089,37879809,38010881,38797313,39583745,40566785,40828929,41025537],"allocate":[1835009,3670018,5963782,6881281,7471110,7667714,9306118,10158092,15335430,15794178,16318466,19726337,21757954,21823490,26345477,31391745,32047105,32702465,34406401,37158913,40173570],"add":[5046273,5963780,9043969,14286849,15335428,16908289,20316161,39780353],"assuming":[24576001],"available":[196610,393218,524290,589826,851970,983042,1114114,1245186,1310722,1376258,1507330,1638402,1966082,2097154,2162690,2293762,2424834,2490370,2555906,2818050,2883586,3014658,3145730,3276802,3342338,3407874,3538946,3735554,3866626,3932162,3997698,4128770,4259842,4325378,4718594,4784130,5046274,5111810,5177346,5242882,5439490,5505026,5570562,5636098,5701634,5832706,5898242,6356994,6488066,6619138,6815746,7012354,7077890,7143426,7274498,7340034,7405570,7536642,7602178,7667714,7733250,7929858,7995394,8060930,8126466,8192002,8257538,8323074,8388610,8650754,8781826,8912898,8978434,9043970,9240578,9306114,9502722,9568258,9699330,9830402,9895938,9961474,10027010,10158082,10223618,10289154,10354690,10420226,10616834,10682370,11206658,11272194,11337730,11403266,11665410,11730946,11862018,11927554,12058626,12124162,12255234,12320770,12386306,12451842,12648450,12713986,12845058,12910594,12976130,13041666,13107202,13172738,13238274,13303810,13369346,13500418,13828098,13893634,13959170,14024706,14155778,14286850,14417922,14483458,14548994,14745602,14811138,15073282,15138818,15466498,15532034,15597570,15728642,15794179,15859714,15925250,16056322,16121858,16187394,16318466,16384002,16449538,16777218,16908290,17039362,17235970,17301506,17629186,17694722,17825794,17956866,18022402,18087938,18284546,18350082,18415619,18612226,18743298,18808834,18874370,19005442,19070978,19333122,19529730,19660802,19791874,19988482,20250626,20316162,20381698,20447234,20512770,20578306,20709378,20774914,20905986,20971522,21037058,21102595,21168130,21233666,21299202,21561346,21626882,21692418,21757955,21954562,22020098,22085634,22347778,22413313,22478850,22675458,22740994,22806530,23265282,23396354,23592962,23658498,23986178,24051714,24117250,21823490,24182786,24313858,24510466,24576002,24707074,24444930,24838146,24969218,25034754,25362434,25559042,25427970,24379394,25821186,25165826,25886722,26017794,26083330,24903682,26279938,26411010,26476546,26607618,26673154,26738690,25690114,25493506,26935298,27000834,25231362,27197442,27328514,27394050,27590658,27656194,27721730,27852802,28114946,28246018,28311554,28377090,28573698,28704770,28770306,28966914,29032450,29097986,29229058,29294594,29360131,29425666,29556738,29622274,29687810,29753346,29884418,30015490,30146562,30277634,30408706,30474242,30539778,30605314,30736386,30867458,30998530,31064066,31195138,31260674,31522818,31850498,32112642,32178178,32374786,32440322,32505858,32833538,32899074,32964610,33095682,27066370,33161218,33357826,33423362,33751042,33882114,33947650,34078722,34209794,34275330,34340866,34865154,34930690,34996226,35061762,35192835,35323906,35389442,35454978,35520514,35717122,35979266,36044802,36241410,36306946,36438018,36503554,36569090,36634626,36831234,36962306,37289986,37355522,37421058,37617666,37748738,37814274,37879810,37945346,38010882,38076418,38141954,38207490,38338563,38404098,38469634,38600706,38666242,38797314,38928386,38993922,39059458,39124994,39256066,39387138,39518210,39583746,39649282,39714818,39780354,39845890,39976962,40108034,40173570,40370178,40501250,40566786,40632322,40697858,40763394,40828930,40894466,40960002,41025538,41156610,41222146,41287682,41353218]} \ No newline at end of file diff --git a/docs/fti/FTI_98.json b/docs/fti/FTI_98.json new file mode 100644 index 0000000..01b9e3f --- /dev/null +++ b/docs/fti/FTI_98.json @@ -0,0 +1 @@ +{"bit":[917505,1245186,2424834,2949121,3014658,4063233,4653057,5439490,5570562,5636102,5701634,5963805,7864321,9568258,10223632,10289154,11337730,12058640,12124166,12910596,13631489,14680065,14745602,15204353,15335454,15532034,16384002,16908289,17104897,17629186,20774913,22216705,22347782,22413314,22478850,23396354,23658509,24838146,26279949,25624577,27656194,28966914,29032449,29097986,30605314,31653889,31850497,33030145,33357826,34013185,35323905,35979266,36831233,36896769,37552130,38600706,38797314,39256066,39583750,40435713,41222146,41418753],"binary":[1245185,2097153,5963780,12648449,14352385,15335428,17235969,18022401,22806529,23396353,30146561,32243713,35520513,36503553],"behaves":[2424833,5636097,10223617,10289153,12058625,12124161,12910593,16384001,22347777,23396353,38797313,39583745],"block":[1835016,3670018,5963781,6881282,10485762,15335429,15925251,18546691,20316161,25034753,27328515,29360131,30015489,32571394,33554435,34406402,35782659,36306947,37093381,38338563,40173571],"bool":[655364,7798787,8519683,9175044,9764868,10747907,11993091,14221315,19136516,19595267,19857412,20185092,23330819,27131907,27262979,27983875,28049411,28442627,28508163,28639235,28835843,29818883,29949955,30343172,30670851,30801923,31784963,32636932,33685507,33816579,35848195,39321603],"bits":[196610,2490370,3145730,3538945,3735554,3866626,4063234,4259844,5505026,5570562,5701638,5963787,7929858,8060930,8126465,8388610,8912898,9699330,9830402,9895937,10027010,10223617,11665410,11730950,12058625,12451842,12713986,12845058,12910593,13172738,13303810,14483458,15073281,15335436,16908292,18087938,18415618,18612226,19988484,20774916,21561346,23396355,24051714,21823491,24182790,24838148,25427970,25886722,27328514,28114946,29097988,30539778,31850498,32899074,34406401,34537473,34865153,34930690,35323906,35454983,35717121,37552129,37748738,37879810,38928386,39059458,40173570,40435713,40566786,40632324,41156616,41353218],"bytesperlimb":[14417924],"bitwise":[2424835,2883585,4325378,5963793,6815746,10289155,15335441,16777217,18350081,22478849,30998530,32374786,33751042,38797315,38993921],"byref":[10158086,20250626,40173570],"binomial":[5963778,11272195,15335426,29425667],"boolean":[655362,7798786,8519682,9175042,9764866,10747906,11993090,14221314,19136514,19595266,19857410,20185090,23330818,27131906,27262978,27983874,28049410,28442626,28508162,28639234,28835842,29818882,29949954,30343170,30670850,30801922,31784962,32636930,33685506,33816578,35848194,39321602],"bases":[17235970,22478850,22806530,24444930],"based":[5832705,9961473,13500418,21168130,21233666,22413313,29163521],"book":[5963777,15335425,39124993],"bytes":[1245189,1835015,3670017,5046274,5963781,6881281,7471107,7667714,8781827,8978434,11337731,14417921,15335430,15925250,16318466,18874371,22806531,21823494,26869761,27066369,27328514,31653889,32702467,33554434,34078723,34406404,36306946,37093382,39976962,40173572,40435713],"bitsperlimb":[35717124],"bin":[29425666],"base":[1179650,5046283,5963803,8781839,8978440,13303816,15335451,15925259,16449543,17235980,18874378,22478858,22806538,24576021,24444943,26607638,27066379,27328521,27590677,27721750,30867464,34078729,35520521,36306955,39059466,39976969],"byte":[327682,720898,1245186,2752515,4063237,4849670,5046278,5308418,8585217,8847362,9371650,13434881,13631493,16515078,17760262,18153478,18481154,20643846,23068676,23789573,21823495,24248322,24772611,25296902,26542086,26869765,27787268,29491205,30081030,31326211,31653892,32309250,32768002,27066377,33488902,34013189,34537476,34734085,36372486,37486594,38535169,40173576],"beginning":[24444929],"body":[34537473],"bound":[524289],"bugs":[12648449,30146561,36503553],"bit_index":[5636103,5963780,12124166,15335428,22347782,39583750],"borrows":[19791873,36044801],"buf":[5963780,7667719,15335428,15794184,16318471,21757960],"bigger":[1835009,34865153],"build":[22413313],"behave":[22413313],"b1p":[34996230],"borrow":[22740997,25034757,25559045,26411013,31195141,38469637,39714821],"big":[1245185,9895937,18415618,21102593,22478849,31850497,32178177,35192834,36831233,39059457],"behaviour":[35061761],"building":[20316161,22413313,25034753,30015489],"better":[29884417,39845889],"best":[2555905,29556737]} \ No newline at end of file diff --git a/docs/fti/FTI_99.json b/docs/fti/FTI_99.json new file mode 100644 index 0000000..f384d6c --- /dev/null +++ b/docs/fti/FTI_99.json @@ -0,0 +1 @@ +{"calculating":[2555905,29556737],"coefficient":[5963778,11272195,15335426,29425667,37289986],"copy":[196610,262145,393218,458753,524290,589826,655361,786433,851970,917505,983042,1114114,1179649,1245186,1310722,1376258,1441793,1507331,1572865,1638402,1835009,1966082,2031617,2097154,2162690,2228225,2293762,2359297,2424834,2490370,2555906,2686977,2818050,2883586,2949121,3014658,3080193,3145730,3211265,3276802,3342338,3407874,3538946,3604481,3670017,3735554,3866626,3932162,3997698,4063233,4128770,4194305,4259842,4325378,4456449,4521985,4587521,4653057,4718594,4784130,4849665,4980737,5046278,5111810,5177346,5242882,5373953,5439490,5505026,5570562,5636098,5701634,5767169,5832706,5898242,5963779,6029313,6160385,6225921,6291457,6356994,6488066,6553601,6619138,6684673,6750209,6815746,6881281,7012354,7077890,7143426,7208961,7274498,7340034,7405570,7471105,7536642,7602178,7667714,7733250,7798785,7864322,7929858,7995394,8060930,8126466,8192002,8257538,8323074,8388610,8454146,8519681,8650754,8716289,8781826,8847361,8912898,8978434,9043970,9175041,9240578,9306114,9371649,9437185,9502722,9568258,9633793,9699330,9764865,9830402,9895938,9961474,10027010,10092545,10158082,10223618,10289154,10354690,10420226,10485761,10551297,10616834,10682370,10747905,10813441,10878977,10944513,11010049,11075585,11141121,11206658,11272194,11337730,11403266,11468801,11534337,11665410,11730946,11796481,11862018,11927554,11993089,12058626,12124162,12189697,12255235,12320770,12386306,12451842,12582913,12648450,12713986,12845058,12910594,12976130,13041666,13107202,13172738,13238274,13303810,13369346,13434882,13500418,13565953,13631489,13762561,13828098,13893634,13959170,14024706,14155778,14221313,14286850,14352385,14417922,14483458,14548994,14614529,14680065,14745602,14811138,14942209,15007746,15073282,15138818,15204353,15269889,15335428,15400961,15466498,15532034,15597570,15663105,15728642,15794178,15859714,15925250,15990785,16056322,16121858,16187395,16318466,16384002,16449538,16515073,16580609,16646145,16711681,16777218,16842754,16908290,16973825,17039362,17104897,17170433,17235970,17301506,17367041,17432577,17498113,17563649,17629186,17694722,17760257,17825794,17891329,17956866,18022402,18087938,18153473,18219009,18284546,18350082,18415618,18546689,18612226,18743298,18808834,18874370,19005442,19070978,19136513,19202049,19333122,19398657,19464193,19529730,19595265,19660802,19726337,19791874,19857409,19922945,19988482,20054017,20119553,20185089,20250626,20316162,20381698,20447234,20512770,20578306,20643841,20709378,20774914,20840449,20905987,20971522,21037058,21102594,21168130,21233666,21299202,21364737,21430274,21495809,21561346,21626882,21692418,21757954,21823495,21954562,22020098,22085634,22151169,22216705,22282242,22347778,22478850,22544385,22675458,22740994,22806530,22872065,22937601,23003137,23134209,23199745,23265282,23330817,23396354,23461889,23592962,23658498,23724033,23855105,23920641,23986178,24051714,24117250,24182786,24313858,24510466,24444930,24576002,24707074,24379394,24838146,24903682,24969218,25034754,25100289,25165826,25231362,25296897,25362434,25427970,25493506,25559042,25624577,25690114,25755649,25821186,25886722,25952257,26017794,26083330,26148865,26214401,26279938,26411010,26476546,26542081,26607618,26673154,26738690,26804225,26869761,26935298,27000834,27066372,27131905,27197442,27262977,27328514,27394050,27459585,27525121,27590658,27656194,27721730,27852802,27918337,27983873,28049409,28114946,28180481,28246018,28311554,28377090,28442625,28508161,28573698,28639233,28704770,28770306,28835841,28901377,28966914,29032450,29097986,29163521,29229058,29294594,29360130,29425666,29556738,29622274,29687810,29753346,29818881,29884418,29949953,30015490,30081025,30146562,30212097,30277634,30343169,30408706,30474242,30539778,30605314,30670849,30736386,30801921,30867458,30998530,31064066,31129601,31195138,31260674,31391745,31457281,31522818,31588353,31653889,31784961,31850498,31916033,31981569,32047105,32112642,32178178,32243713,32374786,32440322,32505858,32636929,32702465,32833538,32899074,32964610,33030145,33095682,33161218,33226753,33292289,33357826,33423362,33488897,33554433,33619969,33685505,33751042,33816577,33882114,33947650,34013185,34078722,34144257,34209794,34275330,34340866,34471937,34537473,34603010,34668545,34799617,34865154,34930690,34996226,35061762,35127297,35192834,35258369,35323906,35389442,35454978,35520514,35651585,35717122,35782657,35848193,35913729,35979266,36044802,36110337,36175873,36241410,36306947,36372481,36438018,36503554,36569090,36634626,36700161,36765697,36831234,36896769,36962306,37027841,37093377,37158913,37224449,37289986,37355522,37421058,37486593,37552129,37617666,37683201,37748738,37814274,37879810,37945346,38010882,38076418,38141954,38207490,38273025,38338562,38404098,38469634,38535169,38600706,38666242,38731777,38797314,38862849,38928386,38993922,39059458,39124994,39190529,39256066,39321601,39387138,39452673,39518210,39583746,39649282,39714818,39780354,39845890,39976962,40042497,40108034,40173573,40239105,40304641,40370178,40501250,40566786,40632322,40697858,40763394,40828930,40894466,40960002,41025538,41091073,41156610,41222146,41287682,41353218,41418753],"compatibility":[1245185,11337729,19529729,28573697,40501249],"characters":[5046274,5963777,7667716,8781825,8978436,14352385,15335425,15728641,15794179,16318468,17039361,17235969,20512769,21757955,22806529,24444929,29360129,31653889,32243713,33161217,34406401,35520513,38338561],"compare":[393217,655361,983041,1638401,5963793,7602177,7798785,9175041,9764865,10354689,10682369,11927553,13172737,13238273,14483457,15335441,18612225,19136513,19857409,20185089,27000833,27852801,28049409,28114945,28508161,28639233,30343169,30670849,32636929,33816577,34930689,35848193,37355521,37421057,39321601],"common":[983041,3932161,5898241,5963785,11927553,13041667,15335433,17956866,19529729,20971523,22282241,26083329,29622273,34406401,37289988,38076419,40960001],"compared":[29884417,39845889],"clear":[5963778,15335426,22347780,26279939],"certain":[14155777],"compromise":[25493505],"call":[589825,2490369,2555905,8912897,9306114,11730945,13303809,13959169,17825793,19791873,25821185,29556737,30015489,32505857,36044801,40632321],"create":[196612,393218,524290,589825,851970,983042,1114116,1245186,1310722,1376260,1507330,1638401,1966082,2097154,2162692,2293764,2424838,2490370,2555906,2818050,2883586,3014658,3145730,3276804,3342338,3407876,3538948,3735556,3866628,3997698,4325378,4718596,4784130,5046274,5111810,5177346,5439490,5505028,5570562,5636098,5701634,5832706,5898242,6356994,6488068,6815746,7012354,7077890,7143426,7274500,7340038,7405570,7536642,7602178,7733254,7929860,7995398,8060934,8126466,8192006,8257540,8323074,8388612,8650756,8781826,8912898,8978434,9043970,9306114,9502724,9568258,9699330,9830404,9895938,9961474,10027012,10223618,10289158,10354692,10616834,10682372,11206660,11272194,11337730,11665410,11730946,11862020,11927554,12058626,12124162,12255236,12320772,12386310,12451842,12648452,12713988,12845062,12910596,12976132,13041670,13107204,13172738,13238274,13303810,13369346,13500418,13828100,13893636,13959170,14024706,14155778,14286850,14483460,14548998,14745602,14811140,15073282,15138818,15466502,15532034,15597572,15859716,15925250,16056322,16121858,16187394,16384004,16449538,16777218,16908290,17039362,17235970,17301506,17629186,17694726,17825794,17956866,18022402,18087942,18350082,18415618,18612226,18743300,18808834,18874370,19005444,19070980,19333124,19529730,19660804,19791874,19988484,20250626,20316162,20381700,20447234,20578308,20709382,20774914,20905986,20971522,21037058,21102594,21168130,21233666,21299204,21561346,21626884,21954566,22020098,22085634,22347778,22478850,22675460,22740994,22806530,23265284,23396354,23658498,23986180,24051716,24117254,21823490,24313858,24510468,24576008,24707074,24444930,24838146,24969220,25034754,25362434,25559044,25427972,24379398,25821186,25165826,25886724,26017796,26083330,24903682,26279938,26411010,26476546,26607624,26673154,26738692,25690116,25493506,26935300,27000836,25231362,27197444,27328514,27394052,27590660,27656194,27721732,27852802,28114948,28246020,28311554,28377090,28573698,28704772,28770310,28966914,29097986,29229060,29294594,29360130,29425668,29556738,29622274,29687810,29753348,29884418,30015490,30146562,30277636,30408706,30474242,30539778,30605314,30736388,30867458,30998530,31064066,31195138,31260678,31522822,31850498,32112642,32178178,32374786,32440322,32505858,32899078,32964612,27066370,33161218,33357826,33423362,33751042,33882116,33947654,34078722,34209794,34275332,34865154,34930690,34996226,35061766,35192834,35323906,35389442,35454978,35520513,35979266,36044802,36241412,36306946,36438022,36503554,36634626,36962306,37289990,37355524,37421058,37617668,37748742,37814276,37879812,37945348,38010886,38076422,38141954,38207494,38338562,38404098,38469634,38600706,38666242,38797318,38928386,38993922,39059458,39124994,39256066,39387138,39518210,39583746,39649284,39714818,39780354,39845890,39976961,40108034,40173570,40370178,40501250,40566788,40632324,40697858,40763396,40894466,41025540,41156610,41222146,41287682,41353220],"correct":[30867457],"comlpement":[12124161],"changing":[5963777,15335425,24444929,40632321],"close":[1245186,18874370,34078722,39976961],"corresponding":[8781825,9306113,24444929],"calling":[5701633,12648449,12976129,13828097,15204353,15859713,16908289,19791873,19988481,24117249,26411009,26869761,27394049,28573697,30736385,33619969,36044801,37552129,40501249,40632321,41418753],"char":[4128771,4849665,5046273,5963777,6619139,6750209,8323075,8847361,9371649,9437185,9633793,10944513,14024707,15335425,16515073,16711681,17760257,18153473,20643841,21692419,23920641,25296897,26542081,26869761,30081025,32833539,33488897,36372481,37486593,38535169],"clock":[29884417,39845889],"canonical":[8978433,35520513],"currently":[196610,393218,524290,589826,851970,983042,1114114,1245186,1310722,1376258,1507330,1638402,1966082,2097154,2162690,2293762,2424834,2490370,2555906,2818050,2883586,3014658,3145730,3276802,3342338,3407874,3538946,3735554,3866626,3932162,3997698,4063233,4128770,4259842,4325378,4718594,4784130,5046274,5111810,5177346,5242882,5439490,5505026,5570562,5636098,5701634,5832706,5898242,5963777,6356994,6488066,6619138,6815746,7012354,7077890,7143426,7274498,7340034,7405570,7536642,7602178,7667714,7733250,7864322,7929858,7995394,8060930,8126466,8192002,8257538,8323074,8388610,8650754,8781826,8912898,8978434,9043970,9240578,9306114,9502722,9568258,9699330,9830402,9895938,9961474,10027010,10158082,10223618,10289154,10354690,10420226,10616834,10682370,11206658,11272194,11337730,11403266,11599873,11665410,11730946,11862018,11927554,12058626,12124162,12255234,12320770,12386306,12451844,12648450,12713986,12845058,12910594,12976130,13041666,13107202,13172738,13238274,13303810,13369346,13500418,13631489,13828098,13893634,13959170,14024706,14155778,14286850,14417922,14483458,14548994,14745602,14811138,14876673,15073282,15138818,15335425,15466498,15532034,15597570,15728642,15794178,15859714,15925250,16056322,16121858,16187394,16318466,16384002,16449538,16777218,16908290,17039362,17235970,17301506,17629186,17694722,17825794,17956866,18022402,18087938,18284546,18350082,18415618,18612226,18743298,18808834,18874370,19005442,19070978,19333122,19529730,19660802,19791875,19988482,20250626,20316162,20381698,20447234,20512770,20578306,20709378,20774914,20905986,20971522,21037058,21102594,21168130,21233666,21299202,21430273,21561346,21626882,21692418,21757954,21954562,22020098,22085634,22347778,22478850,22675458,22740994,22806530,23265282,23396354,23592962,23658498,23724034,23986178,24051714,24117250,21823490,24182786,24313858,24510466,24576002,24707074,24444930,24838146,24969218,25034754,25362434,25559042,25427970,24379394,25821186,25165826,25886722,26017794,26083330,24903682,26279938,26411010,26476546,26607618,26673154,26738690,25690114,25493507,26935298,27000834,25231362,27197442,27328514,27394050,27590658,27656194,27721730,27852802,28114946,28246018,28311554,28377090,28573698,28704770,28770306,28966914,29032450,29097986,29229058,29294594,29360130,29425666,29556738,29622274,29687810,29753346,29884418,30015490,30146562,30277634,30408706,30474242,30539778,30605314,30736386,30867458,30998530,31064066,31195138,31260674,31522818,31850498,32112642,32178178,32374786,32440322,32505858,32833538,32899074,32964610,33030145,33095682,27066370,33161218,33357826,33423362,33751042,33882114,33947650,34013185,34078722,34209794,34275330,34340866,34471937,34865154,34930690,34996226,35061762,35192834,35323906,35389442,35454978,35520514,35717122,35979266,36044803,36241410,36306946,36438018,36503554,36569090,36634626,36831234,36962306,37289986,37355522,37421058,37617666,37748738,37814274,37879810,37945346,38010882,38076418,38141954,38207490,38338562,38404098,38469634,38600706,38666242,38797314,38928386,38993922,39059458,39124994,39256066,39387138,39518210,39583746,39649282,39714818,39780354,39845890,39976962,40108034,40173570,40370178,40501250,40566786,40632322,40697858,40763394,40828930,40894466,40960002,41025538,41156610,41222146,41287682,41353218],"cbrt":[6488066,26017794],"conditonal":[7012353,31195137,34996225],"custom":[1835009,3670017,7471105,9306113,10158081,27328513,36306945,40173569],"classes":[34406401],"c99":[7667713,16318465],"choice":[15073281],"chosen":[27066369,34865153,37289985],"const":[16187394],"congruential":[5570563,5963778,15335426,34865155],"class":[196609,393217,458753,524289,589825,851969,983041,1114113,1179649,1245185,1310721,1376257,1441793,1507329,1638401,1835009,1966081,2031617,2097153,2162689,2293761,2424833,2490369,2555905,2621441,2686977,2818049,2883585,3014657,3080193,3145729,3211265,3276801,3342337,3407873,3538945,3670017,3735553,3801089,3866625,3932161,3997697,4063233,4128769,4259841,4325377,4390913,4456449,4521985,4587521,4718593,4784129,5046273,5111809,5177345,5242881,5373953,5439489,5505025,5570561,5636097,5701633,5832705,5898241,5963777,6029313,6291457,6356993,6422529,6488065,6553601,6619137,6815745,7012353,7077889,7143425,7274497,7340033,7405569,7471105,7536641,7602177,7667713,7733249,7864325,7929857,7995393,8060929,8126465,8192001,8257537,8323073,8388609,8454145,8585217,8650753,8781825,8912897,8978433,9043969,9109505,9240577,9306113,9502721,9568257,9699329,9830401,9895937,9961473,10027009,10092546,10158081,10223617,10289153,10354689,10420225,10616833,10682369,10813441,11141121,11206657,11272193,11337729,11403265,11468801,11599873,11665409,11730945,11862017,11927553,12058625,12124161,12189697,12255233,12320769,12386305,12451841,12517377,12648449,12713985,12845057,12910593,12976129,13041665,13107201,13172737,13238273,13303809,13369345,13434885,13500417,13631489,13828097,13893633,13959169,14024705,14090241,14155777,14286849,14352385,14417921,14483457,14548993,14745601,14811137,14876673,15007750,15073281,15138817,15204353,15269889,15335429,15400961,15466497,15532033,15597569,15728641,15794177,15859713,15925249,16056321,16121857,16187393,16318465,16384001,16449537,16777217,16842757,16908289,17039361,17235969,17301505,17432577,17629185,17694721,17825793,17956865,18022401,18087937,18284545,18350081,18415617,18612225,18743297,18808833,18874369,19005441,19070977,19333121,19464193,19529729,19660801,19726337,19791873,19922945,19988481,20250625,20316161,20381697,20447233,20512769,20578305,20709377,20774913,20905985,20971521,21037057,21102593,21168129,21233665,21299201,21430277,21561345,21626881,21692417,21757953,21954561,22020097,22085633,22282246,22347777,22478849,22675457,22740993,22806529,22872065,23134209,23199745,23265281,23396353,23527425,23592961,23658497,23724033,23986177,24051713,24117249,21823489,24182785,24313857,24510465,24576001,24707073,24444929,24838145,24969217,25034753,25362433,25559041,25755649,25427969,24379393,25821185,25165825,25886721,25952257,26017793,26083329,26148865,24903681,26279937,26345473,26411009,26476545,26607617,26673153,26738689,25690113,26869761,25493505,26935297,27000833,25231361,27197441,27328513,27394049,27525121,27590657,27656193,27721729,27852801,27918337,28114945,28246017,28311553,28377089,28573697,28704769,28770305,28966913,29032449,29097985,29163521,29229057,29294593,29360129,29425665,29556737,29622273,29687809,29753345,29884417,30015489,30146561,30277633,30408705,30474241,30539777,30605313,30736385,30867457,30932993,30998529,31064065,31195137,31260673,31391745,31522817,31588353,31653889,31850497,31916033,32047105,32112641,32178177,32243713,32374785,32440321,32505857,32833537,32899073,32964609,33030145,33095681,27066369,33161217,33292289,33357825,33423361,33554433,33619969,33751041,33882113,33947649,34013185,34078721,34209793,34275329,34340865,34406401,34471937,34537473,34603013,34668545,34865153,34930689,34996225,35061761,35127297,35192833,35323905,35389441,35454977,35520513,35717121,35782657,35913729,35979265,36044801,36110337,36241409,36306945,36438017,36503553,36569089,36634625,36700161,36831233,36962305,37158913,37289985,37355521,37421057,37552129,37617665,37748737,37814273,37879809,37945345,38010881,38076417,38141953,38207489,38338561,38404097,38469633,38600705,38666241,38797313,38928385,38993921,39059457,39124993,39256065,39387137,39518209,39583745,39649281,39714817,39780353,39845889,39976961,40042497,40108033,40173569,40370177,40435713,40501249,40566785,40632321,40697857,40763393,40828929,40894465,40960001,41025537,41091073,41156609,41222145,41287681,41353217,41418753],"copies":[5963778,7012354,15335426,31195138],"current":[131073,1441793,1703937,1900545,4063233,4456449,4915201,5963781,6291459,7864323,8781825,9306113,10158081,11141123,13434884,13500418,13631489,15007748,15335429,15400963,15925249,16842755,18939905,21168130,21233666,21430275,21889025,22282244,22413314,23199748,24444929,24641537,24838146,27328513,29360130,31588356,31653889,32571393,34013185,34537473,34603012,35127300,35782657,36306945,38338562,39976961,40042500,40173569],"cover":[22413313],"considering":[24444929],"correctness":[2097153,18022401],"comparison":[28114945],"composite":[14155779,21299201,39124994],"comparing":[983041,2818049,10682369,11927553,20578305,27000833],"congruent":[5963779,7733254,10616838,13893637,15335427],"cases":[22413313,37289986],"chances":[14155777],"course":[1835009,3670017,30408705],"changes":[1245185,11337729,39256065],"constants":[10420225,35717121],"collection":[6291457,7864321,11141121,13434881,15007745,15400961,16842753,21430273,22282241,23199745,31588353,34603009,35127297,40042497],"choosing":[29884417,39845889],"comparisons":[393217,1638401,7602177,10354689,24707073,27852801,37355521,37421057,40173569],"code":[131073,196610,393218,524290,589826,851970,917506,983042,1114114,1245186,1310722,1376258,1441793,1507330,1638402,1703937,1900545,1966082,2097154,2162690,2293762,2424834,2490370,2555906,2818050,2883586,2949122,3014658,3145730,3276802,3342338,3407874,3538946,3735554,3866626,3932162,3997698,4063233,4128770,4259842,4325378,4456449,4653058,4718594,4784130,4915201,5046274,5111810,5177346,5242882,5439490,5505026,5570562,5636098,5701634,5832706,5898242,6356994,6488066,6619138,6815746,7012354,7077890,7143426,7274498,7340034,7405570,7536642,7602178,7667714,7733250,7929858,7995394,8060930,8126466,8192002,8257538,8323074,8388610,8650754,8781826,8912898,8978434,9043970,9240578,9306114,9502722,9568258,9699330,9830402,9895938,9961474,10027010,10158082,10223618,10289154,10354690,10420226,10616834,10682370,11206658,11272194,11337730,11403266,11665410,11730946,11862018,11927554,12058626,12124162,12255234,12320770,12386306,12451842,12648450,12713986,12845058,12910594,12976130,13041666,13107202,13172738,13238274,13303810,13369346,13500418,13631489,13828098,13893634,13959170,14024706,14155778,14286850,14417922,14483458,14548994,14680066,14745602,14811138,15073282,15138818,15466498,15532034,15597570,15728642,15794178,15859714,15925250,16056322,16121858,16187394,16318466,16384002,16449538,16777218,16908290,17039362,17104898,17235970,17301506,17629186,17694722,17825794,17956866,18022402,18087938,18284546,18350082,18415618,18612226,18743298,18808834,18874370,18939905,19005442,19070978,19333122,19529730,19660802,19791874,19988482,20250626,20316162,20381698,20447234,20512770,20578306,20709378,20774914,20905986,20971522,21037058,21102594,21168130,21233666,21299202,21561346,21626882,21692418,21757954,21889025,21954562,22020098,22085634,22216706,22347778,22413313,22478850,22675458,22740994,22806530,23265282,23396354,23592962,23658498,23986178,24051714,24117250,21823490,24182786,24313858,24510466,24576002,24641537,24707074,24444930,24838146,24969218,25034754,25362434,25559042,25624578,24379394,25427970,25821186,25165826,25886722,26017794,26083330,24903682,26279938,26411010,26476546,26607618,26673154,26738690,25690114,25493506,26935298,27000834,25231362,27197442,27328514,27394050,27590658,27656194,27721730,27852802,28114946,28246018,28311554,28377090,28573698,28704770,28770306,28966914,29032450,29097986,29229058,29294594,29360130,29425666,29556738,29622274,29687810,29753346,29884418,30015490,30146562,30277634,30408706,30474242,30539778,30605314,30736386,30867458,30998530,31064066,31195138,31260674,31522818,31653889,31850498,32112642,32178178,32374786,32440322,32505858,32571393,32833538,32899074,32964610,33095682,27066370,33161218,33357826,33423362,33751042,33882114,33947650,34013185,34078722,34209794,34275330,34340866,34537473,34865154,34930690,34996226,35061762,35192834,35323906,35389442,35454978,35520514,35717122,35782657,35979266,36044802,36241410,36306946,36438018,36503554,36569090,36634626,36831234,36896770,36962306,37289986,37355522,37421058,37617666,37748738,37814274,37879810,37945346,38010882,38076418,38141954,38207490,38338562,38404098,38469634,38600706,38666242,38797314,38928386,38993922,39059458,39124994,39256066,39387138,39518210,39583746,39649282,39714818,39780354,39845890,39976962,40108034,40173570,40370178,40501250,40566786,40632322,40697858,40763394,40828930,40894466,40960002,41025538,41156610,41222146,41287682,41353218],"combined":[3735553,7274497,13303809,21037057,21561345,25165825,30539777,30867457,38928385,40108033],"convert":[5046276,5963789,8978433,15335437,15925249,18415617,20250625,21102593,27066371,27328513,31850497,35192833,35323905,36306945,36831233],"cleanup":[6291457,7864321,11141121,13434881,15007745,15400961,16842753,21430273,22282241,23199745,31588353,34603009,35127297,40042497],"counting":[22478849],"chose":[34537473],"cint":[5046273],"cpu":[22413315,21823490,40173570],"case":[1835009,3080193,5046273,5963778,8978433,12648449,15073281,15335426,15925252,16449537,17235973,18874372,22806533,24444933,27328517,27590657,30146561,34471937,36503553,38141953,39976964,40173570],"checks":[23724033],"contents":[5963777,15335425,21168129,34996225],"ctype":[262145,786433,1179649,1572865,2228225,3604481,4194305,4849665,5767169,6225921,6684673,6750209,7208961,8716289,8847361,9371649,9437185,9633793,10551297,10878977,10944513,11534337,11796481,12582913,13565953,14352385,14614529,14942209,15663105,15990785,16515073,16580609,16646145,16711681,16973825,17170433,17367041,17498113,17563649,17760257,18153473,18219009,19202049,19398657,20643841,20840449,21364737,21495809,22544385,22937601,23003137,23461889,23855105,23920641,25100289,25296897,26214401,26542081,26804225,28180481,30081025,31129601,31457281,31981569,32243713,33226753,33488897,34799617,35258369,35651585,36175873,36372481,36765697,37027841,37224449,37486593,38273025,38535169,38731777,38862849,39190529,40239105,40304641],"convenience":[1835009,3670017,16187393,33030145],"called":[393217,8978433,9306114,13172737,27852801,35520513],"critical":[29884417,39845889],"culng":[18743298],"cast":[16187393],"content":[1245186,18874370,34078722,39976961],"count":[4063233,4128769,5046278,5963780,6619137,8323073,9043969,9306116,9699329,13631489,14024705,15335428,19529730,21692417,21823494,23396354,30015489,31653889,32833537,27066372,34406403,35454984,40173573,41156616],"coefficients":[5963777,15335425,37289985],"character":[1179649,5046273,8978433,29360130,27066369,38338562],"corner":[12648449,30146561,36503553],"conversion":[262145,327681,720897,786433,1179649,1572865,2228225,2752513,3604481,3997697,4194305,4849665,5308417,5767169,5963778,6225921,6684673,6750209,7208961,8716289,8847361,9371649,9437185,9633793,10551297,10878977,10944513,11534337,11796481,12582913,13565953,14352385,14614529,14942209,15335426,15663105,15990785,16515073,16580609,16646145,16711681,16973825,17170433,17367041,17498113,17563649,17760257,18153473,18219009,18481153,19202049,19398657,20643841,20840449,21102593,21364737,21495809,22544385,22937601,23003137,23461889,23855105,23920641,24248321,24772609,25100289,25296897,26214401,26542081,26804225,28180481,30081025,31129601,31326209,31457281,31981569,32243713,32309249,32768001,33226753,33488897,34799617,35192833,35258369,35651585,36175873,36372481,36765697,37027841,37224449,37486593,38273025,38535169,38731777,38862849,39190529,40239105,40304641,40763393],"completed":[8454145],"certainly":[21823489],"cache":[24576001],"computation":[6488065],"clobbered":[5046273],"cryptographic":[24576001,29884417,39845889],"creates":[1441793,2686977,3801090,4063233,5373953,6029313,6160385,6291457,6553601,7864322,8585221,11141121,13434886,13631489,13762561,15007747,15204353,15400961,16842754,17891329,21430274,22151169,22282241,23199745,26869761,27459585,27525121,27918337,30212097,31588353,31653889,33619969,34013185,34537473,34603010,35127297,37552129,40042497,41418753],"completely":[5111809,28573697,38141954,40501249],"cpus":[9043969,19791873,20316161,22740993,25034753,30015489,35454977,36044801,41156609],"channel":[9961473,24576001],"conditional":[7012353,31195137],"changed":[5701636,39256068],"calculate":[851969,1966081,5963783,8650753,15335431,15597569,28377089,29753345,32440321],"concatenated":[5570561],"constructor":[2686977,3801089,5373953,6029313,6160385,6553601,8585217,10092545,13762561,15204353,17891329,22151169,26869761,27459585,27525121,27918337,30212097,33619969,37552129,41418753],"ceil":[5963778,15073282,15335426,24051714,34275329,38141954],"converting":[9895937,15925249,18415617,20250625,21102593,22478849,21823489,27328513,31850497,32178177,35323905,36831233],"converts":[262145,327685,720905,786433,1179649,1572865,2228225,2752519,3604481,4063248,4194305,4390913,4849665,5308427,5767169,6225921,6422529,6684673,6750209,7208961,7864321,8716289,8847361,9109505,9371649,9437185,9633793,10551297,10878977,10944513,11534337,11796481,12582913,13565953,13631504,14352385,14614529,14942209,15663105,15990785,16515073,16580609,16646145,16711681,16842753,16973825,17170433,17367041,17498113,17563649,17760257,18153473,18219009,18481158,19202049,19398657,20643841,20840449,21364737,21430273,21495809,22544385,22937601,23003137,23068688,23461889,23789584,23855105,23920641,24248329,24772618,25100289,25296897,26214401,26542081,26804225,27787280,28180481,29491216,30081025,31129601,31326215,31457281,31653904,31981569,32243713,32309259,32768005,33226753,33488897,34013200,34537488,34734096,34799617,35258369,35651585,36175873,36372481,36765697,37027841,37224449,37486593,38273025,38535169,38731777,38862849,39190529,40239105,40304641],"care":[29884417,39845889],"calls":[9306114,24182785],"counter":[9306126],"casting":[262145,786433,1179649,1572865,2228225,3604481,4194305,4849665,5767169,6225921,6684673,6750209,7208961,8716289,8847361,9371649,9437185,9633793,10551297,10878977,10944513,11534337,11796481,12582913,13565953,14352385,14614529,14942209,15663105,15990785,16515073,16580609,16646145,16711681,16973825,17170433,17367041,17498113,17563649,17760257,18153473,18219009,19202049,19398657,20643841,20840449,21364737,21495809,22544385,22937601,23003137,23461889,23855105,23920641,25100289,25296897,26214401,26542081,26804225,28180481,30081025,31129601,31457281,31981569,32243713,33226753,33488897,34799617,35258369,35651585,36175873,36372481,36765697,37027841,37224449,37486593,38273025,38535169,38731777,38862849,39190529,40239105,40304641],"carry":[3276805,7012357,9043973,14286853,19791876,20316165,30015492,36044810,39780357],"compute":[5963786,11272193,15335434,19529730,20971521,28966913,29425665,35061761,37748737,38141953,40697857],"cnd":[5963781,7012364,15335429,31195148,34996231],"computed":[19529729,37289985],"containing":[34537473],"construct":[15007745],"copied":[1835009],"char_ptr":[1310721,1441802,3407873,3735553,3932161,3997697,4784129,4980738,5046281,5177345,5701639,5832707,5963778,6160390,6946820,7274497,7667721,8257537,9502721,9895937,11075586,13303817,13500419,15335426,15728641,15794185,15925262,16187396,16318475,17235980,18415617,18939909,19857411,20119560,20250628,20447233,21037057,21102593,21168132,21233668,21561345,21757963,22020097,22216706,22609923,23265281,23986177,24117251,21823492,24444936,24510465,25165825,26083329,24903681,26345473,26476547,25690113,27066377,27131918,27328526,28246017,28311553,29360138,29622273,30277633,30474241,30539777,30867470,31391750,31850497,32178177,32505857,33161217,33685518,34406401,35192833,35323905,35520522,36306958,36831233,38338572,38404101,38928385,39059458,39256071,39321610,39387140,39518209,39911428,40108033,40173571,40763393,41287681],"constructors":[1441793,4063233,7864321,13434881,13631489,15007745,16842753,21430273,22282241,31653889,34013185,34537473,34603009],"considered":[6356993,7733249,10616833,12320769,17301505,30408705],"contain":[8454145],"consider":[22413313],"cofactor":[5963777,15335425,19529736],"codes":[5046273],"cpnverted":[18415617],"countp":[40173579],"calculation":[19464193,19791873,33030145,36044801,40173569,40632322],"chance":[21299201],"change":[5701633,5963778,15335426,24444929,33030145,39256065,40632322],"cleared":[2490369,29097985,38404097],"converted":[15925249,31850497,27066369,35192833,36831233],"conversions":[3997697,4390913,6422529,9109505,23068673,23789569,27787265,29491201,34734081,35192833,36306945,40763393],"clearly":[19791873,36044801],"complement":[2424833,4325377,5636097,5963784,6815745,10223617,10289153,12058625,12124164,12910593,15335432,16384004,18350081,22347777,23396353,30998529,32374785,33751041,38797313,39583745],"ceiling":[1376259,5963785,7077892,15335433,20381699,20709379,21954565,26935301,27197443,28704771,38207491],"cray":[21823489],"counts":[4063233,13631489],"condition":[7012353,31195137]} \ No newline at end of file diff --git a/docs/fti/FTI_Files.json b/docs/fti/FTI_Files.json new file mode 100644 index 0000000..d7a59ce --- /dev/null +++ b/docs/fti/FTI_Files.json @@ -0,0 +1 @@ +["GMP Native Interface for .NET - Redirect\u0000index.html\u000018","GMP Native Interface for .NET - Search\u0000search.html\u000015","FILE Methods\u0000html/00586c66-53ac-3fe3-16a4-3ceb2f94620b.htm\u0000125","gmp_lib.mpf_sqrt Method\u0000html/00a7e91d-b046-f5d3-5b51-55868d87e228.htm\u0000535","mp_exp_t Implicit Conversion (mp_exp_t to Int32)\u0000html/015f7dd6-55ab-71d0-316b-71a3f99799c3.htm\u0000141","mp_limb_t Implicit Conversion Operators\u0000html/015a8bc4-a8de-d7c7-3aac-2524de5dfd03.htm\u000095","gmp_lib.mpz_cmpabs_d Method\u0000html/011efd01-e7f0-47d8-7d1e-77888d96f0d4.htm\u0000491","mpz_t.ToIntPtr Method\u0000html/018d9747-3053-df6d-2bb3-5273ad735860.htm\u0000113","gmp_lib.gmp_urandomm_ui Method\u0000html/020d0663-b84b-54aa-8e2f-645ed532d175.htm\u0000395","gmp_lib.mpf_inits Method\u0000html/018278a0-148f-c898-5bd0-42aae4ae0069.htm\u0000407","void_ptr.Equals Method (Object)\u0000html/0177c7b6-b5d5-3815-b64a-4f3a7686bf6d.htm\u0000180","mp_exp_t Explicit Conversion Operators\u0000html/021c96a1-51fa-2b2a-4c65-7ae3bb374c33.htm\u0000151","mp_limb_t Explicit Conversion (Int64 to mp_limb_t)\u0000html/03a17ed9-19e1-9de3-0ea4-4ff3f63938a6.htm\u0000140","gmp_lib.mpz_kronecker_si Method\u0000html/0252e04b-b8fc-5a06-e1e2-a0cafbb44296.htm\u0000511","void_ptr.GetHashCode Method\u0000html/04ef14d3-d09c-cfcb-0cea-8984c92612f5.htm\u0000121","gmp_lib.mpq_cmp_ui Method\u0000html/03336561-2bb9-b38f-8adb-506e0fad094b.htm\u0000492","void_ptr.Equals Method\u0000html/0521b935-27ad-ca39-ed8a-6c4b4fc51116.htm\u000069","gmp_lib.mpn_sec_mul Method\u0000html/028e92d4-3699-77ff-e8da-9ff4c367f5b3.htm\u0000977","mpf_t Implicit Conversion (String to mpf_t)\u0000html/058e477a-0126-b073-ee83-77ed89a58351.htm\u0000195","gmp_lib.mpz_out_raw Method\u0000html/053b54b6-f646-f0aa-ddaf-00c494a6d5ef.htm\u0000899","gmp_lib.mpf_set_ui Method\u0000html/060aa73e-8c00-0a6b-f569-ad198c4f0d90.htm\u0000405","gmp_lib.mpz_cdiv_q_ui Method\u0000html/05b3707d-5f48-4d76-c42a-566f3179d7f8.htm\u0000689","char_ptr Structure\u0000html/06249483-9daf-95f9-32c7-30195550bbcc.htm\u0000267","gmp_lib.mpn_copyi Method\u0000html/00d8413a-b34b-5e89-193c-1bfe522710c5.htm\u0000507","mp_limb_t Explicit Conversion (Int32 to mp_limb_t)\u0000html/06428417-fb0b-82c7-4b50-99dfe28c7afb.htm\u0000139","gmp_lib.mpz_cmpabs_ui Method\u0000html/05f897c4-77dc-7735-81ca-65650f61d961.htm\u0000384","size_t Methods\u0000html/0777a4c0-90d5-95bc-1192-f390bfbcbc43.htm\u0000124","mp_size_t.Equals Method\u0000html/096397d8-2db8-7eeb-3b75-25ed0bad8379.htm\u000069","gmp_lib.reallocate Method\u0000html/067f64f9-7014-8c6a-3c02-153c1460a1dd.htm\u0000354","mp_bitcnt_t Methods\u0000html/0968b601-ff25-497d-c2eb-28487c3d29cf.htm\u0000124","gmp_lib.mpz_kronecker_ui Method\u0000html/07613c31-7d00-9806-1676-55f8c5a997f8.htm\u0000512","gmp_lib.mpn_sec_sub_1_itch Method\u0000html/098c8787-2069-5d1e-a2f9-1f78bdcd60a9.htm\u0000207","gmp_lib.mpn_random2 Method\u0000html/06d850ef-82b2-56f1-32ae-2f1724da3d5b.htm\u0000395","gmp_lib.mpn_sec_div_r Method\u0000html/094ea390-8cc8-bac7-35c3-3616775736de.htm\u0000874","mp_exp_t Explicit Conversion (mp_exp_t to Int16)\u0000html/0c44ebce-9678-a295-598a-588046225af2.htm\u0000141","gmp_lib.mpz_fdiv_q_ui Method\u0000html/0dcf05e1-ec39-5294-c4d0-d8e0f92642e4.htm\u0000681","mp_bitcnt_t.ToString Method\u0000html/0dd7a5d2-ab07-87dc-79d2-d9b361bc0a34.htm\u0000124","gmp_lib.mpz_ior Method\u0000html/0ccb1bab-4817-1062-242d-41c181cacf77.htm\u0000658","gmp_lib.mpf_init Method\u0000html/0dd846ac-56b6-3ea8-0441-12490f67fbf7.htm\u0000422","gmp_lib.mpz_lucnum2_ui Method\u0000html/0cdaca8f-816e-8c22-f46b-fcf58e9e91d4.htm\u0000631","mpq_t Properties\u0000html/0e7e8afb-9c1f-87e4-4f01-0575c8203613.htm\u000049","mpf_t Constructor\u0000html/0e0a10d5-52ab-1821-6fe1-97514e009418.htm\u000090","mp_size_t Implicit Conversion Operators\u0000html/13c05087-b2db-4751-d548-4fa64e30f663.htm\u0000123","gmp_lib.mpq_sgn Method\u0000html/1176cc4e-ffda-2993-1a4a-2e0c7ed24adb.htm\u0000422","gmp_lib.mpn_xor_n Method\u0000html/0f01fecd-9200-982d-c331-c213f3b960a1.htm\u0000680","mp_exp_t.GetHashCode Method\u0000html/1443760d-18a5-f276-ec75-7b8ead9d8332.htm\u0000121","gmp_lib.mpf_fits_sshort_p Method\u0000html/142199e1-6aef-83d5-1986-1b1248ddc6e3.htm\u0000402","mpz_t._mp_size Property\u0000html/15e1db51-a27c-7eee-03dd-5c6457889be1.htm\u0000167","gmp_lib.mpf_integer_p Method\u0000html/11a036ec-5052-7dc4-bdb6-10e5c92f88cc.htm\u0000412","mp_base._mp_size Property\u0000html/178d8d44-2485-2972-fe2f-eb9848059e6f.htm\u0000120","gmp_lib.mpn_sec_add_1 Method\u0000html/1555cd52-98d2-6253-214a-d342a539bfb5.htm\u0000895","gmp_lib.mpz_fac_ui Method\u0000html/17280f99-d0dc-6714-12c7-be17c97c0cdb.htm\u0000376","gmp_lib.mpq_swap Method\u0000html/11e36fbc-ffc4-46df-50b7-2b07684c1755.htm\u0000604","void_ptr Fields\u0000html/12a4c9d6-02cf-e913-816e-ad530e77722c.htm\u000038","gmp_lib.mpz_mul_2exp Method\u0000html/18cd39f5-7c88-f557-3803-8a4a321cfb97.htm\u0000582","size_t Implicit Conversion (UInt16 to size_t)\u0000html/18ef1696-938e-0932-1d55-eaced0d92464.htm\u0000140","gmp_lib.free Method (void_ptr, size_t)\u0000html/19ccd2e3-05f1-d4f4-79b7-28b4f26e5768.htm\u0000227","gmp_lib.mpf_init_set Method\u0000html/17b3dc26-68af-fb0c-9923-36777e8bd87e.htm\u0000508","ptr(T) Constructor\u0000html/1b117248-4e1d-a985-2ab6-4bd8e5b3e769.htm\u000052","gmp_lib.mpf_abs Method\u0000html/17731ba4-bf91-6b9b-737a-a9cc306ba17d.htm\u0000539","gmp_lib.mpq_canonicalize Method\u0000html/19d53697-65f1-2df5-62f3-988182af0c88.htm\u0000242","gmp_lib.mpq_set_d Method\u0000html/1a7c5874-9132-2c43-e407-df1eead74fab.htm\u0000430","mp_bitcnt_t Structure\u0000html/1b2b1d64-20c1-7a64-0278-d9ff58ee9cc3.htm\u0000528","gmp_lib.gmp_vsscanf Method\u0000html/1a966758-12dc-4da3-cb22-b3b3d788ba02.htm\u0000779","mp_size_t Explicit Conversion (mp_size_t to UInt16)\u0000html/1babcb9f-d828-81fb-30d5-296cccd21929.htm\u0000142","gmp_lib.mpf_get_default_prec Method\u0000html/1ca4ec7e-b5d1-3b51-8341-5a345990e62d.htm\u0000312","gmp_lib.mpn_iorn_n Method\u0000html/1b76ffd8-d7f4-5309-3b10-e7e0c418706a.htm\u0000686","mpz_t Type Conversions\u0000html/1cc35e31-9ab0-7239-d05b-1e2a426338bc.htm\u000046","FILE Structure\u0000html/1bcc07bd-8fee-1107-844c-a5ff10e7660c.htm\u0000234","gmp_lib.mpn_sec_sqr_itch Method\u0000html/1ba86b5b-8ace-b6ee-99c5-32a8d7648519.htm\u0000199","gmp_lib.mpn_sec_div_r_itch Method\u0000html/1cefa5f6-adc3-30a6-b3bd-cb6a7543cb00.htm\u0000254","mp_limb_t.GetHashCode Method\u0000html/1bd10056-1935-a793-4930-68ebfaf82cd1.htm\u0000121","gmp_lib.mpz_sqrt Method\u0000html/1e1204c7-2d33-c9d1-4f4e-c36215f5ebed.htm\u0000485","gmp_lib.mpf_set_d Method\u0000html/1d0c5734-9f0d-ec6b-c540-4379f832b0ca.htm\u0000418","mp_bitcnt_t Explicit Conversion (mp_bitcnt_t to Byte)\u0000html/1d378f21-73e1-43e7-e286-5a6c0cb101ba.htm\u0000142","mp_limb_t Methods\u0000html/1e30b810-66a8-52cc-8501-8bdda18bfaa7.htm\u0000124","char_ptr.ToString Method\u0000html/1eedfa7e-7135-6b5d-e395-9a6b90fab236.htm\u0000128","gmp_lib.mpn_get_str Method\u0000html/1e9cacd7-32b3-7f3b-659a-efdb3e064092.htm\u0000810","gmp_lib.mpn_divexact_1 Method\u0000html/1d6343a5-d42c-c362-714e-e10730e6a6d5.htm\u0000798","gmp_lib.mpz_set_si Method\u0000html/1ffac718-d814-0556-ea54-dbf1d676e0cc.htm\u0000409","gmp_lib.mpq_abs Method\u0000html/1f2250c3-a1b8-db12-19e4-9946e39eb64c.htm\u0000265","size_t Explicit Conversion Operators\u0000html/1f76425d-66dd-c23e-2032-d6f1f2337813.htm\u0000179","gmp_randstate_t Constructor\u0000html/20a4edb9-f361-6367-9965-64b0f7aeddaa.htm\u0000110","gmp_lib.mpf_fits_uint_p Method\u0000html/201b1b12-bb0c-6a53-c6d5-e75db73f8470.htm\u0000403","gmp_lib.mpf_mul_2exp Method\u0000html/2041c81e-218b-b514-5a7b-5ee315711bc9.htm\u0000585","gmp_lib.gmp_randinit_lc_2exp Method\u0000html/21fdbc76-a0de-1f3a-195f-a5ae0cb3d1da.htm\u0000550","gmp_lib.mpz_tstbit Method\u0000html/20a476ea-9a38-9ef3-1e23-da2b2eba69a9.htm\u0000462","gmp_lib.mpz_realloc2 Method\u0000html/1de9b70a-1d21-8168-e41c-1c259f64091a.htm\u0000693","mp_bitcnt_t Explicit Conversion (UInt64 to mp_bitcnt_t)\u0000html/22aee6e2-0a8a-0514-baa1-2f6882b60174.htm\u0000141","gmp_lib.mpz_getlimbn Method\u0000html/1dfbf5da-f4c2-bbab-5708-3b31d40e4f16.htm\u0000678","gmp_lib.mpn_gcd Method\u0000html/24ecd2d5-422f-e538-fd43-94b749652393.htm\u0000773","gmp_lib Methods\u0000html/0fa7cbf3-e8f4-6b14-d829-8aa663e77c74.htm\u00007248","mpz_t Constructor\u0000html/0fcbb911-bc5a-1b11-90c5-96babff86526.htm\u000088","size_t.Equals Method\u0000html/255140dc-27a7-cc9d-df9a-dc4d03c9a8e4.htm\u000069","char_ptr Constructor\u0000html/255d9de2-3cf6-50f3-3276-a4332896da07.htm\u0000143","size_t Explicit Conversion (Int32 to size_t)\u0000html/25c0e500-2d89-f414-530f-a0a53b57766f.htm\u0000139","mpf_t Methods\u0000html/2583789b-09c3-0f9a-fbf9-4d362bd9129a.htm\u0000163","gmp_lib.mpz_perfect_square_p Method\u0000html/260d6edf-ce02-26f7-d704-ad0d11604e61.htm\u0000402","mpq_t Type Conversions\u0000html/25bb755c-4475-9382-5601-dd83fda02afe.htm\u000046","gmp_lib.mpz_root Method\u0000html/279877e1-b8d0-f52c-16ba-b2e38e671437.htm\u0000546","mpq_t Constructor\u0000html/2c2936bd-f40b-391b-de4c-e5111654993b.htm\u000088","gmp_lib.gmp_sscanf Method\u0000html/279d21b9-bd04-522e-0759-d1add6fe6fae.htm\u0000779","mp_size_t Implicit Conversion (mp_size_t to Int64)\u0000html/289280eb-add9-3787-a6bf-8e9766849efd.htm\u0000142","mp_exp_t Explicit Conversion (mp_exp_t to SByte)\u0000html/2c30c503-671c-e6f1-38a8-3a42f51f8019.htm\u0000142","gmp_lib.mpn_xnor_n Method\u0000html/25d623c3-ee22-4b83-1161-3f98ce698012.htm\u0000688","free_function Delegate\u0000html/2c9876e2-a0f5-14c6-5069-1a9d50b89185.htm\u0000159","char_ptr.Equals Method\u0000html/2d2c429f-5828-694d-2ad7-9d13e5c412b3.htm\u000069","gmp_lib.mpn_cnd_add_n Method\u0000html/27902901-3a7d-b5b3-d3fc-3900f754bff1.htm\u0000975","gmp_lib.mpz_cdiv_ui Method\u0000html/290eb509-85df-a0cc-86f8-ac4e6f5d730a.htm\u0000551","gmp_lib.mpq_denref Method\u0000html/2d93abcb-e73f-fe40-a50b-395a0bf6a4fc.htm\u0000474","mp_bitcnt_t Explicit Conversion (Int16 to mp_bitcnt_t)\u0000html/29b5075a-d6d3-6fe8-5125-d679317b1022.htm\u0000139","gmp_lib.mpz_init_set Method\u0000html/2c37941c-dee7-0d74-7889-3fa6c20bab6a.htm\u0000475","gmp_lib.mpz_divexact Method\u0000html/2ddc32dc-4ee3-18e9-dd3d-7e64c3304e1e.htm\u0000620","gmp_lib.mpn_zero_p Method\u0000html/2e469258-d5e3-da86-aebe-025b92d7cf73.htm\u0000387","gmp_lib.allocate Method\u0000html/2c68671c-cd5c-e2ec-52a2-65b0ca31c3d1.htm\u0000174","gmp_lib.mpz_random Method\u0000html/2b0da39e-331c-878e-26c7-bd6d81c7f8e0.htm\u0000460","gmp_lib.mpz_cmp_si Method\u0000html/2e55f6fd-0083-fc85-0d42-65e472376dbe.htm\u0000414","gmp_lib.gmp_vsnprintf Method\u0000html/300c388f-ba1c-0ba3-64fd-e7aafb39dcdb.htm\u0000845","gmp_lib.mpz_congruent_p Method\u0000html/2ff1eb0a-f399-2ad2-f7d1-3fb51dceac10.htm\u0000688","mp_bitcnt_t.Equals Method (mp_bitcnt_t)\u0000html/306b1c06-9439-c811-b7b9-42777ca691e6.htm\u0000161","mpf_t Class\u0000html/37c88d6c-8d02-2330-ad77-f20fb73d1677.htm\u0000417","gmp_lib.mpf_ui_div Method\u0000html/34a39f93-359c-526f-c9ad-cd7558968f1e.htm\u0000634","gmp_lib.mpz_mul Method\u0000html/3523bf0e-75ec-6286-76a0-4685198e51f6.htm\u0000635","gmp_lib.mpf_mul Method\u0000html/309e6a8c-1318-2d30-a058-f119193546a0.htm\u0000665","gmp_lib.mpf_div_ui Method\u0000html/3985111a-6d13-b418-9c90-422a8e1e5b8b.htm\u0000506","gmp_lib.mpz_tdiv_qr Method\u0000html/387ec1dd-15b3-4cc9-862a-e3f0a8e2cb78.htm\u0000822","gmp_lib.mpf_set Method\u0000html/3a025035-e715-0a3d-8d2d-6011430c9463.htm\u0000542","gmp_lib.gmp_vfscanf Method\u0000html/316be139-2970-161f-ba7c-730f067b5cf3.htm\u0000960","gmp_lib.mpf_div_2exp Method\u0000html/352401d6-c6d1-29c1-a9f6-e5e0ed46bc86.htm\u0000592","gmp_lib.mpz_limbs_finish Method\u0000html/398e3eb8-0f55-086f-a765-0a8b3c9307e0.htm\u0000388","mp_limb_t.Equality Operator\u0000html/2e8177f2-fc95-380b-ef64-a51cf494c686.htm\u0000189","mp_ptr Constructor\u0000html/33563f2c-baba-b555-20fb-9def8b70074c.htm\u0000110","gmp_lib.mpz_jacobi Method\u0000html/38be0c24-42ac-e0ea-9e18-e75e3bda2a1e.htm\u0000472","mp_size_t Explicit Conversion (mp_size_t to Int16)\u0000html/339354f8-0924-d332-2217-0b06b81f5e5a.htm\u0000141","gmp_lib.mpf_inp_str Method\u0000html/3a24f5bd-0b45-8164-f27b-c2e04e35ab64.htm\u0000800","mp_exp_t Implicit Conversion (SByte to mp_exp_t)\u0000html/2f9a1c6d-82f4-6ef2-476a-8231d6b7d497.htm\u0000140","gmp_lib.mpf_clear Method\u0000html/3a2a17ed-a64c-8716-7f65-18c661a5279f.htm\u0000394","gmp_lib.mpq_inp_str Method\u0000html/38d3a9de-bae7-3f44-18e0-38fe450d4cba.htm\u0000837","gmp_lib.mpn_add_n Method\u0000html/339edb73-5781-7d73-97b6-9b73451a698f.htm\u0000902","mpf_t Type Conversions\u0000html/3ca44c9f-677e-d5fa-5414-399843506633.htm\u000046","mp_limb_t.Equals Method (Object)\u0000html/33b840cd-1b41-ad67-8956-b5811ddc6175.htm\u0000180","gmp_lib.mpq_inv Method\u0000html/3b01109c-5b01-16d2-edd0-5ac3d5514930.htm\u0000279","gmp_lib.gmp_set_memory_functions Method\u0000html/3568dd4d-d565-0b12-2da2-2fed2d433257.htm\u0000852","mp_size_t Implicit Conversion (SByte to mp_size_t)\u0000html/3bab30e1-4da4-b2cd-ea9c-9f06097052e6.htm\u0000140","mp_limb_t Explicit Conversion (mp_limb_t to SByte)\u0000html/3cd34dae-2d2e-5efd-cc59-e555d879812a.htm\u0000142","gmp_lib.mpz_set Method\u0000html/3a4e6141-0771-f9ac-2283-5e9348f86d4a.htm\u0000521","gmp_lib.mpz_fits_uint_p Method\u0000html/3ce0cc26-e888-90f8-a517-aad88332eec0.htm\u0000383","mp_limb_t Explicit Conversion (SByte to mp_limb_t)\u0000html/3006d511-ecd7-0e95-44e1-b9effd406cbf.htm\u0000140","gmp_lib.mpn_popcount Method\u0000html/3bd9de08-5768-bb79-1e09-2953ae1483aa.htm\u0000402","size_t.Equals Method (Object)\u0000html/3c3a57f3-ab98-976d-e470-2b8da8c97b53.htm\u0000180","gmp_lib.mpf_neg Method\u0000html/357791cb-951d-5542-ff67-c00ef5e9aadb.htm\u0000529","gmp_lib.mpz_get_ui Method\u0000html/3a92eddc-59f3-b42f-9921-4e1cc5700d60.htm\u0000394","gmp_lib.mpn_sec_tabselect Method\u0000html/3588cf60-567a-6182-20e8-5e2836498f49.htm\u0000750","gmp_lib.mpf_trunc Method\u0000html/3ac2ecd4-f154-de62-9170-b2d28f362a7e.htm\u0000540","mp_base Constructor\u0000html/3e385e89-d6d3-27df-ec51-6580f6bea08b.htm\u000089","gmp_lib.gmp_get_memory_functions Method\u0000html/37510828-012a-9e6a-7916-776acfd8f1f9.htm\u0000449","gmp_lib.mpz_scan0 Method\u0000html/3e36be2b-14ed-eb7b-0546-af6d49e983fa.htm\u0000569","gmp_lib.mpz_and Method\u0000html/3e5268ed-796b-2880-93a3-8d17143f99b1.htm\u0000655","gmp_lib.mpz_cmpabs Method\u0000html/3e06d348-8a15-691d-5889-ab3f1a4c9f73.htm\u0000532","gmp_lib.gmp_version Field\u0000html/3f1b2832-ff9c-cc4a-3e85-e2ee16acc69b.htm\u0000196","void_ptr.ToIntPtr Method\u0000html/3e1375c2-3f44-721d-6ef3-32e49a3d7d3b.htm\u0000107","size_t Implicit Conversion (size_t to UInt64)\u0000html/4089ae7b-a5ca-3feb-37ce-f5f4e627dde7.htm\u0000143","gmp_lib.mpz_congruent_ui_p Method\u0000html/3eae225a-8db3-3b14-d862-03718f3a5548.htm\u0000538","gmp_lib.mpq_cmp Method\u0000html/3f29d5f4-13ae-cec8-ea75-6a76d00d10fc.htm\u0000550","void_ptr.Equality Operator\u0000html/3d7c5927-d163-5d46-1f0b-5c35ca116b22.htm\u0000189","mpq_t._mp_num Property\u0000html/3fad7a3a-76d1-7e19-0ab4-c93a4bf3655e.htm\u0000123","size_t Explicit Conversion (size_t to Int16)\u0000html/4137f93d-8fb6-8ae8-3961-eeba189925e6.htm\u0000141","size_t Explicit Conversion (size_t to SByte)\u0000html/44012ded-01f3-9156-80d0-0df7ee0b048c.htm\u0000142","void_ptr.Zero Field\u0000html/3fce2dbc-bac6-d24f-d6d4-84454567b8f5.htm\u000094","char_ptr.ToIntPtr Method\u0000html/42a15292-978c-35c6-bfa3-9d5acf725ca7.htm\u0000107","mpz_t Methods\u0000html/430d894e-57e0-6020-0ad7-40b74cbd969f.htm\u0000161","gmp_lib.mpz_divexact_ui Method\u0000html/3ddee65c-a067-79a3-968d-31f3d585db3b.htm\u0000547","gmp_lib.mpz_bin_uiui Method\u0000html/402dc8d2-32bd-59ad-80f3-4bd2cc000b0d.htm\u0000420","gmp_lib.mpz_inp_raw Method\u0000html/44097b06-123a-4c00-b17f-ab0c70ad78bb.htm\u0000729","gmp_lib.mpq_div Method\u0000html/433b0777-4514-5b20-7494-f0f2746fe8e5.htm\u0000296","ptr(T).Value Field\u0000html/448dfb4b-f4d7-8db7-3d44-31f3bd032771.htm\u000094","mp_size_t Explicit Conversion (UInt64 to mp_size_t)\u0000html/43436692-e9c9-739f-aa96-be2b775dae62.htm\u0000141","mpf_t Properties\u0000html/44d8440b-0daa-0393-510e-a0ace6d299f7.htm\u0000104","gmp_lib.mpf_sqrt_ui Method\u0000html/44e6038b-2e97-b53d-0d46-ce1fff3522d0.htm\u0000458","gmp_lib.mpf_set_prec Method\u0000html/438e6843-fc7b-4e6f-9ac0-d97a2773b032.htm\u0000485","size_t Explicit Conversion (size_t to Int32)\u0000html/47fd5e17-2217-5e2f-8d68-440cfcf85179.htm\u0000141","gmp_lib.mpz_fdiv_qr_ui Method\u0000html/452a9316-f421-a65c-a9ba-254b201dc431.htm\u0000797","gmp_lib.mpq_cmp_si Method\u0000html/43cb2c87-9fab-eb9d-2f7a-140d72af7b15.htm\u0000488","mp_exp_t.Equality Operator\u0000html/4a543b73-f62d-cf04-fa49-22bc93e657e7.htm\u0000189","gmp_lib.mpz_scan1 Method\u0000html/480d1d15-b561-ac8f-b12a-f27ba075b3f2.htm\u0000569","gmp_lib.mpz_combit Method\u0000html/4a959468-7670-9303-a5e7-3f1de8f17a62.htm\u0000466","gmp_lib.gmp_errno Property\u0000html/4c3f1727-1891-2918-da3a-321930e883ed.htm\u0000132","gmp_lib.gmp_randinit_set Method\u0000html/494fa261-4044-f216-7041-a55d95a26f5b.htm\u0000406","gmp_lib.mpz_divisible_p Method\u0000html/4bafc7fe-d2a8-7cf2-b9b8-c296550b4ef2.htm\u0000557","gmp_lib.mpz_tdiv_q Method\u0000html/4c830876-cdf6-9d94-1ceb-24d30f873bc2.htm\u0000686","gmp_lib.mpf_size Method\u0000html/4c81a27a-206c-e5da-44e9-0ac7767b3366.htm\u0000349","gmp_lib Properties\u0000html/4c8c8860-0cde-fd90-76f1-81cd6fb7a125.htm\u000041","mp_size_t Implicit Conversion (Int32 to mp_size_t)\u0000html/4d1fd187-6b51-f72c-b150-3cc4eb7ead18.htm\u0000139","gmp_lib.mpz_rrandomb Method\u0000html/4be917d3-47c6-cb58-d768-6276e78f0afb.htm\u0000645","gmp_lib.mpf_add_ui Method\u0000html/45a76d5c-c5bf-e7f8-906a-15d290e9a50d.htm\u0000572","FILE.Equals Method\u0000html/4e0b1b66-de5f-3451-d835-df0116b8c789.htm\u000069","gmp_lib.mpf_div Method\u0000html/4e876639-72f5-7659-f4a9-862639e27e1c.htm\u0000719","gmp_lib.mpz_hamdist Method\u0000html/4dfb8bd5-8a6f-6919-7aa9-8c060d42b5d7.htm\u0000621","gmp_lib.mpq_get_num Method\u0000html/4f98333c-76a2-db46-cbba-97785a449450.htm\u0000600","gmp_lib.mpz_gcd Method\u0000html/4e14cfc4-6f8b-14f7-74df-2f4415ce6f1c.htm\u0000619","gmp_lib.mpz_addmul_ui Method\u0000html/4e93c4c4-d799-2828-5285-8a3f3ed02ad3.htm\u0000573","gmp_lib.mpf_cmp_d Method\u0000html/4f0f115a-3956-13f7-4d6f-0157936c03bd.htm\u0000466","gmp_lib.mpn_cmp Method\u0000html/4fcc5434-e328-6730-f46e-bd0823ec7560.htm\u0000491","gmp_lib.mpf_init_set_str Method\u0000html/4e30a5e0-637b-949e-a627-387a56945f7b.htm\u0000578","gmp_lib.mpz_divisible_2exp_p Method\u0000html/4f821e78-facb-4ea2-ab21-62d1f5049e68.htm\u0000444","mp_ptr Class\u0000html/4609ac5e-5cf9-cd20-2fa9-8040101c165c.htm\u0000389","gmp_lib.mpz_limbs_read Method\u0000html/4b08344c-f506-a717-4e1d-112cd19f5286.htm\u0000597","mp_limb_t Implicit Conversion (UInt16 to mp_limb_t)\u0000html/4e7a1224-4cf6-269a-82b6-8fdb83429949.htm\u0000140","mp_size_t Structure\u0000html/4b58a584-7a0e-b600-18fa-ebd493861eb3.htm\u0000538","FILE Operators\u0000html/4fe7aa66-0d05-7853-360a-72c4b55b69bd.htm\u000059","size_t Constructor\u0000html/4a5eee32-b03c-e613-22b1-6b4f54a95362.htm\u0000125","gmp_lib.mpq_set_den Method\u0000html/52388f4c-575a-9b13-41a6-e7ec2bd0becd.htm\u0000549","gmp_lib.mpz_congruent_2exp_p Method\u0000html/4b6a07f8-2a61-d1a3-7192-f2907292bf2a.htm\u0000598","gmp_lib.mpz_clear Method\u0000html/551f8670-3080-9a92-cd50-58d09cbf77ef.htm\u0000334","gmp_lib.gmp_fscanf Method\u0000html/50306850-d92d-5038-bbcc-c452cd3c69a9.htm\u0000960","ptr(T) Fields\u0000html/50e025ca-c11a-c1db-2233-d11f66776439.htm\u000045","gmp_lib.mpz_probab_prime_p Method\u0000html/52ce0428-7c09-f2b9-f517-d3d02521f365.htm\u0000465","size_t.Equality Operator\u0000html/46b18925-3e4b-f26c-ef9c-ade34e23f518.htm\u0000189","gmp_lib.mpn_add_1 Method\u0000html/5562b14f-48a4-be75-2eb0-6a129cd0d5ab.htm\u0000782","mpq_t Implicit Conversion (String to mpq_t)\u0000html/5d499247-7cb9-266f-eb4f-78bcf5768aa4.htm\u0000199","gmp_lib.mp_bytes_per_limb Field\u0000html/47695d57-9a89-48db-97c3-2ed03965d913.htm\u0000174","gmp_lib.mpf_cmp_z Method\u0000html/5236d7a8-b79f-add8-4898-997e9d6a68bf.htm\u0000515","gmp_lib.mpz_sub Method\u0000html/53702772-53e9-ec51-c3a5-7a1912b4f2b4.htm\u0000621","mp_bitcnt_t Implicit Conversion (UInt16 to mp_bitcnt_t)\u0000html/55809d71-2a62-422c-a7e5-955b2b62fe37.htm\u0000140","mp_bitcnt_t.GetHashCode Method\u0000html/540dc183-f6ab-a0bb-d6ef-a08f5a464b78.htm\u0000121","gmp_lib.mpf_fits_sint_p Method\u0000html/5ea7691b-2a0f-5f25-290c-54c78e2cf3bd.htm\u0000402","gmp_lib.mpz_mul_ui Method\u0000html/5fba9944-4437-9b1c-afa0-666d87eafe39.htm\u0000568","mpz_t Properties\u0000html/5f492d5c-72f0-17b4-24a4-e5b58a061ef7.htm\u000086","mp_bitcnt_t Explicit Conversion (mp_bitcnt_t to Int16)\u0000html/55d30a4b-ca4f-4f4b-208a-026c54586e64.htm\u0000141","ptr(T) Class\u0000html/542faa00-d28a-72a2-2dd8-6c6021e683ce.htm\u0000393","gmp_lib.mpn_sec_invert Method\u0000html/62ffb793-b32f-e0dc-a399-f20fe708a803.htm\u0000867","gmp_lib.mpz_odd_p Method\u0000html/6820d6c4-6ee1-53d7-7223-3f654a496ce4.htm\u0000381","mp_ptr Constructor (UInt16[])\u0000html/54ac0eda-b14f-8083-16dc-6c0abe8a5e5e.htm\u0000189","mp_ptr.Size Property\u0000html/562de56d-c1a8-5f66-59dc-e2886d89bfc3.htm\u0000110","gmp_lib Class\u0000html/3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm\u00007412","mpq_t Methods\u0000html/6871c168-60e1-5bd2-5a03-2d60f473d7b8.htm\u0000161","gmp_lib.mpz_fdiv_r Method\u0000html/5dfc0ea9-a81f-bda9-356c-034395ba3c9c.htm\u0000699","gmp_lib.mpz_fits_ushort_p Method\u0000html/6b85c6a3-d6c5-d1d2-829a-af000bae687e.htm\u0000384","gmp_lib.mpz_kronecker Method\u0000html/54ba330f-67d3-fa30-2d5f-0480b7f4659c.htm\u0000589","mp_bitcnt_t Implicit Conversion (mp_bitcnt_t to UInt64)\u0000html/6b870324-3daa-70e6-ded7-2757f5755310.htm\u0000143","gmp_lib.gmp_printf Method\u0000html/5c2015f3-41d2-7b80-5309-e41ccec0baaf.htm\u0000475","gmp_lib.gmp_vsprintf Method\u0000html/56e1a610-d238-ab9f-87b5-001764290847.htm\u0000728","gmp_lib.mpq_set_num Method\u0000html/6885ad71-c185-1e0c-abc8-4320e12f377a.htm\u0000545","gmp_lib.mpz_get_str Method\u0000html/54c1f778-6fc8-0056-6f25-26f6754645fb.htm\u0000659","mp_bitcnt_t Explicit Conversion (Int64 to mp_bitcnt_t)\u0000html/56fbe432-4b26-efff-13e9-242996bfa78d.htm\u0000140","gmp_lib.mpn_perfect_power_p Method\u0000html/61401484-d06f-ab9e-110d-b46f4d0a9eba.htm\u0000389","gmp_lib.mpn_mul Method\u0000html/68d3161d-2909-1909-cda7-e87949ee27ce.htm\u0000910","gmp_lib.mpz_roinit_n Method\u0000html/5786e0c6-2dde-406f-b86d-3df6757c80c0.htm\u0000834","void_ptr Operators\u0000html/578ac23c-2986-d809-fa1b-c9a111d0c780.htm\u000059","gmp_lib.gmp_snprintf Method\u0000html/61686857-e4a0-ad60-1419-2b87a79b06c1.htm\u0000865","gmp_lib.mpz_com Method\u0000html/635ddf01-9c52-0d37-202e-c560b895fb7d.htm\u0000550","gmp_lib.mpz_ui_pow_ui Method\u0000html/6101fda5-1230-66a9-5aff-5d8da426e364.htm\u0000441","mp_limb_t Explicit Conversion (mp_limb_t to Byte)\u0000html/6991a24e-345d-029c-c189-ed263640928b.htm\u0000142","mp_size_t Implicit Conversion (mp_size_t to Int32)\u0000html/57c5f9bf-43e8-b575-90c8-23c0e366fb2d.htm\u0000141","mp_bitcnt_t Implicit Conversion (UInt32 to mp_bitcnt_t)\u0000html/6280cd97-b728-ab06-89e1-7181e2ab72fe.htm\u0000140","size_t Explicit Conversion (SByte to size_t)\u0000html/5c1d434c-5d85-dea7-ac47-09126d92900d.htm\u0000140","gmp_lib.mpn_and_n Method\u0000html/69ffabc9-a19c-6590-d918-fbf0710aff82.htm\u0000679","mpq_t Class\u0000html/635f1879-5f85-881e-cca8-3222baf5045a.htm\u0000290","gmp_lib.mpz_init2 Method\u0000html/5cd3a242-93b7-49c5-b9c9-1dca02ed4662.htm\u0000493","mp_exp_t Explicit Conversion (UInt64 to mp_exp_t)\u0000html/6b879622-df00-c9b2-deba-307574416ff2.htm\u0000141","gmp_lib.gmp_vfprintf Method\u0000html/62c5f2f4-2a93-e6d2-b867-23d4f2b98af4.htm\u0000681","size_t.GetHashCode Method\u0000html/6feeab0d-dc91-818f-ef60-2434ff3a1146.htm\u0000121","mp_exp_t Explicit Conversion (Int64 to mp_exp_t)\u0000html/70eabcfd-22ae-e08e-1bc5-54f8e1ccb736.htm\u0000140","gmp_lib.mpz_set_str Method\u0000html/6a3819df-abc1-ceb1-a5c7-87a879977b8c.htm\u0000706","gmp_lib.mpz_divisible_ui_p Method\u0000html/6c026976-a6c9-6f12-6b31-c113166ea236.htm\u0000480","mp_bitcnt_t Explicit Conversion (Int32 to mp_bitcnt_t)\u0000html/6ba37de9-82cf-e884-2537-0d8e83b8ffa0.htm\u0000139","mpz_t.ToString Method\u0000html/709eb598-ee38-4031-9dc5-74a73d8f9142.htm\u0000122","mp_limb_t Explicit Conversion (mp_limb_t to Int64)\u0000html/63e2f5c3-b5bb-ebf6-3bcf-682671a0dbc3.htm\u0000142","mp_exp_t Explicit Conversion (mp_exp_t to UInt32)\u0000html/6b71bf90-ded3-6f2b-f59b-19b7e3442ef4.htm\u0000142","gmp_lib.mpf_fits_slong_p Method\u0000html/6c178e2d-a080-13b8-75b0-3fe232b46d75.htm\u0000402","gmp_lib.mpz_addmul Method\u0000html/582a0647-1482-ecd7-cc78-bd2222610e06.htm\u0000634","size_t Implicit Conversion (Byte to size_t)\u0000html/6d0766fc-29bc-75e6-aa00-ed7b80fe586e.htm\u0000140","gmp_lib.mpz_fib_ui Method\u0000html/71884691-07d0-7bdf-c761-df9b07723735.htm\u0000445","mp_bitcnt_t Constructor\u0000html/5846cdbc-83b9-0197-aa29-fd226641eb76.htm\u0000124","gmp_lib.mpn_gcd_1 Method\u0000html/64373933-f98b-74b4-c10f-3b1a98c410bc.htm\u0000442","gmp_lib.mpn_random Method\u0000html/6d4f993a-1fd6-9db2-c0a7-0f3926863565.htm\u0000395","gmp_lib.mpf_sub Method\u0000html/718e7623-d25b-8a09-2543-745f24cd82c1.htm\u0000665","mp_size_t Explicit Conversion (mp_size_t to Byte)\u0000html/6eb39888-e104-5cdd-a22d-c1240ef748e4.htm\u0000142","mp_limb_t Explicit Conversion (mp_limb_t to Int32)\u0000html/72723d8b-579c-0c0f-d5c8-868ae849457e.htm\u0000141","gmp_lib.mpq_mul Method\u0000html/584834ae-b1f7-d965-2586-f88d5c9b4f67.htm\u0000296","gmp_lib.mpn_com Method\u0000html/6f0c915a-514a-fce0-957b-50180f4b79a7.htm\u0000595","gmp_lib.mpf_get_d Method\u0000html/648fa405-45d3-506a-f6be-72642e8a7f32.htm\u0000464","mp_bitcnt_t Implicit Conversion Operators\u0000html/72fbcc09-5765-7f60-3897-57fec21cc9f9.htm\u0000109","void_ptr.FromIntPtr Method\u0000html/650e9cdb-0392-1173-aba8-9a1d6fc6a694.htm\u0000148","gmp_lib.mpf_cmp_ui Method\u0000html/5a168ae0-405b-7259-0853-84999876c47a.htm\u0000441","mp_exp_t.Equals Method\u0000html/5a3c38b8-5205-bc81-58e8-60b155c0579c.htm\u000069","gmp_lib.mpn_sec_div_qr Method\u0000html/6f1dca2b-39f4-3acd-71fb-4f1e5a0d04e6.htm\u00001197","gmp_lib.mpz_add_ui Method\u0000html/7327aa92-1ab5-7553-7eee-7b5e3e61322a.htm\u0000467","gmp_lib.mpz_out_str Method\u0000html/6f85986d-b6a0-435d-3675-c025ef70413d.htm\u0000787","char_ptr Methods\u0000html/73876566-4eec-b421-e4d6-3593e9641f0a.htm\u0000135","gmp_lib.mpz_tdiv_q_ui Method\u0000html/67fc54a2-05e7-bc3c-64f4-8c6de48fa6b6.htm\u0000690","gmp_lib.mpz_neg Method\u0000html/5a61d62c-a0f0-5e86-b6dd-8ca6414b35ed.htm\u0000494","mp_size_t.Equals Method (Object)\u0000html/764c23ab-f2fe-b3e4-68a4-4a27fb6dc6b0.htm\u0000180","size_t Explicit Conversion (size_t to UInt16)\u0000html/784c4122-3a62-f338-0e4a-88b6a69a1e9e.htm\u0000142","FILE Fields\u0000html/76b37dae-ecff-2bd9-2e80-002354a7dddc.htm\u000038","gmp_lib.mpz_fdiv_r_ui Method\u0000html/772064e8-3ec1-840e-c79c-78f478321b6c.htm\u0000702","mp_exp_t Explicit Conversion (UInt32 to mp_exp_t)\u0000html/78fdf4c2-15a1-fdab-23fa-806cdf3dc983.htm\u0000140","mpf_t._mp_prec Property\u0000html/772c3bd8-b9ec-225d-3d98-e17ae89d4294.htm\u0000135","gmp_lib.mpn_gcdext Method\u0000html/746d102a-5f3e-6142-b02a-63f3cac385ab.htm\u00001284","FILE.Inequality Operator\u0000html/77413435-917b-2cdc-cfde-d0891b6ede82.htm\u0000191","gmp_lib.mpz_tdiv_q_2exp Method\u0000html/746301ec-352c-9bae-ff92-8a2ed31be655.htm\u0000623","gmp_lib.free Method (mp_ptr[])\u0000html/7924a2a3-75c1-0aa9-636f-4772d74a723f.htm\u0000165","gmp_lib.mpn_divexact_by3 Method\u0000html/75f2a84e-44f3-b7cc-e6ad-392111d5b9cc.htm\u00001041","char_ptr.Equals Method (Object)\u0000html/77d1beb2-2aed-58e8-dc50-bba2ff56afee.htm\u0000180","mpf_t.ToString Method\u0000html/77eccd6b-888f-b3a8-0800-ead4af162af0.htm\u0000122","gmp_lib.mpf_urandomb Method\u0000html/5a698221-639e-333b-061b-0aa3f76c38e9.htm\u0000575","mp_limb_t.ToString Method\u0000html/7ae8e775-5b2d-4ce0-c45b-5afd1b66ac62.htm\u0000124","char_ptr.Zero Field\u0000html/76481715-8a8b-e739-905c-f0d83de503ab.htm\u000094","mp_bitcnt_t.Equals Method (Object)\u0000html/5b4fc57b-2ab5-9b95-6c35-ec9b499a6d59.htm\u0000180","gmp_lib.mpz_get_d_2exp Method\u0000html/74e22b4c-fa79-f5f9-b752-da41bd427f37.htm\u0000561","gmp_lib.mpn_addmul_1 Method\u0000html/77fdf32b-986d-4df3-3c76-022e3e3fbb98.htm\u0000885","gmp_lib.mpz_cdiv_qr_ui Method\u0000html/7aee9fae-9d14-72be-6d0f-0f9c4a863fe5.htm\u0000801","gmp_lib.mpz_set_ui Method\u0000html/7daadb71-9f36-2848-86c4-ba1fba25fcfd.htm\u0000402","gmp_lib.gmp_vprintf Method\u0000html/8031c594-b2b2-fa62-7088-00b6fe92f88e.htm\u0000455","gmp_lib.mpq_equal Method\u0000html/7828ce92-079b-da4d-aab2-1742209287fb.htm\u0000548","mp_limb_t Implicit Conversion (Byte to mp_limb_t)\u0000html/7dbd9949-90ab-2b31-978d-9fde0a2ba7ee.htm\u0000140","gmp_lib.mpz_cdiv_qr Method\u0000html/7f89c102-d1eb-2dab-0e6e-061893309c4b.htm\u0000825","gmp_lib.gmp_urandomb_ui Method\u0000html/7b541895-53a8-b335-32de-d5b2224ff0f7.htm\u0000443","mp_size_t Implicit Conversion (UInt16 to mp_size_t)\u0000html/7c9b8744-cc4a-e2c1-659f-6da60e92bb78.htm\u0000140","gmp_lib.mpn_copyd Method\u0000html/78443f19-f0c6-4a1f-1eed-a815b734e981.htm\u0000507","gmp_lib.mpz_gcd_ui Method\u0000html/88b8d333-9c9c-de7d-8131-6d1432c14a0c.htm\u0000485","gmp_lib.mpz_init_set_ui Method\u0000html/7da3b40f-ae2c-63c5-0157-9b51d54cf6cb.htm\u0000373","gmp_lib.mpz_get_d Method\u0000html/89d8c501-6c12-9104-7e2d-be411f443b62.htm\u0000405","gmp_lib.mpz_limbs_write Method\u0000html/86ddbf69-57f6-af58-bd13-3eca06123b29.htm\u0000746","gmp_lib.mpz_limbs_modify Method\u0000html/87f5432d-aacb-57b6-b4a7-e4dc803684a4.htm\u0000743","gmp_lib.mpz_nextprime Method\u0000html/88f2d84b-105b-f882-ac55-54a2b6aea39d.htm\u0000478","mp_limb_t Implicit Conversion (mp_limb_t to UInt64)\u0000html/880536ad-8f64-bc4a-a807-0071061ac720.htm\u0000143","mpz_t Class\u0000html/8beda7fb-bbc4-b56f-fd1f-1459377ecb3b.htm\u0000345","mp_exp_t Implicit Conversion (Int16 to mp_exp_t)\u0000html/835b1c14-21a0-f806-1953-af0ddf068758.htm\u0000139","gmp_lib.mpf_init_set_ui Method\u0000html/8d1b97c9-ef9d-303a-0fbe-e7ece7edf391.htm\u0000425","gmp_lib.mpz_mod_ui Method\u0000html/86fd57d1-ccfa-804e-760b-bd8e7ade2176.htm\u0000643","gmp_lib.gmp_scanf Method\u0000html/880c96b7-378e-3cdb-057e-b6eea1c9e529.htm\u0000753","gmp_lib.gmp_sprintf Method\u0000html/8916c18b-a745-2699-2f0a-035cf62dd051.htm\u0000768","gmp_lib.mpz_import Method\u0000html/8c8c1e55-275f-cff8-2152-883a4eaa163c.htm\u00001175","mp_exp_t Methods\u0000html/8968de81-b069-4c5d-e694-8aad8a2c3cdb.htm\u0000124","gmp_lib.mpz_cdiv_q Method\u0000html/8b1e9c27-7278-6032-80c0-015b93258d96.htm\u0000686","gmp_lib.mpz_set_d Method\u0000html/8d6c39e2-22d8-d0ef-219c-dc594e73b2c5.htm\u0000425","gmp_lib.mpz_fdiv_ui Method\u0000html/8435af1d-e5e4-3e55-1024-449ff7b56ad4.htm\u0000550","mp_limb_t Constructor\u0000html/89d25f98-71ed-79b0-9b85-7cb9fcbab79d.htm\u0000125","char_ptr.GetHashCode Method\u0000html/84492195-83e7-7738-6678-c299663dd02c.htm\u0000121","mp_base Class\u0000html/8f3c572b-8133-bccc-b838-9d22e3467898.htm\u0000269","gmp_lib.mpz_clrbit Method\u0000html/8812c658-675a-b564-9159-2383971747b1.htm\u0000470","Welcome to the GMP Native Interface for .NET Library\u0000html/846f5c8a-6cba-433e-9f18-cde2ff5695cd.htm\u0000211","gmp_lib.mpz_sizeinbase Method\u0000html/7dfe367e-74d3-e782-860b-2314da9c44cf.htm\u0000654","mp_size_t Implicit Conversion (Int16 to mp_size_t)\u0000html/8f9e1df5-6eb0-4f14-3a1f-0d40ab45aac6.htm\u0000139","char_ptr Operators\u0000html/84b523e8-bc53-01e9-49af-f7996af73647.htm\u000059","gmp_lib.mpz_ui_sub Method\u0000html/8d80c2f9-de42-f223-595e-108f165d5746.htm\u0000546","gmp_lib.mpn_sub Method\u0000html/87681f32-b766-3ce2-7c08-98b2d32cb5fa.htm\u0000905","gmp_lib.mpz_inp_str Method\u0000html/8b8d6ec1-3ae5-e6f3-f030-289abe5002d0.htm\u0000751","gmp_lib.gmp_randclear Method\u0000html/7ef82a61-e43a-78c7-a28f-8f2d0a5f59b1.htm\u0000163","mp_exp_t Explicit Conversion (mp_exp_t to UInt16)\u0000html/92ffc71c-a4b3-4367-ba65-25b82d7e5cfd.htm\u0000142","size_t Explicit Conversion (Int16 to size_t)\u0000html/8da2a46e-34a6-f8be-270d-32fbf6424d98.htm\u0000139","mp_limb_t Operators and Type Conversions\u0000html/88234d39-a3da-db4f-71ff-17d0f2e2c7fe.htm\u0000286","gmp_lib.mpn_sec_add_1_itch Method\u0000html/87bbc39f-b11a-76d9-f31d-f5dcf365a67d.htm\u0000207","gmp_randstate_t Methods\u0000html/94df18f5-d7f6-b30a-5f00-f168e513840c.htm\u0000150","gmp_lib.mpz_swap Method\u0000html/90eada10-67d0-8376-0010-d053e5043b96.htm\u0000522","mp_exp_t.Inequality Operator\u0000html/931e55b9-30c1-aa94-c044-0400b5abea60.htm\u0000191","gmp_lib.mpz_popcount Method\u0000html/84bf95e4-d9d0-4ffe-f836-3650342de962.htm\u0000467","mp_exp_t Implicit Conversion (UInt16 to mp_exp_t)\u0000html/94f00d9c-cc2e-8ce7-56e5-f827238651cd.htm\u0000140","mp_ptr Properties\u0000html/9b1ae76e-d9d8-e72d-9fa6-fe8e2d833d40.htm\u000050","gmp_lib.mpq_div_2exp Method\u0000html/8dc5397d-96e4-74dd-cd31-0d05649ea927.htm\u0000295","gmp_lib.mpn_scan1 Method\u0000html/95c5a467-0bfe-337e-f6ca-657cf8c19eb1.htm\u0000422","mpz_t._mp_alloc Property\u0000html/93206a07-9ee6-f89b-f029-f0e80982c911.htm\u0000173","mp_size_t Operators and Type Conversions\u0000html/884aef1a-9faa-b787-ff5e-022615bd41eb.htm\u0000286","mp_limb_t Implicit Conversion (UInt64 to mp_limb_t)\u0000html/9b49e0e1-2b6a-8d1a-eb15-0a1a17358384.htm\u0000141","mp_size_t Explicit Conversion (mp_size_t to SByte)\u0000html/8dc5a181-8213-f87c-bd52-e77624313a9c.htm\u0000142","gmp_lib.mpq_set_z Method\u0000html/84d256a1-cd11-3bf9-3e8c-8a7e1980315d.htm\u0000563","gmp_lib.mpf_ceil Method\u0000html/9b4a5f6b-3f8e-a957-ae84-303c6897aeb4.htm\u0000540","gmp_lib.mpz_urandomm Method\u0000html/981cfca4-f958-045f-84b7-01717fcd88d1.htm\u0000694","gmp_lib.mpf_set_default_prec Method\u0000html/9e93d02e-f5c7-1a6f-68fe-a33d793a93e2.htm\u0000319","mp_size_t Explicit Conversion Operators\u0000html/9c49193c-e71d-9d5a-ce64-27446b2d8c1b.htm\u0000151","gmp_lib.mpz_primorial_ui Method\u0000html/985a65cd-9a65-e8b3-580b-626b65662dd6.htm\u0000398","gmp_lib.mpz_mod Method\u0000html/8d141ae9-4a01-bdc9-caf3-8daba3321ac1.htm\u0000632","gmp_lib.mpf_set_str Method\u0000html/823b356e-0731-c9ca-0b37-660b6eb9ee7c.htm\u0000825","gmp_lib.mpq_set Method\u0000html/9eac8ea9-0821-09b2-8091-e6638c562c7f.htm\u0000576","gmp_lib.mpz_powm_sec Method\u0000html/93210ab6-2523-3130-044a-80bcf43c181d.htm\u0000800","mp_size_t Methods\u0000html/afc0fd4e-39a7-905a-93b9-8bd291904211.htm\u0000124","gmp_lib.mpz_sgn Method\u0000html/86b2033c-26c3-3889-9025-b2a638910a86.htm\u0000413","mp_bitcnt_t Explicit Conversion Operators\u0000html/a2b35c8b-a71a-2e93-2f3b-cd5f8dcb51b4.htm\u0000165","gmp_lib.mpf_get_prec Method\u0000html/96c4a09e-3f83-00ab-30d0-78a82764b0ce.htm\u0000418","gmp_lib.mpz_set_f Method\u0000html/9005bf40-4373-e879-9f0a-448b174aad67.htm\u0000464","gmp_lib.mpz_tdiv_r_ui Method\u0000html/a58b3e42-f5e9-42d3-e71a-2a6f68dec3a9.htm\u0000679","gmp_lib.mpn_submul_1 Method\u0000html/95e10fea-31c2-e900-c5b0-f48636e1d76e.htm\u0000885","mp_exp_t Implicit Conversion (Int32 to mp_exp_t)\u0000html/82a3fa70-9dcd-a931-eb3e-18095e458891.htm\u0000139","gmp_lib.mpz_init_set_si Method\u0000html/9cbc8594-a202-86fd-f4e8-22635ba952b5.htm\u0000372","gmp_lib.mpn_tdiv_qr Method\u0000html/9fe90631-f519-1cf3-5a20-701d2bae1d0d.htm\u00001086","mp_exp_t Explicit Conversion (mp_exp_t to Byte)\u0000html/a5c30e13-40af-5fb4-97fa-75f4653eccee.htm\u0000142","gmp_lib.mpn_perfect_square_p Method\u0000html/a5dfd9bc-f86b-8a3b-69fc-8d2d5dea30ae.htm\u0000411","gmp_lib.mpf_mul_ui Method\u0000html/99a405b5-c051-9905-cf57-7139a0e503cf.htm\u0000580","gmp_lib.gmp_randinit_default Method\u0000html/89fff39e-9dc4-4d23-9460-301ae7df92d1.htm\u0000326","gmp_lib.mpn_sec_sub_1 Method\u0000html/9137a632-abd2-7963-1991-85e6d753bf13.htm\u0000895","FILE.GetHashCode Method\u0000html/b6911fef-883d-ec11-c2ad-1ff1ff565601.htm\u0000121","gmp_lib.mpf_swap Method\u0000html/b77c0292-518a-64d8-4b4e-0dd3c0cb801f.htm\u0000605","gmp_lib.mpn_sec_powm_itch Method\u0000html/96652cce-b8f1-0b9e-8434-19cf9bb3eb29.htm\u0000336","gmp_lib.mpz_lucnum_ui Method\u0000html/a48d50bf-0432-7feb-cc41-d6bf70f78e58.htm\u0000445","gmp_lib.mpf_pow_ui Method\u0000html/96e2fb95-0ac0-3d24-bea9-ee5631f30347.htm\u0000562","gmp_lib.mpn_sec_mul_itch Method\u0000html/b07466c5-6249-332d-e89b-aeb3675970ff.htm\u0000264","gmp_lib.mpz_rootrem Method\u0000html/a637ce7e-54d7-eba9-0c6f-c237f115b621.htm\u0000670","gmp_lib.mpq_set_ui Method\u0000html/915a7958-6821-bb64-468f-b0b48b351878.htm\u0000509","gmp_lib.mpn_sec_div_qr_itch Method\u0000html/b9e1a8f8-5156-ca69-337b-e67c2fd851f7.htm\u0000264","mp_bitcnt_t Implicit Conversion (mp_bitcnt_t to Int64)\u0000html/b9af7417-7e72-7f81-8433-2e231271f9b6.htm\u0000142","gmp_lib.mpn_scan0 Method\u0000html/ae66c86a-cc34-81be-2a38-e841e8a36f43.htm\u0000422","gmp_lib.free Method\u0000html/92160da3-b1af-e005-cb05-e3fb4dd524d8.htm\u000094","gmp_lib.mpn_neg Method\u0000html/9fb96802-e56e-8fd8-cef2-b44870d09a10.htm\u0000788","gmp_lib.mpz_size Method\u0000html/9a169dd9-42b0-ea59-abbe-4efc6b870c75.htm\u0000486","mp_bitcnt_t Implicit Conversion (Byte to mp_bitcnt_t)\u0000html/906e0eef-6efb-c60b-60d8-4827d7d57bf7.htm\u0000140","gmp_lib.mpz_powm Method\u0000html/9de702f4-758b-2a4e-1025-ed5e46cc7db2.htm\u0000765","gmp_lib.mpq_numref Method\u0000html/a4c2958c-5957-d736-6883-ce7e76b3d7a4.htm\u0000470","gmp_lib.mpz_abs Method\u0000html/9761cc8e-6099-7a76-5ea6-d27f617fd5d1.htm\u0000494","mp_size_t Explicit Conversion (mp_size_t to UInt64)\u0000html/969bef9e-e9a3-e671-5378-0767ee7f946b.htm\u0000143","mp_ptr Constructor (Byte[])\u0000html/be2f5733-8c21-c6e9-c4be-ca5f0b0ebba9.htm\u0000187","gmp_lib.mpz_cdiv_q_2exp Method\u0000html/a4def6d8-f8a5-f76f-4ef0-3e6e7eec23fb.htm\u0000623","gmp_lib.mpq_cmp_z Method\u0000html/bc33b7de-0deb-669e-0bb7-6cd1090f4aea.htm\u0000537","gmp_lib.mpn_set_str Method\u0000html/9a68645a-d8d6-f4c1-f706-0dc217f9809a.htm\u0000859","char_ptr.Equality Operator\u0000html/a4f47fa4-8285-638d-c094-bc9e249a49a0.htm\u0000189","gmp_lib.mpz_cdiv_r_2exp Method\u0000html/8320e5d8-1df9-ca26-3054-e4b93cc0f616.htm\u0000642","mp_limb_t.Inequality Operator\u0000html/be93bccd-2cad-322c-e211-5523de89b567.htm\u0000191","gmp_lib.mpf_get_str Method\u0000html/bad56282-fbca-6e3b-03c8-085cff07eed8.htm\u0000934","gmp_lib.mpq_get_den Method\u0000html/ae9e468d-e9ce-db55-1964-433829dfa476.htm\u0000608","mp_size_t Constructor\u0000html/be71a625-32c1-841d-0915-f0771323d00a.htm\u0000123","ptr(T) Constructor (T)\u0000html/b7987d45-5188-14f6-7ac7-bbe14184971b.htm\u0000128","gmp_lib.mpz_pow_ui Method\u0000html/8e3a525d-9371-fb32-1051-e8e8fe23a63d.htm\u0000529","gmp_lib.mpz_fits_sint_p Method\u0000html/a066df5a-c312-3b00-6092-6f914c3ee248.htm\u0000384","gmp_lib.mpz_powm_ui Method\u0000html/9fd28088-e353-2b5e-03e3-9c2763226ed6.htm\u0000663","size_t Operators and Type Conversions\u0000html/c27b5f76-606f-b512-9424-8e74cea9f6da.htm\u0000286","gmp_lib.mpz_cmp_d Method\u0000html/bb37470f-5f40-4f6d-01d9-4e40446782a3.htm\u0000447","ptr(T) Constructor\u0000html/8e86c547-280b-afb8-98ea-aebfb3ec04b9.htm\u000094","mp_bitcnt_t.Equality Operator\u0000html/c0825a57-1ba5-e1d1-3fa9-9c43008c1ada.htm\u0000189","mp_limb_t.Equals Method (mp_limb_t)\u0000html/a1075491-112f-885c-7097-2745d8c251a2.htm\u0000161","gmp_lib.mpf_cmp Method\u0000html/be9e6a25-83fb-49c2-949a-b8642a8234f5.htm\u0000524","mp_exp_t Explicit Conversion (mp_exp_t to UInt64)\u0000html/bb3fdf5b-8b0e-e922-a1bd-cd337a89f971.htm\u0000143","gmp_lib.mpf_set_q Method\u0000html/bd669b1e-a941-2e35-7c29-29a5b5ff5e3a.htm\u0000491","gmp_lib.mpq_inits Method\u0000html/8ab8ea40-9723-f0c8-18f4-9558c73397b9.htm\u0000503","gmp_lib.mpz_si_kronecker Method\u0000html/a248732b-c4be-7e9a-4207-0049371764ff.htm\u0000513","size_t.Inequality Operator\u0000html/a68386d1-23de-611a-543f-fbd5600f674a.htm\u0000191","size_t.Equals Method (size_t)\u0000html/b08a01e0-6ae7-c9db-4d46-9fdeadaca5ed.htm\u0000161","gmp_lib.mpn_divmod_1 Method\u0000html/9074a45b-0d68-cf18-75fe-076e720a9a61.htm\u0000837","mp_exp_t.Equals Method (mp_exp_t)\u0000html/c349463b-04b6-167b-b8f7-9f117789577d.htm\u0000161","gmp_lib.mpz_cdiv_r_ui Method\u0000html/af797947-8f84-320e-d1cd-ba578b26cef3.htm\u0000682","gmp_lib.mpz_tdiv_r Method\u0000html/beb982a6-fa8e-6a0f-409a-bce1fddb6002.htm\u0000699","mp_size_t.Equality Operator\u0000html/a6d79a12-4568-8617-30a9-e36698ef5994.htm\u0000189","mp_exp_t.ToString Method\u0000html/cd071eb3-c175-836d-c47a-f9c007b8738d.htm\u0000124","gmp_lib.mpn_hamdist Method\u0000html/caf28774-7b13-0802-858c-a49970d7aa55.htm\u0000512","gmp_lib.mp_uint_per_limb Field\u0000html/af9533ce-5e67-245d-1cb3-9efb7772a6c8.htm\u0000188","gmp_lib.mpf_init2 Method\u0000html/98083eac-9993-41b2-4943-678785fce712.htm\u0000479","mp_ptr.Item Property\u0000html/a7661bd2-2bcb-01c5-9833-5ab6d6305daf.htm\u0000176","gmp_lib.mpz_submul_ui Method\u0000html/c5a0fa06-536c-6c6f-20c7-fb014ebc6444.htm\u0000573","gmp_lib.mpn_zero Method\u0000html/90a57214-6596-be63-31e7-aa3186252628.htm\u0000413","gmp_lib.gmp_vasprintf Method\u0000html/bd7a38bd-df52-4b0f-36d4-eb539767d89f.htm\u0000701","gmp_lib.mpz_bin_ui Method\u0000html/cbbdf666-7c6c-f3f3-1790-b5bb1655af87.htm\u0000562","mp_exp_t Operators and Type Conversions\u0000html/d0d07662-13f1-e033-9619-1c9f89c37939.htm\u0000286","gmp_lib.mpz_fib2_ui Method\u0000html/c0f8ab02-55db-8a6b-705d-6fa700d54545.htm\u0000635","gmp_lib.mpq_set_si Method\u0000html/ba898f37-20d0-a5cd-eff1-0663f18220dd.htm\u0000516","gmp_lib.mpz_2fac_ui Method\u0000html/d479f2da-ecf9-c9d6-5cc7-66eb8b5ba16b.htm\u0000380","gmp_lib.mpz_legendre Method\u0000html/b5936979-01aa-1cd8-20de-d6386368e234.htm\u0000485","void_ptr.Inequality Operator\u0000html/bd89f9a0-7e6f-d1e7-46b3-051bfbe290f4.htm\u0000191","gmp_lib.gmp_randseed_ui Method\u0000html/c5f4e595-de6c-a555-426d-6cb8f429a960.htm\u0000507","mp_bitcnt_t.Inequality Operator\u0000html/8ae70a65-d9d6-0c44-b148-82f39dc474ab.htm\u0000191","gmp_lib.mpn_mul_1 Method\u0000html/b819fb3b-5d3e-ff23-1687-0e71af684bd7.htm\u0000891","size_t Explicit Conversion (size_t to Byte)\u0000html/b60d2b4d-e77b-2a6a-bc12-9bba19450de7.htm\u0000142","gmp_lib.mpz_random2 Method\u0000html/cd88d27d-fb03-9e74-e353-4f0df7a38a96.htm\u0000472","mp_exp_t Constructor\u0000html/d4cd9f0b-9f54-1f1d-6a27-a0ce3122249c.htm\u0000123","gmp_lib.mpf_set_z Method\u0000html/d60489f8-91f8-ea00-d29c-a52449e712da.htm\u0000479","FILE.Equals Method (Object)\u0000html/c35318b5-343e-5f6f-2a46-89cb3019121c.htm\u0000180","gmp_lib.mpz_perfect_power_p Method\u0000html/d7722641-e3ea-336d-63f3-dc48f786e376.htm\u0000449","gmp_lib.mpq_clears Method\u0000html/cc2693e9-1cc5-3098-f2f7-bb05c8017f62.htm\u0000506","gmp_lib.mpf_init_set_d Method\u0000html/a2c14761-1b23-0de9-3842-c2d4e3d7aac0.htm\u0000436","gmp_lib.mpf_fits_ulong_p Method\u0000html/d1b172bb-9c87-c255-a736-4b8ef1f6a5fe.htm\u0000404","void_ptr.Equals Method (void_ptr)\u0000html/c39c5883-0cbc-86ee-d3a6-be3a95f8cadc.htm\u0000161","gmp_lib.mpz_urandomb Method\u0000html/c5fc473c-b8dc-8053-4199-e80d58a05230.htm\u0000590","mp_size_t.Inequality Operator\u0000html/d7d60484-ecc2-8e26-1dac-de2617ab1867.htm\u0000191","gmp_lib.mpz_init_set_str Method\u0000html/d5af3442-ab5b-08e2-9398-0b6f04506c16.htm\u0000589","mp_base Properties\u0000html/c65a20b0-ddd8-db62-1d34-19bf1a71ce8c.htm\u000050","gmp_lib.mpn_nand_n Method\u0000html/a7d1fd40-0415-b4af-1787-706d245ff96e.htm\u0000686","gmp_lib.mpf_sgn Method\u0000html/d229629f-3bba-817b-d9a3-6f00271e1da7.htm\u0000403","mp_limb_t Explicit Conversion (mp_limb_t to Int16)\u0000html/c3def8a2-dda3-3951-fca6-035e9c7ec894.htm\u0000141","gmp_lib.mpn_cnd_sub_n Method\u0000html/b82bad6a-f8f0-db53-a6d3-ed6002046257.htm\u0000975","gmp_lib.mpz_remove Method\u0000html/d6721058-8a6f-9b20-2a5f-8ffd83cc2a2e.htm\u0000636","mp_exp_t Implicit Conversion Operators\u0000html/c7574415-f402-d74d-8dfc-c4ec2f893a5f.htm\u0000123","gmp_lib.free Method (char_ptr)\u0000html/d3ad552c-4d46-029e-9eeb-44d8abb800e2.htm\u0000141","mp_limb_t Explicit Conversion (Int16 to mp_limb_t)\u0000html/b88446f7-b9cf-5692-d4fe-7b809ef197eb.htm\u0000139","gmp_lib.mpz_submul Method\u0000html/ce7d559a-3772-41c0-912f-9ab218f4d98c.htm\u0000638","mp_base Methods\u0000html/dc319ce0-0560-799e-9187-8445d98b802b.htm\u0000150","size_t Structure\u0000html/d9761bfb-1882-59d2-e89b-c6460141f9a6.htm\u0000478","mp_bitcnt_t.Equals Method\u0000html/cfedc4a1-b264-82a8-cf48-a6416e4afce7.htm\u000069","FILE.Equality Operator\u0000html/cdb5f955-23ce-e22d-5090-d137153e866f.htm\u0000189","gmp_lib.mpf_get_si Method\u0000html/d948e832-ee71-628a-6a7b-766138afff62.htm\u0000435","mpq_t.ToIntPtr Method\u0000html/ce76ca4d-3aab-d682-1f85-aa95ce7d43a9.htm\u0000113","size_t Explicit Conversion (size_t to UInt32)\u0000html/d00d45f6-e184-7a72-2c0e-e2b0d39a40c7.htm\u0000142","gmp_lib.free Method (void_ptr)\u0000html/c10cea6f-22cd-f84c-c11a-5924ba0b0ee7.htm\u0000141","gmp_lib.mpz_inits Method\u0000html/de0b7cf7-1826-55f3-379d-41a6ef2d0991.htm\u0000472","gmp_lib.mpz_get_si Method\u0000html/da585eac-be2c-38ea-8be5-90c5be95ae86.htm\u0000437","mpz_t Implicit Conversion (String to mpz_t)\u0000html/d07ddfe6-a0d0-51e7-180c-481fe678fc38.htm\u0000169","mp_limb_t Explicit Conversion Operators\u0000html/e2434db6-d7f3-e7d6-2bd7-04e29ba0a7a8.htm\u0000179","gmp_lib.mpn_andn_n Method\u0000html/b8b6d088-3330-5073-dc17-18ea23b0fc14.htm\u0000685","gmp_lib.mpz_ui_kronecker Method\u0000html/d9715b1a-6092-83e6-d7f3-6cfbb4adb143.htm\u0000514","gmp_lib.mpq_clear Method\u0000html/b69da354-160b-602a-4cc4-faf7ca423186.htm\u0000376","void_ptr Methods\u0000html/e267ef2f-54a1-a3f1-441f-0655b542bf55.htm\u0000148","mp_exp_t.Equals Method (Object)\u0000html/b91d6398-e5f7-0ee9-e982-4ec2e009d0bc.htm\u0000180","allocate_function Delegate\u0000html/dfe3609d-cc50-e357-4254-e3a8e2847f07.htm\u0000149","size_t Implicit Conversion Operators\u0000html/a35ea6b8-48fa-4e62-bdbd-fee74574cac5.htm\u000095","gmp_lib.gmp_vscanf Method\u0000html/e5060da5-cafd-67e7-f18f-3a9d3c2aba7d.htm\u0000753","gmp_lib.mpf_add Method\u0000html/c19999f1-01ee-a3fe-dc4d-2a459e73492d.htm\u0000657","gmp_lib.mpz_tdiv_qr_ui Method\u0000html/d5b95352-7b5e-881b-136a-b78fd8e033ff.htm\u0000797","mp_base._mp_d Property\u0000html/db55f1a9-cd4c-b7e9-c831-4391c0497ef7.htm\u0000379","gmp_lib.mpq_neg Method\u0000html/b6bd5187-99bb-c6b5-d871-b163fa0f7e0e.htm\u0000263","gmp_lib.gmp_fprintf Method\u0000html/e3abec5c-9d83-babc-a020-ca4817962a21.htm\u0000697","size_t Explicit Conversion (Int64 to size_t)\u0000html/e9177dc9-2049-a649-3bf2-735ed6927aae.htm\u0000140","mpf_t.ToIntPtr Method\u0000html/b77413f7-f862-7996-838a-f510fc3f69ed.htm\u0000117","gmp_lib.mpz_fits_sshort_p Method\u0000html/e07f3328-a28c-c75c-10a6-f21d05e6aec0.htm\u0000384","gmp_lib.mpz_even_p Method\u0000html/e6012778-c71b-b078-2ef3-9f9db90f1769.htm\u0000381","mp_size_t Implicit Conversion (Byte to mp_size_t)\u0000html/e2817889-195b-d443-500d-2568ebfefe4f.htm\u0000140","gmp_lib.ZeroMemory Method\u0000html/e3d53be6-a0ad-fb21-5381-ff688f5984a6.htm\u0000188","mp_ptr Constructor (mp_size_t)\u0000html/e0c0acc3-41cd-cb7d-68e7-3bf8dc5039d4.htm\u0000148","char_ptr.Inequality Operator\u0000html/f090e7f3-7440-c789-5594-e5512076a61a.htm\u0000191","gmp_lib.mpn_nior_n Method\u0000html/c7d8bbe3-23cd-3460-be24-3a3ac3b28cf4.htm\u0000690","mp_size_t.Equals Method (mp_size_t)\u0000html/b93a08cc-4dfe-0c34-c1ac-25344489f2d3.htm\u0000161","gmp_lib.mpz_sub_ui Method\u0000html/e3e3f2ce-f3d8-5321-37a5-de65b6c2a30d.htm\u0000548","gmp_lib.mpz_fdiv_qr Method\u0000html/d9ab5220-69aa-8e5d-8d15-375eb27149ad.htm\u0000826","mp_exp_t Structure\u0000html/e6a17880-791f-37d4-4942-cf26ce7d4cbf.htm\u0000511","gmp_lib.mpq_out_str Method\u0000html/e1c059c4-4cd9-9a2b-1178-4b1a60354129.htm\u0000745","size_t.ToString Method\u0000html/e465d040-0d35-f8c8-51db-c56b3d14b4c8.htm\u0000124","gmp_lib.mpn_mod_1 Method\u0000html/9aa24cc8-8cf5-4b8a-cd1b-5ded400efa50.htm\u0000608","gmp_lib.mpn_sec_powm Method\u0000html/a38b87c5-c6ac-fa68-6d58-c45793bf933e.htm\u00001074","gmp_lib.mpq_mul_2exp Method\u0000html/f148f8be-dfbc-fc41-981d-0a99834f01ff.htm\u0000295","Math.Gmp.Native Namespace\u0000html/d9c51b9f-0c54-770b-28ea-6eebd8fef368.htm\u0000223","mpf_t._mp_size Property\u0000html/9aa3bb30-32b3-b465-af05-9b048bb610f1.htm\u0000171","mp_limb_t Structure\u0000html/bf1f694d-f9b2-6413-12e5-ebae603d5b49.htm\u0000533","gmp_randstate_t Class\u0000html/f7e5846d-548d-3bf3-74ac-219fde42a041.htm\u0000234","mpq_t._mp_den Property\u0000html/fb8c2e17-4a22-899c-77af-6d3bef099fc2.htm\u0000123","mp_bitcnt_t Operators and Type Conversions\u0000html/bee91f05-75c7-52c6-18ae-eb792710655d.htm\u0000286","mp_limb_t Explicit Conversion (mp_limb_t to UInt16)\u0000html/9ab62efe-605f-58cf-588c-1e52adcfb373.htm\u0000142","gmp_lib.gmp_randinit_lc_2exp_size Method\u0000html/f209112e-311a-88cd-becf-33bc3787f91d.htm\u0000417","gmp_lib.mpf_cmp_si Method\u0000html/d9d29633-42c7-fb1c-cdee-3b7993f45653.htm\u0000440","gmp_lib.mpn_cnd_swap Method\u0000html/f0985ccc-17da-8a0b-066c-53df9b1921a1.htm\u0000794","gmp_lib.mpz_invert Method\u0000html/e3072efb-05a9-947c-5532-6d806c157e4a.htm\u0000711","mp_ptr Methods\u0000html/f324e472-a709-9f28-6b3c-ffdeda0376bf.htm\u0000162","gmp_lib.mpq_get_d Method\u0000html/f88b40d4-3da9-e2c7-4c4c-1ad868778075.htm\u0000440","mp_size_t Explicit Conversion (mp_size_t to UInt32)\u0000html/ee84dcdc-769f-5829-0e77-99ea66f0151b.htm\u0000142","gmp_lib.mpf_get_d_2exp Method\u0000html/e1edc21e-74a0-b44c-216b-bad204b5a48a.htm\u0000611","gmp_lib.mpz_clears Method\u0000html/a909faa8-4939-1ba3-5647-af8836c9a291.htm\u0000468","gmp_lib.mpn_rshift Method\u0000html/bb46ebe4-c002-8769-19ed-136a86e87134.htm\u0000726","gmp_lib.mpq_set_str Method\u0000html/e98ec3cf-b539-8024-c401-ecd24bd43662.htm\u0000642","mp_limb_t.Equals Method\u0000html/f3da8743-4110-ef69-3809-3261d9304977.htm\u000069","size_t Implicit Conversion (UInt32 to size_t)\u0000html/e76254b7-0a0e-d726-a1a2-ebc21dab1c96.htm\u0000140","gmp_lib.mp_bits_per_limb Field\u0000html/f88c76a8-118a-5cbd-0df1-e30adcacb8ae.htm\u0000183","void_ptr Structure\u0000html/e200d734-044d-4cc7-acc7-2333d7cf3c9a.htm\u0000262","FILE.Equals Method (FILE)\u0000html/a964376d-5264-550c-0dc6-5ce21c48ac93.htm\u0000161","mpq_t.ToString Method\u0000html/e9fce326-9ff5-0bbc-87d7-53ace305f107.htm\u0000122","gmp_lib.mpz_fits_ulong_p Method\u0000html/fb9e7caf-b049-7884-b70c-185053972604.htm\u0000379","gmp_lib.mpn_divexact_by3c Method\u0000html/c40ea3de-d1be-146b-fe7a-deff566ca817.htm\u00001075","mp_ptr.GetEnumerator Method\u0000html/f9a60366-d1e2-5565-bbc2-63d98d779e27.htm\u0000156","mp_exp_t Implicit Conversion (mp_exp_t to Int64)\u0000html/e7a5fd85-46d5-46ed-b943-3c245fae350a.htm\u0000142","gmp_lib.mpz_tdiv_r_2exp Method\u0000html/c8216c67-1e74-82d0-6ca0-f24d07045ca8.htm\u0000638","gmp_lib.mpq_get_str Method\u0000html/f457878b-c3f5-bfe2-aaa9-7f2179332f57.htm\u0000662","mp_exp_t Implicit Conversion (Byte to mp_exp_t)\u0000html/fa401922-089c-d6e0-8ef7-e9013676e9e5.htm\u0000140","gmp_lib.mpz_fdiv_q Method\u0000html/b0d00a52-e539-c5f7-7d6d-ab202e72ad98.htm\u0000686","gmp_lib.mpf_random2 Method\u0000html/cc6e8f51-f396-f6c3-c6e4-9a9aeeaf2a13.htm\u0000515","gmp_lib.mpq_sub Method\u0000html/e7d65cf6-2ee4-c983-62b5-4ad66f1d8599.htm\u0000296","gmp_lib.mpz_tdiv_ui Method\u0000html/eea23315-8275-7472-44b0-94b9a05a6657.htm\u0000550","gmp_lib.mpn_sec_invert_itch Method\u0000html/ec24a122-714e-5b6f-9872-95fd5fda54ea.htm\u0000216","mp_bitcnt_t Explicit Conversion (mp_bitcnt_t to Int32)\u0000html/ecccb4d7-41db-d565-2551-4c15730c6d2f.htm\u0000141","gmp_lib.mpf_get_ui Method\u0000html/aa3fd0ea-a8b6-674b-59ff-b6d4785baed1.htm\u0000256","mp_size_t.GetHashCode Method\u0000html/c82e8cd1-5053-7e58-3b57-c20583dcc5e7.htm\u0000121","gmp_lib.mpf_clears Method\u0000html/bfb87570-3b2e-079a-1528-3746424bbdef.htm\u0000498","mp_size_t Explicit Conversion (UInt32 to mp_size_t)\u0000html/edf58344-c7ce-6c94-dea2-e07f06eb7987.htm\u0000140","reallocate_function Delegate\u0000html/aa9d21b4-a929-d550-5a65-f9cbcfa7f638.htm\u0000218","gmp_lib.free Method (gmp_randstate_t)\u0000html/f46e4103-d4c4-69c2-1363-a4cb17d9cfda.htm\u0000143","mp_bitcnt_t Implicit Conversion (mp_bitcnt_t to UInt32)\u0000html/c897167e-f92f-0785-bda4-0f40d89fe35a.htm\u0000142","gmp_lib.mpz_gcdext Method\u0000html/fae08c47-86df-9010-1827-a9fa6e48a1af.htm\u00001103","gmp_lib.mpz_cmp Method\u0000html/eea958f4-5951-38f2-05ba-3870cefb3842.htm\u0000492","gmp_lib.mpz_cmp_ui Method\u0000html/bfe022c5-95d3-45d7-0c6f-97167a9a0af2.htm\u0000409","mp_bitcnt_t Explicit Conversion (SByte to mp_bitcnt_t)\u0000html/aaf1db64-d29e-3aa5-0a72-6fe2578210de.htm\u0000140","mp_ptr Constructor (UInt64[])\u0000html/ef5be106-0301-8122-c640-70bda121b879.htm\u0000186","gmp_lib.mpz_sqrtrem Method\u0000html/e802af92-73bf-b138-dc95-a3c57eeefb66.htm\u0000649","mp_size_t.ToString Method\u0000html/abd28ab6-f7d7-296e-852b-ef28b35a08d8.htm\u0000124","gmp_lib.mpf_reldiff Method\u0000html/f485faa1-3758-8316-f712-42e0fc2058a8.htm\u0000657","gmp_lib.mpz_fdiv_r_2exp Method\u0000html/b0f120a7-a215-fbff-1138-bac5df8d741c.htm\u0000638","gmp_lib.mpf_ui_sub Method\u0000html/efbe678f-e1f3-b203-eb36-0db03ba11795.htm\u0000586","gmp_lib.mpn_sec_sqr Method\u0000html/bfe1e9b5-6fc1-95f2-d5b6-137fe87c071a.htm\u0000813","gmp_lib.mpz_add Method\u0000html/acb6d3d4-70ad-58be-7cb8-9edb997204b3.htm\u0000613","gmp_lib.mpz_lcm Method\u0000html/db614763-a13e-6456-d52b-9f567be7e776.htm\u0000598","gmp_lib.mpn_sqrtrem Method\u0000html/ee31871c-38bd-fccc-77f5-e76909dd7a79.htm\u00001110","gmp_lib.mpz_cdiv_r Method\u0000html/e8f34851-d0b2-335e-1ea5-f9129062aabf.htm\u0000703","mp_limb_t Explicit Conversion (mp_limb_t to UInt32)\u0000html/f4b3e873-d3fc-637d-d8cb-04cd63c76b6d.htm\u0000142","gmp_lib.gmp_asprintf Method\u0000html/fe6e46c3-8464-a080-b5fc-718589320cd5.htm\u0000728","gmp_lib.mpq_init Method\u0000html/dbf3d252-fd6d-455f-2ba7-4091845b86a7.htm\u0000436","gmp_lib.mpn_sub_n Method\u0000html/b104184e-cf49-dbdb-764a-9dee5cf7b2fd.htm\u0000848","mp_bitcnt_t Explicit Conversion (mp_bitcnt_t to SByte)\u0000html/fe73a139-80df-459c-fb02-d0d9ccdd8bb5.htm\u0000142","gmp_lib.mpf_fits_ushort_p Method\u0000html/ada84e5e-397e-e963-7d50-e260d4a104f7.htm\u0000405","gmp_lib.mpn_mul_n Method\u0000html/ee321a9a-852a-993e-f602-72ff2af02ff6.htm\u0000876","mp_bitcnt_t Explicit Conversion (mp_bitcnt_t to UInt16)\u0000html/b195041a-f22f-4f68-fba0-58479ec4158e.htm\u0000142","gmp_lib.mpz_xor Method\u0000html/fd4c285a-e2e1-f8ba-97b3-08d4ae6a2ebf.htm\u0000658","mp_limb_t Implicit Conversion (UInt32 to mp_limb_t)\u0000html/adc5aae1-accd-ed83-fe1b-8910aa034c17.htm\u0000140","gmp_lib.mpf_init_set_si Method\u0000html/dc1406fd-4ca4-70d3-dc83-bd40b955564a.htm\u0000430","gmp_lib.mpn_ior_n Method\u0000html/f4c54e3b-1c09-d01d-eb28-b7b05cf6fa70.htm\u0000680","gmp_lib.mpn_sizeinbase Method\u0000html/fb2d29b4-f7e2-e3d6-6fcb-920f2e86c0d7.htm\u0000502","gmp_lib.mpz_millerrabin Method\u0000html/f0bda1a7-4b40-0896-4939-4dc66b256424.htm\u0000433","size_t Explicit Conversion (size_t to Int64)\u0000html/fd60a636-df2f-3c60-40c7-b46077830f00.htm\u0000142","gmp_lib._mpz_realloc Method\u0000html/c9cb6a67-59b8-5c03-f31d-f252441c53f6.htm\u0000710","char_ptr.Equals Method (char_ptr)\u0000html/b1eefed1-412c-fcb1-29ff-34094bc8d57e.htm\u0000161","gmp_lib.mpz_init Method\u0000html/dc2f13ec-ac21-1196-0a1d-c574578b1f24.htm\u0000375","FILE.Value Field\u0000html/fb70a49d-b7b0-b8fc-83f5-0864f381cc76.htm\u000088","gmp_lib.mpf_set_si Method\u0000html/f059f8e4-dfc8-79fe-6455-42e227ccbc2e.htm\u0000412","gmp_lib.mpz_setbit Method\u0000html/f0caf821-320b-1a8b-87ff-84fcbdfd5801.htm\u0000470","gmp_lib.mpz_fdiv_q_2exp Method\u0000html/f56c5489-8c01-a687-fec8-a5f443738701.htm\u0000623","gmp_lib.mpn_sub_1 Method\u0000html/ae3c6cf7-08a0-54dd-951f-b2fe2112b8b0.htm\u0000791","gmp_lib.mpn_add Method\u0000html/b9df04c4-224e-f2ad-8e90-fbb3b30bd76d.htm\u0000882","gmp_lib.gmp_randseed Method\u0000html/b31d5778-362b-b75f-40cc-4c8280ca889c.htm\u0000548","char_ptr Fields\u0000html/b32f2955-fb82-d5d4-3b3d-7dcd95a5d305.htm\u000038","gmp_lib.mpf_out_str Method\u0000html/feafa6f8-9793-d704-31a8-67c2cec0c33e.htm\u0000716","ptr(T) Methods\u0000html/b390b506-1cff-5bd4-fcf5-a135127497dc.htm\u0000154","gmp_lib.mpz_init_set_d Method\u0000html/fec3a449-96b9-64b0-f53d-0b5a3856d02d.htm\u0000396","gmp_lib.mpz_export Method\u0000html/c9d371c8-8c16-77a3-2c47-8edae05276c5.htm\u00001507","size_t Implicit Conversion (UInt64 to size_t)\u0000html/c9d426b1-7505-f34c-5122-7ccd2571f577.htm\u0000141","mp_size_t Explicit Conversion (Int64 to mp_size_t)\u0000html/fecd3260-6eb9-5e31-0266-9bb52bf9b038.htm\u0000140","gmp_lib.gmp_randinit_mt Method\u0000html/b3ed0ded-086a-41f1-6051-d08afa338da8.htm\u0000311","gmp_lib Fields\u0000html/b4507d49-5a58-a25b-6ae3-ac7e599caab1.htm\u000082","gmp_lib.mpn_divrem_1 Method\u0000html/f5c3f25d-1ad5-b3be-fc4b-280a62869912.htm\u0000903","gmp_lib.mpf_sub_ui Method\u0000html/ca339303-b509-db06-c875-3aac3edec5dd.htm\u0000584","gmp_lib.mpf_set_prec_raw Method\u0000html/b456f637-83f4-9d4f-18c5-052d77fbf981.htm\u0000849","gmp_lib.mpn_sqr Method\u0000html/ff9c2930-ded2-c5b6-46dd-3ff9279cdc5e.htm\u0000760","gmp_lib.mpq_set_f Method\u0000html/f5dc74ec-155b-2a14-3eb5-4610a8509bae.htm\u0000535","gmp_lib.mpq_add Method\u0000html/ca6a2024-43ea-fb4e-245e-12e2e01e4ebd.htm\u0000296","gmp_lib.mpz_mfac_uiui Method\u0000html/b4ff3a9e-3ab5-689f-7a80-b61dad2ea125.htm\u0000424","gmp_lib.mpz_lcm_ui Method\u0000html/f60dbcbd-d4f0-edcc-8f88-2de1aa375e6b.htm\u0000276","gmp_lib.mpz_mul_si Method\u0000html/ffd27ee1-e1e3-567f-b3cf-87dec2de2c83.htm\u0000567","mpf_t._mp_exp Property\u0000html/f63ee104-afaa-e0b8-ff39-f60b9a934ea3.htm\u0000228","gmp_lib.mpn_lshift Method\u0000html/b52f3ab3-7ad3-7dde-14a2-83c81840b829.htm\u0000700","gmp_lib.mpz_fits_slong_p Method\u0000html/cad028df-c3f1-12b6-d8dd-56c4968730e4.htm\u0000384","gmp_lib.mpz_set_q Method\u0000html/f6eeca07-edf7-6915-36e4-e8a7a62333d7.htm\u0000464","gmp_lib.mpf_floor Method\u0000html/f7584918-b77f-3524-eea2-04134a2c3ba6.htm\u0000539","mp_ptr Constructor (UInt32[])\u0000html/cad424b2-4a92-fda9-45dd-243ef9e5f321.htm\u0000189"] \ No newline at end of file diff --git a/docs/html/00586c66-53ac-3fe3-16a4-3ceb2f94620b.htm b/docs/html/00586c66-53ac-3fe3-16a4-3ceb2f94620b.htm new file mode 100644 index 0000000..55202da --- /dev/null +++ b/docs/html/00586c66-53ac-3fe3-16a4-3ceb2f94620b.htm @@ -0,0 +1,9 @@ +FILE Methods
    FILE Methods

    The FILE type exposes the following members.

    Methods
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(FILE)
    + Returns a value indicating whether this instance is equal to a specified FILE value. +
    Public methodGetHashCode
    + Returns the hash code for this instance. +
    (Overrides ValueTypeGetHashCode.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Public methodToString
    Returns the fully qualified type name of this instance.
    (Inherited from ValueType.)
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/00a7e91d-b046-f5d3-5b51-55868d87e228.htm b/docs/html/00a7e91d-b046-f5d3-5b51-55868d87e228.htm new file mode 100644 index 0000000..c18f716 --- /dev/null +++ b/docs/html/00a7e91d-b046-f5d3-5b51-55868d87e228.htm @@ -0,0 +1,56 @@ +gmp_lib.mpf_sqrt Method
    Click or drag to resize
    gmp_libmpf_sqrt Method
    + Set rop to the square root of op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_sqrt(
    +	mpf_t rop,
    +	mpf_t op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op
    Type: Math.Gmp.Nativempf_t
    The operand.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 100.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, 100);
    +
    +// Create and initialize a new floating-point number z.
    +mpf_t z = new mpf_t();
    +gmp_lib.mpf_init(z);
    +
    +// Set z = sqrt(x).
    +gmp_lib.mpf_sqrt(z, x);
    +
    +// Assert that the value of z is 10.
    +Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpf_clears(x, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/00d8413a-b34b-5e89-193c-1bfe522710c5.htm b/docs/html/00d8413a-b34b-5e89-193c-1bfe522710c5.htm new file mode 100644 index 0000000..f57f509 --- /dev/null +++ b/docs/html/00d8413a-b34b-5e89-193c-1bfe522710c5.htm @@ -0,0 +1,48 @@ +gmp_lib.mpn_copyi Method
    Click or drag to resize
    gmp_libmpn_copyi Method
    + Copy from {s1p, n} to {rp, n}, increasingly. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpn_copyi(
    +	mp_ptr rp,
    +	mp_ptr s1p,
    +	mp_size_t n
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    s1p
    Type: Math.Gmp.Nativemp_ptr
    The operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of s1p.
    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr sp = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 });
    +mp_ptr rp = new mp_ptr(new uint[2]);
    +mp_ptr result = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 });
    +
    +// Set rp = sp.
    +gmp_lib.mpn_copyi(rp, sp, sp.Size);
    +
    +// Assert result of operation.
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, sp, result);
    See Also
    \ No newline at end of file diff --git a/docs/html/011efd01-e7f0-47d8-7d1e-77888d96f0d4.htm b/docs/html/011efd01-e7f0-47d8-7d1e-77888d96f0d4.htm new file mode 100644 index 0000000..18eb55b --- /dev/null +++ b/docs/html/011efd01-e7f0-47d8-7d1e-77888d96f0d4.htm @@ -0,0 +1,38 @@ +gmp_lib.mpz_cmpabs_d Method
    Click or drag to resize
    gmp_libmpz_cmpabs_d Method
    + Compare the absolute values of op1 and op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_cmpabs_d(
    +	mpz_t op1,
    +	double op2
    +)

    Parameters

    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: SystemDouble
    The second operand integer.

    Return Value

    Type: Int32
    Return a positive value if |op1| > |op2|, zero if |op1| = |op2|, or a negative value if |op1| < |op2|.
    Remarks

    mpz_cmpabs_d(mpz_t, Double) can be called with an infinity (see PositiveInfinity or NegativeInfinity), + but results are undefined for a NaN. +

    Examples
    // Create, initialize, and set the value of op1 to -63.
    +mpz_t op1 = new mpz_t();
    +gmp_lib.mpz_init_set_si(op1, -63);
    +
    +// Assert that |op1| < |-70.0|.
    +Assert.IsTrue(gmp_lib.mpz_cmpabs_d(op1, -70.0) < 0);
    +
    +// Release unmanaged memory allocated for op1.
    +gmp_lib.mpz_clear(op1);
    See Also
    \ No newline at end of file diff --git a/docs/html/015a8bc4-a8de-d7c7-3aac-2524de5dfd03.htm b/docs/html/015a8bc4-a8de-d7c7-3aac-2524de5dfd03.htm new file mode 100644 index 0000000..536a8f8 --- /dev/null +++ b/docs/html/015a8bc4-a8de-d7c7-3aac-2524de5dfd03.htm @@ -0,0 +1,13 @@ +mp_limb_t Implicit Conversion Operators \ No newline at end of file diff --git a/docs/html/015f7dd6-55ab-71d0-316b-71a3f99799c3.htm b/docs/html/015f7dd6-55ab-71d0-316b-71a3f99799c3.htm new file mode 100644 index 0000000..a188bf5 --- /dev/null +++ b/docs/html/015f7dd6-55ab-71d0-316b-71a3f99799c3.htm @@ -0,0 +1,13 @@ +mp_exp_t Implicit Conversion (mp_exp_t to Int32)
    mp_exp_t  Conversion (mp_exp_t to Int32)
    + Converts an mp_exp_t value to an Int32 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator int (
    +	mp_exp_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_exp_t
    An mp_exp_t value.

    Return Value

    Type: Int32
    An Int32 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/0177c7b6-b5d5-3815-b64a-4f3a7686bf6d.htm b/docs/html/0177c7b6-b5d5-3815-b64a-4f3a7686bf6d.htm new file mode 100644 index 0000000..ee1d909 --- /dev/null +++ b/docs/html/0177c7b6-b5d5-3815-b64a-4f3a7686bf6d.htm @@ -0,0 +1,17 @@ +void_ptr.Equals Method (Object)
    void_ptrEquals Method (Object)
    + Returns a value indicating whether this instance is equal to a specified object. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override bool Equals(
    +	Object obj
    +)

    Parameters

    obj
    Type: SystemObject
    An object to compare with this instance.

    Return Value

    Type: Boolean
    True if obj is an instance of void_ptr and equals the value of this instance; otherwise, False.
    See Also
    \ No newline at end of file diff --git a/docs/html/018278a0-148f-c898-5bd0-42aae4ae0069.htm b/docs/html/018278a0-148f-c898-5bd0-42aae4ae0069.htm new file mode 100644 index 0000000..97a7e68 --- /dev/null +++ b/docs/html/018278a0-148f-c898-5bd0-42aae4ae0069.htm @@ -0,0 +1,33 @@ +gmp_lib.mpf_inits Method
    Click or drag to resize
    gmp_libmpf_inits Method
    + Initialize a NULL-terminated list of mpf_t variables, and set their values to 0. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_inits(
    +	params mpf_t[] x
    +)

    Parameters

    x
    Type: Math.Gmp.Nativempf_t
    The operand float.
    Remarks

    + The precision of the initialized variables is undefined unless a default precision has already + been established by a call to mpf_set_default_prec(mp_bitcnt_t). +

    Examples
    // Create new floating-point numbers x1, x2 and x3.
    +mpf_t x1 = new mpf_t();
    +mpf_t x2 = new mpf_t();
    +mpf_t x3 = new mpf_t();
    +
    +// Initialize the floating-point numbers.
    +gmp_lib.mpf_inits(x1, x2, x3, null);
    +
    +// Assert that their value is 0.
    +Assert.IsTrue(gmp_lib.mpf_get_d(x1) == 0.0);
    +Assert.IsTrue(gmp_lib.mpf_get_d(x2) == 0.0);
    +Assert.IsTrue(gmp_lib.mpf_get_d(x3) == 0.0);
    +
    +// Release unmanaged memory allocated for the floating-point numbers.
    +gmp_lib.mpf_clears(x1, x2, x3, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/018d9747-3053-df6d-2bb3-5273ad735860.htm b/docs/html/018d9747-3053-df6d-2bb3-5273ad735860.htm new file mode 100644 index 0000000..1485195 --- /dev/null +++ b/docs/html/018d9747-3053-df6d-2bb3-5273ad735860.htm @@ -0,0 +1,9 @@ +mpz_t.ToIntPtr Method
    mpz_tToIntPtr Method
    + Gets the unmanaged memory pointer of the multiple precision integer. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public IntPtr ToIntPtr()

    Return Value

    Type: IntPtr
    The unmanaged memory pointer of the multiple precision integer.
    See Also
    \ No newline at end of file diff --git a/docs/html/020d0663-b84b-54aa-8e2f-645ed532d175.htm b/docs/html/020d0663-b84b-54aa-8e2f-645ed532d175.htm new file mode 100644 index 0000000..9e2f30b --- /dev/null +++ b/docs/html/020d0663-b84b-54aa-8e2f-645ed532d175.htm @@ -0,0 +1,39 @@ +gmp_lib.gmp_urandomm_ui Method
    Click or drag to resize
    gmp_libgmp_urandomm_ui Method
    + Generate a uniformly distributed random number in the range 0 to n - 1, inclusive. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static uint gmp_urandomm_ui(
    +	gmp_randstate_t state,
    +	uint n
    +)

    Parameters

    state
    Type: Math.Gmp.Nativegmp_randstate_t
    The state of the random number generator to use.
    n
    Type: SystemUInt32
    The upper bound of the range.

    Return Value

    Type: UInt32
    The generated random number.
    Examples
    // Create, initialize, and seed a new random number generator.
    +gmp_randstate_t state = new gmp_randstate_t();
    +gmp_lib.gmp_randinit_mt(state);
    +gmp_lib.gmp_randseed_ui(state, 1000U);
    +
    +// Generate a random integer in the range [0, 8-1].
    +uint rand = gmp_lib.gmp_urandomm_ui(state, 8);
    +
    +// Free all memory occupied by state.
    +gmp_lib.gmp_randclear(state);
    See Also
    \ No newline at end of file diff --git a/docs/html/021c96a1-51fa-2b2a-4c65-7ae3bb374c33.htm b/docs/html/021c96a1-51fa-2b2a-4c65-7ae3bb374c33.htm new file mode 100644 index 0000000..2154518 --- /dev/null +++ b/docs/html/021c96a1-51fa-2b2a-4c65-7ae3bb374c33.htm @@ -0,0 +1,21 @@ +mp_exp_t Explicit Conversion Operators
    mp_exp_t  Conversion Operators
    Overload List
    +   + NameDescription
    Public operatorStatic member(Int64 to mp_exp_t)
    + Converts an Int64 value to a mp_exp_t value. +
    Public operatorStatic member(UInt32 to mp_exp_t)
    + Converts a UInt32 value to an mp_exp_t value. +
    Public operatorStatic member(UInt64 to mp_exp_t)
    + Converts a UInt64 value to an mp_exp_t value. +
    Public operatorStatic member(mp_exp_t to Byte)
    + Converts an mp_exp_t value to a Byte value. +
    Public operatorStatic member(mp_exp_t to SByte)
    + Converts an mp_exp_t value to an SByte value. +
    Public operatorStatic member(mp_exp_t to UInt16)
    + Converts an mp_exp_t value to a UInt16 value. +
    Public operatorStatic member(mp_exp_t to Int16)
    + Converts an mp_exp_t value to an Int16 value. +
    Public operatorStatic member(mp_exp_t to UInt32)
    + Converts an mp_exp_t value to a UInt32 value. +
    Public operatorStatic member(mp_exp_t to UInt64)
    + Converts an mp_exp_t value to a UInt64 value. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/0252e04b-b8fc-5a06-e1e2-a0cafbb44296.htm b/docs/html/0252e04b-b8fc-5a06-e1e2-a0cafbb44296.htm new file mode 100644 index 0000000..34e0db0 --- /dev/null +++ b/docs/html/0252e04b-b8fc-5a06-e1e2-a0cafbb44296.htm @@ -0,0 +1,39 @@ +gmp_lib.mpz_kronecker_si Method
    Click or drag to resize
    gmp_libmpz_kronecker_si Method
    + Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_kronecker_si(
    +	mpz_t a,
    +	int b
    +)

    Parameters

    a
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    b
    Type: SystemInt32
    The second operand integer.

    Return Value

    Type: Int32
    The Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
    Remarks

    + When b is odd the Jacobi symbol and Kronecker symbol are identical, + so mpz_kronecker_ui(mpz_t, UInt32), etc. can be used for mixed precision Jacobi symbols too. +

    Examples
    // Create, initialize, and set the value of a to 15.
    +mpz_t a = new mpz_t();
    +gmp_lib.mpz_init_set_ui(a, 15U);
    +
    +// Assert that the Kronecker symbol of (a/4) is 1.
    +Assert.IsTrue(gmp_lib.mpz_kronecker_si(a, 4) == 1);
    +
    +// Release unmanaged memory allocated for a.
    +gmp_lib.mpz_clear(a);
    See Also
    \ No newline at end of file diff --git a/docs/html/028e92d4-3699-77ff-e8da-9ff4c367f5b3.htm b/docs/html/028e92d4-3699-77ff-e8da-9ff4c367f5b3.htm new file mode 100644 index 0000000..179891c --- /dev/null +++ b/docs/html/028e92d4-3699-77ff-e8da-9ff4c367f5b3.htm @@ -0,0 +1,78 @@ +gmp_lib.mpn_sec_mul Method
    Click or drag to resize
    gmp_libmpn_sec_mul Method
    + Set R to A * B, where A = {ap, an}, B = {bp, bn}, and R = {rp, an + bn}. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpn_sec_mul(
    +	mp_ptr rp,
    +	mp_ptr ap,
    +	mp_size_t an,
    +	mp_ptr bp,
    +	mp_size_t bn,
    +	mp_ptr tp
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    ap
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    an
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of ap.
    bp
    Type: Math.Gmp.Nativemp_ptr
    The second operand integer.
    bn
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of bp.
    tp
    Type: Math.Gmp.Nativemp_ptr
    The scratch operand integer.
    Remarks

    + It is required that an ≥ bn > 0. +

    + No overlapping between R and the input operands is allowed. + For A = B, use mpn_sec_sqr(mp_ptr, mp_ptr, mp_size_t, mp_ptr) for optimal performance. +

    + This function requires scratch space of mpn_sec_mul_itch(mp_size_t, mp_size_t)(an, bn) + limbs to be passed in the tp parameter. The scratch space requirements are guaranteed to increase monotonously in the operand sizes. +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
    +mp_ptr bp = new mp_ptr(new uint[] { 0x00000002 });
    +mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff, 0x00000001 });
    +mp_ptr rp = new mp_ptr(ap.Size + bp.Size);
    +
    +// Create scratch space.
    +mp_size_t size = gmp_lib.mpn_sec_mul_itch(ap.Size, bp.Size);
    +mp_ptr tp = new mp_ptr(size);
    +
    +// Set rp = ap * bp.
    +gmp_lib.mpn_sec_mul(rp, ap, ap.Size, bp, bp.Size, tp);
    +
    +// Assert result of operation.
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, ap, bp, tp, result);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/03336561-2bb9-b38f-8adb-506e0fad094b.htm b/docs/html/03336561-2bb9-b38f-8adb-506e0fad094b.htm new file mode 100644 index 0000000..1323fda --- /dev/null +++ b/docs/html/03336561-2bb9-b38f-8adb-506e0fad094b.htm @@ -0,0 +1,43 @@ +gmp_lib.mpq_cmp_ui Method
    Click or drag to resize
    gmp_libmpq_cmp_ui Method
    + Compare op1 and num2 / den2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpq_cmp_ui(
    +	mpq_t op1,
    +	uint num2,
    +	uint den2
    +)

    Parameters

    op1
    Type: Math.Gmp.Nativempq_t
    The first operand rational.
    num2
    Type: SystemUInt32
    The second operand numerator integer.
    den2
    Type: SystemUInt32
    The second operand denominator integer.

    Return Value

    Type: Int32
    Return a positive value if op1 > num2 / den2, zero if op1 = num2 / den2, and a negative value if op1 < num2 / den2.
    Remarks

    num2 and den2 are allowed to have common factors. +

    Examples
    // Create, initialize, and set the value of op1 to 1 / 2.
    +mpq_t op1 = new mpq_t();
    +gmp_lib.mpq_init(op1);
    +gmp_lib.mpq_set_si(op1, 1, 2U);
    +
    +// Assert that op1 == 3/6.
    +Assert.IsTrue(gmp_lib.mpq_cmp_ui(op1, 3, 6U) == 0);
    +
    +// Release unmanaged memory allocated for op1.
    +gmp_lib.mpq_clear(op1);
    See Also
    \ No newline at end of file diff --git a/docs/html/03a17ed9-19e1-9de3-0ea4-4ff3f63938a6.htm b/docs/html/03a17ed9-19e1-9de3-0ea4-4ff3f63938a6.htm new file mode 100644 index 0000000..6d4550c --- /dev/null +++ b/docs/html/03a17ed9-19e1-9de3-0ea4-4ff3f63938a6.htm @@ -0,0 +1,13 @@ +mp_limb_t Explicit Conversion (Int64 to mp_limb_t)
    mp_limb_t  Conversion (Int64 to mp_limb_t)
    + Converts an Int64 value to an mp_limb_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator mp_limb_t (
    +	long value
    +)

    Parameters

    value
    Type: SystemInt64
    An Int64 value.

    Return Value

    Type: mp_limb_t
    An mp_limb_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/04ef14d3-d09c-cfcb-0cea-8984c92612f5.htm b/docs/html/04ef14d3-d09c-cfcb-0cea-8984c92612f5.htm new file mode 100644 index 0000000..e1f3d40 --- /dev/null +++ b/docs/html/04ef14d3-d09c-cfcb-0cea-8984c92612f5.htm @@ -0,0 +1,9 @@ +void_ptr.GetHashCode Method
    void_ptrGetHashCode Method
    + Returns the hash code for this instance. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override int GetHashCode()

    Return Value

    Type: Int32
    A 32-bit signed integer hash code.
    See Also
    \ No newline at end of file diff --git a/docs/html/0521b935-27ad-ca39-ed8a-6c4b4fc51116.htm b/docs/html/0521b935-27ad-ca39-ed8a-6c4b4fc51116.htm new file mode 100644 index 0000000..940d9b6 --- /dev/null +++ b/docs/html/0521b935-27ad-ca39-ed8a-6c4b4fc51116.htm @@ -0,0 +1,7 @@ +void_ptr.Equals Method
    void_ptrEquals Method
    Overload List
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(void_ptr)
    + Returns a value indicating whether this instance is equal to a specified void_ptr value. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/053b54b6-f646-f0aa-ddaf-00c494a6d5ef.htm b/docs/html/053b54b6-f646-f0aa-ddaf-00c494a6d5ef.htm new file mode 100644 index 0000000..c294698 --- /dev/null +++ b/docs/html/053b54b6-f646-f0aa-ddaf-00c494a6d5ef.htm @@ -0,0 +1,78 @@ +gmp_lib.mpz_out_raw Method
    Click or drag to resize
    gmp_libmpz_out_raw Method
    + Output op on stdio stream stream, in raw binary format. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static size_t mpz_out_raw(
    +	ptr<FILE> stream,
    +	mpz_t op
    +)

    Parameters

    stream
    Type: Math.Gmp.NativeptrFILE
    Pointer to file streama.
    op
    Type: Math.Gmp.Nativempz_t
    The operand integer.

    Return Value

    Type: size_t
    Return the number of bytes written, or if an error occurred, return 0.
    Remarks

    + The integer is written in a portable format, with 4 bytes of size information, and that many bytes of limbs. + Both the size and the limbs are written in decreasing significance order (i.e., in big-endian). +

    + The output can be read with mpz_inp_raw(mpz_t, ptrFILE). +

    + The output of this can not be read by mpz_inp_raw from GMP 1, + because of changes necessary for compatibility between 32-bit and 64-bit machines. +

    Examples
    // Create, initialize, and set the value of op to 123456 (0x1E240).
    +mpz_t op = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op, 0x1E240);
    +
    +// Get a temporary file.
    +string pathname = System.IO.Path.GetTempFileName();
    +
    +// Open temporary file for writing.
    +ptr<FILE> stream = new ptr<FILE>();
    +_wfopen_s(out stream.Value.Value, pathname, "w");
    +
    +// Write op to temporary file, and assert that the number of bytes written is 7.
    +Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) == 7);
    +
    +// Close temporary file.
    +fclose(stream.Value.Value);
    +
    +// Assert that the content of the temporary file.
    +byte[] r = System.IO.File.ReadAllBytes(pathname);
    +Assert.IsTrue(r[0] == 0 && r[1] == 0 && r[2] == 0 && r[3] == 3 && r[4] == 0x01 && r[5] == 0xE2 && r[6] == 0x40);
    +
    +// Delete temporary file.
    +System.IO.File.Delete(pathname);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpz_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/058e477a-0126-b073-ee83-77ed89a58351.htm b/docs/html/058e477a-0126-b073-ee83-77ed89a58351.htm new file mode 100644 index 0000000..e11d0f9 --- /dev/null +++ b/docs/html/058e477a-0126-b073-ee83-77ed89a58351.htm @@ -0,0 +1,18 @@ +mpf_t Implicit Conversion (String to mpf_t)
    mpf_t  Conversion (String to mpf_t)
    + Converts a String value to an mpf_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator mpf_t (
    +	string value
    +)

    Parameters

    value
    Type: SystemString
    A String value.

    Return Value

    Type: mpf_t
    An mpf_t value.
    Remarks

    + Base is assumed to be 10 unless the first character of the string is B + followed by the base 2 to 62 or -62 to -2 followed + by a space and then the floating-point number. + Negative values are used to specify that the exponent is in decimal. +

    See Also
    \ No newline at end of file diff --git a/docs/html/05b3707d-5f48-4d76-c42a-566f3179d7f8.htm b/docs/html/05b3707d-5f48-4d76-c42a-566f3179d7f8.htm new file mode 100644 index 0000000..36027c5 --- /dev/null +++ b/docs/html/05b3707d-5f48-4d76-c42a-566f3179d7f8.htm @@ -0,0 +1,52 @@ +gmp_lib.mpz_cdiv_q_ui Method
    Click or drag to resize
    gmp_libmpz_cdiv_q_ui Method
    + Set the quotient q to ceiling(n / d), and return the remainder r = |n - q * d|. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static uint mpz_cdiv_q_ui(
    +	mpz_t q,
    +	mpz_t n,
    +	uint d
    +)

    Parameters

    q
    Type: Math.Gmp.Nativempz_t
    The result quotient integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: SystemUInt32
    The denominator integer.

    Return Value

    Type: UInt32
    Return the remainder r = |n - q * d|.
    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10000);
    +
    +// Create, initialize, and set the value of q to 0.
    +mpz_t q = new mpz_t();
    +gmp_lib.mpz_init(q);
    +
    +// Set q = ceiling(n / 3) and return r = n - 3 * q.
    +// Assert q and r values.
    +Assert.IsTrue(gmp_lib.mpz_cdiv_q_ui(q, n, 3U) == 2U);
    +Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334);
    +
    +// Release unmanaged memory allocated for n and q.
    +gmp_lib.mpz_clears(n, q, null);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/05f897c4-77dc-7735-81ca-65650f61d961.htm b/docs/html/05f897c4-77dc-7735-81ca-65650f61d961.htm new file mode 100644 index 0000000..576bf65 --- /dev/null +++ b/docs/html/05f897c4-77dc-7735-81ca-65650f61d961.htm @@ -0,0 +1,28 @@ +gmp_lib.mpz_cmpabs_ui Method
    Click or drag to resize
    gmp_libmpz_cmpabs_ui Method
    + Compare the absolute values of op1 and op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_cmpabs_ui(
    +	mpz_t op1,
    +	uint op2
    +)

    Parameters

    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: SystemUInt32
    The second operand integer.

    Return Value

    Type: Int32
    Return a positive value if |op1| > |op2|, zero if |op1| = |op2|, or a negative value if |op1| < |op2|.
    Examples
    // Create, initialize, and set the value of op1 to -63.
    +mpz_t op1 = new mpz_t();
    +gmp_lib.mpz_init_set_si(op1, -63);
    +
    +// Assert that |op1| < |70|.
    +Assert.IsTrue(gmp_lib.mpz_cmpabs_ui(op1, 70U) < 0);
    +
    +// Release unmanaged memory allocated for op1.
    +gmp_lib.mpz_clear(op1);
    See Also
    \ No newline at end of file diff --git a/docs/html/060aa73e-8c00-0a6b-f569-ad198c4f0d90.htm b/docs/html/060aa73e-8c00-0a6b-f569-ad198c4f0d90.htm new file mode 100644 index 0000000..af2ecc5 --- /dev/null +++ b/docs/html/060aa73e-8c00-0a6b-f569-ad198c4f0d90.htm @@ -0,0 +1,42 @@ +gmp_lib.mpf_set_ui Method
    Click or drag to resize
    gmp_libmpf_set_ui Method
    + Set the value of rop from op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_set_ui(
    +	mpf_t rop,
    +	uint op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op
    Type: SystemUInt32
    The operand.
    Examples
    // Create and initialize a new floating-point number.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init2(x, 128U);
    +
    +// Set x to 100.
    +gmp_lib.mpf_set_ui(x, 100U);
    +
    +// Assert that the value of x is 100.
    +Assert.IsTrue(gmp_lib.mpf_get_d(x) == 100.0);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpf_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/06249483-9daf-95f9-32c7-30195550bbcc.htm b/docs/html/06249483-9daf-95f9-32c7-30195550bbcc.htm new file mode 100644 index 0000000..40d34f5 --- /dev/null +++ b/docs/html/06249483-9daf-95f9-32c7-30195550bbcc.htm @@ -0,0 +1,34 @@ +char_ptr Structure
    char_ptr Structure
    + Represents a pointer to a string in unmanaged memory. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public struct char_ptr

    The char_ptr type exposes the following members.

    Constructors
    +   + NameDescription
    Public methodchar_ptr
    + Creates new string in unmanaged memory and initializes it with str. +
    Top
    Methods
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(char_ptr)
    + Returns a value indicating whether this instance is equal to a specified char_ptr value. +
    Public methodGetHashCode
    + Returns the hash code for this instance. +
    (Overrides ValueTypeGetHashCode.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Public methodToIntPtr
    + Gets pointer to string in unmanaged memory. +
    Public methodToString
    + Gets the .NET String equivalent of the unmanaged string. +
    (Overrides ValueTypeToString.)
    Top
    Operators
    +   + NameDescription
    Public operatorStatic memberEquality
    + Gets a value that indicates whether the two argument values are equal. +
    Public operatorStatic memberInequality
    + Gets a value that indicates whether the two argument values are different. +
    Top
    Fields
    +   + NameDescription
    Public fieldStatic memberZero
    + Gets a null char_ptr. +
    Top
    Remarks
    See Also
    \ No newline at end of file diff --git a/docs/html/06428417-fb0b-82c7-4b50-99dfe28c7afb.htm b/docs/html/06428417-fb0b-82c7-4b50-99dfe28c7afb.htm new file mode 100644 index 0000000..f496d9d --- /dev/null +++ b/docs/html/06428417-fb0b-82c7-4b50-99dfe28c7afb.htm @@ -0,0 +1,13 @@ +mp_limb_t Explicit Conversion (Int32 to mp_limb_t)
    mp_limb_t  Conversion (Int32 to mp_limb_t)
    + Converts an Int32 value to an mp_limb_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator mp_limb_t (
    +	int value
    +)

    Parameters

    value
    Type: SystemInt32
    An Int32 value.

    Return Value

    Type: mp_limb_t
    An mp_limb_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/067f64f9-7014-8c6a-3c02-153c1460a1dd.htm b/docs/html/067f64f9-7014-8c6a-3c02-153c1460a1dd.htm new file mode 100644 index 0000000..001a399 --- /dev/null +++ b/docs/html/067f64f9-7014-8c6a-3c02-153c1460a1dd.htm @@ -0,0 +1,33 @@ +gmp_lib.reallocate Method
    Click or drag to resize
    gmp_libreallocate Method
    + Resize a previously allocated block ptr of old_size bytes to be new_size bytes. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void_ptr reallocate(
    +	void_ptr ptr,
    +	size_t old_size,
    +	size_t new_size
    +)

    Parameters

    ptr
    Type: Math.Gmp.Nativevoid_ptr
    Pointer to previously allocated block.
    old_size
    Type: Math.Gmp.Nativesize_t
    Number of bytes of previously allocated block.
    new_size
    Type: Math.Gmp.Nativesize_t
    New number of bytes of previously allocated block.

    Return Value

    Type: void_ptr
    A previously allocated block ptr of old_size bytes to be new_size bytes.
    Remarks

    + The block may be moved if necessary or if desired, and in that case the smaller of old_size and + new_size bytes must be copied to the new location. + The return value is a pointer to the resized block, that being the new location if moved or just ptr if not. +

    ptr is never NULL, it’s always a previously allocated block. + new_size may be bigger or smaller than old_size. +

    + The reallocate function parameter old_size is passed for convenience, but of course it can be ignored + if not needed by an implementation. The default functions using malloc and friends for instance don’t use it. +

    See Also
    \ No newline at end of file diff --git a/docs/html/06d850ef-82b2-56f1-32ae-2f1724da3d5b.htm b/docs/html/06d850ef-82b2-56f1-32ae-2f1724da3d5b.htm new file mode 100644 index 0000000..ccad1f5 --- /dev/null +++ b/docs/html/06d850ef-82b2-56f1-32ae-2f1724da3d5b.htm @@ -0,0 +1,39 @@ +gmp_lib.mpn_random2 Method
    Click or drag to resize
    gmp_libmpn_random2 Method
    + Generate a random number of length r1n and store it at r1p. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpn_random2(
    +	mp_ptr r1p,
    +	mp_size_t r1n
    +)

    Parameters

    r1p
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    r1n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of r1p.
    Remarks

    + The most significant limb is always non-zero. + mpn_random(mp_ptr, mp_size_t) generates uniformly distributed limb data, + mpn_random2(mp_ptr, mp_size_t) generates long strings of zeros and ones in the binary representation. +

    mpn_random2(mp_ptr, mp_size_t) is intended for testing the correctness of the mpn routines. +

    Examples
    // Create multi-precision operand.
    +mp_ptr r1p = new mp_ptr(new uint[2]);
    +
    +// Generate random number.
    +gmp_lib.mpn_random2(r1p, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 1);
    +
    +// Release unmanaged memory.
    +gmp_lib.free(r1p);
    See Also
    \ No newline at end of file diff --git a/docs/html/07613c31-7d00-9806-1676-55f8c5a997f8.htm b/docs/html/07613c31-7d00-9806-1676-55f8c5a997f8.htm new file mode 100644 index 0000000..62fa30f --- /dev/null +++ b/docs/html/07613c31-7d00-9806-1676-55f8c5a997f8.htm @@ -0,0 +1,39 @@ +gmp_lib.mpz_kronecker_ui Method
    Click or drag to resize
    gmp_libmpz_kronecker_ui Method
    + Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_kronecker_ui(
    +	mpz_t a,
    +	uint b
    +)

    Parameters

    a
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    b
    Type: SystemUInt32
    The second operand integer.

    Return Value

    Type: Int32
    The Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
    Remarks

    + When b is odd the Jacobi symbol and Kronecker symbol are identical, + so mpz_kronecker_ui(mpz_t, UInt32), etc. can be used for mixed precision Jacobi symbols too. +

    Examples
    // Create, initialize, and set the value of a to 15.
    +mpz_t a = new mpz_t();
    +gmp_lib.mpz_init_set_ui(a, 15U);
    +
    +// Assert that the Kronecker symbol of (a/4) is 1.
    +Assert.IsTrue(gmp_lib.mpz_kronecker_ui(a, 4U) == 1);
    +
    +// Release unmanaged memory allocated for a.
    +gmp_lib.mpz_clear(a);
    See Also
    \ No newline at end of file diff --git a/docs/html/0777a4c0-90d5-95bc-1192-f390bfbcbc43.htm b/docs/html/0777a4c0-90d5-95bc-1192-f390bfbcbc43.htm new file mode 100644 index 0000000..d0aa26c --- /dev/null +++ b/docs/html/0777a4c0-90d5-95bc-1192-f390bfbcbc43.htm @@ -0,0 +1,11 @@ +size_t Methods
    size_t Methods

    The size_t type exposes the following members.

    Methods
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(size_t)
    + Returns a value indicating whether this instance is equal to a specified size_t value. +
    Public methodGetHashCode
    + Returns the hash code for this instance. +
    (Overrides ValueTypeGetHashCode.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Public methodToString
    + Gets the string representation of the size_t. +
    (Overrides ValueTypeToString.)
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/094ea390-8cc8-bac7-35c3-3616775736de.htm b/docs/html/094ea390-8cc8-bac7-35c3-3616775736de.htm new file mode 100644 index 0000000..20aacc6 --- /dev/null +++ b/docs/html/094ea390-8cc8-bac7-35c3-3616775736de.htm @@ -0,0 +1,73 @@ +gmp_lib.mpn_sec_div_r Method
    Click or drag to resize
    gmp_libmpn_sec_div_r Method
    + Set R to N modulo D, where N = {np, nn}, D = {dp, dn}, and R = {np, dn}. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpn_sec_div_r(
    +	mp_ptr np,
    +	mp_size_t nn,
    +	mp_ptr dp,
    +	mp_size_t dn,
    +	mp_ptr tp
    +)

    Parameters

    np
    Type: Math.Gmp.Nativemp_ptr
    The first operand and result integer.
    nn
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of np.
    dp
    Type: Math.Gmp.Nativemp_ptr
    The second operand integer
    dn
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of dp.
    tp
    Type: Math.Gmp.Nativemp_ptr
    The scratch operand integer.
    Remarks

    + It is required that nndn ≥ 1, + and that dp[dn - 1] ≠ 0. + This does not imply that N ≥ D since N might be zero-padded. +

    + Note the overlapping between N and R. + No other operand overlapping is allowed. + The entire space occupied by N is overwritten. +

    + This function requires scratch space of mpn_sec_div_r_itch(mp_size_t, mp_size_t)(nn, dn) + limbs to be passed in the tp parameter. +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr np = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
    +mp_ptr dp = new mp_ptr(new uint[] { 0x00000004 });
    +
    +// Create scratch space.
    +mp_size_t size = gmp_lib.mpn_sec_div_r_itch(np.Size, dp.Size);
    +mp_ptr tp = new mp_ptr(size);
    +
    +// Set np = np mod dp.
    +gmp_lib.mpn_sec_div_r(np, np.Size, dp, dp.Size, tp);
    +
    +// Assert result of operation.
    +Assert.IsTrue(np[0] == 3);
    +
    +// Release unmanaged memory.
    +gmp_lib.free(np, dp, tp);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/096397d8-2db8-7eeb-3b75-25ed0bad8379.htm b/docs/html/096397d8-2db8-7eeb-3b75-25ed0bad8379.htm new file mode 100644 index 0000000..9a098ac --- /dev/null +++ b/docs/html/096397d8-2db8-7eeb-3b75-25ed0bad8379.htm @@ -0,0 +1,7 @@ +mp_size_t.Equals Method
    mp_size_tEquals Method
    Overload List
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(mp_size_t)
    + Returns a value indicating whether this instance is equal to a specified mp_size_t value. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/0968b601-ff25-497d-c2eb-28487c3d29cf.htm b/docs/html/0968b601-ff25-497d-c2eb-28487c3d29cf.htm new file mode 100644 index 0000000..399f34c --- /dev/null +++ b/docs/html/0968b601-ff25-497d-c2eb-28487c3d29cf.htm @@ -0,0 +1,11 @@ +mp_bitcnt_t Methods \ No newline at end of file diff --git a/docs/html/098c8787-2069-5d1e-a2f9-1f78bdcd60a9.htm b/docs/html/098c8787-2069-5d1e-a2f9-1f78bdcd60a9.htm new file mode 100644 index 0000000..3b589f2 --- /dev/null +++ b/docs/html/098c8787-2069-5d1e-a2f9-1f78bdcd60a9.htm @@ -0,0 +1,16 @@ +gmp_lib.mpn_sec_sub_1_itch Method
    Click or drag to resize
    gmp_libmpn_sec_sub_1_itch Method
    + Return the scratch space in number of limbs required by the function mpn_sec_sub_1(mp_ptr, mp_ptr, mp_size_t, mp_limb_t, mp_ptr). +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_size_t mpn_sec_sub_1_itch(
    +	mp_size_t n
    +)

    Parameters

    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of the mpn_sec_sub_1(mp_ptr, mp_ptr, mp_size_t, mp_limb_t, mp_ptr) operand.

    Return Value

    Type: mp_size_t
    The scratch space in number of limbs required by the function mpn_sec_sub_1(mp_ptr, mp_ptr, mp_size_t, mp_limb_t, mp_ptr).
    See Also
    \ No newline at end of file diff --git a/docs/html/0c44ebce-9678-a295-598a-588046225af2.htm b/docs/html/0c44ebce-9678-a295-598a-588046225af2.htm new file mode 100644 index 0000000..1406d99 --- /dev/null +++ b/docs/html/0c44ebce-9678-a295-598a-588046225af2.htm @@ -0,0 +1,13 @@ +mp_exp_t Explicit Conversion (mp_exp_t to Int16)
    mp_exp_t  Conversion (mp_exp_t to Int16)
    + Converts an mp_exp_t value to an Int16 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator short (
    +	mp_exp_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_exp_t
    An mp_exp_t value.

    Return Value

    Type: Int16
    An Int16 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/0ccb1bab-4817-1062-242d-41c181cacf77.htm b/docs/html/0ccb1bab-4817-1062-242d-41c181cacf77.htm new file mode 100644 index 0000000..4a00188 --- /dev/null +++ b/docs/html/0ccb1bab-4817-1062-242d-41c181cacf77.htm @@ -0,0 +1,65 @@ +gmp_lib.mpz_ior Method
    Click or drag to resize
    gmp_libmpz_ior Method
    + Set rop to op1 bitwise inclusive-or op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_ior(
    +	mpz_t rop,
    +	mpz_t op1,
    +	mpz_t op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: Math.Gmp.Nativempz_t
    The second operand integer.
    Remarks

    + The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + The least significant bit is number 0. +

    Examples
    // Create, initialize, and set the value of op1 to 63.
    +mpz_t op1 = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op1, 63U);
    +
    +// Create, initialize, and set the value of op2 to 70.
    +mpz_t op2 = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op2, 70U);
    +
    +// Create, initialize, and set the value of rop to 0.
    +mpz_t rop = new mpz_t();
    +gmp_lib.mpz_init(rop);
    +
    +// Set rop to the bitwise inclusive or of op1 and op2.
    +gmp_lib.mpz_ior(rop, op1, op2);
    +
    +// Assert that rop is 127.
    +Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 127);
    +
    +// Release unmanaged memory allocated for rop, op1, and op2.
    +gmp_lib.mpz_clears(rop, op1, op2, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/0cdaca8f-816e-8c22-f46b-fcf58e9e91d4.htm b/docs/html/0cdaca8f-816e-8c22-f46b-fcf58e9e91d4.htm new file mode 100644 index 0000000..89f5c82 --- /dev/null +++ b/docs/html/0cdaca8f-816e-8c22-f46b-fcf58e9e91d4.htm @@ -0,0 +1,60 @@ +gmp_lib.mpz_lucnum2_ui Method
    Click or drag to resize
    gmp_libmpz_lucnum2_ui Method
    + Sets ln to L[n], and lnsub1 to L[n - 1]. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_lucnum2_ui(
    +	mpz_t ln,
    +	mpz_t lnsub1,
    +	uint n
    +)

    Parameters

    ln
    Type: Math.Gmp.Nativempz_t
    The L[n] result.
    lnsub1
    Type: Math.Gmp.Nativempz_t
    The L[n - 1] result.
    n
    Type: SystemUInt32
    The operand integer.
    Remarks

    + This function is designed for calculating isolated Lucas numbers. + When a sequence of values is wanted it’s best to start with mpz_lucnum2_ui(mpz_t, mpz_t, UInt32) + and iterate the defining L[n + 1] = L[n] + L[n - 1] or similar. +

    + The Fibonacci numbers and Lucas numbers are related sequences, so it’s never necessary to call both + mpz_fib2_ui(mpz_t, mpz_t, UInt32) and mpz_lucnum2_ui(mpz_t, mpz_t, UInt32). + The formulas for going from Fibonacci to Lucas can be found in + GNU MP - Lucas Numbers Algorithm, + the reverse is straightforward too. +

    Examples
    // Create, initialize, and set the values of lnsub1 and ln to 0.
    +mpz_t ln = new mpz_t();
    +mpz_t lnsub1 = new mpz_t();
    +gmp_lib.mpz_inits(ln, lnsub1, null);
    +
    +// Set lnsub1 and ln to the 8'th and 9'th Lucas nunbers respectively.
    +gmp_lib.mpz_lucnum2_ui(ln, lnsub1, 9U);
    +
    +// Assert that lnsub1 and ln are respectively 47 and 76.
    +Assert.IsTrue(gmp_lib.mpz_get_si(lnsub1) == 47);
    +Assert.IsTrue(gmp_lib.mpz_get_si(ln) == 76);
    +
    +// Release unmanaged memory allocated for ln and lnsub1.
    +gmp_lib.mpz_clears(ln, lnsub1, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/0dcf05e1-ec39-5294-c4d0-d8e0f92642e4.htm b/docs/html/0dcf05e1-ec39-5294-c4d0-d8e0f92642e4.htm new file mode 100644 index 0000000..a50aba7 --- /dev/null +++ b/docs/html/0dcf05e1-ec39-5294-c4d0-d8e0f92642e4.htm @@ -0,0 +1,52 @@ +gmp_lib.mpz_fdiv_q_ui Method
    Click or drag to resize
    gmp_libmpz_fdiv_q_ui Method
    + Set the quotient q to floor(n / d), and return the remainder r = |n - q * d|. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static long mpz_fdiv_q_ui(
    +	mpz_t q,
    +	mpz_t n,
    +	uint d
    +)

    Parameters

    q
    Type: Math.Gmp.Nativempz_t
    The result quotient integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: SystemUInt32
    The denominator integer.

    Return Value

    Type: Int64
    Return the remainder r = |n - q * d|.
    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10000);
    +
    +// Create, initialize, and set the value of q to 0.
    +mpz_t q = new mpz_t();
    +gmp_lib.mpz_init(q);
    +
    +// Set q = floor(n / 3) and return r = n - 3 * q.
    +// Assert q and r values.
    +Assert.IsTrue(gmp_lib.mpz_fdiv_q_ui(q, n, 3U) == 1U);
    +Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);
    +
    +// Release unmanaged memory allocated for n and q.
    +gmp_lib.mpz_clears(n, q, null);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/0dd7a5d2-ab07-87dc-79d2-d9b361bc0a34.htm b/docs/html/0dd7a5d2-ab07-87dc-79d2-d9b361bc0a34.htm new file mode 100644 index 0000000..d7c3c67 --- /dev/null +++ b/docs/html/0dd7a5d2-ab07-87dc-79d2-d9b361bc0a34.htm @@ -0,0 +1,9 @@ +mp_bitcnt_t.ToString Method
    mp_bitcnt_tToString Method
    + Gets the string representation of the mp_bitcnt_t. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override string ToString()

    Return Value

    Type: String
    The string representation of the mp_bitcnt_t.
    See Also
    \ No newline at end of file diff --git a/docs/html/0dd846ac-56b6-3ea8-0441-12490f67fbf7.htm b/docs/html/0dd846ac-56b6-3ea8-0441-12490f67fbf7.htm new file mode 100644 index 0000000..dfae71d --- /dev/null +++ b/docs/html/0dd846ac-56b6-3ea8-0441-12490f67fbf7.htm @@ -0,0 +1,43 @@ +gmp_lib.mpf_init Method
    Click or drag to resize
    gmp_libmpf_init Method
    + Initialize x to 0. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_init(
    +	mpf_t x
    +)

    Parameters

    x
    Type: Math.Gmp.Nativempf_t
    The operand float.
    Remarks

    + Normally, a variable should be initialized once only or at least be cleared, using mpf_clear(mpf_t), + between initializations. The precision of x is undefined unless a default precision has + already been established by a call to mpf_set_default_prec(mp_bitcnt_t). +

    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create and initialize a new floating-point number x.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init(x);
    +
    +// Assert that the value of x is 0.0.
    +Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpf_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/0e0a10d5-52ab-1821-6fe1-97514e009418.htm b/docs/html/0e0a10d5-52ab-1821-6fe1-97514e009418.htm new file mode 100644 index 0000000..d666924 --- /dev/null +++ b/docs/html/0e0a10d5-52ab-1821-6fe1-97514e009418.htm @@ -0,0 +1,8 @@ +mpf_t Constructor
    mpf_t Constructor
    + Creates a new multiple precision floating-point number. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public mpf_t()
    See Also
    \ No newline at end of file diff --git a/docs/html/0e7e8afb-9c1f-87e4-4f01-0575c8203613.htm b/docs/html/0e7e8afb-9c1f-87e4-4f01-0575c8203613.htm new file mode 100644 index 0000000..3917af0 --- /dev/null +++ b/docs/html/0e7e8afb-9c1f-87e4-4f01-0575c8203613.htm @@ -0,0 +1,7 @@ +mpq_t Properties
    mpq_t Properties

    The mpq_t type exposes the following members.

    Properties
    +   + NameDescription
    Public property_mp_den
    + Get the denominator integer of the rational. +
    Public property_mp_num
    + Get the numerator integer of the rational. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/0f01fecd-9200-982d-c331-c213f3b960a1.htm b/docs/html/0f01fecd-9200-982d-c331-c213f3b960a1.htm new file mode 100644 index 0000000..e8ff39e --- /dev/null +++ b/docs/html/0f01fecd-9200-982d-c331-c213f3b960a1.htm @@ -0,0 +1,54 @@ +gmp_lib.mpn_xor_n Method
    Click or drag to resize
    gmp_libmpn_xor_n Method
    + Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpn_xor_n(
    +	mp_ptr rp,
    +	mp_ptr s1p,
    +	mp_ptr s2p,
    +	mp_size_t n
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    s1p
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    s2p
    Type: Math.Gmp.Nativemp_ptr
    The second operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of s1p and s2p.
    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
    +mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
    +mp_ptr rp = new mp_ptr(new uint[2]);
    +mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xedcba987 });
    +
    +// Set rp = s1 xor s2.
    +gmp_lib.mpn_xor_n(rp, s1p, s2p, s1p.Size);
    +
    +// Assert result of operation.
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, s1p, s2p, result);
    See Also
    \ No newline at end of file diff --git a/docs/html/0fa7cbf3-e8f4-6b14-d829-8aa663e77c74.htm b/docs/html/0fa7cbf3-e8f4-6b14-d829-8aa663e77c74.htm new file mode 100644 index 0000000..875bfd4 --- /dev/null +++ b/docs/html/0fa7cbf3-e8f4-6b14-d829-8aa663e77c74.htm @@ -0,0 +1,751 @@ +gmp_lib Methods
    Click or drag to resize
    gmp_lib Methods

    The gmp_lib type exposes the following members.

    Methods
    +   + NameDescription
    Public methodStatic memberCode example_mpz_realloc
    + Change the space for integer to new_alloc limbs. +
    Public methodStatic memberallocate
    + Return a pointer to newly allocated space with at least alloc_size bytes. +
    Public methodStatic memberfree(char_ptr)
    + De-allocate the space pointed to by ptr. +
    Public methodStatic memberfree(gmp_randstate_t)
    + De-allocate the space pointed to by ptr. +
    Public methodStatic memberfree(mp_ptr)
    + De-allocate the space pointed to by ptrs. +
    Public methodStatic memberfree(void_ptr)
    + De-allocate the space pointed to by ptr. +
    Public methodStatic memberfree(void_ptr, size_t)
    + De-allocate the space pointed to by ptr. +
    Public methodStatic memberCode examplegmp_asprintf
    + Form a null-terminated string in a block of memory obtained from the current memory allocation function. +
    Public methodStatic memberCode examplegmp_fprintf
    + Print to the stream fp. +
    Public methodStatic memberCode examplegmp_fscanf
    + Read from the stream fp. +
    Public methodStatic memberCode examplegmp_get_memory_functions
    + Get the current allocation functions, storing function pointers to the locations given by the arguments. +
    Public methodStatic memberCode examplegmp_printf
    + Print to the standard output stdout. +
    Public methodStatic membergmp_randclear
    + Free all memory occupied by state. +
    Public methodStatic memberCode examplegmp_randinit_default
    + Initialize state with a default algorithm. +
    Public methodStatic memberCode examplegmp_randinit_lc_2exp
    + Initialize state with a linear congruential algorithm X = (aX + c) mod 2^m2exp. +
    Public methodStatic memberCode examplegmp_randinit_lc_2exp_size
    + Initialize state for a linear congruential algorithm as per gmp_randinit_lc_2exp(gmp_randstate_t, mpz_t, UInt32, mp_bitcnt_t). +
    Public methodStatic memberCode examplegmp_randinit_mt
    + Initialize state for a Mersenne Twister algorithm. +
    Public methodStatic memberCode examplegmp_randinit_set
    + Initialize rop with a copy of the algorithm and state from op. +
    Public methodStatic memberCode examplegmp_randseed
    + Set an initial seed value into state. +
    Public methodStatic memberCode examplegmp_randseed_ui
    + Set an initial seed value into state. +
    Public methodStatic memberCode examplegmp_scanf
    + Read from the standard input stdin. +
    Public methodStatic memberCode examplegmp_set_memory_functions
    + Replace the current allocation functions from the arguments. +
    Public methodStatic memberCode examplegmp_snprintf
    + Form a null-terminated string in buf. +
    Public methodStatic memberCode examplegmp_sprintf
    + Form a null-terminated string in buf. +
    Public methodStatic memberCode examplegmp_sscanf
    + Read from a null-terminated string s. +
    Public methodStatic memberCode examplegmp_urandomb_ui
    + Generate a uniformly distributed random number of n bits, i.e. in the range 0 to 2^n - 1 inclusive. +
    Public methodStatic memberCode examplegmp_urandomm_ui
    + Generate a uniformly distributed random number in the range 0 to n - 1, inclusive. +
    Public methodStatic memberCode examplegmp_vasprintf
    + Form a null-terminated string in a block of memory obtained from the current memory allocation function. +
    Public methodStatic memberCode examplegmp_vfprintf
    + Print to the stream fp. +
    Public methodStatic memberCode examplegmp_vfscanf
    + Read from the stream fp. +
    Public methodStatic memberCode examplegmp_vprintf
    + Print to the standard output stdout. +
    Public methodStatic memberCode examplegmp_vscanf
    + Read from the standard input stdin. +
    Public methodStatic memberCode examplegmp_vsnprintf
    + Form a null-terminated string in buf. +
    Public methodStatic memberCode examplegmp_vsprintf
    + Form a null-terminated string in buf. +
    Public methodStatic memberCode examplegmp_vsscanf
    + Read from a null-terminated string s. +
    Public methodStatic memberCode examplempf_abs
    + Set rop to |op|. +
    Public methodStatic memberCode examplempf_add
    + Set rop to op1 + op2. +
    Public methodStatic memberCode examplempf_add_ui
    + Set rop to op1 + op2. +
    Public methodStatic memberCode examplempf_ceil
    + Set rop to op rounded to the next higher integer. +
    Public methodStatic memberCode examplempf_clear
    + Free the space occupied by x. +
    Public methodStatic memberCode examplempf_clears
    + Free the space occupied by a NULL-terminated list of mpf_t variables. +
    Public methodStatic memberCode examplempf_cmp
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempf_cmp_d
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempf_cmp_si
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempf_cmp_ui
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempf_cmp_z
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempf_div
    + Set rop to op1 / op2. +
    Public methodStatic memberCode examplempf_div_2exp
    + Set rop to op1 / 2^op2. +
    Public methodStatic memberCode examplempf_div_ui
    + Set rop to op1 / op2. +
    Public methodStatic memberCode examplempf_fits_sint_p
    + Return non-zero if op fits in a 32-bit integer, when truncated to an integer. +
    Public methodStatic memberCode examplempf_fits_slong_p
    + Return non-zero if op fits in a 32-bit integer, when truncated to an integer. +
    Public methodStatic memberCode examplempf_fits_sshort_p
    + Return non-zero if op fits in a 16-bit integer, when truncated to an integer. +
    Public methodStatic memberCode examplempf_fits_uint_p
    + Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer. +
    Public methodStatic memberCode examplempf_fits_ulong_p
    + Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer. +
    Public methodStatic memberCode examplempf_fits_ushort_p
    + Return non-zero if op fits in an unsigned 16-bit integer, when truncated to an integer. +
    Public methodStatic memberCode examplempf_floor
    + Set rop to op rounded to the next lower integer. +
    Public methodStatic memberCode examplempf_get_d
    + Convert op to a Double, truncating if necessary (i.e. rounding towards zero). +
    Public methodStatic memberCode examplempf_get_d_2exp
    + Convert op to a double, truncating if necessary (i.e. rounding towards zero), and with an exponent returned separately. +
    Public methodStatic memberCode examplempf_get_default_prec
    + Return the default precision actually used. +
    Public methodStatic memberCode examplempf_get_prec
    + Return the current precision of op, in bits. +
    Public methodStatic memberCode examplempf_get_si
    + Convert op to a 32-bit integer, truncating any fraction part. +
    Public methodStatic memberCode examplempf_get_str
    + Convert op to a string of digits in base base. +
    Public methodStatic memberCode examplempf_get_ui
    + Convert op to an unsigned 32-bit integer, truncating any fraction part. +
    Public methodStatic memberCode examplempf_init
    + Initialize x to 0. +
    Public methodStatic memberCode examplempf_init_set
    + Initialize rop and set its value from op. +
    Public methodStatic memberCode examplempf_init_set_d
    + Initialize rop and set its value from op. +
    Public methodStatic memberCode examplempf_init_set_si
    + Initialize rop and set its value from op. +
    Public methodStatic memberCode examplempf_init_set_str
    + Initialize rop and set its value from the string in str. +
    Public methodStatic memberCode examplempf_init_set_ui
    + Initialize rop and set its value from op. +
    Public methodStatic memberCode examplempf_init2
    + Initialize x to 0 and set its precision to be at least prec bits. +
    Public methodStatic memberCode examplempf_inits
    + Initialize a NULL-terminated list of mpf_t variables, and set their values to 0. +
    Public methodStatic memberCode examplempf_inp_str
    + Read a string in base base from stream, and put the read float in rop. +
    Public methodStatic memberCode examplempf_integer_p
    + Return non-zero if op is an integer. +
    Public methodStatic memberCode examplempf_mul
    + Set rop to op1 * op2. +
    Public methodStatic memberCode examplempf_mul_2exp
    + Set rop to op1 * 2^op2. +
    Public methodStatic memberCode examplempf_mul_ui
    + Set rop to op1 * op2. +
    Public methodStatic memberCode examplempf_neg
    + Set rop to -op. +
    Public methodStatic memberCode examplempf_out_str
    + Print op to stream, as a string of digits. +
    Public methodStatic memberCode examplempf_pow_ui
    + Set rop to op1^op2. +
    Public methodStatic memberCode examplempf_random2
    + Generate a random float of at most max_size limbs, with long strings of zeros and ones in the binary representation. +
    Public methodStatic memberCode examplempf_reldiff
    + Compute the relative difference between op1 and op2 and store the result in rop. This is |op1 - op2| / op1. +
    Public methodStatic memberCode examplempf_set
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempf_set_d
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempf_set_default_prec
    + Set the default precision to be at least prec bits. +
    Public methodStatic memberCode examplempf_set_prec
    + Set the precision of rop to be at least prec bits. +
    Public methodStatic memberCode examplempf_set_prec_raw
    + Set the precision of rop to be at least prec bits, without changing the memory allocated. +
    Public methodStatic memberCode examplempf_set_q
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempf_set_si
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempf_set_str
    + Set the value of rop from the string in str. +
    Public methodStatic memberCode examplempf_set_ui
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempf_set_z
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempf_sgn
    + Return +1 if op > 0, 0 if op = 0, and -1 if op < 0. +
    Public methodStatic memberCode examplempf_size
    + Return the number of limbs currently in use. +
    Public methodStatic memberCode examplempf_sqrt
    + Set rop to the square root of op. +
    Public methodStatic memberCode examplempf_sqrt_ui
    + Set rop to the square root of op. +
    Public methodStatic memberCode examplempf_sub
    + Set rop to op1 - op2. +
    Public methodStatic memberCode examplempf_sub_ui
    + Set rop to op1 - op2. +
    Public methodStatic memberCode examplempf_swap
    + Swap rop1 and rop2 efficiently. +
    Public methodStatic memberCode examplempf_trunc
    + Set rop to op rounded to the integer towards zero. +
    Public methodStatic memberCode examplempf_ui_div
    + Set rop to op1 / op2. +
    Public methodStatic memberCode examplempf_ui_sub
    + Set rop to op1 - op2. +
    Public methodStatic memberCode examplempf_urandomb
    + Generate a uniformly distributed random float in rop, such that 0 ≤ rop < 1, with nbits significant bits in the mantissa or less if the precision of rop is smaller. +
    Public methodStatic memberCode examplempn_add
    + Add {s1p, s1n} and {s2p, s2n}, and write the s1n least significant limbs of the result to rp. +
    Public methodStatic memberCode examplempn_add_1
    + Add {s1p, n} and s2limb, and write the n least significant limbs of the result to rp. +
    Public methodStatic memberCode examplempn_add_n
    + Add {s1p, n} and {s2p, n}, and write the n least significant limbs of the result to rp. +
    Public methodStatic memberCode examplempn_addmul_1
    + Multiply {s1p, n} and s2limb, and add the n least significant limbs of the product to {rp, n} and write the result to rp. +
    Public methodStatic memberCode examplempn_and_n
    + Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_andn_n
    + Perform the bitwise logical and of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_cmp
    + Compare {s1p, n} and {s2p, n}. +
    Public methodStatic memberCode examplempn_cnd_add_n
    + If cnd is non-zero, it produces the same result as a regular mpn_add_n(mp_ptr, mp_ptr, mp_ptr, mp_size_t), and if cnd is zero, it copies {s1p, n} to the result area and returns zero. +
    Public methodStatic memberCode examplempn_cnd_sub_n
    + If cnd is non-zero, it produces the same result as a regular mpn_sub_n(mp_ptr, mp_ptr, mp_ptr, mp_size_t), and if cnd is zero, it copies {s1p, n} to the result area and returns zero. +
    Public methodStatic memberCode examplempn_cnd_swap
    + If cnd is non-zero, swaps the contents of the areas {ap, n} and {bp, n}. Otherwise, the areas are left unmodified. +
    Public methodStatic memberCode examplempn_com
    + Perform the bitwise complement of {sp, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_copyd
    + Copy from {s1p, n} to {rp, n}, decreasingly. +
    Public methodStatic memberCode examplempn_copyi
    + Copy from {s1p, n} to {rp, n}, increasingly. +
    Public methodStatic memberCode examplempn_divexact_1
    + Divide {sp, n} by d, expecting it to divide exactly, and writing the result to {rrp, n}. +
    Public methodStatic memberCode examplempn_divexact_by3
    + Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}. +
    Public methodStatic memberCode examplempn_divexact_by3c
    + Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}. +
    Public methodStatic memberCode examplempn_divmod_1
    + Divide {s2p, s2n} by s3limb, and write the quotient at r1p. +
    Public methodStatic memberCode examplempn_divrem_1
    + Divide {s2p, s2n} by s3limb, and write the quotient at r1p. +
    Public methodStatic memberCode examplempn_gcd
    + Set {rp, retval} to the greatest common divisor of {xp, xn} and {yp, yn}. +
    Public methodStatic memberCode examplempn_gcd_1
    + Return the greatest common divisor of {xp, xn} and ylimb. +
    Public methodStatic memberCode examplempn_gcdext
    + Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT. +
    Public methodStatic memberCode examplempn_get_str
    + Convert {s1p, s1n} to a raw unsigned char array at str in base base, and return the number of characters produced. +
    Public methodStatic memberCode examplempn_hamdist
    + Compute the hamming distance between {s1p, n} and {s2p, n}, which is the number of bit positions where the two operands have different bit values. +
    Public methodStatic memberCode examplempn_ior_n
    + Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_iorn_n
    + Perform the bitwise logical inclusive or of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_lshift
    + Shift {sp, n} left by count bits, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_mod_1
    + Divide {s1p, s1n} by s2limb, and return the remainder. +
    Public methodStatic memberCode examplempn_mul
    + Multiply {s1p, s1n} and {s2p, s2n}, and write the (s1n + s2n)-limb result to rp. +
    Public methodStatic memberCode examplempn_mul_1
    + Multiply {s1p, n} by s2limb, and write the n least significant limbs of the product to rp. +
    Public methodStatic memberCode examplempn_mul_n
    + Multiply {s1p, n} and {s2p, n}, and write the (2 * n)-limb result to rp. +
    Public methodStatic memberCode examplempn_nand_n
    + Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}. +
    Public methodStatic memberCode examplempn_neg
    + Perform the negation of {sp, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_nior_n
    + Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}. +
    Public methodStatic memberCode examplempn_perfect_power_p
    + Return non-zero iff {sp, n} is a perfect power. +
    Public methodStatic memberCode examplempn_perfect_square_p
    + Return non-zero iff {s1p, n} is a perfect square. +
    Public methodStatic memberCode examplempn_popcount
    + Count the number of set bits in {s1p, n}. +
    Public methodStatic memberCode examplempn_random
    + Generate a random number of length r1n and store it at r1p. +
    Public methodStatic memberCode examplempn_random2
    + Generate a random number of length r1n and store it at r1p. +
    Public methodStatic memberCode examplempn_rshift
    + Shift {sp, n} right by count bits, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_scan0
    + Scan s1p from bit position bit for the next clear bit. +
    Public methodStatic memberCode examplempn_scan1
    + Scan s1p from bit position bit for the next set bit. +
    Public methodStatic memberCode examplempn_sec_add_1
    + Set R to A + b, where R = {rp, n}, A = {ap, n}, and b is a single limb. +
    Public methodStatic membermpn_sec_add_1_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_add_1(mp_ptr, mp_ptr, mp_size_t, mp_limb_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_div_qr
    + Set Q to the truncated quotient N / D and R to N modulo D, where N = {np, nn}, D = {dp, dn}, Q’s most significant limb is the function return value and the remaining limbs are {qp, nn - dn}, and R = {np, dn}. +
    Public methodStatic membermpn_sec_div_qr_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_div_qr(mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_div_r
    + Set R to N modulo D, where N = {np, nn}, D = {dp, dn}, and R = {np, dn}. +
    Public methodStatic membermpn_sec_div_r_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_div_r(mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_invert
    + Set R to the inverse of A modulo M, where R = {rp, n}, A = {ap, n}, and M = {mp, n}. This function’s interface is preliminary. +
    Public methodStatic membermpn_sec_invert_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_invert(mp_ptr, mp_ptr, mp_ptr, mp_size_t, mp_bitcnt_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_mul
    + Set R to A * B, where A = {ap, an}, B = {bp, bn}, and R = {rp, an + bn}. +
    Public methodStatic membermpn_sec_mul_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_mul(mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_powm
    + Set R to (B^E) modulo M, where R = {rp, n}, M = {mp, n}, and E = {ep, ceil(enb / mp_bits_per_limb)}. +
    Public methodStatic membermpn_sec_powm_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_powm(mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_bitcnt_t, mp_ptr, mp_size_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_sqr
    + Set R to A^2, where A = {ap, an}, and R = {rp, 2 * an}. +
    Public methodStatic membermpn_sec_sqr_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_sqr(mp_ptr, mp_ptr, mp_size_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_sub_1
    + Set R to A - b, where R = {rp, n}, A = {ap, n}, and b is a single limb. +
    Public methodStatic membermpn_sec_sub_1_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_sub_1(mp_ptr, mp_ptr, mp_size_t, mp_limb_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_tabselect
    + Select entry which from table tab, which has nents entries, each n limbs. Store the selected entry at rp. +
    Public methodStatic memberCode examplempn_set_str
    + Convert bytes {str, strsize} in the given base to limbs at rp. +
    Public methodStatic memberCode examplempn_sizeinbase
    + Return the size of {xp, n} measured in number of digits in the given base. +
    Public methodStatic memberCode examplempn_sqr
    + Compute the square of {s1p, n} and write the (2 * n)-limb result to rp. +
    Public methodStatic memberCode examplempn_sqrtrem
    + Compute the square root of {sp, n} and put the result at {r1p, ceil(n / 2)} and the remainder at {r2p, retval}. +
    Public methodStatic memberCode examplempn_sub
    + Subtract {s2p, s2n} from {s1p, s1n}, and write the s1n least significant limbs of the result to rp. +
    Public methodStatic memberCode examplempn_sub_1
    + Subtract s2limb from {s1p, n}, and write the n least significant limbs of the result to rp. +
    Public methodStatic memberCode examplempn_sub_n
    + Subtract {s2p, n} from {s1p, n}, and write the n least significant limbs of the result to rp. +
    Public methodStatic memberCode examplempn_submul_1
    + Multiply {s1p, n} and s2limb, and subtract the n least significant limbs of the product from {rp, n} and write the result to rp. +
    Public methodStatic memberCode examplempn_tdiv_qr
    + Divide {np, nn} by {dp, dn} and put the quotient at {qp, nn - dn + 1} and the remainder at {rp, dn}. +
    Public methodStatic memberCode examplempn_xnor_n
    + Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}. +
    Public methodStatic memberCode examplempn_xor_n
    + Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_zero
    + Zero {rp, n}. +
    Public methodStatic memberCode examplempn_zero_p
    + Test {sp, n} and return 1 if the operand is zero, 0 otherwise. +
    Public methodStatic memberCode examplempq_abs
    + Set rop to the absolute value of op. +
    Public methodStatic memberCode examplempq_add
    + Set sum to addend1 + addend2. +
    Public methodStatic memberCode examplempq_canonicalize
    + Remove any factors that are common to the numerator and denominator of op, and make the denominator positive. +
    Public methodStatic memberCode examplempq_clear
    + Free the space occupied by x. +
    Public methodStatic memberCode examplempq_clears
    + Free the space occupied by a NULL-terminated list of mpq_t variables. +
    Public methodStatic memberCode examplempq_cmp
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempq_cmp_si
    + Compare op1 and num2 / den2. +
    Public methodStatic memberCode examplempq_cmp_ui
    + Compare op1 and num2 / den2. +
    Public methodStatic memberCode examplempq_cmp_z
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempq_denref
    + Return a reference to the denominator op. +
    Public methodStatic memberCode examplempq_div
    + Set quotient to dividend / divisor. +
    Public methodStatic memberCode examplempq_div_2exp
    + Set rop to op1 / 2^op2. +
    Public methodStatic memberCode examplempq_equal
    + Return non-zero if op1 and op2 are equal, zero if they are non-equal. +
    Public methodStatic memberCode examplempq_get_d
    + Convert op to a Double, truncating if necessary (i.e. rounding towards zero). +
    Public methodStatic memberCode examplempq_get_den
    + Set denominator to the denominator of rational. +
    Public methodStatic memberCode examplempq_get_num
    + Set numerator to the numerator of rational. +
    Public methodStatic memberCode examplempq_get_str
    + Convert op to a string of digits in base base. +
    Public methodStatic memberCode examplempq_init
    + Initialize x and set it to 0/1. +
    Public methodStatic memberCode examplempq_inits
    + Initialize a NULL-terminated list of mpq_t variables, and set their values to 0/1. +
    Public methodStatic memberCode examplempq_inp_str
    + Read a string of digits from stream and convert them to a rational in rop. +
    Public methodStatic memberCode examplempq_inv
    + Set inverted_number to 1 / number. +
    Public methodStatic memberCode examplempq_mul
    + Set product to multiplier * multiplicand. +
    Public methodStatic memberCode examplempq_mul_2exp
    + Set rop to op1 * 2*op2. +
    Public methodStatic memberCode examplempq_neg
    + Set negated_operand to -operand. +
    Public methodStatic memberCode examplempq_numref
    + Return a reference to the numerator op. +
    Public methodStatic memberCode examplempq_out_str
    + Output op on stdio stream stream, as a string of digits in base base. +
    Public methodStatic memberCode examplempq_set
    + Assign rop from op. +
    Public methodStatic memberCode examplempq_set_d
    + Set rop to the value of op. There is no rounding, this conversion is exact. +
    Public methodStatic memberCode examplempq_set_den
    + Set the denominator of rational to denominator. +
    Public methodStatic memberCode examplempq_set_f
    + Set rop to the value of op. There is no rounding, this conversion is exact. +
    Public methodStatic memberCode examplempq_set_num
    + Set the numerator of rational to numerator. +
    Public methodStatic memberCode examplempq_set_si
    + Set the value of rop to op1 / op2. +
    Public methodStatic memberCode examplempq_set_str
    + Set rop from a null-terminated string str in the given base. +
    Public methodStatic memberCode examplempq_set_ui
    + Set the value of rop to op1 / op2. +
    Public methodStatic memberCode examplempq_set_z
    + Assign rop from op. +
    Public methodStatic memberCode examplempq_sgn
    + Return +1 if op > 0, 0 if op = 0, and -1 if op < 0. +
    Public methodStatic memberCode examplempq_sub
    + Set difference to minuend - subtrahend. +
    Public methodStatic memberCode examplempq_swap
    + Swap the values rop1 and rop2 efficiently. +
    Public methodStatic memberCode examplempz_2fac_ui
    + Set rop to the double-factorial n!!. +
    Public methodStatic memberCode examplempz_abs
    + Set rop to the absolute value of op. +
    Public methodStatic memberCode examplempz_add
    + Set rop to op1 + op2. +
    Public methodStatic memberCode examplempz_add_ui
    + Set rop to op1 + op2. +
    Public methodStatic memberCode examplempz_addmul
    + Set rop to rop + op1 * op2. +
    Public methodStatic memberCode examplempz_addmul_ui
    + Set rop to rop + op1 * op2. +
    Public methodStatic memberCode examplempz_and
    + Set rop to op1 bitwise-and op2. +
    Public methodStatic memberCode examplempz_bin_ui
    + Compute the binomial coefficient n over k and store the result in rop. +
    Public methodStatic memberCode examplempz_bin_uiui
    + Compute the binomial coefficient n over k and store the result in rop. +
    Public methodStatic memberCode examplempz_cdiv_q
    + Set the quotient q to ceiling(n / d). +
    Public methodStatic memberCode examplempz_cdiv_q_2exp
    + Set the quotient q to ceiling(n / 2^b). +
    Public methodStatic memberCode examplempz_cdiv_q_ui
    + Set the quotient q to ceiling(n / d), and return the remainder r = |n - q * d|. +
    Public methodStatic memberCode examplempz_cdiv_qr
    + Set the quotient q to ceiling(n / d), and set the remainder r to n - q * d. +
    Public methodStatic memberCode examplempz_cdiv_qr_ui
    + Set quotient q to ceiling(n / d), set the remainder r to n - q * d, and return |r|. +
    Public methodStatic memberCode examplempz_cdiv_r
    + Set the remainder r to n - q * d where q = ceiling(n / d). +
    Public methodStatic memberCode examplempz_cdiv_r_2exp
    + Set the remainder r to n - q * 2^b where q = ceiling(n / 2^b). +
    Public methodStatic memberCode examplempz_cdiv_r_ui
    + Set the remainder r to n - q * d where q = ceiling(n / d), and return |r|. +
    Public methodStatic memberCode examplempz_cdiv_ui
    + Return the remainder |r| where r = n - q * d, and where q = ceiling(n / d). +
    Public methodStatic memberCode examplempz_clear
    + Free the space occupied by x. +
    Public methodStatic memberCode examplempz_clears
    + Free the space occupied by a NULL-terminated list of mpz_t variables. +
    Public methodStatic memberCode examplempz_clrbit
    + Clear bit bit_index in rop. +
    Public methodStatic memberCode examplempz_cmp
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempz_cmp_d
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempz_cmp_si
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempz_cmp_ui
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempz_cmpabs
    + Compare the absolute values of op1 and op2. +
    Public methodStatic memberCode examplempz_cmpabs_d
    + Compare the absolute values of op1 and op2. +
    Public methodStatic memberCode examplempz_cmpabs_ui
    + Compare the absolute values of op1 and op2. +
    Public methodStatic memberCode examplempz_com
    + Set rop to the one’s complement of op. +
    Public methodStatic memberCode examplempz_combit
    + Complement bit bit_index in rop. +
    Public methodStatic memberCode examplempz_congruent_2exp_p
    + Return non-zero if n is congruent to c modulo 2^b. +
    Public methodStatic memberCode examplempz_congruent_p
    + Return non-zero if n is congruent to c modulo d. +
    Public methodStatic memberCode examplempz_congruent_ui_p
    + Return non-zero if n is congruent to c modulo d. +
    Public methodStatic memberCode examplempz_divexact
    + Set q to n / d when it is known in advance that d divides n. +
    Public methodStatic memberCode examplempz_divexact_ui
    + Set q to n / d when it is known in advance that d divides n. +
    Public methodStatic memberCode examplempz_divisible_2exp_p
    + Return non-zero if n is exactly divisible by 2^b. +
    Public methodStatic memberCode examplempz_divisible_p
    + Return non-zero if n is exactly divisible by d. +
    Public methodStatic memberCode examplempz_divisible_ui_p
    + Return non-zero if n is exactly divisible by d. +
    Public methodStatic memberCode examplempz_even_p
    + Determine whether op is even. +
    Public methodStatic memberCode examplempz_export
    + Fill rop with word data from op. +
    Public methodStatic memberCode examplempz_fac_ui
    + Set rop to the factorial n!. +
    Public methodStatic memberCode examplempz_fdiv_q
    + Set the quotient q to floor(n / d). +
    Public methodStatic memberCode examplempz_fdiv_q_2exp
    + Set the quotient q to floor(n / 2^b). +
    Public methodStatic memberCode examplempz_fdiv_q_ui
    + Set the quotient q to floor(n / d), and return the remainder r = |n - q * d|. +
    Public methodStatic memberCode examplempz_fdiv_qr
    + Set the quotient q to floor(n / d), and set the remainder r to n - q * d. +
    Public methodStatic memberCode examplempz_fdiv_qr_ui
    + Set quotient q to floor(n / d), set the remainder r to n - q * d, and return |r|. +
    Public methodStatic memberCode examplempz_fdiv_r
    + Set the remainder r to n - q * d where q = floor(n / d). +
    Public methodStatic memberCode examplempz_fdiv_r_2exp
    + Set the remainder r to n - q * 2^b where q = floor(n / 2^b). +
    Public methodStatic memberCode examplempz_fdiv_r_ui
    + Set the remainder r to n - q * d where q = floor(n / d), and return |r|. +
    Public methodStatic memberCode examplempz_fdiv_ui
    + Return the remainder |r| where r = n - q * d, and where q = floor(n / d). +
    Public methodStatic memberCode examplempz_fib_ui
    + Sets fn to to F[n], the n’th Fibonacci number. +
    Public methodStatic memberCode examplempz_fib2_ui
    + Sets fn to F[n], and fnsub1 to F[n - 1]. +
    Public methodStatic memberCode examplempz_fits_sint_p
    + Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero. +
    Public methodStatic memberCode examplempz_fits_slong_p
    + Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero. +
    Public methodStatic memberCode examplempz_fits_sshort_p
    + Return non-zero iff the value of op fits in a signed 16-bit integer. Otherwise, return zero. +
    Public methodStatic memberCode examplempz_fits_uint_p
    + Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero. +
    Public methodStatic memberCode examplempz_fits_ulong_p
    + Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero. +
    Public methodStatic memberCode examplempz_fits_ushort_p
    + Return non-zero iff the value of op fits in an unsigned 16-bit integer. Otherwise, return zero. +
    Public methodStatic memberCode examplempz_gcd
    + Set rop to the greatest common divisor of op1 and op2. +
    Public methodStatic memberCode examplempz_gcd_ui
    + Compute the greatest common divisor of op1 and op2. If rop is not null, store the result there. +
    Public methodStatic memberCode examplempz_gcdext
    + Set g to the greatest common divisor of a and b, and in addition set s and t to coefficients satisfying a * s + b * t = g. +
    Public methodStatic memberCode examplempz_get_d
    + Convert op to a double, truncating if necessary (i.e. rounding towards zero). +
    Public methodStatic memberCode examplempz_get_d_2exp
    + Convert op to a double, truncating if necessary (i.e. rounding towards zero), and returning the exponent separately. +
    Public methodStatic memberCode examplempz_get_si
    + Return the value of op as an signed long. +
    Public methodStatic memberCode examplempz_get_str
    + Convert op to a string of digits in base base. +
    Public methodStatic memberCode examplempz_get_ui
    + Return the value of op as an unsigned long. +
    Public methodStatic memberCode examplempz_getlimbn
    + Return limb number n from op. +
    Public methodStatic memberCode examplempz_hamdist
    + Return the hamming distance between the two operands. +
    Public methodStatic memberCode examplempz_import
    + Set rop from an array of word data at op. +
    Public methodStatic memberCode examplempz_init
    + Initialize x, and set its value to 0. +
    Public methodStatic memberCode examplempz_init_set
    + Initialize rop with limb space and set the initial numeric value from op. +
    Public methodStatic memberCode examplempz_init_set_d
    + Initialize rop with limb space and set the initial numeric value from op. +
    Public methodStatic memberCode examplempz_init_set_si
    + Initialize rop with limb space and set the initial numeric value from op. +
    Public methodStatic memberCode examplempz_init_set_str
    + Initialize rop and set its value like mpz_set_str(mpz_t, char_ptr, Int32). +
    Public methodStatic memberCode examplempz_init_set_ui
    + Initialize rop with limb space and set the initial numeric value from op. +
    Public methodStatic memberCode examplempz_init2
    + Initialize x, with space for n-bit numbers, and set its value to 0. +
    Public methodStatic memberCode examplempz_inits
    + Initialize a NULL-terminated list of mpz_t variables, and set their values to 0. +
    Public methodStatic memberCode examplempz_inp_raw
    Public methodStatic memberCode examplempz_inp_str
    + Input a possibly white-space preceded string in base base from stdio stream stream, and put the read integer in rop. +
    Public methodStatic memberCode examplempz_invert
    + Compute the inverse of op1 modulo op2 and put the result in rop. +
    Public methodStatic memberCode examplempz_ior
    + Set rop to op1 bitwise inclusive-or op2. +
    Public methodStatic memberCode examplempz_jacobi
    + Calculate the Jacobi symbol (a/b). +
    Public methodStatic memberCode examplempz_kronecker
    + Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even. +
    Public methodStatic memberCode examplempz_kronecker_si
    + Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even. +
    Public methodStatic memberCode examplempz_kronecker_ui
    + Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even. +
    Public methodStatic memberCode examplempz_lcm
    + Set rop to the least common multiple of op1 and op2. +
    Public methodStatic memberCode examplempz_lcm_ui
    + Set rop to the least common multiple of op1 and op2. +
    Public methodStatic memberCode examplempz_legendre
    + Calculate the Legendre symbol (a/p). +
    Public methodStatic membermpz_limbs_finish
    + Updates the internal size field of x. +
    Public methodStatic memberCode examplempz_limbs_modify
    + Return a pointer to the limb array of x, intended for write access. +
    Public methodStatic memberCode examplempz_limbs_read
    + Return a pointer to the limb array representing the absolute value of x. +
    Public methodStatic memberCode examplempz_limbs_write
    + Return a pointer to the limb array of x, intended for write access. +
    Public methodStatic memberCode examplempz_lucnum_ui
    + Sets ln to to L[n], the n’th Lucas number. +
    Public methodStatic memberCode examplempz_lucnum2_ui
    + Sets ln to L[n], and lnsub1 to L[n - 1]. +
    Public methodStatic memberCode examplempz_mfac_uiui
    + Set rop to the m-multi-factorial n!^(m)n. +
    Public methodStatic memberCode examplempz_millerrabin
    + An implementation of the probabilistic primality test found in Knuth's Seminumerical Algorithms book. +
    Public methodStatic memberCode examplempz_mod
    + Set r to n mod d. +
    Public methodStatic memberCode examplempz_mod_ui
    + Set r to n mod d. +
    Public methodStatic memberCode examplempz_mul
    + Set rop to op1 * op2. +
    Public methodStatic memberCode examplempz_mul_2exp
    + Set rop to op1 * 2^op2. +
    Public methodStatic memberCode examplempz_mul_si
    + Set rop to op1 * op2. +
    Public methodStatic memberCode examplempz_mul_ui
    + Set rop to op1 * op2. +
    Public methodStatic memberCode examplempz_neg
    + Set rop to -op. +
    Public methodStatic memberCode examplempz_nextprime
    + Set rop to the next prime greater than op. +
    Public methodStatic memberCode examplempz_odd_p
    + Determine whether op is odd. +
    Public methodStatic memberCode examplempz_out_raw
    + Output op on stdio stream stream, in raw binary format. +
    Public methodStatic memberCode examplempz_out_str
    + Output op on stdio stream stream, as a string of digits in base base. +
    Public methodStatic memberCode examplempz_perfect_power_p
    + Return non-zero if op is a perfect power, i.e., if there exist integers a and b, with b > 1, such that op = a^b. +
    Public methodStatic memberCode examplempz_perfect_square_p
    + Return non-zero if op is a perfect square, i.e., if the square root of op is an integer. +
    Public methodStatic memberCode examplempz_popcount
    + Return the population count of op. +
    Public methodStatic memberCode examplempz_pow_ui
    + Set rop to base^exp. The case 0^0 yields 1. +
    Public methodStatic memberCode examplempz_powm
    + Set rop to (base^exp) modulo mod. +
    Public methodStatic memberCode examplempz_powm_sec
    + Set rop to (base^exp) modulo mod. +
    Public methodStatic memberCode examplempz_powm_ui
    + Set rop to (base^exp) modulo mod. +
    Public methodStatic memberCode examplempz_primorial_ui
    + Set rop to the primorial of n, i.e. the product of all positive prime numbers n. +
    Public methodStatic memberCode examplempz_probab_prime_p
    + Determine whether n is prime. +
    Public methodStatic memberCode examplempz_random
    + Generate a random integer of at most max_size limbs. +
    Public methodStatic memberCode examplempz_random2
    + Generate a random integer of at most max_size limbs, with long strings of zeros and ones in the binary representation. +
    Public methodStatic memberCode examplempz_realloc2
    + Change the space allocated for x to n bits. +
    Public methodStatic memberCode examplempz_remove
    + Remove all occurrences of the factor f from op and store the result in rop. +
    Public methodStatic memberCode examplempz_roinit_n
    + Special initialization of x, using the given limb array and size. +
    Public methodStatic memberCode examplempz_root
    + Set rop to the truncated integer part of the nth root of op. +
    Public methodStatic memberCode examplempz_rootrem
    + Set root to the truncated integer part of the nth root of u. Set rem to the remainder, u - root^n. +
    Public methodStatic memberCode examplempz_rrandomb
    + Generate a random integer with long strings of zeros and ones in the binary representation. +
    Public methodStatic memberCode examplempz_scan0
    + Scan op for 0 bit. +
    Public methodStatic memberCode examplempz_scan1
    + Scan op for 1 bit. +
    Public methodStatic memberCode examplempz_set
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempz_set_d
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempz_set_f
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempz_set_q
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempz_set_si
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempz_set_str
    + Set the value of rop from str, a null-terminated C string in base base. +
    Public methodStatic memberCode examplempz_set_ui
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempz_setbit
    + Set bit bit_index in rop. +
    Public methodStatic memberCode examplempz_sgn
    + Return +1 if op > 0, 0 if op = 0, and -1 if op < 0. +
    Public methodStatic memberCode examplempz_si_kronecker
    + Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even. +
    Public methodStatic memberCode examplempz_size
    + Return the size of op measured in number of limbs. +
    Public methodStatic memberCode examplempz_sizeinbase
    + Return the size of op measured in number of digits in the given base. +
    Public methodStatic memberCode examplempz_sqrt
    + Set rop to the truncated integer part of the square root of op. +
    Public methodStatic memberCode examplempz_sqrtrem
    + Set rop1 to the truncated integer part of the square root of op, like mpz_sqrt(mpz_t, mpz_t). Set rop2 to the remainder op - rop1 * rop1, which will be zero if op is a perfect square. +
    Public methodStatic memberCode examplempz_sub
    + Set rop to op1 - op2. +
    Public methodStatic memberCode examplempz_sub_ui
    + Set rop to op1 - op2. +
    Public methodStatic memberCode examplempz_submul
    + Set rop to rop - op1 * op2. +
    Public methodStatic memberCode examplempz_submul_ui
    + Set rop to rop - op1 * op2. +
    Public methodStatic memberCode examplempz_swap
    + Swap the values rop1 and rop2 efficiently. +
    Public methodStatic memberCode examplempz_tdiv_q
    + Set the quotient q to trunc(n / d). +
    Public methodStatic memberCode examplempz_tdiv_q_2exp
    + Set the quotient q to trunc(n / 2^b). +
    Public methodStatic memberCode examplempz_tdiv_q_ui
    + Set the quotient q to trunc(n / d), and return the remainder r = |n - q * d|. +
    Public methodStatic memberCode examplempz_tdiv_qr
    + Set the quotient q to trunc(n / d), and set the remainder r to n - q * d. +
    Public methodStatic memberCode examplempz_tdiv_qr_ui
    + Set quotient q to trunc(n / d), set the remainder r to n - q * d, and return |r|. +
    Public methodStatic memberCode examplempz_tdiv_r
    + Set the remainder r to n - q * d where q = trunc(n / d). +
    Public methodStatic memberCode examplempz_tdiv_r_2exp
    + Set the remainder r to n - q * 2^b where q = trunc(n / 2^b). +
    Public methodStatic memberCode examplempz_tdiv_r_ui
    + Set the remainder r to n - q * d where q = trunc(n / d), and return |r|. +
    Public methodStatic memberCode examplempz_tdiv_ui
    + Return the remainder |r| where r = n - q * d, and where q = trunc(n / d). +
    Public methodStatic memberCode examplempz_tstbit
    + Test bit bit_index in op and return 0 or 1 accordingly. +
    Public methodStatic memberCode examplempz_ui_kronecker
    + Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even. +
    Public methodStatic memberCode examplempz_ui_pow_ui
    + Set rop to base^exp. The case 0^0 yields 1. +
    Public methodStatic memberCode examplempz_ui_sub
    + Set rop to op1 - op2. +
    Public methodStatic memberCode examplempz_urandomb
    + Generate a uniformly distributed random integer in the range 0 to 2^n - 1, inclusive. +
    Public methodStatic memberCode examplempz_urandomm
    + Generate a uniform random integer in the range 0 to n - 1, inclusive. +
    Public methodStatic memberCode examplempz_xor
    + Set rop to op1 bitwise exclusive-or op2. +
    Public methodStatic memberreallocate
    + Resize a previously allocated block ptr of old_size bytes to be new_size bytes. +
    Public methodStatic memberZeroMemory
    + The ZeroMemory(IntPtr, Int32) routine fills a block of memory with zeros, given a pointer to the block and the length, in bytes, to be filled. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/0fcbb911-bc5a-1b11-90c5-96babff86526.htm b/docs/html/0fcbb911-bc5a-1b11-90c5-96babff86526.htm new file mode 100644 index 0000000..c313b8f --- /dev/null +++ b/docs/html/0fcbb911-bc5a-1b11-90c5-96babff86526.htm @@ -0,0 +1,8 @@ +mpz_t Constructor
    mpz_t Constructor
    + Creates a new multiple precision integer. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public mpz_t()
    See Also
    \ No newline at end of file diff --git a/docs/html/1176cc4e-ffda-2993-1a4a-2e0c7ed24adb.htm b/docs/html/1176cc4e-ffda-2993-1a4a-2e0c7ed24adb.htm new file mode 100644 index 0000000..8df256b --- /dev/null +++ b/docs/html/1176cc4e-ffda-2993-1a4a-2e0c7ed24adb.htm @@ -0,0 +1,34 @@ +gmp_lib.mpq_sgn Method
    Click or drag to resize
    gmp_libmpq_sgn Method
    + Return +1 if op > 0, 0 if op = 0, and -1 if op < 0. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpq_sgn(
    +	mpq_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempq_t
    The operand rational.

    Return Value

    Type: Int32
    Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.
    Examples
    // Create, initialize, and set a new rational x to -10 / 11.
    +mpq_t op = new mpq_t();
    +gmp_lib.mpq_init(op);
    +gmp_lib.mpq_set_si(op, -10, 11);
    +
    +// Assert that op is negative.
    +Assert.IsTrue(gmp_lib.mpq_sgn(op) == -1);
    +
    +// Release unmanaged memory allocated for x and y.
    +gmp_lib.mpq_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/11a036ec-5052-7dc4-bdb6-10e5c92f88cc.htm b/docs/html/11a036ec-5052-7dc4-bdb6-10e5c92f88cc.htm new file mode 100644 index 0000000..f96cbfa --- /dev/null +++ b/docs/html/11a036ec-5052-7dc4-bdb6-10e5c92f88cc.htm @@ -0,0 +1,37 @@ +gmp_lib.mpf_integer_p Method
    Click or drag to resize
    gmp_libmpf_integer_p Method
    + Return non-zero if op is an integer. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpf_integer_p(
    +	mpf_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempf_t
    The operand float.

    Return Value

    Type: Int32
    Return non-zero if op is an integer.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 10.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_d(x, 10);
    +
    +// Assert that s is an integer.
    +Assert.IsTrue(gmp_lib.mpf_integer_p(x) != 0);
    +
    +// Release unmanaged memory allocated for x.
    See Also
    \ No newline at end of file diff --git a/docs/html/11e36fbc-ffc4-46df-50b7-2b07684c1755.htm b/docs/html/11e36fbc-ffc4-46df-50b7-2b07684c1755.htm new file mode 100644 index 0000000..e445ded --- /dev/null +++ b/docs/html/11e36fbc-ffc4-46df-50b7-2b07684c1755.htm @@ -0,0 +1,56 @@ +gmp_lib.mpq_swap Method
    Click or drag to resize
    gmp_libmpq_swap Method
    + Swap the values rop1 and rop2 efficiently. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpq_swap(
    +	mpq_t rop1,
    +	mpq_t rop2
    +)

    Parameters

    rop1
    Type: Math.Gmp.Nativempq_t
    The first rational.
    rop2
    Type: Math.Gmp.Nativempq_t
    The second rational.
    Examples
    // Create, initialize, and set a new rational x to 10 / 11.
    +mpq_t x = new mpq_t();
    +gmp_lib.mpq_init(x);
    +gmp_lib.mpq_set_si(x, 10, 11U);
    +
    +// Create, initialize, and set a new rational x to -210 / 13.
    +mpq_t y = new mpq_t();
    +gmp_lib.mpq_init(y);
    +gmp_lib.mpq_set_si(y, -210, 13U);
    +
    +// Swap the values of x and y.
    +gmp_lib.mpq_swap(x, y);
    +
    +// Assert that the values have been swapped.
    +Assert.IsTrue(gmp_lib.mpq_cmp_si(x, -210, 13U) == 0);
    +Assert.IsTrue(gmp_lib.mpq_cmp_si(y, 10, 11U) == 0);
    +
    +// Release unmanaged memory allocated for x and y.
    +gmp_lib.mpq_clears(x, y, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/12a4c9d6-02cf-e913-816e-ad530e77722c.htm b/docs/html/12a4c9d6-02cf-e913-816e-ad530e77722c.htm new file mode 100644 index 0000000..9c3db18 --- /dev/null +++ b/docs/html/12a4c9d6-02cf-e913-816e-ad530e77722c.htm @@ -0,0 +1,5 @@ +void_ptr Fields
    void_ptr Fields

    The void_ptr type exposes the following members.

    Fields
    +   + NameDescription
    Public fieldStatic memberZero
    + Gets a null void_ptr. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/13c05087-b2db-4751-d548-4fa64e30f663.htm b/docs/html/13c05087-b2db-4751-d548-4fa64e30f663.htm new file mode 100644 index 0000000..0aa6281 --- /dev/null +++ b/docs/html/13c05087-b2db-4751-d548-4fa64e30f663.htm @@ -0,0 +1,17 @@ +mp_size_t Implicit Conversion Operators
    \ No newline at end of file diff --git a/docs/html/142199e1-6aef-83d5-1986-1b1248ddc6e3.htm b/docs/html/142199e1-6aef-83d5-1986-1b1248ddc6e3.htm new file mode 100644 index 0000000..0cbe490 --- /dev/null +++ b/docs/html/142199e1-6aef-83d5-1986-1b1248ddc6e3.htm @@ -0,0 +1,32 @@ +gmp_lib.mpf_fits_sshort_p Method
    Click or drag to resize
    gmp_libmpf_fits_sshort_p Method
    + Return non-zero if op fits in a 16-bit integer, when truncated to an integer. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpf_fits_sshort_p(
    +	mpf_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempf_t
    The operand float.

    Return Value

    Type: Int32
    Return non-zero if op fits in a 16-bit integer, when truncated to an integer.
    Examples
    // Create, initialize, and set the value of op 4294967295.
    +mpf_t op = new mpf_t();
    +gmp_lib.mpf_init_set_ui(op, uint.MaxValue);
    +
    +// Assert that op does not fit in short.
    +Assert.IsTrue(gmp_lib.mpf_fits_sshort_p(op) == 0);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpf_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/1443760d-18a5-f276-ec75-7b8ead9d8332.htm b/docs/html/1443760d-18a5-f276-ec75-7b8ead9d8332.htm new file mode 100644 index 0000000..5685ca3 --- /dev/null +++ b/docs/html/1443760d-18a5-f276-ec75-7b8ead9d8332.htm @@ -0,0 +1,9 @@ +mp_exp_t.GetHashCode Method
    mp_exp_tGetHashCode Method
    + Returns the hash code for this instance. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override int GetHashCode()

    Return Value

    Type: Int32
    A 32-bit signed integer hash code.
    See Also
    \ No newline at end of file diff --git a/docs/html/1555cd52-98d2-6253-214a-d342a539bfb5.htm b/docs/html/1555cd52-98d2-6253-214a-d342a539bfb5.htm new file mode 100644 index 0000000..34a1fd0 --- /dev/null +++ b/docs/html/1555cd52-98d2-6253-214a-d342a539bfb5.htm @@ -0,0 +1,70 @@ +gmp_lib.mpn_sec_add_1 Method
    Click or drag to resize
    gmp_libmpn_sec_add_1 Method
    + Set R to A + b, where R = {rp, n}, A = {ap, n}, and b is a single limb. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_limb_t mpn_sec_add_1(
    +	mp_ptr rp,
    +	mp_ptr ap,
    +	mp_size_t n,
    +	mp_limb_t b,
    +	mp_ptr tp
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    ap
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of ap and rp.
    b
    Type: Math.Gmp.Nativemp_limb_t
    The second operand integer.
    tp
    Type: Math.Gmp.Nativemp_ptr
    The scratch operand integer.

    Return Value

    Type: mp_limb_t
    Returns carry, either 0 or 1.
    Remarks

    + This function takes O(N) time, unlike the leaky functions mpn_add_1(mp_ptr, mp_ptr, mp_size_t, mp_limb_t) which is O(1) on average. + It requires scratch space of mpn_sec_add_1_itch(mp_size_t)(n) limbs, to be passed in the tp parameter. + The scratch space requirements are guaranteed to be at most n limbs, and increase monotonously in the operand size. +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr ap = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
    +mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });
    +mp_ptr rp = new mp_ptr(result.Size);
    +
    +// Create scratch space.
    +mp_size_t size = gmp_lib.mpn_sec_add_1_itch(ap.Size);
    +mp_ptr tp = new mp_ptr(size);
    +
    +// Set rp = ap + 1.
    +mp_limb_t carry = gmp_lib.mpn_sec_add_1(rp, ap, ap.Size, 1, tp);
    +
    +// Assert result of operation.
    +Assert.IsTrue(carry == 1);
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, ap, tp, result);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/15e1db51-a27c-7eee-03dd-5c6457889be1.htm b/docs/html/15e1db51-a27c-7eee-03dd-5c6457889be1.htm new file mode 100644 index 0000000..da192f2 --- /dev/null +++ b/docs/html/15e1db51-a27c-7eee-03dd-5c6457889be1.htm @@ -0,0 +1,16 @@ +mpz_t._mp_size Property
    mpz_t_mp_size Property
    + The number of limbs, or the negative of that when representing a negative integer. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override mp_size_t _mp_size { get; }

    Property Value

    Type: mp_size_t
    Remarks

    + The number of limbs, or the negative of that when representing a negative integer. + Zero is represented by _mp_size set to zero, in which case + the _mp_d data is unused. +

    See Also
    \ No newline at end of file diff --git a/docs/html/17280f99-d0dc-6714-12c7-be17c97c0cdb.htm b/docs/html/17280f99-d0dc-6714-12c7-be17c97c0cdb.htm new file mode 100644 index 0000000..63090a7 --- /dev/null +++ b/docs/html/17280f99-d0dc-6714-12c7-be17c97c0cdb.htm @@ -0,0 +1,42 @@ +gmp_lib.mpz_fac_ui Method
    Click or drag to resize
    gmp_libmpz_fac_ui Method
    + Set rop to the factorial n!. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_fac_ui(
    +	mpz_t rop,
    +	uint n
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    n
    Type: SystemUInt32
    The operand integer.
    Examples
    // Create, initialize, and set the value of rop to 0.
    +mpz_t rop = new mpz_t();
    +gmp_lib.mpz_init(rop);
    +
    +// Set rop = 3!.
    +gmp_lib.mpz_fac_ui(rop, 3U);
    +
    +// Assert that rop is 6.
    +Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6);
    +
    +// Release unmanaged memory allocated for rop.
    +gmp_lib.mpz_clear(rop);
    See Also
    \ No newline at end of file diff --git a/docs/html/17731ba4-bf91-6b9b-737a-a9cc306ba17d.htm b/docs/html/17731ba4-bf91-6b9b-737a-a9cc306ba17d.htm new file mode 100644 index 0000000..aa704ae --- /dev/null +++ b/docs/html/17731ba4-bf91-6b9b-737a-a9cc306ba17d.htm @@ -0,0 +1,56 @@ +gmp_lib.mpf_abs Method
    Click or drag to resize
    gmp_libmpf_abs Method
    + Set rop to |op|. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_abs(
    +	mpf_t rop,
    +	mpf_t op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op
    Type: Math.Gmp.Nativempf_t
    The operand.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to -10.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, -10);
    +
    +// Create and initialize a new floating-point number z.
    +mpf_t z = new mpf_t();
    +gmp_lib.mpf_init(z);
    +
    +// Set z = |x|.
    +gmp_lib.mpf_neg(z, x);
    +
    +// Assert that the value of z is 10.
    +Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpf_clears(x, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/178d8d44-2485-2972-fe2f-eb9848059e6f.htm b/docs/html/178d8d44-2485-2972-fe2f-eb9848059e6f.htm new file mode 100644 index 0000000..5b3cd1e --- /dev/null +++ b/docs/html/178d8d44-2485-2972-fe2f-eb9848059e6f.htm @@ -0,0 +1,12 @@ +mp_base._mp_size Property
    mp_base_mp_size Property
    + The number of limbs. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public virtual mp_size_t _mp_size { get; }

    Property Value

    Type: mp_size_t
    Remarks
    \ No newline at end of file diff --git a/docs/html/17b3dc26-68af-fb0c-9923-36777e8bd87e.htm b/docs/html/17b3dc26-68af-fb0c-9923-36777e8bd87e.htm new file mode 100644 index 0000000..0c65ea5 --- /dev/null +++ b/docs/html/17b3dc26-68af-fb0c-9923-36777e8bd87e.htm @@ -0,0 +1,52 @@ +gmp_lib.mpf_init_set Method
    Click or drag to resize
    gmp_libmpf_init_set Method
    + Initialize rop and set its value from op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_init_set(
    +	mpf_t rop,
    +	mpf_t op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op
    Type: Math.Gmp.Nativempf_t
    The operand.
    Remarks

    + The precision of rop will be taken from the active default precision, as set by mpf_set_default_prec(mp_bitcnt_t). +

    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 10.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, 10);
    +
    +// Create, initialize, and set a new floating-point number y to x.
    +mpf_t y = new mpf_t();
    +gmp_lib.mpf_init_set(y, x);
    +
    +// Assert that the value of y is 10.
    +Assert.IsTrue(gmp_lib.mpf_get_d(y) == 10.0);
    +
    +// Release unmanaged memory allocated for x and y.
    +gmp_lib.mpf_clears(x, y, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/18cd39f5-7c88-f557-3803-8a4a321cfb97.htm b/docs/html/18cd39f5-7c88-f557-3803-8a4a321cfb97.htm new file mode 100644 index 0000000..bb2d857 --- /dev/null +++ b/docs/html/18cd39f5-7c88-f557-3803-8a4a321cfb97.htm @@ -0,0 +1,56 @@ +gmp_lib.mpz_mul_2exp Method
    Click or drag to resize
    gmp_libmpz_mul_2exp Method
    + Set rop to op1 * 2^op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_mul_2exp(
    +	mpz_t rop,
    +	mpz_t op1,
    +	mp_bitcnt_t op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: Math.Gmp.Nativemp_bitcnt_t
    The second operand integer.
    Remarks

    + This operation can also be defined as a left shift by op2 bits. +

    Examples
    // Create, initialize, and set the value of x to -10000.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_si(x, -10000);
    +
    +// Create, initialize, and set the value of x to 0.
    +mpz_t z = new mpz_t();
    +gmp_lib.mpz_init(z);
    +
    +// Set z = -10000 * 2^2.
    +gmp_lib.mpz_mul_2exp(z, x, 2U);
    +
    +// Assert that z is -40000.
    +Assert.IsTrue(gmp_lib.mpz_get_si(z) == -10000 * 4);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpz_clears(x, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/18ef1696-938e-0932-1d55-eaced0d92464.htm b/docs/html/18ef1696-938e-0932-1d55-eaced0d92464.htm new file mode 100644 index 0000000..f415ee9 --- /dev/null +++ b/docs/html/18ef1696-938e-0932-1d55-eaced0d92464.htm @@ -0,0 +1,13 @@ +size_t Implicit Conversion (UInt16 to size_t)
    size_t  Conversion (UInt16 to size_t)
    + Converts a UInt16 value to a size_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator size_t (
    +	ushort value
    +)

    Parameters

    value
    Type: SystemUInt16
    A UInt16 value.

    Return Value

    Type: size_t
    A size_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/19ccd2e3-05f1-d4f4-79b7-28b4f26e5768.htm b/docs/html/19ccd2e3-05f1-d4f4-79b7-28b4f26e5768.htm new file mode 100644 index 0000000..a3aa9f5 --- /dev/null +++ b/docs/html/19ccd2e3-05f1-d4f4-79b7-28b4f26e5768.htm @@ -0,0 +1,23 @@ +gmp_lib.free Method (void_ptr, size_t)
    gmp_libfree Method (void_ptr, size_t)
    + De-allocate the space pointed to by ptr. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void free(
    +	void_ptr ptr,
    +	size_t size
    +)

    Parameters

    ptr
    Type: Math.Gmp.Nativevoid_ptr
    Pointer to previously allocated block.
    size
    Type: Math.Gmp.Nativesize_t
    Number of bytes of previously allocated block.
    Remarks

    + The free function parameter size is passed for convenience, but of course it can be ignored + if not needed by an implementation. The default functions using malloc and friends for instance don’t use it. +

    See Also
    \ No newline at end of file diff --git a/docs/html/19d53697-65f1-2df5-62f3-988182af0c88.htm b/docs/html/19d53697-65f1-2df5-62f3-988182af0c88.htm new file mode 100644 index 0000000..f56c31b --- /dev/null +++ b/docs/html/19d53697-65f1-2df5-62f3-988182af0c88.htm @@ -0,0 +1,16 @@ +gmp_lib.mpq_canonicalize Method
    Click or drag to resize
    gmp_libmpq_canonicalize Method
    + Remove any factors that are common to the numerator and denominator of op, and make the denominator positive. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpq_canonicalize(
    +	mpq_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempq_t
    The operand rational.
    Examples
    See Also
    \ No newline at end of file diff --git a/docs/html/1a7c5874-9132-2c43-e407-df1eead74fab.htm b/docs/html/1a7c5874-9132-2c43-e407-df1eead74fab.htm new file mode 100644 index 0000000..848980d --- /dev/null +++ b/docs/html/1a7c5874-9132-2c43-e407-df1eead74fab.htm @@ -0,0 +1,42 @@ +gmp_lib.mpq_set_d Method
    Click or drag to resize
    gmp_libmpq_set_d Method
    + Set rop to the value of op. There is no rounding, this conversion is exact. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpq_set_d(
    +	mpq_t rop,
    +	double op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempq_t
    The result rational.
    op
    Type: SystemDouble
    The operand Double.
    Examples
    // Create and initialize a new rational.
    +mpq_t x = new mpq_t();
    +gmp_lib.mpq_init(x);
    +
    +// Set the value of x to 10.0 / 11.0.
    +gmp_lib.mpq_set_d(x, 10.0D / 11.0);
    +
    +// Assert that the value of x is 10.0 / 11.0.
    +Assert.IsTrue(gmp_lib.mpq_get_d(x) == 10.0D / 11.0);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpq_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/1a966758-12dc-4da3-cb22-b3b3d788ba02.htm b/docs/html/1a966758-12dc-4da3-cb22-b3b3d788ba02.htm new file mode 100644 index 0000000..2aeb981 --- /dev/null +++ b/docs/html/1a966758-12dc-4da3-cb22-b3b3d788ba02.htm @@ -0,0 +1,62 @@ +gmp_lib.gmp_vsscanf Method
    Click or drag to resize
    gmp_libgmp_vsscanf Method
    + Read from a null-terminated string s. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int gmp_vsscanf(
    +	string s,
    +	string fmt,
    +	params Object[] ap
    +)

    Parameters

    s
    Type: SystemString
    A string.
    fmt
    Type: SystemString
    Format string. See Formatted Input Strings.
    ap
    Type: SystemObject
    Arguments.

    Return Value

    Type: Int32
    The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value.
    Examples
    mpz_t z = "0";
    +mpq_t q = "0";
    +mpf_t f = "0";
    +ptr<Char> c = new ptr<Char>('0');
    +ptr<mp_size_t> zt = new ptr<mp_size_t>(0);
    +ptr<Double> dbl = new ptr<Double>(0);
    +
    +Assert.IsTrue(gmp_lib.gmp_vsscanf("123456 7B/1C8 1.234500e+10 A 10 1.000000", "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6);
    +
    +Assert.IsTrue(z.ToString() == "123456");
    +Assert.IsTrue(q.ToString() == "123/456");
    +Assert.IsTrue(f.ToString() == "0.12345e11");
    +Assert.IsTrue(c.Value == 'A');
    +Assert.IsTrue(zt.Value == 10);
    +Assert.IsTrue(dbl.Value == 1.0);
    +
    +// Release unmanaged memory.
    +gmp_lib.mpz_clear(z);
    +gmp_lib.mpq_clear(q);
    +gmp_lib.mpf_clear(f);
    See Also
    \ No newline at end of file diff --git a/docs/html/1b117248-4e1d-a985-2ab6-4bd8e5b3e769.htm b/docs/html/1b117248-4e1d-a985-2ab6-4bd8e5b3e769.htm new file mode 100644 index 0000000..8ece98e --- /dev/null +++ b/docs/html/1b117248-4e1d-a985-2ab6-4bd8e5b3e769.htm @@ -0,0 +1,7 @@ +ptr(T) Constructor \ No newline at end of file diff --git a/docs/html/1b2b1d64-20c1-7a64-0278-d9ff58ee9cc3.htm b/docs/html/1b2b1d64-20c1-7a64-0278-d9ff58ee9cc3.htm new file mode 100644 index 0000000..981dcf5 --- /dev/null +++ b/docs/html/1b2b1d64-20c1-7a64-0278-d9ff58ee9cc3.htm @@ -0,0 +1,65 @@ +mp_bitcnt_t Structure
    mp_bitcnt_t Structure
    + Represents a count of bits. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public struct mp_bitcnt_t

    The mp_bitcnt_t type exposes the following members.

    Constructors
    +   + NameDescription
    Public methodmp_bitcnt_t
    + Creates a new mp_bitcnt_t, and sets its value. +
    Top
    Methods
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(mp_bitcnt_t)
    + Returns a value indicating whether this instance is equal to a specified mp_bitcnt_t value. +
    Public methodGetHashCode
    + Returns the hash code for this instance. +
    (Overrides ValueTypeGetHashCode.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Public methodToString
    + Gets the string representation of the mp_bitcnt_t. +
    (Overrides ValueTypeToString.)
    Top
    Operators
    +   + NameDescription
    Public operatorStatic memberEquality
    + Gets a value that indicates whether the two argument values are equal. +
    Public operatorStatic member(Int16 to mp_bitcnt_t)
    + Converts an Int16 value to an mp_bitcnt_t value. +
    Public operatorStatic member(Int32 to mp_bitcnt_t)
    + Converts an Int32 value to an mp_bitcnt_t value. +
    Public operatorStatic member(Int64 to mp_bitcnt_t)
    + Converts an Int64 value to a mp_bitcnt_t value. +
    Public operatorStatic member(SByte to mp_bitcnt_t)
    + Converts a Byte value to an mp_bitcnt_t value. +
    Public operatorStatic member(UInt64 to mp_bitcnt_t)
    + Converts a UInt64 value to an mp_bitcnt_t value. +
    Public operatorStatic member(mp_bitcnt_t to Byte)
    + Converts an mp_bitcnt_t value to a Byte value. +
    Public operatorStatic member(mp_bitcnt_t to SByte)
    + Converts an mp_bitcnt_t value to an SByte value. +
    Public operatorStatic member(mp_bitcnt_t to UInt16)
    + Converts an mp_bitcnt_t value to a UInt16 value. +
    Public operatorStatic member(mp_bitcnt_t to Int16)
    + Converts an mp_bitcnt_t value to an Int16 value. +
    Public operatorStatic member(mp_bitcnt_t to Int32)
    + Converts an mp_bitcnt_t value to an Int32 value. +
    Public operatorStatic member(Byte to mp_bitcnt_t)
    + Converts a Byte value to an mp_bitcnt_t value. +
    Public operatorStatic member(UInt16 to mp_bitcnt_t)
    + Converts a UInt16 value to an mp_bitcnt_t value. +
    Public operatorStatic member(UInt32 to mp_bitcnt_t)
    + Converts a UInt32 value to an mp_bitcnt_t value. +
    Public operatorStatic member(mp_bitcnt_t to UInt32)
    + Converts an mp_bitcnt_t value to a UInt32 value. +
    Public operatorStatic member(mp_bitcnt_t to UInt64)
    + Converts an mp_bitcnt_t value to a UInt64 value. +
    Public operatorStatic member(mp_bitcnt_t to Int64)
    + Converts an mp_bitcnt_t value to an Int64 value. +
    Public operatorStatic memberInequality
    + Gets a value that indicates whether the two argument values are different. +
    Top
    Remarks

    + Counts of bits of a multi-precision number are represented in the C type mp_bitcnt_t. + Currently this is always an unsigned long, but on some systems it will be an unsigned long long in the future. +

    + In .NET, this is an unsigned 32-bit integer. +

    See Also
    \ No newline at end of file diff --git a/docs/html/1b76ffd8-d7f4-5309-3b10-e7e0c418706a.htm b/docs/html/1b76ffd8-d7f4-5309-3b10-e7e0c418706a.htm new file mode 100644 index 0000000..a83f6c4 --- /dev/null +++ b/docs/html/1b76ffd8-d7f4-5309-3b10-e7e0c418706a.htm @@ -0,0 +1,54 @@ +gmp_lib.mpn_iorn_n Method
    Click or drag to resize
    gmp_libmpn_iorn_n Method
    + Perform the bitwise logical inclusive or of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpn_iorn_n(
    +	mp_ptr rp,
    +	mp_ptr s1p,
    +	mp_ptr s2p,
    +	mp_size_t n
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    s1p
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    s2p
    Type: Math.Gmp.Nativemp_ptr
    The second operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of s1p and s2p.
    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
    +mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
    +mp_ptr rp = new mp_ptr(new uint[2]);
    +mp_ptr result = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
    +
    +// Set rp = s1 or not s2.
    +gmp_lib.mpn_iorn_n(rp, s1p, s2p, s1p.Size);
    +
    +// Assert result of operation.
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, s1p, s2p, result);
    See Also
    \ No newline at end of file diff --git a/docs/html/1ba86b5b-8ace-b6ee-99c5-32a8d7648519.htm b/docs/html/1ba86b5b-8ace-b6ee-99c5-32a8d7648519.htm new file mode 100644 index 0000000..1478407 --- /dev/null +++ b/docs/html/1ba86b5b-8ace-b6ee-99c5-32a8d7648519.htm @@ -0,0 +1,16 @@ +gmp_lib.mpn_sec_sqr_itch Method
    Click or drag to resize
    gmp_libmpn_sec_sqr_itch Method
    + Return the scratch space in number of limbs required by the function mpn_sec_sqr(mp_ptr, mp_ptr, mp_size_t, mp_ptr). +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_size_t mpn_sec_sqr_itch(
    +	mp_size_t an
    +)

    Parameters

    an
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of the mpn_sec_sqr(mp_ptr, mp_ptr, mp_size_t, mp_ptr) operand.

    Return Value

    Type: mp_size_t
    The scratch space in number of limbs required by the function mpn_sec_sqr(mp_ptr, mp_ptr, mp_size_t, mp_ptr).
    See Also
    \ No newline at end of file diff --git a/docs/html/1babcb9f-d828-81fb-30d5-296cccd21929.htm b/docs/html/1babcb9f-d828-81fb-30d5-296cccd21929.htm new file mode 100644 index 0000000..d61bf75 --- /dev/null +++ b/docs/html/1babcb9f-d828-81fb-30d5-296cccd21929.htm @@ -0,0 +1,13 @@ +mp_size_t Explicit Conversion (mp_size_t to UInt16)
    mp_size_t  Conversion (mp_size_t to UInt16)
    + Converts an mp_size_t value to a UInt16 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator ushort (
    +	mp_size_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_size_t
    An mp_size_t value.

    Return Value

    Type: UInt16
    A UInt16 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/1bcc07bd-8fee-1107-844c-a5ff10e7660c.htm b/docs/html/1bcc07bd-8fee-1107-844c-a5ff10e7660c.htm new file mode 100644 index 0000000..c5bdeb6 --- /dev/null +++ b/docs/html/1bcc07bd-8fee-1107-844c-a5ff10e7660c.htm @@ -0,0 +1,26 @@ +FILE Structure
    FILE Structure
    + Represents a file stream. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public struct FILE

    The FILE type exposes the following members.

    Methods
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(FILE)
    + Returns a value indicating whether this instance is equal to a specified FILE value. +
    Public methodGetHashCode
    + Returns the hash code for this instance. +
    (Overrides ValueTypeGetHashCode.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Public methodToString
    Returns the fully qualified type name of this instance.
    (Inherited from ValueType.)
    Top
    Operators
    +   + NameDescription
    Public operatorStatic memberEquality
    + Gets a value that indicates whether the two argument values are equal. +
    Public operatorStatic memberInequality
    + Gets a value that indicates whether the two argument values are different. +
    Top
    Fields
    +   + NameDescription
    Public fieldValue
    + File pointer in unmanaged memory. +
    Top
    Remarks
    See Also
    \ No newline at end of file diff --git a/docs/html/1bd10056-1935-a793-4930-68ebfaf82cd1.htm b/docs/html/1bd10056-1935-a793-4930-68ebfaf82cd1.htm new file mode 100644 index 0000000..7a6ad31 --- /dev/null +++ b/docs/html/1bd10056-1935-a793-4930-68ebfaf82cd1.htm @@ -0,0 +1,9 @@ +mp_limb_t.GetHashCode Method
    mp_limb_tGetHashCode Method
    + Returns the hash code for this instance. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override int GetHashCode()

    Return Value

    Type: Int32
    A 32-bit signed integer hash code.
    See Also
    \ No newline at end of file diff --git a/docs/html/1ca4ec7e-b5d1-3b51-8341-5a345990e62d.htm b/docs/html/1ca4ec7e-b5d1-3b51-8341-5a345990e62d.htm new file mode 100644 index 0000000..96f988d --- /dev/null +++ b/docs/html/1ca4ec7e-b5d1-3b51-8341-5a345990e62d.htm @@ -0,0 +1,20 @@ +gmp_lib.mpf_get_default_prec Method
    Click or drag to resize
    gmp_libmpf_get_default_prec Method
    + Return the default precision actually used. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_bitcnt_t mpf_get_default_prec()

    Return Value

    Type: mp_bitcnt_t
    The default precision actually used.
    Remarks

    + An mpf_t object must be initialized before storing the first value in it. + The functions mpf_init(mpf_t) and mpf_init2(mpf_t, mp_bitcnt_t) are used for that purpose. +

    Examples
    // Set default precision to 128 bits.
    +gmp_lib.mpf_set_default_prec(128U);
    +
    +// Assert that the value of x is 128 bits.
    +Assert.IsTrue(gmp_lib.mpf_get_default_prec() == 128U);
    See Also
    \ No newline at end of file diff --git a/docs/html/1cc35e31-9ab0-7239-d05b-1e2a426338bc.htm b/docs/html/1cc35e31-9ab0-7239-d05b-1e2a426338bc.htm new file mode 100644 index 0000000..5326a76 --- /dev/null +++ b/docs/html/1cc35e31-9ab0-7239-d05b-1e2a426338bc.htm @@ -0,0 +1,5 @@ +mpz_t Type Conversions \ No newline at end of file diff --git a/docs/html/1cefa5f6-adc3-30a6-b3bd-cb6a7543cb00.htm b/docs/html/1cefa5f6-adc3-30a6-b3bd-cb6a7543cb00.htm new file mode 100644 index 0000000..f89cb54 --- /dev/null +++ b/docs/html/1cefa5f6-adc3-30a6-b3bd-cb6a7543cb00.htm @@ -0,0 +1,20 @@ +gmp_lib.mpn_sec_div_r_itch Method
    Click or drag to resize
    gmp_libmpn_sec_div_r_itch Method
    + Return the scratch space in number of limbs required by the function mpn_sec_div_r(mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr). +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_size_t mpn_sec_div_r_itch(
    +	mp_size_t nn,
    +	mp_size_t dn
    +)

    Parameters

    nn
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of the mpn_sec_div_r(mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr) first operand.
    dn
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of the mpn_sec_div_r(mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr) second operand.

    Return Value

    Type: mp_size_t
    The scratch space in number of limbs required by the function mpn_sec_div_r(mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr).
    See Also
    \ No newline at end of file diff --git a/docs/html/1d0c5734-9f0d-ec6b-c540-4379f832b0ca.htm b/docs/html/1d0c5734-9f0d-ec6b-c540-4379f832b0ca.htm new file mode 100644 index 0000000..e3b9db8 --- /dev/null +++ b/docs/html/1d0c5734-9f0d-ec6b-c540-4379f832b0ca.htm @@ -0,0 +1,42 @@ +gmp_lib.mpf_set_d Method
    Click or drag to resize
    gmp_libmpf_set_d Method
    + Set the value of rop from op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_set_d(
    +	mpf_t rop,
    +	double op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op
    Type: SystemDouble
    The operand.
    Examples
    // Create and initialize a new floating-point number.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init2(x, 128U);
    +
    +// Set x to -123.0.
    +gmp_lib.mpf_set_d(x, -123.0);
    +
    +// Assert that the value of x is -123.0.
    +Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpf_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/1d378f21-73e1-43e7-e286-5a6c0cb101ba.htm b/docs/html/1d378f21-73e1-43e7-e286-5a6c0cb101ba.htm new file mode 100644 index 0000000..e21a5b8 --- /dev/null +++ b/docs/html/1d378f21-73e1-43e7-e286-5a6c0cb101ba.htm @@ -0,0 +1,13 @@ +mp_bitcnt_t Explicit Conversion (mp_bitcnt_t to Byte)
    mp_bitcnt_t  Conversion (mp_bitcnt_t to Byte)
    + Converts an mp_bitcnt_t value to a Byte value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator byte (
    +	mp_bitcnt_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_bitcnt_t
    An mp_bitcnt_t value.

    Return Value

    Type: Byte
    A Byte value.
    See Also
    \ No newline at end of file diff --git a/docs/html/1d6343a5-d42c-c362-714e-e10730e6a6d5.htm b/docs/html/1d6343a5-d42c-c362-714e-e10730e6a6d5.htm new file mode 100644 index 0000000..7a03338 --- /dev/null +++ b/docs/html/1d6343a5-d42c-c362-714e-e10730e6a6d5.htm @@ -0,0 +1,55 @@ +gmp_lib.mpn_divexact_1 Method
    Click or drag to resize
    gmp_libmpn_divexact_1 Method
    + Divide {sp, n} by d, expecting it to divide exactly, and writing the result to {rrp, n}. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpn_divexact_1(
    +	mp_ptr rp,
    +	mp_ptr sp,
    +	mp_size_t n,
    +	mp_limb_t d
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    sp
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs in sp and rp.
    d
    Type: Math.Gmp.Nativemp_limb_t
    The second operand integer.
    Remarks

    + If d doesn’t divide exactly, the value written to {rp, n} is undefined. + The areas at rp and sp have to be identical or completely separate, not partially overlapping. +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
    +mp_ptr rp = new mp_ptr(new uint[2]);
    +mp_ptr result = new mp_ptr(new uint[] { 0x55555555, 0x00005555 });
    +
    +// Set rp = sp / 3.
    +gmp_lib.mpn_divexact_1(rp, sp, sp.Size, 0x3);
    +
    +// Assert result of operation.
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, sp, result);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/1de9b70a-1d21-8168-e41c-1c259f64091a.htm b/docs/html/1de9b70a-1d21-8168-e41c-1c259f64091a.htm new file mode 100644 index 0000000..d98a282 --- /dev/null +++ b/docs/html/1de9b70a-1d21-8168-e41c-1c259f64091a.htm @@ -0,0 +1,66 @@ +gmp_lib.mpz_realloc2 Method
    Click or drag to resize
    gmp_libmpz_realloc2 Method
    + Change the space allocated for x to n bits. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_realloc2(
    +	mpz_t x,
    +	mp_bitcnt_t n
    +)

    Parameters

    x
    Type: Math.Gmp.Nativempz_t
    The integer.
    n
    Type: Math.Gmp.Nativemp_bitcnt_t
    The number of bits.
    Remarks

    + The value in x is preserved if it fits, or is set to 0 if not. +

    + Calling this function is never necessary; reallocation is handled automatically by GMP when + needed. But this function can be used to increase the space for a variable in order to avoid + repeated automatic reallocations, or to decrease it to give memory back to the heap. +

    Examples
    // Create and initialize new integer x.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init(x);
    +
    +// Set the value of x to a 77-bit integer.
    +char_ptr value = new char_ptr("1000 0000 0000 0000 0000");
    +gmp_lib.mpz_set_str(x, value, 16);
    +
    +// Resize x to 512 bits, and assert that its value has not changed.
    +gmp_lib.mpz_realloc2(x, 512U);
    +char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 16, x);
    +Assert.IsTrue(s.ToString() == "1000 0000 0000 0000 0000".Replace(" ", ""));
    +
    +// Resize x to 2 bits, and assert that its value has changed to 0.
    +gmp_lib.mpz_realloc2(x, 2U);
    +Assert.IsTrue(gmp_lib.mpz_get_si(x) == 0);
    +
    +// Release unmanaged memory allocated for x and string values.
    +gmp_lib.mpz_clear(x);
    +gmp_lib.free(value);
    +gmp_lib.free(s);
    See Also
    \ No newline at end of file diff --git a/docs/html/1dfbf5da-f4c2-bbab-5708-3b31d40e4f16.htm b/docs/html/1dfbf5da-f4c2-bbab-5708-3b31d40e4f16.htm new file mode 100644 index 0000000..0a28810 --- /dev/null +++ b/docs/html/1dfbf5da-f4c2-bbab-5708-3b31d40e4f16.htm @@ -0,0 +1,63 @@ +gmp_lib.mpz_getlimbn Method
    Click or drag to resize
    gmp_libmpz_getlimbn Method
    + Return limb number n from op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_limb_t mpz_getlimbn(
    +	mpz_t op,
    +	mp_size_t n
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempz_t
    The operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The zero-based limb index.

    Return Value

    Type: mp_limb_t
    The limb number n from op.
    Remarks

    + The sign of op is ignored, just the absolute value is used. + The least significant limb is number 0. +

    mpz_size(mpz_t) can be used to find how many limbs make up op. + mpz_getlimbn(mpz_t, mp_size_t) returns zero if n is outside the range 0 + to mpz_size(op) - 1. +

    Examples
    // Create and initialize new integer x.
    +mpz_t op = new mpz_t();
    +char_ptr value = new char_ptr("1000 ABCD 1234 7AB8 24FD");
    +gmp_lib.mpz_init_set_str(op, value, 16);
    +
    +// Assert the value of the limbs of op.
    +if (gmp_lib.mp_bytes_per_limb == 4)
    +{
    +    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 0) == 0x7AB824FD);
    +    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 1) == 0xABCD1234);
    +    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 2) == 0x00001000);
    +}
    +else // gmp_lib.mp_bytes_per_limb == 8
    +{
    +    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 0) == 0xABCD12347AB824FD);
    +    Assert.IsTrue(gmp_lib.mpz_getlimbn(op, 1) == 0x0000000000001000);
    +}
    +
    +// Release unmanaged memory allocated for op and value.
    +gmp_lib.mpz_clear(op);
    +gmp_lib.free(value);
    See Also
    \ No newline at end of file diff --git a/docs/html/1e1204c7-2d33-c9d1-4f4e-c36215f5ebed.htm b/docs/html/1e1204c7-2d33-c9d1-4f4e-c36215f5ebed.htm new file mode 100644 index 0000000..9fd7ae3 --- /dev/null +++ b/docs/html/1e1204c7-2d33-c9d1-4f4e-c36215f5ebed.htm @@ -0,0 +1,50 @@ +gmp_lib.mpz_sqrt Method
    Click or drag to resize
    gmp_libmpz_sqrt Method
    + Set rop to the truncated integer part of the square root of op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_sqrt(
    +	mpz_t rop,
    +	mpz_t op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result square root integer.
    op
    Type: Math.Gmp.Nativempz_t
    The operand integer.
    Examples
    // Create, initialize, and set the value of op to 10000.
    +mpz_t op = new mpz_t();
    +gmp_lib.mpz_init_set_si(op, 10000);
    +
    +// Create, initialize, and set the value of rop to 0.
    +mpz_t rop = new mpz_t();
    +gmp_lib.mpz_init(rop);
    +
    +// Set rop = trunc(sqrt(op)).
    +gmp_lib.mpz_sqrt(rop, op);
    +
    +// Assert that rop is 100.
    +Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 100);
    +
    +// Release unmanaged memory allocated for rop and op.
    +gmp_lib.mpz_clears(rop, op, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/1e30b810-66a8-52cc-8501-8bdda18bfaa7.htm b/docs/html/1e30b810-66a8-52cc-8501-8bdda18bfaa7.htm new file mode 100644 index 0000000..f7d9fc9 --- /dev/null +++ b/docs/html/1e30b810-66a8-52cc-8501-8bdda18bfaa7.htm @@ -0,0 +1,11 @@ +mp_limb_t Methods
    mp_limb_t Methods

    The mp_limb_t type exposes the following members.

    Methods
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(mp_limb_t)
    + Returns a value indicating whether this instance is equal to a specified mp_limb_t value. +
    Public methodGetHashCode
    + Returns the hash code for this instance. +
    (Overrides ValueTypeGetHashCode.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Public methodToString
    + Gets the string representation of the mp_limb_t. +
    (Overrides ValueTypeToString.)
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/1e9cacd7-32b3-7f3b-659a-efdb3e064092.htm b/docs/html/1e9cacd7-32b3-7f3b-659a-efdb3e064092.htm new file mode 100644 index 0000000..a14d4bc --- /dev/null +++ b/docs/html/1e9cacd7-32b3-7f3b-659a-efdb3e064092.htm @@ -0,0 +1,71 @@ +gmp_lib.mpn_get_str Method
    Click or drag to resize
    gmp_libmpn_get_str Method
    + Convert {s1p, s1n} to a raw unsigned char array at str in base base, and return the number of characters produced. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static size_t mpn_get_str(
    +	char_ptr str,
    +	int base,
    +	mp_ptr s1p,
    +	mp_size_t s1n
    +)

    Parameters

    str
    Type: Math.Gmp.Nativechar_ptr
    The result string.
    base
    Type: SystemInt32
    The base.
    s1p
    Type: Math.Gmp.Nativemp_ptr
    The operand integer.
    s1n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of s1p.

    Return Value

    Type: size_t
    The number of characters produced at str.
    Remarks

    + There may be leading zeros in the string. + The string is not in ASCII; to convert it to printable format, add the ASCII codes for "0" or "A", + depending on the base and range. base can vary from 2 to 256. +

    + The most significant limb of the input {s1p, s1n} must be non-zero. + The input {s1p, s1n} is clobbered, except when base is a power of 2, + in which case it’s unchanged. +

    + The area at str has to have space for the largest possible number + represented by a s1n long limb array, plus one extra character. +

    Examples
    // Create multi-precision operands.
    +mp_ptr s1p = new mp_ptr(new uint[] { 0x00000001, 0x00000001 });
    +char_ptr str = new char_ptr("xxxxxxxxxxxxxxxxx");
    +
    +// Convert s1p to hex string.
    +size_t count = gmp_lib.mpn_get_str(str, 16, s1p, s1p.Size);
    +
    +// Copy out str to bytes.
    +byte[] s = new byte[count];
    +Marshal.Copy(str.ToIntPtr(), s, 0, (int)count);
    +
    +// Assert the non-ASCII, hex representation of s1p.
    +Assert.IsTrue(s.SequenceEqual(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 1 }));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(s1p);
    +gmp_lib.free(str);
    See Also
    \ No newline at end of file diff --git a/docs/html/1eedfa7e-7135-6b5d-e395-9a6b90fab236.htm b/docs/html/1eedfa7e-7135-6b5d-e395-9a6b90fab236.htm new file mode 100644 index 0000000..6433799 --- /dev/null +++ b/docs/html/1eedfa7e-7135-6b5d-e395-9a6b90fab236.htm @@ -0,0 +1,9 @@ +char_ptr.ToString Method
    char_ptrToString Method
    + Gets the .NET String equivalent of the unmanaged string. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override string ToString()

    Return Value

    Type: String
    The .NET String equivalent of the unmanaged string.
    See Also
    \ No newline at end of file diff --git a/docs/html/1f2250c3-a1b8-db12-19e4-9946e39eb64c.htm b/docs/html/1f2250c3-a1b8-db12-19e4-9946e39eb64c.htm new file mode 100644 index 0000000..78c0d5e --- /dev/null +++ b/docs/html/1f2250c3-a1b8-db12-19e4-9946e39eb64c.htm @@ -0,0 +1,20 @@ +gmp_lib.mpq_abs Method
    Click or drag to resize
    gmp_libmpq_abs Method
    + Set rop to the absolute value of op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpq_abs(
    +	mpq_t rop,
    +	mpq_t op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempq_t
    The result rational.
    op
    Type: Math.Gmp.Nativempq_t
    The operand rational.
    Examples
    See Also
    \ No newline at end of file diff --git a/docs/html/1f76425d-66dd-c23e-2032-d6f1f2337813.htm b/docs/html/1f76425d-66dd-c23e-2032-d6f1f2337813.htm new file mode 100644 index 0000000..ade7b0b --- /dev/null +++ b/docs/html/1f76425d-66dd-c23e-2032-d6f1f2337813.htm @@ -0,0 +1,25 @@ +size_t Explicit Conversion Operators
    size_t  Conversion Operators
    Overload List
    +   + NameDescription
    Public operatorStatic member(Int16 to size_t)
    + Converts an Int16 value to a size_t value. +
    Public operatorStatic member(Int32 to size_t)
    + Converts an Int32 value to a size_t value. +
    Public operatorStatic member(Int64 to size_t)
    + Converts an Int64 value to a size_t value. +
    Public operatorStatic member(SByte to size_t)
    + Converts a SByte value to a size_t value. +
    Public operatorStatic member(size_t to Byte)
    + Converts a size_t value to a Byte value. +
    Public operatorStatic member(size_t to SByte)
    + Converts a size_t value to an SByte value. +
    Public operatorStatic member(size_t to UInt16)
    + Converts a size_t value to a UInt16 value. +
    Public operatorStatic member(size_t to Int16)
    + Converts a size_t value to an Int16 value. +
    Public operatorStatic member(size_t to UInt32)
    + Converts a size_t value to a UInt32 value. +
    Public operatorStatic member(size_t to Int32)
    + Converts a size_t value to an Int32 value. +
    Public operatorStatic member(size_t to Int64)
    + Converts a size_t value to an Int64 value. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/1ffac718-d814-0556-ea54-dbf1d676e0cc.htm b/docs/html/1ffac718-d814-0556-ea54-dbf1d676e0cc.htm new file mode 100644 index 0000000..cf7ca4c --- /dev/null +++ b/docs/html/1ffac718-d814-0556-ea54-dbf1d676e0cc.htm @@ -0,0 +1,42 @@ +gmp_lib.mpz_set_si Method
    Click or drag to resize
    gmp_libmpz_set_si Method
    + Set the value of rop from op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_set_si(
    +	mpz_t rop,
    +	int op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The destination integer.
    op
    Type: SystemInt32
    The source integer.
    Examples
    // Create and initialize a new integer x.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init(x);
    +
    +// Set the value of x to -10.
    +gmp_lib.mpz_set_si(x, -10);
    +
    +// Assert that the value of x is -10.
    +Assert.IsTrue(gmp_lib.mpz_get_si(x) == -10);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpz_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/201b1b12-bb0c-6a53-c6d5-e75db73f8470.htm b/docs/html/201b1b12-bb0c-6a53-c6d5-e75db73f8470.htm new file mode 100644 index 0000000..b181612 --- /dev/null +++ b/docs/html/201b1b12-bb0c-6a53-c6d5-e75db73f8470.htm @@ -0,0 +1,32 @@ +gmp_lib.mpf_fits_uint_p Method
    Click or drag to resize
    gmp_libmpf_fits_uint_p Method
    + Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpf_fits_uint_p(
    +	mpf_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempf_t
    The operand float.

    Return Value

    Type: Int32
    Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer.
    Examples
    // Create, initialize, and set the value of op 4294967295.
    +mpf_t op = new mpf_t();
    +gmp_lib.mpf_init_set_ui(op, uint.MaxValue);
    +
    +// Assert that op does not fit in uint.
    +Assert.IsTrue(gmp_lib.mpf_fits_uint_p(op) > 0);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpf_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/2041c81e-218b-b514-5a7b-5ee315711bc9.htm b/docs/html/2041c81e-218b-b514-5a7b-5ee315711bc9.htm new file mode 100644 index 0000000..81c870d --- /dev/null +++ b/docs/html/2041c81e-218b-b514-5a7b-5ee315711bc9.htm @@ -0,0 +1,60 @@ +gmp_lib.mpf_mul_2exp Method
    Click or drag to resize
    gmp_libmpf_mul_2exp Method
    + Set rop to op1 * 2^op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_mul_2exp(
    +	mpf_t rop,
    +	mpf_t op1,
    +	mp_bitcnt_t op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op1
    Type: Math.Gmp.Nativempf_t
    The first operand.
    op2
    Type: Math.Gmp.Nativemp_bitcnt_t
    The second operand.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 100.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, 100);
    +
    +// Create and initialize a new floating-point number z.
    +mpf_t z = new mpf_t();
    +gmp_lib.mpf_init(z);
    +
    +// Set z = x * 2^8.
    +gmp_lib.mpf_mul_2exp(z, x, 8U);
    +
    +// Assert that the value of z is 25600.
    +Assert.IsTrue(gmp_lib.mpf_get_d(z) == 25600.0);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpf_clears(x, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/20a476ea-9a38-9ef3-1e23-da2b2eba69a9.htm b/docs/html/20a476ea-9a38-9ef3-1e23-da2b2eba69a9.htm new file mode 100644 index 0000000..05bb466 --- /dev/null +++ b/docs/html/20a476ea-9a38-9ef3-1e23-da2b2eba69a9.htm @@ -0,0 +1,39 @@ +gmp_lib.mpz_tstbit Method
    Click or drag to resize
    gmp_libmpz_tstbit Method
    + Test bit bit_index in op and return 0 or 1 accordingly. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_tstbit(
    +	mpz_t op,
    +	mp_bitcnt_t bit_index
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempz_t
    bit_index
    Type: Math.Gmp.Nativemp_bitcnt_t

    Return Value

    Type: Int32
    Test bit bit_index in op and return 0 or 1 accordingly.
    Remarks

    + The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + The least significant bit is number 0. +

    Examples
    // Create, initialize, and set the value of rop to 70.
    +mpz_t rop = new mpz_t();
    +gmp_lib.mpz_init_set_si(rop, 70);
    +
    +// Assert that bit 3 of rop is 0.
    +Assert.IsTrue(gmp_lib.mpz_tstbit(rop, 3U) == 0);
    +
    +// Release unmanaged memory allocated for rop.
    +gmp_lib.mpz_clear(rop);
    See Also
    \ No newline at end of file diff --git a/docs/html/20a4edb9-f361-6367-9965-64b0f7aeddaa.htm b/docs/html/20a4edb9-f361-6367-9965-64b0f7aeddaa.htm new file mode 100644 index 0000000..19c3175 --- /dev/null +++ b/docs/html/20a4edb9-f361-6367-9965-64b0f7aeddaa.htm @@ -0,0 +1,10 @@ +gmp_randstate_t Constructor
    gmp_randstate_t Constructor
    + Creates a new random number generator state. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public gmp_randstate_t()
    Remarks

    + When done with the random number generator state, unmanaged memory must be released with free(gmp_randstate_t) . +

    See Also
    \ No newline at end of file diff --git a/docs/html/21fdbc76-a0de-1f3a-195f-a5ae0cb3d1da.htm b/docs/html/21fdbc76-a0de-1f3a-195f-a5ae0cb3d1da.htm new file mode 100644 index 0000000..86bb73f --- /dev/null +++ b/docs/html/21fdbc76-a0de-1f3a-195f-a5ae0cb3d1da.htm @@ -0,0 +1,56 @@ +gmp_lib.gmp_randinit_lc_2exp Method
    Click or drag to resize
    gmp_libgmp_randinit_lc_2exp Method
    + Initialize state with a linear congruential algorithm X = (aX + c) mod 2^m2exp. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void gmp_randinit_lc_2exp(
    +	gmp_randstate_t state,
    +	mpz_t a,
    +	uint c,
    +	mp_bitcnt_t m2exp
    +)

    Parameters

    state
    Type: Math.Gmp.Nativegmp_randstate_t
    The state to initialize.
    a
    Type: Math.Gmp.Nativempz_t
    Parameter of the algorithm.
    c
    Type: SystemUInt32
    Parameter of the algorithm.
    m2exp
    Type: Math.Gmp.Nativemp_bitcnt_t
    Parameter of the algorithm.
    Remarks

    + The low bits of X in this algorithm are not very random. + The least significant bit will have a period no more than 2, and the second bit + no more than 4, etc. For this reason only the high half of each X is actually used. +

    + When a random number of more than m2exp / 2 bits is to be generated, + multiple iterations of the recurrence are used and the results concatenated. +

    Examples
    // Create new random number generator state.
    +gmp_randstate_t state = new gmp_randstate_t();
    +
    +// Initialize state with a linear congruential random number generator algorithm.
    +mpz_t a = new mpz_t();
    +gmp_lib.mpz_init_set_ui(a, 100000U);
    +gmp_lib.gmp_randinit_lc_2exp(state, a, 13, 300);
    +
    +// Free all memory occupied by state and a.
    +gmp_lib.gmp_randclear(state);
    +gmp_lib.mpz_clear(a);
    See Also
    \ No newline at end of file diff --git a/docs/html/22aee6e2-0a8a-0514-baa1-2f6882b60174.htm b/docs/html/22aee6e2-0a8a-0514-baa1-2f6882b60174.htm new file mode 100644 index 0000000..f52071d --- /dev/null +++ b/docs/html/22aee6e2-0a8a-0514-baa1-2f6882b60174.htm @@ -0,0 +1,13 @@ +mp_bitcnt_t Explicit Conversion (UInt64 to mp_bitcnt_t)
    mp_bitcnt_t  Conversion (UInt64 to mp_bitcnt_t)
    + Converts a UInt64 value to an mp_bitcnt_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator mp_bitcnt_t (
    +	ulong value
    +)

    Parameters

    value
    Type: SystemUInt64
    A UInt64 value.

    Return Value

    Type: mp_bitcnt_t
    An mp_bitcnt_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/24ecd2d5-422f-e538-fd43-94b749652393.htm b/docs/html/24ecd2d5-422f-e538-fd43-94b749652393.htm new file mode 100644 index 0000000..3069157 --- /dev/null +++ b/docs/html/24ecd2d5-422f-e538-fd43-94b749652393.htm @@ -0,0 +1,66 @@ +gmp_lib.mpn_gcd Method
    Click or drag to resize
    gmp_libmpn_gcd Method
    + Set {rp, retval} to the greatest common divisor of {xp, xn} and {yp, yn}. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_size_t mpn_gcd(
    +	mp_ptr rp,
    +	mp_ptr xp,
    +	mp_size_t xn,
    +	mp_ptr yp,
    +	mp_size_t yn
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    xp
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    xn
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of xp.
    yp
    Type: Math.Gmp.Nativemp_ptr
    The second operand integer.
    yn
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of yp.

    Return Value

    Type: mp_size_t
    The result can be up to yn limbs, the return value is the actual number produced; i.e. the number of limbs of rp.
    Remarks

    + Both source operands are destroyed. +

    + It is required that xnyn > 0, and the most significant limb + of {yp, yn} must be non-zero. + No overlap is permitted between {xp, xn} and {yp, yn}. +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr xp = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 });
    +mp_ptr yp = new mp_ptr(new uint[] { 0xc2d24d55, 0x00000007 });
    +mp_ptr rp = new mp_ptr(yp.Size);
    +mp_ptr result = new mp_ptr(new uint[] { 0x964619c7, 0x00000002 });
    +
    +// Set rp = gcd(xp, yp).
    +mp_size_t size = gmp_lib.mpn_gcd(rp, xp, xp.Size, yp, yp.Size);
    +
    +// Assert result of operation.
    +Assert.IsTrue(size == result.Size);
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, xp, yp, result);
    See Also
    \ No newline at end of file diff --git a/docs/html/255140dc-27a7-cc9d-df9a-dc4d03c9a8e4.htm b/docs/html/255140dc-27a7-cc9d-df9a-dc4d03c9a8e4.htm new file mode 100644 index 0000000..c08498b --- /dev/null +++ b/docs/html/255140dc-27a7-cc9d-df9a-dc4d03c9a8e4.htm @@ -0,0 +1,7 @@ +size_t.Equals Method
    size_tEquals Method
    Overload List
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(size_t)
    + Returns a value indicating whether this instance is equal to a specified size_t value. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/255d9de2-3cf6-50f3-3276-a4332896da07.htm b/docs/html/255d9de2-3cf6-50f3-3276-a4332896da07.htm new file mode 100644 index 0000000..ab87c78 --- /dev/null +++ b/docs/html/255d9de2-3cf6-50f3-3276-a4332896da07.htm @@ -0,0 +1,17 @@ +char_ptr Constructor
    char_ptr Constructor
    + Creates new string in unmanaged memory and initializes it with str. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public char_ptr(
    +	string str
    +)

    Parameters

    str
    Type: SystemString
    The value of the new string.
    Remarks

    + When done with the string, unmanaged memory must be released with free(char_ptr) . +

    See Also
    \ No newline at end of file diff --git a/docs/html/2583789b-09c3-0f9a-fbf9-4d362bd9129a.htm b/docs/html/2583789b-09c3-0f9a-fbf9-4d362bd9129a.htm new file mode 100644 index 0000000..45698df --- /dev/null +++ b/docs/html/2583789b-09c3-0f9a-fbf9-4d362bd9129a.htm @@ -0,0 +1,7 @@ +mpf_t Methods
    mpf_t Methods

    The mpf_t type exposes the following members.

    Methods
    +   + NameDescription
    Public methodEquals
    Determines whether the specified Object is equal to the current Object.
    (Inherited from Object.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGetHashCode
    Serves as a hash function for a particular type.
    (Inherited from Object.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Public methodToIntPtr
    + Gets the unmanaged memory pointer of the multiple precision floating-point number. +
    Public methodToString
    + Return the string representation of the float. +
    (Overrides ObjectToString.)
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/25bb755c-4475-9382-5601-dd83fda02afe.htm b/docs/html/25bb755c-4475-9382-5601-dd83fda02afe.htm new file mode 100644 index 0000000..8e980e7 --- /dev/null +++ b/docs/html/25bb755c-4475-9382-5601-dd83fda02afe.htm @@ -0,0 +1,5 @@ +mpq_t Type Conversions \ No newline at end of file diff --git a/docs/html/25c0e500-2d89-f414-530f-a0a53b57766f.htm b/docs/html/25c0e500-2d89-f414-530f-a0a53b57766f.htm new file mode 100644 index 0000000..54c9ac1 --- /dev/null +++ b/docs/html/25c0e500-2d89-f414-530f-a0a53b57766f.htm @@ -0,0 +1,13 @@ +size_t Explicit Conversion (Int32 to size_t)
    size_t  Conversion (Int32 to size_t)
    + Converts an Int32 value to a size_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator size_t (
    +	int value
    +)

    Parameters

    value
    Type: SystemInt32
    An Int32 value.

    Return Value

    Type: size_t
    A size_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/25d623c3-ee22-4b83-1161-3f98ce698012.htm b/docs/html/25d623c3-ee22-4b83-1161-3f98ce698012.htm new file mode 100644 index 0000000..045e8fe --- /dev/null +++ b/docs/html/25d623c3-ee22-4b83-1161-3f98ce698012.htm @@ -0,0 +1,54 @@ +gmp_lib.mpn_xnor_n Method
    Click or drag to resize
    gmp_libmpn_xnor_n Method
    + Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpn_xnor_n(
    +	mp_ptr rp,
    +	mp_ptr s1p,
    +	mp_ptr s2p,
    +	mp_size_t n
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    s1p
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    s2p
    Type: Math.Gmp.Nativemp_ptr
    The second operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of s1p and s2p.
    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
    +mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
    +mp_ptr rp = new mp_ptr(new uint[2]);
    +mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
    +
    +// Set rp = not(s1 xor s2).
    +gmp_lib.mpn_xnor_n(rp, s1p, s2p, s1p.Size);
    +
    +// Assert result of operation.
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, s1p, s2p, result);
    See Also
    \ No newline at end of file diff --git a/docs/html/260d6edf-ce02-26f7-d704-ad0d11604e61.htm b/docs/html/260d6edf-ce02-26f7-d704-ad0d11604e61.htm new file mode 100644 index 0000000..8054666 --- /dev/null +++ b/docs/html/260d6edf-ce02-26f7-d704-ad0d11604e61.htm @@ -0,0 +1,34 @@ +gmp_lib.mpz_perfect_square_p Method
    Click or drag to resize
    gmp_libmpz_perfect_square_p Method
    + Return non-zero if op is a perfect square, i.e., if the square root of op is an integer. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_perfect_square_p(
    +	mpz_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempz_t
    The operand integer.

    Return Value

    Type: Int32
    Non-zero if op is a perfect square, i.e., if the square root of op is an integer.
    Remarks

    + Under this definition both 0 and 1 are considered to be perfect squares. +

    Examples
    // Create, initialize, and set the value of x to 10000.
    +mpz_t op = new mpz_t();
    +gmp_lib.mpz_init_set_si(op, 10000);
    +
    +// Assert that op is a perfect square.
    +Assert.IsTrue(gmp_lib.mpz_perfect_square_p(op) > 0);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpz_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/27902901-3a7d-b5b3-d3fc-3900f754bff1.htm b/docs/html/27902901-3a7d-b5b3-d3fc-3900f754bff1.htm new file mode 100644 index 0000000..643c659 --- /dev/null +++ b/docs/html/27902901-3a7d-b5b3-d3fc-3900f754bff1.htm @@ -0,0 +1,68 @@ +gmp_lib.mpn_cnd_add_n Method
    Click or drag to resize
    gmp_libmpn_cnd_add_n Method
    + If cnd is non-zero, it produces the same result as a regular mpn_add_n(mp_ptr, mp_ptr, mp_ptr, mp_size_t), and if cnd is zero, it copies {s1p, n} to the result area and returns zero. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_limb_t mpn_cnd_add_n(
    +	mp_limb_t cnd,
    +	mp_ptr rp,
    +	mp_ptr s1p,
    +	mp_ptr s2p,
    +	mp_size_t n
    +)

    Parameters

    cnd
    Type: Math.Gmp.Nativemp_limb_t
    Conditonal value: non-zero for true, zero for false.
    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    s1p
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    s2p
    Type: Math.Gmp.Nativemp_ptr
    The second operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of s1p and s2p.

    Return Value

    Type: mp_limb_t
    If cnd is non-zero, return carry, either 0 or 1, and if cnd is zero, return 0.
    Remarks

    + This function does conditional addition. + If cnd is non-zero, it produces the same result as a regular mpn_add_n(mp_ptr, mp_ptr, mp_ptr, mp_size_t), + and if cnd is zero, it copies {s1p, n} to the result area and returns zero. + The functions is designed to have timing and memory access patterns depending only + on size and location of the data areas, but independent of the condition cnd. + Like for mpn_add_n(mp_ptr, mp_ptr, mp_ptr, mp_size_t), on most machines, the timing will also be independent + of the actual limb values. +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
    +mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 });
    +mp_ptr rp = new mp_ptr(new uint[2]);
    +mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });
    +
    +// Set rp = s1 + s2.
    +mp_limb_t carry = gmp_lib.mpn_cnd_add_n(1, rp, s1p, s2p, rp.Size);
    +
    +// Assert result of operation.
    +Assert.IsTrue(carry == 1);
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, s1p, s2p, result);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/279877e1-b8d0-f52c-16ba-b2e38e671437.htm b/docs/html/279877e1-b8d0-f52c-16ba-b2e38e671437.htm new file mode 100644 index 0000000..03b9d05 --- /dev/null +++ b/docs/html/279877e1-b8d0-f52c-16ba-b2e38e671437.htm @@ -0,0 +1,54 @@ +gmp_lib.mpz_root Method
    Click or drag to resize
    gmp_libmpz_root Method
    + Set rop to the truncated integer part of the nth root of op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_root(
    +	mpz_t rop,
    +	mpz_t op,
    +	uint n
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result root integer.
    op
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    n
    Type: SystemUInt32
    The second operand integer.

    Return Value

    Type: Int32
    Return non-zero if the computation was exact, i.e., if op is rop to the nth power.
    Examples
    // Create, initialize, and set the value of op to 10000.
    +mpz_t op = new mpz_t();
    +gmp_lib.mpz_init_set_si(op, 10000);
    +
    +// Create, initialize, and set the value of rop to 0.
    +mpz_t rop = new mpz_t();
    +gmp_lib.mpz_init(rop);
    +
    +// Set rop = trunc(cbrt(10000)).
    +gmp_lib.mpz_root(rop, op, 3U);
    +
    +// Assert that rop is 21.
    +Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 21);
    +
    +// Release unmanaged memory allocated for rop.
    +gmp_lib.mpz_clears(rop, op, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/279d21b9-bd04-522e-0759-d1add6fe6fae.htm b/docs/html/279d21b9-bd04-522e-0759-d1add6fe6fae.htm new file mode 100644 index 0000000..e589eec --- /dev/null +++ b/docs/html/279d21b9-bd04-522e-0759-d1add6fe6fae.htm @@ -0,0 +1,62 @@ +gmp_lib.gmp_sscanf Method
    Click or drag to resize
    gmp_libgmp_sscanf Method
    + Read from a null-terminated string s. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int gmp_sscanf(
    +	string s,
    +	string fmt,
    +	params Object[] ap
    +)

    Parameters

    s
    Type: SystemString
    A string.
    fmt
    Type: SystemString
    Format string. See Formatted Input Strings.
    ap
    Type: SystemObject
    Arguments.

    Return Value

    Type: Int32
    The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value.
    Examples
    mpz_t z = "0";
    +mpq_t q = "0";
    +mpf_t f = "0";
    +ptr<Char> c = new ptr<Char>('0');
    +ptr<mp_size_t> zt = new ptr<mp_size_t>(0);
    +ptr<Double> dbl = new ptr<Double>(0);
    +
    +Assert.IsTrue(gmp_lib.gmp_sscanf("123456 7B/1C8 1.234500e+10 A 10 1.000000", "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6);
    +
    +Assert.IsTrue(z.ToString() == "123456");
    +Assert.IsTrue(q.ToString() == "123/456");
    +Assert.IsTrue(f.ToString() == "0.12345e11");
    +Assert.IsTrue(c.Value == 'A');
    +Assert.IsTrue(zt.Value == 10);
    +Assert.IsTrue(dbl.Value == 1.0);
    +
    +// Release unmanaged memory.
    +gmp_lib.mpz_clear(z);
    +gmp_lib.mpq_clear(q);
    +gmp_lib.mpf_clear(f);
    See Also
    \ No newline at end of file diff --git a/docs/html/289280eb-add9-3787-a6bf-8e9766849efd.htm b/docs/html/289280eb-add9-3787-a6bf-8e9766849efd.htm new file mode 100644 index 0000000..05493ba --- /dev/null +++ b/docs/html/289280eb-add9-3787-a6bf-8e9766849efd.htm @@ -0,0 +1,13 @@ +mp_size_t Implicit Conversion (mp_size_t to Int64)
    mp_size_t  Conversion (mp_size_t to Int64)
    + Converts an mp_size_t value to an Int64 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator long (
    +	mp_size_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_size_t
    An mp_size_t value.

    Return Value

    Type: Int64
    An Int64 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/290eb509-85df-a0cc-86f8-ac4e6f5d730a.htm b/docs/html/290eb509-85df-a0cc-86f8-ac4e6f5d730a.htm new file mode 100644 index 0000000..ceb55bf --- /dev/null +++ b/docs/html/290eb509-85df-a0cc-86f8-ac4e6f5d730a.htm @@ -0,0 +1,36 @@ +gmp_lib.mpz_cdiv_ui Method
    Click or drag to resize
    gmp_libmpz_cdiv_ui Method
    + Return the remainder |r| where r = n - q * d, and where q = ceiling(n / d). +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static ulong mpz_cdiv_ui(
    +	mpz_t n,
    +	uint d
    +)

    Parameters

    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: SystemUInt32
    The denominator integer.

    Return Value

    Type: UInt64
    The remainder |r| where r = n - q * d, and where q = ceiling(n / d).
    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10000);
    +
    +// Assert that returned value is |n - 3 * ceiling(n / 3)|.
    +Assert.IsTrue(gmp_lib.mpz_cdiv_ui(n, 3U) == 2U);
    +
    +// Release unmanaged memory allocated for n.
    +gmp_lib.mpz_clear(n);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/29b5075a-d6d3-6fe8-5125-d679317b1022.htm b/docs/html/29b5075a-d6d3-6fe8-5125-d679317b1022.htm new file mode 100644 index 0000000..73a5eda --- /dev/null +++ b/docs/html/29b5075a-d6d3-6fe8-5125-d679317b1022.htm @@ -0,0 +1,13 @@ +mp_bitcnt_t Explicit Conversion (Int16 to mp_bitcnt_t)
    mp_bitcnt_t  Conversion (Int16 to mp_bitcnt_t)
    + Converts an Int16 value to an mp_bitcnt_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator mp_bitcnt_t (
    +	short value
    +)

    Parameters

    value
    Type: SystemInt16
    An Int16 value.

    Return Value

    Type: mp_bitcnt_t
    An mp_bitcnt_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/2b0da39e-331c-878e-26c7-bd6d81c7f8e0.htm b/docs/html/2b0da39e-331c-878e-26c7-bd6d81c7f8e0.htm new file mode 100644 index 0000000..800705c --- /dev/null +++ b/docs/html/2b0da39e-331c-878e-26c7-bd6d81c7f8e0.htm @@ -0,0 +1,46 @@ +gmp_lib.mpz_random Method
    Click or drag to resize
    gmp_libmpz_random Method
    + Generate a random integer of at most max_size limbs. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_random(
    +	mpz_t rop,
    +	mp_size_t max_size
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    max_size
    Type: Math.Gmp.Nativemp_size_t
    The maximum number of limbs.
    Remarks

    + The generated random number doesn’t satisfy any particular requirements of randomness. + Negative random numbers are generated when max_size is negative. +

    + This function is obsolete. Use mpz_urandomb(mpz_t, gmp_randstate_t, mp_bitcnt_t) or mpz_urandomm(mpz_t, gmp_randstate_t, mpz_t) instead. +

    + The random number functions of GMP come in two groups; older function that rely on a global state, + and newer functions that accept a state parameter that is read and modified. + Please see the GNU MP - Random Number Functions + for more information on how to use and not to use random number functions. +

    Examples
    // Create, initialize, and set the value of rop to 0.
    +mpz_t rop = new mpz_t();
    +gmp_lib.mpz_init(rop);
    +
    +// Generate a random integer.
    +gmp_lib.mpz_random(rop, 500);
    +
    +// Free all memory occupied by state and rop.
    +gmp_lib.mpz_clear(rop);
    See Also
    \ No newline at end of file diff --git a/docs/html/2c2936bd-f40b-391b-de4c-e5111654993b.htm b/docs/html/2c2936bd-f40b-391b-de4c-e5111654993b.htm new file mode 100644 index 0000000..4594cd4 --- /dev/null +++ b/docs/html/2c2936bd-f40b-391b-de4c-e5111654993b.htm @@ -0,0 +1,8 @@ +mpq_t Constructor
    mpq_t Constructor
    + Creates a new multiple precision rational. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public mpq_t()
    See Also
    \ No newline at end of file diff --git a/docs/html/2c30c503-671c-e6f1-38a8-3a42f51f8019.htm b/docs/html/2c30c503-671c-e6f1-38a8-3a42f51f8019.htm new file mode 100644 index 0000000..a421b3a --- /dev/null +++ b/docs/html/2c30c503-671c-e6f1-38a8-3a42f51f8019.htm @@ -0,0 +1,13 @@ +mp_exp_t Explicit Conversion (mp_exp_t to SByte)
    mp_exp_t  Conversion (mp_exp_t to SByte)
    + Converts an mp_exp_t value to an SByte value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator sbyte (
    +	mp_exp_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_exp_t
    An mp_exp_t value.

    Return Value

    Type: SByte
    An SByte value.
    See Also
    \ No newline at end of file diff --git a/docs/html/2c37941c-dee7-0d74-7889-3fa6c20bab6a.htm b/docs/html/2c37941c-dee7-0d74-7889-3fa6c20bab6a.htm new file mode 100644 index 0000000..e3e07fc --- /dev/null +++ b/docs/html/2c37941c-dee7-0d74-7889-3fa6c20bab6a.htm @@ -0,0 +1,47 @@ +gmp_lib.mpz_init_set Method
    Click or drag to resize
    gmp_libmpz_init_set Method
    + Initialize rop with limb space and set the initial numeric value from op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_init_set(
    +	mpz_t rop,
    +	mpz_t op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The destination integer.
    op
    Type: Math.Gmp.Nativempz_t
    The source integer.
    Examples
    // Create, initialize, and set a new integer y to -210.
    +mpz_t y = new mpz_t();
    +gmp_lib.mpz_init(y);
    +gmp_lib.mpz_set_si(y, -210);
    +
    +// Create, initialize, and set a new integer x to the value of y.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set(x, y);
    +
    +// Assert that x is equal to the value of y.
    +Assert.IsTrue(gmp_lib.mpz_get_si(x) == -210);
    +
    +// Release unmanaged memory allocated for x and y.
    +gmp_lib.mpz_clears(x, y, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/2c68671c-cd5c-e2ec-52a2-65b0ca31c3d1.htm b/docs/html/2c68671c-cd5c-e2ec-52a2-65b0ca31c3d1.htm new file mode 100644 index 0000000..096c531 --- /dev/null +++ b/docs/html/2c68671c-cd5c-e2ec-52a2-65b0ca31c3d1.htm @@ -0,0 +1,16 @@ +gmp_lib.allocate Method
    Click or drag to resize
    gmp_liballocate Method
    + Return a pointer to newly allocated space with at least alloc_size bytes. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void_ptr allocate(
    +	size_t alloc_size
    +)

    Parameters

    alloc_size
    Type: Math.Gmp.Nativesize_t
    The minimum number of bytes to allocate.

    Return Value

    Type: void_ptr
    A pointer to newly allocated space with at least alloc_size bytes.
    Remarks
    \ No newline at end of file diff --git a/docs/html/2c9876e2-a0f5-14c6-5069-1a9d50b89185.htm b/docs/html/2c9876e2-a0f5-14c6-5069-1a9d50b89185.htm new file mode 100644 index 0000000..d60791e --- /dev/null +++ b/docs/html/2c9876e2-a0f5-14c6-5069-1a9d50b89185.htm @@ -0,0 +1,19 @@ +free_function Delegate
    free_function Delegate
    + De-allocate the space pointed to by ptr. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public delegate void free_function(
    +	void_ptr ptr,
    +	size_t size
    +)

    Parameters

    ptr
    Type: Math.Gmp.Nativevoid_ptr
    Pointer to previously allocated block.
    size
    Type: Math.Gmp.Nativesize_t
    Number of bytes of previously allocated block.
    See Also
    \ No newline at end of file diff --git a/docs/html/2d2c429f-5828-694d-2ad7-9d13e5c412b3.htm b/docs/html/2d2c429f-5828-694d-2ad7-9d13e5c412b3.htm new file mode 100644 index 0000000..88607fe --- /dev/null +++ b/docs/html/2d2c429f-5828-694d-2ad7-9d13e5c412b3.htm @@ -0,0 +1,7 @@ +char_ptr.Equals Method
    char_ptrEquals Method
    Overload List
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(char_ptr)
    + Returns a value indicating whether this instance is equal to a specified char_ptr value. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/2d93abcb-e73f-fe40-a50b-395a0bf6a4fc.htm b/docs/html/2d93abcb-e73f-fe40-a50b-395a0bf6a4fc.htm new file mode 100644 index 0000000..bb7e54a --- /dev/null +++ b/docs/html/2d93abcb-e73f-fe40-a50b-395a0bf6a4fc.htm @@ -0,0 +1,44 @@ +gmp_lib.mpq_denref Method
    Click or drag to resize
    gmp_libmpq_denref Method
    + Return a reference to the denominator op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mpz_t mpq_denref(
    +	mpq_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempq_t
    The operand rational.

    Return Value

    Type: mpz_t
    Return a reference to the denominator op.
    Remarks

    + The mpz functions can be used on the returned reference. +

    Examples
    // Create, initialize, and set the value of op to -1 / 3.
    +mpq_t op = new mpq_t();
    +gmp_lib.mpq_init(op);
    +gmp_lib.mpq_set_si(op, -1, 3U);
    +
    +// Get reference to denominator, and increment it by 2.
    +mpz_t num = gmp_lib.mpq_denref(op);
    +gmp_lib.mpz_add_ui(num, num, 2U);
    +
    +// Assert that op is -1 / 5.
    +Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5U) == 0);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpq_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/2ddc32dc-4ee3-18e9-dd3d-7e64c3304e1e.htm b/docs/html/2ddc32dc-4ee3-18e9-dd3d-7e64c3304e1e.htm new file mode 100644 index 0000000..7ca2820 --- /dev/null +++ b/docs/html/2ddc32dc-4ee3-18e9-dd3d-7e64c3304e1e.htm @@ -0,0 +1,62 @@ +gmp_lib.mpz_divexact Method
    Click or drag to resize
    gmp_libmpz_divexact Method
    + Set q to n / d when it is known in advance that d divides n. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_divexact(
    +	mpz_t q,
    +	mpz_t n,
    +	mpz_t d
    +)

    Parameters

    q
    Type: Math.Gmp.Nativempz_t
    The result quotient integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: Math.Gmp.Nativempz_t
    The denominator integer.
    Examples
    // Create, initialize, and set the value of x to 10000.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_ui(x, 10000U);
    +
    +// Create, initialize, and set the value of y to 5.
    +mpz_t y = new mpz_t();
    +gmp_lib.mpz_init_set_ui(y, 5U);
    +
    +// Create, initialize, and set the value of z to 0.
    +mpz_t z = new mpz_t();
    +gmp_lib.mpz_init(z);
    +
    +// Set z = x / y.
    +gmp_lib.mpz_divexact(z, x, y);
    +
    +// Assert that z is 2000.
    +Assert.IsTrue(gmp_lib.mpz_get_si(z) == 2000);
    +
    +// Release unmanaged memory allocated for x, y, and z.
    +gmp_lib.mpz_clears(x, y, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/2e469258-d5e3-da86-aebe-025b92d7cf73.htm b/docs/html/2e469258-d5e3-da86-aebe-025b92d7cf73.htm new file mode 100644 index 0000000..9b09d58 --- /dev/null +++ b/docs/html/2e469258-d5e3-da86-aebe-025b92d7cf73.htm @@ -0,0 +1,34 @@ +gmp_lib.mpn_zero_p Method
    Click or drag to resize
    gmp_libmpn_zero_p Method
    + Test {sp, n} and return 1 if the operand is zero, 0 otherwise. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpn_zero_p(
    +	mp_ptr sp,
    +	mp_size_t n
    +)

    Parameters

    sp
    Type: Math.Gmp.Nativemp_ptr
    The operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs in sp.

    Return Value

    Type: Int32
    Return 1 if the operand is zero, 0 otherwise.
    Examples
    // Create multi-precision operand.
    +mp_ptr sp = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });
    +
    +// Assert sp == 0.
    +Assert.IsTrue(gmp_lib.mpn_zero_p(sp, sp.Size) == 1);
    +
    +// Release unmanaged memory.
    +gmp_lib.free(sp);
    See Also
    \ No newline at end of file diff --git a/docs/html/2e55f6fd-0083-fc85-0d42-65e472376dbe.htm b/docs/html/2e55f6fd-0083-fc85-0d42-65e472376dbe.htm new file mode 100644 index 0000000..9f83a6f --- /dev/null +++ b/docs/html/2e55f6fd-0083-fc85-0d42-65e472376dbe.htm @@ -0,0 +1,36 @@ +gmp_lib.mpz_cmp_si Method
    Click or drag to resize
    gmp_libmpz_cmp_si Method
    + Compare op1 and op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_cmp_si(
    +	mpz_t op1,
    +	int op2
    +)

    Parameters

    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: SystemInt32
    The second operand integer.

    Return Value

    Type: Int32
    Return a positive value if op1 > op2, zero if op1 = op2, or a negative value if op1 < op2.
    Examples
    // Create, initialize, and set the value of op1 to 63.
    +mpz_t op1 = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op1, 63U);
    +
    +// Assert that op1 < 70.
    +Assert.IsTrue(gmp_lib.mpz_cmp_si(op1, 70) < 0);
    +
    +// Release unmanaged memory allocated for op1.
    +gmp_lib.mpz_clear(op1);
    See Also
    \ No newline at end of file diff --git a/docs/html/2e8177f2-fc95-380b-ef64-a51cf494c686.htm b/docs/html/2e8177f2-fc95-380b-ef64-a51cf494c686.htm new file mode 100644 index 0000000..2f0c25c --- /dev/null +++ b/docs/html/2e8177f2-fc95-380b-ef64-a51cf494c686.htm @@ -0,0 +1,19 @@ +mp_limb_t.Equality Operator
    mp_limb_tEquality Operator
    + Gets a value that indicates whether the two argument values are equal. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static bool operator ==(
    +	mp_limb_t value1,
    +	mp_limb_t value2
    +)

    Parameters

    value1
    Type: Math.Gmp.Nativemp_limb_t
    A mp_limb_t value.
    value2
    Type: Math.Gmp.Nativemp_limb_t
    A mp_limb_t value.

    Return Value

    Type: Boolean
    True if the two values are equal, and False otherwise.
    See Also
    \ No newline at end of file diff --git a/docs/html/2f9a1c6d-82f4-6ef2-476a-8231d6b7d497.htm b/docs/html/2f9a1c6d-82f4-6ef2-476a-8231d6b7d497.htm new file mode 100644 index 0000000..c1b53af --- /dev/null +++ b/docs/html/2f9a1c6d-82f4-6ef2-476a-8231d6b7d497.htm @@ -0,0 +1,13 @@ +mp_exp_t Implicit Conversion (SByte to mp_exp_t)
    mp_exp_t  Conversion (SByte to mp_exp_t)
    + Converts a Byte value to an mp_exp_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator mp_exp_t (
    +	sbyte value
    +)

    Parameters

    value
    Type: SystemSByte
    A Byte value.

    Return Value

    Type: mp_exp_t
    An mp_exp_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/2ff1eb0a-f399-2ad2-f7d1-3fb51dceac10.htm b/docs/html/2ff1eb0a-f399-2ad2-f7d1-3fb51dceac10.htm new file mode 100644 index 0000000..9fa7695 --- /dev/null +++ b/docs/html/2ff1eb0a-f399-2ad2-f7d1-3fb51dceac10.htm @@ -0,0 +1,60 @@ +gmp_lib.mpz_congruent_p Method
    Click or drag to resize
    gmp_libmpz_congruent_p Method
    + Return non-zero if n is congruent to c modulo d. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_congruent_p(
    +	mpz_t n,
    +	mpz_t c,
    +	mpz_t d
    +)

    Parameters

    n
    Type: Math.Gmp.Nativempz_t
    An operand integer.
    c
    Type: Math.Gmp.Nativempz_t
    The remainder of the division by d.
    d
    Type: Math.Gmp.Nativempz_t
    The divisor operand integer.

    Return Value

    Type: Int32
    Non-zero if n is congruent to c modulo d.
    Remarks

    n is congruent to c mod d if there exists an integer q + satisfying n = c + q * d. + Unlike the other division functions, d = 0 is accepted and following the rule it can be seen + that n and c are considered congruent mod 0 only when exactly equal. +

    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_ui(n, 10000U);
    +
    +// Create, initialize, and set the value of d to 3.
    +mpz_t d = new mpz_t();
    +gmp_lib.mpz_init_set_ui(d, 3U);
    +
    +// Create, initialize, and set the value of c to 1.
    +mpz_t c = new mpz_t();
    +gmp_lib.mpz_init_set_ui(c, 1U);
    +
    +// Assert that n is congruent to c mod d.
    +Assert.IsTrue(gmp_lib.mpz_congruent_p(n, c, d) > 0);
    +
    +// Release unmanaged memory allocated for n, d, and c.
    +gmp_lib.mpz_clears(n, d, c, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/3006d511-ecd7-0e95-44e1-b9effd406cbf.htm b/docs/html/3006d511-ecd7-0e95-44e1-b9effd406cbf.htm new file mode 100644 index 0000000..77ab672 --- /dev/null +++ b/docs/html/3006d511-ecd7-0e95-44e1-b9effd406cbf.htm @@ -0,0 +1,13 @@ +mp_limb_t Explicit Conversion (SByte to mp_limb_t)
    mp_limb_t  Conversion (SByte to mp_limb_t)
    + Converts a SByte value to an mp_limb_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator mp_limb_t (
    +	sbyte value
    +)

    Parameters

    value
    Type: SystemSByte
    A SByte value.

    Return Value

    Type: mp_limb_t
    An mp_limb_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/300c388f-ba1c-0ba3-64fd-e7aafb39dcdb.htm b/docs/html/300c388f-ba1c-0ba3-64fd-e7aafb39dcdb.htm new file mode 100644 index 0000000..56b8a1c --- /dev/null +++ b/docs/html/300c388f-ba1c-0ba3-64fd-e7aafb39dcdb.htm @@ -0,0 +1,66 @@ +gmp_lib.gmp_vsnprintf Method
    Click or drag to resize
    gmp_libgmp_vsnprintf Method
    + Form a null-terminated string in buf. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int gmp_vsnprintf(
    +	char_ptr buf,
    +	size_t size,
    +	string fmt,
    +	params Object[] ap
    +)

    Parameters

    buf
    Type: Math.Gmp.Nativechar_ptr
    The string to print to.
    size
    Type: Math.Gmp.Nativesize_t
    The maximum number of bytes to write.
    fmt
    Type: SystemString
    Format string. See Formatted Output Strings.
    ap
    Type: SystemObject
    Arguments.

    Return Value

    Type: Int32
    The return value is the total number of characters which ought to have been produced, excluding the terminating null. If retval ≥ size then the actual output has been truncated to the first size - 1 characters, and a null appended.
    Remarks

    + No more than size bytes will be written. To get the full output, size must be enough for the string and null-terminator. +

    + No overlap is permitted between the regiom {buf,size} and the fmt string. +

    + Notice the return value is in ISO C99 snprintf style. This is so even if the C library vsnprintf is the older GLIBC 2.0.x style. +

    Examples
    // Allocate unmanaged string with 50 characters.
    +char_ptr str = new char_ptr(".................................................");
    +
    +mpz_t z = "123456";
    +mpq_t q = "123/456";
    +mpf_t f = "12345e6";
    +mp_limb_t m = 123456;
    +
    +// Print to string.
    +Assert.IsTrue(gmp_lib.gmp_vsnprintf(str, 50, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
    +Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");
    +
    +// Release unmanaged memory.
    +gmp_lib.free(str);
    +gmp_lib.mpz_clear(z);
    +gmp_lib.mpq_clear(q);
    +gmp_lib.mpf_clear(f);
    See Also
    \ No newline at end of file diff --git a/docs/html/306b1c06-9439-c811-b7b9-42777ca691e6.htm b/docs/html/306b1c06-9439-c811-b7b9-42777ca691e6.htm new file mode 100644 index 0000000..82c1d71 --- /dev/null +++ b/docs/html/306b1c06-9439-c811-b7b9-42777ca691e6.htm @@ -0,0 +1,16 @@ +mp_bitcnt_t.Equals Method (mp_bitcnt_t)
    mp_bitcnt_tEquals Method (mp_bitcnt_t)
    + Returns a value indicating whether this instance is equal to a specified mp_bitcnt_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public bool Equals(
    +	mp_bitcnt_t other
    +)

    Parameters

    other
    Type: Math.Gmp.Nativemp_bitcnt_t
    A mp_bitcnt_t value to compare to this instance.

    Return Value

    Type: Boolean
    True if other has the same value as this instance; otherwise, False.
    See Also
    \ No newline at end of file diff --git a/docs/html/309e6a8c-1318-2d30-a058-f119193546a0.htm b/docs/html/309e6a8c-1318-2d30-a058-f119193546a0.htm new file mode 100644 index 0000000..196cd18 --- /dev/null +++ b/docs/html/309e6a8c-1318-2d30-a058-f119193546a0.htm @@ -0,0 +1,68 @@ +gmp_lib.mpf_mul Method
    Click or drag to resize
    gmp_libmpf_mul Method
    + Set rop to op1 * op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_mul(
    +	mpf_t rop,
    +	mpf_t op1,
    +	mpf_t op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op1
    Type: Math.Gmp.Nativempf_t
    The first operand.
    op2
    Type: Math.Gmp.Nativempf_t
    The second operand.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 10.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, 10);
    +
    +// Create, initialize, and set a new floating-point number y to -210.
    +mpf_t y = new mpf_t();
    +gmp_lib.mpf_init_set_si(y, -210);
    +
    +// Create and initialize a new floating-point number z.
    +mpf_t z = new mpf_t();
    +gmp_lib.mpf_init(z);
    +
    +// Set z = x * y.
    +gmp_lib.mpf_mul(z, x, y);
    +
    +// Assert that the value of z is -2100.
    +Assert.IsTrue(gmp_lib.mpf_get_d(z) == -2100.0);
    +
    +// Release unmanaged memory allocated for x, y, and z.
    +gmp_lib.mpf_clears(x, y, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/316be139-2970-161f-ba7c-730f067b5cf3.htm b/docs/html/316be139-2970-161f-ba7c-730f067b5cf3.htm new file mode 100644 index 0000000..17ebd07 --- /dev/null +++ b/docs/html/316be139-2970-161f-ba7c-730f067b5cf3.htm @@ -0,0 +1,80 @@ +gmp_lib.gmp_vfscanf Method
    Click or drag to resize
    gmp_libgmp_vfscanf Method
    + Read from the stream fp. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int gmp_vfscanf(
    +	ptr<FILE> fp,
    +	string fmt,
    +	params Object[] ap
    +)

    Parameters

    fp
    Type: Math.Gmp.NativeptrFILE
    File stream.
    fmt
    Type: SystemString
    Format string. See Formatted Input Strings.
    ap
    Type: SystemObject
    Arguments.

    Return Value

    Type: Int32
    The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value.
    Examples
    // Create unique filename and stream pointer.
    +string pathname = System.IO.Path.GetTempFileName();
    +ptr<FILE> stream = new ptr<FILE>();
    +
    +mpz_t z = "0";
    +mpq_t q = "0";
    +mpf_t f = "0";
    +ptr<Char> c = new ptr<Char>('0');
    +ptr<mp_size_t> zt = new ptr<mp_size_t>(0);
    +ptr<Double> dbl = new ptr<Double>(0);
    +
    +// Write string to file, and then read values from it.
    +System.IO.File.WriteAllText(pathname, "123456 7B/1C8 1.234500e+10 A 10 1.000000");
    +_wfopen_s(out stream.Value.Value, pathname, "r");
    +Assert.IsTrue(gmp_lib.gmp_vfscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6);
    +fclose(stream.Value.Value);
    +
    +// Assert values read.
    +Assert.IsTrue(z.ToString() == "123456");
    +Assert.IsTrue(q.ToString() == "123/456");
    +Assert.IsTrue(f.ToString() == "0.12345e11");
    +Assert.IsTrue(c.Value == 'A');
    +Assert.IsTrue(zt.Value == 10);
    +Assert.IsTrue(dbl.Value == 1.0);
    +
    +// Release unmanaged memory.
    +gmp_lib.mpz_clear(z);
    +gmp_lib.mpq_clear(q);
    +gmp_lib.mpf_clear(f);
    See Also
    \ No newline at end of file diff --git a/docs/html/33563f2c-baba-b555-20fb-9def8b70074c.htm b/docs/html/33563f2c-baba-b555-20fb-9def8b70074c.htm new file mode 100644 index 0000000..f230ec8 --- /dev/null +++ b/docs/html/33563f2c-baba-b555-20fb-9def8b70074c.htm @@ -0,0 +1,13 @@ +mp_ptr Constructor \ No newline at end of file diff --git a/docs/html/339354f8-0924-d332-2217-0b06b81f5e5a.htm b/docs/html/339354f8-0924-d332-2217-0b06b81f5e5a.htm new file mode 100644 index 0000000..401fd0d --- /dev/null +++ b/docs/html/339354f8-0924-d332-2217-0b06b81f5e5a.htm @@ -0,0 +1,13 @@ +mp_size_t Explicit Conversion (mp_size_t to Int16)
    mp_size_t  Conversion (mp_size_t to Int16)
    + Converts an mp_size_t value to an Int16 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator short (
    +	mp_size_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_size_t
    An mp_size_t value.

    Return Value

    Type: Int16
    An Int16 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/339edb73-5781-7d73-97b6-9b73451a698f.htm b/docs/html/339edb73-5781-7d73-97b6-9b73451a698f.htm new file mode 100644 index 0000000..f7988fb --- /dev/null +++ b/docs/html/339edb73-5781-7d73-97b6-9b73451a698f.htm @@ -0,0 +1,62 @@ +gmp_lib.mpn_add_n Method
    Click or drag to resize
    gmp_libmpn_add_n Method
    + Add {s1p, n} and {s2p, n}, and write the n least significant limbs of the result to rp. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_limb_t mpn_add_n(
    +	mp_ptr rp,
    +	mp_ptr s1p,
    +	mp_ptr s2p,
    +	mp_size_t n
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    s1p
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    s2p
    Type: Math.Gmp.Nativemp_ptr
    The second operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs in s1p and s2p.

    Return Value

    Type: mp_limb_t
    Return carry, either 0 or 1.
    Remarks

    + This is the lowest-level function for addition. + It is the preferred function for addition, since it is written in assembly for most CPUs. + For addition of a variable to itself (i.e., s1p equals s2p) + use mpn_lshift(mp_ptr, mp_ptr, mp_size_t, UInt32) with a count of 1 for optimal speed. +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
    +mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 });
    +mp_ptr rp = new mp_ptr(new uint[2]);
    +mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });
    +
    +// Set rp = s1 + s2.
    +mp_limb_t carry = gmp_lib.mpn_add_n(rp, s1p, s2p, rp.Size);
    +
    +// Assert result of operation.
    +Assert.IsTrue(carry == 1);
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, s1p, s2p, result);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/33b840cd-1b41-ad67-8956-b5811ddc6175.htm b/docs/html/33b840cd-1b41-ad67-8956-b5811ddc6175.htm new file mode 100644 index 0000000..6ac479d --- /dev/null +++ b/docs/html/33b840cd-1b41-ad67-8956-b5811ddc6175.htm @@ -0,0 +1,17 @@ +mp_limb_t.Equals Method (Object)
    mp_limb_tEquals Method (Object)
    + Returns a value indicating whether this instance is equal to a specified object. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override bool Equals(
    +	Object obj
    +)

    Parameters

    obj
    Type: SystemObject
    An object to compare with this instance.

    Return Value

    Type: Boolean
    True if obj is an instance of mp_limb_t and equals the value of this instance; otherwise, False.
    See Also
    \ No newline at end of file diff --git a/docs/html/34a39f93-359c-526f-c9ad-cd7558968f1e.htm b/docs/html/34a39f93-359c-526f-c9ad-cd7558968f1e.htm new file mode 100644 index 0000000..2036952 --- /dev/null +++ b/docs/html/34a39f93-359c-526f-c9ad-cd7558968f1e.htm @@ -0,0 +1,65 @@ +gmp_lib.mpf_ui_div Method
    Click or drag to resize
    gmp_libmpf_ui_div Method
    + Set rop to op1 / op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_ui_div(
    +	mpf_t rop,
    +	uint op1,
    +	mpf_t op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op1
    Type: SystemUInt32
    The first operand.
    op2
    Type: Math.Gmp.Nativempf_t
    The second operand.
    Remarks

    + Division is undefined if the divisor is zero, and passing a zero divisor to the divide + functions will make it intentionally divide by zero. + This lets the user handle arithmetic exceptions in division functions in the same manner + as other arithmetic exceptions. +

    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 10.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, 10);
    +
    +// Create and initialize a new floating-point number z.
    +mpf_t z = new mpf_t();
    +gmp_lib.mpf_init(z);
    +
    +// Set z = 210 / x.
    +gmp_lib.mpf_ui_div(z, 210U, x);
    +
    +// Assert that the value of z is 21.
    +Assert.IsTrue(gmp_lib.mpf_get_d(z) == 21.0);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpf_clears(x, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/3523bf0e-75ec-6286-76a0-4685198e51f6.htm b/docs/html/3523bf0e-75ec-6286-76a0-4685198e51f6.htm new file mode 100644 index 0000000..0b8dccb --- /dev/null +++ b/docs/html/3523bf0e-75ec-6286-76a0-4685198e51f6.htm @@ -0,0 +1,62 @@ +gmp_lib.mpz_mul Method
    Click or drag to resize
    gmp_libmpz_mul Method
    + Set rop to op1 * op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_mul(
    +	mpz_t rop,
    +	mpz_t op1,
    +	mpz_t op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: Math.Gmp.Nativempz_t
    The second operand integer.
    Examples
    // Create, initialize, and set the value of x to 10000.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_ui(x, 10000U);
    +
    +// Create, initialize, and set the value of y to 12222.
    +mpz_t y = new mpz_t();
    +gmp_lib.mpz_init_set_ui(y, 12222U);
    +
    +// Create, initialize, and set the value of z to 0.
    +mpz_t z = new mpz_t();
    +gmp_lib.mpz_init(z);
    +
    +// Set z = x * y.
    +gmp_lib.mpz_mul(z, x, y);
    +
    +// Assert that z is the product of x and y.
    +Assert.IsTrue(gmp_lib.mpz_get_si(z) == 10000 * 12222);
    +
    +// Release unmanaged memory allocated for x, y, and z.
    +gmp_lib.mpz_clears(x, y, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/352401d6-c6d1-29c1-a9f6-e5e0ed46bc86.htm b/docs/html/352401d6-c6d1-29c1-a9f6-e5e0ed46bc86.htm new file mode 100644 index 0000000..d25dcd9 --- /dev/null +++ b/docs/html/352401d6-c6d1-29c1-a9f6-e5e0ed46bc86.htm @@ -0,0 +1,60 @@ +gmp_lib.mpf_div_2exp Method
    Click or drag to resize
    gmp_libmpf_div_2exp Method
    + Set rop to op1 / 2^op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_div_2exp(
    +	mpf_t rop,
    +	mpf_t op1,
    +	uint op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op1
    Type: Math.Gmp.Nativempf_t
    The fisrt operand.
    op2
    Type: SystemUInt32
    The second operand.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 512.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, 512);
    +
    +// Create and initialize a new floating-point number z.
    +mpf_t z = new mpf_t();
    +gmp_lib.mpf_init(z);
    +
    +// Set z = x / 2^8.
    +gmp_lib.mpf_div_2exp(z, x, 8U);
    +
    +// Assert that the value of z is 2.
    +Assert.IsTrue(gmp_lib.mpf_get_d(z) == 2.0);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpf_clears(x, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/3568dd4d-d565-0b12-2da2-2fed2d433257.htm b/docs/html/3568dd4d-d565-0b12-2da2-2fed2d433257.htm new file mode 100644 index 0000000..76fd484 --- /dev/null +++ b/docs/html/3568dd4d-d565-0b12-2da2-2fed2d433257.htm @@ -0,0 +1,99 @@ +gmp_lib.gmp_set_memory_functions Method
    Click or drag to resize
    gmp_libgmp_set_memory_functions Method
    + Replace the current allocation functions from the arguments. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void gmp_set_memory_functions(
    +	allocate_function alloc_func_ptr,
    +	reallocate_function realloc_func_ptr,
    +	free_function free_func_ptr
    +)

    Parameters

    alloc_func_ptr
    Type: Math.Gmp.Nativeallocate_function
    The new memory allocation function.
    realloc_func_ptr
    Type: Math.Gmp.Nativereallocate_function
    The new memory reallocation function.
    free_func_ptr
    Type: Math.Gmp.Nativefree_function
    The new memory de-allocation function.
    Remarks

    + If an argument is null (Nothing in VB.NET), the corresponding + default function is used. +

    Examples
    // Retrieve GMP default memory allocation functions.
    +allocate_function default_allocate = null;
    +reallocate_function default_reallocate = null;
    +free_function default_free = null;
    +gmp_lib.gmp_get_memory_functions(ref default_allocate, ref default_reallocate, ref default_free);
    +
    +// Create and set new memory allocation functions that count the number of times they are called.
    +int counter = 0;
    +allocate_function new_allocate = (size_t alloc_size) => { counter++; return default_allocate(alloc_size); };
    +reallocate_function new_reallocate = (void_ptr ptr, size_t old_size, size_t new_size) => { counter++; return default_reallocate(ptr, old_size, new_size); };
    +free_function new_free = (void_ptr ptr, size_t size) => { counter++; default_free(ptr, size); };
    +gmp_lib.gmp_set_memory_functions(new_allocate, new_reallocate, new_free);
    +
    +// Retrieve GMP memory allocation functions.
    +allocate_function allocate = null;
    +reallocate_function reallocate = null;
    +free_function free = null;
    +gmp_lib.gmp_get_memory_functions(ref allocate, ref reallocate, ref free);
    +
    +// Call memory function and assert calls count.
    +void_ptr p = allocate(10);
    +Assert.IsTrue(counter == 1);
    +
    +reallocate(p, 10, 20);
    +Assert.IsTrue(counter == 2);
    +
    +free(p, 20);
    +Assert.IsTrue(counter == 3);
    +
    +// Restore default memory allocation functions.
    +gmp_lib.gmp_set_memory_functions(null, null, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/357791cb-951d-5542-ff67-c00ef5e9aadb.htm b/docs/html/357791cb-951d-5542-ff67-c00ef5e9aadb.htm new file mode 100644 index 0000000..5f1f0ac --- /dev/null +++ b/docs/html/357791cb-951d-5542-ff67-c00ef5e9aadb.htm @@ -0,0 +1,56 @@ +gmp_lib.mpf_neg Method
    Click or drag to resize
    gmp_libmpf_neg Method
    + Set rop to -op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_neg(
    +	mpf_t rop,
    +	mpf_t op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op
    Type: Math.Gmp.Nativempf_t
    The operand.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 10.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, 10);
    +
    +// Create and initialize a new floating-point number z.
    +mpf_t z = new mpf_t();
    +gmp_lib.mpf_init(z);
    +
    +// Set z = -x.
    +gmp_lib.mpf_neg(z, x);
    +
    +// Assert that the value of z is -10.
    +Assert.IsTrue(gmp_lib.mpf_get_d(z) == -10.0);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpf_clears(x, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/3588cf60-567a-6182-20e8-5e2836498f49.htm b/docs/html/3588cf60-567a-6182-20e8-5e2836498f49.htm new file mode 100644 index 0000000..8fd9644 --- /dev/null +++ b/docs/html/3588cf60-567a-6182-20e8-5e2836498f49.htm @@ -0,0 +1,58 @@ +gmp_lib.mpn_sec_tabselect Method
    Click or drag to resize
    gmp_libmpn_sec_tabselect Method
    + Select entry which from table tab, which has nents entries, each n limbs. Store the selected entry at rp. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpn_sec_tabselect(
    +	mp_ptr rp,
    +	mp_ptr tab,
    +	mp_size_t n,
    +	mp_size_t nents,
    +	mp_size_t which
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    tab
    Type: Math.Gmp.Nativemp_ptr
    The table of operand integers.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs in each entry of the table.
    nents
    Type: Math.Gmp.Nativemp_size_t
    The number of entries in the table.
    which
    Type: Math.Gmp.Nativemp_size_t
    The zero-based index of the entry to select.
    Remarks

    + This function reads the entire table to avoid side-channel information leaks. +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr tab = new mp_ptr(new uint[] { 0x11111111, 0x22222222, 0x33333333, 0x44444444, 0x33333333, 0x00000000 });
    +mp_ptr result = new mp_ptr(new uint[] { 0x33333333 });
    +mp_ptr rp = new mp_ptr(result.Size);
    +
    +// Set rp to third entry in tab.
    +gmp_lib.mpn_sec_tabselect(rp, tab, 1, tab.Size, 2);
    +
    +// Assert result of operation.
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(tab, result);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/37510828-012a-9e6a-7916-776acfd8f1f9.htm b/docs/html/37510828-012a-9e6a-7916-776acfd8f1f9.htm new file mode 100644 index 0000000..402c401 --- /dev/null +++ b/docs/html/37510828-012a-9e6a-7916-776acfd8f1f9.htm @@ -0,0 +1,50 @@ +gmp_lib.gmp_get_memory_functions Method
    Click or drag to resize
    gmp_libgmp_get_memory_functions Method
    + Get the current allocation functions, storing function pointers to the locations given by the arguments. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void gmp_get_memory_functions(
    +	ref allocate_function alloc_func_ptr,
    +	ref reallocate_function realloc_func_ptr,
    +	ref free_function free_func_ptr
    +)

    Parameters

    alloc_func_ptr
    Type: Math.Gmp.Nativeallocate_function
    The memory allocation function.
    realloc_func_ptr
    Type: Math.Gmp.Nativereallocate_function
    The memory reallocation function.
    free_func_ptr
    Type: Math.Gmp.Nativefree_function
    The memory de-allocation function.
    Examples
    allocate_function allocate;
    +reallocate_function reallocate;
    +free_function free;
    +
    +// Retrieve the GMP memory allocation functions.
    +allocate = null;
    +reallocate = null;
    +free = null;
    +gmp_lib.gmp_get_memory_functions(ref allocate, ref reallocate, ref free);
    +Assert.IsTrue(allocate != null && reallocate != null && free != null);
    +
    +// Allocate and free memory.
    +void_ptr p = allocate(100);
    +free(p, 100);
    See Also
    \ No newline at end of file diff --git a/docs/html/37c88d6c-8d02-2330-ad77-f20fb73d1677.htm b/docs/html/37c88d6c-8d02-2330-ad77-f20fb73d1677.htm new file mode 100644 index 0000000..c8343ca --- /dev/null +++ b/docs/html/37c88d6c-8d02-2330-ad77-f20fb73d1677.htm @@ -0,0 +1,40 @@ +mpf_t Class
    mpf_t Class
    + Represents a multiple precision floating-point number. +
    Inheritance Hierarchy

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public class mpf_t : mp_base

    The mpf_t type exposes the following members.

    Constructors
    +   + NameDescription
    Public methodmpf_t
    + Creates a new multiple precision floating-point number. +
    Top
    Properties
    +   + NameDescription
    Public property_mp_d
    + A pointer to an array of limbs which is the magnitude. +
    (Inherited from mp_base.)
    Public property_mp_exp
    + The exponent, in limbs, determining the location of the implied radix point. +
    Public property_mp_prec
    + The precision of the mantissa, in limbs. +
    Public property_mp_size
    + The number of limbs currently in use, or the negative of that when representing a negative value. +
    (Overrides mp_base_mp_size.)
    Top
    Methods
    +   + NameDescription
    Public methodEquals
    Determines whether the specified Object is equal to the current Object.
    (Inherited from Object.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGetHashCode
    Serves as a hash function for a particular type.
    (Inherited from Object.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Public methodToIntPtr
    + Gets the unmanaged memory pointer of the multiple precision floating-point number. +
    Public methodToString
    + Return the string representation of the float. +
    (Overrides ObjectToString.)
    Top
    Operators
    Remarks

    + The floating point functions accept and return exponents in the C type mp_exp_t. + Currently this is usually a long, but on some systems it’s an int for efficiency. +

    + In .NET, this is a 32-bit integer. +

    See Also
    \ No newline at end of file diff --git a/docs/html/387ec1dd-15b3-4cc9-862a-e3f0a8e2cb78.htm b/docs/html/387ec1dd-15b3-4cc9-862a-e3f0a8e2cb78.htm new file mode 100644 index 0000000..7dca746 --- /dev/null +++ b/docs/html/387ec1dd-15b3-4cc9-862a-e3f0a8e2cb78.htm @@ -0,0 +1,70 @@ +gmp_lib.mpz_tdiv_qr Method
    Click or drag to resize
    gmp_libmpz_tdiv_qr Method
    + Set the quotient q to trunc(n / d), and set the remainder r to n - q * d. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_tdiv_qr(
    +	mpz_t q,
    +	mpz_t r,
    +	mpz_t n,
    +	mpz_t d
    +)

    Parameters

    q
    Type: Math.Gmp.Nativempz_t
    The result quotient integer.
    r
    Type: Math.Gmp.Nativempz_t
    The result remainder integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: Math.Gmp.Nativempz_t
    The denominator integer.
    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10000);
    +
    +// Create, initialize, and set the value of d to 3.
    +mpz_t d = new mpz_t();
    +gmp_lib.mpz_init_set_si(d, 3);
    +
    +// Create, initialize, and set the values of q and r to 0.
    +mpz_t q = new mpz_t();
    +mpz_t r = new mpz_t();
    +gmp_lib.mpz_inits(q, r, null);
    +
    +// Set q = trunc(n / 3) and r = n - d * q.
    +gmp_lib.mpz_tdiv_qr(q, r, n, d);
    +
    +// Assert that q is 3333, and that r is 1.
    +Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);
    +Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);
    +
    +// Release unmanaged memory allocated for n, d, q, and r.
    +gmp_lib.mpz_clears(n, d, q, r, null);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/38be0c24-42ac-e0ea-9e18-e75e3bda2a1e.htm b/docs/html/38be0c24-42ac-e0ea-9e18-e75e3bda2a1e.htm new file mode 100644 index 0000000..dc0d865 --- /dev/null +++ b/docs/html/38be0c24-42ac-e0ea-9e18-e75e3bda2a1e.htm @@ -0,0 +1,46 @@ +gmp_lib.mpz_jacobi Method
    Click or drag to resize
    gmp_libmpz_jacobi Method
    + Calculate the Jacobi symbol (a/b). +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_jacobi(
    +	mpz_t a,
    +	mpz_t b
    +)

    Parameters

    a
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    b
    Type: Math.Gmp.Nativempz_t
    The second operand integer.

    Return Value

    Type: Int32
    The Jacobi symbol (a/b).
    Remarks

    + This is defined only for b odd. +

    Examples
    // Create, initialize, and set the value of a to 11.
    +mpz_t a = new mpz_t();
    +gmp_lib.mpz_init_set_ui(a, 11U);
    +
    +// Create, initialize, and set the value of b to 9.
    +mpz_t b = new mpz_t();
    +gmp_lib.mpz_init_set_ui(b, 9U);
    +
    +// Assert that the Jacobi symbol of (a/b) is 1.
    +Assert.IsTrue(gmp_lib.mpz_jacobi(a, b) == 1);
    +
    +// Release unmanaged memory allocated for a and b.
    +gmp_lib.mpz_clears(a, b, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/38d3a9de-bae7-3f44-18e0-38fe450d4cba.htm b/docs/html/38d3a9de-bae7-3f44-18e0-38fe450d4cba.htm new file mode 100644 index 0000000..d03aebb --- /dev/null +++ b/docs/html/38d3a9de-bae7-3f44-18e0-38fe450d4cba.htm @@ -0,0 +1,78 @@ +gmp_lib.mpq_inp_str Method
    Click or drag to resize
    gmp_libmpq_inp_str Method
    + Read a string of digits from stream and convert them to a rational in rop. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static size_t mpq_inp_str(
    +	mpq_t rop,
    +	ptr<FILE> stream,
    +	int base
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempq_t
    The result rational.
    stream
    Type: Math.Gmp.NativeptrFILE
    Pointer to file stream.
    base
    Type: SystemInt32
    The base.

    Return Value

    Type: size_t
    Return the number of characters read (including white space), or 0 if a rational could not be read.
    Remarks

    + Any initial white-space characters are read and discarded. +

    + The input can be a fraction like "17/63" or just an integer like "123". + Reading stops at the first character not in this form, and white space is not permitted within the string. + If the input might not be in canonical form, then mpq_canonicalize(mpq_t) must be called + (see GNU MP - Rational Number Functions). +

    + The base can be between 2 and 36, or can be 0 in which case the leading characters + of the string determine the base, "0x" or "0X" for hexadecimal, "0" for octal, or decimal otherwise. + The leading characters are examined separately for the numerator and denominator of a fraction, so for instance + "0x10/11" is 16/11, whereas "0x10/0x11" is 16/17. +

    Examples
    // Create, initialize, and set the value of op to 123/456.
    +mpq_t op = new mpq_t();
    +gmp_lib.mpq_init(op);
    +
    +// Write rational to a temporary file.
    +string pathname = System.IO.Path.GetTempFileName();
    +System.IO.File.WriteAllText(pathname, "123/456");
    +
    +// Read op from the temporary file, and assert that the number of bytes read is 7.
    +ptr<FILE> stream = new ptr<FILE>();
    +_wfopen_s(out stream.Value.Value, pathname, "r");
    +Assert.IsTrue(gmp_lib.mpq_inp_str(op, stream, 10) == 7);
    +fclose(stream.Value.Value);
    +
    +// Assert that op is 123/456.
    +Assert.IsTrue(gmp_lib.mpq_cmp_ui(op, 123, 456U) == 0);
    +
    +// Delete temporary file.
    +System.IO.File.Delete(pathname);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpq_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/3985111a-6d13-b418-9c90-422a8e1e5b8b.htm b/docs/html/3985111a-6d13-b418-9c90-422a8e1e5b8b.htm new file mode 100644 index 0000000..6910812 --- /dev/null +++ b/docs/html/3985111a-6d13-b418-9c90-422a8e1e5b8b.htm @@ -0,0 +1,47 @@ +gmp_lib.mpf_div_ui Method
    Click or drag to resize
    gmp_libmpf_div_ui Method
    + Set rop to op1 / op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_div_ui(
    +	mpf_t rop,
    +	mpf_t op1,
    +	uint op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op1
    Type: Math.Gmp.Nativempf_t
    The first operand.
    op2
    Type: SystemUInt32
    The second operand.
    Remarks

    + Division is undefined if the divisor is zero, and passing a zero divisor to the divide + functions will make it intentionally divide by zero. + This lets the user handle arithmetic exceptions in division functions in the same manner + as other arithmetic exceptions. +

    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number y to -210.
    +mpf_t y = new mpf_t();
    +gmp_lib.mpf_init_set_si(y, -210);
    +
    +// Create and initialize a new floating-point number z.
    +mpf_t z = new mpf_t();
    +gmp_lib.mpf_init(z);
    +
    +// Set z = y / 10.
    +gmp_lib.mpf_div_ui(z, y, 10U);
    +
    +// Assert that the value of z is -21.
    +Assert.IsTrue(gmp_lib.mpf_get_d(z) == -21.0);
    +
    +// Release unmanaged memory allocated for y and z.
    +gmp_lib.mpf_clears(y, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/398e3eb8-0f55-086f-a765-0a8b3c9307e0.htm b/docs/html/398e3eb8-0f55-086f-a765-0a8b3c9307e0.htm new file mode 100644 index 0000000..a99576e --- /dev/null +++ b/docs/html/398e3eb8-0f55-086f-a765-0a8b3c9307e0.htm @@ -0,0 +1,36 @@ +gmp_lib.mpz_limbs_finish Method
    Click or drag to resize
    gmp_libmpz_limbs_finish Method
    + Updates the internal size field of x. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_limbs_finish(
    +	mpz_t x,
    +	mp_size_t s
    +)

    Parameters

    x
    Type: Math.Gmp.Nativempz_t
    The operand integer.
    s
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs and the sign of x.
    Remarks

    + Used after writing to the limb array pointer returned by mpz_limbs_write(mpz_t, mp_size_t) + or mpz_limbs_modify(mpz_t, mp_size_t) is completed. The array should contain |s| + valid limbs, representing the new absolute value for x, and the sign of x + is taken from the sign of s. + This function never reallocates x, so the limb pointer remains valid. +

    C++
    void foo (mpz_t x)
    +{
    +    mp_size_t n, i;
    +    mp_limb_t* xp;
    +
    +    n = mpz_size(x);
    +    xp = mpz_limbs_modify(x, 2 * n);
    +    for (i = 0; i < n; i++)
    +        xp[n + i] = xp[n - 1 - i];
    +    mpz_limbs_finish(x, mpz_sgn(x) < 0 ? - 2 * n : 2 * n);
    +}
    See Also
    \ No newline at end of file diff --git a/docs/html/3a025035-e715-0a3d-8d2d-6011430c9463.htm b/docs/html/3a025035-e715-0a3d-8d2d-6011430c9463.htm new file mode 100644 index 0000000..f464687 --- /dev/null +++ b/docs/html/3a025035-e715-0a3d-8d2d-6011430c9463.htm @@ -0,0 +1,54 @@ +gmp_lib.mpf_set Method
    Click or drag to resize
    gmp_libmpf_set Method
    + Set the value of rop from op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_set(
    +	mpf_t rop,
    +	mpf_t op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op
    Type: Math.Gmp.Nativempf_t
    The operand.
    Examples
    // Create, initialize, and set a new floating-point number x to 10.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init2(x, 128U);
    +gmp_lib.mpf_set_si(x, 10);
    +
    +// Create, initialize, and set a new floating-point number y to -210.
    +mpf_t y = new mpf_t();
    +gmp_lib.mpf_init2(y, 128U);
    +gmp_lib.mpf_set_si(y, -210);
    +
    +// Assign the value of y to x.
    +gmp_lib.mpf_set(x, y);
    +
    +// Assert that the value of x is -210.
    +Assert.IsTrue(gmp_lib.mpf_get_d(x) == -210.0);
    +
    +// Release unmanaged memory allocated for x and y.
    +gmp_lib.mpf_clears(x, y, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/3a24f5bd-0b45-8164-f27b-c2e04e35ab64.htm b/docs/html/3a24f5bd-0b45-8164-f27b-c2e04e35ab64.htm new file mode 100644 index 0000000..ae8f053 --- /dev/null +++ b/docs/html/3a24f5bd-0b45-8164-f27b-c2e04e35ab64.htm @@ -0,0 +1,79 @@ +gmp_lib.mpf_inp_str Method
    Click or drag to resize
    gmp_libmpf_inp_str Method
    + Read a string in base base from stream, and put the read float in rop. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static size_t mpf_inp_str(
    +	mpf_t rop,
    +	ptr<FILE> stream,
    +	int base
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    stream
    Type: Math.Gmp.NativeptrFILE
    Pointer to file stream.
    base
    Type: SystemInt32
    The base.

    Return Value

    Type: size_t
    Return the number of bytes read, or if an error occurred, return 0.
    Remarks

    + The string is of the form "M@N" or, if the base is 10 or less, alternatively "MeN". + "M" is the mantissa and "N’" is the exponent. + The mantissa is always in the specified base. + The exponent is either in the specified base or, if base is negative, in decimal. + The decimal point expected is taken from the current locale, on systems providing localeconv. +

    + The argument base may be in the ranges 2 to 36, or -36 to -2. + Negative values are used to specify that the exponent is in decimal. +

    + Unlike the corresponding mpz function, the base will not be determined from the leading + characters of the string if base is 0. + This is so that numbers like "0.23" are not interpreted as octal. +

    Examples
    // Create and initialize op.
    +mpf_t op = new mpf_t();
    +gmp_lib.mpf_init(op);
    +
    +// Write op to a temporary file.
    +string pathname = System.IO.Path.GetTempFileName();
    +System.IO.File.WriteAllText(pathname, "0.123456e6");
    +
    +// Read op from the temporary file, and assert that the number of bytes read is 6.
    +ptr<FILE> stream = new ptr<FILE>();
    +_wfopen_s(out stream.Value.Value, pathname, "r");
    +Assert.IsTrue(gmp_lib.mpf_inp_str(op, stream, 10) == 10);
    +fclose(stream.Value.Value);
    +
    +// Assert that op is 123456.
    +Assert.IsTrue(gmp_lib.mpf_get_ui(op) == 123456U);
    +
    +// Delete temporary file.
    +System.IO.File.Delete(pathname);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpf_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/3a2a17ed-a64c-8716-7f65-18c661a5279f.htm b/docs/html/3a2a17ed-a64c-8716-7f65-18c661a5279f.htm new file mode 100644 index 0000000..6582a4a --- /dev/null +++ b/docs/html/3a2a17ed-a64c-8716-7f65-18c661a5279f.htm @@ -0,0 +1,40 @@ +gmp_lib.mpf_clear Method
    Click or drag to resize
    gmp_libmpf_clear Method
    + Free the space occupied by x. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_clear(
    +	mpf_t x
    +)

    Parameters

    x
    Type: Math.Gmp.Nativempf_t
    The operand float.
    Remarks

    + Make sure to call this function for all mpf_t variables when you are done with them. +

    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create and initialize a new floating-point number x.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init(x);
    +
    +// Assert that the value of x is 0.0.
    +Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpf_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/3a4e6141-0771-f9ac-2283-5e9348f86d4a.htm b/docs/html/3a4e6141-0771-f9ac-2283-5e9348f86d4a.htm new file mode 100644 index 0000000..23cf10d --- /dev/null +++ b/docs/html/3a4e6141-0771-f9ac-2283-5e9348f86d4a.htm @@ -0,0 +1,55 @@ +gmp_lib.mpz_set Method
    Click or drag to resize
    gmp_libmpz_set Method
    + Set the value of rop from op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_set(
    +	mpz_t rop,
    +	mpz_t op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The destination integer.
    op
    Type: Math.Gmp.Nativempz_t
    The source integer.
    Examples
    // Create, initialize, and set a new integer x to 10.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init(x);
    +gmp_lib.mpz_set_si(x, 10);
    +
    +// Create, initialize, and set a new integer y to -210.
    +mpz_t y = new mpz_t();
    +gmp_lib.mpz_init(y);
    +gmp_lib.mpz_set_si(y, -210);
    +
    +// Assign the value of y to x.
    +gmp_lib.mpz_set(x, y);
    +
    +// Assert that the value of x is -210.
    +Assert.IsTrue(gmp_lib.mpz_get_si(x) == -210);
    +
    +// Release unmanaged memory allocated for x and y.
    +gmp_lib.mpz_clears(x, y, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/3a92eddc-59f3-b42f-9921-4e1cc5700d60.htm b/docs/html/3a92eddc-59f3-b42f-9921-4e1cc5700d60.htm new file mode 100644 index 0000000..016382c --- /dev/null +++ b/docs/html/3a92eddc-59f3-b42f-9921-4e1cc5700d60.htm @@ -0,0 +1,36 @@ +gmp_lib.mpz_get_ui Method
    Click or drag to resize
    gmp_libmpz_get_ui Method
    + Return the value of op as an unsigned long. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static uint mpz_get_ui(
    +	mpz_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempz_t
    The integer.

    Return Value

    Type: UInt32
    The value of op as an unsigned long.
    Remarks

    + If op is too big to fit an unsigned long then just the least significant + bits that do fit are returned. The sign of op is ignored, only the absolute + value is used. +

    Examples
    // Create, initialize, and set the value of x to 10.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_ui(x, 10U);
    +
    +// Retrieve the value of x, and assert that it is 10.
    +Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 10U);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpz_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/3ac2ecd4-f154-de62-9170-b2d28f362a7e.htm b/docs/html/3ac2ecd4-f154-de62-9170-b2d28f362a7e.htm new file mode 100644 index 0000000..b0c9f75 --- /dev/null +++ b/docs/html/3ac2ecd4-f154-de62-9170-b2d28f362a7e.htm @@ -0,0 +1,56 @@ +gmp_lib.mpf_trunc Method
    Click or drag to resize
    gmp_libmpf_trunc Method
    + Set rop to op rounded to the integer towards zero. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_trunc(
    +	mpf_t rop,
    +	mpf_t op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op
    Type: Math.Gmp.Nativempf_t
    The operand float.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 10.4.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_d(x, 10.4);
    +
    +// Create and initialize a new floating-point number z.
    +mpf_t z = new mpf_t();
    +gmp_lib.mpf_init(z);
    +
    +// Set z = trunc(x).
    +gmp_lib.mpf_trunc(z, x);
    +
    +// Assert that the value of z is 10.
    +Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpf_clears(x, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm b/docs/html/3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm new file mode 100644 index 0000000..5633516 --- /dev/null +++ b/docs/html/3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm @@ -0,0 +1,771 @@ +gmp_lib Class
    gmp_lib Class

    [Missing <summary> documentation for "T:Math.Gmp.Native.gmp_lib"]

    Inheritance Hierarchy
    SystemObject
      Math.Gmp.Nativegmp_lib

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static class gmp_lib

    The gmp_lib type exposes the following members.

    Properties
    +   + NameDescription
    Public propertyStatic membergmp_errno
    + Gets or sets the global GMP error number. +
    Top
    Methods
    +   + NameDescription
    Public methodStatic memberCode example_mpz_realloc
    + Change the space for integer to new_alloc limbs. +
    Public methodStatic memberallocate
    + Return a pointer to newly allocated space with at least alloc_size bytes. +
    Public methodStatic memberfree(char_ptr)
    + De-allocate the space pointed to by ptr. +
    Public methodStatic memberfree(gmp_randstate_t)
    + De-allocate the space pointed to by ptr. +
    Public methodStatic memberfree(mp_ptr)
    + De-allocate the space pointed to by ptrs. +
    Public methodStatic memberfree(void_ptr)
    + De-allocate the space pointed to by ptr. +
    Public methodStatic memberfree(void_ptr, size_t)
    + De-allocate the space pointed to by ptr. +
    Public methodStatic memberCode examplegmp_asprintf
    + Form a null-terminated string in a block of memory obtained from the current memory allocation function. +
    Public methodStatic memberCode examplegmp_fprintf
    + Print to the stream fp. +
    Public methodStatic memberCode examplegmp_fscanf
    + Read from the stream fp. +
    Public methodStatic memberCode examplegmp_get_memory_functions
    + Get the current allocation functions, storing function pointers to the locations given by the arguments. +
    Public methodStatic memberCode examplegmp_printf
    + Print to the standard output stdout. +
    Public methodStatic membergmp_randclear
    + Free all memory occupied by state. +
    Public methodStatic memberCode examplegmp_randinit_default
    + Initialize state with a default algorithm. +
    Public methodStatic memberCode examplegmp_randinit_lc_2exp
    + Initialize state with a linear congruential algorithm X = (aX + c) mod 2^m2exp. +
    Public methodStatic memberCode examplegmp_randinit_lc_2exp_size
    + Initialize state for a linear congruential algorithm as per gmp_randinit_lc_2exp(gmp_randstate_t, mpz_t, UInt32, mp_bitcnt_t). +
    Public methodStatic memberCode examplegmp_randinit_mt
    + Initialize state for a Mersenne Twister algorithm. +
    Public methodStatic memberCode examplegmp_randinit_set
    + Initialize rop with a copy of the algorithm and state from op. +
    Public methodStatic memberCode examplegmp_randseed
    + Set an initial seed value into state. +
    Public methodStatic memberCode examplegmp_randseed_ui
    + Set an initial seed value into state. +
    Public methodStatic memberCode examplegmp_scanf
    + Read from the standard input stdin. +
    Public methodStatic memberCode examplegmp_set_memory_functions
    + Replace the current allocation functions from the arguments. +
    Public methodStatic memberCode examplegmp_snprintf
    + Form a null-terminated string in buf. +
    Public methodStatic memberCode examplegmp_sprintf
    + Form a null-terminated string in buf. +
    Public methodStatic memberCode examplegmp_sscanf
    + Read from a null-terminated string s. +
    Public methodStatic memberCode examplegmp_urandomb_ui
    + Generate a uniformly distributed random number of n bits, i.e. in the range 0 to 2^n - 1 inclusive. +
    Public methodStatic memberCode examplegmp_urandomm_ui
    + Generate a uniformly distributed random number in the range 0 to n - 1, inclusive. +
    Public methodStatic memberCode examplegmp_vasprintf
    + Form a null-terminated string in a block of memory obtained from the current memory allocation function. +
    Public methodStatic memberCode examplegmp_vfprintf
    + Print to the stream fp. +
    Public methodStatic memberCode examplegmp_vfscanf
    + Read from the stream fp. +
    Public methodStatic memberCode examplegmp_vprintf
    + Print to the standard output stdout. +
    Public methodStatic memberCode examplegmp_vscanf
    + Read from the standard input stdin. +
    Public methodStatic memberCode examplegmp_vsnprintf
    + Form a null-terminated string in buf. +
    Public methodStatic memberCode examplegmp_vsprintf
    + Form a null-terminated string in buf. +
    Public methodStatic memberCode examplegmp_vsscanf
    + Read from a null-terminated string s. +
    Public methodStatic memberCode examplempf_abs
    + Set rop to |op|. +
    Public methodStatic memberCode examplempf_add
    + Set rop to op1 + op2. +
    Public methodStatic memberCode examplempf_add_ui
    + Set rop to op1 + op2. +
    Public methodStatic memberCode examplempf_ceil
    + Set rop to op rounded to the next higher integer. +
    Public methodStatic memberCode examplempf_clear
    + Free the space occupied by x. +
    Public methodStatic memberCode examplempf_clears
    + Free the space occupied by a NULL-terminated list of mpf_t variables. +
    Public methodStatic memberCode examplempf_cmp
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempf_cmp_d
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempf_cmp_si
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempf_cmp_ui
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempf_cmp_z
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempf_div
    + Set rop to op1 / op2. +
    Public methodStatic memberCode examplempf_div_2exp
    + Set rop to op1 / 2^op2. +
    Public methodStatic memberCode examplempf_div_ui
    + Set rop to op1 / op2. +
    Public methodStatic memberCode examplempf_fits_sint_p
    + Return non-zero if op fits in a 32-bit integer, when truncated to an integer. +
    Public methodStatic memberCode examplempf_fits_slong_p
    + Return non-zero if op fits in a 32-bit integer, when truncated to an integer. +
    Public methodStatic memberCode examplempf_fits_sshort_p
    + Return non-zero if op fits in a 16-bit integer, when truncated to an integer. +
    Public methodStatic memberCode examplempf_fits_uint_p
    + Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer. +
    Public methodStatic memberCode examplempf_fits_ulong_p
    + Return non-zero if op fits in an unsigned 32-bit integer, when truncated to an integer. +
    Public methodStatic memberCode examplempf_fits_ushort_p
    + Return non-zero if op fits in an unsigned 16-bit integer, when truncated to an integer. +
    Public methodStatic memberCode examplempf_floor
    + Set rop to op rounded to the next lower integer. +
    Public methodStatic memberCode examplempf_get_d
    + Convert op to a Double, truncating if necessary (i.e. rounding towards zero). +
    Public methodStatic memberCode examplempf_get_d_2exp
    + Convert op to a double, truncating if necessary (i.e. rounding towards zero), and with an exponent returned separately. +
    Public methodStatic memberCode examplempf_get_default_prec
    + Return the default precision actually used. +
    Public methodStatic memberCode examplempf_get_prec
    + Return the current precision of op, in bits. +
    Public methodStatic memberCode examplempf_get_si
    + Convert op to a 32-bit integer, truncating any fraction part. +
    Public methodStatic memberCode examplempf_get_str
    + Convert op to a string of digits in base base. +
    Public methodStatic memberCode examplempf_get_ui
    + Convert op to an unsigned 32-bit integer, truncating any fraction part. +
    Public methodStatic memberCode examplempf_init
    + Initialize x to 0. +
    Public methodStatic memberCode examplempf_init_set
    + Initialize rop and set its value from op. +
    Public methodStatic memberCode examplempf_init_set_d
    + Initialize rop and set its value from op. +
    Public methodStatic memberCode examplempf_init_set_si
    + Initialize rop and set its value from op. +
    Public methodStatic memberCode examplempf_init_set_str
    + Initialize rop and set its value from the string in str. +
    Public methodStatic memberCode examplempf_init_set_ui
    + Initialize rop and set its value from op. +
    Public methodStatic memberCode examplempf_init2
    + Initialize x to 0 and set its precision to be at least prec bits. +
    Public methodStatic memberCode examplempf_inits
    + Initialize a NULL-terminated list of mpf_t variables, and set their values to 0. +
    Public methodStatic memberCode examplempf_inp_str
    + Read a string in base base from stream, and put the read float in rop. +
    Public methodStatic memberCode examplempf_integer_p
    + Return non-zero if op is an integer. +
    Public methodStatic memberCode examplempf_mul
    + Set rop to op1 * op2. +
    Public methodStatic memberCode examplempf_mul_2exp
    + Set rop to op1 * 2^op2. +
    Public methodStatic memberCode examplempf_mul_ui
    + Set rop to op1 * op2. +
    Public methodStatic memberCode examplempf_neg
    + Set rop to -op. +
    Public methodStatic memberCode examplempf_out_str
    + Print op to stream, as a string of digits. +
    Public methodStatic memberCode examplempf_pow_ui
    + Set rop to op1^op2. +
    Public methodStatic memberCode examplempf_random2
    + Generate a random float of at most max_size limbs, with long strings of zeros and ones in the binary representation. +
    Public methodStatic memberCode examplempf_reldiff
    + Compute the relative difference between op1 and op2 and store the result in rop. This is |op1 - op2| / op1. +
    Public methodStatic memberCode examplempf_set
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempf_set_d
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempf_set_default_prec
    + Set the default precision to be at least prec bits. +
    Public methodStatic memberCode examplempf_set_prec
    + Set the precision of rop to be at least prec bits. +
    Public methodStatic memberCode examplempf_set_prec_raw
    + Set the precision of rop to be at least prec bits, without changing the memory allocated. +
    Public methodStatic memberCode examplempf_set_q
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempf_set_si
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempf_set_str
    + Set the value of rop from the string in str. +
    Public methodStatic memberCode examplempf_set_ui
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempf_set_z
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempf_sgn
    + Return +1 if op > 0, 0 if op = 0, and -1 if op < 0. +
    Public methodStatic memberCode examplempf_size
    + Return the number of limbs currently in use. +
    Public methodStatic memberCode examplempf_sqrt
    + Set rop to the square root of op. +
    Public methodStatic memberCode examplempf_sqrt_ui
    + Set rop to the square root of op. +
    Public methodStatic memberCode examplempf_sub
    + Set rop to op1 - op2. +
    Public methodStatic memberCode examplempf_sub_ui
    + Set rop to op1 - op2. +
    Public methodStatic memberCode examplempf_swap
    + Swap rop1 and rop2 efficiently. +
    Public methodStatic memberCode examplempf_trunc
    + Set rop to op rounded to the integer towards zero. +
    Public methodStatic memberCode examplempf_ui_div
    + Set rop to op1 / op2. +
    Public methodStatic memberCode examplempf_ui_sub
    + Set rop to op1 - op2. +
    Public methodStatic memberCode examplempf_urandomb
    + Generate a uniformly distributed random float in rop, such that 0 ≤ rop < 1, with nbits significant bits in the mantissa or less if the precision of rop is smaller. +
    Public methodStatic memberCode examplempn_add
    + Add {s1p, s1n} and {s2p, s2n}, and write the s1n least significant limbs of the result to rp. +
    Public methodStatic memberCode examplempn_add_1
    + Add {s1p, n} and s2limb, and write the n least significant limbs of the result to rp. +
    Public methodStatic memberCode examplempn_add_n
    + Add {s1p, n} and {s2p, n}, and write the n least significant limbs of the result to rp. +
    Public methodStatic memberCode examplempn_addmul_1
    + Multiply {s1p, n} and s2limb, and add the n least significant limbs of the product to {rp, n} and write the result to rp. +
    Public methodStatic memberCode examplempn_and_n
    + Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_andn_n
    + Perform the bitwise logical and of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_cmp
    + Compare {s1p, n} and {s2p, n}. +
    Public methodStatic memberCode examplempn_cnd_add_n
    + If cnd is non-zero, it produces the same result as a regular mpn_add_n(mp_ptr, mp_ptr, mp_ptr, mp_size_t), and if cnd is zero, it copies {s1p, n} to the result area and returns zero. +
    Public methodStatic memberCode examplempn_cnd_sub_n
    + If cnd is non-zero, it produces the same result as a regular mpn_sub_n(mp_ptr, mp_ptr, mp_ptr, mp_size_t), and if cnd is zero, it copies {s1p, n} to the result area and returns zero. +
    Public methodStatic memberCode examplempn_cnd_swap
    + If cnd is non-zero, swaps the contents of the areas {ap, n} and {bp, n}. Otherwise, the areas are left unmodified. +
    Public methodStatic memberCode examplempn_com
    + Perform the bitwise complement of {sp, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_copyd
    + Copy from {s1p, n} to {rp, n}, decreasingly. +
    Public methodStatic memberCode examplempn_copyi
    + Copy from {s1p, n} to {rp, n}, increasingly. +
    Public methodStatic memberCode examplempn_divexact_1
    + Divide {sp, n} by d, expecting it to divide exactly, and writing the result to {rrp, n}. +
    Public methodStatic memberCode examplempn_divexact_by3
    + Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}. +
    Public methodStatic memberCode examplempn_divexact_by3c
    + Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}. +
    Public methodStatic memberCode examplempn_divmod_1
    + Divide {s2p, s2n} by s3limb, and write the quotient at r1p. +
    Public methodStatic memberCode examplempn_divrem_1
    + Divide {s2p, s2n} by s3limb, and write the quotient at r1p. +
    Public methodStatic memberCode examplempn_gcd
    + Set {rp, retval} to the greatest common divisor of {xp, xn} and {yp, yn}. +
    Public methodStatic memberCode examplempn_gcd_1
    + Return the greatest common divisor of {xp, xn} and ylimb. +
    Public methodStatic memberCode examplempn_gcdext
    + Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT. +
    Public methodStatic memberCode examplempn_get_str
    + Convert {s1p, s1n} to a raw unsigned char array at str in base base, and return the number of characters produced. +
    Public methodStatic memberCode examplempn_hamdist
    + Compute the hamming distance between {s1p, n} and {s2p, n}, which is the number of bit positions where the two operands have different bit values. +
    Public methodStatic memberCode examplempn_ior_n
    + Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_iorn_n
    + Perform the bitwise logical inclusive or of {s1p, n} and the bitwise complement of {s2p, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_lshift
    + Shift {sp, n} left by count bits, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_mod_1
    + Divide {s1p, s1n} by s2limb, and return the remainder. +
    Public methodStatic memberCode examplempn_mul
    + Multiply {s1p, s1n} and {s2p, s2n}, and write the (s1n + s2n)-limb result to rp. +
    Public methodStatic memberCode examplempn_mul_1
    + Multiply {s1p, n} by s2limb, and write the n least significant limbs of the product to rp. +
    Public methodStatic memberCode examplempn_mul_n
    + Multiply {s1p, n} and {s2p, n}, and write the (2 * n)-limb result to rp. +
    Public methodStatic memberCode examplempn_nand_n
    + Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}. +
    Public methodStatic memberCode examplempn_neg
    + Perform the negation of {sp, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_nior_n
    + Perform the bitwise logical inclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}. +
    Public methodStatic memberCode examplempn_perfect_power_p
    + Return non-zero iff {sp, n} is a perfect power. +
    Public methodStatic memberCode examplempn_perfect_square_p
    + Return non-zero iff {s1p, n} is a perfect square. +
    Public methodStatic memberCode examplempn_popcount
    + Count the number of set bits in {s1p, n}. +
    Public methodStatic memberCode examplempn_random
    + Generate a random number of length r1n and store it at r1p. +
    Public methodStatic memberCode examplempn_random2
    + Generate a random number of length r1n and store it at r1p. +
    Public methodStatic memberCode examplempn_rshift
    + Shift {sp, n} right by count bits, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_scan0
    + Scan s1p from bit position bit for the next clear bit. +
    Public methodStatic memberCode examplempn_scan1
    + Scan s1p from bit position bit for the next set bit. +
    Public methodStatic memberCode examplempn_sec_add_1
    + Set R to A + b, where R = {rp, n}, A = {ap, n}, and b is a single limb. +
    Public methodStatic membermpn_sec_add_1_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_add_1(mp_ptr, mp_ptr, mp_size_t, mp_limb_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_div_qr
    + Set Q to the truncated quotient N / D and R to N modulo D, where N = {np, nn}, D = {dp, dn}, Q’s most significant limb is the function return value and the remaining limbs are {qp, nn - dn}, and R = {np, dn}. +
    Public methodStatic membermpn_sec_div_qr_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_div_qr(mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_div_r
    + Set R to N modulo D, where N = {np, nn}, D = {dp, dn}, and R = {np, dn}. +
    Public methodStatic membermpn_sec_div_r_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_div_r(mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_invert
    + Set R to the inverse of A modulo M, where R = {rp, n}, A = {ap, n}, and M = {mp, n}. This function’s interface is preliminary. +
    Public methodStatic membermpn_sec_invert_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_invert(mp_ptr, mp_ptr, mp_ptr, mp_size_t, mp_bitcnt_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_mul
    + Set R to A * B, where A = {ap, an}, B = {bp, bn}, and R = {rp, an + bn}. +
    Public methodStatic membermpn_sec_mul_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_mul(mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_powm
    + Set R to (B^E) modulo M, where R = {rp, n}, M = {mp, n}, and E = {ep, ceil(enb / mp_bits_per_limb)}. +
    Public methodStatic membermpn_sec_powm_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_powm(mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_bitcnt_t, mp_ptr, mp_size_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_sqr
    + Set R to A^2, where A = {ap, an}, and R = {rp, 2 * an}. +
    Public methodStatic membermpn_sec_sqr_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_sqr(mp_ptr, mp_ptr, mp_size_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_sub_1
    + Set R to A - b, where R = {rp, n}, A = {ap, n}, and b is a single limb. +
    Public methodStatic membermpn_sec_sub_1_itch
    + Return the scratch space in number of limbs required by the function mpn_sec_sub_1(mp_ptr, mp_ptr, mp_size_t, mp_limb_t, mp_ptr). +
    Public methodStatic memberCode examplempn_sec_tabselect
    + Select entry which from table tab, which has nents entries, each n limbs. Store the selected entry at rp. +
    Public methodStatic memberCode examplempn_set_str
    + Convert bytes {str, strsize} in the given base to limbs at rp. +
    Public methodStatic memberCode examplempn_sizeinbase
    + Return the size of {xp, n} measured in number of digits in the given base. +
    Public methodStatic memberCode examplempn_sqr
    + Compute the square of {s1p, n} and write the (2 * n)-limb result to rp. +
    Public methodStatic memberCode examplempn_sqrtrem
    + Compute the square root of {sp, n} and put the result at {r1p, ceil(n / 2)} and the remainder at {r2p, retval}. +
    Public methodStatic memberCode examplempn_sub
    + Subtract {s2p, s2n} from {s1p, s1n}, and write the s1n least significant limbs of the result to rp. +
    Public methodStatic memberCode examplempn_sub_1
    + Subtract s2limb from {s1p, n}, and write the n least significant limbs of the result to rp. +
    Public methodStatic memberCode examplempn_sub_n
    + Subtract {s2p, n} from {s1p, n}, and write the n least significant limbs of the result to rp. +
    Public methodStatic memberCode examplempn_submul_1
    + Multiply {s1p, n} and s2limb, and subtract the n least significant limbs of the product from {rp, n} and write the result to rp. +
    Public methodStatic memberCode examplempn_tdiv_qr
    + Divide {np, nn} by {dp, dn} and put the quotient at {qp, nn - dn + 1} and the remainder at {rp, dn}. +
    Public methodStatic memberCode examplempn_xnor_n
    + Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the bitwise complement of the result to {rp, n}. +
    Public methodStatic memberCode examplempn_xor_n
    + Perform the bitwise logical exclusive or of {s1p, n} and {s2p, n}, and write the result to {rp, n}. +
    Public methodStatic memberCode examplempn_zero
    + Zero {rp, n}. +
    Public methodStatic memberCode examplempn_zero_p
    + Test {sp, n} and return 1 if the operand is zero, 0 otherwise. +
    Public methodStatic memberCode examplempq_abs
    + Set rop to the absolute value of op. +
    Public methodStatic memberCode examplempq_add
    + Set sum to addend1 + addend2. +
    Public methodStatic memberCode examplempq_canonicalize
    + Remove any factors that are common to the numerator and denominator of op, and make the denominator positive. +
    Public methodStatic memberCode examplempq_clear
    + Free the space occupied by x. +
    Public methodStatic memberCode examplempq_clears
    + Free the space occupied by a NULL-terminated list of mpq_t variables. +
    Public methodStatic memberCode examplempq_cmp
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempq_cmp_si
    + Compare op1 and num2 / den2. +
    Public methodStatic memberCode examplempq_cmp_ui
    + Compare op1 and num2 / den2. +
    Public methodStatic memberCode examplempq_cmp_z
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempq_denref
    + Return a reference to the denominator op. +
    Public methodStatic memberCode examplempq_div
    + Set quotient to dividend / divisor. +
    Public methodStatic memberCode examplempq_div_2exp
    + Set rop to op1 / 2^op2. +
    Public methodStatic memberCode examplempq_equal
    + Return non-zero if op1 and op2 are equal, zero if they are non-equal. +
    Public methodStatic memberCode examplempq_get_d
    + Convert op to a Double, truncating if necessary (i.e. rounding towards zero). +
    Public methodStatic memberCode examplempq_get_den
    + Set denominator to the denominator of rational. +
    Public methodStatic memberCode examplempq_get_num
    + Set numerator to the numerator of rational. +
    Public methodStatic memberCode examplempq_get_str
    + Convert op to a string of digits in base base. +
    Public methodStatic memberCode examplempq_init
    + Initialize x and set it to 0/1. +
    Public methodStatic memberCode examplempq_inits
    + Initialize a NULL-terminated list of mpq_t variables, and set their values to 0/1. +
    Public methodStatic memberCode examplempq_inp_str
    + Read a string of digits from stream and convert them to a rational in rop. +
    Public methodStatic memberCode examplempq_inv
    + Set inverted_number to 1 / number. +
    Public methodStatic memberCode examplempq_mul
    + Set product to multiplier * multiplicand. +
    Public methodStatic memberCode examplempq_mul_2exp
    + Set rop to op1 * 2*op2. +
    Public methodStatic memberCode examplempq_neg
    + Set negated_operand to -operand. +
    Public methodStatic memberCode examplempq_numref
    + Return a reference to the numerator op. +
    Public methodStatic memberCode examplempq_out_str
    + Output op on stdio stream stream, as a string of digits in base base. +
    Public methodStatic memberCode examplempq_set
    + Assign rop from op. +
    Public methodStatic memberCode examplempq_set_d
    + Set rop to the value of op. There is no rounding, this conversion is exact. +
    Public methodStatic memberCode examplempq_set_den
    + Set the denominator of rational to denominator. +
    Public methodStatic memberCode examplempq_set_f
    + Set rop to the value of op. There is no rounding, this conversion is exact. +
    Public methodStatic memberCode examplempq_set_num
    + Set the numerator of rational to numerator. +
    Public methodStatic memberCode examplempq_set_si
    + Set the value of rop to op1 / op2. +
    Public methodStatic memberCode examplempq_set_str
    + Set rop from a null-terminated string str in the given base. +
    Public methodStatic memberCode examplempq_set_ui
    + Set the value of rop to op1 / op2. +
    Public methodStatic memberCode examplempq_set_z
    + Assign rop from op. +
    Public methodStatic memberCode examplempq_sgn
    + Return +1 if op > 0, 0 if op = 0, and -1 if op < 0. +
    Public methodStatic memberCode examplempq_sub
    + Set difference to minuend - subtrahend. +
    Public methodStatic memberCode examplempq_swap
    + Swap the values rop1 and rop2 efficiently. +
    Public methodStatic memberCode examplempz_2fac_ui
    + Set rop to the double-factorial n!!. +
    Public methodStatic memberCode examplempz_abs
    + Set rop to the absolute value of op. +
    Public methodStatic memberCode examplempz_add
    + Set rop to op1 + op2. +
    Public methodStatic memberCode examplempz_add_ui
    + Set rop to op1 + op2. +
    Public methodStatic memberCode examplempz_addmul
    + Set rop to rop + op1 * op2. +
    Public methodStatic memberCode examplempz_addmul_ui
    + Set rop to rop + op1 * op2. +
    Public methodStatic memberCode examplempz_and
    + Set rop to op1 bitwise-and op2. +
    Public methodStatic memberCode examplempz_bin_ui
    + Compute the binomial coefficient n over k and store the result in rop. +
    Public methodStatic memberCode examplempz_bin_uiui
    + Compute the binomial coefficient n over k and store the result in rop. +
    Public methodStatic memberCode examplempz_cdiv_q
    + Set the quotient q to ceiling(n / d). +
    Public methodStatic memberCode examplempz_cdiv_q_2exp
    + Set the quotient q to ceiling(n / 2^b). +
    Public methodStatic memberCode examplempz_cdiv_q_ui
    + Set the quotient q to ceiling(n / d), and return the remainder r = |n - q * d|. +
    Public methodStatic memberCode examplempz_cdiv_qr
    + Set the quotient q to ceiling(n / d), and set the remainder r to n - q * d. +
    Public methodStatic memberCode examplempz_cdiv_qr_ui
    + Set quotient q to ceiling(n / d), set the remainder r to n - q * d, and return |r|. +
    Public methodStatic memberCode examplempz_cdiv_r
    + Set the remainder r to n - q * d where q = ceiling(n / d). +
    Public methodStatic memberCode examplempz_cdiv_r_2exp
    + Set the remainder r to n - q * 2^b where q = ceiling(n / 2^b). +
    Public methodStatic memberCode examplempz_cdiv_r_ui
    + Set the remainder r to n - q * d where q = ceiling(n / d), and return |r|. +
    Public methodStatic memberCode examplempz_cdiv_ui
    + Return the remainder |r| where r = n - q * d, and where q = ceiling(n / d). +
    Public methodStatic memberCode examplempz_clear
    + Free the space occupied by x. +
    Public methodStatic memberCode examplempz_clears
    + Free the space occupied by a NULL-terminated list of mpz_t variables. +
    Public methodStatic memberCode examplempz_clrbit
    + Clear bit bit_index in rop. +
    Public methodStatic memberCode examplempz_cmp
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempz_cmp_d
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempz_cmp_si
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempz_cmp_ui
    + Compare op1 and op2. +
    Public methodStatic memberCode examplempz_cmpabs
    + Compare the absolute values of op1 and op2. +
    Public methodStatic memberCode examplempz_cmpabs_d
    + Compare the absolute values of op1 and op2. +
    Public methodStatic memberCode examplempz_cmpabs_ui
    + Compare the absolute values of op1 and op2. +
    Public methodStatic memberCode examplempz_com
    + Set rop to the one’s complement of op. +
    Public methodStatic memberCode examplempz_combit
    + Complement bit bit_index in rop. +
    Public methodStatic memberCode examplempz_congruent_2exp_p
    + Return non-zero if n is congruent to c modulo 2^b. +
    Public methodStatic memberCode examplempz_congruent_p
    + Return non-zero if n is congruent to c modulo d. +
    Public methodStatic memberCode examplempz_congruent_ui_p
    + Return non-zero if n is congruent to c modulo d. +
    Public methodStatic memberCode examplempz_divexact
    + Set q to n / d when it is known in advance that d divides n. +
    Public methodStatic memberCode examplempz_divexact_ui
    + Set q to n / d when it is known in advance that d divides n. +
    Public methodStatic memberCode examplempz_divisible_2exp_p
    + Return non-zero if n is exactly divisible by 2^b. +
    Public methodStatic memberCode examplempz_divisible_p
    + Return non-zero if n is exactly divisible by d. +
    Public methodStatic memberCode examplempz_divisible_ui_p
    + Return non-zero if n is exactly divisible by d. +
    Public methodStatic memberCode examplempz_even_p
    + Determine whether op is even. +
    Public methodStatic memberCode examplempz_export
    + Fill rop with word data from op. +
    Public methodStatic memberCode examplempz_fac_ui
    + Set rop to the factorial n!. +
    Public methodStatic memberCode examplempz_fdiv_q
    + Set the quotient q to floor(n / d). +
    Public methodStatic memberCode examplempz_fdiv_q_2exp
    + Set the quotient q to floor(n / 2^b). +
    Public methodStatic memberCode examplempz_fdiv_q_ui
    + Set the quotient q to floor(n / d), and return the remainder r = |n - q * d|. +
    Public methodStatic memberCode examplempz_fdiv_qr
    + Set the quotient q to floor(n / d), and set the remainder r to n - q * d. +
    Public methodStatic memberCode examplempz_fdiv_qr_ui
    + Set quotient q to floor(n / d), set the remainder r to n - q * d, and return |r|. +
    Public methodStatic memberCode examplempz_fdiv_r
    + Set the remainder r to n - q * d where q = floor(n / d). +
    Public methodStatic memberCode examplempz_fdiv_r_2exp
    + Set the remainder r to n - q * 2^b where q = floor(n / 2^b). +
    Public methodStatic memberCode examplempz_fdiv_r_ui
    + Set the remainder r to n - q * d where q = floor(n / d), and return |r|. +
    Public methodStatic memberCode examplempz_fdiv_ui
    + Return the remainder |r| where r = n - q * d, and where q = floor(n / d). +
    Public methodStatic memberCode examplempz_fib_ui
    + Sets fn to to F[n], the n’th Fibonacci number. +
    Public methodStatic memberCode examplempz_fib2_ui
    + Sets fn to F[n], and fnsub1 to F[n - 1]. +
    Public methodStatic memberCode examplempz_fits_sint_p
    + Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero. +
    Public methodStatic memberCode examplempz_fits_slong_p
    + Return non-zero iff the value of op fits in a signed 32-bit integer. Otherwise, return zero. +
    Public methodStatic memberCode examplempz_fits_sshort_p
    + Return non-zero iff the value of op fits in a signed 16-bit integer. Otherwise, return zero. +
    Public methodStatic memberCode examplempz_fits_uint_p
    + Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero. +
    Public methodStatic memberCode examplempz_fits_ulong_p
    + Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero. +
    Public methodStatic memberCode examplempz_fits_ushort_p
    + Return non-zero iff the value of op fits in an unsigned 16-bit integer. Otherwise, return zero. +
    Public methodStatic memberCode examplempz_gcd
    + Set rop to the greatest common divisor of op1 and op2. +
    Public methodStatic memberCode examplempz_gcd_ui
    + Compute the greatest common divisor of op1 and op2. If rop is not null, store the result there. +
    Public methodStatic memberCode examplempz_gcdext
    + Set g to the greatest common divisor of a and b, and in addition set s and t to coefficients satisfying a * s + b * t = g. +
    Public methodStatic memberCode examplempz_get_d
    + Convert op to a double, truncating if necessary (i.e. rounding towards zero). +
    Public methodStatic memberCode examplempz_get_d_2exp
    + Convert op to a double, truncating if necessary (i.e. rounding towards zero), and returning the exponent separately. +
    Public methodStatic memberCode examplempz_get_si
    + Return the value of op as an signed long. +
    Public methodStatic memberCode examplempz_get_str
    + Convert op to a string of digits in base base. +
    Public methodStatic memberCode examplempz_get_ui
    + Return the value of op as an unsigned long. +
    Public methodStatic memberCode examplempz_getlimbn
    + Return limb number n from op. +
    Public methodStatic memberCode examplempz_hamdist
    + Return the hamming distance between the two operands. +
    Public methodStatic memberCode examplempz_import
    + Set rop from an array of word data at op. +
    Public methodStatic memberCode examplempz_init
    + Initialize x, and set its value to 0. +
    Public methodStatic memberCode examplempz_init_set
    + Initialize rop with limb space and set the initial numeric value from op. +
    Public methodStatic memberCode examplempz_init_set_d
    + Initialize rop with limb space and set the initial numeric value from op. +
    Public methodStatic memberCode examplempz_init_set_si
    + Initialize rop with limb space and set the initial numeric value from op. +
    Public methodStatic memberCode examplempz_init_set_str
    + Initialize rop and set its value like mpz_set_str(mpz_t, char_ptr, Int32). +
    Public methodStatic memberCode examplempz_init_set_ui
    + Initialize rop with limb space and set the initial numeric value from op. +
    Public methodStatic memberCode examplempz_init2
    + Initialize x, with space for n-bit numbers, and set its value to 0. +
    Public methodStatic memberCode examplempz_inits
    + Initialize a NULL-terminated list of mpz_t variables, and set their values to 0. +
    Public methodStatic memberCode examplempz_inp_raw
    Public methodStatic memberCode examplempz_inp_str
    + Input a possibly white-space preceded string in base base from stdio stream stream, and put the read integer in rop. +
    Public methodStatic memberCode examplempz_invert
    + Compute the inverse of op1 modulo op2 and put the result in rop. +
    Public methodStatic memberCode examplempz_ior
    + Set rop to op1 bitwise inclusive-or op2. +
    Public methodStatic memberCode examplempz_jacobi
    + Calculate the Jacobi symbol (a/b). +
    Public methodStatic memberCode examplempz_kronecker
    + Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even. +
    Public methodStatic memberCode examplempz_kronecker_si
    + Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even. +
    Public methodStatic memberCode examplempz_kronecker_ui
    + Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even. +
    Public methodStatic memberCode examplempz_lcm
    + Set rop to the least common multiple of op1 and op2. +
    Public methodStatic memberCode examplempz_lcm_ui
    + Set rop to the least common multiple of op1 and op2. +
    Public methodStatic memberCode examplempz_legendre
    + Calculate the Legendre symbol (a/p). +
    Public methodStatic membermpz_limbs_finish
    + Updates the internal size field of x. +
    Public methodStatic memberCode examplempz_limbs_modify
    + Return a pointer to the limb array of x, intended for write access. +
    Public methodStatic memberCode examplempz_limbs_read
    + Return a pointer to the limb array representing the absolute value of x. +
    Public methodStatic memberCode examplempz_limbs_write
    + Return a pointer to the limb array of x, intended for write access. +
    Public methodStatic memberCode examplempz_lucnum_ui
    + Sets ln to to L[n], the n’th Lucas number. +
    Public methodStatic memberCode examplempz_lucnum2_ui
    + Sets ln to L[n], and lnsub1 to L[n - 1]. +
    Public methodStatic memberCode examplempz_mfac_uiui
    + Set rop to the m-multi-factorial n!^(m)n. +
    Public methodStatic memberCode examplempz_millerrabin
    + An implementation of the probabilistic primality test found in Knuth's Seminumerical Algorithms book. +
    Public methodStatic memberCode examplempz_mod
    + Set r to n mod d. +
    Public methodStatic memberCode examplempz_mod_ui
    + Set r to n mod d. +
    Public methodStatic memberCode examplempz_mul
    + Set rop to op1 * op2. +
    Public methodStatic memberCode examplempz_mul_2exp
    + Set rop to op1 * 2^op2. +
    Public methodStatic memberCode examplempz_mul_si
    + Set rop to op1 * op2. +
    Public methodStatic memberCode examplempz_mul_ui
    + Set rop to op1 * op2. +
    Public methodStatic memberCode examplempz_neg
    + Set rop to -op. +
    Public methodStatic memberCode examplempz_nextprime
    + Set rop to the next prime greater than op. +
    Public methodStatic memberCode examplempz_odd_p
    + Determine whether op is odd. +
    Public methodStatic memberCode examplempz_out_raw
    + Output op on stdio stream stream, in raw binary format. +
    Public methodStatic memberCode examplempz_out_str
    + Output op on stdio stream stream, as a string of digits in base base. +
    Public methodStatic memberCode examplempz_perfect_power_p
    + Return non-zero if op is a perfect power, i.e., if there exist integers a and b, with b > 1, such that op = a^b. +
    Public methodStatic memberCode examplempz_perfect_square_p
    + Return non-zero if op is a perfect square, i.e., if the square root of op is an integer. +
    Public methodStatic memberCode examplempz_popcount
    + Return the population count of op. +
    Public methodStatic memberCode examplempz_pow_ui
    + Set rop to base^exp. The case 0^0 yields 1. +
    Public methodStatic memberCode examplempz_powm
    + Set rop to (base^exp) modulo mod. +
    Public methodStatic memberCode examplempz_powm_sec
    + Set rop to (base^exp) modulo mod. +
    Public methodStatic memberCode examplempz_powm_ui
    + Set rop to (base^exp) modulo mod. +
    Public methodStatic memberCode examplempz_primorial_ui
    + Set rop to the primorial of n, i.e. the product of all positive prime numbers n. +
    Public methodStatic memberCode examplempz_probab_prime_p
    + Determine whether n is prime. +
    Public methodStatic memberCode examplempz_random
    + Generate a random integer of at most max_size limbs. +
    Public methodStatic memberCode examplempz_random2
    + Generate a random integer of at most max_size limbs, with long strings of zeros and ones in the binary representation. +
    Public methodStatic memberCode examplempz_realloc2
    + Change the space allocated for x to n bits. +
    Public methodStatic memberCode examplempz_remove
    + Remove all occurrences of the factor f from op and store the result in rop. +
    Public methodStatic memberCode examplempz_roinit_n
    + Special initialization of x, using the given limb array and size. +
    Public methodStatic memberCode examplempz_root
    + Set rop to the truncated integer part of the nth root of op. +
    Public methodStatic memberCode examplempz_rootrem
    + Set root to the truncated integer part of the nth root of u. Set rem to the remainder, u - root^n. +
    Public methodStatic memberCode examplempz_rrandomb
    + Generate a random integer with long strings of zeros and ones in the binary representation. +
    Public methodStatic memberCode examplempz_scan0
    + Scan op for 0 bit. +
    Public methodStatic memberCode examplempz_scan1
    + Scan op for 1 bit. +
    Public methodStatic memberCode examplempz_set
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempz_set_d
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempz_set_f
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempz_set_q
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempz_set_si
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempz_set_str
    + Set the value of rop from str, a null-terminated C string in base base. +
    Public methodStatic memberCode examplempz_set_ui
    + Set the value of rop from op. +
    Public methodStatic memberCode examplempz_setbit
    + Set bit bit_index in rop. +
    Public methodStatic memberCode examplempz_sgn
    + Return +1 if op > 0, 0 if op = 0, and -1 if op < 0. +
    Public methodStatic memberCode examplempz_si_kronecker
    + Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even. +
    Public methodStatic memberCode examplempz_size
    + Return the size of op measured in number of limbs. +
    Public methodStatic memberCode examplempz_sizeinbase
    + Return the size of op measured in number of digits in the given base. +
    Public methodStatic memberCode examplempz_sqrt
    + Set rop to the truncated integer part of the square root of op. +
    Public methodStatic memberCode examplempz_sqrtrem
    + Set rop1 to the truncated integer part of the square root of op, like mpz_sqrt(mpz_t, mpz_t). Set rop2 to the remainder op - rop1 * rop1, which will be zero if op is a perfect square. +
    Public methodStatic memberCode examplempz_sub
    + Set rop to op1 - op2. +
    Public methodStatic memberCode examplempz_sub_ui
    + Set rop to op1 - op2. +
    Public methodStatic memberCode examplempz_submul
    + Set rop to rop - op1 * op2. +
    Public methodStatic memberCode examplempz_submul_ui
    + Set rop to rop - op1 * op2. +
    Public methodStatic memberCode examplempz_swap
    + Swap the values rop1 and rop2 efficiently. +
    Public methodStatic memberCode examplempz_tdiv_q
    + Set the quotient q to trunc(n / d). +
    Public methodStatic memberCode examplempz_tdiv_q_2exp
    + Set the quotient q to trunc(n / 2^b). +
    Public methodStatic memberCode examplempz_tdiv_q_ui
    + Set the quotient q to trunc(n / d), and return the remainder r = |n - q * d|. +
    Public methodStatic memberCode examplempz_tdiv_qr
    + Set the quotient q to trunc(n / d), and set the remainder r to n - q * d. +
    Public methodStatic memberCode examplempz_tdiv_qr_ui
    + Set quotient q to trunc(n / d), set the remainder r to n - q * d, and return |r|. +
    Public methodStatic memberCode examplempz_tdiv_r
    + Set the remainder r to n - q * d where q = trunc(n / d). +
    Public methodStatic memberCode examplempz_tdiv_r_2exp
    + Set the remainder r to n - q * 2^b where q = trunc(n / 2^b). +
    Public methodStatic memberCode examplempz_tdiv_r_ui
    + Set the remainder r to n - q * d where q = trunc(n / d), and return |r|. +
    Public methodStatic memberCode examplempz_tdiv_ui
    + Return the remainder |r| where r = n - q * d, and where q = trunc(n / d). +
    Public methodStatic memberCode examplempz_tstbit
    + Test bit bit_index in op and return 0 or 1 accordingly. +
    Public methodStatic memberCode examplempz_ui_kronecker
    + Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even. +
    Public methodStatic memberCode examplempz_ui_pow_ui
    + Set rop to base^exp. The case 0^0 yields 1. +
    Public methodStatic memberCode examplempz_ui_sub
    + Set rop to op1 - op2. +
    Public methodStatic memberCode examplempz_urandomb
    + Generate a uniformly distributed random integer in the range 0 to 2^n - 1, inclusive. +
    Public methodStatic memberCode examplempz_urandomm
    + Generate a uniform random integer in the range 0 to n - 1, inclusive. +
    Public methodStatic memberCode examplempz_xor
    + Set rop to op1 bitwise exclusive-or op2. +
    Public methodStatic memberreallocate
    + Resize a previously allocated block ptr of old_size bytes to be new_size bytes. +
    Public methodStatic memberZeroMemory
    + The ZeroMemory(IntPtr, Int32) routine fills a block of memory with zeros, given a pointer to the block and the length, in bytes, to be filled. +
    Top
    Fields
    +   + NameDescription
    Public fieldStatic memberCode examplegmp_version
    + The GMP version number in the form “i.j.k”. This release is "6.1.2". +
    Public fieldStatic memberCode examplemp_bits_per_limb
    + The number of bits per limb. +
    Public fieldStatic memberCode examplemp_bytes_per_limb
    + The number of bytes per limb. +
    Public fieldStatic memberCode examplemp_uint_per_limb
    + The number of 32-bit, unsigned integers per limb. +
    Top
    Remarks
    See Also
    \ No newline at end of file diff --git a/docs/html/3b01109c-5b01-16d2-edd0-5ac3d5514930.htm b/docs/html/3b01109c-5b01-16d2-edd0-5ac3d5514930.htm new file mode 100644 index 0000000..ea122e7 --- /dev/null +++ b/docs/html/3b01109c-5b01-16d2-edd0-5ac3d5514930.htm @@ -0,0 +1,22 @@ +gmp_lib.mpq_inv Method
    Click or drag to resize
    gmp_libmpq_inv Method
    + Set inverted_number to 1 / number. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpq_inv(
    +	mpq_t inverted_number,
    +	mpq_t number
    +)

    Parameters

    inverted_number
    Type: Math.Gmp.Nativempq_t
    The result rational.
    number
    Type: Math.Gmp.Nativempq_t
    The operand rational.
    Remarks

    + If the new denominator is zero, this routine will divide by zero. +

    Examples
    See Also
    \ No newline at end of file diff --git a/docs/html/3bab30e1-4da4-b2cd-ea9c-9f06097052e6.htm b/docs/html/3bab30e1-4da4-b2cd-ea9c-9f06097052e6.htm new file mode 100644 index 0000000..7064f0b --- /dev/null +++ b/docs/html/3bab30e1-4da4-b2cd-ea9c-9f06097052e6.htm @@ -0,0 +1,13 @@ +mp_size_t Implicit Conversion (SByte to mp_size_t)
    mp_size_t  Conversion (SByte to mp_size_t)
    + Converts a Byte value to an mp_size_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator mp_size_t (
    +	sbyte value
    +)

    Parameters

    value
    Type: SystemSByte
    A Byte value.

    Return Value

    Type: mp_size_t
    An mp_size_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/3bd9de08-5768-bb79-1e09-2953ae1483aa.htm b/docs/html/3bd9de08-5768-bb79-1e09-2953ae1483aa.htm new file mode 100644 index 0000000..e0e9118 --- /dev/null +++ b/docs/html/3bd9de08-5768-bb79-1e09-2953ae1483aa.htm @@ -0,0 +1,34 @@ +gmp_lib.mpn_popcount Method
    Click or drag to resize
    gmp_libmpn_popcount Method
    + Count the number of set bits in {s1p, n}. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_bitcnt_t mpn_popcount(
    +	mp_ptr s1p,
    +	mp_size_t n
    +)

    Parameters

    s1p
    Type: Math.Gmp.Nativemp_ptr
    The operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of s1p.

    Return Value

    Type: mp_bitcnt_t
    The number of set bits in {s1p, n}.
    Examples
    // Create multi-precision operand.
    +mp_ptr s1p = new mp_ptr(new uint[] { 0x0000001, 0x00000001 });
    +
    +// Assert result of operation.
    +Assert.IsTrue(gmp_lib.mpn_popcount(s1p, s1p.Size) == 2);
    +
    +// Release unmanaged memory.
    +gmp_lib.free(s1p);
    See Also
    \ No newline at end of file diff --git a/docs/html/3c3a57f3-ab98-976d-e470-2b8da8c97b53.htm b/docs/html/3c3a57f3-ab98-976d-e470-2b8da8c97b53.htm new file mode 100644 index 0000000..68a0c74 --- /dev/null +++ b/docs/html/3c3a57f3-ab98-976d-e470-2b8da8c97b53.htm @@ -0,0 +1,17 @@ +size_t.Equals Method (Object)
    size_tEquals Method (Object)
    + Returns a value indicating whether this instance is equal to a specified object. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override bool Equals(
    +	Object obj
    +)

    Parameters

    obj
    Type: SystemObject
    An object to compare with this instance.

    Return Value

    Type: Boolean
    True if obj is an instance of size_t and equals the value of this instance; otherwise, False.
    See Also
    \ No newline at end of file diff --git a/docs/html/3ca44c9f-677e-d5fa-5414-399843506633.htm b/docs/html/3ca44c9f-677e-d5fa-5414-399843506633.htm new file mode 100644 index 0000000..d453b93 --- /dev/null +++ b/docs/html/3ca44c9f-677e-d5fa-5414-399843506633.htm @@ -0,0 +1,5 @@ +mpf_t Type Conversions \ No newline at end of file diff --git a/docs/html/3cd34dae-2d2e-5efd-cc59-e555d879812a.htm b/docs/html/3cd34dae-2d2e-5efd-cc59-e555d879812a.htm new file mode 100644 index 0000000..4188140 --- /dev/null +++ b/docs/html/3cd34dae-2d2e-5efd-cc59-e555d879812a.htm @@ -0,0 +1,13 @@ +mp_limb_t Explicit Conversion (mp_limb_t to SByte)
    mp_limb_t  Conversion (mp_limb_t to SByte)
    + Converts a mp_limb_t value to an SByte value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator sbyte (
    +	mp_limb_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_limb_t
    An mp_limb_t value.

    Return Value

    Type: SByte
    An SByte value.
    See Also
    \ No newline at end of file diff --git a/docs/html/3ce0cc26-e888-90f8-a517-aad88332eec0.htm b/docs/html/3ce0cc26-e888-90f8-a517-aad88332eec0.htm new file mode 100644 index 0000000..6a11252 --- /dev/null +++ b/docs/html/3ce0cc26-e888-90f8-a517-aad88332eec0.htm @@ -0,0 +1,32 @@ +gmp_lib.mpz_fits_uint_p Method
    Click or drag to resize
    gmp_libmpz_fits_uint_p Method
    + Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_fits_uint_p(
    +	mpz_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempz_t
    The operand integer.

    Return Value

    Type: Int32
    Return non-zero iff the value of op fits in an unsigned 32-bit integer. Otherwise, return zero.
    Examples
    // Create, initialize, and set the value of op 4294967295.
    +mpz_t op = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op, uint.MaxValue);
    +
    +// Assert that op does not fit in uint.
    +Assert.IsTrue(gmp_lib.mpz_fits_uint_p(op) > 0);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpz_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/3d7c5927-d163-5d46-1f0b-5c35ca116b22.htm b/docs/html/3d7c5927-d163-5d46-1f0b-5c35ca116b22.htm new file mode 100644 index 0000000..db0e554 --- /dev/null +++ b/docs/html/3d7c5927-d163-5d46-1f0b-5c35ca116b22.htm @@ -0,0 +1,19 @@ +void_ptr.Equality Operator
    void_ptrEquality Operator
    + Gets a value that indicates whether the two argument values are equal. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static bool operator ==(
    +	void_ptr value1,
    +	void_ptr value2
    +)

    Parameters

    value1
    Type: Math.Gmp.Nativevoid_ptr
    A void_ptr value.
    value2
    Type: Math.Gmp.Nativevoid_ptr
    A void_ptr value.

    Return Value

    Type: Boolean
    True if the two values are equal, and False otherwise.
    See Also
    \ No newline at end of file diff --git a/docs/html/3ddee65c-a067-79a3-968d-31f3d585db3b.htm b/docs/html/3ddee65c-a067-79a3-968d-31f3d585db3b.htm new file mode 100644 index 0000000..0a5bc8c --- /dev/null +++ b/docs/html/3ddee65c-a067-79a3-968d-31f3d585db3b.htm @@ -0,0 +1,54 @@ +gmp_lib.mpz_divexact_ui Method
    Click or drag to resize
    gmp_libmpz_divexact_ui Method
    + Set q to n / d when it is known in advance that d divides n. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_divexact_ui(
    +	mpz_t q,
    +	mpz_t n,
    +	uint d
    +)

    Parameters

    q
    Type: Math.Gmp.Nativempz_t
    The result quotient integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: SystemUInt32
    The denominator integer.
    Examples
    // Create, initialize, and set the value of x to 10000.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_ui(x, 10000U);
    +
    +// Create, initialize, and set the value of z to 0.
    +mpz_t z = new mpz_t();
    +gmp_lib.mpz_init(z);
    +
    +// Set z = x / 5.
    +gmp_lib.mpz_divexact_ui(z, x, 5U);
    +
    +// Assert that z is 2000.
    +Assert.IsTrue(gmp_lib.mpz_get_si(z) == 2000);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpz_clears(x, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/3e06d348-8a15-691d-5889-ab3f1a4c9f73.htm b/docs/html/3e06d348-8a15-691d-5889-ab3f1a4c9f73.htm new file mode 100644 index 0000000..57f8d68 --- /dev/null +++ b/docs/html/3e06d348-8a15-691d-5889-ab3f1a4c9f73.htm @@ -0,0 +1,44 @@ +gmp_lib.mpz_cmpabs Method
    Click or drag to resize
    gmp_libmpz_cmpabs Method
    + Compare the absolute values of op1 and op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_cmpabs(
    +	mpz_t op1,
    +	mpz_t op2
    +)

    Parameters

    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: Math.Gmp.Nativempz_t
    The second operand integer.

    Return Value

    Type: Int32
    Return a positive value if |op1| > |op2|, zero if |op1| = |op2|, or a negative value if |op1| < |op2|.
    Examples
    // Create, initialize, and set the value of op1 to -63.
    +mpz_t op1 = new mpz_t();
    +gmp_lib.mpz_init_set_si(op1, -63);
    +
    +// Create, initialize, and set the value of op2 to 70.
    +mpz_t op2 = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op2, 70U);
    +
    +// Assert that |op1| < |op2|.
    +Assert.IsTrue(gmp_lib.mpz_cmp(op1, op2) < 0);
    +
    +// Release unmanaged memory allocated for op1 and op2.
    +gmp_lib.mpz_clears(op1, op2, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/3e1375c2-3f44-721d-6ef3-32e49a3d7d3b.htm b/docs/html/3e1375c2-3f44-721d-6ef3-32e49a3d7d3b.htm new file mode 100644 index 0000000..fb24e91 --- /dev/null +++ b/docs/html/3e1375c2-3f44-721d-6ef3-32e49a3d7d3b.htm @@ -0,0 +1,9 @@ +void_ptr.ToIntPtr Method
    void_ptrToIntPtr Method
    + Gets pointer to block of unmanaged memory. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public IntPtr ToIntPtr()

    Return Value

    Type: IntPtr
    Pointer to block of unmanaged memory.
    See Also
    \ No newline at end of file diff --git a/docs/html/3e36be2b-14ed-eb7b-0546-af6d49e983fa.htm b/docs/html/3e36be2b-14ed-eb7b-0546-af6d49e983fa.htm new file mode 100644 index 0000000..9d1bc0b --- /dev/null +++ b/docs/html/3e36be2b-14ed-eb7b-0546-af6d49e983fa.htm @@ -0,0 +1,49 @@ +gmp_lib.mpz_scan0 Method
    Click or drag to resize
    gmp_libmpz_scan0 Method
    + Scan op for 0 bit. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_bitcnt_t mpz_scan0(
    +	mpz_t op,
    +	mp_bitcnt_t starting_bit
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempz_t
    The operand integer.
    starting_bit
    Type: Math.Gmp.Nativemp_bitcnt_t
    The start bit index position.

    Return Value

    Type: mp_bitcnt_t
    Return the index of the found bit.
    Remarks

    + Scan op, starting from bit starting_bit, towards more significant bits, + until the first 0 bit is found. Return the index of the found bit. +

    + If the bit at starting_bit is already what’s sought, + then starting_bit is returned. +

    + If there’s no bit found, then the largest possible mp_bitcnt_t is returned. + This will happen in mpz_scan0(mpz_t, mp_bitcnt_t) past the end of a negative number, + or mpz_scan1(mpz_t, mp_bitcnt_t) past the end of a nonnegative number. +

    + The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + The least significant bit is number 0. +

    Examples
    // Create, initialize, and set the value of op to 70.
    +mpz_t op = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op, 70U);
    +
    +// Assert that the first 0 bit starting from bit 1 in op is bit 3.
    +Assert.IsTrue(gmp_lib.mpz_scan0(op, 1U) == 3U);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpz_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/3e385e89-d6d3-27df-ec51-6580f6bea08b.htm b/docs/html/3e385e89-d6d3-27df-ec51-6580f6bea08b.htm new file mode 100644 index 0000000..a3b71b2 --- /dev/null +++ b/docs/html/3e385e89-d6d3-27df-ec51-6580f6bea08b.htm @@ -0,0 +1,6 @@ +mp_base Constructor
    mp_base Constructor
    Initializes a new instance of the mp_base class

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public mp_base()
    See Also
    \ No newline at end of file diff --git a/docs/html/3e5268ed-796b-2880-93a3-8d17143f99b1.htm b/docs/html/3e5268ed-796b-2880-93a3-8d17143f99b1.htm new file mode 100644 index 0000000..bc5a524 --- /dev/null +++ b/docs/html/3e5268ed-796b-2880-93a3-8d17143f99b1.htm @@ -0,0 +1,65 @@ +gmp_lib.mpz_and Method
    Click or drag to resize
    gmp_libmpz_and Method
    + Set rop to op1 bitwise-and op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_and(
    +	mpz_t rop,
    +	mpz_t op1,
    +	mpz_t op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: Math.Gmp.Nativempz_t
    The second operand integer.
    Remarks

    + The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + The least significant bit is number 0. +

    Examples
    // Create, initialize, and set the value of op1 to 63.
    +mpz_t op1 = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op1, 63U);
    +
    +// Create, initialize, and set the value of op2 to 70.
    +mpz_t op2 = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op2, 70U);
    +
    +// Create, initialize, and set the value of rop to 0.
    +mpz_t rop = new mpz_t();
    +gmp_lib.mpz_init(rop);
    +
    +// Set rop to the bitwise and of op1 and op2.
    +gmp_lib.mpz_and(rop, op1, op2);
    +
    +// Assert that rop is 6.
    +Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6);
    +
    +// Release unmanaged memory allocated for rop, op1, and op2.
    +gmp_lib.mpz_clears(rop, op1, op2, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/3eae225a-8db3-3b14-d862-03718f3a5548.htm b/docs/html/3eae225a-8db3-3b14-d862-03718f3a5548.htm new file mode 100644 index 0000000..97d0f66 --- /dev/null +++ b/docs/html/3eae225a-8db3-3b14-d862-03718f3a5548.htm @@ -0,0 +1,44 @@ +gmp_lib.mpz_congruent_ui_p Method
    Click or drag to resize
    gmp_libmpz_congruent_ui_p Method
    + Return non-zero if n is congruent to c modulo d. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_congruent_ui_p(
    +	mpz_t n,
    +	uint c,
    +	uint d
    +)

    Parameters

    n
    Type: Math.Gmp.Nativempz_t
    An operand integer.
    c
    Type: SystemUInt32
    The remainder of the division by d.
    d
    Type: SystemUInt32
    The divisor operand integer.

    Return Value

    Type: Int32
    Non-zero if n is congruent to c modulo d.
    Remarks

    n is congruent to c mod d if there exists an integer q + satisfying n = c + q * d. + Unlike the other division functions, d = 0 is accepted and following the rule it can be seen + that n and c are considered congruent mod 0 only when exactly equal. +

    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_ui(n, 10000U);
    +
    +// Assert that n is congruent to 1 mod 3.
    +Assert.IsTrue(gmp_lib.mpz_congruent_ui_p(n, 1U, 3U) > 0);
    +
    +// Release unmanaged memory allocated for n.
    +gmp_lib.mpz_clear(n);
    See Also
    \ No newline at end of file diff --git a/docs/html/3f1b2832-ff9c-cc4a-3e85-e2ee16acc69b.htm b/docs/html/3f1b2832-ff9c-cc4a-3e85-e2ee16acc69b.htm new file mode 100644 index 0000000..0cb310c --- /dev/null +++ b/docs/html/3f1b2832-ff9c-cc4a-3e85-e2ee16acc69b.htm @@ -0,0 +1,10 @@ +gmp_lib.gmp_version Field
    gmp_libgmp_version Field
    + The GMP version number in the form “i.j.k”. This release is "6.1.2". +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static readonly string gmp_version

    Field Value

    Type: String
    Examples
    string version = gmp_lib.gmp_version;
    +Assert.AreEqual(version, "6.1.2");
    See Also
    \ No newline at end of file diff --git a/docs/html/3f29d5f4-13ae-cec8-ea75-6a76d00d10fc.htm b/docs/html/3f29d5f4-13ae-cec8-ea75-6a76d00d10fc.htm new file mode 100644 index 0000000..8822498 --- /dev/null +++ b/docs/html/3f29d5f4-13ae-cec8-ea75-6a76d00d10fc.htm @@ -0,0 +1,50 @@ +gmp_lib.mpq_cmp Method
    Click or drag to resize
    gmp_libmpq_cmp Method
    + Compare op1 and op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpq_cmp(
    +	mpq_t op1,
    +	mpq_t op2
    +)

    Parameters

    op1
    Type: Math.Gmp.Nativempq_t
    The first operand rational.
    op2
    Type: Math.Gmp.Nativempq_t
    The second operand rational.

    Return Value

    Type: Int32
    Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.
    Remarks

    + To determine if two rationals are equal, mpq_equal(mpq_t, mpq_t) is faster than mpq_cmp(mpq_t, mpq_t). +

    Examples
    // Create, initialize, and set the value of op1 to 1 / 2.
    +mpq_t op1 = new mpq_t();
    +gmp_lib.mpq_init(op1);
    +gmp_lib.mpq_set_si(op1, 1, 2U);
    +
    +// Create, initialize, and set the value of op2 to 1 / 3.
    +mpq_t op2 = new mpq_t();
    +gmp_lib.mpq_init(op2);
    +gmp_lib.mpq_set_si(op2, 1, 3U);
    +
    +// Assert that op1 > op2.
    +Assert.IsTrue(gmp_lib.mpq_cmp(op1, op2) > 0);
    +
    +// Release unmanaged memory allocated for op1 and op2.
    +gmp_lib.mpq_clears(op1, op2, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/3fad7a3a-76d1-7e19-0ab4-c93a4bf3655e.htm b/docs/html/3fad7a3a-76d1-7e19-0ab4-c93a4bf3655e.htm new file mode 100644 index 0000000..0f5b307 --- /dev/null +++ b/docs/html/3fad7a3a-76d1-7e19-0ab4-c93a4bf3655e.htm @@ -0,0 +1,12 @@ +mpq_t._mp_num Property
    mpq_t_mp_num Property
    + Get the numerator integer of the rational. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public mpz_t _mp_num { get; }

    Return Value

    Type: mpz_t
    The numerator integer of the rational.
    See Also
    \ No newline at end of file diff --git a/docs/html/3fce2dbc-bac6-d24f-d6d4-84454567b8f5.htm b/docs/html/3fce2dbc-bac6-d24f-d6d4-84454567b8f5.htm new file mode 100644 index 0000000..0de1f85 --- /dev/null +++ b/docs/html/3fce2dbc-bac6-d24f-d6d4-84454567b8f5.htm @@ -0,0 +1,8 @@ +void_ptr.Zero Field
    void_ptrZero Field
    + Gets a null void_ptr. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static readonly void_ptr Zero

    Field Value

    Type: void_ptr
    See Also
    \ No newline at end of file diff --git a/docs/html/402dc8d2-32bd-59ad-80f3-4bd2cc000b0d.htm b/docs/html/402dc8d2-32bd-59ad-80f3-4bd2cc000b0d.htm new file mode 100644 index 0000000..ac6bfdb --- /dev/null +++ b/docs/html/402dc8d2-32bd-59ad-80f3-4bd2cc000b0d.htm @@ -0,0 +1,46 @@ +gmp_lib.mpz_bin_uiui Method
    Click or drag to resize
    gmp_libmpz_bin_uiui Method
    + Compute the binomial coefficient n over k and store the result in rop. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_bin_uiui(
    +	mpz_t rop,
    +	uint n,
    +	uint k
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    n
    Type: SystemUInt32
    The first operand integer.
    k
    Type: SystemUInt32
    The second operand integer.
    Examples
    // Create, initialize, and set the value of rop to 0.
    +mpz_t rop = new mpz_t();
    +gmp_lib.mpz_init(rop);
    +
    +// Set rop to the binomial coefficient (4:2).
    +gmp_lib.mpz_bin_uiui(rop, 4U, 2U);
    +
    +// Assert that rop is 6.
    +Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6);
    +
    +// Release unmanaged memory allocated for rop.
    +gmp_lib.mpz_clear(rop);
    See Also
    \ No newline at end of file diff --git a/docs/html/4089ae7b-a5ca-3feb-37ce-f5f4e627dde7.htm b/docs/html/4089ae7b-a5ca-3feb-37ce-f5f4e627dde7.htm new file mode 100644 index 0000000..792ad2a --- /dev/null +++ b/docs/html/4089ae7b-a5ca-3feb-37ce-f5f4e627dde7.htm @@ -0,0 +1,13 @@ +size_t Implicit Conversion (size_t to UInt64)
    size_t  Conversion (size_t to UInt64)
    + Converts a size_t value to a UInt64 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator ulong (
    +	size_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativesize_t
    An size_t value.

    Return Value

    Type: UInt64
    A UInt64 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/4137f93d-8fb6-8ae8-3961-eeba189925e6.htm b/docs/html/4137f93d-8fb6-8ae8-3961-eeba189925e6.htm new file mode 100644 index 0000000..d94e15e --- /dev/null +++ b/docs/html/4137f93d-8fb6-8ae8-3961-eeba189925e6.htm @@ -0,0 +1,13 @@ +size_t Explicit Conversion (size_t to Int16)
    size_t  Conversion (size_t to Int16)
    + Converts a size_t value to an Int16 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator short (
    +	size_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativesize_t
    An size_t value.

    Return Value

    Type: Int16
    An Int16 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/42a15292-978c-35c6-bfa3-9d5acf725ca7.htm b/docs/html/42a15292-978c-35c6-bfa3-9d5acf725ca7.htm new file mode 100644 index 0000000..7565bb7 --- /dev/null +++ b/docs/html/42a15292-978c-35c6-bfa3-9d5acf725ca7.htm @@ -0,0 +1,9 @@ +char_ptr.ToIntPtr Method
    char_ptrToIntPtr Method
    + Gets pointer to string in unmanaged memory. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public IntPtr ToIntPtr()

    Return Value

    Type: IntPtr
    Pointer to string in unmanaged memory.
    See Also
    \ No newline at end of file diff --git a/docs/html/430d894e-57e0-6020-0ad7-40b74cbd969f.htm b/docs/html/430d894e-57e0-6020-0ad7-40b74cbd969f.htm new file mode 100644 index 0000000..e81b8bb --- /dev/null +++ b/docs/html/430d894e-57e0-6020-0ad7-40b74cbd969f.htm @@ -0,0 +1,7 @@ +mpz_t Methods
    mpz_t Methods

    The mpz_t type exposes the following members.

    Methods
    +   + NameDescription
    Public methodEquals
    Determines whether the specified Object is equal to the current Object.
    (Inherited from Object.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGetHashCode
    Serves as a hash function for a particular type.
    (Inherited from Object.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Public methodToIntPtr
    + Gets the unmanaged memory pointer of the multiple precision integer. +
    Public methodToString
    + Return the string representation of the integer. +
    (Overrides ObjectToString.)
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/433b0777-4514-5b20-7494-f0f2746fe8e5.htm b/docs/html/433b0777-4514-5b20-7494-f0f2746fe8e5.htm new file mode 100644 index 0000000..c3fd0d4 --- /dev/null +++ b/docs/html/433b0777-4514-5b20-7494-f0f2746fe8e5.htm @@ -0,0 +1,24 @@ +gmp_lib.mpq_div Method
    Click or drag to resize
    gmp_libmpq_div Method
    + Set quotient to dividend / divisor. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpq_div(
    +	mpq_t quotient,
    +	mpq_t dividend,
    +	mpq_t divisor
    +)

    Parameters

    quotient
    Type: Math.Gmp.Nativempq_t
    The result rational.
    dividend
    Type: Math.Gmp.Nativempq_t
    The first operand rational.
    divisor
    Type: Math.Gmp.Nativempq_t
    The second operand rational.
    Examples
    See Also
    \ No newline at end of file diff --git a/docs/html/43436692-e9c9-739f-aa96-be2b775dae62.htm b/docs/html/43436692-e9c9-739f-aa96-be2b775dae62.htm new file mode 100644 index 0000000..e683e13 --- /dev/null +++ b/docs/html/43436692-e9c9-739f-aa96-be2b775dae62.htm @@ -0,0 +1,13 @@ +mp_size_t Explicit Conversion (UInt64 to mp_size_t)
    mp_size_t  Conversion (UInt64 to mp_size_t)
    + Converts a UInt64 value to an mp_size_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator mp_size_t (
    +	ulong value
    +)

    Parameters

    value
    Type: SystemUInt64
    A UInt64 value.

    Return Value

    Type: mp_size_t
    An mp_size_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/438e6843-fc7b-4e6f-9ac0-d97a2773b032.htm b/docs/html/438e6843-fc7b-4e6f-9ac0-d97a2773b032.htm new file mode 100644 index 0000000..71be5e4 --- /dev/null +++ b/docs/html/438e6843-fc7b-4e6f-9ac0-d97a2773b032.htm @@ -0,0 +1,48 @@ +gmp_lib.mpf_set_prec Method
    Click or drag to resize
    gmp_libmpf_set_prec Method
    + Set the precision of rop to be at least prec bits. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_set_prec(
    +	mpf_t rop,
    +	mp_bitcnt_t prec
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    prec
    Type: Math.Gmp.Nativemp_bitcnt_t
    The minimum precision in bits.
    Remarks

    + The value in rop will be truncated to the new precision. +

    + This function requires a call to realloc, and so should not be used in a tight loop. +

    Examples
    // Create and initialize a new floating-point number x.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init(x);
    +
    +// Set its precision to 64 bits.
    +gmp_lib.mpf_set_prec(x, 64U);
    +
    +// Assert that the value of x is 0.0, and that its precision is 64 bits.
    +Assert.IsTrue(gmp_lib.mpf_get_d(x) == 0.0);
    +Assert.IsTrue(gmp_lib.mpf_get_prec(x) == 64U);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpf_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/43cb2c87-9fab-eb9d-2f7a-140d72af7b15.htm b/docs/html/43cb2c87-9fab-eb9d-2f7a-140d72af7b15.htm new file mode 100644 index 0000000..d6403f1 --- /dev/null +++ b/docs/html/43cb2c87-9fab-eb9d-2f7a-140d72af7b15.htm @@ -0,0 +1,43 @@ +gmp_lib.mpq_cmp_si Method
    Click or drag to resize
    gmp_libmpq_cmp_si Method
    + Compare op1 and num2 / den2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpq_cmp_si(
    +	mpq_t op1,
    +	int num2,
    +	uint den2
    +)

    Parameters

    op1
    Type: Math.Gmp.Nativempq_t
    The first operand rational.
    num2
    Type: SystemInt32
    The second operand numerator integer.
    den2
    Type: SystemUInt32
    The second operand denominator integer.

    Return Value

    Type: Int32
    Return a positive value if op1 > num2 / den2, zero if op1 = num2 / den2, and a negative value if op1 < num2 / den2.
    Remarks

    num2 and den2 are allowed to have common factors. +

    Examples
    // Create, initialize, and set the value of op1 to 1 / 2.
    +mpq_t op1 = new mpq_t();
    +gmp_lib.mpq_init(op1);
    +gmp_lib.mpq_set_si(op1, 1, 2U);
    +
    +// Assert that op1 < 5/6.
    +Assert.IsTrue(gmp_lib.mpq_cmp_si(op1, 5, 6U) < 0);
    +
    +// Release unmanaged memory allocated for op1.
    +gmp_lib.mpq_clear(op1);
    See Also
    \ No newline at end of file diff --git a/docs/html/44012ded-01f3-9156-80d0-0df7ee0b048c.htm b/docs/html/44012ded-01f3-9156-80d0-0df7ee0b048c.htm new file mode 100644 index 0000000..7b70396 --- /dev/null +++ b/docs/html/44012ded-01f3-9156-80d0-0df7ee0b048c.htm @@ -0,0 +1,13 @@ +size_t Explicit Conversion (size_t to SByte)
    size_t  Conversion (size_t to SByte)
    + Converts a size_t value to an SByte value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator sbyte (
    +	size_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativesize_t
    An size_t value.

    Return Value

    Type: SByte
    An SByte value.
    See Also
    \ No newline at end of file diff --git a/docs/html/44097b06-123a-4c00-b17f-ab0c70ad78bb.htm b/docs/html/44097b06-123a-4c00-b17f-ab0c70ad78bb.htm new file mode 100644 index 0000000..ce42704 --- /dev/null +++ b/docs/html/44097b06-123a-4c00-b17f-ab0c70ad78bb.htm @@ -0,0 +1,69 @@ +gmp_lib.mpz_inp_raw Method
    Click or drag to resize
    gmp_libmpz_inp_raw Method

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static size_t mpz_inp_raw(
    +	mpz_t rop,
    +	ptr<FILE> stream
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result operand.
    stream
    Type: Math.Gmp.NativeptrFILE
    Pointer to file stream.

    Return Value

    Type: size_t
    Return the number of bytes read, or if an error occurred, return 0.
    Remarks

    + This routine can read the output from mpz_out_raw(ptrFILE, mpz_t) also from GMP 1, + in spite of changes necessary for compatibility between 32-bit and 64-bit machines. +

    Examples
    // Create, initialize, and set the value of op to 123456.
    +mpz_t op = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op, 123456U);
    +
    +// Write op to a temporary file.
    +string pathname = System.IO.Path.GetTempFileName();
    +ptr<FILE> stream = new ptr<FILE>();
    +_wfopen_s(out stream.Value.Value, pathname, "w");
    +Assert.IsTrue(gmp_lib.mpz_out_raw(stream, op) == 7);
    +fclose(stream.Value.Value);
    +
    +// Read op from the temporary file, and assert that the number of bytes read is 6.
    +_wfopen_s(out stream.Value.Value, pathname, "r");
    +Assert.IsTrue(gmp_lib.mpz_inp_raw(op, stream) == 7);
    +fclose(stream.Value.Value);
    +
    +// Assert that op is 123456.
    +Assert.IsTrue(gmp_lib.mpz_get_ui(op) == 123456U);
    +
    +// Delete temporary file.
    +System.IO.File.Delete(pathname);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpz_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/448dfb4b-f4d7-8db7-3d44-31f3bd032771.htm b/docs/html/448dfb4b-f4d7-8db7-3d44-31f3bd032771.htm new file mode 100644 index 0000000..e90e15d --- /dev/null +++ b/docs/html/448dfb4b-f4d7-8db7-3d44-31f3bd032771.htm @@ -0,0 +1,8 @@ +ptr(T).Value Field
    ptrTValue Field
    + The value that is "pointed to". +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public T Value

    Field Value

    Type: T
    See Also
    \ No newline at end of file diff --git a/docs/html/44d8440b-0daa-0393-510e-a0ace6d299f7.htm b/docs/html/44d8440b-0daa-0393-510e-a0ace6d299f7.htm new file mode 100644 index 0000000..de774cf --- /dev/null +++ b/docs/html/44d8440b-0daa-0393-510e-a0ace6d299f7.htm @@ -0,0 +1,11 @@ +mpf_t Properties
    mpf_t Properties

    The mpf_t type exposes the following members.

    Properties
    +   + NameDescription
    Public property_mp_d
    + A pointer to an array of limbs which is the magnitude. +
    (Inherited from mp_base.)
    Public property_mp_exp
    + The exponent, in limbs, determining the location of the implied radix point. +
    Public property_mp_prec
    + The precision of the mantissa, in limbs. +
    Public property_mp_size
    + The number of limbs currently in use, or the negative of that when representing a negative value. +
    (Overrides mp_base_mp_size.)
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/44e6038b-2e97-b53d-0d46-ce1fff3522d0.htm b/docs/html/44e6038b-2e97-b53d-0d46-ce1fff3522d0.htm new file mode 100644 index 0000000..b784e73 --- /dev/null +++ b/docs/html/44e6038b-2e97-b53d-0d46-ce1fff3522d0.htm @@ -0,0 +1,48 @@ +gmp_lib.mpf_sqrt_ui Method
    Click or drag to resize
    gmp_libmpf_sqrt_ui Method
    + Set rop to the square root of op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_sqrt_ui(
    +	mpf_t rop,
    +	uint op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op
    Type: SystemUInt32
    The operand.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create and initialize a new floating-point number z.
    +mpf_t z = new mpf_t();
    +gmp_lib.mpf_init(z);
    +
    +// Set z = sqrt(100).
    +gmp_lib.mpf_sqrt_ui(z, 100U);
    +
    +// Assert that the value of z is 10.
    +Assert.IsTrue(gmp_lib.mpf_get_d(z) == 10.0);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpf_clear(z);
    See Also
    \ No newline at end of file diff --git a/docs/html/452a9316-f421-a65c-a9ba-254b201dc431.htm b/docs/html/452a9316-f421-a65c-a9ba-254b201dc431.htm new file mode 100644 index 0000000..ea24928 --- /dev/null +++ b/docs/html/452a9316-f421-a65c-a9ba-254b201dc431.htm @@ -0,0 +1,62 @@ +gmp_lib.mpz_fdiv_qr_ui Method
    Click or drag to resize
    gmp_libmpz_fdiv_qr_ui Method
    + Set quotient q to floor(n / d), set the remainder r to n - q * d, and return |r|. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static uint mpz_fdiv_qr_ui(
    +	mpz_t q,
    +	mpz_t r,
    +	mpz_t n,
    +	uint d
    +)

    Parameters

    q
    Type: Math.Gmp.Nativempz_t
    The result quotient integer.
    r
    Type: Math.Gmp.Nativempz_t
    The result remainder integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: SystemUInt32
    The denominator integer.

    Return Value

    Type: UInt32
    Return |r|.
    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10000);
    +
    +// Create, initialize, and set the values of q and r to 0.
    +mpz_t q = new mpz_t();
    +mpz_t r = new mpz_t();
    +gmp_lib.mpz_inits(q, r, null);
    +
    +// Set q = floor(n / 3), r = n - d * q, and return r.
    +Assert.IsTrue(gmp_lib.mpz_fdiv_qr_ui(q, r, n, 3U) == 1U);
    +
    +// Assert that q is 3333, and that r is 1.
    +Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);
    +Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);
    +
    +// Release unmanaged memory allocated for n, q, and r.
    +gmp_lib.mpz_clears(n, q, r, null);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/45a76d5c-c5bf-e7f8-906a-15d290e9a50d.htm b/docs/html/45a76d5c-c5bf-e7f8-906a-15d290e9a50d.htm new file mode 100644 index 0000000..d560ee3 --- /dev/null +++ b/docs/html/45a76d5c-c5bf-e7f8-906a-15d290e9a50d.htm @@ -0,0 +1,60 @@ +gmp_lib.mpf_add_ui Method
    Click or drag to resize
    gmp_libmpf_add_ui Method
    + Set rop to op1 + op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_add_ui(
    +	mpf_t rop,
    +	mpf_t op1,
    +	uint op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op1
    Type: Math.Gmp.Nativempf_t
    The first operand.
    op2
    Type: SystemUInt32
    The second operand.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 10.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, 10);
    +
    +// Create and initialize a new floating-point number z.
    +mpf_t z = new mpf_t();
    +gmp_lib.mpf_init(z);
    +
    +// Set z = x + 210.
    +gmp_lib.mpf_add_ui(z, x, 210U);
    +
    +// Assert that the value of z is 220.
    +Assert.IsTrue(gmp_lib.mpf_get_d(z) == 220.0);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpf_clears(x, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/4609ac5e-5cf9-cd20-2fa9-8040101c165c.htm b/docs/html/4609ac5e-5cf9-cd20-2fa9-8040101c165c.htm new file mode 100644 index 0000000..64a6e77 --- /dev/null +++ b/docs/html/4609ac5e-5cf9-cd20-2fa9-8040101c165c.htm @@ -0,0 +1,36 @@ +mp_ptr Class
    mp_ptr Class
    + Represents a pointer to an array of mp_limb_t values in unmanaged memory, +
    Inheritance Hierarchy
    SystemObject
      Math.Gmp.Nativemp_ptr

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public class mp_ptr : IEnumerable<mp_limb_t>, 
    +	IEnumerable

    The mp_ptr type exposes the following members.

    Constructors
    Properties
    +   + NameDescription
    Public propertyItem
    + Gets or sets the value of the limb at index. +
    Public propertySize
    + The number of limbs. +
    Top
    Methods
    +   + NameDescription
    Public methodEquals
    Determines whether the specified Object is equal to the current Object.
    (Inherited from Object.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGetEnumerator
    + Returns an enumerator that iterates through the array of limbs. +
    Public methodGetHashCode
    Serves as a hash function for a particular type.
    (Inherited from Object.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Public methodToString
    Returns a string that represents the current object.
    (Inherited from Object.)
    Top
    Remarks

    See Also
    \ No newline at end of file diff --git a/docs/html/46b18925-3e4b-f26c-ef9c-ade34e23f518.htm b/docs/html/46b18925-3e4b-f26c-ef9c-ade34e23f518.htm new file mode 100644 index 0000000..e843aab --- /dev/null +++ b/docs/html/46b18925-3e4b-f26c-ef9c-ade34e23f518.htm @@ -0,0 +1,19 @@ +size_t.Equality Operator
    size_tEquality Operator
    + Gets a value that indicates whether the two argument values are equal. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static bool operator ==(
    +	size_t value1,
    +	size_t value2
    +)

    Parameters

    value1
    Type: Math.Gmp.Nativesize_t
    A size_t value.
    value2
    Type: Math.Gmp.Nativesize_t
    A size_t value.

    Return Value

    Type: Boolean
    True if the two values are equal, and False otherwise.
    See Also
    \ No newline at end of file diff --git a/docs/html/47695d57-9a89-48db-97c3-2ed03965d913.htm b/docs/html/47695d57-9a89-48db-97c3-2ed03965d913.htm new file mode 100644 index 0000000..af696fd --- /dev/null +++ b/docs/html/47695d57-9a89-48db-97c3-2ed03965d913.htm @@ -0,0 +1,10 @@ +gmp_lib.mp_bytes_per_limb Field
    gmp_libmp_bytes_per_limb Field
    + The number of bytes per limb. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static readonly mp_size_t mp_bytes_per_limb

    Field Value

    Type: mp_size_t
    Examples
    mp_size_t bytesPerLimb = gmp_lib.mp_bytes_per_limb;
    +Assert.AreEqual(bytesPerLimb, (mp_size_t)IntPtr.Size);
    See Also
    \ No newline at end of file diff --git a/docs/html/47fd5e17-2217-5e2f-8d68-440cfcf85179.htm b/docs/html/47fd5e17-2217-5e2f-8d68-440cfcf85179.htm new file mode 100644 index 0000000..cee7853 --- /dev/null +++ b/docs/html/47fd5e17-2217-5e2f-8d68-440cfcf85179.htm @@ -0,0 +1,13 @@ +size_t Explicit Conversion (size_t to Int32)
    size_t  Conversion (size_t to Int32)
    + Converts a size_t value to an Int32 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator int (
    +	size_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativesize_t
    An size_t value.

    Return Value

    Type: Int32
    An Int32 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/480d1d15-b561-ac8f-b12a-f27ba075b3f2.htm b/docs/html/480d1d15-b561-ac8f-b12a-f27ba075b3f2.htm new file mode 100644 index 0000000..003851e --- /dev/null +++ b/docs/html/480d1d15-b561-ac8f-b12a-f27ba075b3f2.htm @@ -0,0 +1,49 @@ +gmp_lib.mpz_scan1 Method
    Click or drag to resize
    gmp_libmpz_scan1 Method
    + Scan op for 1 bit. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_bitcnt_t mpz_scan1(
    +	mpz_t op,
    +	mp_bitcnt_t starting_bit
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempz_t
    The operand integer.
    starting_bit
    Type: Math.Gmp.Nativemp_bitcnt_t
    The start bit index position.

    Return Value

    Type: mp_bitcnt_t
    Return the index of the found bit.
    Remarks

    + Scan op, starting from bit starting_bit, towards more significant bits, + until the first 1 bit is found. Return the index of the found bit. +

    + If the bit at starting_bit is already what’s sought, + then starting_bit is returned. +

    + If there’s no bit found, then the largest possible mp_bitcnt_t is returned. + This will happen in mpz_scan0(mpz_t, mp_bitcnt_t) past the end of a negative number, + or mpz_scan1(mpz_t, mp_bitcnt_t) past the end of a nonnegative number. +

    + The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + The least significant bit is number 0. +

    Examples
    // Create, initialize, and set the value of op to 70.
    +mpz_t op = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op, 70U);
    +
    +// Assert that the first 1 bit starting from bit 3 in op is bit 6.
    +Assert.IsTrue(gmp_lib.mpz_scan1(op, 3U) == 6U);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpz_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/494fa261-4044-f216-7041-a55d95a26f5b.htm b/docs/html/494fa261-4044-f216-7041-a55d95a26f5b.htm new file mode 100644 index 0000000..3c0a9fe --- /dev/null +++ b/docs/html/494fa261-4044-f216-7041-a55d95a26f5b.htm @@ -0,0 +1,42 @@ +gmp_lib.gmp_randinit_set Method
    Click or drag to resize
    gmp_libgmp_randinit_set Method
    + Initialize rop with a copy of the algorithm and state from op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void gmp_randinit_set(
    +	gmp_randstate_t rop,
    +	gmp_randstate_t op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativegmp_randstate_t
    The state to initialize.
    op
    Type: Math.Gmp.Nativegmp_randstate_t
    The source state.
    Examples
    // Create new random number generator state, and initialize state with the Mersenne Twister algorithm.
    +gmp_randstate_t op = new gmp_randstate_t();
    +gmp_lib.gmp_randinit_mt(op);
    +
    +// Create new random number generator state, and initialize it with the state op.
    +gmp_randstate_t rop = new gmp_randstate_t();
    +gmp_lib.gmp_randinit_set(rop, op);
    +
    +// Free all memory occupied by op and rop.
    +gmp_lib.gmp_randclear(op);
    +gmp_lib.gmp_randclear(rop);
    See Also
    \ No newline at end of file diff --git a/docs/html/4a543b73-f62d-cf04-fa49-22bc93e657e7.htm b/docs/html/4a543b73-f62d-cf04-fa49-22bc93e657e7.htm new file mode 100644 index 0000000..23075c7 --- /dev/null +++ b/docs/html/4a543b73-f62d-cf04-fa49-22bc93e657e7.htm @@ -0,0 +1,19 @@ +mp_exp_t.Equality Operator
    mp_exp_tEquality Operator
    + Gets a value that indicates whether the two argument values are equal. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static bool operator ==(
    +	mp_exp_t value1,
    +	mp_exp_t value2
    +)

    Parameters

    value1
    Type: Math.Gmp.Nativemp_exp_t
    A mp_exp_t value.
    value2
    Type: Math.Gmp.Nativemp_exp_t
    A mp_exp_t value.

    Return Value

    Type: Boolean
    True if the two values are equal, and False otherwise.
    See Also
    \ No newline at end of file diff --git a/docs/html/4a5eee32-b03c-e613-22b1-6b4f54a95362.htm b/docs/html/4a5eee32-b03c-e613-22b1-6b4f54a95362.htm new file mode 100644 index 0000000..a46e1a2 --- /dev/null +++ b/docs/html/4a5eee32-b03c-e613-22b1-6b4f54a95362.htm @@ -0,0 +1,15 @@ +size_t Constructor
    size_t Constructor
    + Creates a new size_t, and sets its value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public size_t(
    +	ulong value
    +)

    Parameters

    value
    Type: SystemUInt64
    The value of the new size_t.
    See Also
    \ No newline at end of file diff --git a/docs/html/4a959468-7670-9303-a5e7-3f1de8f17a62.htm b/docs/html/4a959468-7670-9303-a5e7-3f1de8f17a62.htm new file mode 100644 index 0000000..c2aa864 --- /dev/null +++ b/docs/html/4a959468-7670-9303-a5e7-3f1de8f17a62.htm @@ -0,0 +1,44 @@ +gmp_lib.mpz_combit Method
    Click or drag to resize
    gmp_libmpz_combit Method
    + Complement bit bit_index in rop. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_combit(
    +	mpz_t rop,
    +	mp_bitcnt_t bit_index
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    bit_index
    Type: Math.Gmp.Nativemp_bitcnt_t
    The index of the bit to comlpement.
    Remarks

    + The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + The least significant bit is number 0. +

    Examples
    // Create, initialize, and set the value of rop to 70.
    +mpz_t rop = new mpz_t();
    +gmp_lib.mpz_init_set_si(rop, 70);
    +
    +// Complement bit 3 of rop.
    +gmp_lib.mpz_combit(rop, 3U);
    +
    +// Assert that rop is 78.
    +Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 78);
    +
    +// Release unmanaged memory allocated for rop.
    +gmp_lib.mpz_clear(rop);
    See Also
    \ No newline at end of file diff --git a/docs/html/4b08344c-f506-a717-4e1d-112cd19f5286.htm b/docs/html/4b08344c-f506-a717-4e1d-112cd19f5286.htm new file mode 100644 index 0000000..3357958 --- /dev/null +++ b/docs/html/4b08344c-f506-a717-4e1d-112cd19f5286.htm @@ -0,0 +1,52 @@ +gmp_lib.mpz_limbs_read Method
    Click or drag to resize
    gmp_libmpz_limbs_read Method
    + Return a pointer to the limb array representing the absolute value of x. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_ptr mpz_limbs_read(
    +	mpz_t x
    +)

    Parameters

    x
    Type: Math.Gmp.Nativempz_t
    The integer.

    Return Value

    Type: mp_ptr
    A pointer to the limb array representing the absolute value of x.
    Remarks

    + The size of the array is mpz_size(mpz_t)(x). Intended for read access only. +

    Examples
    // Create and initialize new integer x.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init(x);
    +
    +// Set the value of x.
    +char_ptr value = new char_ptr("10000 00000000000000000000000000000000");
    +gmp_lib.mpz_set_str(x, value, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4);
    +
    +// Get pointer to the limbs of x.
    +mp_ptr limbs = gmp_lib.mpz_limbs_read(x);
    +
    +// Assert the values of the limbs based on current architecture (x86 or x64).
    +Assert.IsTrue(limbs[0] == 0);
    +Assert.IsTrue(limbs[1] == (gmp_lib.mp_bytes_per_limb == 4 ? 16U : 256U));
    +
    +// Release unmanaged memory allocated for x and value.
    +gmp_lib.mpz_clear(x);
    +gmp_lib.free(value);
    See Also
    \ No newline at end of file diff --git a/docs/html/4b58a584-7a0e-b600-18fa-ebd493861eb3.htm b/docs/html/4b58a584-7a0e-b600-18fa-ebd493861eb3.htm new file mode 100644 index 0000000..f59acb7 --- /dev/null +++ b/docs/html/4b58a584-7a0e-b600-18fa-ebd493861eb3.htm @@ -0,0 +1,66 @@ +mp_size_t Structure
    mp_size_t Structure
    + Represents a count of limbs. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public struct mp_size_t

    The mp_size_t type exposes the following members.

    Constructors
    +   + NameDescription
    Public methodmp_size_t
    + Creates a new mp_size_t, and sets its value. +
    Top
    Methods
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(mp_size_t)
    + Returns a value indicating whether this instance is equal to a specified mp_size_t value. +
    Public methodGetHashCode
    + Returns the hash code for this instance. +
    (Overrides ValueTypeGetHashCode.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Public methodToString
    + Gets the string representation of the mp_size_t. +
    (Overrides ValueTypeToString.)
    Top
    Operators
    +   + NameDescription
    Public operatorStatic memberEquality
    + Gets a value that indicates whether the two argument values are equal. +
    Public operatorStatic member(Int64 to mp_size_t)
    + Converts an Int64 value to a mp_size_t value. +
    Public operatorStatic member(UInt32 to mp_size_t)
    + Converts a UInt32 value to an mp_size_t value. +
    Public operatorStatic member(UInt64 to mp_size_t)
    + Converts a UInt64 value to an mp_size_t value. +
    Public operatorStatic member(mp_size_t to Byte)
    + Converts an mp_size_t value to a Byte value. +
    Public operatorStatic member(mp_size_t to SByte)
    + Converts an mp_size_t value to an SByte value. +
    Public operatorStatic member(mp_size_t to UInt16)
    + Converts an mp_size_t value to a UInt16 value. +
    Public operatorStatic member(mp_size_t to Int16)
    + Converts an mp_size_t value to an Int16 value. +
    Public operatorStatic member(mp_size_t to UInt32)
    + Converts an mp_size_t value to a UInt32 value. +
    Public operatorStatic member(mp_size_t to UInt64)
    + Converts an mp_size_t value to a UInt64 value. +
    Public operatorStatic member(Byte to mp_size_t)
    + Converts a Byte value to an mp_size_t value. +
    Public operatorStatic member(Int16 to mp_size_t)
    + Converts an Int16 value to an mp_size_t value. +
    Public operatorStatic member(Int32 to mp_size_t)
    + Converts an Int32 value to an mp_size_t value. +
    Public operatorStatic member(SByte to mp_size_t)
    + Converts a Byte value to an mp_size_t value. +
    Public operatorStatic member(UInt16 to mp_size_t)
    + Converts a UInt16 value to an mp_size_t value. +
    Public operatorStatic member(mp_size_t to Int32)
    + Converts an mp_size_t value to an Int32 value. +
    Public operatorStatic member(mp_size_t to Int64)
    + Converts an mp_size_t value to an Int64 value. +
    Public operatorStatic memberInequality
    + Gets a value that indicates whether the two argument values are different. +
    Top
    Remarks

    + Counts of limbs of a multi-precision number represented in the C type mp_size_t. + Currently this is normally a long, but on some systems it’s an int for efficiency, + and on some systems it will be long long in the future. +

    + In .Net, this is a 32-bit integer. +

    See Also
    \ No newline at end of file diff --git a/docs/html/4b6a07f8-2a61-d1a3-7192-f2907292bf2a.htm b/docs/html/4b6a07f8-2a61-d1a3-7192-f2907292bf2a.htm new file mode 100644 index 0000000..64acefc --- /dev/null +++ b/docs/html/4b6a07f8-2a61-d1a3-7192-f2907292bf2a.htm @@ -0,0 +1,50 @@ +gmp_lib.mpz_congruent_2exp_p Method
    Click or drag to resize
    gmp_libmpz_congruent_2exp_p Method
    + Return non-zero if n is congruent to c modulo 2^b. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_congruent_2exp_p(
    +	mpz_t n,
    +	mpz_t c,
    +	mp_bitcnt_t b
    +)

    Parameters

    n
    Type: Math.Gmp.Nativempz_t
    An operand integer.
    c
    Type: Math.Gmp.Nativempz_t
    The remainder of the division by 2^b.
    b
    Type: Math.Gmp.Nativemp_bitcnt_t
    The exponent of the power of two divisor.

    Return Value

    Type: Int32
    Non-zero if n is congruent to c modulo 2^b.
    Remarks

    n is congruent to c mod 2^b if there exists an integer q + satisfying n = c + q * 2^b. +

    Examples
    // Create, initialize, and set the value of n to 10001.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_ui(n, 10001U);
    +
    +// Create, initialize, and set the value of b to 1.
    +mpz_t c = new mpz_t();
    +gmp_lib.mpz_init_set_ui(c, 1U);
    +
    +// Assert that n is congruent to c mod 2^3.
    +Assert.IsTrue(gmp_lib.mpz_congruent_2exp_p(n, c, 3U) > 0);
    +
    +// Release unmanaged memory allocated for n and c.
    +gmp_lib.mpz_clears(n, c, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/4bafc7fe-d2a8-7cf2-b9b8-c296550b4ef2.htm b/docs/html/4bafc7fe-d2a8-7cf2-b9b8-c296550b4ef2.htm new file mode 100644 index 0000000..cef440a --- /dev/null +++ b/docs/html/4bafc7fe-d2a8-7cf2-b9b8-c296550b4ef2.htm @@ -0,0 +1,48 @@ +gmp_lib.mpz_divisible_p Method
    Click or drag to resize
    gmp_libmpz_divisible_p Method
    + Return non-zero if n is exactly divisible by d. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_divisible_p(
    +	mpz_t n,
    +	mpz_t d
    +)

    Parameters

    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: Math.Gmp.Nativempz_t
    The denominator integer.

    Return Value

    Type: Int32
    Non-zero if n is exactly divisible by d.
    Remarks

    n is divisible by d if there exists an integer q + satisfying n = q * d. Unlike the other division functions, + d = 0 is accepted and following the rule it can be seen that only 0 is + considered divisible by 0. +

    Examples
    // Create, initialize, and set the value of x to 10000.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_ui(x, 10000U);
    +
    +// Create, initialize, and set the value of y to 5.
    +mpz_t y = new mpz_t();
    +gmp_lib.mpz_init_set_ui(y, 5U);
    +
    +// Assert that x is divisible by y.
    +Assert.IsTrue(gmp_lib.mpz_divisible_p(x, y) > 0);
    +
    +// Release unmanaged memory allocated for x and y.
    +gmp_lib.mpz_clears(x, y, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/4be917d3-47c6-cb58-d768-6276e78f0afb.htm b/docs/html/4be917d3-47c6-cb58-d768-6276e78f0afb.htm new file mode 100644 index 0000000..df6613e --- /dev/null +++ b/docs/html/4be917d3-47c6-cb58-d768-6276e78f0afb.htm @@ -0,0 +1,64 @@ +gmp_lib.mpz_rrandomb Method
    Click or drag to resize
    gmp_libmpz_rrandomb Method
    + Generate a random integer with long strings of zeros and ones in the binary representation. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_rrandomb(
    +	mpz_t rop,
    +	gmp_randstate_t state,
    +	mp_bitcnt_t n
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    state
    Type: Math.Gmp.Nativegmp_randstate_t
    The random number generator state.
    n
    Type: Math.Gmp.Nativemp_bitcnt_t
    The operand integer.
    Remarks

    + Useful for testing functions and algorithms, since this kind of random numbers have proven to be more + likely to trigger corner-case bugs. The random number will be in the + range 2^(n - 1) to 2^n - 1, inclusive. +

    + The variable state must be initialized by calling one of the gmp_randinit + functions (GNU MP - Random State Initialization) before invoking this function. +

    + The random number functions of GMP come in two groups; older function that rely on a global state, + and newer functions that accept a state parameter that is read and modified. + Please see the GNU MP - Random Number Functions + for more information on how to use and not to use random number functions. +

    Examples
    // Create, initialize, and seed a new random number generator.
    +gmp_randstate_t state = new gmp_randstate_t();
    +gmp_lib.gmp_randinit_mt(state);
    +gmp_lib.gmp_randseed_ui(state, 100000U);
    +
    +// Create, initialize, and set the value of rop to 0.
    +mpz_t rop = new mpz_t();
    +gmp_lib.mpz_init(rop);
    +
    +// Generate a random integer in the range [2^(50-1), (2^50)-1].
    +gmp_lib.mpz_rrandomb(rop, state, 50);
    +
    +// Free all memory occupied by state and rop.
    +gmp_lib.gmp_randclear(state);
    +gmp_lib.mpz_clear(rop);
    See Also
    \ No newline at end of file diff --git a/docs/html/4c3f1727-1891-2918-da3a-321930e883ed.htm b/docs/html/4c3f1727-1891-2918-da3a-321930e883ed.htm new file mode 100644 index 0000000..f930747 --- /dev/null +++ b/docs/html/4c3f1727-1891-2918-da3a-321930e883ed.htm @@ -0,0 +1,14 @@ +gmp_lib.gmp_errno Property
    gmp_libgmp_errno Property
    + Gets or sets the global GMP error number. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int gmp_errno { get; set; }

    Property Value

    Type: Int32
    See Also
    \ No newline at end of file diff --git a/docs/html/4c81a27a-206c-e5da-44e9-0ac7767b3366.htm b/docs/html/4c81a27a-206c-e5da-44e9-0ac7767b3366.htm new file mode 100644 index 0000000..afe7b7c --- /dev/null +++ b/docs/html/4c81a27a-206c-e5da-44e9-0ac7767b3366.htm @@ -0,0 +1,36 @@ +gmp_lib.mpf_size Method
    Click or drag to resize
    gmp_libmpf_size Method
    + Return the number of limbs currently in use. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static size_t mpf_size(
    +	mpf_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempf_t
    The operand float.

    Return Value

    Type: size_t
    The number of limbs currently in use.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x.
    +mpf_t x = "1.00000000000000000000001";
    +
    +// Assert that the size of x is 1.
    +Assert.IsTrue(gmp_lib.mpf_size(x) == 4);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpf_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/4c830876-cdf6-9d94-1ceb-24d30f873bc2.htm b/docs/html/4c830876-cdf6-9d94-1ceb-24d30f873bc2.htm new file mode 100644 index 0000000..3f459c7 --- /dev/null +++ b/docs/html/4c830876-cdf6-9d94-1ceb-24d30f873bc2.htm @@ -0,0 +1,62 @@ +gmp_lib.mpz_tdiv_q Method
    Click or drag to resize
    gmp_libmpz_tdiv_q Method
    + Set the quotient q to trunc(n / d). +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_tdiv_q(
    +	mpz_t q,
    +	mpz_t n,
    +	mpz_t d
    +)

    Parameters

    q
    Type: Math.Gmp.Nativempz_t
    The result quotient integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: Math.Gmp.Nativempz_t
    The denominator integer.
    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10000);
    +
    +// Create, initialize, and set the value of d to 3.
    +mpz_t d = new mpz_t();
    +gmp_lib.mpz_init_set_si(d, 3);
    +
    +// Create, initialize, and set the value of q to 0.
    +mpz_t q = new mpz_t();
    +gmp_lib.mpz_init(q);
    +
    +// Set q = trunc(n / d).
    +gmp_lib.mpz_tdiv_q(q, n, d);
    +
    +// Assert that q is trunc(10000 / 3).
    +Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);
    +
    +// Release unmanaged memory allocated for n, d, and q.
    +gmp_lib.mpz_clears(n, d, q, null);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/4c8c8860-0cde-fd90-76f1-81cd6fb7a125.htm b/docs/html/4c8c8860-0cde-fd90-76f1-81cd6fb7a125.htm new file mode 100644 index 0000000..fb84afc --- /dev/null +++ b/docs/html/4c8c8860-0cde-fd90-76f1-81cd6fb7a125.htm @@ -0,0 +1,5 @@ +gmp_lib Properties
    gmp_lib Properties

    The gmp_lib type exposes the following members.

    Properties
    +   + NameDescription
    Public propertyStatic membergmp_errno
    + Gets or sets the global GMP error number. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/4d1fd187-6b51-f72c-b150-3cc4eb7ead18.htm b/docs/html/4d1fd187-6b51-f72c-b150-3cc4eb7ead18.htm new file mode 100644 index 0000000..095bcf9 --- /dev/null +++ b/docs/html/4d1fd187-6b51-f72c-b150-3cc4eb7ead18.htm @@ -0,0 +1,13 @@ +mp_size_t Implicit Conversion (Int32 to mp_size_t)
    mp_size_t  Conversion (Int32 to mp_size_t)
    + Converts an Int32 value to an mp_size_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator mp_size_t (
    +	int value
    +)

    Parameters

    value
    Type: SystemInt32
    An Int32 value.

    Return Value

    Type: mp_size_t
    An mp_size_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/4dfb8bd5-8a6f-6919-7aa9-8c060d42b5d7.htm b/docs/html/4dfb8bd5-8a6f-6919-7aa9-8c060d42b5d7.htm new file mode 100644 index 0000000..c301867 --- /dev/null +++ b/docs/html/4dfb8bd5-8a6f-6919-7aa9-8c060d42b5d7.htm @@ -0,0 +1,53 @@ +gmp_lib.mpz_hamdist Method
    Click or drag to resize
    gmp_libmpz_hamdist Method
    + Return the hamming distance between the two operands. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_bitcnt_t mpz_hamdist(
    +	mpz_t op1,
    +	mpz_t op2
    +)

    Parameters

    op1
    Type: Math.Gmp.Nativempz_t
    The first operanf integer.
    op2
    Type: Math.Gmp.Nativempz_t
    The second operanf integer.

    Return Value

    Type: mp_bitcnt_t
    The hamming distance between the two operands.
    Remarks

    + If op1 and op2 are both ≥ 0 or both < 0, + return the hamming distance between the two operands, which is the number of bit positions where + op1 and op2 have different bit values. If one operand is + ≥ 0 and the other < 0 then the number of bits different is infinite, and the + return value is the largest possible mp_bitcnt_t. +

    + The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + The least significant bit is number 0. +

    Examples
    // Create, initialize, and set the value of op1 to 63.
    +mpz_t op1 = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op1, 63U);
    +
    +// Create, initialize, and set the value of op2 to 70.
    +mpz_t op2 = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op2, 70U);
    +
    +// Assert that the Hamming distance between op1 and op2 is 5.
    +Assert.IsTrue(gmp_lib.mpz_hamdist(op1, op2) == 5U);
    +
    +// Release unmanaged memory allocated for op1 and op2.
    +gmp_lib.mpz_clears(op1, op2, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/4e0b1b66-de5f-3451-d835-df0116b8c789.htm b/docs/html/4e0b1b66-de5f-3451-d835-df0116b8c789.htm new file mode 100644 index 0000000..4429fd5 --- /dev/null +++ b/docs/html/4e0b1b66-de5f-3451-d835-df0116b8c789.htm @@ -0,0 +1,7 @@ +FILE.Equals Method
    FILEEquals Method
    Overload List
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(FILE)
    + Returns a value indicating whether this instance is equal to a specified FILE value. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/4e14cfc4-6f8b-14f7-74df-2f4415ce6f1c.htm b/docs/html/4e14cfc4-6f8b-14f7-74df-2f4415ce6f1c.htm new file mode 100644 index 0000000..3d7484a --- /dev/null +++ b/docs/html/4e14cfc4-6f8b-14f7-74df-2f4415ce6f1c.htm @@ -0,0 +1,65 @@ +gmp_lib.mpz_gcd Method
    Click or drag to resize
    gmp_libmpz_gcd Method
    + Set rop to the greatest common divisor of op1 and op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_gcd(
    +	mpz_t rop,
    +	mpz_t op1,
    +	mpz_t op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result operand integer.
    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: Math.Gmp.Nativempz_t
    The second operand integer.
    Remarks

    + The result is always positive even if one or both input operands are negative. + Except if both inputs are zero; then this function defines gcd(0,0) = 0. +

    Examples
    // Create, initialize, and set the value of op1 to 63.
    +mpz_t op1 = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op1, 63U);
    +
    +// Create, initialize, and set the value of op2 to 70.
    +mpz_t op2 = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op2, 70U);
    +
    +// Create, initialize, and set the value of rop to 0.
    +mpz_t rop = new mpz_t();
    +gmp_lib.mpz_init(rop);
    +
    +// Set rop to the greatest common divisor of op1 and op2.
    +gmp_lib.mpz_gcd(rop, op1, op2);
    +
    +// Assert that rop is 7.
    +Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 7);
    +
    +// Release unmanaged memory allocated for rop, op1, and op2.
    +gmp_lib.mpz_clears(rop, op1, op2, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/4e30a5e0-637b-949e-a627-387a56945f7b.htm b/docs/html/4e30a5e0-637b-949e-a627-387a56945f7b.htm new file mode 100644 index 0000000..571b406 --- /dev/null +++ b/docs/html/4e30a5e0-637b-949e-a627-387a56945f7b.htm @@ -0,0 +1,56 @@ +gmp_lib.mpf_init_set_str Method
    Click or drag to resize
    gmp_libmpf_init_set_str Method
    + Initialize rop and set its value from the string in str. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpf_init_set_str(
    +	mpf_t rop,
    +	char_ptr str,
    +	int base
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    str
    Type: Math.Gmp.Nativechar_ptr
    The operand string.
    base
    Type: SystemInt32
    The base.

    Return Value

    Type: Int32
    This function returns 0 if the entire string is a valid number in base base. Otherwise it returns -1.
    Remarks

    + See mpf_set_str(mpf_t, char_ptr, Int32) for details on the assignment operation. +

    + Note that rop is initialized even if an error occurs. (I.e., you have to call mpf_clear(mpf_t) for it.) +

    + The precision of rop will be taken from the active default precision, as set by mpf_set_default_prec(mp_bitcnt_t). +

    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 0.0234.
    +char_ptr value = new char_ptr("234e-4");
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_str(x, value, 10);
    +
    +// Assert that x is 40.
    +Assert.IsTrue(x.ToString() == "0.234e-1");
    +
    +// Release unmanaged memory allocated for x and y.
    +gmp_lib.mpf_clear(x);
    +gmp_lib.free(value);
    See Also
    \ No newline at end of file diff --git a/docs/html/4e7a1224-4cf6-269a-82b6-8fdb83429949.htm b/docs/html/4e7a1224-4cf6-269a-82b6-8fdb83429949.htm new file mode 100644 index 0000000..b19a6ac --- /dev/null +++ b/docs/html/4e7a1224-4cf6-269a-82b6-8fdb83429949.htm @@ -0,0 +1,13 @@ +mp_limb_t Implicit Conversion (UInt16 to mp_limb_t)
    mp_limb_t  Conversion (UInt16 to mp_limb_t)
    + Converts a UInt16 value to an mp_limb_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator mp_limb_t (
    +	ushort value
    +)

    Parameters

    value
    Type: SystemUInt16
    A UInt16 value.

    Return Value

    Type: mp_limb_t
    An mp_limb_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/4e876639-72f5-7659-f4a9-862639e27e1c.htm b/docs/html/4e876639-72f5-7659-f4a9-862639e27e1c.htm new file mode 100644 index 0000000..cf746ac --- /dev/null +++ b/docs/html/4e876639-72f5-7659-f4a9-862639e27e1c.htm @@ -0,0 +1,73 @@ +gmp_lib.mpf_div Method
    Click or drag to resize
    gmp_libmpf_div Method
    + Set rop to op1 / op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_div(
    +	mpf_t rop,
    +	mpf_t op1,
    +	mpf_t op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op1
    Type: Math.Gmp.Nativempf_t
    The first operand.
    op2
    Type: Math.Gmp.Nativempf_t
    The second operand.
    Remarks

    + Division is undefined if the divisor is zero, and passing a zero divisor to the divide + functions will make it intentionally divide by zero. + This lets the user handle arithmetic exceptions in division functions in the same manner + as other arithmetic exceptions. +

    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 10.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, 10);
    +
    +// Create, initialize, and set a new floating-point number y to -210.
    +mpf_t y = new mpf_t();
    +gmp_lib.mpf_init_set_si(y, -210);
    +
    +// Create and initialize a new floating-point number z.
    +mpf_t z = new mpf_t();
    +gmp_lib.mpf_init(z);
    +
    +// Set z = y / x.
    +gmp_lib.mpf_div(z, y, x);
    +
    +// Assert that the value of z is -21.
    +Assert.IsTrue(gmp_lib.mpf_get_d(z) == -21.0);
    +
    +// Release unmanaged memory allocated for x, y, and z.
    +gmp_lib.mpf_clears(x, y, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/4e93c4c4-d799-2828-5285-8a3f3ed02ad3.htm b/docs/html/4e93c4c4-d799-2828-5285-8a3f3ed02ad3.htm new file mode 100644 index 0000000..6eddf43 --- /dev/null +++ b/docs/html/4e93c4c4-d799-2828-5285-8a3f3ed02ad3.htm @@ -0,0 +1,54 @@ +gmp_lib.mpz_addmul_ui Method
    Click or drag to resize
    gmp_libmpz_addmul_ui Method
    + Set rop to rop + op1 * op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_addmul_ui(
    +	mpz_t rop,
    +	mpz_t op1,
    +	uint op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: SystemUInt32
    The second operand integer.
    Examples
    // Create, initialize, and set the value of x to -10000.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_si(x, -10000);
    +
    +// Create, initialize, and set the value of z to 20000.
    +mpz_t z = new mpz_t();
    +gmp_lib.mpz_init_set_si(z, 20000);
    +
    +// Set z += x * 12222.
    +gmp_lib.mpz_addmul_ui(z, x, 12222U);
    +
    +// Assert that z has been incremented by -10000 * 12222.
    +Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000 + -10000 * 12222);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpz_clears(x, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/4f0f115a-3956-13f7-4d6f-0157936c03bd.htm b/docs/html/4f0f115a-3956-13f7-4d6f-0157936c03bd.htm new file mode 100644 index 0000000..e669dc8 --- /dev/null +++ b/docs/html/4f0f115a-3956-13f7-4d6f-0157936c03bd.htm @@ -0,0 +1,43 @@ +gmp_lib.mpf_cmp_d Method
    Click or drag to resize
    gmp_libmpf_cmp_d Method
    + Compare op1 and op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpf_cmp_d(
    +	mpf_t op1,
    +	double op2
    +)

    Parameters

    op1
    Type: Math.Gmp.Nativempf_t
    The first operand float.
    op2
    Type: SystemDouble
    The second operand float.

    Return Value

    Type: Int32
    Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.
    Remarks

    mpf_cmp_d(mpf_t, Double) can be called with an infinity, but results are undefined for a NaN. +

    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 512.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, 512);
    +
    +// Assert that x > 128.0.
    +Assert.IsTrue(gmp_lib.mpf_cmp_d(x, 128.0) > 0);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpf_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/4f821e78-facb-4ea2-ab21-62d1f5049e68.htm b/docs/html/4f821e78-facb-4ea2-ab21-62d1f5049e68.htm new file mode 100644 index 0000000..cbe3739 --- /dev/null +++ b/docs/html/4f821e78-facb-4ea2-ab21-62d1f5049e68.htm @@ -0,0 +1,36 @@ +gmp_lib.mpz_divisible_2exp_p Method
    Click or drag to resize
    gmp_libmpz_divisible_2exp_p Method
    + Return non-zero if n is exactly divisible by 2^b. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_divisible_2exp_p(
    +	mpz_t n,
    +	mp_bitcnt_t b
    +)

    Parameters

    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    b
    Type: Math.Gmp.Nativemp_bitcnt_t
    The exponent of the power of two denominator integer.

    Return Value

    Type: Int32
    Non-zero if n is exactly divisible by 2^b.
    Remarks

    n is divisible by 2^b if there exists an integer q + satisfying n = q * 2^b. +

    Examples
    // Create, initialize, and set the value of x to 10000.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_ui(x, 10000U);
    +
    +Assert.IsTrue(gmp_lib.mpz_divisible_2exp_p(x, 2U) > 0);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpz_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/4f98333c-76a2-db46-cbba-97785a449450.htm b/docs/html/4f98333c-76a2-db46-cbba-97785a449450.htm new file mode 100644 index 0000000..0d50d02 --- /dev/null +++ b/docs/html/4f98333c-76a2-db46-cbba-97785a449450.htm @@ -0,0 +1,61 @@ +gmp_lib.mpq_get_num Method
    Click or drag to resize
    gmp_libmpq_get_num Method
    + Set numerator to the numerator of rational. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpq_get_num(
    +	mpz_t numerator,
    +	mpq_t rational
    +)

    Parameters

    numerator
    Type: Math.Gmp.Nativempz_t
    The result integer.
    rational
    Type: Math.Gmp.Nativempq_t
    The operand rational.
    Remarks

    + The function is equivalent to calling mpz_set(mpz_t, mpz_t) with mpq_numref(mpq_t). + Direct use of mpq_numref(mpq_t) is recommended instead of this functions. +

    Examples
    // Create, initialize, and set the value of op to -1 / 3.
    +mpq_t op = new mpq_t();
    +gmp_lib.mpq_init(op);
    +gmp_lib.mpq_set_si(op, -1, 3U);
    +
    +// Create and initialize a new integer.
    +mpz_t num = new mpz_t();
    +gmp_lib.mpz_init(num);
    +
    +// Set integer to numerator of rational, and increment integer by 2.
    +gmp_lib.mpq_get_num(num, op);
    +gmp_lib.mpz_add_ui(num, num, 2U);
    +
    +// Assert that num is 1, and op is -1 / 3.
    +Assert.IsTrue(gmp_lib.mpz_cmp_si(num, 1) == 0);
    +Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 3U) == 0);
    +
    +// Release unmanaged memory allocated for op and num.
    +gmp_lib.mpq_clear(op);
    +gmp_lib.mpz_clear(num);
    See Also
    \ No newline at end of file diff --git a/docs/html/4fcc5434-e328-6730-f46e-bd0823ec7560.htm b/docs/html/4fcc5434-e328-6730-f46e-bd0823ec7560.htm new file mode 100644 index 0000000..cede825 --- /dev/null +++ b/docs/html/4fcc5434-e328-6730-f46e-bd0823ec7560.htm @@ -0,0 +1,40 @@ +gmp_lib.mpn_cmp Method
    Click or drag to resize
    gmp_libmpn_cmp Method
    + Compare {s1p, n} and {s2p, n}. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpn_cmp(
    +	mp_ptr s1p,
    +	mp_ptr s2p,
    +	mp_size_t n
    +)

    Parameters

    s1p
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    s2p
    Type: Math.Gmp.Nativemp_ptr
    The second operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs in s1p and s2p.

    Return Value

    Type: Int32
    Return a positive value if s1 > s2, 0 if they are equal, or a negative value if s1 < s2.
    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
    +mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x00000000 });
    +
    +// Assert s1p > s2p.
    +Assert.IsTrue(gmp_lib.mpn_cmp(s1p, s2p, s1p.Size) > 0);
    +
    +// Release unmanaged memory.
    +gmp_lib.free(s1p, s2p);
    See Also
    \ No newline at end of file diff --git a/docs/html/4fe7aa66-0d05-7853-360a-72c4b55b69bd.htm b/docs/html/4fe7aa66-0d05-7853-360a-72c4b55b69bd.htm new file mode 100644 index 0000000..f982bb6 --- /dev/null +++ b/docs/html/4fe7aa66-0d05-7853-360a-72c4b55b69bd.htm @@ -0,0 +1,7 @@ +FILE Operators
    FILE Operators

    The FILE type exposes the following members.

    Operators
    +   + NameDescription
    Public operatorStatic memberEquality
    + Gets a value that indicates whether the two argument values are equal. +
    Public operatorStatic memberInequality
    + Gets a value that indicates whether the two argument values are different. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/50306850-d92d-5038-bbcc-c452cd3c69a9.htm b/docs/html/50306850-d92d-5038-bbcc-c452cd3c69a9.htm new file mode 100644 index 0000000..6d1d4d9 --- /dev/null +++ b/docs/html/50306850-d92d-5038-bbcc-c452cd3c69a9.htm @@ -0,0 +1,80 @@ +gmp_lib.gmp_fscanf Method
    Click or drag to resize
    gmp_libgmp_fscanf Method
    + Read from the stream fp. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int gmp_fscanf(
    +	ptr<FILE> fp,
    +	string fmt,
    +	params Object[] ap
    +)

    Parameters

    fp
    Type: Math.Gmp.NativeptrFILE
    File stream.
    fmt
    Type: SystemString
    Format string. See Formatted Input Strings.
    ap
    Type: SystemObject
    Arguments.

    Return Value

    Type: Int32
    The return value the number of fields successfully parsed and stored. ‘%n’ fields and fields read but suppressed by ‘*’ don’t count towards the return value.
    Examples
    // Create unique filename and stream pointer.
    +string pathname = System.IO.Path.GetTempFileName();
    +ptr<FILE> stream = new ptr<FILE>();
    +
    +mpz_t z = "0";
    +mpq_t q = "0";
    +mpf_t f = "0";
    +ptr<Char> c = new ptr<Char>('0');
    +ptr<mp_size_t> zt = new ptr<mp_size_t>(0);
    +ptr<Double> dbl = new ptr<Double>(0);
    +
    +// Write string to file, and then read values from it.
    +System.IO.File.WriteAllText(pathname, "123456 7B/1C8 1.234500e+10 A 10 1.000000");
    +_wfopen_s(out stream.Value.Value, pathname, "r");
    +Assert.IsTrue(gmp_lib.gmp_fscanf(stream, "%Zd %QX %Fe %hhc %d %lf", z, q, f, c, zt, dbl) == 6);
    +fclose(stream.Value.Value);
    +
    +// Assert values read.
    +Assert.IsTrue(z.ToString() == "123456");
    +Assert.IsTrue(q.ToString() == "123/456");
    +Assert.IsTrue(f.ToString() == "0.12345e11");
    +Assert.IsTrue(c.Value == 'A');
    +Assert.IsTrue(zt.Value == 10);
    +Assert.IsTrue(dbl.Value == 1.0);
    +
    +// Release unmanaged memory.
    +gmp_lib.mpz_clear(z);
    +gmp_lib.mpq_clear(q);
    +gmp_lib.mpf_clear(f);
    See Also
    \ No newline at end of file diff --git a/docs/html/50e025ca-c11a-c1db-2233-d11f66776439.htm b/docs/html/50e025ca-c11a-c1db-2233-d11f66776439.htm new file mode 100644 index 0000000..c136884 --- /dev/null +++ b/docs/html/50e025ca-c11a-c1db-2233-d11f66776439.htm @@ -0,0 +1,5 @@ +ptr(T) Fields
    ptrT Fields

    The ptrT generic type exposes the following members.

    Fields
    +   + NameDescription
    Public fieldValue
    + The value that is "pointed to". +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/5236d7a8-b79f-add8-4898-997e9d6a68bf.htm b/docs/html/5236d7a8-b79f-add8-4898-997e9d6a68bf.htm new file mode 100644 index 0000000..950b84f --- /dev/null +++ b/docs/html/5236d7a8-b79f-add8-4898-997e9d6a68bf.htm @@ -0,0 +1,53 @@ +gmp_lib.mpf_cmp_z Method
    Click or drag to resize
    gmp_libmpf_cmp_z Method
    + Compare op1 and op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpf_cmp_z(
    +	mpf_t op1,
    +	mpz_t op2
    +)

    Parameters

    op1
    Type: Math.Gmp.Nativempf_t
    The first operand float.
    op2
    Type: Math.Gmp.Nativempz_t
    The second operand float.

    Return Value

    Type: Int32
    Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 512.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, 512);
    +
    +// Create and initialize a new floating-point number z.
    +mpz_t z = new mpz_t();
    +gmp_lib.mpz_init_set_si(z, 128);
    +
    +// Assert that x > z.
    +Assert.IsTrue(gmp_lib.mpf_cmp_z(x, z) > 0);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpf_clear(x);
    +gmp_lib.mpz_clear(z);
    +///
    See Also
    \ No newline at end of file diff --git a/docs/html/52388f4c-575a-9b13-41a6-e7ec2bd0becd.htm b/docs/html/52388f4c-575a-9b13-41a6-e7ec2bd0becd.htm new file mode 100644 index 0000000..3aa99ac --- /dev/null +++ b/docs/html/52388f4c-575a-9b13-41a6-e7ec2bd0becd.htm @@ -0,0 +1,57 @@ +gmp_lib.mpq_set_den Method
    Click or drag to resize
    gmp_libmpq_set_den Method
    + Set the denominator of rational to denominator. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpq_set_den(
    +	mpq_t rational,
    +	mpz_t denominator
    +)

    Parameters

    rational
    Type: Math.Gmp.Nativempq_t
    The result rational.
    denominator
    Type: Math.Gmp.Nativempz_t
    The operand integer.
    Remarks
    + The function is equivalent to calling mpz_set(mpz_t, mpz_t) with mpq_denref(mpq_t). + Direct use of mpq_denref(mpq_t) is recommended instead of this functions. +
    Examples
    // Create, initialize, and set the value of op to -1 / 3.
    +mpq_t op = new mpq_t();
    +gmp_lib.mpq_init(op);
    +gmp_lib.mpq_set_si(op, -1, 3U);
    +
    +// Create, initialize, and set the value of a new integer to 5.
    +mpz_t den = new mpz_t();
    +gmp_lib.mpz_init_set_ui(den, 5U);
    +
    +// Set the denominator of op.
    +gmp_lib.mpq_set_den(op, den);
    +
    +// Assert that op is -1 / 5.
    +Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5U) == 0);
    +
    +// Release unmanaged memory allocated for op and num.
    +gmp_lib.mpq_clear(op);
    +gmp_lib.mpz_clear(den);
    See Also
    \ No newline at end of file diff --git a/docs/html/52ce0428-7c09-f2b9-f517-d3d02521f365.htm b/docs/html/52ce0428-7c09-f2b9-f517-d3d02521f365.htm new file mode 100644 index 0000000..0fa5458 --- /dev/null +++ b/docs/html/52ce0428-7c09-f2b9-f517-d3d02521f365.htm @@ -0,0 +1,41 @@ +gmp_lib.mpz_probab_prime_p Method
    Click or drag to resize
    gmp_libmpz_probab_prime_p Method
    + Determine whether n is prime. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_probab_prime_p(
    +	mpz_t n,
    +	int reps
    +)

    Parameters

    n
    Type: Math.Gmp.Nativempz_t
    The operand integer.
    reps
    Type: SystemInt32
    The number of Miller-Rabin probabilistic primality tests to perform.

    Return Value

    Type: Int32
    Return 2 if n is definitely prime, return 1 if n is probably prime (without being certain), or return 0 if n is definitely non-prime.
    Remarks

    + This function performs some trial divisions, then reps Miller-Rabin probabilistic primality tests. + A higher reps value will reduce the chances of a non-prime being identified as “probably prime”. + A composite number will be identified as a prime with a probability of less than 4^(-reps). + Reasonable values of reps are between 15 and 50. +

    Examples
    // Create, initialize, and set the value of n to 12.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_ui(n, 12U);
    +
    +// Assert that n is a composite number.
    +Assert.IsTrue(gmp_lib.mpz_probab_prime_p(n, 25) == 0);
    +
    +// Release unmanaged memory allocated for n.
    +gmp_lib.mpz_clear(n);
    See Also
    \ No newline at end of file diff --git a/docs/html/53702772-53e9-ec51-c3a5-7a1912b4f2b4.htm b/docs/html/53702772-53e9-ec51-c3a5-7a1912b4f2b4.htm new file mode 100644 index 0000000..3d2d294 --- /dev/null +++ b/docs/html/53702772-53e9-ec51-c3a5-7a1912b4f2b4.htm @@ -0,0 +1,62 @@ +gmp_lib.mpz_sub Method
    Click or drag to resize
    gmp_libmpz_sub Method
    + Set rop to op1 - op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_sub(
    +	mpz_t rop,
    +	mpz_t op1,
    +	mpz_t op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: Math.Gmp.Nativempz_t
    The second operand integer.
    Examples
    // Create, initialize, and set the value of x to 10000.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_ui(x, 10000U);
    +
    +// Create, initialize, and set the value of y to 12222.
    +mpz_t y = new mpz_t();
    +gmp_lib.mpz_init_set_ui(y, 12222U);
    +
    +// Create, initialize, and set the value of z to 0.
    +mpz_t z = new mpz_t();
    +gmp_lib.mpz_init(z);
    +
    +// Set z = x - y.
    +gmp_lib.mpz_sub(z, x, y);
    +
    +// Assert that z = x - y.
    +Assert.IsTrue(gmp_lib.mpz_get_si(z) == -2222);
    +
    +// Release unmanaged memory allocated for x, y, and z.
    +gmp_lib.mpz_clears(x, y, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/540dc183-f6ab-a0bb-d6ef-a08f5a464b78.htm b/docs/html/540dc183-f6ab-a0bb-d6ef-a08f5a464b78.htm new file mode 100644 index 0000000..a7ab429 --- /dev/null +++ b/docs/html/540dc183-f6ab-a0bb-d6ef-a08f5a464b78.htm @@ -0,0 +1,9 @@ +mp_bitcnt_t.GetHashCode Method
    mp_bitcnt_tGetHashCode Method
    + Returns the hash code for this instance. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override int GetHashCode()

    Return Value

    Type: Int32
    A 32-bit signed integer hash code.
    See Also
    \ No newline at end of file diff --git a/docs/html/542faa00-d28a-72a2-2dd8-6c6021e683ce.htm b/docs/html/542faa00-d28a-72a2-2dd8-6c6021e683ce.htm new file mode 100644 index 0000000..18118c2 --- /dev/null +++ b/docs/html/542faa00-d28a-72a2-2dd8-6c6021e683ce.htm @@ -0,0 +1,29 @@ +ptr(T) Class
    ptrT Class
    + Represents a pointer to a value of type T. +
    Inheritance Hierarchy
    SystemObject
      Math.Gmp.NativeptrT

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public class ptr<T>
    +where T : struct, new()
    +

    Type Parameters

    T
    A value type.

    The ptrT type exposes the following members.

    Constructors
    Methods
    +   + NameDescription
    Public methodEquals
    Determines whether the specified Object is equal to the current Object.
    (Inherited from Object.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGetHashCode
    Serves as a hash function for a particular type.
    (Inherited from Object.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Public methodToString
    Returns a string that represents the current object.
    (Inherited from Object.)
    Top
    Fields
    +   + NameDescription
    Public fieldValue
    + The value that is "pointed to". +
    Top
    Remarks

    + Mimics the C address-of (&) construct to pass the address of a value type variable + to a function of the GMP library. +

    + Note that this is only for value types. Strings and arrays have their own "pointer" + types defined with names ending in _ptr. +

    See Also
    \ No newline at end of file diff --git a/docs/html/54ac0eda-b14f-8083-16dc-6c0abe8a5e5e.htm b/docs/html/54ac0eda-b14f-8083-16dc-6c0abe8a5e5e.htm new file mode 100644 index 0000000..60234d3 --- /dev/null +++ b/docs/html/54ac0eda-b14f-8083-16dc-6c0abe8a5e5e.htm @@ -0,0 +1,19 @@ +mp_ptr Constructor (UInt16[])
    mp_ptr Constructor (UInt16)
    + Creates a new array of limbs initialized with values in unmanaged memory. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public mp_ptr(
    +	ushort[] values
    +)

    Parameters

    values
    Type: SystemUInt16
    The values of the limbs.
    Remarks

    + If there is not enough 16-bit words to fill out the most significant limb, it is padded with zeroes. +

    + When done with the array, you must release the unmanaged memory by calling free(mp_ptr). +

    See Also
    \ No newline at end of file diff --git a/docs/html/54ba330f-67d3-fa30-2d5f-0480b7f4659c.htm b/docs/html/54ba330f-67d3-fa30-2d5f-0480b7f4659c.htm new file mode 100644 index 0000000..f04bc7d --- /dev/null +++ b/docs/html/54ba330f-67d3-fa30-2d5f-0480b7f4659c.htm @@ -0,0 +1,47 @@ +gmp_lib.mpz_kronecker Method
    Click or drag to resize
    gmp_libmpz_kronecker Method
    + Calculate the Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_kronecker(
    +	mpz_t a,
    +	mpz_t b
    +)

    Parameters

    a
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    b
    Type: Math.Gmp.Nativempz_t
    The second operand integer.

    Return Value

    Type: Int32
    The Jacobi symbol (a/b) with the Kronecker extension (a/2) = (2/a) when a odd, or (a/2) = 0 when a even.
    Remarks

    + When b is odd the Jacobi symbol and Kronecker symbol are identical, + so mpz_kronecker_ui(mpz_t, UInt32), etc. can be used for mixed precision Jacobi symbols too. +

    Examples
    // Create, initialize, and set the value of a to 15.
    +mpz_t a = new mpz_t();
    +gmp_lib.mpz_init_set_ui(a, 15U);
    +
    +// Create, initialize, and set the value of b to 4.
    +mpz_t b = new mpz_t();
    +gmp_lib.mpz_init_set_ui(b, 4U);
    +
    +// Assert that the Kronecker symbol of (a/b) is 1.
    +Assert.IsTrue(gmp_lib.mpz_kronecker(a, b) == 1);
    +
    +// Release unmanaged memory allocated for a and b.
    +gmp_lib.mpz_clears(a, b, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/54c1f778-6fc8-0056-6f25-26f6754645fb.htm b/docs/html/54c1f778-6fc8-0056-6f25-26f6754645fb.htm new file mode 100644 index 0000000..6683e81 --- /dev/null +++ b/docs/html/54c1f778-6fc8-0056-6f25-26f6754645fb.htm @@ -0,0 +1,58 @@ +gmp_lib.mpz_get_str Method
    Click or drag to resize
    gmp_libmpz_get_str Method
    + Convert op to a string of digits in base base. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static char_ptr mpz_get_str(
    +	char_ptr str,
    +	int base,
    +	mpz_t op
    +)

    Parameters

    str
    Type: Math.Gmp.Nativechar_ptr
    The converted integer.
    base
    Type: SystemInt32
    The base.
    op
    Type: Math.Gmp.Nativempz_t
    The integer.

    Return Value

    Type: char_ptr
    A pointer to the result string is returned, being either the allocated block, or the given str.
    Remarks

    + The base argument may vary from 2 to 62 or from −2 to −36. +

    + For base in the range 2..36, digits and lower-case letters are used; for −2..−36, digits and + upper-case letters are used; for 37..62, digits, upper-case letters, and lower-case letters (in that + significance order) are used. +

    + If str is Zero, the result string is allocated using the current + allocation function. The block will be strlen(str)+1 bytes, that being exactly enough for the string and + null-terminator. +

    + If str is not Zero, it should point to a block of storage large + enough for the result, that being mpz_sizeinbase(mpz_t, Int32)(op, base) + 2. + The two extra bytes are for a possible minus sign, and the null-terminator. +

    Examples
    // Create, initialize, and set the value of x to -210.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_si(x, -210);
    +
    +// Retrieve the string value of x, and assert that it is "-210".
    +char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x);
    +Assert.IsTrue(s.ToString() == "-210");
    +
    +// Release unmanaged memory allocated for x and the string value.
    +gmp_lib.mpz_clear(x);
    +gmp_lib.free(s);
    See Also
    \ No newline at end of file diff --git a/docs/html/551f8670-3080-9a92-cd50-58d09cbf77ef.htm b/docs/html/551f8670-3080-9a92-cd50-58d09cbf77ef.htm new file mode 100644 index 0000000..2954954 --- /dev/null +++ b/docs/html/551f8670-3080-9a92-cd50-58d09cbf77ef.htm @@ -0,0 +1,34 @@ +gmp_lib.mpz_clear Method
    Click or drag to resize
    gmp_libmpz_clear Method
    + Free the space occupied by x. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_clear(
    +	mpz_t x
    +)

    Parameters

    x
    Type: Math.Gmp.Nativempz_t
    The integer.
    Remarks

    + Call this function for all mpz_t variables when you are done with them. +

    Examples
    // Create and initialize a new integer x.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init(x);
    +
    +// Assert that the value of x is 0.
    +Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 0U);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpz_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/5562b14f-48a4-be75-2eb0-6a129cd0d5ab.htm b/docs/html/5562b14f-48a4-be75-2eb0-6a129cd0d5ab.htm new file mode 100644 index 0000000..0385a70 --- /dev/null +++ b/docs/html/5562b14f-48a4-be75-2eb0-6a129cd0d5ab.htm @@ -0,0 +1,54 @@ +gmp_lib.mpn_add_1 Method
    Click or drag to resize
    gmp_libmpn_add_1 Method
    + Add {s1p, n} and s2limb, and write the n least significant limbs of the result to rp. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_limb_t mpn_add_1(
    +	mp_ptr rp,
    +	mp_ptr s1p,
    +	mp_size_t n,
    +	mp_limb_t s2limb
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    s1p
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs in s1p.
    s2limb
    Type: Math.Gmp.Nativemp_limb_t
    The second operand integer.

    Return Value

    Type: mp_limb_t
    Return carry, either 0 or 1.
    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
    +mp_ptr rp = new mp_ptr(new uint[2]);
    +mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });
    +
    +// Set rp = s1 + 1.
    +mp_limb_t carry = gmp_lib.mpn_add_1(rp, s1p, s1p.Size, 1);
    +
    +// Assert result of operation.
    +Assert.IsTrue(carry == 1);
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, s1p, result);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/55809d71-2a62-422c-a7e5-955b2b62fe37.htm b/docs/html/55809d71-2a62-422c-a7e5-955b2b62fe37.htm new file mode 100644 index 0000000..e930cb2 --- /dev/null +++ b/docs/html/55809d71-2a62-422c-a7e5-955b2b62fe37.htm @@ -0,0 +1,13 @@ +mp_bitcnt_t Implicit Conversion (UInt16 to mp_bitcnt_t)
    mp_bitcnt_t  Conversion (UInt16 to mp_bitcnt_t)
    + Converts a UInt16 value to an mp_bitcnt_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator mp_bitcnt_t (
    +	ushort value
    +)

    Parameters

    value
    Type: SystemUInt16
    A UInt16 value.

    Return Value

    Type: mp_bitcnt_t
    An mp_bitcnt_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/55d30a4b-ca4f-4f4b-208a-026c54586e64.htm b/docs/html/55d30a4b-ca4f-4f4b-208a-026c54586e64.htm new file mode 100644 index 0000000..6ee4604 --- /dev/null +++ b/docs/html/55d30a4b-ca4f-4f4b-208a-026c54586e64.htm @@ -0,0 +1,13 @@ +mp_bitcnt_t Explicit Conversion (mp_bitcnt_t to Int16)
    mp_bitcnt_t  Conversion (mp_bitcnt_t to Int16)
    + Converts an mp_bitcnt_t value to an Int16 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator short (
    +	mp_bitcnt_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_bitcnt_t
    An mp_bitcnt_t value.

    Return Value

    Type: Int16
    An Int16 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/562de56d-c1a8-5f66-59dc-e2886d89bfc3.htm b/docs/html/562de56d-c1a8-5f66-59dc-e2886d89bfc3.htm new file mode 100644 index 0000000..457c6b8 --- /dev/null +++ b/docs/html/562de56d-c1a8-5f66-59dc-e2886d89bfc3.htm @@ -0,0 +1,12 @@ +mp_ptr.Size Property
    mp_ptrSize Property
    + The number of limbs. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public mp_size_t Size { get; }

    Property Value

    Type: mp_size_t
    Remarks
    \ No newline at end of file diff --git a/docs/html/56e1a610-d238-ab9f-87b5-001764290847.htm b/docs/html/56e1a610-d238-ab9f-87b5-001764290847.htm new file mode 100644 index 0000000..b17db5f --- /dev/null +++ b/docs/html/56e1a610-d238-ab9f-87b5-001764290847.htm @@ -0,0 +1,60 @@ +gmp_lib.gmp_vsprintf Method
    Click or drag to resize
    gmp_libgmp_vsprintf Method
    + Form a null-terminated string in buf. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int gmp_vsprintf(
    +	char_ptr buf,
    +	string fmt,
    +	params Object[] ap
    +)

    Parameters

    buf
    Type: Math.Gmp.Nativechar_ptr
    The string to print to.
    fmt
    Type: SystemString
    Format string. See Formatted Output Strings.
    ap
    Type: SystemObject
    Arguments.

    Return Value

    Type: Int32
    Return the number of characters written, excluding the terminating null.
    Remarks

    + No overlap is permitted between the space at buf and the string fmt. +

    + These functions are not recommended, since there’s no protection against exceeding the space available at buf. +

    Examples
    // Allocate unmanaged string with 50 characters.
    +char_ptr str = new char_ptr(".................................................");
    +
    +mpz_t z = "123456";
    +mpq_t q = "123/456";
    +mpf_t f = "12345e6";
    +mp_limb_t m = 123456;
    +
    +// Print to string.
    +Assert.IsTrue(gmp_lib.gmp_vsprintf(str, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
    +Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");
    +
    +// Release unmanaged memory.
    +gmp_lib.free(str);
    +gmp_lib.mpz_clear(z);
    +gmp_lib.mpq_clear(q);
    +gmp_lib.mpf_clear(f);
    See Also
    \ No newline at end of file diff --git a/docs/html/56fbe432-4b26-efff-13e9-242996bfa78d.htm b/docs/html/56fbe432-4b26-efff-13e9-242996bfa78d.htm new file mode 100644 index 0000000..ad35090 --- /dev/null +++ b/docs/html/56fbe432-4b26-efff-13e9-242996bfa78d.htm @@ -0,0 +1,13 @@ +mp_bitcnt_t Explicit Conversion (Int64 to mp_bitcnt_t)
    mp_bitcnt_t  Conversion (Int64 to mp_bitcnt_t)
    + Converts an Int64 value to a mp_bitcnt_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator mp_bitcnt_t (
    +	long value
    +)

    Parameters

    value
    Type: SystemInt64
    An Int64 value.

    Return Value

    Type: mp_bitcnt_t
    An mp_bitcnt_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/5786e0c6-2dde-406f-b86d-3df6757c80c0.htm b/docs/html/5786e0c6-2dde-406f-b86d-3df6757c80c0.htm new file mode 100644 index 0000000..9607679 --- /dev/null +++ b/docs/html/5786e0c6-2dde-406f-b86d-3df6757c80c0.htm @@ -0,0 +1,73 @@ +gmp_lib.mpz_roinit_n Method
    Click or drag to resize
    gmp_libmpz_roinit_n Method
    + Special initialization of x, using the given limb array and size. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mpz_t mpz_roinit_n(
    +	mpz_t x,
    +	mp_ptr xp,
    +	mp_size_t xs
    +)

    Parameters

    x
    Type: Math.Gmp.Nativempz_t
    The operand integer.
    xp
    Type: Math.Gmp.Nativemp_ptr
    The limbs array.
    xs
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs and the sign.

    Return Value

    Type: mpz_t
    For convenience, the function returns x, but cast to a const pointer type.
    Remarks

    x should be treated as readonly: it can be passed safely as input to any mpz function, but not as an output. + The array xp must point to at least a readable limb, its size is |xs|, and the + sign of x is the sign of xs. +

    C++
    void foo (mpz_t x)
    +{
    +    static const mp_limb_t y[3] = { 0x1, 0x2, 0x3 };
    +    mpz_t tmp;
    +    mpz_add(x, x, mpz_roinit_n(tmp, y, 3));
    +}
    Examples
    // Create and initialize new integer x.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init(x);
    +
    +// Prepare new limbs for x.
    +mp_ptr limbs;
    +if (gmp_lib.mp_bytes_per_limb == 4)
    +    limbs = new mp_ptr(new uint[] { 0U, 0U, 2U });
    +else
    +    limbs = new mp_ptr(new ulong[] { 0UL, 0UL, 4UL });
    +
    +// Assign new limbs to x, and make x negative.
    +x = gmp_lib.mpz_roinit_n(x, limbs, -3);
    +
    +// Assert new value of x.
    +char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4, x);
    +Assert.IsTrue(s.ToString() == "-10 00000000000000000000000000000000 00000000000000000000000000000000".Replace(" ", ""));
    +
    +// Release unmanaged memory allocated for x and s.
    +gmp_lib.mpz_clear(x);
    +gmp_lib.free(s);
    See Also
    \ No newline at end of file diff --git a/docs/html/578ac23c-2986-d809-fa1b-c9a111d0c780.htm b/docs/html/578ac23c-2986-d809-fa1b-c9a111d0c780.htm new file mode 100644 index 0000000..c4d32dd --- /dev/null +++ b/docs/html/578ac23c-2986-d809-fa1b-c9a111d0c780.htm @@ -0,0 +1,7 @@ +void_ptr Operators
    void_ptr Operators

    The void_ptr type exposes the following members.

    Operators
    +   + NameDescription
    Public operatorStatic memberEquality
    + Gets a value that indicates whether the two argument values are equal. +
    Public operatorStatic memberInequality
    + Gets a value that indicates whether the two argument values are different. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/57c5f9bf-43e8-b575-90c8-23c0e366fb2d.htm b/docs/html/57c5f9bf-43e8-b575-90c8-23c0e366fb2d.htm new file mode 100644 index 0000000..71a48ae --- /dev/null +++ b/docs/html/57c5f9bf-43e8-b575-90c8-23c0e366fb2d.htm @@ -0,0 +1,13 @@ +mp_size_t Implicit Conversion (mp_size_t to Int32)
    mp_size_t  Conversion (mp_size_t to Int32)
    + Converts an mp_size_t value to an Int32 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator int (
    +	mp_size_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_size_t
    An mp_size_t value.

    Return Value

    Type: Int32
    An Int32 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/582a0647-1482-ecd7-cc78-bd2222610e06.htm b/docs/html/582a0647-1482-ecd7-cc78-bd2222610e06.htm new file mode 100644 index 0000000..bddb832 --- /dev/null +++ b/docs/html/582a0647-1482-ecd7-cc78-bd2222610e06.htm @@ -0,0 +1,62 @@ +gmp_lib.mpz_addmul Method
    Click or drag to resize
    gmp_libmpz_addmul Method
    + Set rop to rop + op1 * op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_addmul(
    +	mpz_t rop,
    +	mpz_t op1,
    +	mpz_t op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: Math.Gmp.Nativempz_t
    The second operand integer.
    Examples
    // Create, initialize, and set the value of x to 10000.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_ui(x, 10000U);
    +
    +// Create, initialize, and set the value of y to 12222.
    +mpz_t y = new mpz_t();
    +gmp_lib.mpz_init_set_ui(y, 12222U);
    +
    +// Create, initialize, and set the value of z to 20000.
    +mpz_t z = new mpz_t();
    +gmp_lib.mpz_init_set_ui(z, 20000U);
    +
    +// Set z += x * y.
    +gmp_lib.mpz_addmul(z, x, y);
    +
    +// Assert that z has been incremented by 10000 * 12222.
    +Assert.IsTrue(gmp_lib.mpz_get_si(z) == 20000U + 10000 * 12222);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpz_clears(x, y, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/5846cdbc-83b9-0197-aa29-fd226641eb76.htm b/docs/html/5846cdbc-83b9-0197-aa29-fd226641eb76.htm new file mode 100644 index 0000000..f46288d --- /dev/null +++ b/docs/html/5846cdbc-83b9-0197-aa29-fd226641eb76.htm @@ -0,0 +1,15 @@ +mp_bitcnt_t Constructor
    mp_bitcnt_t Constructor
    + Creates a new mp_bitcnt_t, and sets its value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public mp_bitcnt_t(
    +	uint value
    +)

    Parameters

    value
    Type: SystemUInt32
    The value of the new mp_bitcnt_t.
    See Also
    \ No newline at end of file diff --git a/docs/html/584834ae-b1f7-d965-2586-f88d5c9b4f67.htm b/docs/html/584834ae-b1f7-d965-2586-f88d5c9b4f67.htm new file mode 100644 index 0000000..0e9e80c --- /dev/null +++ b/docs/html/584834ae-b1f7-d965-2586-f88d5c9b4f67.htm @@ -0,0 +1,24 @@ +gmp_lib.mpq_mul Method
    Click or drag to resize
    gmp_libmpq_mul Method
    + Set product to multiplier * multiplicand. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpq_mul(
    +	mpq_t product,
    +	mpq_t multiplier,
    +	mpq_t multiplicand
    +)

    Parameters

    product
    Type: Math.Gmp.Nativempq_t
    The result rational.
    multiplier
    Type: Math.Gmp.Nativempq_t
    The first operand rational.
    multiplicand
    Type: Math.Gmp.Nativempq_t
    The second operand rational.
    Examples
    See Also
    \ No newline at end of file diff --git a/docs/html/5a168ae0-405b-7259-0853-84999876c47a.htm b/docs/html/5a168ae0-405b-7259-0853-84999876c47a.htm new file mode 100644 index 0000000..bc7b8f3 --- /dev/null +++ b/docs/html/5a168ae0-405b-7259-0853-84999876c47a.htm @@ -0,0 +1,42 @@ +gmp_lib.mpf_cmp_ui Method
    Click or drag to resize
    gmp_libmpf_cmp_ui Method
    + Compare op1 and op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpf_cmp_ui(
    +	mpf_t op1,
    +	uint op2
    +)

    Parameters

    op1
    Type: Math.Gmp.Nativempf_t
    The first operand float.
    op2
    Type: SystemUInt32
    The second operand float.

    Return Value

    Type: Int32
    Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 512.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, 512);
    +
    +// Assert that x > 128.
    +Assert.IsTrue(gmp_lib.mpf_cmp_ui(x, 128) > 0);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpf_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/5a3c38b8-5205-bc81-58e8-60b155c0579c.htm b/docs/html/5a3c38b8-5205-bc81-58e8-60b155c0579c.htm new file mode 100644 index 0000000..4a79ca5 --- /dev/null +++ b/docs/html/5a3c38b8-5205-bc81-58e8-60b155c0579c.htm @@ -0,0 +1,7 @@ +mp_exp_t.Equals Method
    mp_exp_tEquals Method
    Overload List
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(mp_exp_t)
    + Returns a value indicating whether this instance is equal to a specified mp_exp_t value. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/5a61d62c-a0f0-5e86-b6dd-8ca6414b35ed.htm b/docs/html/5a61d62c-a0f0-5e86-b6dd-8ca6414b35ed.htm new file mode 100644 index 0000000..2edfd69 --- /dev/null +++ b/docs/html/5a61d62c-a0f0-5e86-b6dd-8ca6414b35ed.htm @@ -0,0 +1,50 @@ +gmp_lib.mpz_neg Method
    Click or drag to resize
    gmp_libmpz_neg Method
    + Set rop to -op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_neg(
    +	mpz_t rop,
    +	mpz_t op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    op
    Type: Math.Gmp.Nativempz_t
    The operand integer.
    Examples
    // Create, initialize, and set the value of x to -10000.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_si(x, -10000);
    +
    +// Create, initialize, and set the value of z to 0.
    +mpz_t z = new mpz_t();
    +gmp_lib.mpz_init(z);
    +
    +// Set z = -x.
    +gmp_lib.mpz_neg(z, x);
    +
    +// Assert that z is -x.
    +Assert.IsTrue(gmp_lib.mpz_get_si(z) == 10000);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpz_clears(x, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/5a698221-639e-333b-061b-0aa3f76c38e9.htm b/docs/html/5a698221-639e-333b-061b-0aa3f76c38e9.htm new file mode 100644 index 0000000..822183a --- /dev/null +++ b/docs/html/5a698221-639e-333b-061b-0aa3f76c38e9.htm @@ -0,0 +1,55 @@ +gmp_lib.mpf_urandomb Method
    Click or drag to resize
    gmp_libmpf_urandomb Method
    + Generate a uniformly distributed random float in rop, such that 0 ≤ rop < 1, with nbits significant bits in the mantissa or less if the precision of rop is smaller. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_urandomb(
    +	mpf_t rop,
    +	gmp_randstate_t state,
    +	mp_bitcnt_t nbits
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    state
    Type: Math.Gmp.Nativegmp_randstate_t
    The random number generator state.
    nbits
    Type: Math.Gmp.Nativemp_bitcnt_t
    Number of significant bits.
    Remarks

    + The variable state must be initialized by calling one of the gmp_randinit functions + (GNU MP - Random State Initialization) before invoking this function. +

    Examples
    // Create, initialize, and seed a new random number generator.
    +gmp_randstate_t state = new gmp_randstate_t();
    +gmp_lib.gmp_randinit_mt(state);
    +gmp_lib.gmp_randseed_ui(state, 100000U);
    +
    +// Create, initialize, and set the value of rop to 0.
    +mpf_t rop = new mpf_t();
    +gmp_lib.mpf_init(rop);
    +
    +// Generate a random integer in the range [0, 1) with 50 bits precision.
    +gmp_lib.mpf_urandomb(rop, state, 50);
    +
    +// Free all memory occupied by state and rop.
    +gmp_lib.gmp_randclear(state);
    +gmp_lib.mpf_clear(rop);
    See Also
    \ No newline at end of file diff --git a/docs/html/5b4fc57b-2ab5-9b95-6c35-ec9b499a6d59.htm b/docs/html/5b4fc57b-2ab5-9b95-6c35-ec9b499a6d59.htm new file mode 100644 index 0000000..d64c688 --- /dev/null +++ b/docs/html/5b4fc57b-2ab5-9b95-6c35-ec9b499a6d59.htm @@ -0,0 +1,17 @@ +mp_bitcnt_t.Equals Method (Object)
    mp_bitcnt_tEquals Method (Object)
    + Returns a value indicating whether this instance is equal to a specified object. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override bool Equals(
    +	Object obj
    +)

    Parameters

    obj
    Type: SystemObject
    An object to compare with this instance.

    Return Value

    Type: Boolean
    True if obj is an instance of mp_bitcnt_t and equals the value of this instance; otherwise, False.
    See Also
    \ No newline at end of file diff --git a/docs/html/5c1d434c-5d85-dea7-ac47-09126d92900d.htm b/docs/html/5c1d434c-5d85-dea7-ac47-09126d92900d.htm new file mode 100644 index 0000000..366a107 --- /dev/null +++ b/docs/html/5c1d434c-5d85-dea7-ac47-09126d92900d.htm @@ -0,0 +1,13 @@ +size_t Explicit Conversion (SByte to size_t)
    size_t  Conversion (SByte to size_t)
    + Converts a SByte value to a size_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator size_t (
    +	sbyte value
    +)

    Parameters

    value
    Type: SystemSByte
    A SByte value.

    Return Value

    Type: size_t
    A size_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/5c2015f3-41d2-7b80-5309-e41ccec0baaf.htm b/docs/html/5c2015f3-41d2-7b80-5309-e41ccec0baaf.htm new file mode 100644 index 0000000..6c83941 --- /dev/null +++ b/docs/html/5c2015f3-41d2-7b80-5309-e41ccec0baaf.htm @@ -0,0 +1,42 @@ +gmp_lib.gmp_printf Method
    Click or drag to resize
    gmp_libgmp_printf Method
    + Print to the standard output stdout. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int gmp_printf(
    +	string fmt,
    +	params Object[] args
    +)

    Parameters

    fmt
    Type: SystemString
    Format string. See Formatted Output Strings.
    args
    Type: SystemObject
    Arguments.

    Return Value

    Type: Int32
    Return the number of characters written, or -1 if an error occurred.
    Examples
    mpz_t z = "123456";
    +mpq_t q = "123/456";
    +mpf_t f = "12345e6";
    +mp_limb_t m = 123456;
    +
    +// Print to standard output.
    +Assert.IsTrue(gmp_lib.gmp_printf("%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
    +
    +// Release unmanaged memory.
    +gmp_lib.mpz_clear(z)
    +gmp_lib.mpq_clear(q)
    +gmp_lib.mpf_clear(f)
    See Also
    \ No newline at end of file diff --git a/docs/html/5cd3a242-93b7-49c5-b9c9-1dca02ed4662.htm b/docs/html/5cd3a242-93b7-49c5-b9c9-1dca02ed4662.htm new file mode 100644 index 0000000..b5dfd55 --- /dev/null +++ b/docs/html/5cd3a242-93b7-49c5-b9c9-1dca02ed4662.htm @@ -0,0 +1,47 @@ +gmp_lib.mpz_init2 Method
    Click or drag to resize
    gmp_libmpz_init2 Method
    + Initialize x, with space for n-bit numbers, and set its value to 0. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_init2(
    +	mpz_t x,
    +	mp_bitcnt_t n
    +)

    Parameters

    x
    Type: Math.Gmp.Nativempz_t
    The integer.
    n
    Type: Math.Gmp.Nativemp_bitcnt_t
    The number of bits.
    Remarks

    + Calling this function instead of mpz_init(mpz_t) or mpz_inits(mpz_t) + is never necessary; reallocation is handled automatically by GMP when needed. +

    + While n defines the initial space, x will grow automatically in the normal way, + if necessary, for subsequent values stored. + mpz_init2(mpz_t, mp_bitcnt_t) makes it possible to avoid such reallocations if a maximum size is known in advance. +

    + In preparation for an operation, GMP often allocates one limb more than ultimately needed. + To make sure GMP will not perform reallocation for x, you need to add the number of bits + in mp_limb_t to n. +

    Examples
    // Create a new integer x, and initialize its size to 300 bits.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init2(x, 300);
    +
    +// Assert that the value of x is 0.
    +Assert.IsTrue(gmp_lib.mpz_get_si(x) == 0);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpz_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/5d499247-7cb9-266f-eb4f-78bcf5768aa4.htm b/docs/html/5d499247-7cb9-266f-eb4f-78bcf5768aa4.htm new file mode 100644 index 0000000..db25626 --- /dev/null +++ b/docs/html/5d499247-7cb9-266f-eb4f-78bcf5768aa4.htm @@ -0,0 +1,19 @@ +mpq_t Implicit Conversion (String to mpq_t)
    mpq_t  Conversion (String to mpq_t)
    + Converts a String value to an mpq_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator mpq_t (
    +	string value
    +)

    Parameters

    value
    Type: SystemString
    A String value.

    Return Value

    Type: mpq_t
    An mpq_t value.
    Remarks

    + The leading characters are used: 0x and 0X for hexadecimal, + 0b and 0B for binary, 0 for octal, or decimal otherwise. + Note that this is done separately for the numerator and denominator, so for + instance 0xEF/100 is 239/100, whereas 0xEF/0x100 is + 239/256. +

    See Also
    \ No newline at end of file diff --git a/docs/html/5dfc0ea9-a81f-bda9-356c-034395ba3c9c.htm b/docs/html/5dfc0ea9-a81f-bda9-356c-034395ba3c9c.htm new file mode 100644 index 0000000..731fd18 --- /dev/null +++ b/docs/html/5dfc0ea9-a81f-bda9-356c-034395ba3c9c.htm @@ -0,0 +1,61 @@ +gmp_lib.mpz_fdiv_r Method
    Click or drag to resize
    gmp_libmpz_fdiv_r Method
    + Set the remainder r to n - q * d where q = floor(n / d). +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_fdiv_r(
    +	mpz_t r,
    +	mpz_t n,
    +	mpz_t d
    +)

    Parameters

    r
    Type: Math.Gmp.Nativempz_t
    The result remainder integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: Math.Gmp.Nativempz_t
    The denominator integer.
    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10000);
    +
    +// Create, initialize, and set the value of d to 3.
    +mpz_t d = new mpz_t();
    +gmp_lib.mpz_init_set_si(d, 3);
    +
    +// Create, initialize, and set the value of r to 0.
    +mpz_t r = new mpz_t();
    +gmp_lib.mpz_init(r);
    +
    +// Set r = n - d * floor(n / d).
    +gmp_lib.mpz_fdiv_r(r, n, d);
    +
    +// Assert that r is 1.
    +Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);
    +
    +// Release unmanaged memory allocated for n, d, and r.
    +gmp_lib.mpz_clears(n, d, r, null);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/5ea7691b-2a0f-5f25-290c-54c78e2cf3bd.htm b/docs/html/5ea7691b-2a0f-5f25-290c-54c78e2cf3bd.htm new file mode 100644 index 0000000..e44c6b6 --- /dev/null +++ b/docs/html/5ea7691b-2a0f-5f25-290c-54c78e2cf3bd.htm @@ -0,0 +1,32 @@ +gmp_lib.mpf_fits_sint_p Method
    Click or drag to resize
    gmp_libmpf_fits_sint_p Method
    + Return non-zero if op fits in a 32-bit integer, when truncated to an integer. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpf_fits_sint_p(
    +	mpf_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempf_t
    The operand float.

    Return Value

    Type: Int32
    Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
    Examples
    // Create, initialize, and set the value of op 4294967295.
    +mpf_t op = new mpf_t();
    +gmp_lib.mpf_init_set_ui(op, uint.MaxValue);
    +
    +// Assert that op does not fit in int.
    +Assert.IsTrue(gmp_lib.mpf_fits_sint_p(op) == 0);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpf_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/5f492d5c-72f0-17b4-24a4-e5b58a061ef7.htm b/docs/html/5f492d5c-72f0-17b4-24a4-e5b58a061ef7.htm new file mode 100644 index 0000000..505133f --- /dev/null +++ b/docs/html/5f492d5c-72f0-17b4-24a4-e5b58a061ef7.htm @@ -0,0 +1,9 @@ +mpz_t Properties
    mpz_t Properties

    The mpz_t type exposes the following members.

    Properties
    +   + NameDescription
    Public property_mp_alloc
    + The number of limbs currently allocated at _mp_d. +
    Public property_mp_d
    + A pointer to an array of limbs which is the magnitude. +
    (Inherited from mp_base.)
    Public property_mp_size
    + The number of limbs, or the negative of that when representing a negative integer. +
    (Overrides mp_base_mp_size.)
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/5fba9944-4437-9b1c-afa0-666d87eafe39.htm b/docs/html/5fba9944-4437-9b1c-afa0-666d87eafe39.htm new file mode 100644 index 0000000..43b286a --- /dev/null +++ b/docs/html/5fba9944-4437-9b1c-afa0-666d87eafe39.htm @@ -0,0 +1,54 @@ +gmp_lib.mpz_mul_ui Method
    Click or drag to resize
    gmp_libmpz_mul_ui Method
    + Set rop to op1 * op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_mul_ui(
    +	mpz_t rop,
    +	mpz_t op1,
    +	uint op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: SystemUInt32
    The second operand integer.
    Examples
    // Create, initialize, and set the value of x to -10000.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_si(x, -10000);
    +
    +// Create, initialize, and set the value of z to 0.
    +mpz_t z = new mpz_t();
    +gmp_lib.mpz_init(z);
    +
    +// Set z = x * 12222.
    +gmp_lib.mpz_mul_ui(z, x, 12222);
    +
    +// Assert that z is the product of x and 12222.
    +Assert.IsTrue(gmp_lib.mpz_get_si(z) == -10000 * 12222);
    +
    +// Release unmanaged memory allocated for x and z.
    +gmp_lib.mpz_clears(x, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/6101fda5-1230-66a9-5aff-5d8da426e364.htm b/docs/html/6101fda5-1230-66a9-5aff-5d8da426e364.htm new file mode 100644 index 0000000..8bd88ca --- /dev/null +++ b/docs/html/6101fda5-1230-66a9-5aff-5d8da426e364.htm @@ -0,0 +1,46 @@ +gmp_lib.mpz_ui_pow_ui Method
    Click or drag to resize
    gmp_libmpz_ui_pow_ui Method
    + Set rop to base^exp. The case 0^0 yields 1. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_ui_pow_ui(
    +	mpz_t rop,
    +	uint base,
    +	uint exp
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    base
    Type: SystemUInt32
    The base integer.
    exp
    Type: SystemUInt32
    The exponent integer.
    Examples
    // Create, initialize, and set the value of rop to 0.
    +mpz_t rop = new mpz_t();
    +gmp_lib.mpz_init(rop);
    +
    +// Set rop = 2^4.
    +gmp_lib.mpz_ui_pow_ui(rop, 2U, 4U);
    +
    +// Assert that rop is 16.
    +Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 16);
    +
    +// Release unmanaged memory allocated for rop.
    +gmp_lib.mpz_clear(rop);
    See Also
    \ No newline at end of file diff --git a/docs/html/61401484-d06f-ab9e-110d-b46f4d0a9eba.htm b/docs/html/61401484-d06f-ab9e-110d-b46f4d0a9eba.htm new file mode 100644 index 0000000..8338169 --- /dev/null +++ b/docs/html/61401484-d06f-ab9e-110d-b46f4d0a9eba.htm @@ -0,0 +1,34 @@ +gmp_lib.mpn_perfect_power_p Method
    Click or drag to resize
    gmp_libmpn_perfect_power_p Method
    + Return non-zero iff {sp, n} is a perfect power. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpn_perfect_power_p(
    +	mp_ptr sp,
    +	mp_size_t n
    +)

    Parameters

    sp
    Type: Math.Gmp.Nativemp_ptr
    The operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The numbe rof limbs of sp.

    Return Value

    Type: Int32
    Non-zero iff {sp, n} is a perfect power.
    Examples
    // Create multi-precision operand.
    +mp_ptr s1p = new mp_ptr(new uint[] { 0xd4a51000, 0x000000e8 });
    +
    +// Assert s1p is a perfect power.
    +Assert.IsTrue(gmp_lib.mpn_perfect_power_p(s1p, s1p.Size) != 0);
    +
    +// Release unmanaged memory.
    +gmp_lib.free(s1p);
    See Also
    \ No newline at end of file diff --git a/docs/html/61686857-e4a0-ad60-1419-2b87a79b06c1.htm b/docs/html/61686857-e4a0-ad60-1419-2b87a79b06c1.htm new file mode 100644 index 0000000..cca45f6 --- /dev/null +++ b/docs/html/61686857-e4a0-ad60-1419-2b87a79b06c1.htm @@ -0,0 +1,66 @@ +gmp_lib.gmp_snprintf Method
    Click or drag to resize
    gmp_libgmp_snprintf Method
    + Form a null-terminated string in buf. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int gmp_snprintf(
    +	char_ptr buf,
    +	size_t size,
    +	string fmt,
    +	params Object[] args
    +)

    Parameters

    buf
    Type: Math.Gmp.Nativechar_ptr
    The string to print to.
    size
    Type: Math.Gmp.Nativesize_t
    The maximum number of bytes to write.
    fmt
    Type: SystemString
    Format string. See Formatted Output Strings.
    args
    Type: SystemObject
    Arguments.

    Return Value

    Type: Int32
    The return value is the total number of characters which ought to have been produced, excluding the terminating null. If retval ≥ size then the actual output has been truncated to the first size - 1 characters, and a null appended.
    Remarks

    + No more than size bytes will be written. To get the full output, size must be enough for the string and null-terminator. +

    + No overlap is permitted between the regiom {buf,size} and the fmt string. +

    + Notice the return value is in ISO C99 snprintf style. This is so even if the C library vsnprintf is the older GLIBC 2.0.x style. +

    Examples
    // Allocate unmanaged string with 50 characters.
    +char_ptr str = new char_ptr(".................................................");
    +
    +mpz_t z = "123456";
    +mpq_t q = "123/456";
    +mpf_t f = "12345e6";
    +mp_limb_t m = 123456;
    +
    +// Print to string.
    +Assert.IsTrue(gmp_lib.gmp_snprintf(str, 50, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
    +Assert.IsTrue(str.ToString() == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");
    +
    +// Release unmanaged memory.
    +gmp_lib.free(str);
    +gmp_lib.mpz_clear(z);
    +gmp_lib.mpq_clear(q);
    +gmp_lib.mpf_clear(f);
    See Also
    \ No newline at end of file diff --git a/docs/html/6280cd97-b728-ab06-89e1-7181e2ab72fe.htm b/docs/html/6280cd97-b728-ab06-89e1-7181e2ab72fe.htm new file mode 100644 index 0000000..90945c5 --- /dev/null +++ b/docs/html/6280cd97-b728-ab06-89e1-7181e2ab72fe.htm @@ -0,0 +1,13 @@ +mp_bitcnt_t Implicit Conversion (UInt32 to mp_bitcnt_t)
    mp_bitcnt_t  Conversion (UInt32 to mp_bitcnt_t)
    + Converts a UInt32 value to an mp_bitcnt_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator mp_bitcnt_t (
    +	uint value
    +)

    Parameters

    value
    Type: SystemUInt32
    A UInt32 value.

    Return Value

    Type: mp_bitcnt_t
    An mp_bitcnt_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/62c5f2f4-2a93-e6d2-b867-23d4f2b98af4.htm b/docs/html/62c5f2f4-2a93-e6d2-b867-23d4f2b98af4.htm new file mode 100644 index 0000000..932e47a --- /dev/null +++ b/docs/html/62c5f2f4-2a93-e6d2-b867-23d4f2b98af4.htm @@ -0,0 +1,59 @@ +gmp_lib.gmp_vfprintf Method
    Click or drag to resize
    gmp_libgmp_vfprintf Method
    + Print to the stream fp. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int gmp_vfprintf(
    +	ptr<FILE> fp,
    +	string fmt,
    +	params Object[] ap
    +)

    Parameters

    fp
    Type: Math.Gmp.NativeptrFILE
    File stream.
    fmt
    Type: SystemString
    Format string. See Formatted Output Strings.
    ap
    Type: SystemObject
    Arguments.

    Return Value

    Type: Int32
    Return the number of characters written, or -1 if an error occurred.
    Examples
    // Create unique file pathname and a file pointer.
    +string pathname = System.IO.Path.GetTempFileName();
    +ptr<FILE> stream = new ptr<FILE>();
    +
    +mpz_t z = "123456";
    +mpq_t q = "123/456";
    +mpf_t f = "12345e6";
    +mp_limb_t m = 123456;
    +
    +// Open file stream and print to it.
    +_wfopen_s(out stream.Value.Value, pathname, "w");
    +Assert.IsTrue(gmp_lib.gmp_vfprintf(stream, "%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
    +fclose(stream.Value.Value);
    +Assert.IsTrue(System.IO.File.ReadAllText(pathname) == "123456 - 7B/1C8 - 0x2.dfd1c04p+32 - 361100");
    +
    +// Release unmanaged memory.
    +gmp_lib.mpz_clear(z)
    +gmp_lib.mpq_clear(q)
    +gmp_lib.mpf_clear(f)
    See Also
    \ No newline at end of file diff --git a/docs/html/62ffb793-b32f-e0dc-a399-f20fe708a803.htm b/docs/html/62ffb793-b32f-e0dc-a399-f20fe708a803.htm new file mode 100644 index 0000000..67fcf47 --- /dev/null +++ b/docs/html/62ffb793-b32f-e0dc-a399-f20fe708a803.htm @@ -0,0 +1,63 @@ +gmp_lib.mpn_sec_invert Method
    Click or drag to resize
    gmp_libmpn_sec_invert Method
    + Set R to the inverse of A modulo M, where R = {rp, n}, A = {ap, n}, and M = {mp, n}. This function’s interface is preliminary. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpn_sec_invert(
    +	mp_ptr rp,
    +	mp_ptr ap,
    +	mp_ptr mp,
    +	mp_size_t n,
    +	mp_bitcnt_t nbcnt,
    +	mp_ptr tp
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    ap
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    mp
    Type: Math.Gmp.Nativemp_ptr
    The second operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of ap and mp.
    nbcnt
    Type: Math.Gmp.Nativemp_bitcnt_t
    The third operand integer.
    tp
    Type: Math.Gmp.Nativemp_ptr
    The scratch operand integer.

    Return Value

    Type: Int32
    If an inverse exists, return 1, otherwise return 0 and leave R undefined.
    Remarks

    + If an inverse exists, return 1, otherwise return 0 and leave R undefined. + In either case, the input A is destroyed. +

    + It is required that M is odd, and that nbcnt ≥ ceil(log(A + 1)) + ceil(log(M + 1)). + A safe choice is nbcnt = 2 * n * mp_bits_per_limb, + but a smaller value might improve performance if M or A are known to have leading zero bits. +

    + This function requires scratch space of mpn_sec_invert_itch(mp_size_t)(n) + limbs to be passed in the tp parameter. +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr ap = new mp_ptr(new uint[] { 3 });
    +mp_ptr mp = new mp_ptr(new uint[] { 11 });
    +mp_ptr rp = new mp_ptr(ap.Size);
    +mp_ptr result = new mp_ptr(new uint[] { 4 });
    +
    +// Create scratch space.
    +mp_size_t size = gmp_lib.mpn_sec_invert_itch(ap.Size);
    +mp_ptr tp = new mp_ptr(size);
    +
    +// Set rp = ap^-1 mod mp.
    +gmp_lib.mpn_sec_invert(rp, ap, mp, ap.Size, (uint)(2 * ap.Size* gmp_lib.mp_bits_per_limb), tp);
    +
    +// Assert result of operation.
    +Assert.IsTrue(rp[0] == result[0]);
    +
    +// Release unmanaged memory.
    +gmp_lib.free(ap, mp, rp, result, tp);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/635ddf01-9c52-0d37-202e-c560b895fb7d.htm b/docs/html/635ddf01-9c52-0d37-202e-c560b895fb7d.htm new file mode 100644 index 0000000..7c9343d --- /dev/null +++ b/docs/html/635ddf01-9c52-0d37-202e-c560b895fb7d.htm @@ -0,0 +1,53 @@ +gmp_lib.mpz_com Method
    Click or drag to resize
    gmp_libmpz_com Method
    + Set rop to the one’s complement of op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_com(
    +	mpz_t rop,
    +	mpz_t op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    op
    Type: Math.Gmp.Nativempz_t
    The operand integer.
    Remarks

    + The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). + The least significant bit is number 0. +

    Examples
    // Create, initialize, and set the value of op to 63.
    +mpz_t op = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op, 63U);
    +
    +// Create, initialize, and set the value of rop to 0.
    +mpz_t rop = new mpz_t();
    +gmp_lib.mpz_init(rop);
    +
    +// Set rop to the one's complement of op.
    +gmp_lib.mpz_com(rop, op);
    +
    +// Assert that rop is -64.
    +Assert.IsTrue(gmp_lib.mpz_get_si(rop) == -64);
    +
    +// Release unmanaged memory allocated for rop and op.
    +gmp_lib.mpz_clears(rop, op, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/635f1879-5f85-881e-cca8-3222baf5045a.htm b/docs/html/635f1879-5f85-881e-cca8-3222baf5045a.htm new file mode 100644 index 0000000..1cdffa9 --- /dev/null +++ b/docs/html/635f1879-5f85-881e-cca8-3222baf5045a.htm @@ -0,0 +1,27 @@ +mpq_t Class
    mpq_t Class
    + Represents a multiple precision rational number. +
    Inheritance Hierarchy
    SystemObject
      Math.Gmp.Nativempq_t

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public class mpq_t

    The mpq_t type exposes the following members.

    Constructors
    +   + NameDescription
    Public methodmpq_t
    + Creates a new multiple precision rational. +
    Top
    Properties
    +   + NameDescription
    Public property_mp_den
    + Get the denominator integer of the rational. +
    Public property_mp_num
    + Get the numerator integer of the rational. +
    Top
    Methods
    +   + NameDescription
    Public methodEquals
    Determines whether the specified Object is equal to the current Object.
    (Inherited from Object.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGetHashCode
    Serves as a hash function for a particular type.
    (Inherited from Object.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Public methodToIntPtr
    + Gets the unmanaged memory pointer of the multiple precision rational. +
    Public methodToString
    + Return the string representation of the rational. +
    (Overrides ObjectToString.)
    Top
    Operators
    Remarks
    \ No newline at end of file diff --git a/docs/html/63e2f5c3-b5bb-ebf6-3bcf-682671a0dbc3.htm b/docs/html/63e2f5c3-b5bb-ebf6-3bcf-682671a0dbc3.htm new file mode 100644 index 0000000..916af9c --- /dev/null +++ b/docs/html/63e2f5c3-b5bb-ebf6-3bcf-682671a0dbc3.htm @@ -0,0 +1,13 @@ +mp_limb_t Explicit Conversion (mp_limb_t to Int64)
    mp_limb_t  Conversion (mp_limb_t to Int64)
    + Converts a mp_limb_t value to an Int64 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator long (
    +	mp_limb_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_limb_t
    An mp_limb_t value.

    Return Value

    Type: Int64
    An Int64 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/64373933-f98b-74b4-c10f-3b1a98c410bc.htm b/docs/html/64373933-f98b-74b4-c10f-3b1a98c410bc.htm new file mode 100644 index 0000000..738d8f9 --- /dev/null +++ b/docs/html/64373933-f98b-74b4-c10f-3b1a98c410bc.htm @@ -0,0 +1,40 @@ +gmp_lib.mpn_gcd_1 Method
    Click or drag to resize
    gmp_libmpn_gcd_1 Method
    + Return the greatest common divisor of {xp, xn} and ylimb. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_limb_t mpn_gcd_1(
    +	mp_ptr xp,
    +	mp_size_t xn,
    +	mp_limb_t ylimb
    +)

    Parameters

    xp
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    xn
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of xp.
    ylimb
    Type: Math.Gmp.Nativemp_limb_t
    The second operand integer.

    Return Value

    Type: mp_limb_t
    The greatest common divisor of {xp, xn} and ylimb.
    Remarks

    + Both operands must be non-zero. +

    Examples
    // Create multi-precision operand.
    +mp_ptr xp = new mp_ptr(new uint[] { 0x00000000, 0x00000001 });
    +
    +// Assert result of operation.
    +Assert.IsTrue(gmp_lib.mpn_gcd_1(xp, xp.Size, 1073741824) == 1073741824);
    +
    +// Release unmanaged memory.
    +gmp_lib.free(xp);
    See Also
    \ No newline at end of file diff --git a/docs/html/648fa405-45d3-506a-f6be-72642e8a7f32.htm b/docs/html/648fa405-45d3-506a-f6be-72642e8a7f32.htm new file mode 100644 index 0000000..c8405e1 --- /dev/null +++ b/docs/html/648fa405-45d3-506a-f6be-72642e8a7f32.htm @@ -0,0 +1,43 @@ +gmp_lib.mpf_get_d Method
    Click or drag to resize
    gmp_libmpf_get_d Method
    + Convert op to a Double, truncating if necessary (i.e. rounding towards zero). +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static double mpf_get_d(
    +	mpf_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempf_t
    The operand float.

    Return Value

    Type: Double
    The cpnverted Double.
    Remarks

    + If the exponent in op is too big or too small to fit a Double then the result is system dependent. + For too big an infinity is returned when available. + For too small 0.0 is normally returned. + Hardware overflow, underflow and denorm traps may or may not occur. +

    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number to -123.0
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_d(x, -123.0);
    +
    +// Assert that the value of x is -123.0.
    +Assert.IsTrue(gmp_lib.mpf_get_d(x) == -123.0);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpf_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/650e9cdb-0392-1173-aba8-9a1d6fc6a694.htm b/docs/html/650e9cdb-0392-1173-aba8-9a1d6fc6a694.htm new file mode 100644 index 0000000..aee2e97 --- /dev/null +++ b/docs/html/650e9cdb-0392-1173-aba8-9a1d6fc6a694.htm @@ -0,0 +1,16 @@ +void_ptr.FromIntPtr Method
    void_ptrFromIntPtr Method
    + Gets a void_ptr from a pointer to a block of unmanaged memory. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public void_ptr FromIntPtr(
    +	IntPtr value
    +)

    Parameters

    value
    Type: SystemIntPtr
    A pointer to a block of unmanaged memory.

    Return Value

    Type: void_ptr
    A void_ptr from a pointer to a block of unmanaged memory.
    See Also
    \ No newline at end of file diff --git a/docs/html/67fc54a2-05e7-bc3c-64f4-8c6de48fa6b6.htm b/docs/html/67fc54a2-05e7-bc3c-64f4-8c6de48fa6b6.htm new file mode 100644 index 0000000..8c74c20 --- /dev/null +++ b/docs/html/67fc54a2-05e7-bc3c-64f4-8c6de48fa6b6.htm @@ -0,0 +1,52 @@ +gmp_lib.mpz_tdiv_q_ui Method
    Click or drag to resize
    gmp_libmpz_tdiv_q_ui Method
    + Set the quotient q to trunc(n / d), and return the remainder r = |n - q * d|. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static ulong mpz_tdiv_q_ui(
    +	mpz_t q,
    +	mpz_t n,
    +	uint d
    +)

    Parameters

    q
    Type: Math.Gmp.Nativempz_t
    The result quotient integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: SystemUInt32
    The denominator integer.

    Return Value

    Type: UInt64
    Return the remainder r = |n - q * d|.
    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10000);
    +
    +// Create, initialize, and set the value of q to 0.
    +mpz_t q = new mpz_t();
    +gmp_lib.mpz_init(q);
    +
    +// Set q = trunc(n / 3) and return r = n - 3 * q.
    +// Assert q and r values.
    +Assert.IsTrue(gmp_lib.mpz_tdiv_q_ui(q, n, 3U) == 1U);
    +Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);
    +
    +// Release unmanaged memory allocated for n and q.
    +gmp_lib.mpz_clears(n, q, null);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/6820d6c4-6ee1-53d7-7223-3f654a496ce4.htm b/docs/html/6820d6c4-6ee1-53d7-7223-3f654a496ce4.htm new file mode 100644 index 0000000..933c157 --- /dev/null +++ b/docs/html/6820d6c4-6ee1-53d7-7223-3f654a496ce4.htm @@ -0,0 +1,34 @@ +gmp_lib.mpz_odd_p Method
    Click or drag to resize
    gmp_libmpz_odd_p Method
    + Determine whether op is odd. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_odd_p(
    +	mpz_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempz_t
    The operand integer.

    Return Value

    Type: Int32
    Return non-zero if odd, zero if even.
    Examples
    // Create, initialize, and set the value of op to 427294.
    +mpz_t op = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op, 427294);
    +
    +// Assert that op is not odd but even.
    +Assert.IsTrue(gmp_lib.mpz_even_p(op) > 0);
    +Assert.IsTrue(gmp_lib.mpz_odd_p(op) == 0);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpz_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/6871c168-60e1-5bd2-5a03-2d60f473d7b8.htm b/docs/html/6871c168-60e1-5bd2-5a03-2d60f473d7b8.htm new file mode 100644 index 0000000..ff6075b --- /dev/null +++ b/docs/html/6871c168-60e1-5bd2-5a03-2d60f473d7b8.htm @@ -0,0 +1,7 @@ +mpq_t Methods
    mpq_t Methods

    The mpq_t type exposes the following members.

    Methods
    +   + NameDescription
    Public methodEquals
    Determines whether the specified Object is equal to the current Object.
    (Inherited from Object.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGetHashCode
    Serves as a hash function for a particular type.
    (Inherited from Object.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Public methodToIntPtr
    + Gets the unmanaged memory pointer of the multiple precision rational. +
    Public methodToString
    + Return the string representation of the rational. +
    (Overrides ObjectToString.)
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/6885ad71-c185-1e0c-abc8-4320e12f377a.htm b/docs/html/6885ad71-c185-1e0c-abc8-4320e12f377a.htm new file mode 100644 index 0000000..cd62b6d --- /dev/null +++ b/docs/html/6885ad71-c185-1e0c-abc8-4320e12f377a.htm @@ -0,0 +1,57 @@ +gmp_lib.mpq_set_num Method
    Click or drag to resize
    gmp_libmpq_set_num Method
    + Set the numerator of rational to numerator. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpq_set_num(
    +	mpq_t rational,
    +	mpz_t numerator
    +)

    Parameters

    rational
    Type: Math.Gmp.Nativempq_t
    The result rational.
    numerator
    Type: Math.Gmp.Nativempz_t
    The operand integer.
    Remarks

    + The function is equivalent to calling mpz_set(mpz_t, mpz_t) with mpq_numref(mpq_t). + Direct use of mpq_numref(mpq_t) is recommended instead of this functions. +

    Examples
    // Create, initialize, and set the value of op to -1 / 3.
    +mpq_t op = new mpq_t();
    +gmp_lib.mpq_init(op);
    +gmp_lib.mpq_set_si(op, -1, 3U);
    +
    +// Create, initialize, and set the value of a new integer to 5.
    +mpz_t num = new mpz_t();
    +gmp_lib.mpz_init_set_ui(num, 5U);
    +
    +// Set the numerator of op.
    +gmp_lib.mpq_set_num(op, num);
    +
    +// Assert that op is 5 / 3.
    +Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 5, 3U) == 0);
    +
    +// Release unmanaged memory allocated for op and num.
    +gmp_lib.mpq_clear(op);
    +gmp_lib.mpz_clear(num);
    See Also
    \ No newline at end of file diff --git a/docs/html/68d3161d-2909-1909-cda7-e87949ee27ce.htm b/docs/html/68d3161d-2909-1909-cda7-e87949ee27ce.htm new file mode 100644 index 0000000..3fc6e05 --- /dev/null +++ b/docs/html/68d3161d-2909-1909-cda7-e87949ee27ce.htm @@ -0,0 +1,64 @@ +gmp_lib.mpn_mul Method
    Click or drag to resize
    gmp_libmpn_mul Method
    + Multiply {s1p, s1n} and {s2p, s2n}, and write the (s1n + s2n)-limb result to rp. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_limb_t mpn_mul(
    +	mp_ptr rp,
    +	mp_ptr s1p,
    +	mp_size_t s1n,
    +	mp_ptr s2p,
    +	mp_size_t s2n
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    s1p
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    s1n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of s1p.
    s2p
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    s2n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of s2p.

    Return Value

    Type: mp_limb_t
    Return the most significant limb of the result.
    Remarks

    + The destination has to have space for s1n + s2n limbs, + even if the product’s most significant limb is zero. + No overlap is permitted between the destination and either source. +

    + This function requires that s1n is greater than or equal to s2n. +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
    +mp_ptr s2p = new mp_ptr(new uint[] { 0x00000002 });
    +mp_ptr rp = new mp_ptr(new uint[3]);
    +mp_ptr result = new mp_ptr(new uint[] { 0xfffffffe, 0xffffffff, 0x00000001 });
    +
    +// Set rp = s1 * s2.
    +gmp_lib.mpn_mul(rp, s1p, s1p.Size, s2p, s2p.Size);
    +
    +// Assert result of operation.
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, s1p, s2p, result);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/6991a24e-345d-029c-c189-ed263640928b.htm b/docs/html/6991a24e-345d-029c-c189-ed263640928b.htm new file mode 100644 index 0000000..19042cf --- /dev/null +++ b/docs/html/6991a24e-345d-029c-c189-ed263640928b.htm @@ -0,0 +1,13 @@ +mp_limb_t Explicit Conversion (mp_limb_t to Byte)
    mp_limb_t  Conversion (mp_limb_t to Byte)
    + Converts a mp_limb_t value to a Byte value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator byte (
    +	mp_limb_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_limb_t
    An mp_limb_t value.

    Return Value

    Type: Byte
    A Byte value.
    See Also
    \ No newline at end of file diff --git a/docs/html/69ffabc9-a19c-6590-d918-fbf0710aff82.htm b/docs/html/69ffabc9-a19c-6590-d918-fbf0710aff82.htm new file mode 100644 index 0000000..09b4f56 --- /dev/null +++ b/docs/html/69ffabc9-a19c-6590-d918-fbf0710aff82.htm @@ -0,0 +1,54 @@ +gmp_lib.mpn_and_n Method
    Click or drag to resize
    gmp_libmpn_and_n Method
    + Perform the bitwise logical and of {s1p, n} and {s2p, n}, and write the result to {rp, n}. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpn_and_n(
    +	mp_ptr rp,
    +	mp_ptr s1p,
    +	mp_ptr s2p,
    +	mp_size_t n
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    s1p
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    s2p
    Type: Math.Gmp.Nativemp_ptr
    The second operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of s1p and s2p.
    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
    +mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
    +mp_ptr rp = new mp_ptr(new uint[2]);
    +mp_ptr result = new mp_ptr(new uint[] { 0x00000001, 0x12345678 });
    +
    +// Set rp = s1 and s2.
    +gmp_lib.mpn_and_n(rp, s1p, s2p, s1p.Size);
    +
    +// Assert result of operation.
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, s1p, s2p, result);
    See Also
    \ No newline at end of file diff --git a/docs/html/6a3819df-abc1-ceb1-a5c7-87a879977b8c.htm b/docs/html/6a3819df-abc1-ceb1-a5c7-87a879977b8c.htm new file mode 100644 index 0000000..03da590 --- /dev/null +++ b/docs/html/6a3819df-abc1-ceb1-a5c7-87a879977b8c.htm @@ -0,0 +1,64 @@ +gmp_lib.mpz_set_str Method
    Click or drag to resize
    gmp_libmpz_set_str Method
    + Set the value of rop from str, a null-terminated C string in base base. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_set_str(
    +	mpz_t rop,
    +	char_ptr str,
    +	int base
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The destination integer.
    str
    Type: Math.Gmp.Nativechar_ptr
    The source integer.
    base
    Type: SystemInt32
    The base.

    Return Value

    Type: Int32
    This function returns 0 if the entire string is a valid number in base base. Otherwise it returns −1.
    Remarks

    + White space is allowed in the string, and is simply ignored. +

    + The base may vary from 2 to 62, or if base is 0, then the leading characters are + used: 0x and 0X for hexadecimal, 0b and 0B for binary, 0 for octal, + or decimal otherwise. +

    + For bases up to 36, case is ignored; upper-case and lower-case letters have the same value. + For bases 37 to 62, upper-case letter represent the usual 10..35 while lower-case + letter represent 36..61. +

    Examples
    // Create and initialize a new integer x.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init(x);
    +
    +// Set the value of x.
    +char_ptr value = new char_ptr("12 345 678 909 876 543 211 234 567 890 987 654 321");
    +gmp_lib.mpz_set_str(x, value, 10);
    +
    +// Assert the value of x.
    +char_ptr s = gmp_lib.mpz_get_str(char_ptr.Zero, 10, x);
    +Assert.IsTrue(s.ToString() == value.ToString().Replace(" ", ""));
    +
    +// Release unmanaged memory allocated for x and string values.
    +gmp_lib.mpz_clear(x);
    +gmp_lib.free(value);
    +gmp_lib.free(s);
    See Also
    \ No newline at end of file diff --git a/docs/html/6b71bf90-ded3-6f2b-f59b-19b7e3442ef4.htm b/docs/html/6b71bf90-ded3-6f2b-f59b-19b7e3442ef4.htm new file mode 100644 index 0000000..dfc0ce1 --- /dev/null +++ b/docs/html/6b71bf90-ded3-6f2b-f59b-19b7e3442ef4.htm @@ -0,0 +1,13 @@ +mp_exp_t Explicit Conversion (mp_exp_t to UInt32)
    mp_exp_t  Conversion (mp_exp_t to UInt32)
    + Converts an mp_exp_t value to a UInt32 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator uint (
    +	mp_exp_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_exp_t
    An mp_exp_t value.

    Return Value

    Type: UInt32
    A UInt32 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/6b85c6a3-d6c5-d1d2-829a-af000bae687e.htm b/docs/html/6b85c6a3-d6c5-d1d2-829a-af000bae687e.htm new file mode 100644 index 0000000..2a8afc2 --- /dev/null +++ b/docs/html/6b85c6a3-d6c5-d1d2-829a-af000bae687e.htm @@ -0,0 +1,32 @@ +gmp_lib.mpz_fits_ushort_p Method
    Click or drag to resize
    gmp_libmpz_fits_ushort_p Method
    + Return non-zero iff the value of op fits in an unsigned 16-bit integer. Otherwise, return zero. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_fits_ushort_p(
    +	mpz_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempz_t
    The operand integer.

    Return Value

    Type: Int32
    Return non-zero iff the value of op fits in an unsigned 16-bit integer. Otherwise, return zero.
    Examples
    // Create, initialize, and set the value of op 4294967295.
    +mpz_t op = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op, uint.MaxValue);
    +
    +// Assert that op does not fit in ushort.
    +Assert.IsTrue(gmp_lib.mpz_fits_ushort_p(op) == 0);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpz_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/6b870324-3daa-70e6-ded7-2757f5755310.htm b/docs/html/6b870324-3daa-70e6-ded7-2757f5755310.htm new file mode 100644 index 0000000..dd78c38 --- /dev/null +++ b/docs/html/6b870324-3daa-70e6-ded7-2757f5755310.htm @@ -0,0 +1,13 @@ +mp_bitcnt_t Implicit Conversion (mp_bitcnt_t to UInt64)
    mp_bitcnt_t  Conversion (mp_bitcnt_t to UInt64)
    + Converts an mp_bitcnt_t value to a UInt64 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator ulong (
    +	mp_bitcnt_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_bitcnt_t
    An mp_bitcnt_t value.

    Return Value

    Type: UInt64
    A UInt64 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/6b879622-df00-c9b2-deba-307574416ff2.htm b/docs/html/6b879622-df00-c9b2-deba-307574416ff2.htm new file mode 100644 index 0000000..72213c3 --- /dev/null +++ b/docs/html/6b879622-df00-c9b2-deba-307574416ff2.htm @@ -0,0 +1,13 @@ +mp_exp_t Explicit Conversion (UInt64 to mp_exp_t)
    mp_exp_t  Conversion (UInt64 to mp_exp_t)
    + Converts a UInt64 value to an mp_exp_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator mp_exp_t (
    +	ulong value
    +)

    Parameters

    value
    Type: SystemUInt64
    A UInt64 value.

    Return Value

    Type: mp_exp_t
    An mp_exp_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/6ba37de9-82cf-e884-2537-0d8e83b8ffa0.htm b/docs/html/6ba37de9-82cf-e884-2537-0d8e83b8ffa0.htm new file mode 100644 index 0000000..e269eea --- /dev/null +++ b/docs/html/6ba37de9-82cf-e884-2537-0d8e83b8ffa0.htm @@ -0,0 +1,13 @@ +mp_bitcnt_t Explicit Conversion (Int32 to mp_bitcnt_t)
    mp_bitcnt_t  Conversion (Int32 to mp_bitcnt_t)
    + Converts an Int32 value to an mp_bitcnt_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator mp_bitcnt_t (
    +	int value
    +)

    Parameters

    value
    Type: SystemInt32
    An Int32 value.

    Return Value

    Type: mp_bitcnt_t
    An mp_bitcnt_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/6c026976-a6c9-6f12-6b31-c113166ea236.htm b/docs/html/6c026976-a6c9-6f12-6b31-c113166ea236.htm new file mode 100644 index 0000000..38b3836 --- /dev/null +++ b/docs/html/6c026976-a6c9-6f12-6b31-c113166ea236.htm @@ -0,0 +1,40 @@ +gmp_lib.mpz_divisible_ui_p Method
    Click or drag to resize
    gmp_libmpz_divisible_ui_p Method
    + Return non-zero if n is exactly divisible by d. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpz_divisible_ui_p(
    +	mpz_t n,
    +	uint d
    +)

    Parameters

    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: SystemUInt32
    The denominator integer.

    Return Value

    Type: Int32
    Non-zero if n is exactly divisible by d.
    Remarks

    n is divisible by d if there exists an integer q + satisfying n = q * d. Unlike the other division functions, + d = 0 is accepted and following the rule it can be seen that only 0 is + considered divisible by 0. +

    Examples
    // Create, initialize, and set the value of x to 10000.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_ui(x, 10000U);
    +
    +// Assert that x is divisible by 5.
    +Assert.IsTrue(gmp_lib.mpz_divisible_ui_p(x, 5U) > 0);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpz_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/6c178e2d-a080-13b8-75b0-3fe232b46d75.htm b/docs/html/6c178e2d-a080-13b8-75b0-3fe232b46d75.htm new file mode 100644 index 0000000..6eeff42 --- /dev/null +++ b/docs/html/6c178e2d-a080-13b8-75b0-3fe232b46d75.htm @@ -0,0 +1,32 @@ +gmp_lib.mpf_fits_slong_p Method
    Click or drag to resize
    gmp_libmpf_fits_slong_p Method
    + Return non-zero if op fits in a 32-bit integer, when truncated to an integer. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpf_fits_slong_p(
    +	mpf_t op
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempf_t
    The operand float.

    Return Value

    Type: Int32
    Return non-zero if op fits in a 32-bit integer, when truncated to an integer.
    Examples
    // Create, initialize, and set the value of op 4294967295.
    +mpf_t op = new mpf_t();
    +gmp_lib.mpf_init_set_ui(op, uint.MaxValue);
    +
    +// Assert that op does not fit in long.
    +Assert.IsTrue(gmp_lib.mpf_fits_slong_p(op) == 0);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpf_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/6d0766fc-29bc-75e6-aa00-ed7b80fe586e.htm b/docs/html/6d0766fc-29bc-75e6-aa00-ed7b80fe586e.htm new file mode 100644 index 0000000..b8519a2 --- /dev/null +++ b/docs/html/6d0766fc-29bc-75e6-aa00-ed7b80fe586e.htm @@ -0,0 +1,13 @@ +size_t Implicit Conversion (Byte to size_t)
    size_t  Conversion (Byte to size_t)
    + Converts a Byte value to a size_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator size_t (
    +	byte value
    +)

    Parameters

    value
    Type: SystemByte
    A Byte value.

    Return Value

    Type: size_t
    A size_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/6d4f993a-1fd6-9db2-c0a7-0f3926863565.htm b/docs/html/6d4f993a-1fd6-9db2-c0a7-0f3926863565.htm new file mode 100644 index 0000000..faa23fa --- /dev/null +++ b/docs/html/6d4f993a-1fd6-9db2-c0a7-0f3926863565.htm @@ -0,0 +1,39 @@ +gmp_lib.mpn_random Method
    Click or drag to resize
    gmp_libmpn_random Method
    + Generate a random number of length r1n and store it at r1p. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpn_random(
    +	mp_ptr r1p,
    +	mp_size_t r1n
    +)

    Parameters

    r1p
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    r1n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of r1p.
    Remarks

    + The most significant limb is always non-zero. + mpn_random(mp_ptr, mp_size_t) generates uniformly distributed limb data, + mpn_random2(mp_ptr, mp_size_t) generates long strings of zeros and ones in the binary representation. +

    mpn_random2(mp_ptr, mp_size_t) is intended for testing the correctness of the mpn routines. +

    Examples
    // Create multi-precision operand.
    +mp_ptr r1p = new mp_ptr(new uint[2]);
    +
    +// Generate random number.
    +gmp_lib.mpn_random(r1p, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 1);
    +
    +// Release unmanaged memory.
    +gmp_lib.free(r1p);
    See Also
    \ No newline at end of file diff --git a/docs/html/6eb39888-e104-5cdd-a22d-c1240ef748e4.htm b/docs/html/6eb39888-e104-5cdd-a22d-c1240ef748e4.htm new file mode 100644 index 0000000..f066fe4 --- /dev/null +++ b/docs/html/6eb39888-e104-5cdd-a22d-c1240ef748e4.htm @@ -0,0 +1,13 @@ +mp_size_t Explicit Conversion (mp_size_t to Byte)
    mp_size_t  Conversion (mp_size_t to Byte)
    + Converts an mp_size_t value to a Byte value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator byte (
    +	mp_size_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_size_t
    An mp_size_t value.

    Return Value

    Type: Byte
    A Byte value.
    See Also
    \ No newline at end of file diff --git a/docs/html/6f0c915a-514a-fce0-957b-50180f4b79a7.htm b/docs/html/6f0c915a-514a-fce0-957b-50180f4b79a7.htm new file mode 100644 index 0000000..71a63f9 --- /dev/null +++ b/docs/html/6f0c915a-514a-fce0-957b-50180f4b79a7.htm @@ -0,0 +1,48 @@ +gmp_lib.mpn_com Method
    Click or drag to resize
    gmp_libmpn_com Method
    + Perform the bitwise complement of {sp, n}, and write the result to {rp, n}. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpn_com(
    +	mp_ptr rp,
    +	mp_ptr sp,
    +	mp_size_t n
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    sp
    Type: Math.Gmp.Nativemp_ptr
    The operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The numbe rof limbs of rp>> and sp.
    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr sp = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 });
    +mp_ptr rp = new mp_ptr(new uint[2]);
    +mp_ptr result = new mp_ptr(new uint[] { 0x0f0f0f0f, 0x0f0f0f0f });
    +
    +// Set rp = not(sp).
    +gmp_lib.mpn_com(rp, sp, sp.Size);
    +
    +// Assert result of operation.
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, sp, result);
    See Also
    \ No newline at end of file diff --git a/docs/html/6f1dca2b-39f4-3acd-71fb-4f1e5a0d04e6.htm b/docs/html/6f1dca2b-39f4-3acd-71fb-4f1e5a0d04e6.htm new file mode 100644 index 0000000..2ef96f0 --- /dev/null +++ b/docs/html/6f1dca2b-39f4-3acd-71fb-4f1e5a0d04e6.htm @@ -0,0 +1,84 @@ +gmp_lib.mpn_sec_div_qr Method
    Click or drag to resize
    gmp_libmpn_sec_div_qr Method
    + Set Q to the truncated quotient N / D and R to N modulo D, where N = {np, nn}, D = {dp, dn}, Q’s most significant limb is the function return value and the remaining limbs are {qp, nn - dn}, and R = {np, dn}. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_limb_t mpn_sec_div_qr(
    +	mp_ptr qp,
    +	mp_ptr np,
    +	mp_size_t nn,
    +	mp_ptr dp,
    +	mp_size_t dn,
    +	mp_ptr tp
    +)

    Parameters

    qp
    Type: Math.Gmp.Nativemp_ptr
    The quotient result operand.
    np
    Type: Math.Gmp.Nativemp_ptr
    The first operand and remainder result integer.
    nn
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of np.
    dp
    Type: Math.Gmp.Nativemp_ptr
    The second operand integer.
    dn
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of dp.
    tp
    Type: Math.Gmp.Nativemp_ptr
    The scratch operand integer.

    Return Value

    Type: mp_limb_t
    Q’s most significant limb.
    Remarks

    + It is required that nndn ≥ 1, and that dp[dn - 1] ≠ 0. + This does not imply that N ≥ D since N might be zero-padded. +

    + Note the overlapping between N and R. + No other operand overlapping is allowed. + The entire space occupied by N is overwritten. +

    + This function requires scratch space of mpn_sec_div_qr_itch(mp_size_t, mp_size_t)(nn, dn) + limbs to be passed in the tp parameter. +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr np = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
    +mp_ptr dp = new mp_ptr(new uint[] { 0x00000003 });
    +mp_ptr remainder = new mp_ptr(new uint[] { 0x00000000 });
    +mp_ptr qp = new mp_ptr(new uint[np.Size]);
    +
    +// Create scratch space.
    +mp_size_t size = gmp_lib.mpn_sec_div_qr_itch(np.Size, dp.Size);
    +mp_ptr tp = new mp_ptr(size);
    +
    +// Set qp = floor(np / dp) and rp = np mod dp.
    +mp_limb_t mslimb = gmp_lib.mpn_sec_div_qr(qp, np, np.Size, dp, dp.Size, tp);
    +
    +// Assert result of operation.
    +Assert.IsTrue(mslimb == (ulong)(gmp_lib.mp_bytes_per_limb == 4 ? 0x00005555 : 0x0000555555555555));
    +Assert.IsTrue(qp[0] == (ulong)(gmp_lib.mp_bytes_per_limb == 4 ? 0x55555555 : 0x0000000000000000));
    +Assert.IsTrue(np[0] == remainder[0]);
    +
    +// Release unmanaged memory.
    +gmp_lib.free(qp, np, dp, remainder, tp);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/6f85986d-b6a0-435d-3675-c025ef70413d.htm b/docs/html/6f85986d-b6a0-435d-3675-c025ef70413d.htm new file mode 100644 index 0000000..8ddf0b4 --- /dev/null +++ b/docs/html/6f85986d-b6a0-435d-3675-c025ef70413d.htm @@ -0,0 +1,80 @@ +gmp_lib.mpz_out_str Method
    Click or drag to resize
    gmp_libmpz_out_str Method
    + Output op on stdio stream stream, as a string of digits in base base. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static size_t mpz_out_str(
    +	ptr<FILE> stream,
    +	int base,
    +	mpz_t op
    +)

    Parameters

    stream
    Type: Math.Gmp.NativeptrFILE
    Pointer to file stream.
    base
    Type: SystemInt32
    The base operand.
    op
    Type: Math.Gmp.Nativempz_t
    The operand integer.

    Return Value

    Type: size_t
    Return the number of bytes written, or if an error occurred, return 0.
    Remarks

    + The base argument may vary from 2 to 62 or from -2 to -36. +

    + For base in the range 2..36, digits and lower-case letters are used; + for -2..-36, digits and upper-case letters are used; for 37..62, digits, upper-case letters, + and lower-case letters (in that significance order) are used. +

    Examples
    // Create, initialize, and set the value of op to 123456.
    +mpz_t op = new mpz_t();
    +gmp_lib.mpz_init_set_ui(op, 123456U);
    +
    +// Get a temporary file.
    +string pathname = System.IO.Path.GetTempFileName();
    +
    +// Open temporary file for writing.
    +ptr<FILE> stream = new ptr<FILE>();
    +_wfopen_s(out stream.Value.Value, pathname, "w");
    +
    +// Write op to temporary file, and assert that the number of bytes written is 6.
    +Assert.IsTrue(gmp_lib.mpz_out_str(stream, 10, op) == 6);
    +
    +// Close temporary file.
    +fclose(stream.Value.Value);
    +
    +// Assert that the content of the temporary file is "123456".
    +string result = System.IO.File.ReadAllText(pathname);
    +Assert.IsTrue(result == "123456");
    +
    +// Delete temporary file.
    +System.IO.File.Delete(pathname);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpz_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/6feeab0d-dc91-818f-ef60-2434ff3a1146.htm b/docs/html/6feeab0d-dc91-818f-ef60-2434ff3a1146.htm new file mode 100644 index 0000000..a385bde --- /dev/null +++ b/docs/html/6feeab0d-dc91-818f-ef60-2434ff3a1146.htm @@ -0,0 +1,9 @@ +size_t.GetHashCode Method
    size_tGetHashCode Method
    + Returns the hash code for this instance. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override int GetHashCode()

    Return Value

    Type: Int32
    A 32-bit signed integer hash code.
    See Also
    \ No newline at end of file diff --git a/docs/html/709eb598-ee38-4031-9dc5-74a73d8f9142.htm b/docs/html/709eb598-ee38-4031-9dc5-74a73d8f9142.htm new file mode 100644 index 0000000..8bba369 --- /dev/null +++ b/docs/html/709eb598-ee38-4031-9dc5-74a73d8f9142.htm @@ -0,0 +1,9 @@ +mpz_t.ToString Method
    mpz_tToString Method
    + Return the string representation of the integer. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override string ToString()

    Return Value

    Type: String
    The string representation of the integer.
    See Also
    \ No newline at end of file diff --git a/docs/html/70eabcfd-22ae-e08e-1bc5-54f8e1ccb736.htm b/docs/html/70eabcfd-22ae-e08e-1bc5-54f8e1ccb736.htm new file mode 100644 index 0000000..b1d5ddc --- /dev/null +++ b/docs/html/70eabcfd-22ae-e08e-1bc5-54f8e1ccb736.htm @@ -0,0 +1,13 @@ +mp_exp_t Explicit Conversion (Int64 to mp_exp_t)
    mp_exp_t  Conversion (Int64 to mp_exp_t)
    + Converts an Int64 value to a mp_exp_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator mp_exp_t (
    +	long value
    +)

    Parameters

    value
    Type: SystemInt64
    An Int64 value.

    Return Value

    Type: mp_exp_t
    An mp_exp_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/71884691-07d0-7bdf-c761-df9b07723735.htm b/docs/html/71884691-07d0-7bdf-c761-df9b07723735.htm new file mode 100644 index 0000000..4dc2ac3 --- /dev/null +++ b/docs/html/71884691-07d0-7bdf-c761-df9b07723735.htm @@ -0,0 +1,48 @@ +gmp_lib.mpz_fib_ui Method
    Click or drag to resize
    gmp_libmpz_fib_ui Method
    + Sets fn to to F[n], the n’th Fibonacci number. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_fib_ui(
    +	mpz_t fn,
    +	uint n
    +)

    Parameters

    fn
    Type: Math.Gmp.Nativempz_t
    The F[n] result.
    n
    Type: SystemUInt32
    The operand integer.
    Remarks

    + The Fibonacci numbers and Lucas numbers are related sequences, so it’s never necessary to call both + mpz_fib2_ui(mpz_t, mpz_t, UInt32) and mpz_lucnum2_ui(mpz_t, mpz_t, UInt32). + The formulas for going from Fibonacci to Lucas can be found in + GNU MP - Lucas Numbers Algorithm, + the reverse is straightforward too. +

    Examples
    // Create, initialize, and set the value of fn to 0.
    +mpz_t fn = new mpz_t();
    +gmp_lib.mpz_init(fn);
    +
    +// Set fn to the n'th Fibonacci number.
    +gmp_lib.mpz_fib_ui(fn, 20U);
    +
    +// Assert that fn is 6765.
    +Assert.IsTrue(gmp_lib.mpz_get_si(fn) == 6765);
    +
    +// Release unmanaged memory allocated for fn.
    +gmp_lib.mpz_clear(fn);
    See Also
    \ No newline at end of file diff --git a/docs/html/718e7623-d25b-8a09-2543-745f24cd82c1.htm b/docs/html/718e7623-d25b-8a09-2543-745f24cd82c1.htm new file mode 100644 index 0000000..a786eef --- /dev/null +++ b/docs/html/718e7623-d25b-8a09-2543-745f24cd82c1.htm @@ -0,0 +1,69 @@ +gmp_lib.mpf_sub Method
    Click or drag to resize
    gmp_libmpf_sub Method
    + Set rop to op1 - op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpf_sub(
    +	mpf_t rop,
    +	mpf_t op1,
    +	mpf_t op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    op1
    Type: Math.Gmp.Nativempf_t
    The first operand.
    op2
    Type: Math.Gmp.Nativempf_t
    The second operand.
    Examples
    // Set default precision to 64 bits.
    +gmp_lib.mpf_set_default_prec(64U);
    +
    +// Create, initialize, and set a new floating-point number x to 10.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init_set_si(x, 10);
    +
    +// Create, initialize, and set a new floating-point number y to -210.
    +mpf_t y = new mpf_t();
    +gmp_lib.mpf_init_set_si(y, -210);
    +
    +// Create and initialize a new floating-point number z.
    +mpf_t z = new mpf_t();
    +gmp_lib.mpf_init(z);
    +
    +// Set z = x - y.
    +gmp_lib.mpf_sub(z, x, y);
    +
    +// Assert that the value of z is 220.
    +Assert.IsTrue(gmp_lib.mpf_get_d(z) == 220.0);
    +
    +// Release unmanaged memory allocated for x, y, and z.
    +gmp_lib.mpf_clears(x, y, z, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/72723d8b-579c-0c0f-d5c8-868ae849457e.htm b/docs/html/72723d8b-579c-0c0f-d5c8-868ae849457e.htm new file mode 100644 index 0000000..eb7e148 --- /dev/null +++ b/docs/html/72723d8b-579c-0c0f-d5c8-868ae849457e.htm @@ -0,0 +1,13 @@ +mp_limb_t Explicit Conversion (mp_limb_t to Int32)
    mp_limb_t  Conversion (mp_limb_t to Int32)
    + Converts a mp_limb_t value to an Int32 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator int (
    +	mp_limb_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativemp_limb_t
    An mp_limb_t value.

    Return Value

    Type: Int32
    An Int32 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/72fbcc09-5765-7f60-3897-57fec21cc9f9.htm b/docs/html/72fbcc09-5765-7f60-3897-57fec21cc9f9.htm new file mode 100644 index 0000000..676690e --- /dev/null +++ b/docs/html/72fbcc09-5765-7f60-3897-57fec21cc9f9.htm @@ -0,0 +1,15 @@ +mp_bitcnt_t Implicit Conversion Operators
    \ No newline at end of file diff --git a/docs/html/7327aa92-1ab5-7553-7eee-7b5e3e61322a.htm b/docs/html/7327aa92-1ab5-7553-7eee-7b5e3e61322a.htm new file mode 100644 index 0000000..0e16788 --- /dev/null +++ b/docs/html/7327aa92-1ab5-7553-7eee-7b5e3e61322a.htm @@ -0,0 +1,48 @@ +gmp_lib.mpz_add_ui Method
    Click or drag to resize
    gmp_libmpz_add_ui Method
    + Set rop to op1 + op2. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_add_ui(
    +	mpz_t rop,
    +	mpz_t op1,
    +	uint op2
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The result integer.
    op1
    Type: Math.Gmp.Nativempz_t
    The first operand integer.
    op2
    Type: SystemUInt32
    The second operand integer.
    Examples
    // Create, initialize, and set the value of x to 0.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init(x);
    +
    +// Increment x twice by 101999.
    +gmp_lib.mpz_add_ui(x, x, 101999U);
    +gmp_lib.mpz_add_ui(x, x, 101999U);
    +
    +// Assert that x is 203998.
    +Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 203998U);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpz_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/73876566-4eec-b421-e4d6-3593e9641f0a.htm b/docs/html/73876566-4eec-b421-e4d6-3593e9641f0a.htm new file mode 100644 index 0000000..08112fd --- /dev/null +++ b/docs/html/73876566-4eec-b421-e4d6-3593e9641f0a.htm @@ -0,0 +1,13 @@ +char_ptr Methods
    char_ptr Methods

    The char_ptr type exposes the following members.

    Methods
    +   + NameDescription
    Public methodEquals(Object)
    + Returns a value indicating whether this instance is equal to a specified object. +
    (Overrides ValueTypeEquals(Object).)
    Public methodEquals(char_ptr)
    + Returns a value indicating whether this instance is equal to a specified char_ptr value. +
    Public methodGetHashCode
    + Returns the hash code for this instance. +
    (Overrides ValueTypeGetHashCode.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Public methodToIntPtr
    + Gets pointer to string in unmanaged memory. +
    Public methodToString
    + Gets the .NET String equivalent of the unmanaged string. +
    (Overrides ValueTypeToString.)
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/746301ec-352c-9bae-ff92-8a2ed31be655.htm b/docs/html/746301ec-352c-9bae-ff92-8a2ed31be655.htm new file mode 100644 index 0000000..c54fa12 --- /dev/null +++ b/docs/html/746301ec-352c-9bae-ff92-8a2ed31be655.htm @@ -0,0 +1,54 @@ +gmp_lib.mpz_tdiv_q_2exp Method
    Click or drag to resize
    gmp_libmpz_tdiv_q_2exp Method
    + Set the quotient q to trunc(n / 2^b). +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_tdiv_q_2exp(
    +	mpz_t q,
    +	mpz_t n,
    +	mp_bitcnt_t b
    +)

    Parameters

    q
    Type: Math.Gmp.Nativempz_t
    The result quotient integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    b
    Type: Math.Gmp.Nativemp_bitcnt_t
    The exponent of the power of two denominator.
    Examples
    // Create, initialize, and set the value of n to 10001.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10001);
    +
    +// Create, initialize, and set the value of q to 0.
    +mpz_t q = new mpz_t();
    +gmp_lib.mpz_init(q);
    +
    +// Set q = trunc(n / 2^2).
    +gmp_lib.mpz_tdiv_q_2exp(q, n, 2U);
    +
    +// Assert that q is trunc(10001 / 4).
    +Assert.IsTrue(gmp_lib.mpz_get_si(q) == 2500);
    +
    +// Release unmanaged memory allocated for n and q.
    +gmp_lib.mpz_clears(n, q, null);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/746d102a-5f3e-6142-b02a-63f3cac385ab.htm b/docs/html/746d102a-5f3e-6142-b02a-63f3cac385ab.htm new file mode 100644 index 0000000..937962d --- /dev/null +++ b/docs/html/746d102a-5f3e-6142-b02a-63f3cac385ab.htm @@ -0,0 +1,101 @@ +gmp_lib.mpn_gcdext Method
    Click or drag to resize
    gmp_libmpn_gcdext Method
    + Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_size_t mpn_gcdext(
    +	mp_ptr gp,
    +	mp_ptr sp,
    +	ptr<mp_size_t> sn,
    +	mp_ptr up,
    +	mp_size_t un,
    +	mp_ptr vp,
    +	mp_size_t vn
    +)

    Parameters

    gp
    Type: Math.Gmp.Nativemp_ptr
    The fisrt result operand.
    sp
    Type: Math.Gmp.Nativemp_ptr
    The second result operand.
    sn
    Type: Math.Gmp.Nativeptrmp_size_t
    Pointer to the number of limbs of sp.
    up
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    un
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of up.
    vp
    Type: Math.Gmp.Nativemp_ptr
    The second operand integer.
    vn
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of vp.

    Return Value

    Type: mp_size_t
    The number of limbs of gp.
    Remarks

    + Let U be defined by {up, un} + and let V be defined by {vp, vn}. +

    + The second cofactor T is not computed but can easily be obtained from (G - U * S) / V (the division will be exact). + It is required that unvn > 0, + and the most significant limb of {vp, vn} must be non-zero. +

    + Store G at gp and let the return value define its limb count. + Store S at sp and let |sn.Value| define its limb count. + S can be negative; when this happens sn.Value will be negative. + The area at gp should have room for vn limbs + and the area at sp should have room for vn + 1 limbs. +

    + Both source operands are destroyed. +

    + Compatibility notes: GMP 4.3.0 and 4.3.1 defined S less strictly. + Earlier as well as later GMP releases define S as described here. + GMP releases before GMP 4.3.0 required additional space for both input and output areas. + More precisely, the areas {up, un + 1} and + {vp, vn + 1} were destroyed (i.e. the operands + plus an extra limb past the end of each), and the areas pointed to by gp + and sp should each have room for un + 1 limbs. +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr up = new mp_ptr(new uint[] { 0x40000000, 0x00000000 });
    +mp_ptr vp = new mp_ptr(new uint[] { 0x00000000, 0x00000001 });
    +mp_ptr gp = new mp_ptr(new uint[vp.Size * (IntPtr.Size / 4)]);
    +mp_ptr sp = new mp_ptr(new uint[(vp.Size + 1) * (IntPtr.Size / 4)]);
    +mp_ptr result = new mp_ptr(new uint[] { 0x40000000, 0x00000000 });
    +mp_ptr cofactor = new mp_ptr(new uint[] { 0x00000001, 0x00000000, 0x00000000 });
    +
    +// Set gp = gcd(up, vp).
    +ptr<mp_size_t> sn = new ptr<mp_size_t>(0);
    +mp_size_t size = gmp_lib.mpn_gcdext(gp, sp, sn, up, up.Size, vp, vp.Size);
    +
    +// Assert result.
    +Assert.IsTrue(size == 1);
    +Assert.IsTrue(gp.SequenceEqual(result));
    +Assert.IsTrue(sn.Value == 1);
    +Assert.IsTrue(sp.SequenceEqual(cofactor));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(gp, up, vp, sp, result, cofactor);
    See Also
    \ No newline at end of file diff --git a/docs/html/74e22b4c-fa79-f5f9-b752-da41bd427f37.htm b/docs/html/74e22b4c-fa79-f5f9-b752-da41bd427f37.htm new file mode 100644 index 0000000..b10a617 --- /dev/null +++ b/docs/html/74e22b4c-fa79-f5f9-b752-da41bd427f37.htm @@ -0,0 +1,50 @@ +gmp_lib.mpz_get_d_2exp Method
    Click or drag to resize
    gmp_libmpz_get_d_2exp Method
    + Convert op to a double, truncating if necessary (i.e. rounding towards zero), and returning the exponent separately. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static double mpz_get_d_2exp(
    +	ref int exp,
    +	mpz_t op
    +)

    Parameters

    exp
    Type: SystemInt32
    The returned exponent.
    op
    Type: Math.Gmp.Nativempz_t
    The integer.

    Return Value

    Type: Double
    op as a double, truncating if necessary (i.e. rounding towards zero).
    Remarks

    + The return value is in the range 0.5 ≤ |d| < 1 and the exponent is stored to exp. + d x 2^exp is the (truncated) op value. + If op is zero, the return value is 0.0 and 0 is stored to exp. +

    + This is similar to the standard C frexp function. +

    Examples
    // Create, initialize, and set the value of x to 2^20.
    +mpz_t x = new mpz_t();
    +char_ptr value = new char_ptr("100000000000000000000");
    +gmp_lib.mpz_init_set_str(x, value, 2);
    +
    +// Assert that x is equal to 0.5^21.
    +int exp = 0;
    +Assert.IsTrue(gmp_lib.mpz_get_d_2exp(ref exp, x) == 0.5D);
    +Assert.IsTrue(exp == 21);
    +
    +// Release unmanaged memory allocated for x and the string value.
    +gmp_lib.mpz_clear(x);
    +gmp_lib.free(value);
    See Also
    \ No newline at end of file diff --git a/docs/html/75f2a84e-44f3-b7cc-e6ad-392111d5b9cc.htm b/docs/html/75f2a84e-44f3-b7cc-e6ad-392111d5b9cc.htm new file mode 100644 index 0000000..cb4b400 --- /dev/null +++ b/docs/html/75f2a84e-44f3-b7cc-e6ad-392111d5b9cc.htm @@ -0,0 +1,64 @@ +gmp_lib.mpn_divexact_by3 Method
    Click or drag to resize
    gmp_libmpn_divexact_by3 Method
    + Divide {sp, n} by 3, expecting it to divide exactly, and writing the result to {rp, n}. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_limb_t mpn_divexact_by3(
    +	mp_ptr rp,
    +	mp_ptr sp,
    +	mp_size_t n
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    sp
    Type: Math.Gmp.Nativemp_ptr
    The operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs in sp.

    Return Value

    Type: mp_limb_t
    If 3 divides exactly, the return value is zero and the result is the quotient. If not, the return value is non-zero and the result won’t be anything useful.
    Remarks

    mpn_divexact_by3c(mp_ptr, mp_ptr, mp_size_t, mp_limb_t) takes an initial carry parameter, which can be the return value from a previous call, + so a large calculation can be done piece by piece from low to high. + mpn_divexact_by3(mp_ptr, mp_ptr, mp_size_t) is simply a macro calling mpn_divexact_by3c(mp_ptr, mp_ptr, mp_size_t, mp_limb_t) with a 0 carry parameter. +

    + These routines use a multiply-by-inverse and will be faster than mpn_divrem_1(mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_limb_t) on CPUs with + fast multiplication but slow division. +

    + The source a, result q, size n, initial carry i, and return value c satisfy + c * b^n + a - i = 3 * q, where b = 2^mp_bits_per_limb. + The return c is always 0, 1 or 2, and the initial carry i must also be 0, + 1 or 2 (these are both borrows really). When c = 0 clearly q = (a - i) / 3. + When c != 0, the remainder (a - i) mod 3 is given by 3 - c, because + b ≡ 1 mod 3 (when mp_bits_per_limb is even, which is always so currently). +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
    +mp_ptr rp = new mp_ptr(new uint[2]);
    +mp_ptr result = new mp_ptr(new uint[] { 0x55555555, 0x00005555 });
    +
    +// Set rp = sp / 3.
    +mp_limb_t remainder = gmp_lib.mpn_divexact_by3(rp, sp, sp.Size);
    +
    +// Assert result of operation.
    +Assert.IsTrue(remainder == 0);
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, sp, result);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/76481715-8a8b-e739-905c-f0d83de503ab.htm b/docs/html/76481715-8a8b-e739-905c-f0d83de503ab.htm new file mode 100644 index 0000000..57ca50f --- /dev/null +++ b/docs/html/76481715-8a8b-e739-905c-f0d83de503ab.htm @@ -0,0 +1,8 @@ +char_ptr.Zero Field
    char_ptrZero Field
    + Gets a null char_ptr. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static readonly char_ptr Zero

    Field Value

    Type: char_ptr
    See Also
    \ No newline at end of file diff --git a/docs/html/764c23ab-f2fe-b3e4-68a4-4a27fb6dc6b0.htm b/docs/html/764c23ab-f2fe-b3e4-68a4-4a27fb6dc6b0.htm new file mode 100644 index 0000000..f2d20a8 --- /dev/null +++ b/docs/html/764c23ab-f2fe-b3e4-68a4-4a27fb6dc6b0.htm @@ -0,0 +1,17 @@ +mp_size_t.Equals Method (Object)
    mp_size_tEquals Method (Object)
    + Returns a value indicating whether this instance is equal to a specified object. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override bool Equals(
    +	Object obj
    +)

    Parameters

    obj
    Type: SystemObject
    An object to compare with this instance.

    Return Value

    Type: Boolean
    True if obj is an instance of mp_size_t and equals the value of this instance; otherwise, False.
    See Also
    \ No newline at end of file diff --git a/docs/html/76b37dae-ecff-2bd9-2e80-002354a7dddc.htm b/docs/html/76b37dae-ecff-2bd9-2e80-002354a7dddc.htm new file mode 100644 index 0000000..ce86852 --- /dev/null +++ b/docs/html/76b37dae-ecff-2bd9-2e80-002354a7dddc.htm @@ -0,0 +1,5 @@ +FILE Fields
    FILE Fields

    The FILE type exposes the following members.

    Fields
    +   + NameDescription
    Public fieldValue
    + File pointer in unmanaged memory. +
    Top
    See Also
    \ No newline at end of file diff --git a/docs/html/772064e8-3ec1-840e-c79c-78f478321b6c.htm b/docs/html/772064e8-3ec1-840e-c79c-78f478321b6c.htm new file mode 100644 index 0000000..f8b3895 --- /dev/null +++ b/docs/html/772064e8-3ec1-840e-c79c-78f478321b6c.htm @@ -0,0 +1,55 @@ +gmp_lib.mpz_fdiv_r_ui Method
    Click or drag to resize
    gmp_libmpz_fdiv_r_ui Method
    + Set the remainder r to n - q * d where q = floor(n / d), and return |r|. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static long mpz_fdiv_r_ui(
    +	mpz_t r,
    +	mpz_t n,
    +	uint d
    +)

    Parameters

    r
    Type: Math.Gmp.Nativempz_t
    The result remainder integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: SystemUInt32
    The denominator integer.

    Return Value

    Type: Int64
    Return |r|.
    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10000);
    +
    +// Create, initialize, and set the value of r to 0.
    +mpz_t r = new mpz_t();
    +gmp_lib.mpz_init(r);
    +
    +// Set r = n - 3 * floor(n / 3), and return |r|.
    +Assert.IsTrue(gmp_lib.mpz_fdiv_r_ui(r, n, 3U) == 1U);
    +
    +// Assert that r is 1.
    +Assert.IsTrue(gmp_lib.mpz_get_si(r) == 1);
    +
    +// Release unmanaged memory allocated for n and r.
    +gmp_lib.mpz_clears(n, r, null);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/772c3bd8-b9ec-225d-3d98-e17ae89d4294.htm b/docs/html/772c3bd8-b9ec-225d-3d98-e17ae89d4294.htm new file mode 100644 index 0000000..1c4a86e --- /dev/null +++ b/docs/html/772c3bd8-b9ec-225d-3d98-e17ae89d4294.htm @@ -0,0 +1,14 @@ +mpf_t._mp_prec Property
    mpf_t_mp_prec Property
    + The precision of the mantissa, in limbs. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public int _mp_prec { get; }

    Property Value

    Type: Int32
    Remarks

    + In any calculation the aim is to produce _mp_prec limbs of result (the most significant being non-zero). +

    See Also
    \ No newline at end of file diff --git a/docs/html/77413435-917b-2cdc-cfde-d0891b6ede82.htm b/docs/html/77413435-917b-2cdc-cfde-d0891b6ede82.htm new file mode 100644 index 0000000..bc9b4fc --- /dev/null +++ b/docs/html/77413435-917b-2cdc-cfde-d0891b6ede82.htm @@ -0,0 +1,19 @@ +FILE.Inequality Operator
    FILEInequality Operator
    + Gets a value that indicates whether the two argument values are different. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static bool operator !=(
    +	FILE value1,
    +	FILE value2
    +)

    Parameters

    value1
    Type: Math.Gmp.NativeFILE
    A FILE value.
    value2
    Type: Math.Gmp.NativeFILE
    A FILE value.

    Return Value

    Type: Boolean
    True if the two FILE are different, and False otherwise.
    See Also
    \ No newline at end of file diff --git a/docs/html/77d1beb2-2aed-58e8-dc50-bba2ff56afee.htm b/docs/html/77d1beb2-2aed-58e8-dc50-bba2ff56afee.htm new file mode 100644 index 0000000..e3bf13b --- /dev/null +++ b/docs/html/77d1beb2-2aed-58e8-dc50-bba2ff56afee.htm @@ -0,0 +1,17 @@ +char_ptr.Equals Method (Object)
    char_ptrEquals Method (Object)
    + Returns a value indicating whether this instance is equal to a specified object. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override bool Equals(
    +	Object obj
    +)

    Parameters

    obj
    Type: SystemObject
    An object to compare with this instance.

    Return Value

    Type: Boolean
    True if obj is an instance of char_ptr and equals the value of this instance; otherwise, False.
    See Also
    \ No newline at end of file diff --git a/docs/html/77eccd6b-888f-b3a8-0800-ead4af162af0.htm b/docs/html/77eccd6b-888f-b3a8-0800-ead4af162af0.htm new file mode 100644 index 0000000..abbe992 --- /dev/null +++ b/docs/html/77eccd6b-888f-b3a8-0800-ead4af162af0.htm @@ -0,0 +1,9 @@ +mpf_t.ToString Method
    mpf_tToString Method
    + Return the string representation of the float. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override string ToString()

    Return Value

    Type: String
    The string representation of the float.
    See Also
    \ No newline at end of file diff --git a/docs/html/77fdf32b-986d-4df3-3c76-022e3e3fbb98.htm b/docs/html/77fdf32b-986d-4df3-3c76-022e3e3fbb98.htm new file mode 100644 index 0000000..2f56136 --- /dev/null +++ b/docs/html/77fdf32b-986d-4df3-3c76-022e3e3fbb98.htm @@ -0,0 +1,60 @@ +gmp_lib.mpn_addmul_1 Method
    Click or drag to resize
    gmp_libmpn_addmul_1 Method
    + Multiply {s1p, n} and s2limb, and add the n least significant limbs of the product to {rp, n} and write the result to rp. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static mp_limb_t mpn_addmul_1(
    +	mp_ptr rp,
    +	mp_ptr s1p,
    +	mp_size_t n,
    +	mp_limb_t s2limb
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    s1p
    Type: Math.Gmp.Nativemp_ptr
    The first operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs in s1p.
    s2limb
    Type: Math.Gmp.Nativemp_limb_t
    The second operand integer.

    Return Value

    Type: mp_limb_t
    Return the most significant limb of the product, plus carry-out from the addition.
    Remarks

    + {s1p, n} and {rp, n} are allowed + to overlap provided rps1p. +

    + This is a low-level function that is a building block for general multiplication as well as other operations in GMP. + It is written in assembly for most CPUs. +

    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
    +mp_ptr rp = new mp_ptr(new uint[] { 0x00000002, 0x00000000 });
    +mp_ptr result = new mp_ptr(new uint[] { 0x00000000, 0x00000000 });
    +
    +// Set rp += s1 * 2.
    +mp_limb_t carry = gmp_lib.mpn_addmul_1(rp, s1p, s1p.Size, 2);
    +
    +// Assert result of operation.
    +Assert.IsTrue(carry == 0x02);
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, s1p, result);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/7828ce92-079b-da4d-aab2-1742209287fb.htm b/docs/html/7828ce92-079b-da4d-aab2-1742209287fb.htm new file mode 100644 index 0000000..8bdf01e --- /dev/null +++ b/docs/html/7828ce92-079b-da4d-aab2-1742209287fb.htm @@ -0,0 +1,50 @@ +gmp_lib.mpq_equal Method
    Click or drag to resize
    gmp_libmpq_equal Method
    + Return non-zero if op1 and op2 are equal, zero if they are non-equal. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpq_equal(
    +	mpq_t op1,
    +	mpq_t op2
    +)

    Parameters

    op1
    Type: Math.Gmp.Nativempq_t
    The first operand rational.
    op2
    Type: Math.Gmp.Nativempq_t
    The second operand rational.

    Return Value

    Type: Int32
    Return non-zero if op1 and op2 are equal, zero if they are non-equal.
    Remarks

    + Although mpq_cmp(mpq_t, mpq_t) can be used for the same purpose, this function is much faster. +

    Examples
    // Create, initialize, and set the value of op1 to 1 / 2.
    +mpq_t op1 = new mpq_t();
    +gmp_lib.mpq_init(op1);
    +gmp_lib.mpq_set_si(op1, 1, 2U);
    +
    +// Create, initialize, and set the value of op2 to 1 / 3.
    +mpq_t op2 = new mpq_t();
    +gmp_lib.mpq_init(op2);
    +gmp_lib.mpq_set_si(op2, 1, 3U);
    +
    +// Assert that op1 != op2.
    +Assert.IsTrue(gmp_lib.mpq_equal(op1, op2) == 0);
    +
    +// Release unmanaged memory allocated for op1 and op2.
    +gmp_lib.mpq_clears(op1, op2, null);
    See Also
    \ No newline at end of file diff --git a/docs/html/78443f19-f0c6-4a1f-1eed-a815b734e981.htm b/docs/html/78443f19-f0c6-4a1f-1eed-a815b734e981.htm new file mode 100644 index 0000000..12d9676 --- /dev/null +++ b/docs/html/78443f19-f0c6-4a1f-1eed-a815b734e981.htm @@ -0,0 +1,48 @@ +gmp_lib.mpn_copyd Method
    Click or drag to resize
    gmp_libmpn_copyd Method
    + Copy from {s1p, n} to {rp, n}, decreasingly. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpn_copyd(
    +	mp_ptr rp,
    +	mp_ptr s1p,
    +	mp_size_t n
    +)

    Parameters

    rp
    Type: Math.Gmp.Nativemp_ptr
    The result integer.
    s1p
    Type: Math.Gmp.Nativemp_ptr
    The operand integer.
    n
    Type: Math.Gmp.Nativemp_size_t
    The number of limbs of s1p.
    Examples
    // Create multi-precision operands, and expected result.
    +mp_ptr sp = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 });
    +mp_ptr rp = new mp_ptr(new uint[2]);
    +mp_ptr result = new mp_ptr(new uint[] { 0xf0f0f0f0, 0xf0f0f0f0 });
    +
    +// Set rp = sp.
    +gmp_lib.mpn_copyd(rp, sp, sp.Size);
    +
    +// Assert result of operation.
    +Assert.IsTrue(rp.SequenceEqual(result));
    +
    +// Release unmanaged memory.
    +gmp_lib.free(rp, sp, result);
    See Also
    \ No newline at end of file diff --git a/docs/html/784c4122-3a62-f338-0e4a-88b6a69a1e9e.htm b/docs/html/784c4122-3a62-f338-0e4a-88b6a69a1e9e.htm new file mode 100644 index 0000000..60e024d --- /dev/null +++ b/docs/html/784c4122-3a62-f338-0e4a-88b6a69a1e9e.htm @@ -0,0 +1,13 @@ +size_t Explicit Conversion (size_t to UInt16)
    size_t  Conversion (size_t to UInt16)
    + Converts a size_t value to a UInt16 value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator ushort (
    +	size_t value
    +)

    Parameters

    value
    Type: Math.Gmp.Nativesize_t
    An size_t value.

    Return Value

    Type: UInt16
    A UInt16 value.
    See Also
    \ No newline at end of file diff --git a/docs/html/78fdf4c2-15a1-fdab-23fa-806cdf3dc983.htm b/docs/html/78fdf4c2-15a1-fdab-23fa-806cdf3dc983.htm new file mode 100644 index 0000000..0602796 --- /dev/null +++ b/docs/html/78fdf4c2-15a1-fdab-23fa-806cdf3dc983.htm @@ -0,0 +1,13 @@ +mp_exp_t Explicit Conversion (UInt32 to mp_exp_t)
    mp_exp_t  Conversion (UInt32 to mp_exp_t)
    + Converts a UInt32 value to an mp_exp_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static explicit operator mp_exp_t (
    +	uint value
    +)

    Parameters

    value
    Type: SystemUInt32
    A UInt32 value.

    Return Value

    Type: mp_exp_t
    An mp_exp_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/7924a2a3-75c1-0aa9-636f-4772d74a723f.htm b/docs/html/7924a2a3-75c1-0aa9-636f-4772d74a723f.htm new file mode 100644 index 0000000..1792e47 --- /dev/null +++ b/docs/html/7924a2a3-75c1-0aa9-636f-4772d74a723f.htm @@ -0,0 +1,16 @@ +gmp_lib.free Method (mp_ptr[])
    gmp_libfree Method (mp_ptr)
    + De-allocate the space pointed to by ptrs. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void free(
    +	params mp_ptr[] ptrs
    +)

    Parameters

    ptrs
    Type: Math.Gmp.Nativemp_ptr
    Pointers to previously allocated memory.
    Remarks
    \ No newline at end of file diff --git a/docs/html/7ae8e775-5b2d-4ce0-c45b-5afd1b66ac62.htm b/docs/html/7ae8e775-5b2d-4ce0-c45b-5afd1b66ac62.htm new file mode 100644 index 0000000..8dd85f0 --- /dev/null +++ b/docs/html/7ae8e775-5b2d-4ce0-c45b-5afd1b66ac62.htm @@ -0,0 +1,9 @@ +mp_limb_t.ToString Method
    mp_limb_tToString Method
    + Gets the string representation of the mp_limb_t. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override string ToString()

    Return Value

    Type: String
    The string representation of the mp_limb_t.
    See Also
    \ No newline at end of file diff --git a/docs/html/7aee9fae-9d14-72be-6d0f-0f9c4a863fe5.htm b/docs/html/7aee9fae-9d14-72be-6d0f-0f9c4a863fe5.htm new file mode 100644 index 0000000..dbe5b2e --- /dev/null +++ b/docs/html/7aee9fae-9d14-72be-6d0f-0f9c4a863fe5.htm @@ -0,0 +1,62 @@ +gmp_lib.mpz_cdiv_qr_ui Method
    Click or drag to resize
    gmp_libmpz_cdiv_qr_ui Method
    + Set quotient q to ceiling(n / d), set the remainder r to n - q * d, and return |r|. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static uint mpz_cdiv_qr_ui(
    +	mpz_t q,
    +	mpz_t r,
    +	mpz_t n,
    +	uint d
    +)

    Parameters

    q
    Type: Math.Gmp.Nativempz_t
    The result quotient integer.
    r
    Type: Math.Gmp.Nativempz_t
    The result remainder integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: SystemUInt32
    The denominator integer.

    Return Value

    Type: UInt32
    Return |r|.
    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10000);
    +
    +// Create, initialize, and set the values of q and r to 0.
    +mpz_t q = new mpz_t();
    +mpz_t r = new mpz_t();
    +gmp_lib.mpz_inits(q, r, null);
    +
    +// Set q = ceiling(n / 3), r = n - d * q, and return r.
    +Assert.IsTrue(gmp_lib.mpz_cdiv_qr_ui(q, r, n, 3U) == 2U);
    +
    +// Assert that q is 3334, and that r is -2.
    +Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334);
    +Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2);
    +
    +// Release unmanaged memory allocated for n, q, and r.
    +gmp_lib.mpz_clears(n, q, r, null);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/7b541895-53a8-b335-32de-d5b2224ff0f7.htm b/docs/html/7b541895-53a8-b335-32de-d5b2224ff0f7.htm new file mode 100644 index 0000000..e02fa8f --- /dev/null +++ b/docs/html/7b541895-53a8-b335-32de-d5b2224ff0f7.htm @@ -0,0 +1,41 @@ +gmp_lib.gmp_urandomb_ui Method
    Click or drag to resize
    gmp_libgmp_urandomb_ui Method
    + Generate a uniformly distributed random number of n bits, i.e. in the range 0 to 2^n - 1 inclusive. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static uint gmp_urandomb_ui(
    +	gmp_randstate_t state,
    +	uint n
    +)

    Parameters

    state
    Type: Math.Gmp.Nativegmp_randstate_t
    The state of the random number generator to use.
    n
    Type: SystemUInt32
    The numbe rof bits.

    Return Value

    Type: UInt32
    The generated random number.
    Remarks

    n must be less than or equal to the number of bits in an unsigned long. +

    + In .NET, n must be less than or equal to the number of bits in an unsigned 32-bit integer. +

    Examples
    // Create, initialize, and seed a new random number generator.
    +gmp_randstate_t state = new gmp_randstate_t();
    +gmp_lib.gmp_randinit_mt(state);
    +gmp_lib.gmp_randseed_ui(state, 100000U);
    +
    +// Generate a random integer in the range [0, 2^8-1].
    +uint rand = gmp_lib.gmp_urandomb_ui(state, 8);
    +
    +// Free all memory occupied by state.
    +gmp_lib.gmp_randclear(state);
    See Also
    \ No newline at end of file diff --git a/docs/html/7c9b8744-cc4a-e2c1-659f-6da60e92bb78.htm b/docs/html/7c9b8744-cc4a-e2c1-659f-6da60e92bb78.htm new file mode 100644 index 0000000..3ea74bd --- /dev/null +++ b/docs/html/7c9b8744-cc4a-e2c1-659f-6da60e92bb78.htm @@ -0,0 +1,13 @@ +mp_size_t Implicit Conversion (UInt16 to mp_size_t)
    mp_size_t  Conversion (UInt16 to mp_size_t)
    + Converts a UInt16 value to an mp_size_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator mp_size_t (
    +	ushort value
    +)

    Parameters

    value
    Type: SystemUInt16
    A UInt16 value.

    Return Value

    Type: mp_size_t
    An mp_size_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/7da3b40f-ae2c-63c5-0157-9b51d54cf6cb.htm b/docs/html/7da3b40f-ae2c-63c5-0157-9b51d54cf6cb.htm new file mode 100644 index 0000000..2b25ac0 --- /dev/null +++ b/docs/html/7da3b40f-ae2c-63c5-0157-9b51d54cf6cb.htm @@ -0,0 +1,36 @@ +gmp_lib.mpz_init_set_ui Method
    Click or drag to resize
    gmp_libmpz_init_set_ui Method
    + Initialize rop with limb space and set the initial numeric value from op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_init_set_ui(
    +	mpz_t rop,
    +	uint op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The destination integer.
    op
    Type: SystemUInt32
    The source integer.
    Examples
    // Create, initialize, and set the value of x to 10.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init_set_ui(x, 10U);
    +
    +// Assert that the value of x is 10.
    +Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 10U);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpz_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/7daadb71-9f36-2848-86c4-ba1fba25fcfd.htm b/docs/html/7daadb71-9f36-2848-86c4-ba1fba25fcfd.htm new file mode 100644 index 0000000..a00f7ea --- /dev/null +++ b/docs/html/7daadb71-9f36-2848-86c4-ba1fba25fcfd.htm @@ -0,0 +1,43 @@ +gmp_lib.mpz_set_ui Method
    Click or drag to resize
    gmp_libmpz_set_ui Method
    + Set the value of rop from op. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_set_ui(
    +	mpz_t rop,
    +	uint op
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempz_t
    The destination integer.
    op
    Type: SystemUInt32
    The source integer.
    Examples
    // Create and initialize a new integer x.
    +mpz_t x = new mpz_t();
    +gmp_lib.mpz_init(x);
    +
    +// Set the value of x to 10.
    +gmp_lib.mpz_set_ui(x, 10U);
    +
    +// Assert that the value of x is 10.
    +Assert.IsTrue(gmp_lib.mpz_get_ui(x) == 10U);
    +
    +// Release unmanaged memory allocated for x.
    +gmp_lib.mpz_clear(x);
    See Also
    \ No newline at end of file diff --git a/docs/html/7dbd9949-90ab-2b31-978d-9fde0a2ba7ee.htm b/docs/html/7dbd9949-90ab-2b31-978d-9fde0a2ba7ee.htm new file mode 100644 index 0000000..3a60b95 --- /dev/null +++ b/docs/html/7dbd9949-90ab-2b31-978d-9fde0a2ba7ee.htm @@ -0,0 +1,13 @@ +mp_limb_t Implicit Conversion (Byte to mp_limb_t)
    mp_limb_t  Conversion (Byte to mp_limb_t)
    + Converts a Byte value to an mp_limb_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator mp_limb_t (
    +	byte value
    +)

    Parameters

    value
    Type: SystemByte
    A Byte value.

    Return Value

    Type: mp_limb_t
    An mp_limb_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/7dfe367e-74d3-e782-860b-2314da9c44cf.htm b/docs/html/7dfe367e-74d3-e782-860b-2314da9c44cf.htm new file mode 100644 index 0000000..430d75f --- /dev/null +++ b/docs/html/7dfe367e-74d3-e782-860b-2314da9c44cf.htm @@ -0,0 +1,56 @@ +gmp_lib.mpz_sizeinbase Method
    Click or drag to resize
    gmp_libmpz_sizeinbase Method
    + Return the size of op measured in number of digits in the given base. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static size_t mpz_sizeinbase(
    +	mpz_t op,
    +	int base
    +)

    Parameters

    op
    Type: Math.Gmp.Nativempz_t
    The operand integer
    base
    Type: SystemInt32
    The base.

    Return Value

    Type: size_t
    The size of op measured in number of digits in the given base.
    Remarks

    base can vary from 2 to 62. + The sign of op is ignored, just the absolute value is used. + The result will be either exact or 1 too big. + If base is a power of 2, the result is always exact. + If op is zero the return value is always 1. +

    + This function can be used to determine the space required when converting op to a string. + The right amount of allocation is normally two more than the value returned by mpz_sizeinbase(mpz_t, Int32), + one extra for a minus sign and one for the null-terminator. +

    + It will be noted that mpz_sizeinbase(op, 2) can be used to locate the most + significant 1 bit in op, counting from 1. + (Unlike the bitwise functions which start from 0, + see GNU MP - Logical and Bit Manipulation Functions.) +

    Examples
    // Create, initialize, and set the value of op to 10000.
    +mpz_t op = new mpz_t();
    +gmp_lib.mpz_init_set_si(op, 10000);
    +
    +// Assert size in different bases.
    +Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 2) == 14);
    +Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 8) == 5);
    +Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 10) == 5);
    +Assert.IsTrue(gmp_lib.mpz_sizeinbase(op, 16) == 4);
    +
    +// Release unmanaged memory allocated for op.
    +gmp_lib.mpz_clear(op);
    See Also
    \ No newline at end of file diff --git a/docs/html/7ef82a61-e43a-78c7-a28f-8f2d0a5f59b1.htm b/docs/html/7ef82a61-e43a-78c7-a28f-8f2d0a5f59b1.htm new file mode 100644 index 0000000..874e8bc --- /dev/null +++ b/docs/html/7ef82a61-e43a-78c7-a28f-8f2d0a5f59b1.htm @@ -0,0 +1,16 @@ +gmp_lib.gmp_randclear Method
    Click or drag to resize
    gmp_libgmp_randclear Method
    + Free all memory occupied by state. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void gmp_randclear(
    +	gmp_randstate_t state
    +)

    Parameters

    state
    Type: Math.Gmp.Nativegmp_randstate_t
    A state.
    See Also
    \ No newline at end of file diff --git a/docs/html/7f89c102-d1eb-2dab-0e6e-061893309c4b.htm b/docs/html/7f89c102-d1eb-2dab-0e6e-061893309c4b.htm new file mode 100644 index 0000000..4450985 --- /dev/null +++ b/docs/html/7f89c102-d1eb-2dab-0e6e-061893309c4b.htm @@ -0,0 +1,70 @@ +gmp_lib.mpz_cdiv_qr Method
    Click or drag to resize
    gmp_libmpz_cdiv_qr Method
    + Set the quotient q to ceiling(n / d), and set the remainder r to n - q * d. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_cdiv_qr(
    +	mpz_t q,
    +	mpz_t r,
    +	mpz_t n,
    +	mpz_t d
    +)

    Parameters

    q
    Type: Math.Gmp.Nativempz_t
    The result quotient integer.
    r
    Type: Math.Gmp.Nativempz_t
    The result remainder integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: Math.Gmp.Nativempz_t
    The denominator integer.
    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10000);
    +
    +// Create, initialize, and set the value of d to 3.
    +mpz_t d = new mpz_t();
    +gmp_lib.mpz_init_set_si(d, 3);
    +
    +// Create, initialize, and set the values of q and r to 0.
    +mpz_t q = new mpz_t();
    +mpz_t r = new mpz_t();
    +gmp_lib.mpz_inits(q, r, null);
    +
    +// Set q = ceiling(n / 3) and r = n - d * q.
    +gmp_lib.mpz_cdiv_qr(q, r, n, d);
    +
    +// Assert that q is 3334, and that r is -2.
    +Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3334);
    +Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2);
    +
    +// Release unmanaged memory allocated for n, d, q, and r.
    +gmp_lib.mpz_clears(n, d, q, r, null);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/8031c594-b2b2-fa62-7088-00b6fe92f88e.htm b/docs/html/8031c594-b2b2-fa62-7088-00b6fe92f88e.htm new file mode 100644 index 0000000..55a7f87 --- /dev/null +++ b/docs/html/8031c594-b2b2-fa62-7088-00b6fe92f88e.htm @@ -0,0 +1,42 @@ +gmp_lib.gmp_vprintf Method
    Click or drag to resize
    gmp_libgmp_vprintf Method
    + Print to the standard output stdout. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int gmp_vprintf(
    +	string fmt,
    +	params Object[] ap
    +)

    Parameters

    fmt
    Type: SystemString
    Format string. See Formatted Output Strings.
    ap
    Type: SystemObject
    Arguments.

    Return Value

    Type: Int32
    Return the number of characters written, or -1 if an error occurred.
    Examples
    mpz_t z = "123456";
    +mpq_t q = "123/456";
    +mpf_t f = "12345e6";
    +mp_limb_t m = 123456;
    +
    +// Print to standard output.
    +Assert.IsTrue(gmp_lib.gmp_vprintf("%Zd - %QX - %Fa - %Mo", z, q, f, m) == 42);
    +
    +// Release unmanaged memory.
    +gmp_lib.mpz_clear(z)
    +gmp_lib.mpq_clear(q)
    +gmp_lib.mpf_clear(f)
    See Also
    \ No newline at end of file diff --git a/docs/html/823b356e-0731-c9ca-0b37-660b6eb9ee7c.htm b/docs/html/823b356e-0731-c9ca-0b37-660b6eb9ee7c.htm new file mode 100644 index 0000000..f31973b --- /dev/null +++ b/docs/html/823b356e-0731-c9ca-0b37-660b6eb9ee7c.htm @@ -0,0 +1,71 @@ +gmp_lib.mpf_set_str Method
    Click or drag to resize
    gmp_libmpf_set_str Method
    + Set the value of rop from the string in str. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static int mpf_set_str(
    +	mpf_t rop,
    +	char_ptr str,
    +	int base
    +)

    Parameters

    rop
    Type: Math.Gmp.Nativempf_t
    The result float.
    str
    Type: Math.Gmp.Nativechar_ptr
    The input string.
    base
    Type: SystemInt32
    The base.

    Return Value

    Type: Int32
    This function returns 0 if the entire string is a valid number in base base. Otherwise it returns -1.
    Remarks

    + The string is of the form "M@N" or, if the base is 10 or less, + alternatively "MeN". + "M" is the mantissa and "N" is the exponent. + The mantissa is always in the specified base. + The exponent is either in the specified base or, if base is negative, in decimal. + The decimal point expected is taken from the current locale, on systems providing localeconv. +

    + The argument base may be in the ranges 2 to 62, or -62 to -2. + Negative values are used to specify that the exponent is in decimal. +

    + For bases up to 36, case is ignored; upper-case and lower-case letters have the same value; + for bases 37 to 62, upper-case letter represent the usual 10..35 while lower-case + letter represent 36..61. +

    + Unlike the corresponding mpz function, the base will not be determined from the leading characters + of the string if base is 0. This is so that numbers like "0.23" are not interpreted as octal. +

    + White space is allowed in the string, and is simply ignored. + [This is not really true; white-space is ignored in the beginning of the string and within the mantissa, + but not in other places, such as after a minus sign or in the exponent. + We are considering changing the definition of this function, making it fail when there is any white-space + in the input, since that makes a lot of sense. + Please tell us your opinion about this change. + Do you really want it to accept "3 14" as meaning 314 as it does now?] +

    Examples
    // Create, initialize, and set a new floating-point number x to 0.0234.
    +mpf_t x = new mpf_t();
    +gmp_lib.mpf_init(x);
    +char_ptr value = new char_ptr("234e-4");
    +gmp_lib.mpf_set_str(x, value, 10);
    +
    +// Assert that x is 40.
    +Assert.IsTrue(x.ToString() == "0.234e-1");
    +
    +// Release unmanaged memory allocated for x and y.
    +gmp_lib.mpf_clear(x);
    +gmp_lib.free(value);
    See Also
    \ No newline at end of file diff --git a/docs/html/82a3fa70-9dcd-a931-eb3e-18095e458891.htm b/docs/html/82a3fa70-9dcd-a931-eb3e-18095e458891.htm new file mode 100644 index 0000000..26dd360 --- /dev/null +++ b/docs/html/82a3fa70-9dcd-a931-eb3e-18095e458891.htm @@ -0,0 +1,13 @@ +mp_exp_t Implicit Conversion (Int32 to mp_exp_t)
    mp_exp_t  Conversion (Int32 to mp_exp_t)
    + Converts an Int32 value to an mp_exp_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator mp_exp_t (
    +	int value
    +)

    Parameters

    value
    Type: SystemInt32
    An Int32 value.

    Return Value

    Type: mp_exp_t
    An mp_exp_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/8320e5d8-1df9-ca26-3054-e4b93cc0f616.htm b/docs/html/8320e5d8-1df9-ca26-3054-e4b93cc0f616.htm new file mode 100644 index 0000000..429d81b --- /dev/null +++ b/docs/html/8320e5d8-1df9-ca26-3054-e4b93cc0f616.htm @@ -0,0 +1,53 @@ +gmp_lib.mpz_cdiv_r_2exp Method
    Click or drag to resize
    gmp_libmpz_cdiv_r_2exp Method
    + Set the remainder r to n - q * 2^b where q = ceiling(n / 2^b). +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static void mpz_cdiv_r_2exp(
    +	mpz_t r,
    +	mpz_t n,
    +	mp_bitcnt_t b
    +)

    Parameters

    r
    Type: Math.Gmp.Nativempz_t
    The result remainder integer.
    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    b
    Type: Math.Gmp.Nativemp_bitcnt_t
    The exponent of the power of two denominator.
    Examples
    // Create, initialize, and set the value of n to 10001.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10001);
    +
    +// Create, initialize, and set the value of r to 0.
    +mpz_t r = new mpz_t();
    +gmp_lib.mpz_init(r);
    +
    +// Set r = n - 2^2 * ceiling(n / 2^2)
    +gmp_lib.mpz_cdiv_r_2exp(r, n, 2U);
    +
    +// Assert that r is -3.
    +Assert.IsTrue(gmp_lib.mpz_get_si(r) == -3);
    +
    +// Release unmanaged memory allocated for n and r.
    +gmp_lib.mpz_clears(n, r, null);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/835b1c14-21a0-f806-1953-af0ddf068758.htm b/docs/html/835b1c14-21a0-f806-1953-af0ddf068758.htm new file mode 100644 index 0000000..470f9ef --- /dev/null +++ b/docs/html/835b1c14-21a0-f806-1953-af0ddf068758.htm @@ -0,0 +1,13 @@ +mp_exp_t Implicit Conversion (Int16 to mp_exp_t)
    mp_exp_t  Conversion (Int16 to mp_exp_t)
    + Converts an Int16 value to an mp_exp_t value. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static implicit operator mp_exp_t (
    +	short value
    +)

    Parameters

    value
    Type: SystemInt16
    An Int16 value.

    Return Value

    Type: mp_exp_t
    An mp_exp_t value.
    See Also
    \ No newline at end of file diff --git a/docs/html/8435af1d-e5e4-3e55-1024-449ff7b56ad4.htm b/docs/html/8435af1d-e5e4-3e55-1024-449ff7b56ad4.htm new file mode 100644 index 0000000..6b58642 --- /dev/null +++ b/docs/html/8435af1d-e5e4-3e55-1024-449ff7b56ad4.htm @@ -0,0 +1,36 @@ +gmp_lib.mpz_fdiv_ui Method
    Click or drag to resize
    gmp_libmpz_fdiv_ui Method
    + Return the remainder |r| where r = n - q * d, and where q = floor(n / d). +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public static long mpz_fdiv_ui(
    +	mpz_t n,
    +	uint d
    +)

    Parameters

    n
    Type: Math.Gmp.Nativempz_t
    The numerator integer.
    d
    Type: SystemUInt32
    The denominator integer.

    Return Value

    Type: Int64
    The remainder |r| where r = n - q * d, and where q = floor(n / d).
    Examples
    // Create, initialize, and set the value of n to 10000.
    +mpz_t n = new mpz_t();
    +gmp_lib.mpz_init_set_si(n, 10000);
    +
    +// Assert that returned value is |n - 3 * floor(n / 3)|.
    +Assert.IsTrue(gmp_lib.mpz_fdiv_ui(n, 3U) == 1U);
    +
    +// Release unmanaged memory allocated for n.
    +gmp_lib.mpz_clear(n);
    See Also

    Reference

    \ No newline at end of file diff --git a/docs/html/84492195-83e7-7738-6678-c299663dd02c.htm b/docs/html/84492195-83e7-7738-6678-c299663dd02c.htm new file mode 100644 index 0000000..e76c7ea --- /dev/null +++ b/docs/html/84492195-83e7-7738-6678-c299663dd02c.htm @@ -0,0 +1,9 @@ +char_ptr.GetHashCode Method
    char_ptrGetHashCode Method
    + Returns the hash code for this instance. +

    + Namespace: +  Math.Gmp.Native
    + Assembly: +  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
    Syntax
    public override int GetHashCode()

    Return Value

    Type: Int32
    A 32-bit signed integer hash code.
    See Also
    \ No newline at end of file diff --git a/docs/html/846f5c8a-6cba-433e-9f18-cde2ff5695cd.htm b/docs/html/846f5c8a-6cba-433e-9f18-cde2ff5695cd.htm new file mode 100644 index 0000000..efecfa1 --- /dev/null +++ b/docs/html/846f5c8a-6cba-433e-9f18-cde2ff5695cd.htm @@ -0,0 +1,22 @@ +Welcome to the GMP Native Interface for .NET Library
    Welcome to the GMP Native Interface for .NET Library

    + The GMP Native Interface for .NET Library exposes to .NET (through P-Invoke and .NET types) + all of the functionality of the + GNU MP Library + (version 6.1.2). It automatically loads at runtime the 32-bit or + 64-bit GNU MP library that matches the current CPU architecture, thus allowing building Visual Studio Projects for AnyCPU, + x86, or x64. It is based on the GNU MP "fat" build which automatically detects the current CPU type, and selects + any available assembly language code optimization for that CPU, thus providing optimal performance. +

    + Consider an example. + +

    C Standard + functions that are missing from the .NET framework. + Functions include among others: + + Both double and single precision functions are implemented. + All functions are static and their names follow the + C Standard. +

    + All functions have been thoroughly tested using a large set of unit tests that cover all + limit cases to guarantee that all functions behave as specified by the C standard. +

    See Also