Update docs with performance results.

Add component based initialization of rationals.

[SVN r76486]
This commit is contained in:
John Maddock
2012-01-14 13:24:52 +00:00
parent a7d480c438
commit c98f15f30d
21 changed files with 4155 additions and 68 deletions
+3 -3
View File
@@ -6,12 +6,12 @@
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.Multiprecision">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Multiprecision">
<link rel="prev" href="ref/backendconc.html" title="Backend Requirements">
<link rel="prev" href="perf/integer_performance.html" title="Integer Algorithm Perfomance">
<link rel="next" href="map/hist.html" title="History">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="spirit-nav">
<a accesskey="p" href="ref/backendconc.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="map/hist.html"><img src="../images/next.png" alt="Next"></a>
<a accesskey="p" href="perf/integer_performance.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="map/hist.html"><img src="../images/next.png" alt="Next"></a>
</div>
<div class="section boost_multiprecision_map">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
@@ -32,7 +32,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="ref/backendconc.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="map/hist.html"><img src="../images/next.png" alt="Next"></a>
<a accesskey="p" href="perf/integer_performance.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="map/hist.html"><img src="../images/next.png" alt="Next"></a>
</div>
</body>
</html>
@@ -27,9 +27,6 @@
<li class="listitem">
Add an adapter backend for complex number types.
</li>
<li class="listitem">
Adapt libtommath code to make an all C++ fixed precision integer type.
</li>
</ul></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+41
View File
@@ -0,0 +1,41 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Performance Comparison</title>
<link rel="stylesheet" href="http://www.boost.org/doc/libs/release/doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.Multiprecision">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Multiprecision">
<link rel="prev" href="ref/backendconc.html" title="Backend Requirements">
<link rel="next" href="perf/realworld.html" title="Real World Tests">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="spirit-nav">
<a accesskey="p" href="ref/backendconc.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="perf/realworld.html"><img src="../images/next.png" alt="Next"></a>
</div>
<div class="section boost_multiprecision_perf">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_multiprecision.perf"></a><a class="link" href="perf.html" title="Performance Comparison">Performance Comparison</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="perf/realworld.html">Real World Tests</a></span></dt>
<dt><span class="section"><a href="perf/float_performance.html">Float Algorithm
Perfomance</a></span></dt>
<dt><span class="section"><a href="perf/integer_performance.html">Integer
Algorithm Perfomance</a></span></dt>
</dl></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2011 John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
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>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="ref/backendconc.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="perf/realworld.html"><img src="../images/next.png" alt="Next"></a>
</div>
</body>
</html>
@@ -0,0 +1,757 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Float Algorithm Perfomance</title>
<link rel="stylesheet" href="http://www.boost.org/doc/libs/release/doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Boost.Multiprecision">
<link rel="up" href="../perf.html" title="Performance Comparison">
<link rel="prev" href="realworld.html" title="Real World Tests">
<link rel="next" href="integer_performance.html" title="Integer Algorithm Perfomance">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="spirit-nav">
<a accesskey="p" href="realworld.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../perf.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="integer_performance.html"><img src="../../images/next.png" alt="Next"></a>
</div>
<div class="section boost_multiprecision_perf_float_performance">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_multiprecision.perf.float_performance"></a><a class="link" href="float_performance.html" title="Float Algorithm Perfomance">Float Algorithm
Perfomance</a>
</h3></div></div></div>
<p>
Note that these tests are carefully designed to test performance of the underlying
algorithms and not memory allocation or variable copying. As usual, performance
results should be taken with a healthy dose of scepticsm, and real-world
peformance may vary widely depending upon the specifics of the program. In
each table relative times are given first, with the best performer given
a score of 1. Total actual times are given in brackets, measured in seconds
for 500000 operations.
</p>
<p>
Test code was compiled with Microsoft Visual Studio 2010 with all optimisations
turned on (/Ox), and used MPIR-2.3.0 and MPFR-3.0.0. The tests were run on
32-bit Windows Vista machine.
</p>
<div class="table">
<a name="boost_multiprecision.perf.float_performance.operator__"></a><p class="title"><b>Table&#160;1.8.&#160;Operator *</b></p>
<div class="table-contents"><table class="table" summary="Operator *">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Backend
</p>
</th>
<th>
<p>
50 Decimal Digits
</p>
</th>
<th>
<p>
100 Decimal Digits
</p>
</th>
<th>
<p>
500 Decimal Digits
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
cpp_float
</p>
</td>
<td>
<p>
1.0826 (0.287216s)
</p>
</td>
<td>
<p>
1.48086 (0.586363s)
</p>
</td>
<td>
<p>
1.57545 (5.05269s)
</p>
</td>
</tr>
<tr>
<td>
<p>
gmp_float
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.265302s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.395962s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (3.20714s)
</p>
</td>
</tr>
<tr>
<td>
<p>
mpfr_float
</p>
</td>
<td>
<p>
1.24249 (0.329636s)
</p>
</td>
<td>
<p>
1.15432 (0.457067s)
</p>
</td>
<td>
<p>
1.16182 (3.72612s)
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="boost_multiprecision.perf.float_performance.operator0"></a><p class="title"><b>Table&#160;1.9.&#160;Operator +</b></p>
<div class="table-contents"><table class="table" summary="Operator +">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Backend
</p>
</th>
<th>
<p>
50 Decimal Digits
</p>
</th>
<th>
<p>
100 Decimal Digits
</p>
</th>
<th>
<p>
500 Decimal Digits
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
cpp_float
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.0242151s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.029252s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.0584099s)
</p>
</td>
</tr>
<tr>
<td>
<p>
gmp_float
</p>
</td>
<td>
<p>
4.55194 (0.110226s)
</p>
</td>
<td>
<p>
3.67516 (0.107506s)
</p>
</td>
<td>
<p>
2.42489 (0.141638s)
</p>
</td>
</tr>
<tr>
<td>
<p>
mpfr_float
</p>
</td>
<td>
<p>
2.45362 (0.0594147s)
</p>
</td>
<td>
<p>
2.18552 (0.0639309s)
</p>
</td>
<td>
<p>
1.32099 (0.0771588s)
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="boost_multiprecision.perf.float_performance.operator___int_"></a><p class="title"><b>Table&#160;1.10.&#160;Operator +(int)</b></p>
<div class="table-contents"><table class="table" summary="Operator +(int)">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Backend
</p>
</th>
<th>
<p>
50 Decimal Digits
</p>
</th>
<th>
<p>
100 Decimal Digits
</p>
</th>
<th>
<p>
500 Decimal Digits
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
cpp_float
</p>
</td>
<td>
<p>
1.51995 (0.0484155s)
</p>
</td>
<td>
<p>
1.78781 (0.0611055s)
</p>
</td>
<td>
<p>
1.8309 (0.104123s)
</p>
</td>
</tr>
<tr>
<td>
<p>
gmp_float
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.0318533s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.0341789s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.0568699s)
</p>
</td>
</tr>
<tr>
<td>
<p>
mpfr_float
</p>
</td>
<td>
<p>
3.39055 (0.108s)
</p>
</td>
<td>
<p>
3.30142 (0.112839s)
</p>
</td>
<td>
<p>
2.05293 (0.11675s)
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="boost_multiprecision.perf.float_performance.operator1"></a><p class="title"><b>Table&#160;1.11.&#160;Operator -</b></p>
<div class="table-contents"><table class="table" summary="Operator -">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Backend
</p>
</th>
<th>
<p>
50 Decimal Digits
</p>
</th>
<th>
<p>
100 Decimal Digits
</p>
</th>
<th>
<p>
500 Decimal Digits
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
cpp_float
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.0261498s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.030946s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.0606388s)
</p>
</td>
</tr>
<tr>
<td>
<p>
gmp_float
</p>
</td>
<td>
<p>
4.48753 (0.117348s)
</p>
</td>
<td>
<p>
3.75823 (0.116302s)
</p>
</td>
<td>
<p>
2.4823 (0.150524s)
</p>
</td>
</tr>
<tr>
<td>
<p>
mpfr_float
</p>
</td>
<td>
<p>
2.96057 (0.0774183s)
</p>
</td>
<td>
<p>
2.61897 (0.0810465s)
</p>
</td>
<td>
<p>
1.56236 (0.0947396s)
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="boost_multiprecision.perf.float_performance.operator_int0"></a><p class="title"><b>Table&#160;1.12.&#160;Operator -(int)</b></p>
<div class="table-contents"><table class="table" summary="Operator -(int)">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Backend
</p>
</th>
<th>
<p>
50 Decimal Digits
</p>
</th>
<th>
<p>
100 Decimal Digits
</p>
</th>
<th>
<p>
500 Decimal Digits
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
cpp_float
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.0567601s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.0626685s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.111692s)
</p>
</td>
</tr>
<tr>
<td>
<p>
gmp_float
</p>
</td>
<td>
<p>
2.27932 (0.129374s)
</p>
</td>
<td>
<p>
2.04821 (0.128358s)
</p>
</td>
<td>
<p>
1.48297 (0.165635s)
</p>
</td>
</tr>
<tr>
<td>
<p>
mpfr_float
</p>
</td>
<td>
<p>
2.43199 (0.13804s)
</p>
</td>
<td>
<p>
2.32131 (0.145473s)
</p>
</td>
<td>
<p>
1.38152 (0.154304s)
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="boost_multiprecision.perf.float_performance.operator2"></a><p class="title"><b>Table&#160;1.13.&#160;Operator /</b></p>
<div class="table-contents"><table class="table" summary="Operator /">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Backend
</p>
</th>
<th>
<p>
50 Decimal Digits
</p>
</th>
<th>
<p>
100 Decimal Digits
</p>
</th>
<th>
<p>
500 Decimal Digits
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
cpp_float
</p>
</td>
<td>
<p>
3.2662 (3.98153s)
</p>
</td>
<td>
<p>
5.07021 (8.11948s)
</p>
</td>
<td>
<p>
6.78872 (53.6099s)
</p>
</td>
</tr>
<tr>
<td>
<p>
gmp_float
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (1.21901s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (1.60141s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (7.89691s)
</p>
</td>
</tr>
<tr>
<td>
<p>
mpfr_float
</p>
</td>
<td>
<p>
1.33238 (1.62419s)
</p>
</td>
<td>
<p>
1.39529 (2.23443s)
</p>
</td>
<td>
<p>
1.70882 (13.4944s)
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="boost_multiprecision.perf.float_performance.operator_str"></a><p class="title"><b>Table&#160;1.14.&#160;Operator str</b></p>
<div class="table-contents"><table class="table" summary="Operator str">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Backend
</p>
</th>
<th>
<p>
50 Decimal Digits
</p>
</th>
<th>
<p>
100 Decimal Digits
</p>
</th>
<th>
<p>
500 Decimal Digits
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
cpp_float
</p>
</td>
<td>
<p>
1.46076 (0.0192656s)
</p>
</td>
<td>
<p>
1.59438 (0.0320398s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.134302s)
</p>
</td>
</tr>
<tr>
<td>
<p>
gmp_float
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.0131888s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1</strong></span> (0.0200954s)
</p>
</td>
<td>
<p>
1.01007 (0.135655s)
</p>
</td>
</tr>
<tr>
<td>
<p>
mpfr_float
</p>
</td>
<td>
<p>
2.19174 (0.0289065s)
</p>
</td>
<td>
<p>
1.86101 (0.0373977s)
</p>
</td>
<td>
<p>
1.15842 (0.155578s)
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2011 John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
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>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="realworld.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../perf.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="integer_performance.html"><img src="../../images/next.png" alt="Next"></a>
</div>
</body>
</html>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,276 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Real World Tests</title>
<link rel="stylesheet" href="http://www.boost.org/doc/libs/release/doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Boost.Multiprecision">
<link rel="up" href="../perf.html" title="Performance Comparison">
<link rel="prev" href="../perf.html" title="Performance Comparison">
<link rel="next" href="float_performance.html" title="Float Algorithm Perfomance">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="spirit-nav">
<a accesskey="p" href="../perf.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../perf.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="float_performance.html"><img src="../../images/next.png" alt="Next"></a>
</div>
<div class="section boost_multiprecision_perf_realworld">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_multiprecision.perf.realworld"></a><a class="link" href="realworld.html" title="Real World Tests">Real World Tests</a>
</h3></div></div></div>
<p>
These tests test the total time taken to execute all of Boost.Math's test
cases for these functions. In each case the best performing library gets
a relative score of 1, with the total execution time given in brackets. The
first three libraries listed are the various floating point types provided
by this library, while for comparison, two popular C++ frontends to MPFR
(mpfr_class and mpreal) are also shown.
</p>
<p>
Test code was compiled with Microsoft Visual Studio 2010 with all optimisations
turned on (/Ox), and used MPIR-2.3.0 and MPFR-3.0.0. The tests were run on
32-bit Windows Vista machine.
</p>
<div class="table">
<a name="boost_multiprecision.perf.realworld.bessel_function_performance"></a><p class="title"><b>Table&#160;1.6.&#160;Bessel Function Performance</b></p>
<div class="table-contents"><table class="table" summary="Bessel Function Performance">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Library
</p>
</th>
<th>
<p>
50 Decimal Digits
</p>
</th>
<th>
<p>
100 Decimal Digits
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
mpfr_float
</p>
</td>
<td>
<p>
<span class="bold"><strong>1.0</strong></span> (6.472s)
</p>
</td>
<td>
<p>
1.193 (10.154s)
</p>
</td>
</tr>
<tr>
<td>
<p>
mpf_float
</p>
</td>
<td>
<p>
1.801 (11.662s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1.0</strong></span>(8.511s)
</p>
</td>
</tr>
<tr>
<td>
<p>
cpp_float
</p>
</td>
<td>
<p>
3.13 (20.285s)
</p>
</td>
<td>
<p>
2.46 (21.019s)
</p>
</td>
</tr>
<tr>
<td>
<p>
mpfr_class
</p>
</td>
<td>
<p>
1.001 (6.480s)
</p>
</td>
<td>
<p>
1.15(9.805s)
</p>
</td>
</tr>
<tr>
<td>
<p>
mpreal
</p>
</td>
<td>
<p>
1.542 (9.981s)
</p>
</td>
<td>
<p>
1.61 (13.702s)
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="boost_multiprecision.perf.realworld.non_central_t_distribution_performance"></a><p class="title"><b>Table&#160;1.7.&#160;Non-Central T Distribution Performance</b></p>
<div class="table-contents"><table class="table" summary="Non-Central T Distribution Performance">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Library
</p>
</th>
<th>
<p>
50 Decimal Digits
</p>
</th>
<th>
<p>
100 Decimal Digits
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
mpfr_float
</p>
</td>
<td>
<p>
1.308 (258.09s)
</p>
</td>
<td>
<p>
1.30 (516.74s)
</p>
</td>
</tr>
<tr>
<td>
<p>
mpf_float
</p>
</td>
<td>
<p>
<span class="bold"><strong>1.0</strong></span> (197.30s)
</p>
</td>
<td>
<p>
<span class="bold"><strong>1.0</strong></span>(397.30s)
</p>
</td>
</tr>
<tr>
<td>
<p>
cpp_float
</p>
</td>
<td>
<p>
1.695 (334.50s)
</p>
</td>
<td>
<p>
2.68 (1064.53s)
</p>
</td>
</tr>
<tr>
<td>
<p>
mpfr_class
</p>
</td>
<td>
<p>
1.35 (266.39s)
</p>
</td>
<td>
<p>
1.323 (525.74s)
</p>
</td>
</tr>
<tr>
<td>
<p>
mpreal
</p>
</td>
<td>
<p>
1.75 (346.64s)
</p>
</td>
<td>
<p>
1.635 (649.94s)
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2011 John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
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>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../perf.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../perf.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="float_performance.html"><img src="../../images/next.png" alt="Next"></a>
</div>
</body>
</html>
@@ -7,11 +7,11 @@
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Boost.Multiprecision">
<link rel="up" href="../ref.html" title="Reference">
<link rel="prev" href="mp_number.html" title="mp_number">
<link rel="next" href="../map.html" title="Roadmap">
<link rel="next" href="../perf.html" title="Performance Comparison">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="spirit-nav">
<a accesskey="p" href="mp_number.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../map.html"><img src="../../images/next.png" alt="Next"></a>
<a accesskey="p" href="mp_number.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../perf.html"><img src="../../images/next.png" alt="Next"></a>
</div>
<div class="section boost_multiprecision_ref_backendconc">
<div class="titlepage"><div><div><h3 class="title">
@@ -34,7 +34,9 @@
<code class="computeroutput"><span class="identifier">pa</span></code> is a variable of type
pointer-to-arithmetic-type, <code class="computeroutput"><span class="identifier">exp</span></code>
is a variable of type <code class="computeroutput"><span class="identifier">B</span><span class="special">::</span><span class="identifier">exp_type</span></code>, <code class="computeroutput"><span class="identifier">pexp</span></code>
is a variable of type <code class="computeroutput"><span class="identifier">B</span><span class="special">::</span><span class="identifier">exp_type</span><span class="special">*</span></code>.
is a variable of type <code class="computeroutput"><span class="identifier">B</span><span class="special">::</span><span class="identifier">exp_type</span><span class="special">*</span></code>,
B2 is another type that meets these requirements, b2 is a variable of type
B2.
</p>
<div class="table">
<a name="boost_multiprecision.ref.backendconc.compulsory_requirements_on_the_backend_type_"></a><p class="title"><b>Table&#160;1.4.&#160;Compulsory Requirements on the Backend type.</b></p>
@@ -730,6 +732,79 @@
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">B</span><span class="special">(</span><span class="identifier">b2</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">B</span></code>
</p>
</td>
<td>
<p>
Copy constructor from a different backend type.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">b</span> <span class="special">=</span>
<span class="identifier">b2</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">b</span><span class="special">&amp;</span></code>
</p>
</td>
<td>
<p>
Assignment operator from a different backend type.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">assign_components</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">a</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="keyword">void</span></code>
</p>
</td>
<td>
<p>
Assigns to <code class="computeroutput"><span class="identifier">b</span></code> the
two components in the following arguments. Only applies to rational
and complex number types.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">assign_components</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span> <span class="identifier">b2</span><span class="special">,</span> <span class="identifier">b2</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="keyword">void</span></code>
</p>
</td>
<td>
<p>
Assigns to <code class="computeroutput"><span class="identifier">b</span></code> the
two components in the following arguments. Only applies to rational
and complex number types.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">add</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span>
@@ -2039,7 +2114,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="mp_number.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../map.html"><img src="../../images/next.png" alt="Next"></a>
<a accesskey="p" href="mp_number.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../perf.html"><img src="../../images/next.png" alt="Next"></a>
</div>
</body>
</html>
@@ -137,6 +137,16 @@
<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">fmod</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&amp;,</span> <span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&amp;);</span>
<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">atan2</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&amp;,</span> <span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&amp;);</span>
<span class="comment">// Traits support:</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">component_type</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">number_category</span><span class="special">;</span>
<span class="comment">// Rational number support:</span>
<span class="keyword">typename</span> <span class="identifier">component_type</span><span class="special">&lt;</span><span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">numerator</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&amp;);</span>
<span class="keyword">typename</span> <span class="identifier">component_type</span><span class="special">&lt;</span><span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">denominator</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&amp;);</span>
<span class="special">}}</span> <span class="comment">// namespaces</span>
<span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
@@ -191,6 +201,16 @@
Any type that the Backend is constructible or assignable from.
</li>
</ul></div>
<p>
In addition, if the type has multiple components (for example rational or
complex number types), then there is a two argument constructor:
</p>
<pre class="programlisting"><span class="identifier">mp_number</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">);</span>
</pre>
<p>
Where the two args must either be arithmetic types, or types that are convertible
to the two components of <code class="computeroutput"><span class="keyword">this</span></code>.
</p>
<pre class="programlisting"><span class="identifier">mp_number</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">+=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&amp;);</span>
<span class="identifier">mp_number</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">-=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&amp;);</span>
<span class="identifier">mp_number</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">*=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&amp;);</span>
@@ -457,6 +477,42 @@
</p>
<h5>
<a name="boost_multiprecision.ref.mp_number.h6"></a>
<span><a name="boost_multiprecision.ref.mp_number.traits_class_support"></a></span><a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.traits_class_support">Traits
Class Support</a>
</h5>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">component_type</span><span class="special">;</span>
</pre>
<p>
If this is a type with mutiple components (for example rational or complex
types), then this trait has a single member <code class="computeroutput"><span class="identifier">type</span></code>
that is the type of those components.
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">number_category</span><span class="special">;</span>
</pre>
<p>
A traits class that inherits from <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">int_</span><span class="special">&lt;</span><span class="identifier">N</span><span class="special">&gt;</span></code>
where <code class="computeroutput"><span class="identifier">N</span></code> is one of the enumerated
values <code class="computeroutput"><span class="identifier">number_kind_integer</span></code>,
<code class="computeroutput"><span class="identifier">number_kind_floating_point</span></code>,
<code class="computeroutput"><span class="identifier">number_kind_rational</span></code> or
<code class="computeroutput"><span class="identifier">number_kind_fixed_point</span></code>.
</p>
<h5>
<a name="boost_multiprecision.ref.mp_number.h7"></a>
<span><a name="boost_multiprecision.ref.mp_number.rational_number_functions"></a></span><a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.rational_number_functions">Rational
Number Functions</a>
</h5>
<pre class="programlisting"><span class="keyword">typename</span> <span class="identifier">component_type</span><span class="special">&lt;</span><span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">numerator</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&amp;);</span>
<span class="keyword">typename</span> <span class="identifier">component_type</span><span class="special">&lt;</span><span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">denominator</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&amp;);</span>
</pre>
<p>
These functions return the numerator and denominator of a rational number
respectively.
</p>
<h5>
<a name="boost_multiprecision.ref.mp_number.h8"></a>
<span><a name="boost_multiprecision.ref.mp_number.boost_math_interoperability_support"></a></span><a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.boost_math_interoperability_support">Boost.Math
Interoperability Support</a>
</h5>
@@ -479,7 +535,7 @@
to ensure interoperability.
</p>
<h5>
<a name="boost_multiprecision.ref.mp_number.h7"></a>
<a name="boost_multiprecision.ref.mp_number.h9"></a>
<span><a name="boost_multiprecision.ref.mp_number.std__numeric_limits_support"></a></span><a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.std__numeric_limits_support">std::numeric_limits
support</a>
</h5>
@@ -263,6 +263,9 @@
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">numerator</span><span class="special">(</span><span class="identifier">v</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>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">denominator</span><span class="special">(</span><span class="identifier">v</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>
<span class="identifier">mpq_rational</span> <span class="identifier">w</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">);</span> <span class="comment">// component wise constructor</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">w</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> <span class="comment">// prints 2/3</span>
<span class="comment">// Access the underlying data:</span>
<span class="identifier">mpq_t</span> <span class="identifier">q</span><span class="special">;</span>
<span class="identifier">mpq_init</span><span class="special">(</span><span class="identifier">q</span><span class="special">);</span>
@@ -322,6 +325,9 @@
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">numerator</span><span class="special">(</span><span class="identifier">v</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>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">denominator</span><span class="special">(</span><span class="identifier">v</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>
<span class="identifier">mp_rational</span> <span class="identifier">w</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">);</span> <span class="comment">// Component wise constructor</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">w</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> <span class="comment">// prints 2/3</span>
</pre>
<p>
</p>
+9 -1
View File
@@ -39,6 +39,14 @@
<dt><span class="section"><a href="boost_multiprecision/ref/mp_number.html">mp_number</a></span></dt>
<dt><span class="section"><a href="boost_multiprecision/ref/backendconc.html">Backend Requirements</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="boost_multiprecision/perf.html">Performance Comparison</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="boost_multiprecision/perf/realworld.html">Real World Tests</a></span></dt>
<dt><span class="section"><a href="boost_multiprecision/perf/float_performance.html">Float Algorithm
Perfomance</a></span></dt>
<dt><span class="section"><a href="boost_multiprecision/perf/integer_performance.html">Integer
Algorithm Perfomance</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="boost_multiprecision/map.html">Roadmap</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="boost_multiprecision/map/hist.html">History</a></span></dt>
@@ -48,7 +56,7 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: January 12, 2012 at 13:44:32 GMT</small></p></td>
<td align="left"><p><small>Last revised: January 14, 2012 at 13:20:36 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
+232 -2
View File
@@ -632,6 +632,16 @@ So for example, given an integer backend type `MyIntegerBackend`, the use would
``['unmentionable-expression-template-type]`` fmod (const ``['mp_number-or-expression-template-type]``&, const ``['mp_number-or-expression-template-type]``&);
``['unmentionable-expression-template-type]`` atan2 (const ``['mp_number-or-expression-template-type]``&, const ``['mp_number-or-expression-template-type]``&);
// Traits support:
template <class T>
struct component_type;
template <class T>
struct number_category;
// Rational number support:
typename component_type<``['mp_number-or-expression-template-type]``>::type numerator (const ``['mp_number-or-expression-template-type]``&);
typename component_type<``['mp_number-or-expression-template-type]``>::type denominator(const ``['mp_number-or-expression-template-type]``&);
}} // namespaces
namespace boost{ namespace math{
@@ -670,6 +680,13 @@ Type `mp_number` is default constructible, and both copy constructible and assig
* A `std::string` or any type which is convertible to `const char*`.
* Any type that the Backend is constructible or assignable from.
In addition, if the type has multiple components (for example rational or complex number types), then there is a
two argument constructor:
mp_number(arg1, arg2);
Where the two args must either be arithmetic types, or types that are convertible to the two components of `this`.
mp_number& operator+=(const ``['see-below]``&);
mp_number& operator-=(const ``['see-below]``&);
mp_number& operator*=(const ``['see-below]``&);
@@ -857,6 +874,27 @@ used at variable precision.
Also note that with the exception of `abs` that these functions can only be used with floating-point Backend types.
[h4 Traits Class Support]
template <class T>
struct component_type;
If this is a type with mutiple components (for example rational or complex types), then this trait has a single member
`type` that is the type of those components.
template <class T>
struct number_category;
A traits class that inherits from `mpl::int_<N>` where `N` is one of the enumerated values `number_kind_integer`, `number_kind_floating_point`,
`number_kind_rational` or `number_kind_fixed_point`.
[h4 Rational Number Functions]
typename component_type<``['mp_number-or-expression-template-type]``>::type numerator (const ``['mp_number-or-expression-template-type]``&);
typename component_type<``['mp_number-or-expression-template-type]``>::type denominator(const ``['mp_number-or-expression-template-type]``&);
These functions return the numerator and denominator of a rational number respectively.
[h4 Boost.Math Interoperability Support]
namespace boost{ namespace math{
@@ -904,7 +942,8 @@ In the following tables, type B is the `Backend` template arument to `mp_number`
a variable of B, `cb` and `cb2` are constant variables of type B, `a` is a variable of Arithmetic type,
`s` is a variable of type `const char*`, `ui` is a variable of type `unsigned`, `bb` is a variable of type `bool`,
`pa` is a variable of type pointer-to-arithmetic-type, `exp` is a variable of type `B::exp_type`,
`pexp` is a variable of type `B::exp_type*`.
`pexp` is a variable of type `B::exp_type*`, B2 is another type that meets these requirements, b2 is a variable
of type B2.
[table Compulsory Requirements on the Backend type.
[[Expression][Return Type][Comments]]
@@ -956,6 +995,12 @@ a variable of B, `cb` and `cb2` are constant variables of type B, `a` is a varia
[table Optional Requirements on the Backend Type
[[Expression][Returns][Comments]]
[[`B(b2)`][`B`][Copy constructor from a different backend type.]]
[[`b = b2`][`b&`][Assignment operator from a different backend type.]]
[[`assign_components(b, a, a)`][`void`][Assigns to `b` the two components in the following arguments.
Only applies to rational and complex number types.]]
[[`assign_components(b, b2, b2)`][`void`][Assigns to `b` the two components in the following arguments.
Only applies to rational and complex number types.]]
[[`add(b, a)`][`void`][Adds `a` to `b`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
[[`subtract(b, a)`][`void`][Subtracts `a` from `b`. The type of `a` shall be listed in one of the type lists
@@ -1044,6 +1089,192 @@ a variable of B, `cb` and `cb2` are constant variables of type B, `a` is a varia
[endsect]
[section:perf Performance Comparison]
[section:realworld Real World Tests]
These tests test the total time taken to execute all of Boost.Math's test cases for these functions.
In each case the best performing library gets a relative score of 1, with the total execution time
given in brackets. The first three libraries listed are the various floating point types provided
by this library, while for comparison, two popular C++ frontends to MPFR (mpfr_class and mpreal)
are also shown.
Test code was compiled with Microsoft Visual Studio 2010 with all optimisations
turned on (/Ox), and used MPIR-2.3.0 and MPFR-3.0.0. The tests were run on 32-bit
Windows Vista machine.
[table Bessel Function Performance
[[Library][50 Decimal Digits][100 Decimal Digits]]
[[mpfr_float][[*1.0] (6.472s)][1.193 (10.154s)]]
[[mpf_float][1.801 (11.662s)][[*1.0](8.511s)]]
[[cpp_float][3.13 (20.285s)][2.46 (21.019s)]]
[[mpfr_class][1.001 (6.480s)][1.15(9.805s)]]
[[mpreal][1.542 (9.981s)][1.61 (13.702s)]]
]
[table Non-Central T Distribution Performance
[[Library][50 Decimal Digits][100 Decimal Digits]]
[[mpfr_float][1.308 (258.09s)][1.30 (516.74s)]]
[[mpf_float][[*1.0] (197.30s)][[*1.0](397.30s)]]
[[cpp_float][1.695 (334.50s)][2.68 (1064.53s)]]
[[mpfr_class][1.35 (266.39s)][1.323 (525.74s)]]
[[mpreal][1.75 (346.64s)][1.635 (649.94s)]]
]
[endsect]
[section:float_performance Float Algorithm Perfomance]
Note that these tests are carefully designed to test performance of the underlying algorithms
and not memory allocation or variable copying. As usual, performance results should be taken
with a healthy dose of scepticsm, and real-world peformance may vary widely depending upon the
specifics of the program. In each table relative times are given first, with the best performer
given a score of 1. Total actual times are given in brackets, measured in seconds for 500000
operations.
Test code was compiled with Microsoft Visual Studio 2010 with all optimisations
turned on (/Ox), and used MPIR-2.3.0 and MPFR-3.0.0. The tests were run on 32-bit
Windows Vista machine.
[table Operator *
[[Backend][50 Decimal Digits][100 Decimal Digits][500 Decimal Digits]]
[[cpp_float][1.0826 (0.287216s)][1.48086 (0.586363s)][1.57545 (5.05269s)]]
[[gmp_float][[*1] (0.265302s)][[*1] (0.395962s)][[*1] (3.20714s)]]
[[mpfr_float][1.24249 (0.329636s)][1.15432 (0.457067s)][1.16182 (3.72612s)]]
]
[table Operator +
[[Backend][50 Decimal Digits][100 Decimal Digits][500 Decimal Digits]]
[[cpp_float][[*1] (0.0242151s)][[*1] (0.029252s)][[*1] (0.0584099s)]]
[[gmp_float][4.55194 (0.110226s)][3.67516 (0.107506s)][2.42489 (0.141638s)]]
[[mpfr_float][2.45362 (0.0594147s)][2.18552 (0.0639309s)][1.32099 (0.0771588s)]]
]
[table Operator +(int)
[[Backend][50 Decimal Digits][100 Decimal Digits][500 Decimal Digits]]
[[cpp_float][1.51995 (0.0484155s)][1.78781 (0.0611055s)][1.8309 (0.104123s)]]
[[gmp_float][[*1] (0.0318533s)][[*1] (0.0341789s)][[*1] (0.0568699s)]]
[[mpfr_float][3.39055 (0.108s)][3.30142 (0.112839s)][2.05293 (0.11675s)]]
]
[table Operator -
[[Backend][50 Decimal Digits][100 Decimal Digits][500 Decimal Digits]]
[[cpp_float][[*1] (0.0261498s)][[*1] (0.030946s)][[*1] (0.0606388s)]]
[[gmp_float][4.48753 (0.117348s)][3.75823 (0.116302s)][2.4823 (0.150524s)]]
[[mpfr_float][2.96057 (0.0774183s)][2.61897 (0.0810465s)][1.56236 (0.0947396s)]]
]
[table Operator -(int)
[[Backend][50 Decimal Digits][100 Decimal Digits][500 Decimal Digits]]
[[cpp_float][[*1] (0.0567601s)][[*1] (0.0626685s)][[*1] (0.111692s)]]
[[gmp_float][2.27932 (0.129374s)][2.04821 (0.128358s)][1.48297 (0.165635s)]]
[[mpfr_float][2.43199 (0.13804s)][2.32131 (0.145473s)][1.38152 (0.154304s)]]
]
[table Operator /
[[Backend][50 Decimal Digits][100 Decimal Digits][500 Decimal Digits]]
[[cpp_float][3.2662 (3.98153s)][5.07021 (8.11948s)][6.78872 (53.6099s)]]
[[gmp_float][[*1] (1.21901s)][[*1] (1.60141s)][[*1] (7.89691s)]]
[[mpfr_float][1.33238 (1.62419s)][1.39529 (2.23443s)][1.70882 (13.4944s)]]
]
[table Operator str
[[Backend][50 Decimal Digits][100 Decimal Digits][500 Decimal Digits]]
[[cpp_float][1.46076 (0.0192656s)][1.59438 (0.0320398s)][[*1] (0.134302s)]]
[[gmp_float][[*1] (0.0131888s)][[*1] (0.0200954s)][1.01007 (0.135655s)]]
[[mpfr_float][2.19174 (0.0289065s)][1.86101 (0.0373977s)][1.15842 (0.155578s)]]
]
[endsect]
[section:integer_performance Integer Algorithm Perfomance]
Note that these tests are carefully designed to test performance of the underlying algorithms
and not memory allocation or variable copying. As usual, performance results should be taken
with a healthy dose of scepticsm, and real-world peformance may vary widely depending upon the
specifics of the program. In each table relative times are given first, with the best performer
given a score of 1. Total actual times are given in brackets, measured in seconds for 500000
operations.
Test code was compiled with Microsoft Visual Studio 2010 with all optimisations
turned on (/Ox), and used MPIR-2.3.0 and MPFR-3.0.0. The tests were run on 32-bit
Windows Vista machine.
[table Operator +
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.0031173s)][[*1] (0.00696555s)][[*1] (0.0163707s)][[*1] (0.0314806s)][[*1] (0.0596158s)]]
[[gmp_int][12.7096 (0.0396194s)][5.89178 (0.0410395s)][2.66402 (0.0436119s)][1.59356 (0.0501664s)][1.11155 (0.0662662s)]]
[[tommath_int][6.14357 (0.0191513s)][3.16177 (0.0220235s)][1.85441 (0.030358s)][1.45895 (0.0459287s)][1.26576 (0.0754591s)]]
]
[table Operator +(int)
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.00329336s)][[*1] (0.00370718s)][[*1] (0.00995385s)][[*1] (0.0117467s)][[*1] (0.0233483s)]]
[[gmp_int][9.56378 (0.031497s)][8.0588 (0.0298754s)][4.15824 (0.0413905s)][5.47974 (0.0643691s)][4.46265 (0.104195s)]]
[[tommath_int][76.2624 (0.25116s)][71.3973 (0.264682s)][28.0238 (0.278945s)][25.9035 (0.304282s)][13.1635 (0.307346s)]]
]
[table Operator -
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.00359417s)][[*1] (0.00721041s)][[*1] (0.0168213s)][[*1] (0.0323563s)][[*1] (0.061385s)]]
[[gmp_int][10.6794 (0.0383836s)][5.65517 (0.0407761s)][2.63634 (0.0443466s)][1.59979 (0.0517632s)][1.13379 (0.0695978s)]]
[[tommath_int][6.43615 (0.0231326s)][3.6161 (0.0260736s)][2.2585 (0.0379908s)][1.52006 (0.0491835s)][1.24231 (0.0762591s)]]
]
[table Operator -(int)
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.00353606s)][[*1] (0.00577573s)][[*1] (0.0155184s)][[*1] (0.029385s)][[*1] (0.0586271s)]]
[[gmp_int][9.04434 (0.0319814s)][5.12393 (0.0295945s)][2.50743 (0.0389112s)][2.01898 (0.0593277s)][1.68381 (0.098717s)]]
[[tommath_int][60.2486 (0.213043s)][38.3032 (0.221229s)][15.8792 (0.24642s)][8.71166 (0.255992s)][4.85236 (0.28448s)]]
]
[table Operator *
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.0175309s)][[*1] (0.0388232s)][[*1] (0.123609s)][[*1] (0.427489s)][[*1] (1.46312s)]]
[[gmp_int][2.93263 (0.0514117s)][1.70358 (0.0661383s)][1.01811 (0.125848s)][1.20692 (0.515943s)][1.03248 (1.51064s)]]
[[tommath_int][3.82476 (0.0670515s)][2.87425 (0.111587s)][2.74339 (0.339108s)][2.26768 (0.969408s)][2.1233 (3.10664s)]]
]
[table Operator /
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.0973696s)][[*1] (0.260936s)][[*1] (0.845628s)][2.4597 (2.51371s)][6.21836 (7.93136s)]]
[[gmp_int][7.66851 (0.74668s)][3.17732 (0.829077s)][1.05006 (0.887961s)][[*1] (1.02196s)][[*1] (1.27547s)]]
[[tommath_int][18.3945 (1.79107s)][8.11201 (2.11671s)][3.49119 (2.95225s)][4.55727 (4.65733s)][9.06813 (11.5662s)]]
]
[table Operator %
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.098458s)][[*1] (0.269155s)][1.10039 (0.849272s)][2.92096 (2.55909s)][7.47157 (7.99106s)]]
[[gmp_int][6.63934 (0.653697s)][2.6753 (0.72007s)][[*1] (0.771794s)][[*1] (0.87611s)][[*1] (1.06953s)]]
[[tommath_int][18.5522 (1.82661s)][8.00831 (2.15548s)][3.89737 (3.00797s)][5.38078 (4.71416s)][10.7885 (11.5386s)]]
]
[table Operator <<
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.0120907s)][[*1] (0.0129147s)][[*1] (0.0214412s)][[*1] (0.0249208s)][[*1] (0.0341293s)]]
[[gmp_int][1.93756 (0.0234265s)][1.97785 (0.0255433s)][1.43607 (0.0307911s)][1.815 (0.0452311s)][2.00167 (0.0683156s)]]
[[tommath_int][3.42859 (0.0414542s)][3.04951 (0.0393836s)][3.04202 (0.0652246s)][3.81169 (0.0949903s)][4.93896 (0.168563s)]]
]
[table Operator >>
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.0064833s)][[*1] (0.00772857s)][[*1] (0.0186871s)][[*1] (0.0218303s)][[*1] (0.0326372s)]]
[[gmp_int][4.212 (0.0273077s)][3.72696 (0.0288041s)][1.55046 (0.0289735s)][1.51403 (0.0330518s)][1.13695 (0.037107s)]]
[[tommath_int][33.9418 (0.220055s)][29.104 (0.224932s)][13.8407 (0.258642s)][13.1488 (0.287043s)][15.1741 (0.495242s)]]
]
[table Operator &
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.0028732s)][[*1] (0.00552933s)][[*1] (0.0125148s)][[*1] (0.020299s)][[*1] (0.034856s)]]
[[gmp_int][16.3018 (0.0468383s)][9.51109 (0.05259s)][5.20026 (0.0650802s)][4.46545 (0.0906443s)][3.99377 (0.139207s)]]
[[tommath_int][42.221 (0.121309s)][22.2471 (0.123011s)][11.3587 (0.142151s)][7.3475 (0.149147s)][11.4043 (0.397507s)]]
]
[table Operator ^
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.00287983s)][[*1] (0.00543128s)][[*1] (0.0125726s)][[*1] (0.019987s)][[*1] (0.034697s)]]
[[gmp_int][14.938 (0.0430189s)][9.00973 (0.0489344s)][4.83803 (0.0608267s)][4.33359 (0.0866154s)][3.89518 (0.135151s)]]
[[tommath_int][41.6898 (0.12006s)][22.4393 (0.121874s)][10.7513 (0.135172s)][7.2632 (0.145169s)][11.5765 (0.401671s)]]
]
[table Operator |
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.00314803s)][[*1] (0.00548233s)][[*1] (0.0125434s)][[*1] (0.0198161s)][[*1] (0.034957s)]]
[[gmp_int][13.0622 (0.0411201s)][8.63936 (0.0473638s)][4.6932 (0.0588688s)][4.25792 (0.0843755s)][3.78236 (0.13222s)]]
[[tommath_int][38.5896 (0.121481s)][22.3609 (0.12259s)][10.9015 (0.136742s)][7.68521 (0.152291s)][11.6322 (0.406628s)]]
]
[table Operator str
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][1.03557 (0.00143356s)][1.39844 (0.00290281s)][3.14081 (0.0099558s)][6.28067 (0.0372769s)][13.2101 (0.188878s)]]
[[gmp_int][[*1] (0.00138432s)][[*1] (0.00207575s)][[*1] (0.00316982s)][[*1] (0.00593518s)][[*1] (0.014298s)]]
[[tommath_int][5.31194 (0.00735345s)][7.90724 (0.0164135s)][15.8581 (0.0502673s)][19.7526 (0.117235s)][26.6031 (0.380373s)]]
]
[endsect]
[endsect]
[section:map Roadmap]
[section:hist History]
@@ -1056,7 +1287,6 @@ More a list of what ['could] be done, rather than what ['should] be done (which
* Add backend support for libdecNumber.
* Add an adapter backend for complex number types.
* Adapt libtommath code to make an all C++ fixed precision integer type.
[endsect]
+3
View File
@@ -71,6 +71,9 @@ void t3()
std::cout << numerator(v) << std::endl;
std::cout << denominator(v) << std::endl;
mpq_rational w(2, 3); // component wise constructor
std::cout << w << std::endl; // prints 2/3
// Access the underlying data:
mpq_t q;
mpq_init(q);
+3
View File
@@ -59,6 +59,9 @@ void t3()
std::cout << numerator(v) << std::endl;
std::cout << denominator(v) << std::endl;
mp_rational w(2, 3); // Component wise constructor
std::cout << w << std::endl; // prints 2/3
//]
}
@@ -277,6 +277,21 @@ inline int get_sign(const T& val)
return val.compare(static_cast<ui_type>(0));
}
template <class T, class V>
inline void assign_components_imp(T& result, const V& v1, const V& v2, const mpl::int_<number_kind_rational>&)
{
result = v1;
T t;
t = v2;
divide(result, t);
}
template <class T, class V>
inline void assign_components(T& result, const V& v1, const V& v2)
{
return assign_components_imp(result, v1, v2, typename number_category<T>::type());
}
template <class R, int b>
struct has_enough_bits
{
@@ -1139,6 +1139,13 @@ struct number_category<mp_number<Backend> > : public number_category<Backend>{};
template <class tag, class A1, class A2, class A3>
struct number_category<detail::mp_exp<tag, A1, A2, A3> > : public number_category<typename detail::mp_exp<tag, A1, A2, A3>::result_type>{};
template <class T>
struct component_type;
template <class T>
struct component_type<mp_number<T> > : public component_type<T>{};
template <class tag, class A1, class A2, class A3>
struct component_type<detail::mp_exp<tag, A1, A2, A3> > : public component_type<typename detail::mp_exp<tag, A1, A2, A3>::result_type>{};
}} // namespaces
namespace boost{ namespace math{ namespace tools{
+23
View File
@@ -1603,6 +1603,12 @@ inline mp_number<gmp_int> denominator(const mp_number<gmp_rational>& val)
return result;
}
template <>
struct component_type<mp_number<gmp_rational> >
{
typedef mp_number<gmp_int> type;
};
inline void add(gmp_rational& t, const gmp_rational& o)
{
mpq_add(t.data(), t.data(), o.data());
@@ -1668,6 +1674,23 @@ inline void eval_abs(gmp_rational& result, const gmp_rational& val)
mpq_abs(result.data(), val.data());
}
inline void assign_components(gmp_rational& result, unsigned long v1, unsigned long v2)
{
mpq_set_ui(result.data(), v1, v2);
mpq_canonicalize(result.data());
}
inline void assign_components(gmp_rational& result, long v1, long v2)
{
mpq_set_si(result.data(), v1, v2);
mpq_canonicalize(result.data());
}
inline void assign_components(gmp_rational& result, gmp_int const& v1, gmp_int const& v2)
{
mpz_set(mpq_numref(result.data()), v1.data());
mpz_set(mpq_denref(result.data()), v2.data());
mpq_canonicalize(result.data());
}
//
// Some member functions that are dependent upon previous code go here:
//
@@ -37,17 +37,35 @@ public:
m_backend = canonical_value(v);
}
mp_number(const mp_number& e, unsigned digits10) : m_backend(e.m_backend, digits10){}
/*
//
// This conflicts with component based initialization (for rational and complex types)
// which is arguably more useful. Disabled for now.
//
template <class V>
mp_number(V v, unsigned digits10, typename enable_if<mpl::or_<boost::is_arithmetic<V>, is_same<std::string, V>, is_convertible<V, const char*> > >::type* dummy1 = 0)
{
m_backend.precision(digits10);
m_backend = canonical_value(v);
}
*/
template <class Other>
mp_number(const mp_number<Other>& val, typename enable_if<boost::is_convertible<Other, Backend> >::type* dummy1 = 0)
{
m_backend = val.backend();
}
template <class V>
mp_number(V v1, V v2, typename enable_if<mpl::or_<boost::is_arithmetic<V>, is_same<std::string, V>, is_convertible<V, const char*> > >::type* dummy1 = 0)
{
using default_ops::assign_components;
assign_components(m_backend, canonical_value(v1), canonical_value(v2));
}
template <class Other>
mp_number(const mp_number<Other>& v1, const mp_number<Other>& v2, typename enable_if<boost::is_convertible<Other, Backend> >::type* dummy1 = 0)
{
using default_ops::assign_components;
assign_components(m_backend, v1.backend(), v2.backend());
}
template <class V>
mp_number(V v, typename enable_if<mpl::and_<is_convertible<V, Backend>, mpl::not_<mpl::or_<boost::is_arithmetic<V>, is_same<std::string, V>, is_convertible<V, const char*> > > > >::type* dummy1 = 0)
@@ -322,6 +340,7 @@ public:
mp_number& operator&=(const self_type& e)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise & operation is only valid for integer types");
do_bitwise_and(detail::mp_exp<detail::terminal, self_type>(e), detail::terminal());
return *this;
}
@@ -329,6 +348,7 @@ public:
template <class Exp>
mp_number& operator&=(const detail::mp_exp<Exp>& e)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise & operation is only valid for integer types");
// Create a temporary if the RHS references *this, but not
// if we're just doing an x &= x;
if(contains_self(e) && !is_self(e))
@@ -347,6 +367,7 @@ public:
typename enable_if<boost::is_arithmetic<V>, mp_number<Backend>& >::type
operator&=(const V& v)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise & operation is only valid for integer types");
using default_ops::bitwise_and;
bitwise_and(m_backend, canonical_value(v));
return *this;
@@ -354,6 +375,7 @@ public:
mp_number& operator|=(const self_type& e)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise | operation is only valid for integer types");
do_bitwise_or(detail::mp_exp<detail::terminal, self_type>(e), detail::terminal());
return *this;
}
@@ -361,6 +383,7 @@ public:
template <class Exp>
mp_number& operator|=(const detail::mp_exp<Exp>& e)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise | operation is only valid for integer types");
// Create a temporary if the RHS references *this, but not
// if we're just doing an x |= x;
if(contains_self(e) && !is_self(e))
@@ -379,6 +402,7 @@ public:
typename enable_if<boost::is_arithmetic<V>, mp_number<Backend>& >::type
operator|=(const V& v)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise | operation is only valid for integer types");
using default_ops::bitwise_or;
bitwise_or(m_backend, canonical_value(v));
return *this;
@@ -386,6 +410,7 @@ public:
mp_number& operator^=(const self_type& e)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise ^ operation is only valid for integer types");
do_bitwise_xor(detail::mp_exp<detail::terminal, self_type>(e), detail::terminal());
return *this;
}
@@ -393,6 +418,7 @@ public:
template <class Exp>
mp_number& operator^=(const detail::mp_exp<Exp>& e)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise ^ operation is only valid for integer types");
if(contains_self(e))
{
self_type temp(e);
@@ -409,6 +435,7 @@ public:
typename enable_if<boost::is_arithmetic<V>, mp_number<Backend>& >::type
operator^=(const V& v)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise ^ operation is only valid for integer types");
using default_ops::bitwise_xor;
bitwise_xor(m_backend, canonical_value(v));
return *this;
@@ -924,6 +951,7 @@ private:
template <class Exp>
void do_assign(const Exp& e, const detail::bitwise_complement&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise ~ operation is only valid for integer types");
using default_ops::complement;
self_type temp(e.left());
complement(m_backend, temp.backend());
@@ -932,6 +960,7 @@ private:
template <class Exp>
void do_assign(const Exp& e, const detail::complement_immediates&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise ~ operation is only valid for integer types");
using default_ops::complement;
complement(m_backend, canonical_value(e.left().value()));
}
@@ -939,6 +968,7 @@ private:
template <class Exp, class Val>
void do_assign_right_shift(const Exp& e, const Val& val, const detail::terminal&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The right shift operation is only valid for integer types");
using default_ops::right_shift;
right_shift(m_backend, canonical_value(e.value()), val);
}
@@ -946,6 +976,7 @@ private:
template <class Exp, class Val>
void do_assign_left_shift(const Exp& e, const Val& val, const detail::terminal&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The left shift operation is only valid for integer types");
using default_ops::left_shift;
left_shift(m_backend, canonical_value(e.value()), val);
}
@@ -953,6 +984,7 @@ private:
template <class Exp, class Val, class Tag>
void do_assign_right_shift(const Exp& e, const Val& val, const Tag&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The right shift operation is only valid for integer types");
using default_ops::right_shift;
self_type temp(e);
right_shift(m_backend, temp.backend(), val);
@@ -961,6 +993,7 @@ private:
template <class Exp, class Val, class Tag>
void do_assign_left_shift(const Exp& e, const Val& val, const Tag&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The left shift operation is only valid for integer types");
using default_ops::left_shift;
self_type temp(e);
left_shift(m_backend, temp.backend(), val);
@@ -1263,12 +1296,14 @@ private:
template <class Exp>
void do_bitwise_and(const Exp& e, const detail::terminal&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise & operation is only valid for integer types");
using default_ops::bitwise_and;
bitwise_and(m_backend, canonical_value(e.value()));
}
template <class Exp>
void do_bitwise_and(const Exp& e, const detail::bitwise_and&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise & operation is only valid for integer types");
typedef typename Exp::left_type left_type;
typedef typename Exp::right_type right_type;
do_bitwise_and(e.left(), typename left_type::tag_type());
@@ -1277,6 +1312,7 @@ private:
template <class Exp, class unknown>
void do_bitwise_and(const Exp& e, const unknown&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise & operation is only valid for integer types");
using default_ops::bitwise_and;
self_type temp(e);
bitwise_and(m_backend, temp.m_backend);
@@ -1285,12 +1321,14 @@ private:
template <class Exp>
void do_bitwise_or(const Exp& e, const detail::terminal&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise | operation is only valid for integer types");
using default_ops::bitwise_or;
bitwise_or(m_backend, canonical_value(e.value()));
}
template <class Exp>
void do_bitwise_or(const Exp& e, const detail::bitwise_or&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise | operation is only valid for integer types");
typedef typename Exp::left_type left_type;
typedef typename Exp::right_type right_type;
do_bitwise_or(e.left(), typename left_type::tag_type());
@@ -1299,6 +1337,7 @@ private:
template <class Exp, class unknown>
void do_bitwise_or(const Exp& e, const unknown&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise | operation is only valid for integer types");
using default_ops::bitwise_or;
self_type temp(e);
bitwise_or(m_backend, temp.m_backend);
@@ -1307,12 +1346,14 @@ private:
template <class Exp>
void do_bitwise_xor(const Exp& e, const detail::terminal&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise ^ operation is only valid for integer types");
using default_ops::bitwise_xor;
bitwise_xor(m_backend, canonical_value(e.value()));
}
template <class Exp>
void do_bitwise_xor(const Exp& e, const detail::bitwise_xor&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise ^ operation is only valid for integer types");
typedef typename Exp::left_type left_type;
typedef typename Exp::right_type right_type;
do_bitwise_xor(e.left(), typename left_type::tag_type());
@@ -1321,6 +1362,7 @@ private:
template <class Exp, class unknown>
void do_bitwise_xor(const Exp& e, const unknown&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise ^ operation is only valid for integer types");
using default_ops::bitwise_xor;
self_type temp(e);
bitwise_xor(m_backend, temp.m_backend);
@@ -42,6 +42,11 @@ struct rational_adapter
m_value = o.m_value;
return *this;
}
rational_adapter& operator = (const IntBackend& o)
{
m_value = o;
return *this;
}
template <class Arithmetic>
typename enable_if<is_arithmetic<Arithmetic>, rational_adapter&>::type operator = (Arithmetic i)
{
@@ -167,18 +172,30 @@ inline mp_number<IntBackend> denominator(const mp_number<rational_adapter<IntBac
return val.backend().data().denominator();
}
template<class IntBackend, class V>
inline void assign_components(rational_adapter<IntBackend>& result, const V& v1, const V& v2)
{
result.data().assign(v1, v2);
}
template<class IntBackend>
struct number_category<rational_adapter<IntBackend> > : public mpl::int_<number_kind_rational>{};
template <class T>
struct component_type<rational_adapter<T> >
{
typedef mp_number<T> type;
};
}} // namespaces
namespace std{
template <class IntBackend>
class numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::rational_adapter<IntBackend> > > : public std::numeric_limits<IntBackend>
class numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::rational_adapter<IntBackend> > > : public std::numeric_limits<boost::multiprecision::mp_number<IntBackend> >
{
typedef std::numeric_limits<IntBackend> base_type;
typedef std::numeric_limits<boost::multiprecision::mp_number<IntBackend> > base_type;
typedef boost::multiprecision::mp_number<boost::multiprecision::rational_adapter<IntBackend> > number_type;
public:
BOOST_STATIC_CONSTEXPR bool is_integer = false;
+447
View File
@@ -0,0 +1,447 @@
gmp_float 50 + 0.110226
gmp_float 50 - 0.117348
gmp_float 50 +(int)0.0318533
gmp_float 50 -(int)0.129374
gmp_float 50 * 0.265302
gmp_float 50 / 1.21901
gmp_float 50 str 0.0131888
gmp_float 100 + 0.107506
gmp_float 100 - 0.116302
gmp_float 100 +(int)0.0341789
gmp_float 100 -(int)0.128358
gmp_float 100 * 0.395962
gmp_float 100 / 1.60141
gmp_float 100 str 0.0200954
gmp_float 500 + 0.141638
gmp_float 500 - 0.150524
gmp_float 500 +(int)0.0568699
gmp_float 500 -(int)0.165635
gmp_float 500 * 3.20714
gmp_float 500 / 7.89691
gmp_float 500 str 0.135655
gmp_int 64 + 0.0396194
gmp_int 64 - 0.0383836
gmp_int 64 +(int)0.031497
gmp_int 64 -(int)0.0319814
gmp_int 64 * 0.0514117
gmp_int 64 / 0.74668
gmp_int 64 str 0.00138432
gmp_int 64 % 0.653697
gmp_int 64 | 0.0411201
gmp_int 64 & 0.0468383
gmp_int 64 ^ 0.0430189
gmp_int 64 << 0.0234265
gmp_int 64 >> 0.0273077
gmp_int 128 + 0.0410395
gmp_int 128 - 0.0407761
gmp_int 128 +(int)0.0298754
gmp_int 128 -(int)0.0295945
gmp_int 128 * 0.0661383
gmp_int 128 / 0.829077
gmp_int 128 str 0.00207575
gmp_int 128 % 0.72007
gmp_int 128 | 0.0473638
gmp_int 128 & 0.05259
gmp_int 128 ^ 0.0489344
gmp_int 128 << 0.0255433
gmp_int 128 >> 0.0288041
gmp_int 256 + 0.0436119
gmp_int 256 - 0.0443466
gmp_int 256 +(int)0.0413905
gmp_int 256 -(int)0.0389112
gmp_int 256 * 0.125848
gmp_int 256 / 0.887961
gmp_int 256 str 0.00316982
gmp_int 256 % 0.771794
gmp_int 256 | 0.0588688
gmp_int 256 & 0.0650802
gmp_int 256 ^ 0.0608267
gmp_int 256 << 0.0307911
gmp_int 256 >> 0.0289735
gmp_int 512 + 0.0501664
gmp_int 512 - 0.0517632
gmp_int 512 +(int)0.0643691
gmp_int 512 -(int)0.0593277
gmp_int 512 * 0.515943
gmp_int 512 / 1.02196
gmp_int 512 str 0.00593518
gmp_int 512 % 0.87611
gmp_int 512 | 0.0843755
gmp_int 512 & 0.0906443
gmp_int 512 ^ 0.0866154
gmp_int 512 << 0.0452311
gmp_int 512 >> 0.0330518
gmp_int 1024 + 0.0662662
gmp_int 1024 - 0.0695978
gmp_int 1024 +(int)0.104195
gmp_int 1024 -(int)0.098717
gmp_int 1024 * 1.51064
gmp_int 1024 / 1.27547
gmp_int 1024 str 0.014298
gmp_int 1024 % 1.06953
gmp_int 1024 | 0.13222
gmp_int 1024 & 0.139207
gmp_int 1024 ^ 0.135151
gmp_int 1024 << 0.0683156
gmp_int 1024 >> 0.037107
mpq_rational 64 + 1.47058
mpq_rational 64 - 1.47214
mpq_rational 64 +(int)0.654198
mpq_rational 64 -(int)0.646626
mpq_rational 64 * 2.63854
mpq_rational 64 / 9.24093
mpq_rational 64 str 0.00265152
mpq_rational 128 + 3.18485
mpq_rational 128 - 3.1691
mpq_rational 128 +(int)0.66159
mpq_rational 128 -(int)0.657712
mpq_rational 128 * 5.8426
mpq_rational 128 / 14.6415
mpq_rational 128 str 0.00372512
mpq_rational 256 + 6.67422
mpq_rational 256 - 6.67532
mpq_rational 256 +(int)0.705687
mpq_rational 256 -(int)0.704919
mpq_rational 256 * 12.6093
mpq_rational 256 / 26.2341
mpq_rational 256 str 0.00573139
mpq_rational 512 + 15.5117
mpq_rational 512 - 15.6279
mpq_rational 512 +(int)0.817714
mpq_rational 512 -(int)0.818141
mpq_rational 512 * 28.654
mpq_rational 512 / 52.808
mpq_rational 512 str 0.011966
mpq_rational 1024 + 37.688
mpq_rational 1024 - 37.6616
mpq_rational 1024 +(int)0.925526
mpq_rational 1024 -(int)0.935657
mpq_rational 1024 * 68.7938
mpq_rational 1024 / 119.722
mpq_rational 1024 str 0.0288116
tommath_int 64 + 0.0191513
tommath_int 64 - 0.0231326
tommath_int 64 +(int)0.25116
tommath_int 64 -(int)0.213043
tommath_int 64 * 0.0670515
tommath_int 64 / 1.79107
tommath_int 64 str 0.00735345
tommath_int 64 % 1.82661
tommath_int 64 | 0.121481
tommath_int 64 & 0.121309
tommath_int 64 ^ 0.12006
tommath_int 64 << 0.0414542
tommath_int 64 >> 0.220055
tommath_int 128 + 0.0220235
tommath_int 128 - 0.0260736
tommath_int 128 +(int)0.264682
tommath_int 128 -(int)0.221229
tommath_int 128 * 0.111587
tommath_int 128 / 2.11671
tommath_int 128 str 0.0164135
tommath_int 128 % 2.15548
tommath_int 128 | 0.12259
tommath_int 128 & 0.123011
tommath_int 128 ^ 0.121874
tommath_int 128 << 0.0393836
tommath_int 128 >> 0.224932
tommath_int 256 + 0.030358
tommath_int 256 - 0.0379908
tommath_int 256 +(int)0.278945
tommath_int 256 -(int)0.24642
tommath_int 256 * 0.339108
tommath_int 256 / 2.95225
tommath_int 256 str 0.0502673
tommath_int 256 % 3.00797
tommath_int 256 | 0.136742
tommath_int 256 & 0.142151
tommath_int 256 ^ 0.135172
tommath_int 256 << 0.0652246
tommath_int 256 >> 0.258642
tommath_int 512 + 0.0459287
tommath_int 512 - 0.0491835
tommath_int 512 +(int)0.304282
tommath_int 512 -(int)0.255992
tommath_int 512 * 0.969408
tommath_int 512 / 4.65733
tommath_int 512 str 0.117235
tommath_int 512 % 4.71416
tommath_int 512 | 0.152291
tommath_int 512 & 0.149147
tommath_int 512 ^ 0.145169
tommath_int 512 << 0.0949903
tommath_int 512 >> 0.287043
tommath_int 1024 + 0.0754591
tommath_int 1024 - 0.0762591
tommath_int 1024 +(int)0.307346
tommath_int 1024 -(int)0.28448
tommath_int 1024 * 3.10664
tommath_int 1024 / 11.5662
tommath_int 1024 str 0.380373
tommath_int 1024 % 11.5386
tommath_int 1024 | 0.406628
tommath_int 1024 & 0.397507
tommath_int 1024 ^ 0.401671
tommath_int 1024 << 0.168563
tommath_int 1024 >> 0.495242
fixed_int 64 + 0.0031173
fixed_int 64 - 0.00359417
fixed_int 64 +(int)0.00329336
fixed_int 64 -(int)0.00353606
fixed_int 64 * 0.0175309
fixed_int 64 / 0.0973696
fixed_int 64 str 0.00143356
fixed_int 64 % 0.098458
fixed_int 64 | 0.00314803
fixed_int 64 & 0.0028732
fixed_int 64 ^ 0.00287983
fixed_int 64 << 0.0120907
fixed_int 64 >> 0.0064833
fixed_int 128 + 0.00696555
fixed_int 128 - 0.00721041
fixed_int 128 +(int)0.00370718
fixed_int 128 -(int)0.00577573
fixed_int 128 * 0.0388232
fixed_int 128 / 0.260936
fixed_int 128 str 0.00290281
fixed_int 128 % 0.269155
fixed_int 128 | 0.00548233
fixed_int 128 & 0.00552933
fixed_int 128 ^ 0.00543128
fixed_int 128 << 0.0129147
fixed_int 128 >> 0.00772857
fixed_int 256 + 0.0163707
fixed_int 256 - 0.0168213
fixed_int 256 +(int)0.00995385
fixed_int 256 -(int)0.0155184
fixed_int 256 * 0.123609
fixed_int 256 / 0.845628
fixed_int 256 str 0.0099558
fixed_int 256 % 0.849272
fixed_int 256 | 0.0125434
fixed_int 256 & 0.0125148
fixed_int 256 ^ 0.0125726
fixed_int 256 << 0.0214412
fixed_int 256 >> 0.0186871
fixed_int 512 + 0.0314806
fixed_int 512 - 0.0323563
fixed_int 512 +(int)0.0117467
fixed_int 512 -(int)0.029385
fixed_int 512 * 0.427489
fixed_int 512 / 2.51371
fixed_int 512 str 0.0372769
fixed_int 512 % 2.55909
fixed_int 512 | 0.0198161
fixed_int 512 & 0.020299
fixed_int 512 ^ 0.019987
fixed_int 512 << 0.0249208
fixed_int 512 >> 0.0218303
fixed_int 1024 + 0.0596158
fixed_int 1024 - 0.061385
fixed_int 1024 +(int)0.0233483
fixed_int 1024 -(int)0.0586271
fixed_int 1024 * 1.46312
fixed_int 1024 / 7.93136
fixed_int 1024 str 0.188878
fixed_int 1024 % 7.99106
fixed_int 1024 | 0.034957
fixed_int 1024 & 0.034856
fixed_int 1024 ^ 0.034697
fixed_int 1024 << 0.0341293
fixed_int 1024 >> 0.0326372
cpp_float 50 + 0.0242151
cpp_float 50 - 0.0261498
cpp_float 50 +(int)0.0484155
cpp_float 50 -(int)0.0567601
cpp_float 50 * 0.287216
cpp_float 50 / 3.98153
cpp_float 50 str 0.0192656
cpp_float 100 + 0.029252
cpp_float 100 - 0.030946
cpp_float 100 +(int)0.0611055
cpp_float 100 -(int)0.0626685
cpp_float 100 * 0.586363
cpp_float 100 / 8.11948
cpp_float 100 str 0.0320398
cpp_float 500 + 0.0584099
cpp_float 500 - 0.0606388
cpp_float 500 +(int)0.104123
cpp_float 500 -(int)0.111692
cpp_float 500 * 5.05269
cpp_float 500 / 53.6099
cpp_float 500 str 0.134302
mpfr_float 50 + 0.0594147
mpfr_float 50 - 0.0774183
mpfr_float 50 +(int)0.108
mpfr_float 50 -(int)0.13804
mpfr_float 50 * 0.329636
mpfr_float 50 / 1.62419
mpfr_float 50 str 0.0289065
mpfr_float 100 + 0.0639309
mpfr_float 100 - 0.0810465
mpfr_float 100 +(int)0.112839
mpfr_float 100 -(int)0.145473
mpfr_float 100 * 0.457067
mpfr_float 100 / 2.23443
mpfr_float 100 str 0.0373977
mpfr_float 500 + 0.0771588
mpfr_float 500 - 0.0947396
mpfr_float 500 +(int)0.11675
mpfr_float 500 -(int)0.154304
mpfr_float 500 * 3.72612
mpfr_float 500 / 13.4944
mpfr_float 500 str 0.155578
[section:float_performance Float Type Perfomance]
[table Operator *
[[Backend][50 Bits][100 Bits][500 Bits]]
[[cpp_float][1.0826 (0.287216s)][1.48086 (0.586363s)][1.57545 (5.05269s)]]
[[gmp_float][[*1] (0.265302s)][[*1] (0.395962s)][[*1] (3.20714s)]]
[[mpfr_float][1.24249 (0.329636s)][1.15432 (0.457067s)][1.16182 (3.72612s)]]
]
[table Operator +
[[Backend][50 Bits][100 Bits][500 Bits]]
[[cpp_float][[*1] (0.0242151s)][[*1] (0.029252s)][[*1] (0.0584099s)]]
[[gmp_float][4.55194 (0.110226s)][3.67516 (0.107506s)][2.42489 (0.141638s)]]
[[mpfr_float][2.45362 (0.0594147s)][2.18552 (0.0639309s)][1.32099 (0.0771588s)]]
]
[table Operator +(int)
[[Backend][50 Bits][100 Bits][500 Bits]]
[[cpp_float][1.51995 (0.0484155s)][1.78781 (0.0611055s)][1.8309 (0.104123s)]]
[[gmp_float][[*1] (0.0318533s)][[*1] (0.0341789s)][[*1] (0.0568699s)]]
[[mpfr_float][3.39055 (0.108s)][3.30142 (0.112839s)][2.05293 (0.11675s)]]
]
[table Operator -
[[Backend][50 Bits][100 Bits][500 Bits]]
[[cpp_float][[*1] (0.0261498s)][[*1] (0.030946s)][[*1] (0.0606388s)]]
[[gmp_float][4.48753 (0.117348s)][3.75823 (0.116302s)][2.4823 (0.150524s)]]
[[mpfr_float][2.96057 (0.0774183s)][2.61897 (0.0810465s)][1.56236 (0.0947396s)]]
]
[table Operator -(int)
[[Backend][50 Bits][100 Bits][500 Bits]]
[[cpp_float][[*1] (0.0567601s)][[*1] (0.0626685s)][[*1] (0.111692s)]]
[[gmp_float][2.27932 (0.129374s)][2.04821 (0.128358s)][1.48297 (0.165635s)]]
[[mpfr_float][2.43199 (0.13804s)][2.32131 (0.145473s)][1.38152 (0.154304s)]]
]
[table Operator /
[[Backend][50 Bits][100 Bits][500 Bits]]
[[cpp_float][3.2662 (3.98153s)][5.07021 (8.11948s)][6.78872 (53.6099s)]]
[[gmp_float][[*1] (1.21901s)][[*1] (1.60141s)][[*1] (7.89691s)]]
[[mpfr_float][1.33238 (1.62419s)][1.39529 (2.23443s)][1.70882 (13.4944s)]]
]
[table Operator str
[[Backend][50 Bits][100 Bits][500 Bits]]
[[cpp_float][1.46076 (0.0192656s)][1.59438 (0.0320398s)][[*1] (0.134302s)]]
[[gmp_float][[*1] (0.0131888s)][[*1] (0.0200954s)][1.01007 (0.135655s)]]
[[mpfr_float][2.19174 (0.0289065s)][1.86101 (0.0373977s)][1.15842 (0.155578s)]]
]
[endsect]
[section:integer_performance Integer Type Perfomance]
[table Operator %
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.098458s)][[*1] (0.269155s)][1.10039 (0.849272s)][2.92096 (2.55909s)][7.47157 (7.99106s)]]
[[gmp_int][6.63934 (0.653697s)][2.6753 (0.72007s)][[*1] (0.771794s)][[*1] (0.87611s)][[*1] (1.06953s)]]
[[tommath_int][18.5522 (1.82661s)][8.00831 (2.15548s)][3.89737 (3.00797s)][5.38078 (4.71416s)][10.7885 (11.5386s)]]
]
[table Operator &
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.0028732s)][[*1] (0.00552933s)][[*1] (0.0125148s)][[*1] (0.020299s)][[*1] (0.034856s)]]
[[gmp_int][16.3018 (0.0468383s)][9.51109 (0.05259s)][5.20026 (0.0650802s)][4.46545 (0.0906443s)][3.99377 (0.139207s)]]
[[tommath_int][42.221 (0.121309s)][22.2471 (0.123011s)][11.3587 (0.142151s)][7.3475 (0.149147s)][11.4043 (0.397507s)]]
]
[table Operator *
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.0175309s)][[*1] (0.0388232s)][[*1] (0.123609s)][[*1] (0.427489s)][[*1] (1.46312s)]]
[[gmp_int][2.93263 (0.0514117s)][1.70358 (0.0661383s)][1.01811 (0.125848s)][1.20692 (0.515943s)][1.03248 (1.51064s)]]
[[tommath_int][3.82476 (0.0670515s)][2.87425 (0.111587s)][2.74339 (0.339108s)][2.26768 (0.969408s)][2.1233 (3.10664s)]]
]
[table Operator +
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.0031173s)][[*1] (0.00696555s)][[*1] (0.0163707s)][[*1] (0.0314806s)][[*1] (0.0596158s)]]
[[gmp_int][12.7096 (0.0396194s)][5.89178 (0.0410395s)][2.66402 (0.0436119s)][1.59356 (0.0501664s)][1.11155 (0.0662662s)]]
[[tommath_int][6.14357 (0.0191513s)][3.16177 (0.0220235s)][1.85441 (0.030358s)][1.45895 (0.0459287s)][1.26576 (0.0754591s)]]
]
[table Operator +(int)
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.00329336s)][[*1] (0.00370718s)][[*1] (0.00995385s)][[*1] (0.0117467s)][[*1] (0.0233483s)]]
[[gmp_int][9.56378 (0.031497s)][8.0588 (0.0298754s)][4.15824 (0.0413905s)][5.47974 (0.0643691s)][4.46265 (0.104195s)]]
[[tommath_int][76.2624 (0.25116s)][71.3973 (0.264682s)][28.0238 (0.278945s)][25.9035 (0.304282s)][13.1635 (0.307346s)]]
]
[table Operator -
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.00359417s)][[*1] (0.00721041s)][[*1] (0.0168213s)][[*1] (0.0323563s)][[*1] (0.061385s)]]
[[gmp_int][10.6794 (0.0383836s)][5.65517 (0.0407761s)][2.63634 (0.0443466s)][1.59979 (0.0517632s)][1.13379 (0.0695978s)]]
[[tommath_int][6.43615 (0.0231326s)][3.6161 (0.0260736s)][2.2585 (0.0379908s)][1.52006 (0.0491835s)][1.24231 (0.0762591s)]]
]
[table Operator -(int)
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.00353606s)][[*1] (0.00577573s)][[*1] (0.0155184s)][[*1] (0.029385s)][[*1] (0.0586271s)]]
[[gmp_int][9.04434 (0.0319814s)][5.12393 (0.0295945s)][2.50743 (0.0389112s)][2.01898 (0.0593277s)][1.68381 (0.098717s)]]
[[tommath_int][60.2486 (0.213043s)][38.3032 (0.221229s)][15.8792 (0.24642s)][8.71166 (0.255992s)][4.85236 (0.28448s)]]
]
[table Operator /
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.0973696s)][[*1] (0.260936s)][[*1] (0.845628s)][2.4597 (2.51371s)][6.21836 (7.93136s)]]
[[gmp_int][7.66851 (0.74668s)][3.17732 (0.829077s)][1.05006 (0.887961s)][[*1] (1.02196s)][[*1] (1.27547s)]]
[[tommath_int][18.3945 (1.79107s)][8.11201 (2.11671s)][3.49119 (2.95225s)][4.55727 (4.65733s)][9.06813 (11.5662s)]]
]
[table Operator <<
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.0120907s)][[*1] (0.0129147s)][[*1] (0.0214412s)][[*1] (0.0249208s)][[*1] (0.0341293s)]]
[[gmp_int][1.93756 (0.0234265s)][1.97785 (0.0255433s)][1.43607 (0.0307911s)][1.815 (0.0452311s)][2.00167 (0.0683156s)]]
[[tommath_int][3.42859 (0.0414542s)][3.04951 (0.0393836s)][3.04202 (0.0652246s)][3.81169 (0.0949903s)][4.93896 (0.168563s)]]
]
[table Operator >>
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.0064833s)][[*1] (0.00772857s)][[*1] (0.0186871s)][[*1] (0.0218303s)][[*1] (0.0326372s)]]
[[gmp_int][4.212 (0.0273077s)][3.72696 (0.0288041s)][1.55046 (0.0289735s)][1.51403 (0.0330518s)][1.13695 (0.037107s)]]
[[tommath_int][33.9418 (0.220055s)][29.104 (0.224932s)][13.8407 (0.258642s)][13.1488 (0.287043s)][15.1741 (0.495242s)]]
]
[table Operator ^
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.00287983s)][[*1] (0.00543128s)][[*1] (0.0125726s)][[*1] (0.019987s)][[*1] (0.034697s)]]
[[gmp_int][14.938 (0.0430189s)][9.00973 (0.0489344s)][4.83803 (0.0608267s)][4.33359 (0.0866154s)][3.89518 (0.135151s)]]
[[tommath_int][41.6898 (0.12006s)][22.4393 (0.121874s)][10.7513 (0.135172s)][7.2632 (0.145169s)][11.5765 (0.401671s)]]
]
[table Operator str
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][1.03557 (0.00143356s)][1.39844 (0.00290281s)][3.14081 (0.0099558s)][6.28067 (0.0372769s)][13.2101 (0.188878s)]]
[[gmp_int][[*1] (0.00138432s)][[*1] (0.00207575s)][[*1] (0.00316982s)][[*1] (0.00593518s)][[*1] (0.014298s)]]
[[tommath_int][5.31194 (0.00735345s)][7.90724 (0.0164135s)][15.8581 (0.0502673s)][19.7526 (0.117235s)][26.6031 (0.380373s)]]
]
[table Operator |
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[fixed_int][[*1] (0.00314803s)][[*1] (0.00548233s)][[*1] (0.0125434s)][[*1] (0.0198161s)][[*1] (0.034957s)]]
[[gmp_int][13.0622 (0.0411201s)][8.63936 (0.0473638s)][4.6932 (0.0588688s)][4.25792 (0.0843755s)][3.78236 (0.13222s)]]
[[tommath_int][38.5896 (0.121481s)][22.3609 (0.12259s)][10.9015 (0.136742s)][7.68521 (0.152291s)][11.6322 (0.406628s)]]
]
[endsect]
[section:rational_performance Rational Type Perfomance]
[table Operator *
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[mpq_rational][[*1] (2.63854s)][[*1] (5.8426s)][[*1] (12.6093s)][[*1] (28.654s)][[*1] (68.7938s)]]
]
[table Operator +
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[mpq_rational][[*1] (1.47058s)][[*1] (3.18485s)][[*1] (6.67422s)][[*1] (15.5117s)][[*1] (37.688s)]]
]
[table Operator +(int)
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[mpq_rational][[*1] (0.654198s)][[*1] (0.66159s)][[*1] (0.705687s)][[*1] (0.817714s)][[*1] (0.925526s)]]
]
[table Operator -
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[mpq_rational][[*1] (1.47214s)][[*1] (3.1691s)][[*1] (6.67532s)][[*1] (15.6279s)][[*1] (37.6616s)]]
]
[table Operator -(int)
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[mpq_rational][[*1] (0.646626s)][[*1] (0.657712s)][[*1] (0.704919s)][[*1] (0.818141s)][[*1] (0.935657s)]]
]
[table Operator /
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[mpq_rational][[*1] (9.24093s)][[*1] (14.6415s)][[*1] (26.2341s)][[*1] (52.808s)][[*1] (119.722s)]]
]
[table Operator str
[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]]
[[mpq_rational][[*1] (0.00265152s)][[*1] (0.00372512s)][[*1] (0.00573139s)][[*1] (0.011966s)][[*1] (0.0288116s)]]
]
[endsect]
+197 -22
View File
@@ -50,6 +50,12 @@
#include <boost/chrono.hpp>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <cctype>
#include <iostream>
#include <iomanip>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int.hpp>
@@ -134,8 +140,8 @@ struct tester
stopwatch<boost::chrono::high_resolution_clock> w;
for(unsigned i = 0; i < 1000; ++i)
{
for(unsigned i = 0; i < b.size(); ++i)
a[i] = b[i] * c[i];
for(unsigned k = 0; k < b.size(); ++k)
a[k] = b[k] * c[k];
}
return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count();
}
@@ -253,7 +259,7 @@ private:
typedef typename T::backend_type::exponent_type e_type;
static boost::random::uniform_int_distribution<e_type> ui(0, std::numeric_limits<T>::max_exponent - 10);
return ldexp(val, ui(gen));
return ldexp(val, static_cast<int>(ui(gen)));
}
T generate_random(const boost::mpl::int_<boost::multiprecision::number_kind_integer>&)
{
@@ -286,6 +292,47 @@ private:
val %= max_val;
return val;
}
T generate_random(const boost::mpl::int_<boost::multiprecision::number_kind_rational>&)
{
typedef boost::random::mt19937::result_type random_type;
typedef typename boost::multiprecision::component_type<T>::type IntType;
IntType max_val;
unsigned digits;
if(std::numeric_limits<IntType>::is_bounded)
{
max_val = (std::numeric_limits<IntType>::max)();
digits = std::numeric_limits<IntType>::digits;
}
else
{
max_val = IntType(1) << bits_wanted;
digits = bits_wanted;
}
unsigned bits_per_r_val = std::numeric_limits<random_type>::digits - 1;
while((random_type(1) << bits_per_r_val) > (gen.max)()) --bits_per_r_val;
unsigned terms_needed = digits / bits_per_r_val + 1;
IntType val = 0;
IntType denom = 0;
for(unsigned i = 0; i < terms_needed; ++i)
{
val *= (gen.max)();
val += gen();
}
for(unsigned i = 0; i < terms_needed; ++i)
{
denom *= (gen.max)();
denom += gen();
}
if(denom == 0)
denom = 1;
val %= max_val;
denom %= max_val;
return T(val, denom);
}
std::vector<T> a, b, c, small;
static boost::random::mt19937 gen;
};
@@ -293,16 +340,46 @@ private:
template <class N, int V>
boost::random::mt19937 tester<N, V>::gen;
const char* category_name(const boost::mpl::int_<boost::multiprecision::number_kind_integer>&)
{
return "integer";
}
const char* category_name(const boost::mpl::int_<boost::multiprecision::number_kind_floating_point>&)
{
return "float";
}
const char* category_name(const boost::mpl::int_<boost::multiprecision::number_kind_rational>&)
{
return "rational";
}
//
// Keys in order are:
// Category
// Operator
// Type
// Precision
// Time
//
std::map<std::string, std::map<std::string, std::map<std::string, std::map<int, double> > > > result_table;
void report_result(const char* cat, const char* type, const char* op, unsigned precision, double time)
{
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << op << time << std::endl;
result_table[cat][op][type][precision] = time;
}
template <class Number, int N>
void test_int_ops(tester<Number, N>& t, const char* type, unsigned precision, const boost::mpl::int_<boost::multiprecision::number_kind_integer>&)
{
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << "%" << t.test_mod() << std::endl;
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << "|" << t.test_or() << std::endl;
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << "&" << t.test_and() << std::endl;
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << "^" << t.test_xor() << std::endl;
//std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << "~" << t.test_complement() << std::endl;
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << "<<" << t.test_left_shift() << std::endl;
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << ">>" << t.test_right_shift() << std::endl;
const char* cat = "integer";
report_result(cat, type, "%", precision, t.test_mod());
report_result(cat, type, "|", precision, t.test_or());
report_result(cat, type, "&", precision, t.test_and());
report_result(cat, type, "^", precision, t.test_xor());
//report_result(cat, type, "~", precision, t.test_complement());
report_result(cat, type, "<<", precision, t.test_left_shift());
report_result(cat, type, ">>", precision, t.test_right_shift());
}
template <class Number, int N, class U>
void test_int_ops(tester<Number, N>& t, const char* type, unsigned precision, const U&)
@@ -314,17 +391,98 @@ void test(const char* type, unsigned precision)
{
bits_wanted = precision;
tester<Number, boost::multiprecision::number_category<Number>::value> t;
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << "+" << t.test_add() << std::endl;
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << "-" << t.test_subtract() << std::endl;
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << "+ (int)" << t.test_add_int() << std::endl;
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << "- (int)" << t.test_subtract_int() << std::endl;
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << "*" << t.test_multiply() << std::endl;
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << "/" << t.test_divide() << std::endl;
std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(5) << "str" << t.test_str() << std::endl;
const char* cat = category_name(typename boost::multiprecision::number_category<Number>::type());
//
// call t.test_multiply() first so that the destination operands are
// forced to perform whatever memory allocation may be needed. That way
// we measure only algorithm performance, and not memory allocation effects.
//
t.test_multiply();
//
// Now the actual tests:
//
report_result(cat, type, "+", precision, t.test_add());
report_result(cat, type, "-", precision, t.test_subtract());
report_result(cat, type, "+(int)", precision, t.test_add_int());
report_result(cat, type, "-(int)", precision, t.test_subtract_int());
report_result(cat, type, "*", precision, t.test_multiply());
report_result(cat, type, "/", precision, t.test_divide());
report_result(cat, type, "str", precision, t.test_str());
test_int_ops(t, type, precision, typename boost::multiprecision::number_category<Number>::type());
}
void quickbook_results()
{
//
// Keys in order are:
// Category
// Operator
// Type
// Precision
// Time
//
typedef std::map<std::string, std::map<std::string, std::map<std::string, std::map<int, double> > > >::const_iterator category_iterator;
typedef std::map<std::string, std::map<std::string, std::map<int, double> > >::const_iterator operator_iterator;
typedef std::map<std::string, std::map<int, double> >::const_iterator type_iterator;
typedef std::map<int, double>::const_iterator precision_iterator;
for(category_iterator i = result_table.begin(); i != result_table.end(); ++i)
{
std::string cat = i->first;
cat[0] = std::toupper(cat[0]);
std::cout << "[section:" << i->first << "_performance " << cat << " Type Perfomance]" << std::endl;
for(operator_iterator j = i->second.begin(); j != i->second.end(); ++j)
{
std::string op = j->first;
std::cout << "[table Operator " << op << std::endl;
std::cout << "[[Backend]";
for(precision_iterator k = j->second.begin()->second.begin(); k != j->second.begin()->second.end(); ++k)
{
std::cout << "[" << k->first << " Bits]";
}
std::cout << "]\n";
std::vector<double> best_times(j->second.begin()->second.size(), (std::numeric_limits<double>::max)());
for(unsigned m = 0; m < j->second.begin()->second.size(); ++m)
{
for(type_iterator k = j->second.begin(); k != j->second.end(); ++k)
{
precision_iterator l = k->second.begin();
std::advance(l, m);
if(best_times[m] > l->second)
best_times[m] = l->second;
}
}
for(type_iterator k = j->second.begin(); k != j->second.end(); ++k)
{
std::cout << "[[" << k->first << "]";
unsigned m = 0;
for(precision_iterator l = k->second.begin(); l != k->second.end(); ++l)
{
double rel_time = l->second / best_times[m];
if(rel_time == 1)
std::cout << "[[*" << rel_time << "]";
else
std::cout << "[" << rel_time;
std::cout << " (" << l->second << "s)]";
++m;
}
std::cout << "]\n";
}
std::cout << "]\n";
}
std::cout << "[endsect]" << std::endl;
}
}
int main()
{
@@ -339,6 +497,12 @@ int main()
test<boost::multiprecision::mpz_int>("gmp_int", 256);
test<boost::multiprecision::mpz_int>("gmp_int", 512);
test<boost::multiprecision::mpz_int>("gmp_int", 1024);
test<boost::multiprecision::mpq_rational>("mpq_rational", 64);
test<boost::multiprecision::mpq_rational>("mpq_rational", 128);
test<boost::multiprecision::mpq_rational>("mpq_rational", 256);
test<boost::multiprecision::mpq_rational>("mpq_rational", 512);
test<boost::multiprecision::mpq_rational>("mpq_rational", 1024);
#endif
#ifdef TEST_TOMMATH
test<boost::multiprecision::mp_int>("tommath_int", 64);
@@ -346,13 +510,23 @@ int main()
test<boost::multiprecision::mp_int>("tommath_int", 256);
test<boost::multiprecision::mp_int>("tommath_int", 512);
test<boost::multiprecision::mp_int>("tommath_int", 1024);
/*
//
// These are actually too slow to test!!!
//
test<boost::multiprecision::mp_rational>("mp_rational", 64);
test<boost::multiprecision::mp_rational>("mp_rational", 128);
test<boost::multiprecision::mp_rational>("mp_rational", 256);
test<boost::multiprecision::mp_rational>("mp_rational", 512);
test<boost::multiprecision::mp_rational>("mp_rational", 1024);
*/
#endif
#ifdef TEST_FIXED_INT
test<boost::multiprecision::mp_number<boost::multiprecision::fixed_int<64, true> > >("mp_int64_t", 64);
test<boost::multiprecision::mp_int128_t>("mp_int128_t", 128);
test<boost::multiprecision::mp_int256_t>("mp_int256_t", 256);
test<boost::multiprecision::mp_int512_t>("mp_int512_t", 512);
test<boost::multiprecision::mp_number<boost::multiprecision::fixed_int<1024, true> > >("mp_int1024_t", 1024);
test<boost::multiprecision::mp_number<boost::multiprecision::fixed_int<64, true> > >("fixed_int", 64);
test<boost::multiprecision::mp_int128_t>("fixed_int", 128);
test<boost::multiprecision::mp_int256_t>("fixed_int", 256);
test<boost::multiprecision::mp_int512_t>("fixed_int", 512);
test<boost::multiprecision::mp_number<boost::multiprecision::fixed_int<1024, true> > >("fixed_int", 1024);
#endif
#ifdef TEST_CPP_FLOAT
test<boost::multiprecision::cpp_float_50>("cpp_float", 50);
@@ -364,6 +538,7 @@ int main()
test<boost::multiprecision::mpfr_float_100>("mpfr_float", 100);
test<boost::multiprecision::mpfr_float_500>("mpfr_float", 500);
#endif
quickbook_results();
return 0;
}
+30 -30
View File
@@ -5,65 +5,65 @@
13
27
Testing Bessel Functions.....
Time for mpfr_float_50 = 6.2742 seconds
Time for mpfr_float_50 = 6.47208 seconds
Total allocations for mpfr_float_50 = 2684348
Time for mpf_float_50 = 11.2255 seconds
Time for mpf_float_50 = 11.6627 seconds
Total allocations for mpf_float_50 = 2601366
Time for cpp_float_50 = 19.5712 seconds
Time for cpp_float_50 = 20.2855 seconds
Total allocations for cpp_float_50 = 0
Time for mpfr_class (50 digits) = 6.11757 seconds
Time for mpfr_class (50 digits) = 6.48063 seconds
Total allocations for mpfr_class (50 digits) = 3946031
Time for mpreal (50 digits) = 9.38756 seconds
Time for mpreal (50 digits) = 9.98151 seconds
Total allocations for mpreal (50 digits) = 13223017
Time for mpfr_float_100 = 9.61944 seconds
Time for mpfr_float_100 = 10.154 seconds
Total allocations for mpfr_float_50 = 3671485
Time for mpf_float_100 = 8.29211 seconds
Time for mpf_float_100 = 8.51179 seconds
Total allocations for mpf_float_100 = 3593669
Time for cpp_float_100 = 20.4485 seconds
Time for cpp_float_100 = 21.0198 seconds
Total allocations for cpp_float_100 = 0
Time for mpfr_class (100 digits) = 9.88427 seconds
Time for mpfr_class (100 digits) = 9.80571 seconds
Total allocations for mpfr_class (100 digits) = 5447348
Time for mpreal (100 digits) = 13.7811 seconds
Time for mpreal (100 digits) = 13.7021 seconds
Total allocations for mpreal (100 digits) = 16671065
Testing Polynomial Evaluation.....
Time for mpfr_float_50 = 0.00839464 seconds
Time for mpfr_float_50 = 0.00823841 seconds
Total allocations for mpfr_float_50 = 2996
Time for mpf_float_50 = 0.0042138 seconds
Time for mpf_float_50 = 0.00401608 seconds
Total allocations for mpf_float_50 = 2996
Time for cpp_float_50 = 0.0046054 seconds
Time for cpp_float_50 = 0.00492116 seconds
Total allocations for cpp_float_50 = 0
Time for mpfr_class (50 digits) = 0.00990538 seconds
Time for mpfr_class (50 digits) = 0.00935629 seconds
Total allocations for mpfr_class (50 digits) = 12976
Time for mpreal (50 digits) = 0.0152955 seconds
Time for mpreal (50 digits) = 0.0148374 seconds
Total allocations for mpreal (50 digits = 27947
Time for mpfr_float_100 = 0.00957098 seconds
Time for mpfr_float_100 = 0.00948452 seconds
Total allocations for mpfr_float_100 = 2996
Time for mpf_float_100 = 0.00418726 seconds
Time for mpf_float_100 = 0.00390071 seconds
Total allocations for mpf_float_100 = 2996
Time for cpp_float_100 = 0.0090742 seconds
Time for cpp_float_100 = 0.00893563 seconds
Total allocations for cpp_float_100 = 0
Time for mpfr_class (100 digits) = 0.011094 seconds
Time for mpfr_class (100 digits) = 0.0106166 seconds
Total allocations for mpfr_class (100 digits) = 12976
Time for mpreal (100 digits) = 0.0172028 seconds
Time for mpreal (100 digits) = 0.0162364 seconds
Total allocations for mpreal (100 digits) = 27947
Testing Non-Central T.....
Time for mpfr_float_50 = 260.324 seconds
Time for mpfr_float_50 = 258.087 seconds
Total allocations for mpfr_float_50 = 139149049
Time for mpf_float_50 = 201.95 seconds
Time for mpf_float_50 = 197.303 seconds
Total allocations for mpf_float_50 = 134600354
Time for cpp_float_50 = 340.292 seconds
Time for cpp_float_50 = 334.503 seconds
Total allocations for cpp_float_50 = 0
Time for mpfr_class (50 digits) = 269.03 seconds
Time for mpfr_class (50 digits) = 266.389 seconds
Total allocations for mpfr_class (50 digits) = 252401115
Time for mpreal (50 digits) = 350.758 seconds
Time for mpreal (50 digits) = 346.641 seconds
Total allocations for mpreal (50 digits) = 447009420
Time for mpfr_float_100 = 519.421 seconds
Time for mpfr_float_100 = 516.741 seconds
Total allocations for mpfr_float_100 = 220400854
Time for mpf_float_100 = 404.593 seconds
Time for mpf_float_100 = 397.302 seconds
Total allocations for mpf_float_100 = 212307349
Time for cpp_float_100 = 1118.91 seconds
Time for cpp_float_100 = 1064.53 seconds
Total allocations for cpp_float_100 = 0
Time for mpfr_class (100 digits) = 541.35 seconds
Time for mpfr_class (100 digits) = 525.74 seconds
Total allocations for mpfr_class (100 digits) = 407154781
Time for mpreal (100 digits) = 677.265 seconds
Time for mpreal (100 digits) = 649.941 seconds
Total allocations for mpreal (100 digits) = 724581024