From e0737c56c1e384e05064a0c6e1ac46979371041b Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Wed, 19 Dec 2018 22:58:32 +0100 Subject: New upstream version 2.0.0+repack --- .../math_toolkit/next_float/float_advance.html | 72 +++++++++ .../math_toolkit/next_float/float_distance.html | 106 +++++++++++++ .../html/math_toolkit/next_float/float_next.html | 76 ++++++++++ .../html/math_toolkit/next_float/float_prior.html | 76 ++++++++++ .../html/math_toolkit/next_float/nextafter.html | 130 ++++++++++++++++ .../math/doc/html/math_toolkit/next_float/ulp.html | 164 +++++++++++++++++++++ 6 files changed, 624 insertions(+) create mode 100644 boost/libs/math/doc/html/math_toolkit/next_float/float_advance.html create mode 100644 boost/libs/math/doc/html/math_toolkit/next_float/float_distance.html create mode 100644 boost/libs/math/doc/html/math_toolkit/next_float/float_next.html create mode 100644 boost/libs/math/doc/html/math_toolkit/next_float/float_prior.html create mode 100644 boost/libs/math/doc/html/math_toolkit/next_float/nextafter.html create mode 100644 boost/libs/math/doc/html/math_toolkit/next_float/ulp.html (limited to 'boost/libs/math/doc/html/math_toolkit/next_float') diff --git a/boost/libs/math/doc/html/math_toolkit/next_float/float_advance.html b/boost/libs/math/doc/html/math_toolkit/next_float/float_advance.html new file mode 100644 index 00000000..155e22de --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/next_float/float_advance.html @@ -0,0 +1,72 @@ + + + +Advancing a floating-point Value by a Specific Representation Distance (ULP) float_advance + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Function float_advance advances + a floating-point number by a specified number of ULP. +

+
+ + Synopsis +
+
#include <boost/math/special_functions/next.hpp>
+
+
namespace boost{ namespace math{
+
+template <class FPT>
+FPT float_advance(FPT val, int distance);
+
+}} // namespaces
+
+
+ + Description + - float_advance +
+

+ Returns a floating-point number r such that float_distance(val, r) == distance. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/next_float/float_distance.html b/boost/libs/math/doc/html/math_toolkit/next_float/float_distance.html new file mode 100644 index 00000000..a9d01d45 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/next_float/float_distance.html @@ -0,0 +1,106 @@ + + + +Calculating the Representation Distance Between Two floating-point Values (ULP) float_distance + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Function float_distance finds the number of gaps/bits/ULP between any two + floating-point values. If the significands of floating-point numbers are + viewed as integers, then their difference is the number of ULP/gaps/bits + different. +

+
+ + Synopsis +
+
#include <boost/math/special_functions/next.hpp>
+
+
namespace boost{ namespace math{
+
+template <class FPT>
+FPT float_distance(FPT a, FPT b);
+
+}} // namespaces
+
+
+ + Description + - float_distance +
+

+ Returns the distance between a and b: + the result is always a signed integer value (stored in floating-point type + FPT) representing the number of distinct representations between a + and b. +

+

+ Note that +

+
    +
  • + float_distance(a, a) + always returns 0. +
  • +
  • + float_distance(float_next(a), a) + always returns -1. +
  • +
  • + float_distance(float_prior(a), a) + always returns 1. +
  • +
+

+ The function float_distance + is equivalent to calculating the number of ULP (Units in the Last Place) + between a and b except that it + returns a signed value indicating whether a + > b + or not. +

+

+ If the distance is too great then it may not be able to be represented as + an exact integer by type FPT, but in practice this is unlikely to be a issue. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/next_float/float_next.html b/boost/libs/math/doc/html/math_toolkit/next_float/float_next.html new file mode 100644 index 00000000..2bc6076c --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/next_float/float_next.html @@ -0,0 +1,76 @@ + + + +Finding the Next Greater Representable Value (float_next) + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/next.hpp>
+
+
namespace boost{ namespace math{
+
+template <class FPT>
+FPT float_next(FPT val);
+
+}} // namespaces
+
+
+ + Description + - float_next +
+

+ Returns the next representable value which is greater than x. + If x is non-finite then returns the result of a domain_error. If + there is no such value greater than x then returns an + overflow_error. +

+

+ Has the same effect as +

+
nextafter(val, (std::numeric_limits<FPT>::max)());
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/next_float/float_prior.html b/boost/libs/math/doc/html/math_toolkit/next_float/float_prior.html new file mode 100644 index 00000000..448f5773 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/next_float/float_prior.html @@ -0,0 +1,76 @@ + + + +Finding the Next Smaller Representable Value (float_prior) + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/next.hpp>
+
+
namespace boost{ namespace math{
+
+template <class FPT>
+FPT float_prior(FPT val);
+
+}} // namespaces
+
+
+ + Description + - float_prior +
+

+ Returns the next representable value which is less than x. + If x is non-finite then returns the result of a domain_error. If + there is no such value less than x then returns an + overflow_error. +

+

+ Has the same effect as +

