Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'doc/libinum-doc.html')
-rw-r--r--doc/libinum-doc.html2332
1 files changed, 2332 insertions, 0 deletions
diff --git a/doc/libinum-doc.html b/doc/libinum-doc.html
new file mode 100644
index 0000000..e50e8f7
--- /dev/null
+++ b/doc/libinum-doc.html
@@ -0,0 +1,2332 @@
+<html>
+ <head>
+ <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>
+ <!--<script type="text/javascript" src="/usr/share/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>-->
+
+ <style>
+ body {
+ margin-top:40pt;
+ margin-bottom:40pt;
+ margin-left:40pt;
+ margin-right:40pt;
+
+ text-align:justify;
+ }
+
+ p {
+ text-indent:20pt;
+ }
+
+ .codeblock {
+ display:block;
+ margin-left:40pt;
+ margin-top:10pt;
+ margin-bottom:15pt;
+ text-indent:0pt;
+ }
+
+ li {
+ margin-top:10pt;
+ }
+
+ .toc {
+ font-weight:bold;
+ }
+ .toc ul {
+ list-style-type:none;
+ }
+ .toc li {
+ margin-top:0pt;
+ }
+ .toc_sec {
+ counter-increment: tocsec;
+ counter-reset: tocsub 0;
+ }
+ .toc_sec:before {
+ content: counter(tocsec) ". ";
+ }
+ .toc_sub {
+ counter-increment: tocsub;
+ }
+ .toc_sub:before {
+ content: counter(tocsec) "." counter(tocsub) ". ";
+ }
+
+ body {
+ counter-reset: section 0;
+ }
+ .section:before {
+ counter-increment: section;
+ content: counter(section) ". ";
+ }
+ .section {
+ margin-top:50pt;
+ counter-reset: subsection 0;
+ }
+ .subsection:before {
+ counter-increment: subsection;
+ content: counter(section) "." counter(subsection) ". ";
+ }
+ .subsection {
+ margin-top:30pt;
+ }
+
+ </style>
+
+ </head>
+
+ <body>
+ <h1 style="margin-bottom:50pt;">libinum <span style="margin-left:10pt;font-size:18pt">v1.0</span></h1>
+
+ <p>
+ This is the official documentation for <b>libinum</b>, version 1.0.
+ </p>
+
+ <h2 style="margin-top:50pt;">Table of contents</h2>
+ <div class="toc">
+ <ul>
+ <li class="toc_sec"><a href="#sec_description">Description</a></li>
+ <li class="toc_sec"><a href="#sec_datatypes">Data types</a></li>
+ <li class="toc_sec"><a href="#sec_algorithms">Algorithms</a></li>
+ <ul>
+ <li class="toc_sub"><a href="#subsec_root_finding">Root finding</a></li>
+ <ul>
+ <li><a href="#func_root_newton"><code>root_newton</code></a></li>
+ <li><a href="#func_root_newton_inplace"><code>root_newton_inplace</code></a></li>
+ </ul>
+ <li class="toc_sub"><a href="#subsec_integrals">Integrals</a></li>
+ <ul>
+ <li><a href="#func_integrate_gauss"><code>integrate_gauss</code></a></li>
+ <li><a href="#func_integrate_gauss_multithread"><code>integrate_gauss_multithread</code></a></li>
+ <li><a href="#func_integrate_gauss_smarttmp"><code>integrate_gauss_smarttmp</code></a></li>
+ <li><a href="#func_integrate_gauss_smarttmp_multithread"><code>integrate_gauss_smarttmp_multithread</code></a></li>
+ <li><a href="#func_gauss_legendre_weights"><code>gauss_legendre_weights</code></a></li>
+ </ul>
+ </ul>
+ <li class="toc_sec"><a href="#sec_types">Types</a></li>
+ <ul>
+ <li class="toc_sub"><a href="#subsec_array"><code>array</code></a></li>
+ <li class="toc_sub"><a href="#subsec_polynomial"><code>polynomial</code></a></li>
+ <li class="toc_sub"><a href="#subsec_polynomialMV"><code>polynomialMV</code></a></li>
+ <li class="toc_sub"><a href="#subsec_functions">Functions</a></li>
+ </ul>
+ <li class="toc_sec"><a href="#sec_utilities">Utilities</a></li>
+ <li class="toc_sec"><a href="#sec_examples">Examples</a></li>
+ <li class="toc_sec"><a href="#sec_authors">Authors</a></li>
+ </ul>
+ </div>
+
+ <h2 class="section" id="sec_description">Description</h2>
+ <p>
+ <b>libinum</b> is a C library that implements several algorithms, intended for applications in numerical and symbolic computations.
+ </p>
+ <p>
+ <b>libinum</b> defines functions to perform the following tasks:
+ <ul>
+ <li>Compute roots of smooth real functions numerically using the Newton-Raphson algorithm.</li>
+ <li>Compute definite integrals of smooth real functions numerically using Gauss-Legendre quadratures.</li>
+ </ul>
+ In addition, <b>libinum</b> defines the following structures:
+ <ul>
+ <li>Variable-length arrays.</li>
+ <li>Single variable and multivariate polynomials.</li>
+ </ul>
+ </p>
+
+ <p>
+ As a general rule, the functions and structures can be used with several different data types. For instance, the root finding and integration functions can manipulate double precision, extended precision, or multi-precision floating point numbers. See <a href="#sec_datatypes">Data types</a> for details.
+ </p>
+
+ <h2 class="section" id="sec_datatypes">Data types</h2>
+ <p>
+ One of the guiding principles of <b>libinum</b> is that it should should not push a specific data type on users. If, hypothetically, the computation being carried out requires the precision of the floating point numbers to be large, then multi-precision floating point numbers might be preferable to double precision numbers. If, instead, computation time is more important than precision, then extended precision floats may be preferred. The structures and functions defined in <b>libinum</b>, therefore, support various data types.
+ </p>
+
+ <p>
+ We will now briefly discuss the data types that may be used to represent numbers.
+ </p>
+
+
+ <h3 class="subsection" id="subsec_int">Integers</h3>
+ <h4>Fixed-precision integers</h4>
+ <p>
+ The standard integer types of the C language are <code>char</code>, <code>short int</code>, <code>int</code>, <code>long int</code> and <code>long long int</code>, as well as their <code>unsigned</code> counterparts. The number of bits, and, in consequence, the available range of integers, of each of these types, is platform-dependent. In cases where this could be problematic, fixed-precision integers can be used: with 8 bits: <code>int8_t</code>, 16: <code>int16_t</code>, 32: <code>int32_t</code> and 64: <code>int64_t</code>.
+ </p>
+ <p>
+ <b>libinum</b> provides a function, <code>print_datatype_info()</code>, that prints the equivalence table between <code>char</code>, <code>short int</code>, <code>int</code>, <code>long int</code> and <code>long long int</code> and <code>int8_t</code>, <code>int16_t</code>, <code>int32_t</code> and <code>int64_t</code> for the implementation of the C library used to compile <b>libinum</b>.
+ </p>
+
+ <h4>Multi-precision integers</h4>
+ <p>
+ In cases where the required number of bits of integers exceeds 64, one can use <i>multi-precision integers</i>, which can be as large as will fit in memory. However, computation times can greatly increase when using multi-precision integers. The implementation used in <b>libinum</b> is provided by the <a href="http://gmplib.org">GNU GMP</a> library.
+ </p>
+
+
+
+ <h3 class="subsection" id="subsec_float">Floating point numbers</h3>
+ <p>
+ Let us first start with a description of floating point numbers. A real number \(x\) is approximated, with a <i>precision</i> of \(m\) bits, as a collection of three numbers: the <i>sign</i> \(s\in\{-1,1\}\); <i>mantissa</i>, whose binary expansion is denoted by \(a_1\cdots a_m\); and <i>exponent</i> \(e\in\mathbb Z\). The approximate value of the number \(x\) is obtained from its sign, mantissa and exponent by
+ $$
+ x=s\times a_1.a_2\cdots a_m\times2^e.
+ $$
+ The <i>precision</i> of a floating point number is the number of bits allocated to its sign and mantissa (since \(a_1\) is necessarily equal to \(1\), it is not stored, so the precision of \(x\) is \(m\) instead of \(m+1\)).
+ </p>
+ <p> In <b>libinum</b>, floating point number may either be double, extended or multi-precision numbers.
+
+ <h4>Double precision floating point numbers</h4>
+ <p>
+ Double precision floats are represented using the <code>double</code> type.
+ </p>
+ <p>
+ The precision and maximal and minimal values of the exponent of <code>double</code> floats depends on the compiler. Their values can be printed using the <b>libinum</b> function <code>print_datatype_info()</code>.
+ </p>
+ <p>
+ For example, using version 5.3.0 of the <a href="https://gcc.gnu.org/">GNU GCC</a> compiler on the x86-64 architecture, the precision is of 53 bits (i.e. 15 decimal digits), and the maximal and minimal values of the exponent are 1024 and -1021.
+ </p>
+
+ <h4>Extended precision floating point numbers</h4>
+ <p>
+ Extended precision floats are represented using the <code>long double</code> type. They require more memory than double precision floats, and, as a consequence, slightly more computation time.
+ </p>
+ <p>
+ The precision and maximal and minimal values of the exponent of <code>long double</code> floats depends on the compiler. Their values can be printed using the <b>libinum</b> function <code>print_datatype_info()</code>.
+ </p>
+ <p>
+ For example, using version 5.3.0 of the <a href="https://gcc.gnu.org/">GNU GCC</a> compiler on the x86-64 architecture, the precision is of 64 bits (i.e. 18 decimal digits), and the maximal and minimal values of the exponent are 16384 and -16381.
+ </p>
+
+ <h4>Multi-precision floating point numbers</h4>
+ <p>
+ A multi-precision floating point number is a floating point number whose precision can be set to an arbitrary value (until the number fills up the entire memory of the computer). In <b>libinum</b>, multi-precision floats are implemented using the <a href="http://mpfr.org">GNU MPFR</a> library, and will be called <i> MPFR floats</i>.
+ </p>
+ <p>
+ The precision of MPFR floats can be set using the function <code>mpfr_set_default_prec</code> (see the MPFR library <a href="http://www.mpfr.org/mpfr-current/mpfr.html#index-mpfr_005fset_005fdefault_005fprec">documentation</a> for details). The default value of the precision is 53 bits (as of version 3.1.4 of the MPFR library).
+ </p>
+ <p>
+ In addition, the maximal value (in absolute value) of the exponent can be controlled by setting <i>emax</i> using the function <code>mpfr_set_emax</code> (see the MPFR library <a href="http://www.mpfr.org/mpfr-current/mpfr.html#index-mpfr_005fset_005femax">documentation</a> for details).
+ </p>
+ <p>
+ Depending on the MPFR implementation, the precision and emax can either be an <code>int</code> or a <code>long int</code>, so its maximal and minimal values are platform dependent. The <b>libinum</b> function <code>print_datatype_info()</code> prints which it is.
+ </p>
+
+
+ <h2 class="section" id="sec_algorithms">Algorithms</h2>
+ <p>
+ What follows is a detailed description of the functions that implement the algorithms supported by <b>libinum</b>.
+ </p>
+
+ <h3 class="subsection" id="subsec_root_finding">Root finding</h3>
+ <p>
+ <b>libinum</b> can compute the root of smooth real functions using the Newton-Raphson algorithm. The algorithm converges quickly, provided an adequate approximation of the root in provided, and that the root is not located at a minimum of the function.
+ </p>
+
+ <h4>Description</h4>
+ <p>
+ Given a function \(f\) and a real number \(x_0\), the algorithm produces a sequence \((x_n)\) which, provided the algorithm converges, tends to a root of \(f\). The sequence is defined as
+ $$
+ x_{n+1}=x_n-\frac{f(x_{n})}{f'(x_{n})}
+ $$
+ where \(f'\) denotes the derivative of \(f\). The following estimate holds:
+ $$
+ |x_{n+1}-x_n|\leqslant \frac12|x_n-x_{n-1}|^2\sup_{\xi\in[x_{n+1},x_n]}\frac{f''(\xi)}{f'(\xi)}
+ $$
+ so that, provided \(f\) is smooth and its derivative does not vanish in the intervals \([x_{n+1},x_n]\), the algorithm converges <i>quadratically</i>.
+ </p>
+
+ <h4>Implementation</h4>
+ <p>
+ This algorithm has been implemented using double, extended and multi-precision floats.
+ </p>
+
+ <ul>
+ <li id="func_root_newton">
+ <div style="vertical-align: top;">
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_root_newton_double" style="display: inline-block; vertical-align: top;">
+ int root_newton_double(
+ </div>
+ <div id="func_root_newton_double" style="display: inline-block; vertical-align: top;">
+ double* out,<br>
+ int (*func)(double*, double, void*),<br>
+ int (*deriv_func)(double*, double, void*),<br>
+ double init,<br>
+ double tolerance,<br>
+ int maxiter,<br>
+ void* extra_args)
+ </div>
+ </div>
+ </code>
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_root_newton_ldouble" style="display: inline-block; vertical-align: top;">
+ int root_newton_ldouble(
+ </div>
+ <div id="func_root_newton_ldouble" style="display: inline-block; vertical-align: top;">
+ long double* out,<br>
+ int (*func)(long double*, long double, void*),<br>
+ int (*deriv_func)(long double*, long double, void*),<br>
+ long double init,<br>
+ long double tolerance,<br>
+ int maxiter,<br>
+ void* extra_args)
+ </div>
+ </div>
+ </code>
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_root_newton_mpfr" style="display: inline-block; vertical-align: top;">
+ int root_newton_mpfr(
+ </div>
+ <div id="func_root_newton_mpfr" style="display: inline-block; vertical-align: top;">
+ mpfr_t* out,<br>
+ int (*func)(mpfr_t*, mpfr_t, void*),<br>
+ int (*deriv_func)(mpfr_t*, mpfr_t, void*),<br>
+ mpfr_t init,<br>
+ mpfr_t tolerance,<br>
+ int maxiter,<br>
+ void* extra_args)
+ </div>
+ </div>
+ </code>
+ </div>
+
+ <br>
+ <b>Description</b>: Compute a numerical approximation for the root.<br>
+ <br>
+
+ <b>Arguments</b>:
+ <ul>
+ <li>
+ <code>out</code>: pointer to the number to which the result will be written. If the number requires initialization (e.g. if it is an <code>mpfr_t</code>), then it must be initialized.
+ </li>
+ <li>
+ <code>func</code>: pointer to the function that computes \(f(x)\). It must be in the format specified in <a href="#subsec_functions">functions</a>.
+ </li>
+ <li>
+ <code>deriv_func</code>: pointer to the function that computes the derivative of \(f\). It must be in the format specified in <a href="#subsec_functions">functions</a>.
+ </li>
+ <li>
+ <code>init</code>: the value of \(x_0\).
+ </li>
+ <li>
+ <code>tolerance</code>: the algorithm halts when \(|x_{n+1}-x_n|\leqslant\)<code>tolerance</code>. <code>tolerance</code> thus provides control over the error of the algorithm.
+ </li>
+ <li>
+ <code>maxiter</code>: maximum number of iterations. The algorithm gives up if this number is reached and throws a <code>LIBINUM_ERROR_MAXITER</code> exception.
+ </li>
+ <li>
+ <code>extra_args</code>: pointer to the extra arguments to be passed to the functions <code>*func</code> and <code>*deriv_func</code> when they are evaluated.
+ </li>
+ </ul>
+ <br>
+ <b>Return value</b>: returns <code>0</code> on success, and
+ <ul>
+ <li><code>LIBINUM_ERROR_MAXITER</code> if the maximal number of iterations was reached.</li>
+ <li><code>LIBINUM_ERROR_NAN</code> if any of the evaluations of <code>*func</code> or <code>*deriv_func</code> returned <code>nan</code> or <code>infinity</code>, or if any of the evaluations of <code>*deriv_func</code> returned <code>0</code>.</li>
+ </ul>
+ </li>
+ <br><br>
+
+ <li id="func_root_newton_inplace">
+ <div style="vertical-align: top;">
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_root_newton_inplace_double" style="display: inline-block; vertical-align: top">
+ int root_newton_inplace_double(
+ </div>
+ <div style="display: inline-block; vertical-align: top">
+ double* out,<br>
+ int (*func)(double*, double, void*),<br>
+ int (*deriv_func)(double*, double, void*),<br>
+ double tolerance,<br>
+ int maxiter,<br>
+ void* extra_args)<br>
+ </div>
+ </div>
+ </code>
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_root_newton_inplace_ldouble" style="display: inline-block; vertical-align: top">
+ int root_newton_inplace_ldouble(
+ </div>
+ <div style="display: inline-block; vertical-align: top">
+ long double* out,<br>
+ int (*func)(long double*, long double, void*),<br>
+ int (*deriv_func)(long double*, long double, void*),<br>
+ long double tolerance,<br>
+ int maxiter,<br>
+ void* extra_args)<br>
+ </div>
+ </div>
+ </code>
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_root_newton_inplace_mpfr" style="display: inline-block; vertical-align: top">
+ int root_newton_inplace_mpfr(
+ </div>
+ <div style="display: inline-block; vertical-align: top">
+ mpfr_t* out,<br>
+ int (*func)(mpfr_t*, mpfr_t, void*),<br>
+ int (*deriv_func)(mpfr_t*, mpfr_t, void*),<br>
+ mpfr_t tolerance,<br>
+ int maxiter,<br>
+ void* extra_args)<br>
+ </div>
+ </div>
+ </code>
+ </div>
+
+ <br>
+ <b>Description</b>: Similar to <a href="#func_root_newton"><code>root_newton_*</code></a> except that the value of \(x_0\) is passed to the function in the argument <code>out</code>.
+ </li>
+ </ul>
+
+ <h3 class="subsection" id="subsec_integrals">Integrals</h3>
+ <p>
+ <b>libinum</b> can compute definite integrals of smooth real functions using Gauss-Legendre quadratures.
+ </p>
+
+ <h4>Description</h4>
+ <p>
+ The main idea of Gauss-Legendre quadratures is to find a set of <i>abcissa</i> \(\{t_1,\cdots,t_N\}\in[-1,1]^N\) and <i>weights</i> \(\{w_1,\cdots,w_N\}\in\mathbb R^N\) such that, if \(f\) were a polynomial of degree \(\leqslant2N-1\), then the integral would be equal to a discrete sum:
+ $$
+ \int_{a}^bdx\ f(x)=\sum_{i=1}^Nw_if\left(\frac{a+b}2+t_i\frac{b-a}2\right).
+ $$
+ In the general case, if \(f\) is \(\mathcal C^{2N}\), then
+ $$
+ \left|\int_{a}^bdx\ f(x)-\sum_{i=1}^Nw_if\left(\frac{a+b}2+t_i\frac{b-a}2\right)\right|
+ \leqslant \frac{N!^4}{(2N+1)(2N)!^3}\sup_{x\in[a,b]}\frac{d^{2N}f(x)}{dx^{2N}}.
+ $$
+ The number \(N\) is called the <i>order</i> of the integration.
+ </p>
+
+ <p>
+ As it turns out, the abcissa are the roots of the \(N\)-th Legendre polynomial \(L_N\), defined by the recursive equation
+ $$
+ (N+1)L_{N+1}(x)=(2N+1)xL_N(x)-NL_{N-1}(x),\quad
+ L_0(x)=1,\quad L_1(x)=x
+ $$
+ and the weights are
+ $$
+ w_i=\frac2{(1-x_i^2)L_N'(t_i)}.
+ $$
+ </p>
+
+ <h4>Implementation</h4>
+ <p>
+ This algorithm has been implemented using double, extended and multi-precision floats
+ <ul>
+
+ <li id="func_integrate_gauss">
+ <div style="vertical-align: top;">
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_integrate_gauss_double" style="display: inline-block; vertical-align: top">
+ int integrate_gauss_double(
+ </div>
+ <div style="display: inline-block; vertical-align: top">
+ double* out,<br>
+ int (*func)(double*, double, void*),<br>
+ double lower,<br>
+ double upper,<br>
+ array_double abcissa,<br>
+ array_double weights,<br>
+ void* extra_args)
+ </div>
+ </div>
+ </code>
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_integrate_gauss_ldouble" style="display: inline-block; vertical-align: top">
+ int integrate_gauss_ldouble(
+ </div>
+ <div style="display: inline-block; vertical-align: top">
+ long double* out,<br>
+ int (*func)(long double*, long double, void*),<br>
+ long double lower,<br>
+ long double upper,<br>
+ array_ldouble abcissa,<br>
+ array_ldouble weights,<br>
+ void* extra_args)
+ </div>
+ </div>
+ </code>
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_integrate_gauss_mpfr" style="display: inline-block; vertical-align: top">
+ int integrate_gauss_mpfr(
+ </div>
+ <div style="display: inline-block; vertical-align: top">
+ mpfr_t* out,<br>
+ int (*func)(mpfr_t*, mpfr_t, void*),<br>
+ mpfr_t lower,<br>
+ mpfr_t upper,<br>
+ array_mpfr abcissa,<br>
+ array_mpfr weights,<br>
+ void* extra_args)
+ </div>
+ </div>
+ </code>
+ </div>
+
+ <br>
+ <b>Description</b>: Compute a numerical approximation for the integral of a real function using Gauss quadratures.<br>
+ <br>
+
+ <b>Arguments</b>:
+ <ul>
+ <li>
+ <code>out</code>: pointer to the number to which the result will be written. If the number requires initialization (e.g. if it is an <code>mpfr_t</code>), then it must be initialized.
+ </li>
+ <li>
+ <code>func</code>: pointer to the function that computes the integrand \(f(x)\). It must be in the format specified in <a href="#subsec_functions">functions</a>.
+ </li>
+ <li>
+ <code>lower</code>: lower bound of the integration.
+ </li>
+ <li>
+ <code>upper</code>: upper bound of the integration.
+ </li>
+ <li>
+ <code>abcissa</code>: the abcissa used to compute the integral using Gauss quadratures. For Gauss-Legendre integration, they can be computed by the function <a href="#func_gauss_legendre_weights"><code>gauss_legendre_weights</code></a>.
+ </li>
+ <li>
+ <code>weights</code>: the weights used to compute the integral using Gauss quadratures. For Gauss-Legendre integration, they can be computed by the function <a href="#func_gauss_legendre_weights"><code>gauss_legendre_weights</code></a>.
+ </li>
+ <li>
+ <code>extra_args</code>: pointer to the extra arguments to be passed to the function <code>*func</code> when it is evaluated (see <a href="#subsec_functions">functions</a>).
+ </li>
+ </ul>
+ <br>
+ <b>Return value</b>: returns <code>0</code> on success, and
+ <ul>
+ <li><code>LIBINUM_ERROR_NAN</code> if any of the evaluations of <code>*func</code> returned <code>nan</code> or <code>infinity</code>.</li>
+ <li><code>LIBINUM_ERROR_SIZE_MISMATCH</code> if the lengths of the vectors <code>abcissa</code> and <code>weights</code> are different.</li>
+ </ul>
+ </li>
+ <br><br>
+
+ <li id="func_integrate_gauss_multithread">
+ <div style="vertical-align: top;">
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_integrate_gauss_multithread_double" style="display: inline-block; vertical-align: top">
+ int integrate_gauss_multithread_double(
+ </div>
+ <div style="display: inline-block; vertical-align: top;">
+ double* out,<br>
+ int (*func)(double*, double, void*),<br>
+ double lower,<br>
+ double upper,<br>
+ array_double abcissa,<br>
+ array_double weights,<br>
+ void* extra_args,<br>
+ unsigned int threads,<br>
+ array_pthread_t* thread_ids)
+ </div>
+ </div>
+ </code>
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_integrate_gauss_multithread_ldouble" style="display: inline-block; vertical-align: top">
+ int integrate_gauss_multithread_ldouble(
+ </div>
+ <div style="display: inline-block; vertical-align: top;">
+ long double* out,<br>
+ int (*func)(long double*, long double, void*),<br>
+ long double lower,<br>
+ long double upper,<br>
+ array_ldouble abcissa,<br>
+ array_ldouble weights,<br>
+ void* extra_args,<br>
+ unsigned int threads,<br>
+ array_pthread_t* thread_ids)
+ </div>
+ </div>
+ </code>
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_integrate_gauss_multithread_mpfr" style="display: inline-block; vertical-align: top">
+ int integrate_gauss_multithread_mpfr(
+ </div>
+ <div style="display: inline-block; vertical-align: top;">
+ mpfr_t* out,<br>
+ int (*func)(mpfr_t*, mpfr_t, void*),<br>
+ mpfr_t lower,<br>
+ mpfr_t upper,<br>
+ array_mpfr abcissa,<br>
+ array_mpfr weights,<br>
+ void* extra_args,<br>
+ unsigned int threads,<br>
+ array_pthread_t* thread_ids)
+ </div>
+ </div>
+ </code>
+ </div>
+
+ <b>Description</b>: Multithreaded version of <a href="#func_integrate_gauss"><code>integrate_gauss_*</code></a>, in which function calls are performed in parallel.<br>
+ <br>
+
+ <b>Arguments</b>: Same as <a href="#func_integrate_gauss"><code>integrate_gauss_*</code></a>, except for
+ <ul>
+ <li>
+ <code>threads</code>: number of threads to use for the computation.
+ </li>
+ <li>
+ <code>thread_ids</code>: pointer to an array in which the id of each thread is written to. The array must not be initialized. This array can then be used by each thread to identify themselves.
+ </li>
+ </ul>
+ <br>
+ <b>Return value</b>: Same as <a href="#func_integrate_gauss"><code>integrate_gauss_*</code></a>.
+ </li>
+ <br><br>
+
+ <li id="func_integrate_gauss_smarttmp">
+ <div style="vertical-align: top;">
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_integrate_gauss_smarttmp_mpfr" style="display: inline-block; vertical-align: top">
+ int integrate_gauss_smarttmp_mpfr(
+ </div>
+ <div style="display: inline-block; vertical-align: top;">
+ mpfr_t* out,<br>
+ int (*func)(mpfr_t*, mpfr_t, void*),<br>
+ mpfr_t lower,<br>
+ mpfr_t upper,<br>
+ array_mpfr abcissa,<br>
+ array_mpfr weights,<br>
+ array_mpfr* tmps,<br>
+ void* extra_args)
+ </div>
+ </div>
+ </code>
+ </div>
+
+ <b>Description</b>: Similar to <a href="#func_integrate_gauss"><code>integrate_gauss_*</code></a>, except that, if temporary floats are needed during the computation, they are saved to an array so that they can be re-used later on. This is useful to perform repeated integrations, in which it would be costly to re-allocate memory for temporary floats. When using this function, temporary floats are allocated as needed, but they are not discarded.<br>
+ <br>
+
+ <b>Arguments</b>: Same as <a href="#func_integrate_gauss"><code>integrate_gauss_*</code></a>, except for
+ <ul>
+ <li>
+ <code>tmps</code>: pointer to an array that is used to store temporary floats. The array must be initialized beforehand. When temporary floats are needed, the array is checked for available floats. If enough of them are already present in the array, then the routine uses them, if not, it enlarges the array and allocates as many extra floats as is needed. The floats in the array can then be re-used for other purposes.
+ </li>
+ </ul>
+ <br>
+ <b>Return value</b>: Same as <a href="#func_integrate_gauss"><code>integrate_gauss_*</code></a>.
+ </li>
+ <br><br>
+
+ <li id="func_integrate_gauss_smarttmp_multithread">
+ <div style="vertical-align: top;">
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_integrate_gauss_smarttmp_multithread_mpfr" style="display: inline-block; vertical-align: top">
+ int integrate_gauss_smarttmp_multithread_mpfr(
+ </div>
+ <div style="display: inline-block; vertical-align: top;">
+ mpfr_t* out,<br>
+ int (*func)(mpfr_t*, mpfr_t, void*),<br>
+ mpfr_t lower,<br>
+ mpfr_t upper,<br>
+ array_mpfr abcissa,<br>
+ array_mpfr weights,<br>
+ void* extra_args,<br>
+ unsigned int threads,<br>
+ array_pthread_t* thread_ids)
+ </div>
+ </div>
+ </code>
+ </div>
+
+ <b>Description</b>: Multithreaded version of <a href="#func_integrate_gauss_smarttmp"><code>integrate_gauss_smarttmp_*</code></a>, in which function calls are performed in parallel.<br>
+ <br>
+
+ <b>Arguments</b>: Same as <a href="#func_integrate_gauss"><code>integrate_gauss_smarttmp_*</code></a>, except for
+ <ul>
+ <li>
+ <code>threads</code>: number of threads to use for the computation.
+ </li>
+ <li>
+ <code>thread_ids</code>: pointer to an array in which the id of each thread is written to. The array must not be initialized. This array can then be used by each thread to identify themselves.
+ </li>
+ </ul>
+ <br>
+ <b>Return value</b>: Same as <a href="#func_integrate_gauss"><code>integrate_gauss_*</code></a>.
+ </li>
+ <br><br>
+
+
+ <li id="func_gauss_legendre_weights">
+ <div style="vertical-align: top;">
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_gauss_legendre_weights_double" style="display: inline-block; vertical-align: top">
+ gauss_legendre_weights_double(
+ </div>
+ <div style="display: inline-block; vertical-align: top">
+ unsigned int order,<br>
+ double tolerance,<br>
+ unsigned int maxiter,<br>
+ array_double* abcissa,<br>
+ array_double* weights)
+ </div>
+ </div>
+ </code>
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_gauss_legendre_weights_ldouble" style="display: inline-block; vertical-align: top">
+ gauss_legendre_weights_ldouble(
+ </div>
+ <div style="display: inline-block; vertical-align: top">
+ unsigned int order,<br>
+ long double tolerance,<br>
+ unsigned int maxiter,<br>
+ array_ldouble* abcissa,<br>
+ array_ldouble* weights)
+ </div>
+ </div>
+ </code>
+
+ <code>
+ <div style="margin-bottom:20pt">
+ <div id="func_gauss_legendre_weights_mpfr" style="display: inline-block; vertical-align: top">
+ gauss_legendre_weights_mpfr(
+ </div>
+ <div style="display: inline-block; vertical-align: top">
+ unsigned int order,<br>
+ mpfr_t tolerance,<br>
+ unsigned int maxiter,<br>
+ array_mpfr* abcissa,<br>
+ array_mpfr* weights)
+ </div>
+ </div>
+ </code>
+ </div>
+
+ <b>Description</b>: Compute the Gauss-Legendre abcissa and weights.<br>
+ <br>
+
+ <b>Arguments</b>:
+ <ul>
+ <li>
+ <code>order</code>: the order \(N\) of the integration.
+ </li>
+ <li>
+ <code>tolerance</code>: tolerance for the Newton algorithm used to compute the roots of the Legendre polynomial (see <a href="#func_root_newton"><code>root_newton</code></a>).
+ </li>
+ <li>
+ <code>maxiter</code>: the maximal number of steps to compute before giving up.
+ </li>
+ <li>
+ <code>abcissa</code>: pointer to the <a href="#subsec_array">array</a> in which to write the abcissa. It must not be initialized.
+ </li>
+ <li>
+ <code>weights</code>: pointer to the <a href="#subsec_array">array</a> in which to write the weights. It must not be initialized.
+ </li>
+ </ul>
+ <br>
+ <b>Return value</b>: returns <code>0</code> on success, and
+ <ul>
+ <li><code>LIBINUM_ERROR_MAXITER</code> if, when computing the roots of the Legendre polynomial using a Newton iteration, the maximal number of iterations was reached.</li>
+ </ul>
+ </li>
+ </ul>
+
+ <h2 class="section" id="sec_types">Types</h2>
+ <p>
+ What follows is a detailed description of the C types defined in <b>libinum</b>.
+ </p>
+
+ <h3 class="subsection" id="subsec_array"><code>array</code></h3>
+ <p>Array that can be dynamically resized.</p>
+
+
+ <h4>Structure</h4>
+ Arrays of several types of objects are defined. They are structures, with the following keys:
+
+ <ul>
+
+ <li id="struct_array_int">
+ <code>array_int</code>:
+ <code>{ int* values, unsigned int length, unsigned int memory }</code>
+ </li>
+
+ <li id="struct_array_uint">
+ <code>array_uint</code>:
+ <code>{ unsigned int* values, unsigned int length, unsigned int memory }</code>
+ </li>
+
+ <li id="struct_array_double">
+ <code>array_double</code>:
+ <code>{ double* values, unsigned int length, unsigned int memory }</code>
+ </li>
+
+ <li id="struct_array_ldouble">
+ <code>array_ldouble</code>:
+ <code>{ long double* values, unsigned int length, unsigned int memory }</code>
+ </li>
+
+ <li id="struct_array_mpfr">
+ <code>array_mpfr</code>:
+ <code>{ mpfr_t* values, unsigned int length, unsigned int memory }</code>
+ </li>
+
+ <li id="struct_array_2_mpfr">
+ <code>array_2_mpfr</code>:
+ <code>{ array_mpfr* values, unsigned int length, unsigned int memory }</code>
+ </li>
+
+ <li id="struct_array_char">
+ <code>array_char</code>:
+ <code>{ char* values, unsigned int length, unsigned int memory }</code>
+ </li>
+
+ <li id="struct_array_str">
+ <code>array_str</code>:
+ <code>{ array_char* values, unsigned int length, unsigned int memory }</code>
+ </li>
+
+ <li id="struct_array_polynomial_double">
+ <code>array_polynomial_double</code>:
+ <code>{ polynomial_double* values, unsigned int length, unsigned int memory }</code>
+ </li>
+
+ <li id="struct_array_polynomial_ldouble">
+ <code>array_polynomial_ldouble</code>:
+ <code>{ polynomial_ldouble* values, unsigned int length, unsigned int memory }</code>
+ </li>
+
+ <li id="struct_array_polynomial_mpfr">
+ <code>array_polynomial_mpfr</code>:
+ <code>{ polynomial_mpfr* values, unsigned int length, unsigned int memory }</code>
+ </li>
+
+ <li id="struct_array_pthread_t">
+ <code>array_pthread_t</code>:
+ <code>{ pthread_t* values, unsigned int length, unsigned int memory }</code>
+ </li>
+ </ul>
+ where the keys correspond to
+ <ul>
+ <li><code>values</code>: the array in which the objects are stored</li>
+ <li><code>length</code>: the number of elements in the array</li>
+ <li><code>memory</code>: the number of elements allocated to the array</li>
+ </ul>
+ <code>array_*</code>'s must be initialized before they are used, and freed when they are no longer needed. khen the array is freed, the objects it contains are freed as well.
+
+ <h4>Functions</h4>
+ <ul>
+ <li id="func_array_init">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_init_int">int array_int_init(array_int* array, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_init_uint">int array_uint_init(array_uint* array, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_init_double">int array_double_init(array_double* array, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_init_ldouble">int array_ldouble_init(array_ldouble* array, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_init_mpfr">int array_mpfr_init(array_mpfr* array, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_init_2_mpfr">int array_2_mpfr_init(array_2_mpfr* array, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_init_char">int array_char_init(array_char* array, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_init_str">int array_str_init(array_str* array, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_init_polynomial_double">int array_polynomial_double_init(array_polynomial_double* array, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_init_polynomial_ldouble">int array_polynomial_ldouble_init(array_polynomial_ldouble* array, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_init_polynomial_mpfr">int array_polynomial_mpfr_init(array_polynomial_mpfr* array, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_init_pthread_t">int array_pthread_t_init(array_pthread_t* array, unsigned int memory)</code>
+ </div>
+ <br>
+ initialize the array pointed to by <code>array</code>, and allocate <code>memory</code> elements.
+ </li>
+ <br>
+ <li id="func_array_free">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_int">int array_int_free(array_int array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_uint">int array_uint_free(array_uint array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_double">int array_double_free(array_double array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_ldouble">int array_ldouble_free(array_ldouble array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_mpfr">int array_mpfr_free(array_mpfr array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_2_mpfr">int array_2_mpfr_free(array_2_mpfr array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_char">int array_char_free(array_char array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_str">int array_str_free(array_str array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_polynomial_double">int array_polynomial_double_free(array_polynomial_double array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_polynomial_ldouble">int array_polynomial_ldouble_free(array_polynomial_ldouble array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_polynomial_mpfr">int array_polynomial_mpfr_free(array_polynomial_mpfr array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_pthread_t">int array_pthread_t_free(array_pthread_t array)</code><br>
+ </div>
+ <br>
+ free the array <code>array</code>.
+ </li>
+ <br>
+ <li id="func_array_free_vects">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_vects_mpfr">int array_mpfr_free_vects(array_mpfr array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_vects_2_mpfr">int array_2_mpfr_free_vects(array_2_mpfr array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_vects_str">int array_str_free_vects(array_str array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_vects_polynomial_double">int array_polynomial_double_free_vects(array_polynomial_double array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_vects_polynomial_ldouble">int array_polynomial_ldouble_free_vects(array_polynomial_ldouble array)</code><br>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_free_vects_polynomial_mpfr">int array_polynomial_mpfr_free_vects(array_polynomial_mpfr array)</code><br>
+ </div>
+ <br>
+ free the memory pointed to by <code>array.values</code>, but do not free the elements of the array.
+ </li>
+ <br>
+ <li id="func_array_resize">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_resize_int">int array_int_resize(array_int* array, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_resize_uint">int array_uint_resize(array_uint* array, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_resize_double">int array_double_resize(array_double* array, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_resize_ldouble">int array_ldouble_resize(array_ldouble* array, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_resize_mpfr">int array_mpfr_resize(array_mpfr* array, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_resize_2_mpfr">int array_2_mpfr_resize(array_2_mpfr* array, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_resize_char">int array_char_resize(array_char* array, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_resize_str">int array_str_resize(array_str* array, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_resize_polynomial_double">int array_polynomial_double_resize(array_polynomial_double* array, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_resize_polynomial_ldouble">int array_polynomial_ldouble_resize(array_polynomial_ldouble* array, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_resize_polynomial_mpfr">int array_polynomial_mpfr_resize(array_polynomial_mpfr* array, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_resize_pthread_t">int array_pthread_t_resize(array_pthread_t* array, unsigned int newsize)</code>
+ </div>
+ <br>
+ copy the array pointed to by <code>array</code> to another with memory <code>newsize</code>.
+ </li>
+ <br>
+ <li id="func_array_append">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_int">int array_int_append(int value, array_int* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_uint">int array_uint_append(unsigned int value, array_uint* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_double">int array_double_append(double value, array_double* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_ldouble">int array_ldouble_append(long double value, array_ldouble* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_mpfr">int array_mpfr_append(mpfr_t value, array_mpfr* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_2_mpfr">int array_2_mpfr_append(array_mpfr value, array_2_mpfr* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_char">int array_char_append(char value, array_char* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_str">int array_str_append(array_char value, array_str* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_polynomial_double">int array_polynomial_double_append(polynomial_double value, array_polynomial_double* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_polynomial_ldouble">int array_polynomial_ldouble_append(polynomial_ldouble value, array_polynomial_ldouble* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_polynomial_mpfr">int array_polynomial_mpfr_append(polynomial_mpfr value, array_polynomial_mpfr* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_pthread_t">int array_pthread_t_append(pthread_t value, array_pthread_t* array)</code>
+ </div>
+ <br>
+ append <code>value</code> to the end of the array pointed to by <code>array</code>. Resize the array if needed.
+ </li>
+ <br>
+ <li id="func_array_append_noinit">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_noinit_mpfr">int array_mpfr_append_noinit(int value, array_mpfr* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_noinit_2_mpfr">int array_2_mpfr_append_noinit(unsigned int value, array_2_mpfr* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_noinit_str">int array_str_append_noinit(double value, array_str* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_noinit_polynomial_double">int array_polynomial_double_append_noinit(long double value, array_polynomial_double* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_noinit_polynomial_ldouble">int array_polynomial_ldouble_append_noinit(mpfr_t value, array_polynomial_ldouble* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_noinit_polynomial_mpfr">int array_polynomial_mpfr_append_noinit(array_mpfr value, array_polynomial_mpfr* array)</code>
+ </div>
+ <br>
+ append <code>value</code> to the end of the array pointed to by <code>array</code>. Do not initialize the new value, instead, copy <code>value</code> to the end of <code>*array</code>. <code>value</code> must not be freed, since it will be freed when <code>*array</code> is. Resize the array if needed.
+ </li>
+ <br>
+ <li id="func_array_concat">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_int">int array_int_concat(array_int input, array_int* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_uint">int array_uint_concat(array_uint input, array_uint* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_double">int array_double_concat(array_double input, array_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_ldouble">int array_ldouble_concat(array_ldouble input, array_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_mpfr">int array_mpfr_concat(array_mpfr input, array_mpfr* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_2_mpfr">int array_2_mpfr_concat(array_2_mpfr input, array_2_mpfr* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_char">int array_char_concat(array_char input, array_char* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_str">int array_str_concat(array_str input, array_str* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_polynomial_double">int array_polynomial_double_concat(array_polynomial_double input, array_polynomial_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_polynomial_ldouble">int array_polynomial_ldouble_concat(array_polynomial_ldouble input, array_polynomial_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_polynomial_mpfr">int array_polynomial_mpfr_concat(array_polynomial_mpfr input, array_polynomial_mpfr* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_pthread_t">int array_pthread_t_concat(array_pthread_t input, array_pthread_t* output)</code>
+ </div>
+ <br>
+ append the values in <code>input</code> to the end of the array pointed to by <code>output</code>. Resize the array if needed.
+ </li>
+ <br>
+ <li id="func_array_cpy">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_int">int array_int_cpy(array_int input, array_int* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_uint">int array_uint_cpy(array_uint input, array_uint* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_double">int array_double_cpy(array_double input, array_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_ldouble">int array_ldouble_cpy(array_ldouble input, array_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_mpfr">int array_mpfr_cpy(array_mpfr input, array_mpfr* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_2_mpfr">int array_2_mpfr_cpy(array_2_mpfr input, array_2_mpfr* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_char">int array_char_cpy(array_char input, array_char* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_str">int array_str_cpy(array_str input, array_str* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_polynomial_double">int array_polynomial_double_cpy(array_polynomial_double input, array_polynomial_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_polynomial_ldouble">int array_polynomial_ldouble_cpy(array_polynomial_ldouble input, array_polynomial_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_polynomial_mpfr">int array_polynomial_mpfr_cpy(array_polynomial_mpfr input, array_polynomial_mpfr* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_pthread_t">int array_pthread_t_cpy(array_pthread_t input, array_pthread_t* output)</code>
+ </div>
+ <br>
+ copy <code>input</code> to the array pointed to by <code>output</code>. Initializes <code>*output</code>.
+ </li>
+ <br>
+ <li id="func_array_cpy_noinit">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_noinit_int">int array_int_cpy_noinit(array_int input, array_int* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_noinit_uint">int array_uint_cpy_noinit(array_uint input, array_uint* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_noinit_double">int array_double_cpy_noinit(array_double input, array_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_noinit_ldouble">int array_ldouble_cpy_noinit(array_ldouble input, array_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_noinit_mpfr">int array_mpfr_cpy_noinit(array_mpfr input, array_mpfr* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_noinit_2_mpfr">int array_2_mpfr_cpy_noinit(array_2_mpfr input, array_2_mpfr* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_noinit_char">int array_char_cpy_noinit(array_char input, array_char* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_noinit_str">int array_str_cpy_noinit(array_str input, array_str* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_noinit_polynomial_double">int array_polynomial_double_cpy_noinit(array_polynomial_double input, array_polynomial_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_noinit_polynomial_ldouble">int array_polynomial_ldouble_cpy_noinit(array_polynomial_ldouble input, array_polynomial_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_noinit_polynomial_mpfr">int array_polynomial_mpfr_cpy_noinit(array_polynomial_mpfr input, array_polynomial_mpfr* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cpy_noinit_pthread_t">int array_pthread_t_cpy_noinit(array_pthread_t input, array_pthread_t* output)</code>
+ </div>
+ <br>
+ copy <code>input</code> to the array pointed to by <code>output</code>. Does not initialize <code>*output</code>, so <code>*output</code> must be initialized ahead of time, and its memory must be larger or equal to the length of <code>input</code>. Returns <code>LIBINUM_ERROR_SIZE_MISMATCH</code> if the memory of <code>*output</code> is smaller than the length of <code>input</code>.
+ </li>
+ <br>
+ <li id="func_array_subarray">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_subarray_int">int array_int_subarray(array_int array, unsigned int begin, unsigned int end, array_int* subarray)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_subarray_uint">int array_uint_subarray(array_uint array, unsigned int begin, unsigned int end, array_uint* subarray)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_subarray_double">int array_double_subarray(array_double array, unsigned int begin, unsigned int end, array_double* subarray)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_subarray_ldouble">int array_ldouble_subarray(array_ldouble array, unsigned int begin, unsigned int end, array_ldouble* subarray)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_subarray_mpfr">int array_mpfr_subarray(array_mpfr array, unsigned int begin, unsigned int end, array_mpfr* subarray)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_subarray_2_mpfr">int array_2_mpfr_subarray(array_2_mpfr array, unsigned int begin, unsigned int end, array_2_mpfr* subarray)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_subarray_char">int array_char_subarray(array_char array, unsigned int begin, unsigned int end, array_char* subarray)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_subarray_str">int array_str_subarray(array_str array, unsigned int begin, unsigned int end, array_str* subarray)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_subarray_polynomial_double">int array_polynomial_double_subarray(array_polynomial_double array, unsigned int begin, unsigned int end, array_polynomial_double* subarray)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_subarray_polynomial_ldouble">int array_polynomial_ldouble_subarray(array_polynomial_ldouble array, unsigned int begin, unsigned int end, array_polynomial_ldouble* subarray)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_subarray_polynomial_mpfr">int array_polynomial_mpfr_subarray(array_polynomial_mpfr array, unsigned int begin, unsigned int end, array_polynomial_mpfr* subarray)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_subarray_pthread_t">int array_pthread_t_subarray(array_pthread_t array, unsigned int begin, unsigned int end, array_pthread_t* subarray)</code>
+ </div>
+ <br>
+ extract the sub-array of <code>array</code> whose indices are larger or equal to <code>begin</code> and smaller or equal to <code>end</code>. Returns <code>LIBINUM_ERROR_ILLEGAL_MEMORY_ACCESS</code> if the subarray does not exist.
+ </li>
+ <br>
+ <li id="func_array_print">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_print_int">int array_int_print(array_int array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_print_uint">int array_uint_print(array_uint array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_print_double">int array_double_print(array_double array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_print_ldouble">int array_ldouble_print(array_ldouble array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_print_mpfr">int array_mpfr_print(array_mpfr array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_print_2_mpfr">int array_2_mpfr_print(array_2_mpfr array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_print_char">int array_char_print(array_char array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_print_str">int array_str_print(array_str array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_print_polynomial_double">int array_polynomial_double_print(array_polynomial_double array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_print_polynomial_ldouble">int array_polynomial_ldouble_print(array_polynomial_ldouble array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_print_polynomial_mpfr">int array_polynomial_mpfr_print(array_polynomial_mpfr array)</code>
+ </div>
+ <br>
+ print the elements of <code>array</code>.
+ </li>
+ </ul>
+
+ <h4>Extra functions for arrays of ordered objects</h4>
+ In addition, we define the following ordering for the possible objects in an array:
+ <ul>
+ <li>the obvious ordering for <code>int, unsigned int, double, long double, mpfr, char</code></li>
+ <li>lexicographical ordering for <code>array_char</code></li>
+ <li>no ordering for <code>polynomial_*</code>.</li>
+ </ul>
+ If the ordering is defined, then the following functions are defined:
+
+ <ul>
+ <li id="func_array_append_unique">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_unique_int">int array_int_append_unique(int value, array_int* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_unique_uint">int array_uint_append_unique(unsigned int value, array_uint* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_unique_double">int array_double_append_unique(double value, array_double* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_unique_ldouble">int array_ldouble_append_unique(long double value, array_ldouble* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_unique_mpfr">int array_mpfr_append_unique(mpfr_t value, array_mpfr* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_unique_2_mpfr">int array_2_mpfr_append_unique(array_mpfr value, array_2_mpfr* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_unique_char">int array_char_append_unique(char value, array_char* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_unique_str">int array_str_append_unique(array_char value, array_str* array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_append_unique_pthread_t">int array_pthread_t_append_unique(pthread_t value, array_pthread_t* array)</code>
+ </div>
+ <br>
+ if <code>value</code> is not already present in the array pointed to by <code>array</code>, then append it. Resize the array if needed.
+ </li>
+ <br>
+ <li id="func_array_concat_unique">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_unique_int">int array_int_concat_unique(array_int input, array_int* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_unique_uint">int array_uint_concat_unique(array_uint input, array_uint* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_unique_double">int array_double_concat_unique(array_double input, array_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_unique_ldouble">int array_ldouble_concat_unique(array_ldouble input, array_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_unique_mpfr">int array_mpfr_concat_unique(array_mpfr input, array_mpfr* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_unique_2_mpfr">int array_2_mpfr_concat_unique(array_2_mpfr input, array_2_mpfr* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_unique_char">int array_char_concat_unique(array_char input, array_char* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_unique_str">int array_str_concat_unique(array_str input, array_str* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_concat_unique_pthread_t">int array_pthread_t_concat_unique(array_pthread_t input, array_pthread_t* output)</code>
+ </div>
+ <br>
+ append the values in <code>input</code> that are not already present in the array pointed to by <code>output</code>. Resize the array if needed.
+ </li>
+ <br>
+ <li id="func_array_find">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_find_int">int array_int_find(int val, array_int array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_find_uint">int array_uint_find(unsigned int val, array_uint array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_find_double">int array_double_find(double val, array_double array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_find_ldouble">int array_ldouble_find(long double val, array_ldouble array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_find_mpfr">int array_mpfr_find(mpfr_t val, array_mpfr array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_find_2_mpfr">int array_2_mpfr_find(array_mpfr val, array_2_mpfr array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_find_char">int array_char_find(char val, array_char array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_find_str">int array_str_find(array_char val, array_str array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_find_pthread_t">int array_pthread_t_find(pthread_t val, array_pthread_t array)</code>
+ </div>
+ <br>
+ search for <code>val</code> in <code>array</code>. Returns the index of <code>val</code> in <code>array</code> if it is present, and <code>-1</code> if it is not.
+ </li>
+ <br>
+ <li id="func_array_sort">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_int">int array_int_sort(array_int array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_uint">int array_uint_sort(array_uint array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_double">int array_double_sort(array_double array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_ldouble">int array_ldouble_sort(array_ldouble array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_mpfr">int array_mpfr_sort(array_mpfr array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_2_mpfr">int array_2_mpfr_sort(array_2_mpfr array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_char">int array_char_sort(array_char array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_str">int array_str_sort(array_str array)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_pthread_t">int array_pthread_t_sort(array_pthread_t array)</code>
+ </div>
+ <br>
+ sort the elements of <code>array</code> from smallest to largest (for numerical values, the ordering relation is the usual one, for characters and strings, the lexicographical ordering is used). The sorting is performed in place. The <i>quicksort</i> algorithm is used.
+ </li>
+ <br>
+ <li id="func_array_sort_sub">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_sub_int">int array_int_sort_sub(array_int array, unsigned int begin, unsigned int end)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_sub_uint">int array_uint_sort_sub(array_uint array, unsigned int begin, unsigned int end)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_sub_double">int array_double_sort_sub(array_double array, unsigned int begin, unsigned int end)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_sub_ldouble">int array_ldouble_sort_sub(array_ldouble array, unsigned int begin, unsigned int end)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_sub_mpfr">int array_mpfr_sort_sub(array_mpfr array, unsigned int begin, unsigned int end)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_sub_2_mpfr">int array_2_mpfr_sort_sub(array_2_mpfr array, unsigned int begin, unsigned int end)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_sub_char">int array_char_sort_sub(array_char array, unsigned int begin, unsigned int end)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_sub_str">int array_str_sort_sub(array_str array, unsigned int begin, unsigned int end)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_sort_sub_pthread_t">int array_pthread_t_sort_sub(array_pthread_t array, unsigned int begin, unsigned int end)</code>
+ </div>
+ <br>
+ sort the elements of the sub-array of <code>array</code> consisting of the elements whose index is larger or equal than <code>begin</code> and smaller or equal than <code>end</code>. The sorting is performed in place. The <i>quicksort</i> algorithm is used.
+ </li>
+ <br>
+ <li id="func_array_cmp">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cmp_int">int array_int_cmp(array_int array1, array_int array2)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cmp_uint">int array_uint_cmp(array_uint array1, array_uint array2)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cmp_double">int array_double_cmp(array_double array1, array_double array2)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cmp_ldouble">int array_ldouble_cmp(array_ldouble array1, array_ldouble array2)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cmp_mpfr">int array_mpfr_cmp(array_mpfr array1, array_mpfr array2)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cmp_2_mpfr">int array_2_mpfr_cmp(array_2_mpfr array1, array_2_mpfr array2)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cmp_char">int array_char_cmp(array_char array1, array_char array2)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cmp_str">int array_str_cmp(array_str array1, array_str array2)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_array_cmp_pthread_t">int array_pthread_t_cmp(array_pthread_t array1, array_pthread_t array2)</code>
+ </div>
+ <br>
+ compare <code>array1</code> and <code>array2</code>. Returns <code>0</code> if both arrays are equal (that is, if their elements are the same, and in the same order), <code>-1</code> if <code>array1</code> is smaller than <code>array2</code> in lexicographical order, and <code>1</code> if <code>array1</code> is smaller than <code>array2</code> in lexicographical order.
+ </li>
+ </ul>
+
+ <h4>Extra functions for <code>array_char</code></h4>
+ In addition, the following functions are defined for <code>array_char</code>.
+ <ul>
+ <li id="func_array_char_append_str">
+ <code>int array_char_append_str(char* str, array_char* output)</code><br>
+ append the characters in <code>str</code> to the end of the array pointed to by <code>output</code>. Resize the array if needed.
+ </li>
+ <li id="func_array_char_to_str">
+ <code>int array_char_to_str(array_char input, char** output)</code><br>
+ copy the string in <code>input</code> to the string pointed to by <code>output</code>. Initializes <code>*output</code>.
+ </li>
+ <li id="func_array_char_to_str_noinit">
+ <code>char* array_char_to_str(array_char* input)</code><br>
+ convert the array pointed to by <code>input</code> to a string, and return it. Appends <code>'\0'</code> at the end of <code>*input</code>. The string thus generated should not be freed, since it is actually a pointer to <code>input->str</code>, which is freed when <code>*input</code> is.
+ </li>
+ <li id="func_str_to_array_char">
+ <code>int str_to_array_char(char* str, array_char* output)</code><br>
+ copy the string <code>input</code> to the array pointed to by <code>output</code>. Initializes <code>*output</code>.
+ </li>
+ <li id="func_array_char_cmp_str">
+ <code>int array_char_cmp_str(array_char array_char, char* str)</code><br>
+ compare the string in <code>array_char</code> and the string <code>str</code>. Returns <code>1</code> if the strings are identical, and <code>0</code> if not.
+ </li>
+ <li id="func_array_char_snprintf">
+ <code>int array_char_snprintf(array_char* output, char* fmt)</code><br>
+ reads the format <code>fmt</code> and appends the output to the array pointed to by <code>output</code>. The format should follow the specifications of the standard C function <code>printf</code>.
+ </li>
+ </ul>
+
+
+ <h3 class="subsection" id="subsec_polynomial"><code>polynomial</code></h3>
+ <p>A polynomial with real coefficients. A <code>polynomial</code> is represented as an array of coefficients and an array of exponents. For example \(1+x+2x^2\) is represented as <code>({1.,1.,2.},{0,1,2})</code>.</p>
+
+ <h4>Structure</h4>
+ The coefficients of polynomials can be double, extended, or multi-precision floats, and their exponents are unsigned integers. Polynomials are represented as structures, with the following keys:
+
+
+ <ul>
+
+ <li id="struct_polynomial_double">
+ <code>polynomial_double</code>:
+ <code>{ array_double coefficients, array_uint orders }</code>
+ </li>
+
+ <li id="struct_polynomial_ldouble">
+ <code>polynomial_ldouble</code>:
+ <code>{ array_ldouble coefficients, array_uint orders }</code>
+ </li>
+
+ <li id="struct_polynomial_mpfr">
+ <code>polynomial_mpfr</code>:
+ <code>{ array_mpfr coefficients, array_uint orders }</code>
+ </li>
+ </ul>
+ where the keys correspond to
+ <ul>
+ <li><code>coefficients</code>: array of coefficients</li>
+ <li><code>orders</code>: array of exponents.</li>
+ </ul>
+ <code>polynomial_*</code>'s must be initialized before they are used, and freed when they are no longer needed.
+
+ <h4>Functions</h4>
+ <ul>
+ <li id="func_polynomial_init">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_init_double">polynomial_double_init(polynomial_double* poly, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_init_ldouble">polynomial_ldouble_init(polynomial_ldouble* poly, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_init_mpfr">polynomial_mpfr_init(polynomial_mpfr* poly, unsigned int memory)</code>
+ </div>
+ <br>
+ initialize the polynomial pointed to by <code>poly</code>, and allocate <code>memory</code> terms.
+ </li>
+ <br>
+ <li id="func_polynomial_free">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_free_double">polynomial_double_free(polynomial_double poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_free_ldouble">polynomial_ldouble_free(polynomial_ldouble poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_free_mpfr">polynomial_mpfr_free(polynomial_mpfr poly)</code>
+ </div>
+ <br>
+ free the polynomial <code>poly</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_resize">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_resize_double">polynomial_double_resize(polynomial_double* poly, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_resize_ldouble">polynomial_ldouble_resize(polynomial_ldouble* poly, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_resize_mpfr">polynomial_mpfr_resize(polynomial_mpfr* poly, unsigned int newsize)</code>
+ </div>
+ <br>
+ copy the array polynomial to by <code>poly</code> to another with memory <code>newsize</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_append">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_append_double">polynomial_double_add_monomial(double val, unsigned int order, polynomial_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_append_ldouble">polynomial_ldouble_add_monomial(long double val, unsigned int order, polynomial_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_append_mpfr">polynomial_mpfr_add_monomial(mpfr_t val, unsigned int order, polynomial_mpfr* output)</code>
+ </div>
+ <br>
+ add a term with coefficient <code>val</code> and exponent <code>order</code> to the polynomial pointed to by <code>output</code>. Resize the polynomial if needed.
+ </li>
+ <br>
+ <li id="func_polynomial_append_d">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_append_d_ldouble">polynomial_ldouble_add_monomial_dui(double val, unsigned int order, polynomial_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_append_d_mpfr">polynomial_mpfr_add_monomial_dui(double val, unsigned int order, polynomial_mpfr* output)</code>
+ </div>
+ <br>
+ add a term with coefficient <code>val</code> (converted from a <code>double</code>) and exponent <code>order</code> (converted from an <code>unsigned int</code>) to the polynomial pointed to by <code>output</code>. Resize the polynomial if needed.
+ </li>
+ <br>
+ <li id="func_polynomial_cpy">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_cpy_double">polynomial_double_cpy(polynomial_double input, polynomial_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_cpy_ldouble">polynomial_ldouble_cpy(polynomial_ldouble input, polynomial_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_cpy_mpfr">polynomial_mpfr_cpy(polynomial_mpfr input, polynomial_mpfr* output)</code>
+ </div>
+ <br>
+ copy <code>input</code> to the polynomial pointed to by <code>output</code>. Initializes <code>*output</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_cpy_noinit">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_cpy_noinit_double">polynomial_double_cpy_noinit(polynomial_double input, polynomial_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_cpy_noinit_ldouble">polynomial_ldouble_cpy_noinit(polynomial_ldouble input, polynomial_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_cpy_noinit_mpfr">polynomial_mpfr_cpy_noinit(polynomial_mpfr input, polynomial_mpfr* output)</code>
+ </div>
+ <br>
+ copy <code>input</code> to the polynomial pointed to by <code>output</code>. Does not initialize <code>*output</code>, so <code>*output</code> must be initialized ahead of time, and its memory must be larger or equal to the length of <code>input</code>. Returns <code>LIBINUM_ERROR_SIZE_MISMATCH</code> if the memory of <code>*output</code> is smaller than the length of <code>input</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_add">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_add_double">polynomial_double_add(polynomial poly1, polynomial_double poly2, polynomial_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_add_ldouble">polynomial_ldouble_add(polynomial poly1, polynomial_ldouble poly2, polynomial_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_add_mpfr">polynomial_mpfr_add(polynomial poly1, polynomial_mpfr poly2, polynomial_mpfr* output)</code>
+ </div>
+ <br>
+ add <code>poly1</code> and <code>poly2</code> and write the result to the polynomial pointed to by <code>output</code>. Initializes <code>*output</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_add_inplace">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_add_inplace_double">polynomial_double_add_inplace(polynomial_double poly1, polynomial_double* poly2)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_add_inplace_ldouble">polynomial_ldouble_add_inplace(polynomial_ldouble poly1, polynomial_ldouble* poly2)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_add_inplace_mpfr">polynomial_mpfr_add_inplace(polynomial_mpfr poly1, polynomial_mpfr* poly2)</code>
+ </div>
+ <br>
+ add <code>poly1</code> and <code>*poly2</code> and write the result to the polynomial pointed to by <code>poly2</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_mul_scalar">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_scalar_double">polynomial_double_mul_scalar(double x, polynomial_double poly, polynomial_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_scalar_ldouble">polynomial_ldouble_mul_scalar(long double x, polynomial_ldouble poly, polynomial_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_scalar_mpfr">polynomial_mpfr_mul_scalar(mpfr_t x, polynomial_mpfr poly, polynomial_mpfr* output)</code>
+ </div>
+ <br>
+ multiply <code>x</code> and <code>poly</code> and write the result to the polynomial pointed to by <code>output</code>. Initializes <code>*output</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_mul_scalar_inplace">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_scalar_inplace_double">polynomial_double_mul_scalar_inplace(double x, polynomial_double* poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_scalar_inplace_ldouble">polynomial_ldouble_mul_scalar_inplace(long double x, polynomial_ldouble* poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_scalar_inplace_mpfr">polynomial_mpfr_mul_scalar_inplace(mpfr_t x, polynomial_mpfr* poly)</code>
+ </div>
+ <br>
+ multiply <code>x</code> and <code>*poly</code> and write the result to the polynomial pointed to by <code>poly</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_mul_monomial">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_monomial_double">polynomial_double_mul_monomial(double x, unsigned int order, polynomial_double poly, polynomial_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_monomial_ldouble">polynomial_ldouble_mul_monomial(long double x, unsigned int order, polynomial_ldouble poly, polynomial_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_monomial_mpfr">polynomial_mpfr_mul_monomial(mpfr_t x, unsigned int order, polynomial_mpfr poly, polynomial_mpfr* output)</code>
+ </div>
+ <br>
+ multiply <code>poly</code> and the monomial whose coefficient and exponent are <code>x</code> and <code>order</code>, and write the result to the polynomial pointed to by <code>output</code>. Initializes <code>*output</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_mul_monomial_inplace">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_monomial_inplace_double">polynomial_double_mul_monomial_inplace(double x, unsigned int order, polynomial_double* poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_monomial_inplace_ldouble">polynomial_ldouble_mul_monomial_inplace(long double x, unsigned int order, polynomial_ldouble* poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_monomial_inplace_mpfr">polynomial_mpfr_mul_monomial_inplace(mpfr_t x, unsigned int order, polynomial_mpfr* poly)</code>
+ </div>
+ <br>
+ multiply <code>*poly</code> and the monomial whose coefficient and exponent are <code>x</code> and <code>order</code>, and write the result to the polynomial pointed to by <code>poly</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_mul">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_double">polynomial_double_mul(polynomial_double poly1, polynomial_double poly2, polynomial_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_ldouble">polynomial_ldouble_mul(polynomial_ldouble poly1, polynomial_ldouble poly2, polynomial_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_mpfr">polynomial_mpfr_mul(polynomial_mpfr poly1, polynomial_mpfr poly2, polynomial_mpfr* output)</code>
+ </div>
+ <br>
+ multiply <code>poly1</code> and <code>poly2</code> and write the result to the polynomial pointed to by <code>output</code>. Initializes <code>*output</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_mul_inplace">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_inplace_double">polynomial_double_mul_inplace(polynomial_double poly1, polynomial_double* poly2)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_inplace_ldouble">polynomial_ldouble_mul_inplace(polynomial_ldouble poly1, polynomial_ldouble* poly2)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_mul_inplace_mpfr">polynomial_mpfr_mul_inplace(polynomial_mpfr poly1, polynomial_mpfr* poly2)</code>
+ </div>
+ <br>
+ multiply <code>poly1</code> and <code>*poly2</code> and write the result to the polynomial pointed to by <code>poly2</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_derive">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_derive_double">polynomial_double_derive(polynomial_double poly, polynomial_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_derive_ldouble">polynomial_ldouble_derive(polynomial_ldouble poly, polynomial_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_derive_mpfr">polynomial_mpfr_derive(polynomial_mpfr poly, polynomial_mpfr* output)</code>
+ </div>
+ <br>
+ derive <code>poly</code> and write the result to the polynomial pointed to by <code>output</code>. Initializes <code>*output</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_derive_inplace">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_derive_inplace_double">polynomial_double_derive_inplace(polynomial_double* poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_derive_inplace_ldouble">polynomial_ldouble_derive_inplace(polynomial_ldouble* poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_derive_inplace_mpfr">polynomial_mpfr_derive_inplace(polynomial_mpfr* poly)</code>
+ </div>
+ <br>
+ derive <code>*poly</code> and write the result to the polynomial pointed to by <code>poly</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_evaluate">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_evaluate_double">polynomial_double_evaluate(double* out, double x, polynomial_double poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_evaluate_ldouble">polynomial_ldouble_evaluate(long double* out, long double x, polynomial_ldouble poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_evaluate_mpfr">polynomial_mpfr_evaluate(mpfr_t* out, mpfr_t x, polynomial_mpfr poly)</code>
+ </div>
+ <br>
+ evaluate <code>poly</code> at <code>x</code>, and write the result to <code>out</code>. <code>out</code> must be initialized if its type requires it.
+ </li>
+ <br>
+ <li id="func_polynomial_print">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_print_double">polynomial_double_print(polynomial_double poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_print_ldouble">polynomial_ldouble_print(polynomial_ldouble poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_print_mpfr">polynomial_mpfr_print(polynomial_mpfr poly)</code>
+ </div>
+ <br>
+ print <code>poly</code>.
+ </li>
+ <br>
+ <li id="func_polynomial_legendre">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_legendre_double">polynomial_double_legendre(unsigned int n, polynomial_double* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_legendre_ldouble">polynomial_ldouble_legendre(unsigned int n, polynomial_ldouble* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomial_legendre_mpfr">polynomial_mpfr_legendre(unsigned int n, polynomial_mpfr* output)</code>
+ </div>
+ <br>
+ compute the <code>n</code>-th Legendre polynomial, and write the output to the polynomial pointed to by <code>poly</code>. Initializes <code>*poly</code>.
+ </li>
+ </ul>
+
+ <h3 class="subsection" id="subsec_polynomialMV"><code>polynomialMV</code></h3>
+ <p>Multi-variable polynomials. A <code>polynomial</code> is represented as an array of coefficients and an array of arrays of indices, each of which represents a variable. For example, \(3x_1^2+x_1x_2\) is represented as <code>({3,1},{{1,1},{1,2}})</code>.</p>
+
+
+ <h4>Structure</h4>
+ The coefficients of multi-variable polynomials can be integers or multiprecision integers, and the indices are integers. Multi-variable polynomials are represented as structures, with the following keys:
+ <ul>
+
+ <li id="struct_polynomialMV_int">
+ <code>polynomialMV_int</code>:
+ <code>{ int* coefficients, array_int factors, unsigned int length, unsigned int memory }</code>
+ </li>
+
+ <li id="struct_polynomialMV_mpz">
+ <code>polynomialMV_mpz</code>:
+ <code>{ mpz_t* coefficients, array_int factors, unsigned int length, unsigned int memory }</code>
+ </li>
+ </ul>
+ where the keys correspond to
+ <ul>
+ <li><code>coefficients</code>: array of coefficients</li>
+ <li><code>factors</code>: array of <i>factors</i>, i.e. arrays of indices of variables</li>
+ <li><code>length</code>: the number of terms in the polynomial</li>
+ <li><code>memory</code>: the number of terms allocated to the polynomial</li>
+ </ul>
+ <code>polynomialMV_*</code>'s must be initialized before they are used, and freed when they are no longer needed. When the polynomial is freed, its coefficients and factors are freed as well.
+
+ <h4>Functions</h4>
+ <ul>
+ <li id="func_polynomialMV_init">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_init_int">polynomialMV_int_init(polynomialMV_int* poly, unsigned int memory)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_init_mpz">polynomialMV_mpz_init(polynomialMV_mpz* poly, unsigned int memory)</code>
+ </div>
+ <br>
+ initialize the polynomial pointed to by <code>poly</code>, and allocate <code>memory</code> terms.
+ </li>
+ <br>
+ <li id="func_polynomialMV_free">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_free_int">polynomialMV_int_free(polynomialMV_int poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_free_mpz">polynomialMV_mpz_free(polynomialMV_mpz poly)</code>
+ </div>
+ <br>
+ free the polynomial <code>poly</code>.
+ </li>
+ <br>
+ <li id="func_polynomialMV_resize">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_resize_int">polynomialMV_int_resize(polynomialMV_int* poly, unsigned int newsize)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_resize_mpz">polynomialMV_mpz_resize(polynomialMV_mpz* poly, unsigned int newsize)</code>
+ </div>
+ <br>
+ copy the array polynomial to by <code>poly</code> to another with memory <code>newsize</code>.
+ </li>
+ <br>
+ <li id="func_polynomialMV_cpy">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_cpy_int">polynomialMV_int_cpy(polynomialMV_int input, polynomialMV_int* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_cpy_mpz">polynomialMV_mpz_cpy(polynomialMV_mpz input, polynomialMV_mpz* output)</code>
+ </div>
+ <br>
+ copy <code>input</code> to the polynomial pointed to by <code>output</code>. Initializes <code>*output</code>.
+ </li>
+ <br>
+ <li id="func_polynomialMV_cpy_noinit">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_cpy_noinit_int">polynomialMV_int_cpy_noinit(polynomialMV_int input, polynomialMV_int* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_cpy_noinit_mpz">polynomialMV_mpz_cpy_noinit(polynomialMV_mpz input, polynomialMV_mpz* output)</code>
+ </div>
+ <br>
+ copy <code>input</code> to the polynomial pointed to by <code>output</code>. Does not initialize <code>*output</code>, so <code>*output</code> must be initialized ahead of time, and its memory must be larger or equal to the length of <code>input</code>. Returns <code>LIBINUM_ERROR_SIZE_MISMATCH</code> if the memory of <code>*output</code> is smaller than the length of <code>input</code>.
+ </li>
+ <br>
+ <li id="func_polynomialMV_append">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_append_int">polynomialMV_int_append(array_int factor, int coef, polynomialMV_int* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_append_mpz">polynomialMV_mpz_append(array_int factor, mpz_t coef, polynomialMV_mpz* output)</code>
+ </div>
+ <br>
+ add a term with coefficient <code>coef</code> and factor <code>factor</code> to the polynomial pointed to by <code>output</code>. Resize the polynomial if needed.
+ </li>
+ <br>
+ <li id="func_polynomialMV_append_inplace">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_append_inplace_int">polynomialMV_int_append_inplace(array_int factor, int coef, polynomialMV_int* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_append_inplace_mpz">polynomialMV_mpz_append_inplace(array_int factor, mpz_t coef, polynomialMV_mpz* output)</code>
+ </div>
+ <br>
+ same as <a href="#func_polynomialMV_append"><code>polynomialMV_*_append</code></a> except that if the factor is already present in the polynomial pointed to by <code>output</code>, then add <code>coef</code> to the coefficient of that factor, instead of appending it to the end of the polynomial. Resize the polynomial if needed.
+ </li>
+ <br>
+ <li id="func_polynomialMV_append_noinit">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_append_noinit_int">polynomialMV_int_append_noinit(array_int factor, int coef, polynomialMV_int* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_append_noinit_mpz">polynomialMV_mpz_append_noinit(array_int factor, mpz_t coef, polynomialMV_mpz* output)</code>
+ </div>
+ <br>
+ same as <a href="#func_polynomialMV_append"><code>polynomialMV_*_append</code></a> except that the new factor and coefficient to be appended to the polynomial pointed to by <code>output</code> are not allocated. Instead, pointers to <code>factor</code> and <code>coef</code> are appended. <code>factor</code> and <code>coef</code> must therefore not be freed (since they will be freed when <code>output</code> is). Resize the polynomial if needed.
+ </li>
+ <br>
+ <li id="func_polynomialMV_append_noinitfactor">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_append_noinitfactor_int">polynomialMV_int_append_noinitfactor(array_int factor, int coef, polynomialMV_int* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_append_noinitfactor_mpz">polynomialMV_mpz_append_noinitfactor(array_int factor, mpz_t coef, polynomialMV_mpz* output)</code>
+ </div>
+ <br>
+ same as <a href="#func_polynomialMV_append"><code>polynomialMV_*_append</code></a> except that the new factor to be appended to the polynomial pointed to by <code>output</code> is not allocated. Instead, a pointer to <code>factor</code> is appended. <code>factor</code> must therefore not be freed (since it will be freed when <code>output</code> is). <code>coef</code> is, however, copied and must be freed. Resize the polynomial if needed.
+ </li>
+ <br>
+ <li id="func_polynomialMV_append_noinit_inplace">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_append_noinit_inplace_int">polynomialMV_int_append_noinit_inplace(array_int factor, int coef, polynomial* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_append_noinit_inplace_mpz">polynomialMV_mpz_append_noinit_inplace(array_int factor, mpz_t coef, polynomial* output)</code>
+ </div>
+ <br>
+ same as <a href="#func_polynomialMV_append_noinit"><code>polynomialMV_*_append_noinit</code></a> except that if the factor is already present in the polynomial pointed to by <code>output</code>, then add <code>coef</code> to the coefficient of that factor, instead of appending it to the end of the polynomial. Resize the polynomial if needed.
+ </li>
+ <br>
+ <li id="func_polynomialMV_append_noinitfactor_inplace">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_append_noinitfactor_inplace_int">polynomialMV_int_append_noinit_inplace(array_int factor, int coef, polynomial* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_append_noinitfactor_inplace_mpz">polynomialMV_mpz_append_noinit_inplace(array_int factor, mpz_t coef, polynomial* output)</code>
+ </div>
+ <br>
+ same as <a href="#func_polynomialMV_append_noinitfactor"><code>polynomialMV_*_append_noinitfactor</code></a> except that if the factor is already present in the polynomial pointed to by <code>output</code>, then add <code>coef</code> to the coefficient of that factor, instead of appending it to the end of the polynomial. Resize the polynomial if needed.
+ </li>
+ <br>
+ <li id="func_polynomialMV_add">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_add_int">polynomialMV_int_add(polynomialMV_int poly1, polynomialMV_int poly2, polynomialMV_int* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_add_mpz">polynomialMV_mpz_add(polynomialMV_mpz poly1, polynomialMV_mpz poly2, polynomialMV_mpz* output)</code>
+ </div>
+ <br>
+ add <code>poly1</code> and <code>poly2</code> and write the result to the polynomial pointed to by <code>output</code>. Initializes <code>*output</code>.
+ </li>
+ <br>
+ <li id="func_polynomialMV_add_inplace">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_add_inplace_int">polynomialMV_int_add_inplace(polynomialMV_int poly1, polynomialMV_int* poly2)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_add_inplace_mpz">polynomialMV_mpz_add_inplace(polynomialMV_mpz poly1, polynomialMV_mpz* poly2)</code>
+ </div>
+ <br>
+ add <code>poly1</code> and <code>*poly2</code> and write the result to the polynomial pointed to by <code>poly2</code>.
+ </li>
+ <br>
+ <li id="func_polynomialMV_multiply_scalar">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_multiply_scalar_int">polynomialMV_int_multiply_scalar(polynomial poly, int num)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_multiply_scalar_mpz">polynomialMV_mpz_multiply_scalar(polynomial poly, mpz_t num)</code>
+ </div>
+ <br>
+ multiply <code>num</code> and <code>poly</code> and write the result to <code>poly</code>.
+ </li>
+ <br>
+ <li id="func_polynomialMV_prod">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_prod_int">polynomialMV_int_prod(polynomialMV_int poly1, polynomialMV_int poly2, polynomialMV_int* output)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_prod_mpz">polynomialMV_mpz_prod(polynomialMV_mpz poly1, polynomialMV_mpz poly2, polynomialMV_mpz* output)</code>
+ </div>
+ <br>
+ multiply <code>poly1</code> and <code>poly2</code> and write the result to the polynomial pointed to by <code>output</code>. Initializes <code>*output</code>.
+ </li>
+ <br>
+ <li id="func_polynomialMV_order">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_order_int">polynomialMV_int_order(polynomialMV_int poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_order_mpz">polynomialMV_mpz_order(polynomialMV_mpz poly)</code>
+ </div>
+ <br>
+ order the factors in <code>poly</code>, using <a href="#func_array_sort">array_*_sort</a>.
+ </li>
+ <br>
+ <li id="func_polynomialMV_print">
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_print_int">polynomialMV_int_print(polynomialMV_int poly)</code>
+ </div>
+
+ <div style="margin-bottom:5pt">
+ <code id="func_polynomialMV_print_mpz">polynomialMV_mpz_print(polynomialMV_mpz poly)</code>
+ </div>
+ <br>
+ print <code>poly</code>.
+ </li>
+ </ul>
+
+
+ <h3 class="subsection" id="subsec_functions">Functions</h3>
+ <p>
+ Functions are not, strictly speaking, a C type. Instead, in this section, we describe how functions whose pointers are to be passed to the various algorithms of <b>libinum</b>, should be formatted.
+ </p>
+
+ <p>
+ Functions must take 3 arguments, and return an integer (a return code):
+ <code class="codeblock">int f(TYPE* out, TYPE in, void* extra_args)</code>
+ where <code>TYPE</code> is the appropriate data type, e.g. <code>double</code> or <code>mpfr_t</code>. <code>in</code> is the argument of the function, <code>out</code> is made to point to \(f(\)<code>in</code>\()\), and <code>extra_args</code> is a pointer to void, which may contain extra arguments to be passed to the function, for example a parameter that the function depends on. For example, to implement the function \(f_\alpha(x)=x^\alpha\) using MPFR floats,
+ <code class=codeblock>
+<pre>
+int f(mpfr_t out, mpfr_t in, void* extra_args){
+ int alpha=*((*int)extra_args);
+ mpfr_pow_ui(out, in, alpha, MPFR_RNDN);
+ return(0);
+}
+</pre>
+ </code>
+ </p>
+
+ <h2 class="section" id="sec_utilities">Utilities</h2>
+ <p>
+ In addition, the following functions are defined
+ </p>
+ <ul>
+ <li id="func_fprint_double">
+ <code>fprint_double(FILE* file, double x)</code><br>
+ print <code>x</code> to <code>file</code>, with as many digits as possible.
+ </li>
+ <li id="func_fprint_ldouble">
+ <code>fprint_ldouble(FILE* file, long double x)</code><br>
+ print <code>x</code> to <code>file</code>, with as many digits as possible.
+ </li>
+ <li id="func_fprint_mpfr">
+ <code>fprint_mpfr(FILE* file, mpfr_t x)</code><br>
+ print <code>x</code> to <code>file</code>, with as many digits as allowed by the MPFR precision.
+ </li>
+ <li id="func_print_datatype_info">
+ <code>print_datatype_info()</code><br>
+ print miscellaneous information about integers and floats. Namely, the number of bits used in <code>char</code>, <code>short int</code>, <code>int</code>, <code>long int</code> and <code>long long int</code>; the precision and maximal and minimal exponents of <code>double</code> and <code>long double</code>; the type used to store the precision and emax of MPFR floats.
+ </li>
+ </ul>
+
+
+ <h2 class="section" id="sec_examples">Examples</h2>
+ <p>
+ Examples of programs using <b>libinum</b> are provided with the source code, in the <code>doc/libinum-examples</code> directory. If <b>libinum</b> is installed on the filesystem, then the examples can also be found at <code>/usr/share/doc/libinum/libinum-examples</code>.
+ </p>
+
+
+ <h2 class="section" id="sec_authors">Authors</h2>
+ <p>
+ <b>libinum</b> was written by Ian Jauslin.
+ </p>
+ </body>
+</html>