Math.Gmp.Native/docs/html/846f5c8a-6cba-433e-9f18-cde...

35 lines
8.4 KiB
HTML

<html><head><meta http-equiv="X-UA-Compatible" content="IE=edge" /><link rel="shortcut icon" href="../icons/favicon.ico" /><link rel="stylesheet" type="text/css" href="../styles/branding.css" /><link rel="stylesheet" type="text/css" href="../styles/branding-en-US.css" /><script type="text/javascript" src="../scripts/branding.js"> </script><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Welcome to the GMP Native Interface for .NET Library</title><meta name="Language" content="en-us" /><meta name="System.Keywords" content="Welcome" /><meta name="Microsoft.Help.Id" content="846f5c8a-6cba-433e-9f18-cde2ff5695cd" /><meta name="Description" content="The GMP Native Interface for .NET Library exposes to .NET (through P-Invoke and .NET types) all of the functionality of the GNU MP Libraryhttps://gmplib.org/ (version 6.1.2)." /><meta name="Microsoft.Help.ContentType" content="Concepts" /><meta name="BrandingAware" content="true" /><link rel="stylesheet" type="text/css" href="../styles/branding-Website.css" /><script type="text/javascript" src="../scripts/jquery-1.11.0.min.js"></script><script type="text/javascript" src="../scripts/branding-Website.js"></script><script type="text/javascript" src="../scripts/clipboard.min.js"></script></head><body onload="OnLoad('cs')"><input type="hidden" id="userDataCache" class="userDataStyle" /><div class="pageHeader" id="PageHeader">GMP Native Interface for .NET<form id="SearchForm" method="get" action="#" onsubmit="javascript:TransferToSearchPage(); return false;"><input id="SearchTextBox" type="text" maxlength="200" /><button id="SearchButton" type="submit"></button></form></div><div class="pageBody"><div class="leftNav" id="leftNav"><div id="tocNav"><div class="toclevel0" data-toclevel="0" data-childrenloaded="true"><a class="tocExpanded" onclick="javascript: Toggle(this);" href="#!" /><a data-tochassubtree="true" href="846f5c8a-6cba-433e-9f18-cde2ff5695cd.htm" title="GMP Native Interface for .NET" tocid="roottoc">GMP Native Interface for .NET</a></div><div class="toclevel1 current" data-toclevel="1"><a data-tochassubtree="false" href="846f5c8a-6cba-433e-9f18-cde2ff5695cd.htm" title="Welcome to the GMP Native Interface for .NET Library" tocid="846f5c8a-6cba-433e-9f18-cde2ff5695cd">Welcome to the GMP Native Interface for .NET Library</a></div><div class="toclevel1" data-toclevel="1"><a class="tocCollapsed" onclick="javascript: Toggle(this);" href="#!" /><a data-tochassubtree="true" href="d9c51b9f-0c54-770b-28ea-6eebd8fef368.htm" title="Math.Gmp.Native" tocid="d9c51b9f-0c54-770b-28ea-6eebd8fef368">Math.Gmp.Native</a></div></div><div id="tocResizableEW" onmousedown="OnMouseDown(event);"></div><div id="TocResize" class="tocResize"><img id="ResizeImageIncrease" src="../icons/TocOpen.gif" onclick="OnIncreaseToc()" alt="Click or drag to resize" title="Click or drag to resize" /><img id="ResizeImageReset" src="../icons/TocClose.gif" style="display:none" onclick="OnResetToc()" alt="Click or drag to resize" title="Click or drag to resize" /></div></div><div class="topicContent" id="TopicContent"><table class="titleTable"><tr><td class="titleColumn">Welcome to the GMP Native Interface for .NET Library</td></tr></table><span class="introStyle"></span> <div class="introduction"><p>
The <strong>GMP Native Interface for .NET Library</strong> exposes to .NET (through P-Invoke and .NET types)
all of the functionality of the
<a href="https://gmplib.org/" target="_blank">GNU MP Library</a>
(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.
</p></div><div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('ID0RB')" onkeypress="SectionExpandCollapse_CheckKey('ID0RB', event)" tabindex="0"><img id="ID0RBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Overview</span></div><div id="ID0RBSection" class="collapsibleSection"><p>
The <a href="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm">gmp_lib</a> class has a static
method for each one of the GNU MP functions.
Other types are defined to mimic struct's and typedef's of the GNU MP and C libraries, as well as C language
constructs such as <span class="code">char *</span> and <span class="code">void *</span>.
</p><p>
The GMP Native Interface for .NET Library relies on pre-built 32-bit and 64-bit versions of the GNU MP Library.
Instructions for building the GNU MP Library on Windows are given below.
</p><p>
For convenience, this help file has been created from the GNU MP manual version 6.1.2. It shows with examples
how each GNU MP function is called in .NET. For an introduction to GNU MP, refer to the
<a href="https://gmplib.org/manual/" target="_blank">GNU MP Manual</a>.
</p></div><div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('ID1RB')" onkeypress="SectionExpandCollapse_CheckKey('ID1RB', event)" tabindex="0"><img id="ID1RBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />C and .NET Types Equivalence</span></div><div id="ID1RBSection" class="collapsibleSection"><p>
The table below shows how each C type maps to .NET.
Note that the <a href="bf1f694d-f9b2-6413-12e5-ebae603d5b49.htm">mp_limb_t</a>
and <a href="d9761bfb-1882-59d2-e89b-c6460141f9a6.htm">size_t</a> C types map
to the CPU word, i.e., 32 or 64 bits.
In particular, because <a href="bf1f694d-f9b2-6413-12e5-ebae603d5b49.htm">mp_limb_t</a>
is the type of the integers that make up multi-precision numbers, matching the CPU word size ensures
maximum performance.
Unless you intend to use low-level (mpn) functions, you do not need to take into account the
CPU word size, and can build for the "Any CPU" platform.
</p><div class="tableSection"><table><tr><th><p>C Types</p></th><th><p>.NET Types</p></th></tr><tr><td><p>short</p></td><td><p>Int16</p></td></tr><tr><td><p>int</p></td><td><p>Int32</p></td></tr><tr><td><p>long</p></td><td><p>Int32</p></td></tr><tr><td><p>long long</p></td><td><p>Int64</p></td></tr><tr><td><p><a href="1b2b1d64-20c1-7a64-0278-d9ff58ee9cc3.htm">mp_bitcnt_t</a></p></td><td><p>UInt32</p></td></tr><tr><td><p><a href="e6a17880-791f-37d4-4942-cf26ce7d4cbf.htm">mp_exp_t</a></p></td><td><p>Int32</p></td></tr><tr><td><p><a href="4b58a584-7a0e-b600-18fa-ebd493861eb3.htm">mp_size_t</a></p></td><td><p>Int32</p></td></tr><tr><td><p><a href="bf1f694d-f9b2-6413-12e5-ebae603d5b49.htm">mp_limb_t</a></p></td><td><p>UInt32 (on 32-bit CPU) / UInt64 (on 64-bit CPU)</p></td></tr><tr><td><p><a href="d9761bfb-1882-59d2-e89b-c6460141f9a6.htm">size_t</a></p></td><td><p>UInt32 (on 32-bit CPU) / UInt64 (on 64-bit CPU)</p></td></tr></table></div></div><div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('ID2RB')" onkeypress="SectionExpandCollapse_CheckKey('ID2RB', event)" tabindex="0"><img id="ID2RBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Building the GNU MP Library on Windows</span></div><div id="ID2RBSection" class="collapsibleSection"><ol><li><p>
Install MSYS2
</p><p>
Get the latest version from...
</p></li><li><p>Install yasm</p></li><li><p>Install GNU MP</p></li><li><p>Build GNU MP</p></li></ol></div><div class="collapsibleAreaRegion" id="seeAlsoSection"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('ID3RB')" onkeypress="SectionExpandCollapse_CheckKey('ID3RB', event)" tabindex="0"><img id="ID3RBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />See Also</span></div><div id="ID3RBSection" class="collapsibleSection"><h4 class="subHeading">Other Resources</h4><div class="seeAlsoStyle"><a href="http://en.cppreference.com/w/c/numeric/math" target="_self">C Standard</a></div><div class="seeAlsoStyle"><a href="https://github.com/MachineCognitis/Math.Gmp.Native" target="_self">Math.Gmp.Native on GitHub</a></div></div></div></div><div id="pageFooter" class="pageFooter" /></body></html>