+
nextafter(val, -(std::numeric_limits<FPT>::max)());  // Note most negative value -max.
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/next_float/nextafter.html b/boost/libs/math/doc/html/math_toolkit/next_float/nextafter.html new file mode 100644 index 00000000..96d50818 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/next_float/nextafter.html @@ -0,0 +1,130 @@ + + + +Finding the Next Representable Value in a Specific Direction (nextafter) + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/next.hpp>
+
+
namespace boost{ namespace math{
+
+template <class FPT>
+FPT nextafter(FPT val, FPT direction);
+
+}} // namespaces
+
+
+ + Description + - nextafter +
+

+ This is an implementation of the nextafter + function included in the C99 standard. (It is also effectively an implementation + of the C99 nexttoward legacy + function which differs only having a long + double direction, and can generally + serve in its place if required). +

+
+ + + + + +
[Note]Note

+ The C99 functions must use suffixes f and l to distinguish float and long + double versions. C++ uses the template + mechanism instead. +

+

+ Returns the next representable value after x in the + direction of y. If x + == y + then returns x. If x is non-finite + then returns the result of a domain_error. + If there is no such value in the direction of y then + returns an overflow_error. +

+
+ + + + + +
[Warning]Warning

+ The template parameter FTP must be a floating-point type. An integer type, + for example, will produce an unhelpful error message. +

+
+ + + + + +
[Tip]Tip

+ Nearly always, you just want the next or prior representable value, so + instead use float_next + or float_prior below. +

+
+ + Examples - + nextafter +
+

+ The two representations using a 32-bit float either side of unity are: +

+
The nearest (exact) representation of 1.F is      1.00000000
+nextafter(1.F, 999) is                            1.00000012
+nextafter(1/f, -999) is                           0.99999994
+
+The nearest (not exact) representation of 0.1F is 0.100000001
+nextafter(0.1F, 10) is                            0.100000009
+nextafter(0.1F, 10) is                            0.099999994
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/next_float/ulp.html b/boost/libs/math/doc/html/math_toolkit/next_float/ulp.html new file mode 100644 index 00000000..0f6c943c --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/next_float/ulp.html @@ -0,0 +1,164 @@ + + + +Obtaining the Size of a Unit In the Last Place - ULP + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Function ulp gives the size + of a unit-in-the-last-place for a specified floating-point value. +

+
+ + Synopsis +
+
#include <boost/math/special_functions/ulp.hpp>
+
+
namespace boost{ namespace math{
+
+template <class FPT>
+FPT ulp(const FPT& x);
+
+template <class FPT, class Policy>
+FPT ulp(const FPT& x, const Policy&);
+
+}} // namespaces
+
+
+ + Description + - ulp +
+

+ Returns one unit + in the last place of x. +

+

+ Corner cases are handled as followes: +

+
    +
  • + If the argument is a NaN, then raises a domain_error. +
  • +
  • + If the argument is an infinity, then raises an overflow_error. +
  • +
  • + If the argument is zero then returns the smallest representable value: + for example for type double + this would be either std::numeric_limits<double>::min() or std::numeric_limits<double>::denorm_min() depending whether denormals are supported + (which have the values 2.2250738585072014e-308 + and 4.9406564584124654e-324 + respectively). +
  • +
  • + If the result is too small to represent, then returns the smallest representable + value. +
  • +
  • + Always returns a positive value such that ulp(x) == ulp(-x). +
  • +
+

+ Important: The behavior of this function + is aligned to that of Java's + ulp function, please note however that this function should only + ever be used for rough and ready calculations as there are enough corner + cases to trap even careful programmers. In particular: +

+
    +
  • + The function is asymetrical, which is to say, given u + = ulp(x) if x + > 0 + then x + + u is the next floating-point + value, but x - + u is not necessarily the previous + value. Similarly, if x < 0 + then x - + u is the previous floating-point + value, but x + + u is not necessarily the next + value. The corner cases occur at power of 2 boundaries. +
  • +
  • + When the argument becomes very small, it may be that there is no floating-point + value that represents one ULP. Whether this is the case or not depends + not only on whether the hardware may sometimes support + denormals (as signalled by std::numeric_limits<FPT>::has_denorm), + but also whether these are currently enabled at runtime (for example + on SSE hardware, the DAZ or FTZ flags will disable denormal support). + In this situation, the ulp + function may return a value that is many orders of magnitude too large. +
  • +
+

+ In light of the issues above, we recomend that: +

+
    +
  • + To move between adjacent floating-point values always use float_next, + float_prior + or nextafter + (std::nextafter is another candidate, but + our experience is that this also often breaks depending which optimizations + and hardware flags are in effect). +
  • +
  • + To move several floating-point values away use float_advance. +
  • +
  • + To calculate the edit distance between two floats use Boost.Math + float_distance. +
  • +
+

+ There is none the less, one important use case for this function: +

+

+ If it is known that the true result of some function is xt and the calculated + result is xc, then the error measured in ulp is simply fabs(xt - + xc) / ulp(xt). +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + -- cgit v1.2.3