• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>complex128</title>
5<link rel="stylesheet" href="../../../multiprecision.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../../index.html" title="Chapter 1. Boost.Multiprecision">
8<link rel="up" href="../complex.html" title="Complex Number Types">
9<link rel="prev" href="mpc_complex.html" title="mpc_complex">
10<link rel="next" href="complex_adaptor.html" title="complex_adaptor">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="mpc_complex.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../complex.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="complex_adaptor.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h4 class="title">
27<a name="boost_multiprecision.tut.complex.complex128"></a><a class="link" href="complex128.html" title="complex128">complex128</a>
28</h4></div></div></div>
29<p>
30          <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">complex128</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
31        </p>
32<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">multiprecision</span><span class="special">{</span>
33
34<span class="keyword">class</span> <span class="identifier">complex128_backend</span><span class="special">;</span>
35
36<span class="keyword">typedef</span> <span class="identifier">number</span><span class="special">&lt;</span><span class="identifier">complex128_backend</span><span class="special">,</span> <span class="identifier">et_off</span><span class="special">&gt;</span>    <span class="identifier">complex128</span><span class="special">;</span>
37
38<span class="special">}}</span> <span class="comment">// namespaces</span>
39</pre>
40<p>
41          The <code class="computeroutput"><span class="identifier">complex128</span></code> number type
42          is a very thin wrapper around GCC's <code class="computeroutput"><span class="identifier">__float128</span></code>
43          or Intel's <code class="computeroutput"><span class="identifier">_Quad</span></code> data types
44          and provides a complex-number type that is a drop-in replacement for the
45          native C++ floating-point types, but with a 113 bit mantissa, and compatible
46          with FORTRAN's 128-bit QUAD real.
47        </p>
48<p>
49          All the usual standard library functions are available, performance should
50          be equivalent to the underlying native types.
51        </p>
52<p>
53          As well as the usual conversions from arithmetic and string types, instances
54          of <code class="computeroutput"><span class="identifier">float128</span></code> are copy constructible
55          and assignable from GCC's <code class="computeroutput"><span class="identifier">__float128</span></code>
56          and Intel's <code class="computeroutput"><span class="identifier">_Quad</span></code> data
57          types.
58        </p>
59<p>
60          Things you should know when using this type:
61        </p>
62<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
63<li class="listitem">
64              Default constructed <code class="computeroutput"><span class="identifier">complex128</span></code>s
65              have the value zero.
66            </li>
67<li class="listitem">
68              This backend supports rvalue-references and is move-aware, making instantiations
69              of <code class="computeroutput"><span class="identifier">number</span></code> on this backend
70              move aware.
71            </li>
72<li class="listitem">
73              It is not possible to round-trip objects of this type to and from a
74              string and get back exactly the same value when compiled with Intel's
75              C++ compiler and using <code class="computeroutput"><span class="identifier">_Quad</span></code>
76              as the underlying type: this is a current limitation of our code. Round
77              tripping when using <code class="computeroutput"><span class="identifier">__float128</span></code>
78              as the underlying type is possible (both for GCC and Intel).
79            </li>
80<li class="listitem">
81              Conversion from a string results in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span></code>
82              being thrown if the string can not be interpreted as a valid floating-point
83              number.
84            </li>
85<li class="listitem">
86              Division by zero results in an infinity being produced.
87            </li>
88<li class="listitem">
89              When using the Intel compiler, the underlying type defaults to <code class="computeroutput"><span class="identifier">__float128</span></code> if it's available and
90              <code class="computeroutput"><span class="identifier">_Quad</span></code> if not. You can
91              override the default by defining either <code class="computeroutput"><span class="identifier">BOOST_MP_USE_FLOAT128</span></code>
92              or <code class="computeroutput"><span class="identifier">BOOST_MP_USE_QUAD</span></code>.
93            </li>
94<li class="listitem">
95              When the underlying type is Intel's <code class="computeroutput"><span class="identifier">_Quad</span></code>
96              type, the code must be compiled with the compiler option <code class="computeroutput"><span class="special">-</span><span class="identifier">Qoption</span><span class="special">,</span><span class="identifier">cpp</span><span class="special">,--</span><span class="identifier">extended_float_type</span></code>.
97            </li>
98</ul></div>
99<h6>
100<a name="boost_multiprecision.tut.complex.complex128.h0"></a>
101          <span class="phrase"><a name="boost_multiprecision.tut.complex.complex128.complex128_example"></a></span><a class="link" href="complex128.html#boost_multiprecision.tut.complex.complex128.complex128_example">complex128
102          example:</a>
103        </h6>
104<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
105<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">complex</span><span class="special">&gt;</span>
106<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">complex128</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
107
108<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Complex</span><span class="special">&gt;</span>
109<span class="keyword">void</span> <span class="identifier">complex_number_examples</span><span class="special">()</span>
110<span class="special">{</span>
111    <span class="identifier">Complex</span> <span class="identifier">z1</span><span class="special">{</span><span class="number">0</span><span class="special">,</span> <span class="number">1</span><span class="special">};</span>
112    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">setprecision</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Complex</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">&gt;::</span><span class="identifier">digits10</span><span class="special">);</span>
113    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">scientific</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">fixed</span><span class="special">;</span>
114    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Print a complex number: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">z1</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
115    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Square it             : "</span> <span class="special">&lt;&lt;</span> <span class="identifier">z1</span><span class="special">*</span><span class="identifier">z1</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
116    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Real part             : "</span> <span class="special">&lt;&lt;</span> <span class="identifier">z1</span><span class="special">.</span><span class="identifier">real</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">real</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
117    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Imaginary part        : "</span> <span class="special">&lt;&lt;</span> <span class="identifier">z1</span><span class="special">.</span><span class="identifier">imag</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">imag</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
118    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">abs</span><span class="special">;</span>
119    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Absolute value        : "</span> <span class="special">&lt;&lt;</span> <span class="identifier">abs</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
120    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Argument              : "</span> <span class="special">&lt;&lt;</span> <span class="identifier">arg</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
121    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Norm                  : "</span> <span class="special">&lt;&lt;</span> <span class="identifier">norm</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
122    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Complex conjugate     : "</span> <span class="special">&lt;&lt;</span> <span class="identifier">conj</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
123    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Projection onto Riemann sphere: "</span> <span class="special">&lt;&lt;</span>  <span class="identifier">proj</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
124    <span class="keyword">typename</span> <span class="identifier">Complex</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">r</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>
125    <span class="keyword">typename</span> <span class="identifier">Complex</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">theta</span> <span class="special">=</span> <span class="number">0.8</span><span class="special">;</span>
126    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">polar</span><span class="special">;</span>
127    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Polar coordinates (phase = 0)    : "</span> <span class="special">&lt;&lt;</span> <span class="identifier">polar</span><span class="special">(</span><span class="identifier">r</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
128    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Polar coordinates (phase !=0)    : "</span> <span class="special">&lt;&lt;</span> <span class="identifier">polar</span><span class="special">(</span><span class="identifier">r</span><span class="special">,</span> <span class="identifier">theta</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
129
130    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"\nElementary special functions:\n"</span><span class="special">;</span>
131    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">;</span>
132    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"exp(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">exp</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
133    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">log</span><span class="special">;</span>
134    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"log(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
135    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">log10</span><span class="special">;</span>
136    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"log10(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">log10</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
137    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pow</span><span class="special">;</span>
138    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"pow(z1, z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">pow</span><span class="special">(</span><span class="identifier">z1</span><span class="special">,</span> <span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
139    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">sqrt</span><span class="special">;</span>
140    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Take its square root  : "</span> <span class="special">&lt;&lt;</span> <span class="identifier">sqrt</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
141    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">sin</span><span class="special">;</span>
142    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"sin(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">sin</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
143    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cos</span><span class="special">;</span>
144    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"cos(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">cos</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
145    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">tan</span><span class="special">;</span>
146    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"tan(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">tan</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
147    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">asin</span><span class="special">;</span>
148    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"asin(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">asin</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
149    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">acos</span><span class="special">;</span>
150    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"acos(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">acos</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
151    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">atan</span><span class="special">;</span>
152    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"atan(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">atan</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
153    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">sinh</span><span class="special">;</span>
154    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"sinh(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">sinh</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
155    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cosh</span><span class="special">;</span>
156    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"cosh(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">cosh</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
157    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">tanh</span><span class="special">;</span>
158    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"tanh(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">tanh</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
159    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">asinh</span><span class="special">;</span>
160    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"asinh(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">asinh</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
161    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">acosh</span><span class="special">;</span>
162    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"acosh(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">acosh</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
163    <span class="keyword">using</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">atanh</span><span class="special">;</span>
164    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"atanh(z1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">atanh</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
165<span class="special">}</span>
166
167<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
168<span class="special">{</span>
169    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"First, some operations we usually perform with std::complex:\n"</span><span class="special">;</span>
170    <span class="identifier">complex_number_examples</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">complex</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;&gt;();</span>
171    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"\nNow the same operations performed using quad precision complex numbers:\n"</span><span class="special">;</span>
172    <span class="identifier">complex_number_examples</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">complex128</span><span class="special">&gt;();</span>
173
174    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
175<span class="special">}</span>
176</pre>
177<p>
178          Which results in the output:
179        </p>
180<pre class="programlisting"><span class="identifier">Print</span> <span class="identifier">a</span> <span class="identifier">complex</span> <span class="identifier">number</span><span class="special">:</span> <span class="special">(</span><span class="number">0.000000000000000000000000000000000</span><span class="special">,</span><span class="number">1.000000000000000000000000000000000</span><span class="special">)</span>
181<span class="identifier">Square</span> <span class="identifier">it</span>             <span class="special">:</span> <span class="special">-</span><span class="number">1.000000000000000000000000000000000</span>
182<span class="identifier">Real</span> <span class="identifier">part</span>             <span class="special">:</span> <span class="number">0.000000000000000000000000000000000</span> <span class="special">=</span> <span class="number">0.000000000000000000000000000000000</span>
183<span class="identifier">Imaginary</span> <span class="identifier">part</span>        <span class="special">:</span> <span class="number">1.000000000000000000000000000000000</span> <span class="special">=</span> <span class="number">1.000000000000000000000000000000000</span>
184<span class="identifier">Absolute</span> <span class="identifier">value</span>        <span class="special">:</span> <span class="number">1.000000000000000000000000000000000</span>
185<span class="identifier">Argument</span>              <span class="special">:</span> <span class="number">1.570796326794896619231321691639751</span>
186<span class="identifier">Norm</span>                  <span class="special">:</span> <span class="number">1.000000000000000000000000000000000</span>
187<span class="identifier">Complex</span> <span class="identifier">conjugate</span>     <span class="special">:</span> <span class="special">(</span><span class="number">0.000000000000000000000000000000000</span><span class="special">,-</span><span class="number">1.000000000000000000000000000000000</span><span class="special">)</span>
188<span class="identifier">Projection</span> <span class="identifier">onto</span> <span class="identifier">Riemann</span> <span class="identifier">sphere</span><span class="special">:</span> <span class="special">(</span><span class="number">0.000000000000000000000000000000000</span><span class="special">,</span><span class="number">1.000000000000000000000000000000000</span><span class="special">)</span>
189<span class="identifier">Polar</span> <span class="identifier">coordinates</span> <span class="special">(</span><span class="identifier">phase</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span>    <span class="special">:</span> <span class="number">1.000000000000000000000000000000000</span>
190<span class="identifier">Polar</span> <span class="identifier">coordinates</span> <span class="special">(</span><span class="identifier">phase</span> <span class="special">!=</span><span class="number">0</span><span class="special">)</span>    <span class="special">:</span> <span class="special">(</span><span class="number">0.696706709347165389063740022772449</span><span class="special">,</span><span class="number">0.717356090899522792567167815703377</span><span class="special">)</span>
191
192<span class="identifier">Elementary</span> <span class="identifier">special</span> <span class="identifier">functions</span><span class="special">:</span>
193<span class="identifier">exp</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">0.540302305868139717400936607442977</span><span class="special">,</span><span class="number">0.841470984807896506652502321630299</span><span class="special">)</span>
194<span class="identifier">log</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">0.000000000000000000000000000000000</span><span class="special">,</span><span class="number">1.570796326794896619231321691639751</span><span class="special">)</span>
195<span class="identifier">log10</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">0.000000000000000000000000000000000</span><span class="special">,</span><span class="number">0.682188176920920673742891812715678</span><span class="special">)</span>
196<span class="identifier">pow</span><span class="special">(</span><span class="identifier">z1</span><span class="special">,</span> <span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="number">0.207879576350761908546955619834979</span>
197<span class="identifier">Take</span> <span class="identifier">its</span> <span class="identifier">square</span> <span class="identifier">root</span>  <span class="special">:</span> <span class="special">(</span><span class="number">0.707106781186547524400844362104849</span><span class="special">,</span><span class="number">0.707106781186547524400844362104849</span><span class="special">)</span>
198<span class="identifier">sin</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">0.000000000000000000000000000000000</span><span class="special">,</span><span class="number">1.175201193643801456882381850595601</span><span class="special">)</span>
199<span class="identifier">cos</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="number">1.543080634815243778477905620757061</span>
200<span class="identifier">tan</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">0.000000000000000000000000000000000</span><span class="special">,</span><span class="number">0.761594155955764888119458282604794</span><span class="special">)</span>
201<span class="identifier">asin</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">0.000000000000000000000000000000000</span><span class="special">,</span><span class="number">0.881373587019543025232609324979792</span><span class="special">)</span>
202<span class="identifier">acos</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">1.570796326794896619231321691639751</span><span class="special">,-</span><span class="number">0.881373587019543025232609324979792</span><span class="special">)</span>
203<span class="identifier">atan</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">0.000000000000000000000000000000000</span><span class="special">,</span><span class="identifier">inf</span><span class="special">)</span>
204<span class="identifier">sinh</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">0.000000000000000000000000000000000</span><span class="special">,</span><span class="number">0.841470984807896506652502321630299</span><span class="special">)</span>
205<span class="identifier">cosh</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="number">0.540302305868139717400936607442977</span>
206<span class="identifier">tanh</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">0.000000000000000000000000000000000</span><span class="special">,</span><span class="number">1.557407724654902230506974807458360</span><span class="special">)</span>
207<span class="identifier">asinh</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">0.000000000000000000000000000000000</span><span class="special">,</span><span class="number">1.570796326794896619231321691639751</span><span class="special">)</span>
208<span class="identifier">acosh</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">0.881373587019543025232609324979792</span><span class="special">,</span><span class="number">1.570796326794896619231321691639751</span><span class="special">)</span>
209<span class="identifier">atanh</span><span class="special">(</span><span class="identifier">z1</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">0.000000000000000000000000000000000</span><span class="special">,</span><span class="number">0.785398163397448309615660845819876</span><span class="special">)</span>
210</pre>
211</div>
212<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
213<td align="left"></td>
214<td align="right"><div class="copyright-footer">Copyright © 2002-2020 John
215      Maddock and Christopher Kormanyos<p>
216        Distributed under the Boost Software License, Version 1.0. (See accompanying
217        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
218      </p>
219</div></td>
220</tr></table>
221<hr>
222<div class="spirit-nav">
223<a accesskey="p" href="mpc_complex.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../complex.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="complex_adaptor.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
224</div>
225</body>
226</html>
227