|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r86372 - in sandbox/multiprecision.cpp_bin_float: boost/multiprecision libs/multiprecision/doc libs/multiprecision/doc/html libs/multiprecision/test
From: john_at_[hidden]
Date: 2013-10-20 12:41:57
Author: johnmaddock
Date: 2013-10-20 12:41:57 EDT (Sun, 20 Oct 2013)
New Revision: 86372
URL: http://svn.boost.org/trac/boost/changeset/86372
Log:
Change default expression template options.
Tweak docs and regenerate.
Text files modified:
sandbox/multiprecision.cpp_bin_float/boost/multiprecision/cpp_bin_float.hpp | 10 ++++++++--
sandbox/multiprecision.cpp_bin_float/libs/multiprecision/doc/html/index.html | 2 +-
sandbox/multiprecision.cpp_bin_float/libs/multiprecision/doc/multiprecision.qbk | 20 ++++++++++++++++----
sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_arithmetic_cpp_bin_float_1.cpp | 2 +-
4 files changed, 26 insertions(+), 8 deletions(-)
Modified: sandbox/multiprecision.cpp_bin_float/boost/multiprecision/cpp_bin_float.hpp
==============================================================================
--- sandbox/multiprecision.cpp_bin_float/boost/multiprecision/cpp_bin_float.hpp Sun Oct 20 12:39:12 2013 (r86371)
+++ sandbox/multiprecision.cpp_bin_float/boost/multiprecision/cpp_bin_float.hpp 2013-10-20 12:41:57 EDT (Sun, 20 Oct 2013) (r86372)
@@ -1322,8 +1322,14 @@
template<unsigned Digits, backends::digit_base_type DigitBase, class Exponent, Exponent MinE, Exponent MaxE, class Allocator>
struct number_category<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > : public boost::mpl::int_<boost::multiprecision::number_kind_floating_point>{};
-typedef number<backends::cpp_bin_float<50>, et_off> cpp_bin_float_50;
-typedef number<backends::cpp_bin_float<100>, et_off> cpp_bin_float_100;
+template<unsigned Digits, backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
+struct expression_template_default<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> >
+{
+ static const expression_template_option value = is_void<Allocator>::value ? et_off : et_on;
+};
+
+typedef number<backends::cpp_bin_float<50> > cpp_bin_float_50;
+typedef number<backends::cpp_bin_float<100> > cpp_bin_float_100;
typedef number<backends::cpp_bin_float<24, backends::digit_base_2, void, boost::int16_t, -126, 127>, et_off> float32_t;
typedef number<backends::cpp_bin_float<53, backends::digit_base_2, void, boost::int16_t, -1022, 1023>, et_off> float64_t;
Modified: sandbox/multiprecision.cpp_bin_float/libs/multiprecision/doc/html/index.html
==============================================================================
--- sandbox/multiprecision.cpp_bin_float/libs/multiprecision/doc/html/index.html Sun Oct 20 12:39:12 2013 (r86371)
+++ sandbox/multiprecision.cpp_bin_float/libs/multiprecision/doc/html/index.html 2013-10-20 12:41:57 EDT (Sun, 20 Oct 2013) (r86372)
@@ -149,7 +149,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: October 16, 2013 at 11:16:57 GMT</small></p></td>
+<td align="left"><p><small>Last revised: October 20, 2013 at 16:40:18 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: sandbox/multiprecision.cpp_bin_float/libs/multiprecision/doc/multiprecision.qbk
==============================================================================
--- sandbox/multiprecision.cpp_bin_float/libs/multiprecision/doc/multiprecision.qbk Sun Oct 20 12:39:12 2013 (r86371)
+++ sandbox/multiprecision.cpp_bin_float/libs/multiprecision/doc/multiprecision.qbk 2013-10-20 12:41:57 EDT (Sun, 20 Oct 2013) (r86372)
@@ -665,12 +665,17 @@
digit_base_10 = 10
};
- template <unsigned Digits, digit_base_type base = digit_base_10, class Allocator = void>
+ template <unsigned Digits, digit_base_type base = digit_base_10, class Allocator = void, class Exponent = int, ExponentMin = 0, ExponentMax = 0>
class cpp_bin_float;
typedef number<cpp_bin_float<50> > cpp_bin_float_50;
typedef number<cpp_bin_float<100> > cpp_bin_float_100;
+ typedef number<backends::cpp_bin_float<24, backends::digit_base_2, void, boost::int16_t, -126, 127>, et_off> float32_t;
+ typedef number<backends::cpp_bin_float<53, backends::digit_base_2, void, boost::int16_t, -1022, 1023>, et_off> float64_t;
+ typedef number<backends::cpp_bin_float<64, backends::digit_base_2, void, boost::int16_t, -16382, 16383>, et_off> float80_t;
+ typedef number<backends::cpp_bin_float<113, backends::digit_base_2, void, boost::int16_t, -16382, 16383>, et_off> float128_t;
+
}} // namespaces
The `cpp_bin_float` back-end is used in conjunction with `number`: It acts as an entirely C++ (header only and dependency free)
@@ -683,7 +688,8 @@
Optionally, you can specify whether the precision is specified in decimal digits or binary bits - for example
to declare a `cpp_bin_float` with exactly the same precision as `double` one would use
-`number<cpp_bin_float<53, digit_base_2> >`.
+`number<cpp_bin_float<53, digit_base_2> >`. The typedefs `float32_t`, `float64_t`, `float128_t` and `float80_t` provide
+software analogues of the IEEE single, double and quad float data types, plus the intel-extended-double type respectively.
Normally `cpp_bin_float` allocates no memory: all of the space required for its digits are allocated
directly within the class. As a result care should be taken not to use the class with too high a digit count
@@ -696,6 +702,13 @@
is completely opaque, the suggestion would be to use an allocator with `void` `value_type`, for example:
`number<cpp_bin_float<1000, digit_base_10, std::allocator<void> > >`.
+The final template parameters determine the type and range of the exponent: parameter `Exponent` can be
+any signed integer type, but note that `MinExponent` and `MaxExponent` can not go right up to the limits
+of the `Exponent` type as there has to be a little extra headroom for internal calculations. You will
+get a compile time error if if this is the case. In addition if MinExponent or MaxExponent are zero, then
+the library will choose suitable values that are as large as possible given the constraints of the type
+and need for extra headhoom for internal calculations.
+
There is full standard library and `numeric_limits` support available for this type.
Things you should know when using this type:
@@ -710,8 +723,7 @@
Narrowing conversions round to nearest and are `explicit`.
* Conversion from a string results in a `std::runtime_error` being thrown if the string can not be interpreted
as a valid floating point number.
-* When the precision is specified as binary bits, the precision of the type is exactly that number of bits
-and all arithmetic operations are correctly rounded to nearest. String comversions and the `sqrt` function
+* All arithmetic operations are correctly rounded to nearest. String comversions and the `sqrt` function
are also correctly rounded, but transcendental functions (sin, cos, pow, exp etc) are not.
[h5 cpp_bin_float example:]
Modified: sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_arithmetic_cpp_bin_float_1.cpp
==============================================================================
--- sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_arithmetic_cpp_bin_float_1.cpp Sun Oct 20 12:39:12 2013 (r86371)
+++ sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_arithmetic_cpp_bin_float_1.cpp 2013-10-20 12:41:57 EDT (Sun, 20 Oct 2013) (r86372)
@@ -19,7 +19,7 @@
int main()
{
- //test<boost::multiprecision::cpp_bin_float_50>();
+ test<boost::multiprecision::cpp_bin_float_50>();
//test<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<21> > >();
test<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<1000, boost::multiprecision::digit_base_10, std::allocator<void> > > >();
//test<boost::multiprecision::float128_t>();
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk