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

168 lines
80 KiB
HTML
Raw Normal View History

2017-11-05 15:50:00 +01:00
<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/_self (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>
2017-11-04 16:02:37 +01:00
The <strong>GMP Native Interface for .NET Library</strong> exposes to .NET (through P-Invoke and .NET types)
all of the functionality of the
2017-11-05 15:50:00 +01:00
<a href="https://gmplib.org/" target="_self">GNU MP Library</a>
2017-11-04 18:58:39 +01:00
(version 6.1.2). It automatically loads at runtime the 32-bit or 64-bit GNU MP library that matches the current CPU
2017-11-05 15:38:56 +01:00
architecture, thus allowing building Visual Studio Projects for Any CPU, x86, or x64.
2017-11-04 18:58:39 +01:00
It is based on the GNU MP "fat" build which automatically detects the current CPU type, and selects any available
2017-11-06 13:38:19 +01:00
assembly language code optimization for that CPU, thus providing best performance.
2017-11-05 01:02:04 +01:00
</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
2017-11-05 15:50:00 +01:00
<a href="https://gmplib.org/manual/" target="_self">GNU MP Manual</a>.
2017-11-11 22:42:26 +01:00
</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" />Functions Categories</span></div><div id="ID1RBSection" class="collapsibleSection"><ul><li><p><strong>Global Variable and Constants:</strong></p><ul class="noBullet"><li><p><a href="4c3f1727-1891-2918-da3a-321930e883ed.htm">gmp_errno</a> - Gets or sets the global GMP error number.<br /><a href="3f1b2832-ff9c-cc4a-3e85-e2ee16acc69b.htm">gmp_version</a> - The GMP version number in the form “i.j.k”. This release is "6.1.2".<br /><a href="f88c76a8-118a-5cbd-0df1-e30adcacb8ae.htm">mp_bits_per_limb</a> - The number of bits per limb.<br /><a href="47695d57-9a89-48db-97c3-2ed03965d913.htm">mp_bytes_per_limb</a> - The number of bytes per limb.<br /><a href="af9533ce-5e67-245d-1cb3-9efb7772a6c8.htm">mp_uint_per_limb</a> - The number of 32-bit, unsigned integers per limb.<br /></p></li></ul></li><li><p><strong>Integer Functions:</strong></p><ul><li><p>
Initializing Integers:
</p><p><a href="dc2f13ec-ac21-1196-0a1d-c574578b1f24.htm">mpz_init</a> - Initialize <em>x</em>, and set its value to 0.<br /><a href="de0b7cf7-1826-55f3-379d-41a6ef2d0991.htm">mpz_inits</a> - Initialize a NULL-terminated list of <a href="8beda7fb-bbc4-b56f-fd1f-1459377ecb3b.htm">mpz_t</a> variables, and set their values to 0.<br /><a href="5cd3a242-93b7-49c5-b9c9-1dca02ed4662.htm">mpz_init2</a> - Initialize <em>x</em>, with space for <em>n</em>-bit numbers, and set its value to 0.<br /><a href="551f8670-3080-9a92-cd50-58d09cbf77ef.htm">mpz_clear</a> - Free the space occupied by <em>x</em>.<br /><a href="a909faa8-4939-1ba3-5647-af8836c9a291.htm">mpz_clears</a> - Free the space occupied by a NULL-terminated list of <a href="8beda7fb-bbc4-b56f-fd1f-1459377ecb3b.htm">mpz_t</a> variables.<br /><a href="1de9b70a-1d21-8168-e41c-1c259f64091a.htm">mpz_realloc2</a> - Change the space allocated for <em>x</em> to <em>n</em> bits.<br /></p></li><li><p>
Assigning Integers:
</p><p><a href="3a4e6141-0771-f9ac-2283-5e9348f86d4a.htm">mpz_set</a> - Set the value of <em>rop</em> from <em>op</em>.<br /><a href="7daadb71-9f36-2848-86c4-ba1fba25fcfd.htm">mpz_set_ui</a> - Set the value of <em>rop</em> from <em>op</em>.<br /><a href="1ffac718-d814-0556-ea54-dbf1d676e0cc.htm">mpz_set_si</a> - Set the value of <em>rop</em> from <em>op</em>.<br /><a href="8d6c39e2-22d8-d0ef-219c-dc594e73b2c5.htm">mpz_set_d</a> - Set the value of <em>rop</em> from <em>op</em>.<br /><a href="f6eeca07-edf7-6915-36e4-e8a7a62333d7.htm">mpz_set_q</a> - Set the value of <em>rop</em> from <em>op</em>.<br /><a href="9005bf40-4373-e879-9f0a-448b174aad67.htm">mpz_set_f</a> - Set the value of <em>rop</em> from <em>op</em>.<br /><a href="6a3819df-abc1-ceb1-a5c7-87a879977b8c.htm">mpz_set_str</a> - Set the value of <em>rop</em> from <em>str</em>, a null-terminated C string in base <em>base</em>.<br /><a href="90eada10-67d0-8376-0010-d053e5043b96.htm">mpz_swap</a> - Swap the values <em>rop1</em> and <em>rop2</em> efficiently.<br /></p></li><li><p>
Simultaneous Integer Init &amp; Assign:
</p><p><a href="2c37941c-dee7-0d74-7889-3fa6c20bab6a.htm">mpz_init_set</a> - Initialize <em>rop</em> with limb space and set the initial numeric value from <em>op</em>.<br /><a href="7da3b40f-ae2c-63c5-0157-9b51d54cf6cb.htm">mpz_init_set_ui</a> - Initialize <em>rop</em> with limb space and set the initial numeric value from <em>op</em>.<br /><a href="9cbc8594-a202-86fd-f4e8-22635ba952b5.htm">mpz_init_set_si</a> - Initialize <em>rop</em> with limb space and set the initial numeric value from <em>op</em>.<br /><a href="fec3a449-96b9-64b0-f53d-0b5a3856d02d.htm">mpz_init_set_d</a> - Initialize <em>rop</em> with limb space and set the initial numeric value from <em>op</em>.<br /><a href="d5af3442-ab5b-08e2-9398-0b6f04506c16.htm">mpz_init_set_str</a> - Initialize <em>rop</em> and set its value like <a href="6a3819df-abc1-ceb1-a5c7-87a879977b8c.htm">mpz_set_str</a>.<br /></p></li><li><p>
Converting Integers:
</p><p><a href="3a92eddc-59f3-b42f-9921-4e1cc5700d60.htm">mpz_get_ui</a> - Return the value of <em>op</em> as an unsigned long.<br /><a href="da585eac-be2c-38ea-8be5-90c5be95ae86.htm">mpz_get_si</a> - Return the value of <em>op</em> as an signed long.<br /><a href="89d8c501-6c12-9104-7e2d-be411f443b62.htm">mpz_get_d</a> - Convert <em>op</em> to a double, truncating if necessary (i.e. rounding towards zero).<br /><a href="74e22b4c-fa79-f5f9-b752-da41bd427f37.htm">mpz_get_d_2exp</a> - Convert <em>op</em> to a double, truncating if necessary (i.e. rounding towards zero), and returning the exponent separately.<br /><a href="54c1f778-6fc8-0056-6f25-26f6754645fb.htm">mpz_get_str</a> - Convert <em>op</em> to a string of digits in base <em>base</em>.<br /></p></li><li><p>
Integer Arithmetic:
</p><p><a href="acb6d3d4-70ad-58be-7cb8-9edb997204b3.htm">mpz_add</a> - Set <em>rop</em> to <em>op1</em> + <em>op2</em>.<br /><a href="7327aa92-1ab5-7553-7eee-7b5e3e61322a.htm">mpz_add_ui</a> - Set <em>rop</em> to <em>op1</em> + <em>op2</em>.<br /><a href="53702772-53e9-ec51-c3a5-7a1912b4f2b4.htm">mpz_sub</a> - Set <em>rop</em> to <em>op1</em> - <em>op2</em>.<br /><a href="e3e3f2ce-f3d8-5321-37a5-de65b6c2a30d.htm">mpz_sub_ui</a> - Set <em>rop</em> to <em>op1</em> - <em>op2</em>.<br /><a href="8d80c2f9-de42-f223-595e-108f165d5746.htm">mpz_ui_sub</a> - Set <em>rop</em> to <em>op1</em> - <em>op2</em>.<br /><a href="3523bf0e-75ec-6286-76a0-4685198e51f6.htm">mpz_mul</a> - Set <em>rop</em> to <em>op1</em> * <em>op2</em>.<br /><a href="ffd27ee1-e1e3-567f-b3cf-87dec2de2c83.htm">mpz_mul_si</a> - Set <em>rop</em> to <em>op1</em> * <em>op2</em>.<br /><a href="5fba9944-4437-9b1c-afa0-666d87eafe39.htm">mpz_mul_ui</a> - Set <em>rop</em> to <em>op1</em> * <em>op2</em>.<br /><a href="582a0647-1482-ecd7-cc78-bd2222610e06.htm">mpz_addmul</a> - Set <em>rop</em> to <em>rop</em> + <em>op1</em> * <em>op2</em>.<br /><a href="4e93c4c4-d799-2828-5285-8a3f3ed02ad3.htm">mpz_addmul_ui</a> - Set <em>rop</em> to <em>rop</em> + <em>op1</em> * <em>op2</em>.<br /><a href="ce7d559a-3772-41c0-912f-9ab218f4d98c.htm">mpz_submul</a> - Set <em>rop</em> to <em>rop</em> - <em>op1</em> * <em>op2</em>.<br /><a href="c5a0fa06-536c-6c6f-20c7-fb014ebc6444.htm">mpz_submul_ui</a> - Set <em>rop</em> to <em>rop</em> - <em>op1</em> * <em>op2</em>.<br /><a href="18cd39f5-7c88-f557-3803-8a4a321cfb97.htm">mpz_mul_2exp</a> - Set <em>rop</em> to <em>op1</em> * 2^<em>op2</em>.<br /><a href="5a61d62c-a0f0-5e86-b6dd-8ca6414b35ed.htm">mpz_neg</a> - Set <em>rop</em> to -<em>op</em>.<br /><a href="9761cc8e-6099-7a76-5ea6-d27f617fd5d1.htm">mpz_abs</a> - Set <em>rop</em> to the absolute value of <em>op</em>.<br /></p></li><li><p>
Integer Division:
</p><p><a href="8b1e9c27-7278-6032-80c0-015b93258d96.htm">mpz_cdiv_q</a> - Set the quotient <em>q</em> to ceiling(<em>n</em> / <em>d</em>).<br /><a href="e8f34851-d0b2-335e-1ea5-f9129062aabf.htm">mpz_cdiv_r</a> - Set the remainder <em>r</em> to <em>n</em> - q * <em>d</em> where q = ceiling(<em>n</em> / <em>d</em>).<br /><a href="7f89c102-d1eb-2dab-0e6e-061893309c4b.htm">mpz_cdiv_qr</a> - Set the quotient <em>q</em> to ceiling(<em>n</em> / <em>d</em>), and set the remainder <em>r</em> to <em>n</em> - <em>q</em> * <em>d</em>.<br /><a href="05b3707d-5f48-4d76-c42a-566f3179d7f8.htm">mpz_cdiv_q_ui</a> - Set the quotient <em>q</em> to ceiling(<em>n</em> / <em>d</em>), and return the remainder r = | <em>n</em> - <em>q</em> * <em>d</em> |.<br /><a href="af797947-8f84-320e-d1cd-ba578b26cef3.htm">mpz_cdiv_r_ui</a> - Set the remainder <em>r</em> to <em>n</em> - q * <em>d</em> where q = ceiling(<em>n</em> / <em>d</em>), and return | <em>r</em> |.<br /><a href="7aee9fae-9d14-72be-6d0f-0f9c4a863fe5.htm">mpz_cdiv_qr_ui</a> - Set quotient <em>q</em> to ceiling(<em>n</em> / <em>d</em>), set the remainder <em>r</em> to <em>n</em> - <em>q</em> * <em>d</em>, and return | <em>r</em> |.<br /><a href="290eb509-85df-a0cc-86f8-ac4e6f5d730a.htm">mpz_cdiv_ui</a> - Return the remainder | r | where r = <em>n</em> - q * <em>d</em>, and where q = ceiling(<em>n</em> / <em>d</em>).<br /><a href="a4def6d8-f8a5-f76f-4ef0-3e6e7eec23fb.htm">mpz_cdiv_q_2exp</a> - Set the quotient <em>q</em> to ceiling(<em>n</em> / 2^<em>b</em>).<br /><a href="8320e5d8-1df9-ca26-3054-e4b93cc0f616.htm">mpz_cdiv_r_2exp</a> - Set the remainder <em>r</em> to <em>n</em> - q * 2^<em>b</em> where q = ceiling(<em>n</em> / 2^<em>b</em>).<br /><a href="b0d00a52-e539-c5f7-7d6d-ab202e72ad98.htm">mpz_fdiv_q</a> - Set the quotient <em>q</em> to floor(<em>n</em> / <em>d</em>).<br /><a href="5dfc0ea9-a81f-bda9-356c-034395ba3c9c.htm">mpz_fdiv_r</a> - Set the remainder <em>r</em> to <em>n</em> - q * <em>d</em> where q = floor(<em>n</em> / <em>d</em>).<br /><a href="d9ab5220-69aa-8e5d-8d15-375eb27149ad.htm">mpz_fdiv_qr</a> - Set the quotient <em>q</em> to floor(<em>n</em> / <em>d</em>), and set the remainder <em>r</em> to <em>n</em> - <em>q</em> * <em>d</em>.<br /><a href="0dcf05e1-ec39-5294-c4d0-d8e0f92642e4.htm">mpz_fdiv_q_ui</a> - Set the quotient <em>q</em> to floor(<em>n</em> / <em>d</em>), and return the remainder r = | <em>n</em> - <em>q</em> * <em>d</em> |.<br /><a href="772064e8-3ec1-840e-c79c-78f478321b6c.htm">mpz_fdiv_r_ui</a> - Set the remainder <em>r</em> to <em>n</em> - q * <em>d</em> where q = floor(<em>n</em> / <em>d</em>), and return | <em>r</em> |.<br /><a href="452a9316-f421-a65c-a9ba-254b201dc431.htm">mpz_fdiv_qr_ui</a> - Set quotient <em>q</em> to floor(<em>n</em> / <em>d</em>), set the remainder <em>r</em> to <em>n</em> - <em>q</em> * <em>d</em>, and return | <em>r</em> |.<br /><a href="8435af1d-e5e4-3e55-1024-449ff7b56ad4.htm">mpz_fdiv_ui</a> - Return the remainder | r | where r = <em>n</em> - q * <em>d</em>, and where q = floor(<em>n</em> / <em>d</em>).<br /><a href="f56c5489-8c01-a687-fec8-a5f443738701.htm">mpz_fdiv_q_2exp</a> - Set the quotient <em>q</em> to floor(<em>n</em> / 2^<em>b</em>).<br /><a href="b0f120a7-a215-fbff-1138-bac5df8d741c.htm">mpz_fdiv_r_2exp</a> - Set the remainder <em>r</em> to <em>n</em> - q * 2^<em>b</em> where q = floor(<em>n</em> / 2^<em>b</em>).<br /><a href="4c830876-cdf6-9d94-1ceb-24d30f873bc2.htm">mpz_tdiv_q</a> - Set the quotient <em>q</em> to trunc(<em>n</em> / <em>d</em>).<br /><a href="beb982a6-fa8e-6a0f-409a-bce1fddb6002.htm">mpz_tdiv_r</a> - Set the remainder <em>r</em> to <em>n</em> - q * <em>d</em> where q = trunc(<em>n</em> / <em>d</em>).<br /><a href="387ec1dd-15b3-4cc9-862a-e3f0a8e2cb78.htm">mpz_tdiv_qr</a> - Set the quotient <em>q</em> to trunc(<em>n</em> / <em>d</em>), and set the remainder <em>r</em> to <em>n</em> - <em>q</em> * <em>d</em>.<br /><a href="67fc54a2-05e7-bc3c-64f4-8c6de48fa6b6.htm">mpz_tdiv_q_ui</a> - Set the quotient <em>q</em> to trunc(<em>n</em> / <em>d</em>), and return the remainder r = | <
Integer Exponentiation:
</p><p><a href="9de702f4-758b-2a4e-1025-ed5e46cc7db2.htm">mpz_powm</a> - Set <em>rop</em> to (<em>base</em>^<em>exp</em>) modulo <em>mod</em>. <br /><a href="9fd28088-e353-2b5e-03e3-9c2763226ed6.htm">mpz_powm_ui</a> - Set <em>rop</em> to (<em>base</em>^<em>exp</em>) modulo <em>mod</em>. <br /><a href="93210ab6-2523-3130-044a-80bcf43c181d.htm">mpz_powm_sec</a> - Set <em>rop</em> to (<em>base</em>^<em>exp</em>) modulo <em>mod</em>.<br /><a href="8e3a525d-9371-fb32-1051-e8e8fe23a63d.htm">mpz_pow_ui</a> - Set <em>rop</em> to <em>base</em>^<em>exp</em>. The case 0^0 yields 1. <br /><a href="6101fda5-1230-66a9-5aff-5d8da426e364.htm">mpz_ui_pow_ui</a> - Set <em>rop</em> to <em>base</em>^<em>exp</em>. The case 0^0 yields 1.<br /></p></li><li><p>
Integer Roots:
</p><p><a href="279877e1-b8d0-f52c-16ba-b2e38e671437.htm">mpz_root</a> - Set <em>rop</em> to the truncated integer part of the <em>n</em>th root of <em>op</em>.<br /><a href="a637ce7e-54d7-eba9-0c6f-c237f115b621.htm">mpz_rootrem</a> - Set <em>root</em> to the truncated integer part of the <em>n</em>th root of <em>u</em>. Set <em>rem</em> to the remainder, <em>u</em> - <em>root</em>^<em>n</em>. <br /><a href="1e1204c7-2d33-c9d1-4f4e-c36215f5ebed.htm">mpz_sqrt</a> - Set <em>rop</em> to the truncated integer part of the square root of <em>op</em>.<br /><a href="e802af92-73bf-b138-dc95-a3c57eeefb66.htm">mpz_sqrtrem</a> - Set <em>rop1</em> to the truncated integer part of the square root of <em>op</em>, like <a href="1e1204c7-2d33-c9d1-4f4e-c36215f5ebed.htm">mpz_sqrt</a>. Set <em>rop2</em> to the remainder <em>op</em> - <em>rop1</em> * <em>rop1</em>, which will be zero if <em>op</em> is a perfect square.<br /><a href="d7722641-e3ea-336d-63f3-dc48f786e376.htm">mpz_perfect_power_p</a> - Return non-zero if <em>op</em> is a perfect power, i.e., if there exist integers a and b, with b &gt; 1, such that <em>op</em> = a^b. <br /><a href="260d6edf-ce02-26f7-d704-ad0d11604e61.htm">mpz_perfect_square_p</a> - Return non-zero if <em>op</em> is a perfect square, i.e., if the square root of <em>op</em> is an integer.<br /></p></li><li><p>
Number Theoretic Functions:
</p><p><a href="52ce0428-7c09-f2b9-f517-d3d02521f365.htm">mpz_probab_prime_p</a> - Determine whether <em>n</em> is prime.<br /><a href="88f2d84b-105b-f882-ac55-54a2b6aea39d.htm">mpz_nextprime</a> - Set <em>rop</em> to the next prime greater than <em>op</em>.<br /><a href="4e14cfc4-6f8b-14f7-74df-2f4415ce6f1c.htm">mpz_gcd</a> - Set <em>rop</em> to the greatest common divisor of <em>op1</em> and <em>op2</em>.<br /><a href="88b8d333-9c9c-de7d-8131-6d1432c14a0c.htm">mpz_gcd_ui</a> - Compute the greatest common divisor of <em>op1</em> and <em>op2</em>. If <em>rop</em> is not null, store the result there. <br /><a href="fae08c47-86df-9010-1827-a9fa6e48a1af.htm">mpz_gcdext</a> - Set <em>g</em> to the greatest common divisor of <em>a</em> and <em>b</em>, and in addition set <em>s</em> and <em>t</em> to coefficients satisfying <em>a</em> * <em>s</em> + <em>b</em> * <em>t</em> = <em>g</em>.<br /><a href="db614763-a13e-6456-d52b-9f567be7e776.htm">mpz_lcm</a> - Set <em>rop</em> to the least common multiple of <em>op1</em> and <em>op2</em>.<br /><a href="f60dbcbd-d4f0-edcc-8f88-2de1aa375e6b.htm">mpz_lcm_ui</a> - Set <em>rop</em> to the least common multiple of <em>op1</em> and <em>op2</em>.<br /><a href="e3072efb-05a9-947c-5532-6d806c157e4a.htm">mpz_invert</a> - Compute the inverse of <em>op1</em> modulo <em>op2</em> and put the result in <em>rop</em>.<br /><a href="38be0c24-42ac-e0ea-9e18-e75e3bda2a1e.htm">mpz_jacobi</a> - Calculate the Jacobi symbol (<em>a</em>/<em>b</em>).<br /><a href="b5936979-01aa-1cd8-20de-d6386368e234.htm">mpz_legendre</a> - Calculate the Legendre symbol (<em>a</em>/<em>p</em>).<br /><a href="54ba330f-67d3-fa30-2d5f-0480b7f4659c.htm">mpz_kronecker</a> - Calculate the Jacobi symbol (<em>a</em>/<em>b</em>) with the Kronecker extension (<em>a</em>/2) = (2/<em>a</em>) when <em>a</em> odd, or (<em>a</em>/2) = 0 when <em>a</em> even. <br /><a href="0252e04b-b8fc-5a06-e1e2-a0cafbb44296.htm">mpz_kronecker_si</a> - Calculate the Jacobi symbol (<em>a</em>/<em>b</em>) with the Kronecker extension (<em>a</em>/2) = (2/<em>a</em>) when <em>a</em> odd, or (<em>a</em>/2) = 0 when <em>a</em> even. <br /><a href="07613c31-7d00-9806-1676-55f8c5a997f8.htm">mpz_kronecker_ui</a> - Calculate the Jacobi symbol (<em>a</em>/<em>b</em>) with the Kronecker extension (<em>a</em>/2) = (2/<em>a</em>) when <em>a</em> odd, or (<em>a</em>/2) = 0 when <em>a</em> even. <br /><a href="a248732b-c4be-7e9a-4207-0049371764ff.htm">mpz_si_kronecker</a> - Calculate the Jacobi symbol (<em>a</em>/<em>b</em>) with the Kronecker extension (<em>a</em>/2) = (2/<em>a</em>) when <em>a</em> odd, or (<em>a</em>/2) = 0 when <em>a</em> even. <br /><a href="d9715b1a-6092-83e6-d7f3-6cfbb4adb143.htm">mpz_ui_kronecker</a> - Calculate the Jacobi symbol (<em>a</em>/<em>b</em>) with the Kronecker extension (<em>a</em>/2) = (2/<em>a</em>) when <em>a</em> odd, or (<em>a</em>/2) = 0 when <em>a</em> even. <br /><a href="d6721058-8a6f-9b20-2a5f-8ffd83cc2a2e.htm">mpz_remove</a> - Remove all occurrences of the factor <em>f</em> from <em>op</em> and store the result in <em>rop</em>.<br /><a href="17280f99-d0dc-6714-12c7-be17c97c0cdb.htm">mpz_fac_ui</a> - Set <em>rop</em> to the factorial <em>n</em>!.<br /><a href="d479f2da-ecf9-c9d6-5cc7-66eb8b5ba16b.htm">mpz_2fac_ui</a> - Set <em>rop</em> to the double-factorial <em>n</em>!!.<br /><a href="b4ff3a9e-3ab5-689f-7a80-b61dad2ea125.htm">mpz_mfac_uiui</a> - Set <em>rop</em> to the m-multi-factorial <em>n</em>!^(<em>m</em>)n.<br /><a href="985a65cd-9a65-e8b3-580b-626b65662dd6.htm">mpz_primorial_ui</a> - Set <em>rop</em> to the primorial of <em>n</em>, i.e. the product of all positive prime numbers ≤ <em>n</em>. <br /><a href="cbbdf666-7c6c-f3f3-1790-b5bb1655af87.htm">mpz_bin_ui</a> - Compute the binomial coefficient <em>n</em> over <em>k</em> and store the result in <em>rop</em>.<br /><a href="402dc8d2-32bd-59ad-80f3-4bd2cc000b0d.htm">mpz_bin_uiui</a> - Compute the binomial coefficient <em>n</em> over <em>k</em> and store the result in <em>rop</em>.<br /><a href="71884691-07d0-7bdf-c761-df9b07723735.htm">mpz_fib_ui</
Integer Comparisons:
</p><p><a href="eea958f4-5951-38f2-05ba-3870cefb3842.htm">mpz_cmp</a> - Compare <em>op1</em> and <em>op2</em>.<br /><a href="bb37470f-5f40-4f6d-01d9-4e40446782a3.htm">mpz_cmp_d</a> - Compare <em>op1</em> and <em>op2</em>.<br /><a href="2e55f6fd-0083-fc85-0d42-65e472376dbe.htm">mpz_cmp_si</a> - Compare <em>op1</em> and <em>op2</em>.<br /><a href="bfe022c5-95d3-45d7-0c6f-97167a9a0af2.htm">mpz_cmp_ui</a> - Compare <em>op1</em> and <em>op2</em>.<br /><a href="3e06d348-8a15-691d-5889-ab3f1a4c9f73.htm">mpz_cmpabs</a> - Compare the absolute values of <em>op1</em> and <em>op2</em>.<br /><a href="011efd01-e7f0-47d8-7d1e-77888d96f0d4.htm">mpz_cmpabs_d</a> - Compare the absolute values of <em>op1</em> and <em>op2</em>.<br /><a href="05f897c4-77dc-7735-81ca-65650f61d961.htm">mpz_cmpabs_ui</a> - Compare the absolute values of <em>op1</em> and <em>op2</em>.<br /><a href="86b2033c-26c3-3889-9025-b2a638910a86.htm">mpz_sgn</a> - Return +1 if <em>op</em> &gt; 0, 0 if <em>op</em> = 0, and -1 if <em>op</em> &lt; 0.<br /></p></li><li><p>
Integer Logic and Bit Fiddling:
</p><p><a href="3e5268ed-796b-2880-93a3-8d17143f99b1.htm">mpz_and</a> - Set <em>rop</em> to <em>op1</em> bitwise-and <em>op2</em>. <br /><a href="0ccb1bab-4817-1062-242d-41c181cacf77.htm">mpz_ior</a> - Set <em>rop</em> to <em>op1</em> bitwise inclusive-or <em>op2</em>. <br /><a href="fd4c285a-e2e1-f8ba-97b3-08d4ae6a2ebf.htm">mpz_xor</a> - Set <em>rop</em> to <em>op1</em> bitwise exclusive-or <em>op2</em>. <br /><a href="635ddf01-9c52-0d37-202e-c560b895fb7d.htm">mpz_com</a> - Set <em>rop</em> to the ones complement of <em>op</em>.<br /><a href="84bf95e4-d9d0-4ffe-f836-3650342de962.htm">mpz_popcount</a> - Return the population count of <em>op</em>.<br /><a href="4dfb8bd5-8a6f-6919-7aa9-8c060d42b5d7.htm">mpz_hamdist</a> - Return the hamming distance between the two operands.<br /><a href="3e36be2b-14ed-eb7b-0546-af6d49e983fa.htm">mpz_scan0</a> - Scan <em>op</em> for 0 bit.<br /><a href="480d1d15-b561-ac8f-b12a-f27ba075b3f2.htm">mpz_scan1</a> - Scan <em>op</em> for 1 bit.<br /><a href="f0caf821-320b-1a8b-87ff-84fcbdfd5801.htm">mpz_setbit</a> - Set bit <em>bit_index</em> in <em>rop</em>.<br /><a href="8812c658-675a-b564-9159-2383971747b1.htm">mpz_clrbit</a> - Clear bit <em>bit_index</em> in <em>rop</em>.<br /><a href="4a959468-7670-9303-a5e7-3f1de8f17a62.htm">mpz_combit</a> - Complement bit <em>bit_index</em> in <em>rop</em>. <br /><a href="20a476ea-9a38-9ef3-1e23-da2b2eba69a9.htm">mpz_tstbit</a> - Test bit <em>bit_index</em> in <em>op</em> and return 0 or 1 accordingly. <br /></p></li><li><p>
I/O of Integers:
</p><p><a href="6f85986d-b6a0-435d-3675-c025ef70413d.htm">mpz_out_str</a> - Output <em>op</em> on stdio stream <em>stream</em>, as a string of digits in base <em>base</em>.<br /><a href="8b8d6ec1-3ae5-e6f3-f030-289abe5002d0.htm">mpz_inp_str</a> - Input a possibly white-space preceded string in base <em>base</em> from stdio stream <em>stream</em>, and put the read integer in <em>rop</em>. <br /><a href="053b54b6-f646-f0aa-ddaf-00c494a6d5ef.htm">mpz_out_raw</a> - Output <em>op</em> on stdio stream <em>stream</em>, in raw binary format.<br /><a href="44097b06-123a-4c00-b17f-ab0c70ad78bb.htm">mpz_inp_raw</a> - Input from stdio stream <em>stream</em> in the format written by <a href="053b54b6-f646-f0aa-ddaf-00c494a6d5ef.htm">mpz_out_raw</a>, and put the result in <em>rop</em>.<br /></p></li><li><p>
Integer Random Numbers:
</p><p><a href="c5fc473c-b8dc-8053-4199-e80d58a05230.htm">mpz_urandomb</a> - Generate a uniformly distributed random integer in the range 0 to 2^<em>n</em> - 1, inclusive.<br /><a href="981cfca4-f958-045f-84b7-01717fcd88d1.htm">mpz_urandomm</a> - Generate a uniform random integer in the range 0 to <em>n</em> - 1, inclusive.<br /><a href="4be917d3-47c6-cb58-d768-6276e78f0afb.htm">mpz_rrandomb</a> - Generate a random integer with long strings of zeros and ones in the binary representation.<br /><a href="2b0da39e-331c-878e-26c7-bd6d81c7f8e0.htm">mpz_random</a> - Generate a random integer of at most <em>max_size</em> limbs.<br /><a href="cd88d27d-fb03-9e74-e353-4f0df7a38a96.htm">mpz_random2</a> - Generate a random integer of at most <em>max_size</em> limbs, with long strings of zeros and ones in the binary representation.<br /></p></li><li><p>
Integer Import and Export:
</p><p><a href="8c8c1e55-275f-cff8-2152-883a4eaa163c.htm">mpz_import</a> - Set <em>rop</em> from an array of word data at <em>op</em>.<br /><a href="5fbffc1a-1ac4-6ca6-e528-abe7f8c96667.htm">mpz_export</a> - Fill <em>rop</em> with word data from <em>op</em>.<br /></p></li><li><p>
2017-11-11 22:42:26 +01:00
Miscellaneous Integer Functions:
</p><p><a href="a066df5a-c312-3b00-6092-6f914c3ee248.htm">mpz_fits_sint_p</a> - Return non-zero iff the value of <em>op</em> fits in a signed 32-bit integer. Otherwise, return zero.<br /><a href="cad028df-c3f1-12b6-d8dd-56c4968730e4.htm">mpz_fits_slong_p</a> - Return non-zero iff the value of <em>op</em> fits in a signed 32-bit integer. Otherwise, return zero.<br /><a href="e07f3328-a28c-c75c-10a6-f21d05e6aec0.htm">mpz_fits_sshort_p</a> - Return non-zero iff the value of <em>op</em> fits in a signed 16-bit integer. Otherwise, return zero.<br /><a href="3ce0cc26-e888-90f8-a517-aad88332eec0.htm">mpz_fits_uint_p</a> - Return non-zero iff the value of <em>op</em> fits in an unsigned 32-bit integer. Otherwise, return zero.<br /><a href="fb9e7caf-b049-7884-b70c-185053972604.htm">mpz_fits_ulong_p</a> - Return non-zero iff the value of <em>op</em> fits in an unsigned 32-bit integer. Otherwise, return zero.<br /><a href="6b85c6a3-d6c5-d1d2-829a-af000bae687e.htm">mpz_fits_ushort_p</a> - Return non-zero iff the value of <em>op</em> fits in an unsigned 16-bit integer. Otherwise, return zero.<br /><a href="7dfe367e-74d3-e782-860b-2314da9c44cf.htm">mpz_sizeinbase</a> - Return the size of <em>op</em> measured in number of digits in the given <em>base</em>.<br /><a href="e6012778-c71b-b078-2ef3-9f9db90f1769.htm">mpz_even_p</a> - Determine whether <em>op</em> is even.<br /><a href="6820d6c4-6ee1-53d7-7223-3f654a496ce4.htm">mpz_odd_p</a> - Determine whether <em>op</em> is odd.<br /></p></li><li><p>
Integer Special Functions:
</p><p><a href="c9cb6a67-59b8-5c03-f31d-f252441c53f6.htm">_mpz_realloc</a> - Change the space for <em>integer</em> to <em>new_alloc</em> limbs.<br /><a href="1dfbf5da-f4c2-bbab-5708-3b31d40e4f16.htm">mpz_getlimbn</a> - Return limb number <em>n</em> from <em>op</em>.<br /><a href="9a169dd9-42b0-ea59-abbe-4efc6b870c75.htm">mpz_size</a> - Return the size of <em>op</em> measured in number of limbs.<br /><a href="4b08344c-f506-a717-4e1d-112cd19f5286.htm">mpz_limbs_read</a> - Return a pointer to the limb array representing the absolute value of <em>x</em>.<br /><a href="86ddbf69-57f6-af58-bd13-3eca06123b29.htm">mpz_limbs_write</a> - Return a pointer to the limb array of <em>x</em>, intended for write access.<br /><a href="87f5432d-aacb-57b6-b4a7-e4dc803684a4.htm">mpz_limbs_modify</a> - Return a pointer to the limb array of <em>x</em>, intended for write access.<br /><a href="398e3eb8-0f55-086f-a765-0a8b3c9307e0.htm">mpz_limbs_finish</a> - Updates the internal size field of <em>x</em>.<br /><a href="5786e0c6-2dde-406f-b86d-3df6757c80c0.htm">mpz_roinit_n</a> - Special initialization of <em>x</em>, using the given limb array and size.<br /></p></li></ul></li><li><p><strong>Rational Number Functions:</strong></p><ul><li><p>
Initializing Rationals:
</p><p><a href="19d53697-65f1-2df5-62f3-988182af0c88.htm">mpq_canonicalize</a> - Remove any factors that are common to the numerator and denominator of <em>op</em>, and make the denominator positive.<br /><a href="dbf3d252-fd6d-455f-2ba7-4091845b86a7.htm">mpq_init</a> - Initialize <em>x</em> and set it to 0/1.<br /><a href="8ab8ea40-9723-f0c8-18f4-9558c73397b9.htm">mpq_inits</a> - Initialize a NULL-terminated list of <a href="635f1879-5f85-881e-cca8-3222baf5045a.htm">mpq_t</a> variables, and set their values to 0/1. <br /><a href="b69da354-160b-602a-4cc4-faf7ca423186.htm">mpq_clear</a> - Free the space occupied by <em>x</em>.<br /><a href="cc2693e9-1cc5-3098-f2f7-bb05c8017f62.htm">mpq_clears</a> - Free the space occupied by a NULL-terminated list of <a href="635f1879-5f85-881e-cca8-3222baf5045a.htm">mpq_t</a> variables. <br /><a href="9eac8ea9-0821-09b2-8091-e6638c562c7f.htm">mpq_set</a> - Assign <em>rop</em> from <em>op</em>.<br /><a href="84d256a1-cd11-3bf9-3e8c-8a7e1980315d.htm">mpq_set_z</a> - Assign <em>rop</em> from <em>op</em>.<br /><a href="915a7958-6821-bb64-468f-b0b48b351878.htm">mpq_set_ui</a> - Set the value of <em>rop</em> to <em>op1</em> / <em>op2</em>.<br /><a href="ba898f37-20d0-a5cd-eff1-0663f18220dd.htm">mpq_set_si</a> - Set the value of <em>rop</em> to <em>op1</em> / <em>op2</em>.<br /><a href="e98ec3cf-b539-8024-c401-ecd24bd43662.htm">mpq_set_str</a> - Set <em>rop</em> from a null-terminated string <em>str</em> in the given <em>base</em>.<br /><a href="11e36fbc-ffc4-46df-50b7-2b07684c1755.htm">mpq_swap</a> - Swap the values <em>rop1</em> and <em>rop2</em> efficiently. <br /></p></li><li><p>
Rational Conversions:
</p><p><a href="f88b40d4-3da9-e2c7-4c4c-1ad868778075.htm">mpq_get_d</a> - Convert <em>op</em> to a <a href="http://msdn2.microsoft.com/en-us/library/643eft0t" target="_blank">Double</a>, truncating if necessary (i.e. rounding towards zero). <br /><a href="1a7c5874-9132-2c43-e407-df1eead74fab.htm">mpq_set_d</a> - Set <em>rop</em> to the value of <em>op</em>. There is no rounding, this conversion is exact. <br /><a href="f5dc74ec-155b-2a14-3eb5-4610a8509bae.htm">mpq_set_f</a> - Set <em>rop</em> to the value of <em>op</em>. There is no rounding, this conversion is exact. <br /><a href="f457878b-c3f5-bfe2-aaa9-7f2179332f57.htm">mpq_get_str</a> - Convert <em>op</em> to a string of digits in base <em>base</em>.<br /></p></li><li><p>
Rational Arithmetic:
</p><p><a href="ca6a2024-43ea-fb4e-245e-12e2e01e4ebd.htm">mpq_add</a> - Set <em>sum</em> to <em>addend1</em> + <em>addend2</em>. <br /><a href="e7d65cf6-2ee4-c983-62b5-4ad66f1d8599.htm">mpq_sub</a> - Set <em>difference</em> to <em>minuend</em> - <em>subtrahend</em>.<br /><a href="584834ae-b1f7-d965-2586-f88d5c9b4f67.htm">mpq_mul</a> - Set <em>product</em> to <em>multiplier</em> * <em>multiplicand</em>. <br /><a href="f148f8be-dfbc-fc41-981d-0a99834f01ff.htm">mpq_mul_2exp</a> - Set <em>rop</em> to <em>op1</em> * 2*<em>op2</em>.<br /><a href="433b0777-4514-5b20-7494-f0f2746fe8e5.htm">mpq_div</a> - Set <em>quotient</em> to <em>dividend</em> / <em>divisor</em>. <br /><a href="8dc5397d-96e4-74dd-cd31-0d05649ea927.htm">mpq_div_2exp</a> - Set <em>rop</em> to <em>op1</em> / 2^<em>op2</em>.<br /><a href="b6bd5187-99bb-c6b5-d871-b163fa0f7e0e.htm">mpq_neg</a> - Set <em>negated_operand</em> to -<em>operand</em>.<br /><a href="1f2250c3-a1b8-db12-19e4-9946e39eb64c.htm">mpq_abs</a> - Set <em>rop</em> to the absolute value of <em>op</em>.<br /><a href="3b01109c-5b01-16d2-edd0-5ac3d5514930.htm">mpq_inv</a> - Set <em>inverted_number</em> to 1 / <em>number</em>.<br /></p></li><li><p>
Comparing Rationals:
</p><p><a href="3f29d5f4-13ae-cec8-ea75-6a76d00d10fc.htm">mpq_cmp</a> - Compare <em>op1</em> and <em>op2</em>.<br /><a href="bc33b7de-0deb-669e-0bb7-6cd1090f4aea.htm">mpq_cmp_z</a> - Compare <em>op1</em> and <em>op2</em>.<br /><a href="03336561-2bb9-b38f-8adb-506e0fad094b.htm">mpq_cmp_ui</a> - Compare <em>op1</em> and <em>num2</em> / <em>den2</em>.<br /><a href="43cb2c87-9fab-eb9d-2f7a-140d72af7b15.htm">mpq_cmp_si</a> - Compare <em>op1</em> and <em>num2</em> / <em>den2</em>.<br /><a href="1176cc4e-ffda-2993-1a4a-2e0c7ed24adb.htm">mpq_sgn</a> - Return +1 if <em>op</em> &gt; 0, 0 if <em>op</em> = 0, and -1 if <em>op</em> &lt; 0. <br /><a href="7828ce92-079b-da4d-aab2-1742209287fb.htm">mpq_equal</a> - Return non-zero if <em>op1</em> and <em>op2</em> are equal, zero if they are non-equal. <br /></p></li><li><p>
Applying Integer Functions:
</p><p><a href="a4c2958c-5957-d736-6883-ce7e76b3d7a4.htm">mpq_numref</a> - Return a reference to the numerator <em>op</em>.<br /><a href="2d93abcb-e73f-fe40-a50b-395a0bf6a4fc.htm">mpq_denref</a> - Return a reference to the denominator <em>op</em>.<br /><a href="4f98333c-76a2-db46-cbba-97785a449450.htm">mpq_get_num</a> - Set <em>numerator</em> to the numerator of <em>rational</em>.<br /><a href="ae9e468d-e9ce-db55-1964-433829dfa476.htm">mpq_get_den</a> - Set <em>denominator</em> to the denominator of <em>rational</em>.<br /><a href="6885ad71-c185-1e0c-abc8-4320e12f377a.htm">mpq_set_num</a> - Set the numerator of <em>rational</em> to <em>numerator</em>.<br /><a href="52388f4c-575a-9b13-41a6-e7ec2bd0becd.htm">mpq_set_den</a> - Set the denominator of <em>rational</em> to <em>denominator</em>.<br /></p></li><li><p>
I/O of Rationals:
</p><p><a href="e1c059c4-4cd9-9a2b-1178-4b1a60354129.htm">mpq_out_str</a> - Output <em>op</em> on stdio stream <em>stream</em>, as a string of digits in base <em>base</em>.<br /><a href="38d3a9de-bae7-3f44-18e0-38fe450d4cba.htm">mpq_inp_str</a> - Read a string of digits from <em>stream</em> and convert them to a rational in <em>rop</em>.<br /></p></li></ul></li><li><p><strong>Floating-point Functions:</strong></p><ul><li><p>
Initializing Floats:
</p><p><a href="9e93d02e-f5c7-1a6f-68fe-a33d793a93e2.htm">mpf_set_default_prec</a> - Set the default precision to be at least <em>prec</em> bits.<br /><a href="1ca4ec7e-b5d1-3b51-8341-5a345990e62d.htm">mpf_get_default_prec</a> - Return the default precision actually used. <br /><a href="0dd846ac-56b6-3ea8-0441-12490f67fbf7.htm">mpf_init</a> - Initialize <em>x</em> to 0.<br /><a href="98083eac-9993-41b2-4943-678785fce712.htm">mpf_init2</a> - Initialize <em>x</em> to 0 and set its precision to be at least <em>prec</em> bits.<br /><a href="018278a0-148f-c898-5bd0-42aae4ae0069.htm">mpf_inits</a> - Initialize a NULL-terminated list of <a href="37c88d6c-8d02-2330-ad77-f20fb73d1677.htm">mpf_t</a> variables, and set their values to 0.<br /><a href="3a2a17ed-a64c-8716-7f65-18c661a5279f.htm">mpf_clear</a> - Free the space occupied by <em>x</em>.<br /><a href="bfb87570-3b2e-079a-1528-3746424bbdef.htm">mpf_clears</a> - Free the space occupied by a NULL-terminated list of <a href="37c88d6c-8d02-2330-ad77-f20fb73d1677.htm">mpf_t</a> variables. <br /><a href="96c4a09e-3f83-00ab-30d0-78a82764b0ce.htm">mpf_get_prec</a> - Return the current precision of <em>op</em>, in bits. <br /><a href="438e6843-fc7b-4e6f-9ac0-d97a2773b032.htm">mpf_set_prec</a> - Set the precision of <em>rop</em> to be at least <em>prec</em> bits.<br /><a href="b456f637-83f4-9d4f-18c5-052d77fbf981.htm">mpf_set_prec_raw</a> - Set the precision of <em>rop</em> to be at least <em>prec</em> bits, without changing the memory allocated. <br /><a href="4c81a27a-206c-e5da-44e9-0ac7767b3366.htm">mpf_size</a> - Return the number of limbs currently in use.<br /></p></li><li><p>
Assigning Floats:
</p><p><a href="3a025035-e715-0a3d-8d2d-6011430c9463.htm">mpf_set</a> - Set the value of <em>rop</em> from <em>op</em>. <br /><a href="060aa73e-8c00-0a6b-f569-ad198c4f0d90.htm">mpf_set_ui</a> - Set the value of <em>rop</em> from <em>op</em>. <br /><a href="f059f8e4-dfc8-79fe-6455-42e227ccbc2e.htm">mpf_set_si</a> - Set the value of <em>rop</em> from <em>op</em>. <br /><a href="1d0c5734-9f0d-ec6b-c540-4379f832b0ca.htm">mpf_set_d</a> - Set the value of <em>rop</em> from <em>op</em>. <br /><a href="d60489f8-91f8-ea00-d29c-a52449e712da.htm">mpf_set_z</a> - Set the value of <em>rop</em> from <em>op</em>. <br /><a href="bd669b1e-a941-2e35-7c29-29a5b5ff5e3a.htm">mpf_set_q</a> - Set the value of <em>rop</em> from <em>op</em>. <br /><a href="823b356e-0731-c9ca-0b37-660b6eb9ee7c.htm">mpf_set_str</a> - Set the value of <em>rop</em> from the string in <em>str</em>.<br /><a href="b77c0292-518a-64d8-4b4e-0dd3c0cb801f.htm">mpf_swap</a> - Swap <em>rop1</em> and <em>rop2</em> efficiently. <br /></p></li><li><p>
Simultaneous Float Init &amp; Assign:
</p><p><a href="17b3dc26-68af-fb0c-9923-36777e8bd87e.htm">mpf_init_set</a> - Initialize <em>rop</em> and set its value from <em>op</em>.<br /><a href="8d1b97c9-ef9d-303a-0fbe-e7ece7edf391.htm">mpf_init_set_ui</a> - Initialize <em>rop</em> and set its value from <em>op</em>.<br /><a href="dc1406fd-4ca4-70d3-dc83-bd40b955564a.htm">mpf_init_set_si</a> - Initialize <em>rop</em> and set its value from <em>op</em>.<br /><a href="a2c14761-1b23-0de9-3842-c2d4e3d7aac0.htm">mpf_init_set_d</a> - Initialize <em>rop</em> and set its value from <em>op</em>.<br /><a href="4e30a5e0-637b-949e-a627-387a56945f7b.htm">mpf_init_set_str</a> - Initialize <em>rop</em> and set its value from the string in <em>str</em>.<br /></p></li><li><p>
Converting Floats:
</p><p><a href="648fa405-45d3-506a-f6be-72642e8a7f32.htm">mpf_get_d</a> - Convert <em>op</em> to a <a href="http://msdn2.microsoft.com/en-us/library/643eft0t" target="_blank">Double</a>, truncating if necessary (i.e. rounding towards zero). <br /><a href="e1edc21e-74a0-b44c-216b-bad204b5a48a.htm">mpf_get_d_2exp</a> - Convert op to a double, truncating if necessary (i.e. rounding towards zero), and with an exponent returned separately. <br /><a href="d948e832-ee71-628a-6a7b-766138afff62.htm">mpf_get_si</a> - Convert <em>op</em> to a 32-bit integer, truncating any fraction part.<br /><a href="aa3fd0ea-a8b6-674b-59ff-b6d4785baed1.htm">mpf_get_ui</a> - Convert <em>op</em> to an unsigned 32-bit integer, truncating any fraction part.<br /><a href="73766ead-a037-a852-4589-04adc3407e15.htm">mpf_get_str</a> - Convert <em>op</em> to a string of digits in base <em>base</em>.<br /></p></li><li><p>
2017-11-11 22:42:26 +01:00
Float Arithmetic:
</p><p><a href="c19999f1-01ee-a3fe-dc4d-2a459e73492d.htm">mpf_add</a> - Set <em>rop</em> to <em>op1</em> + <em>op2</em>.<br /><a href="45a76d5c-c5bf-e7f8-906a-15d290e9a50d.htm">mpf_add_ui</a> - Set <em>rop</em> to <em>op1</em> + <em>op2</em>.<br /><a href="718e7623-d25b-8a09-2543-745f24cd82c1.htm">mpf_sub</a> - Set <em>rop</em> to <em>op1</em> - <em>op2</em>.<br /><a href="efbe678f-e1f3-b203-eb36-0db03ba11795.htm">mpf_ui_sub</a> - Set <em>rop</em> to <em>op1</em> - <em>op2</em>.<br /><a href="ca339303-b509-db06-c875-3aac3edec5dd.htm">mpf_sub_ui</a> - Set <em>rop</em> to <em>op1</em> - <em>op2</em>.<br /><a href="309e6a8c-1318-2d30-a058-f119193546a0.htm">mpf_mul</a> - Set <em>rop</em> to <em>op1</em> * <em>op2</em>. <br /><a href="99a405b5-c051-9905-cf57-7139a0e503cf.htm">mpf_mul_ui</a> - Set <em>rop</em> to <em>op1</em> * <em>op2</em>. <br /><a href="4e876639-72f5-7659-f4a9-862639e27e1c.htm">mpf_div</a> - Set <em>rop</em> to <em>op1</em> / <em>op2</em>. <br /><a href="34a39f93-359c-526f-c9ad-cd7558968f1e.htm">mpf_ui_div</a> - Set <em>rop</em> to <em>op1</em> / <em>op2</em>. <br /><a href="3985111a-6d13-b418-9c90-422a8e1e5b8b.htm">mpf_div_ui</a> - Set <em>rop</em> to <em>op1</em> / <em>op2</em>. <br /><a href="00a7e91d-b046-f5d3-5b51-55868d87e228.htm">mpf_sqrt</a> - Set <em>rop</em> to the square root of <em>op</em>. <br /><a href="44e6038b-2e97-b53d-0d46-ce1fff3522d0.htm">mpf_sqrt_ui</a> - Set <em>rop</em> to the square root of <em>op</em>. <br /><a href="96e2fb95-0ac0-3d24-bea9-ee5631f30347.htm">mpf_pow_ui</a> - Set <em>rop</em> to <em>op1</em>^<em>op2</em>.<br /><a href="357791cb-951d-5542-ff67-c00ef5e9aadb.htm">mpf_neg</a> - Set <em>rop</em> to -<em>op</em>. <br /><a href="17731ba4-bf91-6b9b-737a-a9cc306ba17d.htm">mpf_abs</a> - Set <em>rop</em> to | <em>op</em> |. <br /><a href="2041c81e-218b-b514-5a7b-5ee315711bc9.htm">mpf_mul_2exp</a> - Set <em>rop</em> to <em>op1</em> * 2^<em>op2</em>. <br /><a href="352401d6-c6d1-29c1-a9f6-e5e0ed46bc86.htm">mpf_div_2exp</a> - Set <em>rop</em> to <em>op1</em> / 2^<em>op2</em>. <br /></p></li><li><p>
Float Comparison:
</p><p><a href="be9e6a25-83fb-49c2-949a-b8642a8234f5.htm">mpf_cmp</a> - Compare <em>op1</em> and <em>op2</em>.<br /><a href="5236d7a8-b79f-add8-4898-997e9d6a68bf.htm">mpf_cmp_z</a> - Compare <em>op1</em> and <em>op2</em>.<br /><a href="4f0f115a-3956-13f7-4d6f-0157936c03bd.htm">mpf_cmp_d</a> - Compare <em>op1</em> and <em>op2</em>.<br /><a href="5a168ae0-405b-7259-0853-84999876c47a.htm">mpf_cmp_ui</a> - Compare <em>op1</em> and <em>op2</em>.<br /><a href="d9d29633-42c7-fb1c-cdee-3b7993f45653.htm">mpf_cmp_si</a> - Compare <em>op1</em> and <em>op2</em>.<br /><a href="f485faa1-3758-8316-f712-42e0fc2058a8.htm">mpf_reldiff</a> - Compute the relative difference between <em>op1</em> and <em>op2</em> and store the result in <em>rop</em>. This is | <em>op1</em> - <em>op2</em> | / <em>op1</em>. <br /><a href="d229629f-3bba-817b-d9a3-6f00271e1da7.htm">mpf_sgn</a> - Return +1 if op &gt; 0, 0 if op = 0, and -1 if op &lt; 0. <br /></p></li><li><p>
I/O of Floats:
</p><p><a href="feafa6f8-9793-d704-31a8-67c2cec0c33e.htm">mpf_out_str</a> - Print <em>op</em> to <em>stream</em>, as a string of digits.<br /><a href="3a24f5bd-0b45-8164-f27b-c2e04e35ab64.htm">mpf_inp_str</a> - Read a string in base <em>base</em> from <em>stream</em>, and put the read float in <em>rop</em>.<br /></p></li><li><p>
Miscellaneous Float Functions:
</p><p><a href="9b4a5f6b-3f8e-a957-ae84-303c6897aeb4.htm">mpf_ceil</a> - Set <em>rop</em> to <em>op</em> rounded to the next higher integer. <br /><a href="f7584918-b77f-3524-eea2-04134a2c3ba6.htm">mpf_floor</a> - Set <em>rop</em> to <em>op</em> rounded to the next lower integer.<br /><a href="3ac2ecd4-f154-de62-9170-b2d28f362a7e.htm">mpf_trunc</a> - Set <em>rop</em> to <em>op</em> rounded to the integer towards zero. <br /><a href="11a036ec-5052-7dc4-bdb6-10e5c92f88cc.htm">mpf_integer_p</a> - Return non-zero if <em>op</em> is an integer.<br /><a href="d1b172bb-9c87-c255-a736-4b8ef1f6a5fe.htm">mpf_fits_ulong_p</a> - Return non-zero if <em>op</em> fits in an unsigned 32-bit integer, when truncated to an integer. <br /><a href="6c178e2d-a080-13b8-75b0-3fe232b46d75.htm">mpf_fits_slong_p</a> - Return non-zero if <em>op</em> fits in a 32-bit integer, when truncated to an integer. <br /><a href="201b1b12-bb0c-6a53-c6d5-e75db73f8470.htm">mpf_fits_uint_p</a> - Return non-zero if <em>op</em> fits in an unsigned 32-bit integer, when truncated to an integer. <br /><a href="5ea7691b-2a0f-5f25-290c-54c78e2cf3bd.htm">mpf_fits_sint_p</a> - Return non-zero if <em>op</em> fits in a 32-bit integer, when truncated to an integer. <br /><a href="142199e1-6aef-83d5-1986-1b1248ddc6e3.htm">mpf_fits_sshort_p</a> - Return non-zero if <em>op</em> fits in a 16-bit integer, when truncated to an integer. <br /><a href="ada84e5e-397e-e963-7d50-e260d4a104f7.htm">mpf_fits_ushort_p</a> - Return non-zero if <em>op</em> fits in an unsigned 16-bit integer, when truncated to an integer. <br /><a href="5a698221-639e-333b-061b-0aa3f76c38e9.htm">mpf_urandomb</a> - Generate a uniformly distributed random float in <em>rop</em>, such that 0 ≤ rop &lt; 1, with <em>nbits</em> significant bits in the mantissa or less if the precision of <em>rop</em> is smaller.<br /><a href="cc6e8f51-f396-f6c3-c6e4-9a9aeeaf2a13.htm">mpf_random2</a> - Generate a random float of at most <em>max_size</em> limbs, with long strings of zeros and ones in the binary representation.<br /></p></li></ul></li><li><p><strong>Low-level Functions:</strong></p><ul><li><p><a href="339edb73-5781-7d73-97b6-9b73451a698f.htm">mpn_add_n</a> - Add {<em>s1p</em>, <em>n</em>} and {<em>s2p</em>, <em>n</em>}, and write the <em>n</em> least significant limbs of the result to <em>rp</em>. <br /><a href="5562b14f-48a4-be75-2eb0-6a129cd0d5ab.htm">mpn_add_1</a> - Add {<em>s1p</em>, <em>n</em>} and <em>s2limb</em>, and write the <em>n</em> least significant limbs of the result to <em>rp</em>.<br /><a href="b9df04c4-224e-f2ad-8e90-fbb3b30bd76d.htm">mpn_add</a> - Add {<em>s1p</em>, <em>s1n</em>} and {<em>s2p</em>, <em>s2n</em>}, and write the <em>s1n</em> least significant limbs of the result to <em>rp</em>. <br /><a href="b104184e-cf49-dbdb-764a-9dee5cf7b2fd.htm">mpn_sub_n</a> - Subtract {<em>s2p</em>, <em>n</em>} from {<em>s1p</em>, <em>n</em>}, and write the <em>n</em> least significant limbs of the result to <em>rp</em>.<br /><a href="ae3c6cf7-08a0-54dd-951f-b2fe2112b8b0.htm">mpn_sub_1</a> - Subtract <em>s2limb</em> from {<em>s1p</em>, <em>n</em>}, and write the <em>n</em> least significant limbs of the result to <em>rp</em>.<br /><a href="87681f32-b766-3ce2-7c08-98b2d32cb5fa.htm">mpn_sub</a> - Subtract {<em>s2p</em>, <em>s2n</em>} from {<em>s1p</em>, <em>s1n</em>}, and write the <em>s1n</em> least significant limbs of the result to <em>rp</em>.<br /><a href="9fb96802-e56e-8fd8-cef2-b44870d09a10.htm">mpn_neg</a> - Perform the negation of {<em>sp</em>, <em>n</em>}, and write the result to {<em>rp</em>, <em>n</em>}.<br /><a href="ee321a9a-852a-993e-f602-72ff2af02ff6.htm">mpn_mul_n</a> - Multiply {<em>s1p</em>, <em>n</em>} and {<em>s2p</em>, <em>n</em>}, and write the (2 * <em>n</em>)-limb result to <em>rp</em>.<br /><a href="68d3161d-2909-1909-cda7-e87949ee27ce.htm">mpn_mul</a> - Multiply {<em>s1p</em>, <em>s1n</em>} and {<em>s2p</em>, <em>s2n</em>}, and write the (<em>s1n</em> + <em>s2n</em>)-limb result to <em>rp</em>.<br /><a href="ff9c2930-ded2-c5b6-46dd-3ff9279cdc5e.htm">mpn_sqr</a> - Compute
2017-11-11 22:42:26 +01:00
Low-level functions for cryptography:
</p><p><a href="27902901-3a7d-b5b3-d3fc-3900f754bff1.htm">mpn_cnd_add_n</a> - If <em>cnd</em> is non-zero, it produces the same result as a regular <a href="339edb73-5781-7d73-97b6-9b73451a698f.htm">mpn_add_n</a>, and if <em>cnd</em> is zero, it copies {<em>s1p</em>, <em>n</em>} to the result area and returns zero.<br /><a href="b82bad6a-f8f0-db53-a6d3-ed6002046257.htm">mpn_cnd_sub_n</a> - If <em>cnd</em> is non-zero, it produces the same result as a regular <a href="b104184e-cf49-dbdb-764a-9dee5cf7b2fd.htm">mpn_sub_n</a>, and if <em>cnd</em> is zero, it copies {<em>s1p</em>, <em>n</em>} to the result area and returns zero.<br /><a href="1555cd52-98d2-6253-214a-d342a539bfb5.htm">mpn_sec_add_1</a> - Set R to A + b, where R = {<em>rp</em>, <em>n</em>}, A = {<em>ap</em>, <em>n</em>}, and <em>b</em> is a single limb.<br /><a href="87bbc39f-b11a-76d9-f31d-f5dcf365a67d.htm">mpn_sec_add_1_itch</a> - Return the scratch space in number of limbs required by the function <a href="1555cd52-98d2-6253-214a-d342a539bfb5.htm">mpn_sec_add_1</a>.<br /><a href="9137a632-abd2-7963-1991-85e6d753bf13.htm">mpn_sec_sub_1</a> - Set R to A - b, where R = {<em>rp</em>, <em>n</em>}, A = {<em>ap</em>, <em>n</em>}, and <em>b</em> is a single limb.<br /><a href="098c8787-2069-5d1e-a2f9-1f78bdcd60a9.htm">mpn_sec_sub_1_itch</a> - Return the scratch space in number of limbs required by the function <a href="9137a632-abd2-7963-1991-85e6d753bf13.htm">mpn_sec_sub_1</a>.<br /><a href="f0985ccc-17da-8a0b-066c-53df9b1921a1.htm">mpn_cnd_swap</a> - If <em>cnd</em> is non-zero, swaps the contents of the areas {<em>ap</em>, <em>n</em>} and {<em>bp</em>, <em>n</em>}. Otherwise, the areas are left unmodified.<br /><a href="028e92d4-3699-77ff-e8da-9ff4c367f5b3.htm">mpn_sec_mul</a> - Set R to A * B, where A = {<em>ap</em>, <em>an</em>}, B = {<em>bp</em>, <em>bn</em>}, and R = {<em>rp</em>, <em>an</em> + <em>bn</em>}. <br /><a href="b07466c5-6249-332d-e89b-aeb3675970ff.htm">mpn_sec_mul_itch</a> - Return the scratch space in number of limbs required by the function <a href="028e92d4-3699-77ff-e8da-9ff4c367f5b3.htm">mpn_sec_mul</a>.<br /><a href="bfe1e9b5-6fc1-95f2-d5b6-137fe87c071a.htm">mpn_sec_sqr</a> - Set R to A^2, where A = {<em>ap</em>, <em>an</em>}, and R = {<em>rp</em>, 2 * <em>an</em>}. <br /><a href="1ba86b5b-8ace-b6ee-99c5-32a8d7648519.htm">mpn_sec_sqr_itch</a> - Return the scratch space in number of limbs required by the function <a href="bfe1e9b5-6fc1-95f2-d5b6-137fe87c071a.htm">mpn_sec_sqr</a>.<br /><a href="a38b87c5-c6ac-fa68-6d58-c45793bf933e.htm">mpn_sec_powm</a> - Set R to (B^E) modulo M, where R = {<em>rp</em>, <em>n</em>}, M = {<em>mp</em>, <em>n</em>}, and E = {<em>ep</em>, ceil(<em>enb</em> / <a href="f88c76a8-118a-5cbd-0df1-e30adcacb8ae.htm">mp_bits_per_limb</a>)}. <br /><a href="96652cce-b8f1-0b9e-8434-19cf9bb3eb29.htm">mpn_sec_powm_itch</a> - Return the scratch space in number of limbs required by the function <a href="a38b87c5-c6ac-fa68-6d58-c45793bf933e.htm">mpn_sec_powm</a>.<br /><a href="3588cf60-567a-6182-20e8-5e2836498f49.htm">mpn_sec_tabselect</a> - Select entry <em>which</em> from table <em>tab</em>, which has <em>nents</em> entries, each <em>n</em> limbs. Store the selected entry at <em>rp</em>.<br /><a href="6f1dca2b-39f4-3acd-71fb-4f1e5a0d04e6.htm">mpn_sec_div_qr</a> - Set Q to the truncated quotient N / D and R to N modulo D, where N = {<em>np</em>, <em>nn</em>}, D = {<em>dp</em>, <em>dn</em>}, Qs most significant limb is the function return value and the remaining limbs are {<em>qp</em>, <em>nn</em> - <em>dn</em>}, and R = {<em>np</em>, <em>dn</em>}. <br /><a href="b9e1a8f8-5156-ca69-337b-e67c2fd851f7.htm">mpn_sec_div_qr_itch</a> - Return the scratch space in number of limbs required by the function <a href="6f1dca2b-39f4-3acd-71fb-4f1e5a0d04e6.htm">mpn_sec_div_qr</a>.<br /><a href="094ea390-8cc8-bac7-35c3-3616775736de.htm">mpn_sec_div_r</a> - Set R to N modulo D, where N = {<em>np</em>, <em>nn</em>}, D = {<em>dp</em>, <em>dn</em>}, and R = {<em>np</em>, <em>dn</em>}. <br /><a href="1cefa5f6-adc3-30a6-b3bd-cb6a754
Random State Initialization:
</p><p><a href="89fff39e-9dc4-4d23-9460-301ae7df92d1.htm">gmp_randinit_default</a> - Initialize <em>state</em> with a default algorithm.<br /><a href="b3ed0ded-086a-41f1-6051-d08afa338da8.htm">gmp_randinit_mt</a> - Initialize <em>state</em> for a Mersenne Twister algorithm.<br /><a href="21fdbc76-a0de-1f3a-195f-a5ae0cb3d1da.htm">gmp_randinit_lc_2exp</a> - Initialize <em>state</em> with a linear congruential algorithm X = (<em>a</em>X + <em>c</em>) mod 2^<em>m2exp</em>.<br /><a href="f209112e-311a-88cd-becf-33bc3787f91d.htm">gmp_randinit_lc_2exp_size</a> - Initialize <em>state</em> for a linear congruential algorithm as per <a href="21fdbc76-a0de-1f3a-195f-a5ae0cb3d1da.htm">gmp_randinit_lc_2exp</a>.<br /><a href="494fa261-4044-f216-7041-a55d95a26f5b.htm">gmp_randinit_set</a> - Initialize <em>rop</em> with a copy of the algorithm and state from <em>op</em>.<br /><a href="7ef82a61-e43a-78c7-a28f-8f2d0a5f59b1.htm">gmp_randclear</a> - Free all memory occupied by <em>state</em>.<br /></p></li><li><p>
Random State Seeding:
</p><p><a href="b31d5778-362b-b75f-40cc-4c8280ca889c.htm">gmp_randseed</a> - Set an initial <em>seed</em> value into <em>state</em>.<br /><a href="c5f4e595-de6c-a555-426d-6cb8f429a960.htm">gmp_randseed_ui</a> - Set an initial <em>seed</em> value into <em>state</em>.<br /></p></li><li><p>
Random State Miscellaneous:
</p><p><a href="7b541895-53a8-b335-32de-d5b2224ff0f7.htm">gmp_urandomb_ui</a> - Generate a uniformly distributed random number of <em>n</em> bits, i.e. in the range 0 to 2^<em>n</em> - 1 inclusive.<br /><a href="020d0663-b84b-54aa-8e2f-645ed532d175.htm">gmp_urandomm_ui</a> - Generate a uniformly distributed random number in the range 0 to <em>n</em> - 1, inclusive.<br /></p></li></ul></li><li><p><strong>Formatted Output:</strong></p><ul><li><p>
Formatted Output Functions:
</p><p><a href="5c2015f3-41d2-7b80-5309-e41ccec0baaf.htm">gmp_printf</a> - Print to the standard output stdout.<br /><a href="8031c594-b2b2-fa62-7088-00b6fe92f88e.htm">gmp_vprintf</a> - Print to the standard output stdout.<br /><a href="e3abec5c-9d83-babc-a020-ca4817962a21.htm">gmp_fprintf</a> - Print to the stream <em>fp</em>.<br /><a href="62c5f2f4-2a93-e6d2-b867-23d4f2b98af4.htm">gmp_vfprintf</a> - Print to the stream <em>fp</em>.<br /><a href="8916c18b-a745-2699-2f0a-035cf62dd051.htm">gmp_sprintf</a> - Form a null-terminated string in <em>buf</em>.<br /><a href="56e1a610-d238-ab9f-87b5-001764290847.htm">gmp_vsprintf</a> - Form a null-terminated string in <em>buf</em>.<br /><a href="61686857-e4a0-ad60-1419-2b87a79b06c1.htm">gmp_snprintf</a> - Form a null-terminated string in <em>buf</em>.<br /><a href="300c388f-ba1c-0ba3-64fd-e7aafb39dcdb.htm">gmp_vsnprintf</a> - Form a null-terminated string in <em>buf</em>.<br /><a href="fe6e46c3-8464-a080-b5fc-718589320cd5.htm">gmp_asprintf</a> - Form a null-terminated string in a block of memory obtained from the current memory allocation function.<br /><a href="bd7a38bd-df52-4b0f-36d4-eb539767d89f.htm">gmp_vasprintf</a> - Form a null-terminated string in a block of memory obtained from the current memory allocation function.<br /></p></li></ul></li><li><p><strong>Formatted Input:</strong></p><ul><li><p>
Formatted Input Functions:
</p><p><a href="880c96b7-378e-3cdb-057e-b6eea1c9e529.htm">gmp_scanf</a> - Read from the standard input stdin.<br /><a href="e5060da5-cafd-67e7-f18f-3a9d3c2aba7d.htm">gmp_vscanf</a> - Read from the standard input stdin.<br /><a href="50306850-d92d-5038-bbcc-c452cd3c69a9.htm">gmp_fscanf</a> - Read from the stream fp.<br /><a href="316be139-2970-161f-ba7c-730f067b5cf3.htm">gmp_vfscanf</a> - Read from the stream fp.<br /><a href="279d21b9-bd04-522e-0759-d1add6fe6fae.htm">gmp_sscanf</a> - Read from a null-terminated string <em>s</em>.<br /><a href="1a966758-12dc-4da3-cb22-b3b3d788ba02.htm">gmp_vsscanf</a> - Read from a null-terminated string <em>s</em>.<br /></p></li></ul></li><li><p><strong>Custom Allocation:</strong></p><ul><li><p><a href="15ac48e3-750c-d154-7d8f-6dcaa137f5db.htm">mp_set_memory_functions</a> - Replace the current allocation functions from the arguments.<br /><a href="9a229bed-b8b6-e0ad-f153-689455252ec4.htm">mp_get_memory_functions</a> - Get the current allocation functions, storing function pointers to the locations given by the arguments.<br /><a href="2c68671c-cd5c-e2ec-52a2-65b0ca31c3d1.htm">allocate</a> - Return a pointer to newly allocated space with at least <em>alloc_size</em> bytes.<br /><a href="067f64f9-7014-8c6a-3c02-153c1460a1dd.htm">reallocate</a> - Resize a previously allocated block <em>ptr</em> of <em>old_size</em> bytes to be <em>new_size</em> bytes.<br /><a href="92160da3-b1af-e005-cb05-e3fb4dd524d8.htm">free</a> - De-allocate the space pointed to by <em>ptrs</em>.<br /><a href="92160da3-b1af-e005-cb05-e3fb4dd524d8.htm">free</a> - De-allocate the space pointed to by <em>ptr</em>.<br /><a href="92160da3-b1af-e005-cb05-e3fb4dd524d8.htm">free</a> - De-allocate the space pointed to by <em>ptr</em>.<br /><a href="92160da3-b1af-e005-cb05-e3fb4dd524d8.htm">free</a> - De-allocate the space pointed to by <em>ptr</em>.<br /><a href="92160da3-b1af-e005-cb05-e3fb4dd524d8.htm">free</a> - De-allocate the space pointed to by <em>ptr</em>.<br /><a href="e3d53be6-a0ad-fb21-5381-ff688f5984a6.htm">ZeroMemory</a> - The <a href="e3d53be6-a0ad-fb21-5381-ff688f5984a6.htm">ZeroMemory</a> routine fills a block of memory with zeros, given a pointer to the block and the length, in bytes, to be filled.<br /></p></li></ul></li></ul></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" />C and .NET Types Equivalence</span></div><div id="ID2RBSection" class="collapsibleSection"><p>
2017-11-05 01:02:04 +01:00
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 / short (C#) / Short (VB.NET)</p></td></tr><tr><td><p>int</p></td><td><p>Int32 / int (C#) / Integer (VB.NET)</p></td></tr><tr><td><p>long</p></td><td><p>Int32 / int (C#) / Integer (VB.NET)</p></td></tr><tr><td><p>long long</p></td><td><p>Int64 / long (C#) / Long (VB.NET)</p></td></tr><tr><td><p><a href="1b2b1d64-20c1-7a64-0278-d9ff58ee9cc3.htm">mp_bitcnt_t</a></p></td><td><p>UInt32 / uint (C#) / UInteger (VB.NET)</p></td></tr><tr><td><p><a href="e6a17880-791f-37d4-4942-cf26ce7d4cbf.htm">mp_exp_t</a></p></td><td><p>Int32 / int (C#) / Integer (VB.NET)</p></td></tr><tr><td><p><a href="4b58a584-7a0e-b600-18fa-ebd493861eb3.htm">mp_size_t</a></p></td><td><p>Int32 / int (C#) / Integer (VB.NET)</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('ID3RB')" onkeypress="SectionExpandCollapse_CheckKey('ID3RB', event)" tabindex="0"><img id="ID3RBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Building the GNU MP Library on Windows</span></div><div id="ID3RBSection" class="collapsibleSection"><ol><li><p>
2017-11-05 15:50:00 +01:00
Install <a href="https://github.com/msys2/msys2/wiki/MSYS2-introduction" target="_self">MSYS2</a>.
2017-11-05 01:02:04 +01:00
</p><p>
2017-11-05 15:50:00 +01:00
On a 64-bit computer, install <a href="https://github.com/MachineCognitis/Math.Gmp.Native/blob/master/Math.Gmp.Native/Dependencies/" target="_self">msys2-x86_64-20161025.exe</a>,
and on a 32-bit computer, install <a href="https://github.com/MachineCognitis/Math.Gmp.Native/tree/master/Math.Gmp.Native/Dependencies/" target="_self">msys2-i686-20161025.exe</a>.
2017-11-05 15:38:56 +01:00
You can also check for a more recent version of MSYS2 <a href="https://github.com/msys2/msys2/wiki/MSYS2-installation" target="_blank">here</a>.
Install MSYS2 to its default location.
</p><p>
After installation, you need to updates MSYS2 packages. From the Windows Start Menu, start <span class="command">MSYS2 MSYS</span>. In the shell command window,
enter the command:
</p><ul class="noBullet"><li><p><span class="input">pacman -Syuu</span></p></li></ul><p>
and follow instructions.
You will have to close the command window, reopen a new one, and reenter the command <span class="input">pacman -Syuu</span>.
</p><p>
Finally, in order to build software, you need to install a number of packages with the command:
</p><ul class="noBullet"><li><p><span class="input">pacman -S --needed base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain git subversion mercurial mingw-w64-i686-cmake mingw-w64-x86_64-cmake</span></p></li></ul><p>
run from the same command window as in the previous step.
</p><p>
To build 32-bit software, use the <span class="command">MSYS2 MinGW 32-bit</span> command from the Windows Start Menu, and
for 64-bit software, use <span class="command">MSYS2 MinGW 64-bit</span>.
</p></li><li><p>
2017-11-05 16:17:46 +01:00
Install <a href="http://yasm.tortall.net/Download.html" target="_self">yasm</a>.
2017-11-05 15:38:56 +01:00
</p><p>
2017-11-05 16:17:46 +01:00
On a 64-bit computer, copy <a href="https://github.com/MachineCognitis/Math.Gmp.Native/blob/master/Math.Gmp.Native/Dependencies/" target="_self">yasm-1.3.0-win64.exe</a>
2017-11-05 15:38:56 +01:00
to <em>C:\msys64\usr\bin</em>, and rename it to <em>yasm.exe</em>.
</p><p>
2017-11-05 16:17:46 +01:00
Similarly on a 32-bit computer, copy <a href="https://github.com/MachineCognitis/Math.Gmp.Native/blob/master/Math.Gmp.Native/Dependencies/" target="_self">yasm-1.3.0-win32.exe</a>
2017-11-05 15:38:56 +01:00
to <em>C:\msys32\usr\bin</em>, and rename it to <em>yasm.exe</em>.
</p></li><li><p>
2017-11-05 16:17:46 +01:00
Build <a href="https://gmplib.org/" target="_self">GNU MP</a>.
2017-11-05 15:38:56 +01:00
</p><p>
Create folders <em>C:\Temp\x86</em> and <em>C:\Temp\x64</em>.
These are the folder where the compiled 32-bit and 64-bit versions of GNU MP will be installed.
2017-11-05 16:17:46 +01:00
Unzip <a href="https://github.com/MachineCognitis/Math.Gmp.Native/blob/master/Math.Gmp.Native/Dependencies/" target="_self">gmp-6.1.2.tar.bz2</a>
2017-11-05 15:38:56 +01:00
in folder <em>C:\Temp</em>.
This puts GNU MP in subfolder <em>gmp-6.1.2</em>.
</p><p>
In each one of the command windows openend with the commands <span class="command">MSYS2 MinGW 32-bit</span>
and <span class="command">MSYS2 MinGW 64-bit</span> from the Windows Start Menu, run the commands below:
</p><ul class="noBullet"><li><p><span class="input">cd /c/Temp/gmp-6.1.2</span><br /><span class="input">./configure --enable-fat --disable-static --enable-shared --prefix=/c/Temp/x86</span> or <span class="input">x64</span><br /><span class="input">make</span><br /><span class="input">make check</span><br /><span class="input">make install</span><br /></p></li></ul><p>
The <span class="input">--prefix</span> specifies the install folder.
Note that the Windows <em>C:\</em> drive is specified as the root <em>/C/</em> folder in the <span class="command">MinGW</span> window.
Note also that the <span class="input">configure</span> and <span class="input">make</span> commands are to be run against a fresly uncompressed GNU MP source.
The <span class="input">make install</span> command creates <em>libgmp-10.dll</em> in the <em>C:\Temp\x86</em> and <em>C:\Temp\x64</em> folders.
These two compiled versions of the GNU MP library are to be copied to the <em>x86</em> and <em>x64</em> folders of the <em>Math.Gmp.Native</em> Visual Studio projects.
They can also be copied directly into the <em>x86</em> and <em>x64</em> folders of the <em>bin/Debug</em> or <em>bin/Release</em> folders.
</p><p>
The 32-bit and 64-bit <span class="input">make check</span> commands generate some warnings, but all tests passed successfully.
2017-11-11 22:42:26 +01:00
</p></li></ol></div><div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('ID4RB')" onkeypress="SectionExpandCollapse_CheckKey('ID4RB', event)" tabindex="0"><img id="ID4RBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Building the GNU MP Library for a Specific CPU Type on Windows</span></div><div id="ID4RBSection" class="collapsibleSection"><p>
2017-11-05 15:38:56 +01:00
The <span class="input">--enable-fat</span> build option above creates a library where optimized low level subroutines are chosen at runtime according to the CPU detected.
By using instead the <span class="input">--host</span> option, you can build a library for a specific CPU type.
You will end up with a library that runs only on that CPU type, but the library will be samller.
2017-11-05 16:17:46 +01:00
See the <a href="https://gmplib.org/manual/Build-Options.html#Build-Options/" target="_self">Build Options</a> from the GNU MP Manual for the supported CPU types.
2017-11-11 22:42:26 +01:00
</p></div><div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('ID5RB')" onkeypress="SectionExpandCollapse_CheckKey('ID5RB', event)" tabindex="0"><img id="ID5RBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Using the GNU MP Library in a Visual Studio C++ Project</span></div><div id="ID5RBSection" class="collapsibleSection"><p>
2017-11-05 15:38:56 +01:00
Although our main goal was to compile GNU MP in order to use it from .NET, the compiled 32-bit and 64-bit GNU MP libraries may be used directly in Visual Studio C++ projects.
For example, create a default Visual Studio C++ Console Application.
Set the <strong>Platform</strong> to <strong>x64</strong>.
Copy from the <em>C:\Temp\x64</em> folder the files <em>include\gmp.h</em>, <em>bin\libgmp-10.dll</em>, and <em>lib\libgmp.dll.a</em> to the Visual Studio C++ project folder.
Include <em>gmp.h</em> in your C++ source file.
In the <strong>Linker</strong>, <strong>Input Property Page</strong> of the project, add <em>libgmp.dll.a</em> to the <strong>Additional Dependencies</strong>.
Build your C++ project, and copy <em>libgmp-10.dll</em> to the output <em>bin</em> folder.
Run your application.
</p><p>
2017-11-05 16:17:46 +01:00
See <a href="https://github.com/MachineCognitis/Math.Gmp.Native/blob/master/Math.Gmp.Native/Dependencies/" target="_self">ConsoleApplication12.zip</a>
2017-11-05 15:38:56 +01:00
for a sample Visual Studio C++ project.
2017-11-11 22:42:26 +01:00
</p></div><div class="collapsibleAreaRegion" id="seeAlsoSection"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('ID6RB')" onkeypress="SectionExpandCollapse_CheckKey('ID6RB', event)" tabindex="0"><img id="ID6RBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />See Also</span></div><div id="ID6RBSection" class="collapsibleSection"><h4 class="subHeading">Other Resources</h4><div class="seeAlsoStyle"><a href="https://github.com/msys2/msys2/wiki/MSYS2-introduction" target="_self">MSYS2</a></div><div class="seeAlsoStyle"><a href="http://yasm.tortall.net/Download.html" target="_self">yasm</a></div><div class="seeAlsoStyle"><a href="https://gmplib.org/" target="_self">GNU MP</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>