You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
186 lines
12 KiB
HTML
186 lines
12 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<!-- This manual is for GNU MPC, a library for multiple precision complex arithmetic,
|
|
version 1.0.3 of February 2015.
|
|
|
|
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 INRIA
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
any later version published by the Free Software Foundation; with no
|
|
Invariant Sections. A copy of the license is included in the section
|
|
entitled "GNU Free Documentation License." -->
|
|
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<title>Basic Arithmetic (GNU MPC 1.0.3)</title>
|
|
|
|
<meta name="description" content="Basic Arithmetic (GNU MPC 1.0.3)">
|
|
<meta name="keywords" content="Basic Arithmetic (GNU MPC 1.0.3)">
|
|
<meta name="resource-type" content="document">
|
|
<meta name="distribution" content="global">
|
|
<meta name="Generator" content="makeinfo">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<link href="index.html#Top" rel="start" title="Top">
|
|
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
|
|
<link href="Complex-Functions.html#Complex-Functions" rel="up" title="Complex Functions">
|
|
<link href="Power-Functions-and-Logarithm.html#Power-Functions-and-Logarithm" rel="next" title="Power Functions and Logarithm">
|
|
<link href="Projection-_0026-Decomposing.html#Projection-_0026-Decomposing" rel="prev" title="Projection & Decomposing">
|
|
<style type="text/css">
|
|
<!--
|
|
a.summary-letter {text-decoration: none}
|
|
blockquote.indentedblock {margin-right: 0em}
|
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
|
blockquote.smallquotation {font-size: smaller}
|
|
div.display {margin-left: 3.2em}
|
|
div.example {margin-left: 3.2em}
|
|
div.lisp {margin-left: 3.2em}
|
|
div.smalldisplay {margin-left: 3.2em}
|
|
div.smallexample {margin-left: 3.2em}
|
|
div.smalllisp {margin-left: 3.2em}
|
|
kbd {font-style: oblique}
|
|
pre.display {font-family: inherit}
|
|
pre.format {font-family: inherit}
|
|
pre.menu-comment {font-family: serif}
|
|
pre.menu-preformatted {font-family: serif}
|
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
|
pre.smallexample {font-size: smaller}
|
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
|
pre.smalllisp {font-size: smaller}
|
|
span.nolinebreak {white-space: nowrap}
|
|
span.roman {font-family: initial; font-weight: normal}
|
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
|
ul.no-bullet {list-style: none}
|
|
-->
|
|
</style>
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<a name="Basic-Arithmetic"></a>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="Power-Functions-and-Logarithm.html#Power-Functions-and-Logarithm" accesskey="n" rel="next">Power Functions and Logarithm</a>, Previous: <a href="Projection-_0026-Decomposing.html#Projection-_0026-Decomposing" accesskey="p" rel="prev">Projection & Decomposing</a>, Up: <a href="Complex-Functions.html#Complex-Functions" accesskey="u" rel="up">Complex Functions</a> [<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<hr>
|
|
<a name="Basic-Arithmetic-Functions"></a>
|
|
<h3 class="section">5.7 Basic Arithmetic Functions</h3>
|
|
<a name="index-Complex-arithmetic-functions"></a>
|
|
<a name="index-Arithmetic-functions"></a>
|
|
|
|
<p>All the following functions are designed in such a way that, when working
|
|
with real numbers instead of complex numbers, their complexity should
|
|
essentially be the same as with the GNU MPFR library, with only a marginal
|
|
overhead due to the GNU MPC layer.
|
|
</p>
|
|
<dl>
|
|
<dt><a name="index-mpc_005fadd"></a>Function: <em>int</em> <strong>mpc_add</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, mpc_t <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fadd_005fui"></a>Function: <em>int</em> <strong>mpc_add_ui</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, unsigned long int <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fadd_005ffr"></a>Function: <em>int</em> <strong>mpc_add_fr</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, mpfr_t <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dd><p>Set <var>rop</var> to <var>op1</var> <em>+</em> <var>op2</var> rounded according to <var>rnd</var>.
|
|
</p></dd></dl>
|
|
|
|
<dl>
|
|
<dt><a name="index-mpc_005fsub"></a>Function: <em>int</em> <strong>mpc_sub</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, mpc_t <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fsub_005ffr"></a>Function: <em>int</em> <strong>mpc_sub_fr</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, mpfr_t <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005ffr_005fsub"></a>Function: <em>int</em> <strong>mpc_fr_sub</strong> <em>(mpc_t <var>rop</var>, mpfr_t <var>op1</var>, mpc_t <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fsub_005fui"></a>Function: <em>int</em> <strong>mpc_sub_ui</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, unsigned long int <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fui_005fsub"></a>Macro: <em>int</em> <strong>mpc_ui_sub</strong> <em>(mpc_t <var>rop</var>, unsigned long int <var>op1</var>, mpc_t <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fui_005fui_005fsub"></a>Function: <em>int</em> <strong>mpc_ui_ui_sub</strong> <em>(mpc_t <var>rop</var>, unsigned long int <var>re1</var>, unsigned long int <var>im1</var>, mpc_t <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dd><p>Set <var>rop</var> to <var>op1</var> - <var>op2</var> rounded according to <var>rnd</var>.
|
|
For <code>mpc_ui_ui_sub</code>, <var>op1</var> is <var>re1</var> + <var>im1</var>.
|
|
</p></dd></dl>
|
|
|
|
<dl>
|
|
<dt><a name="index-mpc_005fneg"></a>Function: <em>int</em> <strong>mpc_neg</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dd><p>Set <var>rop</var> to -<var>op</var> rounded according to <var>rnd</var>.
|
|
Just changes the sign if <var>rop</var> and <var>op</var> are the same variable.
|
|
</p></dd></dl>
|
|
|
|
<dl>
|
|
<dt><a name="index-mpc_005fmul"></a>Function: <em>int</em> <strong>mpc_mul</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, mpc_t <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fmul_005fui"></a>Function: <em>int</em> <strong>mpc_mul_ui</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, unsigned long int <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fmul_005fsi"></a>Function: <em>int</em> <strong>mpc_mul_si</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, long int <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fmul_005ffr"></a>Function: <em>int</em> <strong>mpc_mul_fr</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, mpfr_t <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dd><p>Set <var>rop</var> to <var>op1</var> times <var>op2</var> rounded according to <var>rnd</var>.
|
|
Note: for <code>mpc_mul</code>, in case <var>op1</var> and <var>op2</var> have the same value,
|
|
use <code>mpc_sqr</code> for better efficiency.
|
|
</p></dd></dl>
|
|
|
|
<dl>
|
|
<dt><a name="index-mpc_005fmul_005fi"></a>Function: <em>int</em> <strong>mpc_mul_i</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op</var>, int <var>sgn</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dd><p>Set <var>rop</var> to <var>op</var> times the imaginary unit i if <var>sgn</var> is
|
|
non-negative, set <var>rop</var> to <var>op</var> times -i otherwise,
|
|
in both cases rounded according to <var>rnd</var>.
|
|
</p></dd></dl>
|
|
|
|
<dl>
|
|
<dt><a name="index-mpc_005fsqr"></a>Function: <em>int</em> <strong>mpc_sqr</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dd><p>Set <var>rop</var> to the square of <var>op</var> rounded according to <var>rnd</var>.
|
|
</p></dd></dl>
|
|
|
|
<dl>
|
|
<dt><a name="index-mpc_005ffma"></a>Function: <em>int</em> <strong>mpc_fma</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, mpc_t <var>op2</var>, mpc_t <var>op3</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dd><p>Set <var>rop</var> to <var>op1</var>*<var>op2</var>+<var>op3</var>,
|
|
rounded according to <var>rnd</var>, with only one final rounding.
|
|
</p></dd></dl>
|
|
|
|
<dl>
|
|
<dt><a name="index-mpc_005fdiv"></a>Function: <em>int</em> <strong>mpc_div</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, mpc_t <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fdiv_005fui"></a>Function: <em>int</em> <strong>mpc_div_ui</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, unsigned long int <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fdiv_005ffr"></a>Function: <em>int</em> <strong>mpc_div_fr</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, mpfr_t <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fui_005fdiv"></a>Function: <em>int</em> <strong>mpc_ui_div</strong> <em>(mpc_t <var>rop</var>, unsigned long int <var>op1</var>, mpc_t <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005ffr_005fdiv"></a>Function: <em>int</em> <strong>mpc_fr_div</strong> <em>(mpc_t <var>rop</var>, mpfr_t <var>op1</var>, mpc_t <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dd><p>Set <var>rop</var> to <var>op1</var>/<var>op2</var> rounded according to <var>rnd</var>.
|
|
</p></dd></dl>
|
|
|
|
<dl>
|
|
<dt><a name="index-mpc_005fconj"></a>Function: <em>int</em> <strong>mpc_conj</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dd><p>Set <var>rop</var> to the conjugate of <var>op</var> rounded according to <var>rnd</var>.
|
|
Just changes the sign of the imaginary part
|
|
if <var>rop</var> and <var>op</var> are the same variable.
|
|
</p></dd></dl>
|
|
|
|
<dl>
|
|
<dt><a name="index-mpc_005fabs"></a>Function: <em>int</em> <strong>mpc_abs</strong> <em>(mpfr_t <var>rop</var>, mpc_t <var>op</var>, mpfr_rnd_t <var>rnd</var>)</em></dt>
|
|
<dd><p>Set the floating-point number <var>rop</var> to the absolute value of <var>op</var>,
|
|
rounded in the direction <var>rnd</var>.
|
|
</p></dd></dl>
|
|
|
|
<dl>
|
|
<dt><a name="index-mpc_005fnorm"></a>Function: <em>int</em> <strong>mpc_norm</strong> <em>(mpfr_t <var>rop</var>, mpc_t <var>op</var>, mpfr_rnd_t <var>rnd</var>)</em></dt>
|
|
<dd><p>Set the floating-point number <var>rop</var> to the norm of <var>op</var>
|
|
(i.e., the square of its absolute value),
|
|
rounded in the direction <var>rnd</var>.
|
|
</p></dd></dl>
|
|
|
|
<dl>
|
|
<dt><a name="index-mpc_005fmul_005f2ui"></a>Function: <em>int</em> <strong>mpc_mul_2ui</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, unsigned long int <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fmul_005f2si"></a>Function: <em>int</em> <strong>mpc_mul_2si</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, long int <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dd><p>Set <var>rop</var> to <var>op1</var> times 2 raised to <var>op2</var>
|
|
rounded according to <var>rnd</var>. Just modifies the exponents
|
|
of the real and imaginary parts by <var>op2</var>
|
|
when <var>rop</var> and <var>op1</var> are identical.
|
|
</p></dd></dl>
|
|
|
|
<dl>
|
|
<dt><a name="index-mpc_005fdiv_005f2ui"></a>Function: <em>int</em> <strong>mpc_div_2ui</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, unsigned long int <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dt><a name="index-mpc_005fdiv_005f2si"></a>Function: <em>int</em> <strong>mpc_div_2si</strong> <em>(mpc_t <var>rop</var>, mpc_t <var>op1</var>, long int <var>op2</var>, mpc_rnd_t <var>rnd</var>)</em></dt>
|
|
<dd><p>Set <var>rop</var> to <var>op1</var> divided by 2 raised to <var>op2</var>
|
|
rounded according to <var>rnd</var>. Just modifies the exponents
|
|
of the real and imaginary parts by <var>op2</var>
|
|
when <var>rop</var> and <var>op1</var> are identical.
|
|
</p></dd></dl>
|
|
|
|
|
|
<hr>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="Power-Functions-and-Logarithm.html#Power-Functions-and-Logarithm" accesskey="n" rel="next">Power Functions and Logarithm</a>, Previous: <a href="Projection-_0026-Decomposing.html#Projection-_0026-Decomposing" accesskey="p" rel="prev">Projection & Decomposing</a>, Up: <a href="Complex-Functions.html#Complex-Functions" accesskey="u" rel="up">Complex Functions</a> [<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|