From 84a626e0000fbbb57dd06e0a9a7dc8196357e7db Mon Sep 17 00:00:00 2001 From: pabristow Date: Fri, 12 Aug 2016 16:12:46 +0100 Subject: [PATCH] Revision to Chap 3 overview section --- doc/cstdfloat/cstdfloat.qbk | 27 +++++++++---- doc/html/index.html | 2 +- doc/html/indexes/s01.html | 10 +---- doc/html/indexes/s02.html | 2 +- doc/html/indexes/s03.html | 2 +- doc/html/indexes/s04.html | 2 +- doc/html/indexes/s05.html | 17 +------- doc/html/math_toolkit/conventions.html | 2 +- doc/html/math_toolkit/float128.html | 40 +------------------ doc/html/math_toolkit/float128_hints.html | 19 +++++---- doc/html/math_toolkit/navigation.html | 2 +- doc/html/math_toolkit/rationale.html | 2 +- doc/html/math_toolkit/specified_typedefs.html | 15 +++++++ doc/math.qbk | 1 + example/cstdfloat_example.cpp | 2 +- example/float128_example.cpp | 19 +++------ 16 files changed, 65 insertions(+), 99 deletions(-) diff --git a/doc/cstdfloat/cstdfloat.qbk b/doc/cstdfloat/cstdfloat.qbk index a5e0bb2b0..0c90e6198 100644 --- a/doc/cstdfloat/cstdfloat.qbk +++ b/doc/cstdfloat/cstdfloat.qbk @@ -6,7 +6,8 @@ [import ../../example/cstdfloat_example.cpp] [import ../../example/normal_tables.cpp] -[import ../../example/quadmath_snprintf.c] +[/Removed as unhelpful for C++ users, but might have use as a check that quadmath is available and linked OK.] +[/import ../../example/quadmath_snprintf.c] [section:specified_typedefs Overview] @@ -39,6 +40,16 @@ and may not be supplied for all platforms/compilers, because compiler support for a 128-bit floating-point type is not mandated by either the C standard or the C++ standard. +If 128-bit floating-point is supported, then including `boost/cstdfloat.hpp` +provides a [*native] 128-bit type, and +includes other headers in folder `boost/math/cstdfloat` that provide C++ +quad support for __C_math in ``, ``, ``, ``, +and the available floating-point types. + +One can also, more robustly, include `boost/multiprecision/float128.hpp` +and this provides a thin wrapper selecting the appropriate 128-bit native type +from `cstdfloat` if available, or else a 128-bit multiprecision type. + See [link math_toolkit.examples.je_lambda Jahnke-Emden-Lambda function example] for an example using both a `` function and a Boost.Math function to evaluate a moderately interesting function, the @@ -83,7 +94,7 @@ naming conventions. a `typedef` if the underlying type is not provided by the compiler]. For example, if a compiler does not have an underlying floating-point type with 128 bits (highly sought-after in scientific and numeric programming), -then `float128_t` and its corresponding least and fast types are not +then `float128_t` and its corresponding least and fast types are [*not] provided by `.] [warning If `` uses a compiler-specific non-standardized type @@ -335,16 +346,17 @@ Some sample output for two different platforms is appended to the code at [section:float128_hints Hints on using float128 (and __float128)] [h5:different_float128 __float128 versus float128] -* __float128 is the compiler supplied hardware type, +* __float128 is the (optionally) compiler supplied hardware type, it's an C-ish extension to C++ and there is only minimal support for it in normal C++ (no IO streams or `numeric_limits` support, function names in libquadmath all have different names to the `std::` ones etc.) -So you can program that type directly but it's harder work. +So you can program type `__float128` directly, but it's harder work. -* Type float128 is a thin wrapper around __float128 and makes it -C++ and generic code friendly. +* Type `float128` uses __float128 and makes it C++ and generic code friendly, +with all the usual standard `iostream`, `numeric_limits`, `complex` in namspace `std::` available, +so strongly recommended for C++ use. [h5 Hints and tips] @@ -364,7 +376,8 @@ and not Boost.Math is probably less error prone than declaring your own, likewise the special functions etc. -Some examples of what can go horribly and silently wrong are at [@../../example/float128_example.cpp float128_example.cpp]. +Some examples of what can go horribly and silently wrong are at +[@../../example/float128_example.cpp float128_example.cpp]. [endsect] [/section:float128_hints Hints on using float128] diff --git a/doc/html/index.html b/doc/html/index.html index 9e4df8392..4d0f9fd10 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -116,7 +116,7 @@ This manual is also available in -

Last revised: August 09, 2016 at 14:52:49 GMT

+

Last revised: August 12, 2016 at 15:07:11 GMT


diff --git a/doc/html/indexes/s01.html b/doc/html/indexes/s01.html index e3751dd52..1f21b1ecd 100644 --- a/doc/html/indexes/s01.html +++ b/doc/html/indexes/s01.html @@ -24,7 +24,7 @@

-Function Index

+Function Index

2 4 A B C D E F G H I J K L M N O P Q R S T U V X Y Z

@@ -2255,10 +2255,6 @@

-Class Index

+Class Index

A B C D E F G H I L M N O P Q R S T U W

diff --git a/doc/html/indexes/s03.html b/doc/html/indexes/s03.html index d43ceb248..23b47e2e0 100644 --- a/doc/html/indexes/s03.html +++ b/doc/html/indexes/s03.html @@ -24,7 +24,7 @@

-Typedef Index

+Typedef Index

A B C D E F G H I L N O P R S T U V W

diff --git a/doc/html/indexes/s04.html b/doc/html/indexes/s04.html index e4b73dc6d..a2e06c79c 100644 --- a/doc/html/indexes/s04.html +++ b/doc/html/indexes/s04.html @@ -24,7 +24,7 @@

-Macro Index

+Macro Index

B F

diff --git a/doc/html/indexes/s05.html b/doc/html/indexes/s05.html index bab4247e6..1a311a981 100644 --- a/doc/html/indexes/s05.html +++ b/doc/html/indexes/s05.html @@ -23,7 +23,7 @@

-Index

+Index

2 4 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

@@ -4259,13 +4259,6 @@
  • -

    Implementation of Float128 type

    - -
  • -
  • Incomplete Beta Function Inverses

    - +

    This documentation aims to use of the following naming and formatting conventions. diff --git a/doc/html/math_toolkit/float128.html b/doc/html/math_toolkit/float128.html index a72ce789c..f3b7c33b9 100644 --- a/doc/html/math_toolkit/float128.html +++ b/doc/html/math_toolkit/float128.html @@ -87,46 +87,8 @@ C __float128 quadmath type

    - Example of using GCC Quad-Precision Math Library quadmath __float128 - type, taking a square root with sqrtq, and output using quadmath_snprintf. + [quadmath_snprintf_1]

    -

    - From GCC Quad-Precision Math Library, 3.2 - quadmath_snprintf, Convert to string (pages 9 and 10). -

    -

    - Requires GCC linker option -lquadmath. -

    -

    - If this linker option is missing then you will get errors like: -

    -
    /Cpp/float128/quadmath_snprintf/quadmath_snprintf.c:44: undefined reference to 'sqrtq'.
    -/Cpp/float128/quadmath_snprintf/quadmath_snprintf.c:45: undefined reference to 'quadmath_snprintf'.
    -
    -

    - On one system, the header file (that contains all the extern - declarations), included, for example: -

    -
    extern __float128 sqrtq (__float128) __quadmath_throw;
    -extern __float128 strtoflt128 (const char *, char **) __quadmath_throw;
    -extern int quadmath_snprintf (char *str, size_t size, const char *format, ...) __quadmath_throw;
    -
    -

    - An example of a location of quadmath.h is -

    -
    C:\program files\gcc-6-win64\lib\gcc\x86_64-w64-mingw32\6.1.1\include\quadmath.h
    -
    -

    - and library at -

    -
    C:\Program Files\gcc-6-win64\bin\libquadmath-0.dll
    -
    -

    - Command lines used (using CodeBLocks: -

    -
    gcc.exe -Wall -g  -c J:\Cpp\float128\quadmath_snprintf\main.c -o obj\Debug\main.o
    -g++.exe  -o bin\Debug\quadmath_snprintf.exe obj\Debug\main.o  -lquadmath
    -

    The source code is at quadmath_snprintf.c.

    diff --git a/doc/html/math_toolkit/float128_hints.html b/doc/html/math_toolkit/float128_hints.html index 0d91fdc84..62b52afe3 100644 --- a/doc/html/math_toolkit/float128_hints.html +++ b/doc/html/math_toolkit/float128_hints.html @@ -34,15 +34,20 @@
    • - __float128 is the compiler supplied hardware type, it's an C-ish extension - to C++ and there is only minimal support for it in normal C++ (no IO streams - or numeric_limits support, - function names in libquadmath all have different names to the std:: - ones etc.) So you can program that type directly but it's harder work. + __float128 is the (optionally) compiler supplied hardware type, it's an + C-ish extension to C++ and there is only minimal support for it in normal + C++ (no IO streams or numeric_limits + support, function names in libquadmath all have different names to the + std:: + ones etc.) So you can program type __float128 + directly, but it's harder work.
    • - Type float128 is a thin wrapper around __float128 and makes it C++ and - generic code friendly. + Type float128 uses __float128 + and makes it C++ and generic code friendly, with all the usual standard + iostream, numeric_limits, complex + in namspace std:: + available, so strongly recommended for C++ use.
    diff --git a/doc/html/math_toolkit/navigation.html b/doc/html/math_toolkit/navigation.html index c657abb69..b2ecc2c74 100644 --- a/doc/html/math_toolkit/navigation.html +++ b/doc/html/math_toolkit/navigation.html @@ -27,7 +27,7 @@ Navigation

    - +

    Boost.Math documentation is provided in both HTML and PDF formats. diff --git a/doc/html/math_toolkit/rationale.html b/doc/html/math_toolkit/rationale.html index 763d46645..7d13af7ad 100644 --- a/doc/html/math_toolkit/rationale.html +++ b/doc/html/math_toolkit/rationale.html @@ -70,7 +70,7 @@ if the underlying type is not provided by the compiler. For example, if a compiler does not have an underlying floating-point type with 128 bits (highly sought-after in scientific and numeric programming), then float128_t and its corresponding least - and fast types are not provided by <boost/cstdfloat.hpp>. + and fast types are not provided by <boost/cstdfloat.hpp>.

    diff --git a/doc/html/math_toolkit/specified_typedefs.html b/doc/html/math_toolkit/specified_typedefs.html index 0dc0c5603..c92fe11dc 100644 --- a/doc/html/math_toolkit/specified_typedefs.html +++ b/doc/html/math_toolkit/specified_typedefs.html @@ -65,6 +65,21 @@ all platforms/compilers, because compiler support for a 128-bit floating-point type is not mandated by either the C standard or the C++ standard.

    +

    + If 128-bit floating-point is supported, then including boost/cstdfloat.hpp provides + a native 128-bit type, and includes other + headers in folder boost/math/cstdfloat + that provide C++ quad support for C + math functions in <cmath>, + <limits>, types, <iostream>, + <complex> and the available floating-point types. +

    +

    + One can also, more robustly, include boost/multiprecision/float128.hpp and + this provides a thin wrapper selecting the appropriate 128-bit native type + from cstdfloat if available, + or else a 128-bit multiprecision type. +

    See Jahnke-Emden-Lambda function example for an example using both a <cmath> diff --git a/doc/math.qbk b/doc/math.qbk index 240496030..445ff9d3b 100644 --- a/doc/math.qbk +++ b/doc/math.qbk @@ -428,6 +428,7 @@ and use the function's name as the link text.] [def __random_variate [@http://en.wikipedia.org/wiki/Random_variate random variate]] [def __random_variable [@http://en.wikipedia.org/wiki/Random_variable random variable]] [def __probability_distribution [@http://en.wikipedia.org/wiki/Probability_distribution probability_distribution]] +[def __C_math [@http://www.cplusplus.com/reference/cmath/ C math functions]] [/ Some composite templates] [template super[x]''''''[x]''''''] diff --git a/example/cstdfloat_example.cpp b/example/cstdfloat_example.cpp index 119532a08..761e811b1 100644 --- a/example/cstdfloat_example.cpp +++ b/example/cstdfloat_example.cpp @@ -20,7 +20,7 @@ The Jahnke-Emden lambda function is described at Weisstein, Eric W. "Lambda Function." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/LambdaFunction.html -E. Jahnke and F. Emde, "Tables of Functions with Formulae and Curves," +E. Jahnke and F. Emden, "Tables of Functions with Formulae and Curves," Dover, New York, 4th ed., (1945), pages 180-188. */ diff --git a/example/float128_example.cpp b/example/float128_example.cpp index 418abf07b..23e01666a 100644 --- a/example/float128_example.cpp +++ b/example/float128_example.cpp @@ -36,7 +36,7 @@ /*`To make float128 available it is vital to get the dialect and options on the command line correct. Quad type is forbidden by all the strict C++ standards, so using or adding -std=c++11 and later standards will prevent its use. -so explicitly use -std=gnu++11, 1y, 14, , 1z or 17 ... +so explicitly use -std=gnu++11, 1y, 14, 17, or 1z or ... For GCC 6.1.1, for example, the default is if no C++ language dialect options are given, is -std=gnu++14. @@ -56,6 +56,7 @@ If this is missing, then get errors like: Requires compile option -fext-numeric-literals + If missing, then get errors like: \modular-boost\libs\math\include/boost/math/cstdfloat/cstdfloat_types.hpp:229:43: error: unable to find numeric literal operator 'operator""Q' @@ -162,24 +163,16 @@ int main() // But sadly functions like sqrt are not yet available constexpr for float128. - //constexpr float128 root_pi_constexpr = sqrt(pi_constexpr); // Fails - not constexpr (yet). - //constexpr float128 root_pi_constexpr = std::sqrt(pi_constexpr); // Fails - no know conversion for argument 1 from 'const float128'. + // constexpr float128 root_pi_constexpr = sqrt(pi_constexpr); // Fails - not constexpr (yet). + // constexpr float128 root_pi_constexpr = std::sqrt(pi_constexpr); // Fails - no known conversion for argument 1 from 'const float128'. // constexpr float128 root_pi_constexpr = sqrt(pi_constexpr); // Call to non-constexpr - //constexpr float128 root_pi_constexpr = boost::math::constants::root_pi(); // Missing type for constant. + // constexpr float128 root_pi_constexpr = boost::math::constants::root_pi(); // Missing type for constant. // Best current way to get a constexpr is to use a Boost.Math constant if one is available. constexpr float128 root_pi_constexpr = boost::math::constants::root_pi(); std::cout << root_pi_constexpr << std::endl; // 1.77245385090551602729816748334114514 - /* - inline _GLIBCXX_CONSTEXPR long double - sqrt(long double __x) - { return __builtin_sqrtl(__x); } - - Need a float128 version of __builtin_sqrt_128. - */ - - // Note that casts within the sqrt call are NOT NEEDED (nor allowed) + // Note that casts within the sqrt call are NOT NEEDED (nor allowed), // since all the variables are the correct type to begin with. // std::cout << sqrt(pi3) << std::endl; // But note examples of catastrophic (but hard to see) loss of precision below.