diff --git a/config/Jamfile.v2 b/config/Jamfile.v2 index 546b07be8..8773e6e1d 100644 --- a/config/Jamfile.v2 +++ b/config/Jamfile.v2 @@ -8,6 +8,7 @@ import path ; local ntl-path = [ modules.peek : NTL_PATH ] ; local gmp_path = [ modules.peek : GMP_PATH ] ; +local e_float_path = [ modules.peek : E_FLOAT_PATH ] ; obj has_long_double_support : has_long_double_support.cpp ; obj has_mpfr_class : has_mpfr_class.cpp : @@ -19,6 +20,7 @@ obj has_gmpxx : has_gmpxx.cpp : $(gmp_path) $(gmp_path)/mpfr $(gmp_path)/gmpfrxx ; obj has_gcc_visibility : has_gcc_visibility.cpp : gcc:-fvisibility=hidden gcc:-Werror ; +obj has_e_float : has_e_float.cpp : $(e_float_path) ; explicit has_long_double_support ; explicit has_mpfr_class ; @@ -26,4 +28,4 @@ explicit has_mpreal ; explicit has_ntl_rr ; explicit has_gmpxx ; explicit has_gcc_visibility ; - +explicit has_e_float ; diff --git a/config/has_e_float.cpp b/config/has_e_float.cpp new file mode 100644 index 000000000..1f3b30539 --- /dev/null +++ b/config/has_e_float.cpp @@ -0,0 +1,15 @@ +// Copyright John Maddock 2011. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#ifdef _MSC_VER +# pragma warning (disable : 4100) // unreferenced formal parameter +#endif + +#define E_FLOAT_TYPE_EFX + +#include +#include + diff --git a/doc/html/index.html b/doc/html/index.html index de760e113..88eacc674 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -55,7 +55,7 @@ Hubert Holin, Daryle Walker, Xiaogang Zhang, Bruno Lalande, Johan Råde, Gautam Sewani and Thijs van den Berg

-

+

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

@@ -461,7 +461,7 @@
- +

Last revised: September 01, 2010 at 19:10:43 +0100

Last revised: January 01, 2011 at 17:16:10 +0000


diff --git a/doc/sf_and_dist/Jamfile.v2 b/doc/sf_and_dist/Jamfile.v2 index 3e168fc16..881b4e692 100644 --- a/doc/sf_and_dist/Jamfile.v2 +++ b/doc/sf_and_dist/Jamfile.v2 @@ -19,6 +19,7 @@ if --enable-index in [ modules.peek : ARGV ] html:on $(here)/index.idx $(here)/../../../.. + on enable_index pdf:index.on.type=1 ; } @@ -92,3 +93,4 @@ install pdf-install : standalone : . PDF math.pdf + diff --git a/doc/sf_and_dist/concepts.qbk b/doc/sf_and_dist/concepts.qbk index a1d491337..e0cceeaa3 100644 --- a/doc/sf_and_dist/concepts.qbk +++ b/doc/sf_and_dist/concepts.qbk @@ -84,6 +84,21 @@ There is a concept checking test program for mpfr support [endsect][/section:use_mpfr Using With MPFR / GMP - a High-Precision Floating-Point Library] +[section:e_float e_float Support] + +This library can be used with [@http://calgo.acm.org/910.zip e_float (TOMS Algorithm 910)] via the header: + + + +And the type `boost::math::ef::e_float`: this type is a thin wrapper class around ::e_float which provides the necessary +syntactic sugar to make everything "just work". + +There is also a concept checking test program for e_float support +[@../../../../../libs/math/test/e_float_concept_check.cpp here]. + + +[endsect] + [section:concepts Conceptual Requirements for Real Number Types] The functions, and statistical distributions in this library can be used with diff --git a/doc/sf_and_dist/credits.qbk b/doc/sf_and_dist/credits.qbk index 6398b5942..8e4b753fa 100644 --- a/doc/sf_and_dist/credits.qbk +++ b/doc/sf_and_dist/credits.qbk @@ -22,8 +22,20 @@ Google Summer of Code project 2006. Bruno Lalande submitted the "compile time power of a runtime base" code. -Johan R'''å'''de wrote the optimised floating point classification -code. +Johan R'''å'''de wrote the optimised floating-point classification +and manipulation code, and nonfinite facets to permit C99 output of infinities and NaNs. +(nonfinite facets were not added until Boost 1.47 but had been in use with Boost.Spirit). +This library was based on a suggestion from Robert Ramey, author of Boost.Serialization. +Paul A. Bristow expressed the need for better handling of +[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2022.pdf +Input & Output of NaN and infinity for the C++ Standard Library] +and suggested following the C99 format. + +H'''å'''kan Ard'''ö''', +Boris Gubenko, John Maddock, +Markus Sch'''ö'''pflin +and Olivier Verdier tested the floating-point library and +Martin Bonner, Peter Dimov and John Maddock provided valuable advice. Gautam Sewani coded the logistic distribution as part of a Google Summer of Code project 2008. diff --git a/doc/sf_and_dist/distributions/geometric_example.qbk b/doc/sf_and_dist/distributions/geometric_example.qbk index 1db1b0954..c529c1490 100644 --- a/doc/sf_and_dist/distributions/geometric_example.qbk +++ b/doc/sf_and_dist/distributions/geometric_example.qbk @@ -1,11 +1,11 @@ [section:geometric_eg Geometric Distribution Examples] -[import \..\..\..\example\geometric_examples.cpp] +[import ../../../example/geometric_examples.cpp] [geometric_eg1_1] [geometric_eg1_2] See full source C++ of this example at -[@\..\..\..\example\geometric_examples.cpp geometric_examples.cpp] +[@../../../example/geometric_examples.cpp geometric_examples.cpp] [link math_toolkit.dist.stat_tut.weg.neg_binom_eg.neg_binom_conf See negative_binomial confidence interval example.] diff --git a/doc/sf_and_dist/faq.qbk b/doc/sf_and_dist/faq.qbk index 172a2a0b6..58d30686f 100644 --- a/doc/sf_and_dist/faq.qbk +++ b/doc/sf_and_dist/faq.qbk @@ -76,6 +76,8 @@ Probably, thought not always, and not by too much: our priority is accuracy. For most functions, making sure you have the latest compiler version with all optimisations switched on is the key to speed. For evaluations that require iteration, you may be able to gain a little more speed at the expense of accuracy. See detailed suggestions and results on __performance. +# ['How do I handle infinity and NaNs portably?] [br] +See __fp_facets for Facets for Floating-Point Infinities and NaNs. # ['Where are the pre-built libraries?] [br] Good news - you probably don't need any! - just #include . But in the unlikely event that you do, see __building. diff --git a/doc/sf_and_dist/float_next.qbk b/doc/sf_and_dist/float_next.qbk index fa8309c1f..5c3d16db0 100644 --- a/doc/sf_and_dist/float_next.qbk +++ b/doc/sf_and_dist/float_next.qbk @@ -5,7 +5,9 @@ is the gap between two different, but as close as possible, floating-point numbers. Most decimal values, for example 0.1, cannot be exactly represented as floating-point values, -but will be stored as the closest representable floating-point. +but will be stored as the +[@http://en.wikipedia.org/wiki/Floating_point#Representable_numbers.2C_conversion_and_rounding +closest representable floating-point]. Functions are provided for finding adjacent greater and lesser floating-point values, and estimating the number of gaps between any two floating-point values. diff --git a/doc/sf_and_dist/fp_facets.qbk b/doc/sf_and_dist/fp_facets.qbk new file mode 100644 index 000000000..9792c943b --- /dev/null +++ b/doc/sf_and_dist/fp_facets.qbk @@ -0,0 +1,539 @@ +[section:fp_facets Facets for Floating-Point Infinities and NaNs] + +[import ../../example/nonfinite_facet_sstream.cpp] + +[h4 Synopsis] + + namespace boost{ namespace math + { + // Values for flags. + const int legacy; + const int signed_zero; + const int trap_infinity; + const int trap_nan; + + template< + class CharType, + class OutputIterator = std::ostreambuf_iterator + > + class nonfinite_num_put : public std::num_put + { + public: + explicit nonfinite_num_put(int flags = 0); + }; + + template< + class CharType, + class InputIterator = std::istreambuf_iterator + > + class nonfinite_num_get : public std::num_get + { + public: + explicit nonfinite_num_get(int flags = 0); // legacy, sign_zero ... + }; + }} // namespace boost namespace math + +To use these facets + + #include + + +[section:intro Introduction] + +[h5 The Problem] + +The C++98 standard does not specify how ['infinity] and ['NaN] are represented in text streams. +As a result, different platforms use different string representations. +This can cause undefined behavior when text files are moved between different platforms. +Some platforms cannot even input parse their own output! +So 'route-tripping' or loopback of output to input is not possible. +For instance, the following test fails with MSVC: + + stringstream ss; + double inf = numeric_limits::infinity(); + double r; + ss << inf; // Write out. + ss >> r; // Read back in. + + cout << "infinity output was " << inf << endl; // 1.#INF + cout << "infinity input was " << r << endl; // 1 + + assert(inf == y); // Fails! + +[h5 The Solution] + +The facets `nonfinite_num_put` and `nonfinite_num_get` +format and parse all floating-point numbers, +including `infinity` and `NaN`, in a consistent and portable manner. + +The following test succeeds with MSVC. + +[nonfinite_facets_sstream_1] + +[tip To add two facets, `nonfinite_num_put` and `nonfinite_num_get`, +you may have to add one at a time, using a temporary locale. + +Or you can create a new locale in one step + +`std::locale new_locale(std::locale(std::locale(std::locale(), new boost::math::nonfinite_num_put), new boost::math::nonfinite_num_get));` + +and, for example, use it to imbue an input and output stringstream. +] + +[nonfinite_facets_sstream_2] + +[h4 C++0X standard for output of infinity and NaN] + +[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf C++0X (final) draft standard] +does not explicitly specify the representation (and input) of nonfinite values, +leaving it implementation-defined. +So without some specific action, input and output of nonfinite values is not portable. + +[h4 C99 standard for output of infinity and NaN] + +The [@http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf C99 standard] +[*does] specify how infinity and NaN +are formatted by printf and similar output functions, +and parsed by scanf and similar input functions. + +The following string representations are used: + +[table C99 Representation of Infinity and NaN +[[number] [string]] +[[Positive infinity]["inf" or "infinity"]] +[[Positive NaN]["nan" or "nan(...)"]] +[[Negative infinity]["-inf" or "-infinity"]] +[[Negative NaN]["-nan" or "-nan(...)"]] +] + +So following C99 provides a sensible 'standard' way +of handling input and output of nonfinites in C++, +and this implementation follows most of these formats. + +[h5 Signaling NaNs] +A particular type of NaN is the signaling NaN. +The usual mechanism of signaling is by raising a floating-point exception. +Signaling NaNs are defined by +[@http://en.wikipedia.org/wiki/IEEE_floating-point_standard IEEE 754-2008]. + +Floating-point values with layout ['s]111 1111 1['a]xx xxxx xxxx xxxx xxxx xxxx +where ['s] is the sign, ['x] is the payload, and bit ['a] determines the type of NaN. + +If bit ['a] = 1, it is a quiet NaN. + +If bit ['a] is zero and the payload ['x] is nonzero, then it is a signaling NaN. + +Although there has been theoretical interest in the ability of a signaling NaN +to raise an exception, for example to prevent use of an uninitialised variable, +in practice there appears to be no useful application of signaling NaNs for +most current processors. +[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf C++0X 18.3.2.2] +still specifies a (implementation-defined) representation for signaling NaN, +and `static constexpr bool has_signaling_NaN` +a method of checking if a floating-point type has a representation for signaling NaN. + +But in practice, most platforms treat signaling NaNs in the same as quiet NaNs. +So, for example, they are represented by "nan" on output in +[@http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf C99] format, +and output as `1.#QNAN` by Microsoft compilers. + +[note The C99 standard does not distinguish +between the quiet NaN and signaling NaN values. +A quiet NaN propagates through almost every arithmetic operation +without raising a floating-point exception; +a signaling NaN generally raises a floating-point exception +when occurring as an arithmetic operand. + +C99 specification does not define the behavior of signaling NaNs. +NaNs created by IEC 60559 operations are always quiet. +Therefore this implementation follows C99, and treats the signaling NaN bit +as just a part of the NaN payload field. +So this implementation does not distinguish between the two classes of NaN.] + +[note An implementation may give zero and non-numeric values (such as infinities and NaNs) +a sign or may leave them unsigned. Wherever such values are unsigned, +any requirement in the C99 Standard to retrieve the sign shall produce an unspecified sign, +and any requirement to set the sign shall be ignored. + +This might apply to user-defined types, but in practice built-in floating-point +types `float`, `double` and `long double` have well-behaved signs.] + +The numbers can be of type `float`, `double` and `long double`. +An optional + sign can be used with positive numbers (controlled by ios manipulator `showpos`). +The function `printf` and similar C++ functions use standard formatting flags +to put all lower or all upper case +(controlled by `std::ios` manipulator `uppercase` and `lowercase`). + +The function `scanf` and similar input functions are case-insensitive. + +The dots in `nan(...)` stand for an arbitrary string. +The meaning of that string is implementation dependent. +It can be used to convey extra information about the NaN, from the 'payload'. +A particular value of the payload might be used to indicate a ['missing value], for example. + +This library uses the string representations specified by the C99 standard. + +An example of an implementation that optionally includes the NaN payload information is at +[@http://publib.boulder.ibm.com/infocenter/zos/v1r10/index.jsp?topic=/com.ibm.zos.r10.bpxbd00/fprints.htm AIX NaN fprintf]. +That implementation specifies for Binary Floating Point NANs: + +* A NaN ordinal sequence is a left-parenthesis character '(', +followed by a digit sequence representing +an integer n, where 1 <= n <= INT_MAX-1, +followed by a right-parenthesis character ')'. + +* The integer value, n, is determined by the fraction bits of the NaN argument value as follows: + +* For a signalling NaN value, NaN fraction bits are reversed (left to right) +to produce bits (right to left) of an even integer value, 2*n. +Then formatted output functions produce a (signalling) NaN ordinal sequence +corresponding to the integer value n. + +* For a quiet NaN value, NaN fraction bits are reversed (left to right) +to produce bits (right to left) of an odd integer value, 2*n-1. +Then formatted output functions produce a (quiet) NaN ordinal sequence +corresponding to the integer value n. + +[warning This implementation does not (yet) provide output of, or access to, the NaN payload.] + +[endsect] [/section:intro Introduction] + +[section:reference Reference] + +[h5 The Facet `nonfinite_num_put`] + + template< + class CharType, class OutputIterator = std::ostreambuf_iterator + > + class nonfinite_num_put; + +The `class nonfinite_num_put` +is derived from `std::num_put`. +Thus it is a facet that formats numbers. +The first template argument is the character type of the formatted strings, +usually `char` or `wchar_t`. +The second template argument is the type of iterator used to write the strings. +It is required to be an output iterator. +Usually the default `std::ostreambuf_iterator` is used. +The public interface of the class consists of a single constructor only: + + nonfinite_num_put(int flags = 0); + +The flags argument (effectively optional because a default of ` no_flags` is provided) +is discussed below. +The class template `nonfinite_num_put` is defined in the +header `boost/math/nonfinite_num_facets.hpp` +and lives in the namespace `boost::math`. + +Unlike the C++ Standard facet `std::num_put`, the facet `nonfinite_num_put` +formats `infinity` and `NaN` in a consistent and portable manner. +It uses the following string representations: + +[table +[[Number][String]] +[[Positive infinity][inf]] +[[Positive NaN][nan]] +[[Negative infinity][-inf]] +[[Negative NaN][-nan]] +] + +The numbers can be of type `float`, `double` and `long double`. +The strings can be in all lower case or all upper case. +An optional + sign can be used with positive numbers. +This can be controlled with the `uppercase`, `lowercase`, `showpos` and `noshowpos` manipulators. +Formatting of integers, boolean values and finite floating-point numbers is simply delegated to the normal `std::num_put`. + + +[h5 Facet `nonfinite_num_get`] + + template > class nonfinite_num_get; + +The class `nonfinite_num_get` is derived from `std::num_get`. +Thus it is a facet that parses strings that represent numbers. +The first template argument is the character type of the strings, +usually `char` or `wchar_t`. +The second template argument is the type of iterator used to read the strings. +It is required to be an input iterator. Usually the default is used. +The public interface of the class consists of a single constructor only: + + nonfinite_num_get(int flags = 0); + +The flags argument is discussed below. +The `class template nonfinite_num_get` is defined +in the header `boost/math/nonfinite_num_facets.hpp` +and lives in the `namespace boost::math`. + +Unlike the facet `std::num_get`, the facet `nonfinite_num_get` parses strings +that represent `infinity` and `NaN` in a consistent and portable manner. +It recognizes precisely the string representations specified by the C99 standard: + +[table +[[Number][String]] +[[Positive infinity][inf, infinity]] +[[Positive NaN][nan, nan(...)]] +[[Negative infinity][-inf, -infinity]] +[[Negative NaN][-nan, -nan(...)]] +] + +The numbers can be of type `float`, `double` and `long double`. +The facet is case-insensitive. An optional + sign can be used with positive numbers. +The dots in nan(...) stand for an arbitrary string usually containing the ['NaN payload]. +Parsing of strings that represent integers, boolean values +and finite floating-point numbers is delegated to `std::num_get`. + +When the facet parses a string that represents `infinity` on a platform that lacks infinity, +then the fail bit of the stream is set. + +When the facet parses a string that represents `NaN` on a platform that lacks NaN, +then the fail bit of the stream is set. + +[h4 Flags] + +The constructors for `nonfinite_num_put` and `nonfinite_num_get` +take an optional bit flags argument. +There are four different bit flags: + +* legacy +* signed_zero +* trap_infinity +* trap_nan + +The flags can be combined with the OR `operator|`. + +The flags are defined in the header `boost/math/nonfinite_num_facets.hpp` +and live in the `namespace boost::math`. + +[h5 legacy] + +The legacy flag has no effect with the output facet `nonfinite_num_put`. + +If the legacy flag is used with the `nonfinite_num_get` input facet, +then the facet will recognize all the following string representations of `infinity` and `NaN`: + +[table +[[Number][String]] +[[Positive infinity][inf, infinity, one#inf]] +[[Positive NaN][nan, nan(...), nanq, nans, qnan, snan, one#ind, one#qnan, one#snan]] +[[Negative infinity][-inf, -infinity, -one#inf]] +[[Negative NaN][-nan, -nan(...), -nanq, -nans, -qnan, -snan, -one#ind, - one#qnan, -one#snan]] +] + +* The numbers can be of type `float`, `double` and `long double`. +* The facet is case-insensitive. +* An optional `+` sign can be used with the positive values. +* The dots in `nan(...)` stand for an arbitrary string. +* `one` stands for any string that `std::num_get` parses as the number `1`, +typically "1.#INF", "1.QNAN" but also "000001.#INF"... + +The list includes a number of non-standard string representations of infinity and NaN +that are used by various existing implementations of the C++ standard library, +and also string representations used by other programming languages. + +[h5 signed_zero] + +If the `signed_zero` flag is used with `nonfinite_num_put`, +then the facet will distinguish between positive and negative zero. +It will format positive zero as "0" or "+0" and negative zero as "-0". +The string representation of positive zero can be controlled +with the `showpos` and `noshowpos` manipulators. + +The `signed_zero flag` has no effect with the input facet `nonfinite_num_get`. +The input facet `nonfinite_num_get` always parses "0" and "+0" +as positive zero and "-0" as negative zero, +as do most implementations of `std::num_get`. + +[h5 trap_infinity] + +If the `trap_infinity` flag is used with `nonfinite_num_put`, +then the facet will throw an exception of type `std::ios_base::failure` +when an attempt is made to format positive or negative infinity. +If the facet is called from a stream insertion operator, +then the stream will catch that exception and set either its `fail bit` or its `bad bit`. +Which bit is set is platform dependent. + +If the `trap_infinity` flag is used with `nonfinite_num_get`, +then the facet will set the `fail bit` of the stream when an attempt is made +to parse a string that represents positive or negative infinity. + +(See Design Rationale below for a discussion of this inconsistency.) + +[h5 trap_nan] + +Same as `trap_infinity`, but positive and negative NaN are trapped instead. + +[endsect] [/section:reference Reference] + + +[section:examples Examples] + +[h5 Simple example with std::stringstreams] + +[nonfinite_facets_sstream_1] +[nonfinite_facets_sstream_2] + +[h5 Use with lexical_cast] + +Without using a new locale that contains the nonfinite facets, `lexical_cast` is not portable +(and often fails) if nonfinite values are found. + +[nonfinite_facets_sstream_1] + +Although other examples imbue individual streams with the new locale, +for the streams constructed inside lexical_cast, +it is necesary to assign to a global locale. + + locale::global(new_locale); + +`lexical_cast` then works as expected, even with infinity and NaNs. + + double x = boost::lexical_cast("inf"); + assert(x == std::numeric:limits::infinity()); + + string s = boost::lexical_cast(numeric_limits::infinity()); + assert(s == "inf"); + +[warning You should be aware that the C++ specification does not explicitly require +that input from decimal digits strings converts with rounding to the +nearest representable floating-point binary value. +(In contrast, decimal digits read by the compiler, +for example by an assignment like `double d = 1.234567890123456789`, +are guaranteed to assign the nearest representable value to double d). +This implies that, no matter how many decimal digits you provide, +there is a potential uncertainty of 1 least significant bit in the resulting binary value.] + +See [@http://en.wikipedia.org/wiki/Floating_point#Representable_numbers.2C_conversion_and_rounding +for more information on ['nearest representable] and ['rounding]]. + +Most iostream libraries do in fact achieve the desirable +['nearest representable floating-point binary value] for all values of input. +However one popular STL library does not quite achieve this for 64-bit doubles. See +[@http://connect.microsoft.com/VisualStudio/feedback/details/98770/decimal-digit-string-input-to-double-may-be-1-bit-wrong +Decimal digit string input to double may be 1 bit wrong] for the bizarre full details. + +If you are expecting to 'round-trip' `lexical_cast` or `serialization`, +for example archiving and loading, +and want to be [*absolutely certain that you will +always get an exactly identical double value binary pattern], +you should use the suggested 'workaround' below that is believed to work on all platforms. + +You should output using all potentially significant decimal digits, +by setting stream precision to `std::numeric_limits::max_digits10`, +(or for the appropriate floating-point type, if not double) +and crucially, [*require `scientific` format], not `fixed` or automatic (default), for example: + + double output_value = any value; + std::stringstream s; + s << setprecison(std::numeric_limits::max_digits10) << scientific << output_value; + s >> input_value; + + +[h4 Use with serialization archives] + +It is vital that the same locale is used +when an archive is saved and when it is loaded. +Otherwise, loading the archive may fail. +By default, archives are saved and loaded with a classic C locale +with a `boost::archive::codecvt_null` facet added. +Normally you do not have to worry about that. + +The constructors for the archive classes, as a side-effect, +imbue the stream with such a locale. +However, if you want to use the +facets `nonfinite_num_put` and `nonfinite_num_get` with archives, +then you have to manage the locale manually. +That is done by calling the archive constructor with the flag +`boost::archive::no_codecvt`, thereby ensuring that the archive constructor +will [*not imbue the stream with a new locale]. + +The following code shows how to use `nonfinite_num_put` with a `text_oarchive`. + + locale default_locale(locale::classic(), new boost::archive::codecvt_null); + locale my_locale(default_locale, new nonfinite_num_put); + + ofstream ofs("test.txt"); + ofs.imbue(my_locale); + + boost::archive::text_oarchive oa(ofs, no_codecvt); + + double x = numeric_limits::infinity(); + oa & x; + +The same method works with `nonfinite_num_get` and `text_iarchive`. + +If you use the `nonfinite_num_put` with `trap_infinity` +and/or `trap_nan` flag with a serialization archive, +then you must set the exception mask of the stream. +Serialization archives do not check the stream state. + + +[h5 Other examples] + +[@../../../example/nonfinite_facet_simple.cpp nonfinite_facet_simple.cpp] +give some more simple demonstrations of the difference between using classic C locale +and constructing a C99 infinty and NaN compliant locale for input and output. + +See [@../../../example/nonfinite_facet_sstream.cpp nonfinite_facet_sstream.cpp] +for this example of use with `std::stringstream`s. + +For an example of how to enforce the MSVC 'legacy' +"1.#INF" and "1.#QNAN" representations of infinity and NaNs, +for input and output, +see [@../../../example/nonfinite_legacy.cpp nonfinite_legacy.cpp]. + +Treatment of signaling NaN is demonstrated at +[@../../../example/nonfinite_signaling_NaN.cpp] + +Example [@../../../example/nonfinite_loopback_ok.cpp] shows loopback works OK. + +Example [@../../../example/nonfinite_num_facet.cpp] shows output and re-input +of various finite and nonfinite values. + +A very basic example of using Boost.Archive is at +[@../../../example/nonfinite_serialization_archives.cpp]. + +A full demonstration of serialization by Francois Mauger is at +[@../../../example/nonfinite_num_facet_serialization.cpp] + +[endsect] [/section:examples Examples] + +[section:portability Portability] + +This library uses the floating-point number classification and sign-bit from Boost.Math library, +and should work on all platforms where that library works. +See the portability information for that library. + +[endsect] [/section:portability Portability] + +[section:rationale Design Rationale] + +* The flags are implemented as a const data member of the facet. +Facets are reference counted, and locales can share facets. +Therefore changing the flags of a facet would have effects that are hard to predict. +An alternative design would be to implement the flags +using `std::ios_base::xalloc` and `std::ios_base::iword`. +Then one could safely modify the flags, and one could define manipulators that do so. +However, for that to work with dynamically linked libraries, +a `.cpp` file would have to be added to the library. +It was judged be more desirable to have a headers only library, +than to have mutable flags and manipulators. + +* The facet `nonfinite_num_put` throws an exception when +the `trap_infinity` or `trap_nan` flag is set +and an attempt is made to format infinity or NaN. +It would be better if the facet set the fail bit of the stream. +However, facets derived from `std::num_put` do not have access to the stream state. + +[endsect] [/section:rationale Design Rationale] + +[endsect] [/section:fp_facets Facets for Floating-Point Infinities and NaNs] + +[/ + Copyright Johan Rade and Paul A. Bristow 2011. + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +] + + + + diff --git a/doc/sf_and_dist/fpclassify.qbk b/doc/sf_and_dist/fpclassify.qbk index a21a5a50c..ab7f7f4b9 100644 --- a/doc/sf_and_dist/fpclassify.qbk +++ b/doc/sf_and_dist/fpclassify.qbk @@ -1,4 +1,4 @@ -[section:fpclass Floating-Point Classification: Infinities and NaN's] +[section:fpclass Floating-Point Classification: Infinities and NaNs] [h4 Synopsis] @@ -34,9 +34,10 @@ name in C99, indeed if the C99 macros are available, then these functions are implemented in terms of them, otherwise they rely on std::numeric_limits<> to function. -Note that the definition of these functions ['does not suppress the definition -of these names as macros by math.h] on those platforms that already provide -these as macros. That mean that the following have differing meanings: +Note that the definition of these functions +['does not suppress the definition of these names as macros by math.h] +on those platforms that already provide +these as macros. That mean that the following have differing meanings: using namespace boost::math; @@ -102,10 +103,21 @@ Returns true only if /z/ is a [@http://en.wikipedia.org/wiki/NaN NaN]. Returns true only if /z/ is a normal number (not zero, infinite, NaN, or denormalised). -[endsect] [/section:fpclass Floating Point Classification: Infinities and NaN's] +[h5 Floating-point format] + +If you wish to find details of the floating-point format for any particular processor, +there is a program + +[@../../../example/inspect_fp.cpp inspect_fp.cpp] + +by Johan Rade which can be used to print out the processor type, +endianness, and detailed bit layout of a selection of floating-point values, +including infinity and NaNs. + +[endsect] [/section:fpclass Floating Point Classification: Infinities and NaNs] [/ - Copyright 2006, 2008 John Maddock and Paul A. Bristow. + Copyright 2006, 2008, 2011 John Maddock, Johan Rade and Paul A. Bristow. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). diff --git a/doc/sf_and_dist/html/index.html b/doc/sf_and_dist/html/index.html index b29b14609..92217d718 100644 --- a/doc/sf_and_dist/html/index.html +++ b/doc/sf_and_dist/html/index.html @@ -53,7 +53,7 @@ Hubert Holin, Xiaogang Zhang, Bruno Lalande, Johan Råde, Gautam Sewani and Thijs van den Berg

- +

Last revised: March 06, 2011 at 16:46:12 GMT

Last revised: May 16, 2011 at 16:53:57 GMT


diff --git a/doc/sf_and_dist/html/index/s12.html b/doc/sf_and_dist/html/index/s12.html index 2f814ce6a..055f2c909 100644 --- a/doc/sf_and_dist/html/index/s12.html +++ b/doc/sf_and_dist/html/index/s12.html @@ -24,13 +24,19 @@

-Function Index

-

A B C D E F G H I K L M N P Q R S T U V Z

+Function Index
+

A B C E F H I L N R S T

A
+
accuracy
+
+ + + +

Additional Implementation Notes

Frequently Asked Questions FAQ

log1p

acosh
@@ -38,6 +44,18 @@

acosh

C99 and TR1 C Functions Overview

C99 C Functions

+
acoshf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
acoshl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

asinh
@@ -45,6 +63,54 @@

asinh

C99 and TR1 C Functions Overview

C99 C Functions

+
asinhf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
asinhl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
assoc_laguerre
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
assoc_laguerref
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
assoc_laguerrel
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
assoc_legendre
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
assoc_legendref
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
assoc_legendrel
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

atanh
@@ -52,6 +118,18 @@

atanh

C99 and TR1 C Functions Overview

C99 C Functions

+
atanhf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
atanhl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

B @@ -60,25 +138,27 @@
beta
+ + + +

Beta

Beta Distribution

Binomial Coefficients

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Incomplete Beta Functions

Noncentral Beta Distribution

The Incomplete Beta Function Inverses

TR1 C Functions Quick Reference

-
betac
-

Incomplete Beta Functions

betaf

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
binomial_coefficient
-

Binomial Coefficients

-
BOOST_MATH_INSTRUMENT_CODE
-

Configuration Macros

-
BOOST_MATH_INSTRUMENT_VARIABLE
-

Configuration Macros

+
betal
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

C @@ -92,55 +172,75 @@

cbrt

Root Finding With Derivatives: Newton-Raphson, Halley & Schroeder

-
cdf
+
cbrtf
- - + + +

Extras/Future Directions

Non-Member Properties

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
checked_narrowing_cast
-

Error Handling

-
chf
-

Non-Member Properties

-
comp_ellint_2
+
cbrtl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
changesign
+

Sign Manipulation Functions

+
comp_ellint_1

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_2f
+
comp_ellint_1f

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_2l
+
comp_ellint_1l

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_3
+
conf_hyperg

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_3f
+
conf_hypergf

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_3l
+
conf_hypergl

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
continued_fraction_a
-

Continued Fraction Evaluation

-
continued_fraction_b
-

Continued Fraction Evaluation

+
copysign
+
+ + + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Sign Manipulation Functions

+
copysignf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
copysignl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

cyl_bessel_i
@@ -148,6 +248,18 @@

C99 and C++ TR1 C-style Functions

Modified Bessel Functions of the First and Second Kinds

TR1 C Functions Quick Reference

+
cyl_bessel_if
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
cyl_bessel_il
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

cyl_bessel_j
@@ -155,6 +267,18 @@

Bessel Functions of the First and Second Kinds

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
cyl_bessel_jf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
cyl_bessel_jl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

cyl_bessel_k
@@ -162,6 +286,18 @@

C99 and C++ TR1 C-style Functions

Modified Bessel Functions of the First and Second Kinds

TR1 C Functions Quick Reference

+
cyl_bessel_kf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
cyl_bessel_kl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

cyl_neumann
@@ -169,22 +305,23 @@

Bessel Functions of the First and Second Kinds

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
cyl_neumannf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
cyl_neumannl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-D +E
-
digamma
-

Digamma

-
double_factorial
-

Double Factorial

-
-
-E -
-
-
e
-

Numeric Constants

ellint_1
@@ -192,6 +329,18 @@

C99 and C++ TR1 C-style Functions

Elliptic Integrals of the First Kind - Legendre Form

TR1 C Functions Quick Reference

+
ellint_1f
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
ellint_1l
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

ellint_2
@@ -199,6 +348,18 @@

C99 and C++ TR1 C-style Functions

Elliptic Integrals of the Second Kind - Legendre Form

TR1 C Functions Quick Reference

+
ellint_2f
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
ellint_2l
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

ellint_3
@@ -206,6 +367,18 @@

C99 and C++ TR1 C-style Functions

Elliptic Integrals of the Third Kind - Legendre Form

TR1 C Functions Quick Reference

+
ellint_3f
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
ellint_3l
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

erf
@@ -219,19 +392,47 @@ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Error Functions

Normal (Gaussian) Distribution

+
erfcf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
erfcl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
erff
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
erfl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
exp2
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
exp2f
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
exp2l
+
+ +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
erfc_inv
-

Error Function Inverses

-
erf_inv
-

Error Function Inverses

-
evaluate_even_polynomial
-

Polynomial and Rational Function Evaluation

-
evaluate_odd_polynomial
-

Polynomial and Rational Function Evaluation

-
evaluate_polynomial
-

Polynomial and Rational Function Evaluation

-
evaluate_rational
-

Polynomial and Rational Function Evaluation

expint
@@ -240,6 +441,18 @@

C99 and C++ TR1 C-style Functions

Exponential Integral En

TR1 C Functions Quick Reference

+
expintf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
expintl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

expm1
@@ -247,79 +460,96 @@

C99 and C++ TR1 C-style Functions

C99 C Functions

expm1

+
expm1f
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
expm1l
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-F +F
-
factorial
-

Factorial

-
falling_factorial
-

Falling Factorial

-
find_beta
-

Beta Distribution

-
find_degrees_of_freedom
+
fdim
- - - + +

Chi Squared Distribution

Noncentral Chi-Squared Distribution

Students t Distribution

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
find_location
-

Distribution Algorithms

-
find_lower_bound_on_p
+
fdimf
- - - + +

Binomial Distribution

Geometric Distribution

Negative Binomial Distribution

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
find_non_centrality
-

Noncentral Chi-Squared Distribution

-
find_scale
-

Distribution Algorithms

-
find_upper_bound_on_p
+
fdiml
- - - + +

Binomial Distribution

Geometric Distribution

Negative Binomial Distribution

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
float_advance
-

Advancing a Floating Point Value by a Specific Representation Distance (ULP) float_advance

-
float_distance
-

Calculating the Representation Distance Between Two Floating Point Values (ULP) float_distance

-
float_next
-

Finding the Next Greater Representable Value (float_next)

-
float_prior
-

Finding the Next Smaller Representable Value (float_prior)

+
fma
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
fmaf
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
fmal
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
fmax
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
fmaxf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
fmaxl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
fmin
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
fminf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
fminl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
fpclassify
+

Floating-Point Classification: Infinities and NaNs

-G +H
-
-H -
-
-I +I
-K -
-
-
kahan_sum_series
-

Series Evaluation

-
kurtosis
-

Non-Member Properties

-
kurtosis_excess
-

Non-Member Properties

-
-
-L +L
-
laguerre_next
-

Laguerre (and Associated) Polynomials

-
legendre_next
-

Legendre (and Associated) Polynomials

-
legendre_p
-

Legendre (and Associated) Polynomials

-
legendre_q
-

Legendre (and Associated) Polynomials

+
laguerref
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
laguerrel
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
legendre
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
legendref
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
legendrel
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

lgamma
@@ -404,6 +684,33 @@

C99 and C++ TR1 C-style Functions

Log Gamma

Setting Polices at Namespace Scope

+
lgammaf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
lgammal
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
llrint
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
llrintf
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
llrintl
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

llround
@@ -411,8 +718,18 @@

C99 and C++ TR1 C-style Functions

C99 C Functions

Rounding Functions

-
lltrunc
-

Truncation Functions

+
llroundf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
llroundl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

log1p
@@ -421,6 +738,64 @@

C99 and C++ TR1 C-style Functions

log1p

Series Evaluation

+
log1pf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
log1pl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
log2
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Compile Time Power of a Runtime Base

+
log2f
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
log2l
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
logb
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
logbf
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
logbl
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
lrint
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
lrintf
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
lrintl
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

lround
@@ -428,30 +803,55 @@

C99 and C++ TR1 C-style Functions

C99 C Functions

Rounding Functions

-
ltrunc
-

Truncation Functions

+
lroundf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
lroundl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-M +N
-
-N -
-
-P +R
-
pdf
-

Non-Member Properties

-
powm1
-

powm1

-
-
-Q -
-
-
quantile
-

Non-Member Properties

-
-
-R -
-
-
relative_error
-

Relative Error and Testing

-
rising_factorial
-

Rising Factorial

+
remainder
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
remainderf
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
remainderl
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
remquo
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
remquof
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
remquol
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
riemann_zeta
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
riemann_zetaf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
riemann_zetal
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
rint
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
rintf
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
rintl
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

round
+

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Conceptual Requirements for Real Number Types

Rounding Functions

+
roundf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
roundl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-S +S
-
scale
-

Additional Implementation Notes

-
schroeder_iterate
-

Root Finding With Derivatives: Newton-Raphson, Halley & Schroeder

-
sinc_pi
-

sinc_pi

-
sinhc_pi
-

sinhc_pi

-
skewness
-

Non-Member Properties

-
spherical_harmonic_i
-

Spherical Harmonics

-
spherical_harmonic_r
-

Spherical Harmonics

+
scalbln
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
scalblnf
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
scalblnl
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
scalbn
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
scalbnf
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
scalbnl
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

+
sign
+

Sign Manipulation Functions

+
signbit
+

Sign Manipulation Functions

sph_bessel
@@ -519,6 +1023,36 @@

C99 and C++ TR1 C-style Functions

Spherical Bessel Functions of the First and Second Kinds

TR1 C Functions Quick Reference

+
sph_besself
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
sph_bessell
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
sph_legendre
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
sph_legendref
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
sph_legendrel
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

sph_neumann
@@ -526,19 +1060,23 @@

C99 and C++ TR1 C-style Functions

Spherical Bessel Functions of the First and Second Kinds

TR1 C Functions Quick Reference

-
sqrt1pm1
-

sqrt1pm1

-
standard_deviation
-

Non-Member Properties

-
sum_series
-

Series Evaluation

+
sph_neumannf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
sph_neumannl
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-T +T
-
-U -
-
-
-V -
-
-
variance
-

Non-Member Properties

-
-
-Z -
-
diff --git a/doc/sf_and_dist/html/index/s13.html b/doc/sf_and_dist/html/index/s13.html index a5f22d691..9daf02622 100644 --- a/doc/sf_and_dist/html/index/s13.html +++ b/doc/sf_and_dist/html/index/s13.html @@ -24,11 +24,11 @@

-Class Index

-

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

+Class Index
+

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

-B +B
bernoulli_distribution
@@ -39,7 +39,7 @@

Binomial Distribution

-C +C
cauchy_distribution
@@ -48,14 +48,14 @@

Chi Squared Distribution

-D +D
default_policy

Policy Class Reference

-E +E
eps_tolerance
@@ -72,14 +72,14 @@

Extreme Value Distribution

-F +F
fisher_f_distribution

F Distribution

-G +G
gamma_distribution
@@ -88,14 +88,14 @@

Geometric Distribution

-H +H
hypergeometric_distribution

Hypergeometric Distribution

-I +I
inverse_chi_squared_distribution
@@ -106,7 +106,7 @@

Inverse Gaussian (or Inverse Normal) Distribution

-L +L
laplace_distribution
@@ -119,18 +119,22 @@

Log Normal Distribution

-M +M
max_factorial

Factorial

-N +N
negative_binomial_distribution

Negative Binomial Distribution

+
nonfinite_num_get
+

Facets for Floating-Point Infinities and NaNs

+
nonfinite_num_put
+

Facets for Floating-Point Infinities and NaNs

non_central_beta_distribution

Noncentral Beta Distribution

non_central_chi_squared_distribution
@@ -145,7 +149,7 @@

Normal (Gaussian) Distribution

-P +P
pareto_distribution
@@ -159,21 +163,21 @@
-R +R
rayleigh_distribution

Rayleigh Distribution

-S +S
students_t_distribution

Students t Distribution

-T +T
test_data
@@ -185,7 +189,7 @@
-U +U
-W +W
weibull_distribution
diff --git a/doc/sf_and_dist/html/index/s14.html b/doc/sf_and_dist/html/index/s14.html index d1def3fc8..0a5fe575a 100644 --- a/doc/sf_and_dist/html/index/s14.html +++ b/doc/sf_and_dist/html/index/s14.html @@ -24,18 +24,18 @@

-Typedef Index

-

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

+Typedef Index
+

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

-A +A
assert_undefined_type

Policy Class Reference

-B +B
bernoulli
@@ -46,7 +46,7 @@

Binomial Distribution

-C +C
cauchy
@@ -61,7 +61,7 @@

Chi Squared Distribution

-D +D
denorm_error_type
@@ -78,7 +78,7 @@
-E +E
evaluation_error_type
@@ -89,7 +89,7 @@

Extreme Value Distribution

-F +F
fisher_f
@@ -105,7 +105,7 @@
-G +G
gamma
@@ -118,14 +118,14 @@

Geometric Distribution

-H +H
-I +I
indeterminate_result_error_type
@@ -136,7 +136,7 @@

Inverse Gaussian (or Inverse Normal) Distribution

-L +L
laplace
@@ -147,7 +147,7 @@

Log Normal Distribution

-N +N
negative_binomial
@@ -171,14 +171,14 @@
-O +O
overflow_error_type

Policy Class Reference

-P +P
pareto
@@ -224,7 +224,7 @@

Policy Class Reference

-R +R
rayleigh
@@ -233,7 +233,7 @@

Policy Class Reference

-S +S
students_t
@@ -243,14 +243,14 @@
-T +T
-U +U
underflow_error_type
@@ -259,7 +259,7 @@

Uniform Distribution

-V +V
value_type
@@ -299,7 +299,7 @@
-W +W
weibull
diff --git a/doc/sf_and_dist/html/index/s15.html b/doc/sf_and_dist/html/index/s15.html index 97e2a4f61..93e9b9c88 100644 --- a/doc/sf_and_dist/html/index/s15.html +++ b/doc/sf_and_dist/html/index/s15.html @@ -24,160 +24,13 @@

-Macro Index

-

A B C E F H I L N R S T

+Macro Index
+

B F

-A +B
-
acosh
-
- - - - -

acosh

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
acoshf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
acoshl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
asinh
-
- - - - -

asinh

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
asinhf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
asinhl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
assoc_laguerre
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
assoc_laguerref
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
assoc_laguerrel
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
assoc_legendre
-
- - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Legendre (and Associated) Polynomials

TR1 C Functions Quick Reference

-
assoc_legendref
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
assoc_legendrel
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
atanh
-
- - - - -

atanh

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
atanhf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
atanhl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
-
-B -
-
-
beta
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

About the Math Toolkit

Additional Implementation Notes

Beta

Beta Distribution

Binomial Coefficients

Binomial Distribution

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Chi Squared Distribution

Conceptual Requirements for Real Number Types

Credits and Acknowledgements

Derivative of the Incomplete Beta Function

Directory and File Structure

Distribution Construction Example

Distributions are Objects

Estimating how large a sample size would have to become in order to give a significant Students-t test result with a single sample test

Estimating the Required Sample Sizes for a Chi-Square Test for the Standard Deviation

F Distribution

Graphing, Profiling, and Generating Test Data for Special Functions

History and What's New

Incomplete Beta Functions

Negative Binomial Distribution

Noncentral Beta Distribution

Noncentral F Distribution

Noncentral T Distribution

Ratios of Gamma Functions

Students t Distribution

Tables of the power function of the χ 2 test.

The Incomplete Beta Function Inverses

The Lanczos Approximation

TR1 C Functions Quick Reference

Triangular Distribution

Weibull Distribution

-
betaf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
betal
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

BOOST_DEFINE_MATH_CONSTANT

Additional Implementation Notes

BOOST_FPU_EXCEPTION_GUARD
@@ -312,1076 +165,19 @@

Configuration Macros

-C +F
-
cbrt
-
- - - - - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

cbrt

Comparisons to Other Open Source Libraries

Directory and File Structure

Root Finding With Derivatives: Newton-Raphson, Halley & Schroeder

-
cbrtf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
cbrtl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
comp_ellint_1
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_1f
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_1l
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_2
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_2f
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_2l
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_3
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_3f
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_3l
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
copysign
-
- - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Sign Manipulation Functions

-
copysignf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
copysignl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
cyl_bessel_i
-
- - - - - - - - -

Bessel Function Overview

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Comparisons to Other Open Source Libraries

History and What's New

Modified Bessel Functions of the First and Second Kinds

Noncentral Chi-Squared Distribution

TR1 C Functions Quick Reference

-
cyl_bessel_if
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
cyl_bessel_il
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
cyl_bessel_j
-
- - - - - - - - - -

Bessel Function Overview

Bessel Functions of the First and Second Kinds

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Calculation of the Type of the Result

Comparisons to Other Open Source Libraries

Modified Bessel Functions of the First and Second Kinds

Spherical Bessel Functions of the First and Second Kinds

TR1 C Functions Quick Reference

-
cyl_bessel_jf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
cyl_bessel_jl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
cyl_bessel_k
-
- - - - - - -

Bessel Function Overview

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Comparisons to Other Open Source Libraries

Modified Bessel Functions of the First and Second Kinds

TR1 C Functions Quick Reference

-
cyl_bessel_kf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
cyl_bessel_kl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
cyl_neumann
-
- - - - - - - - -

Bessel Function Overview

Bessel Functions of the First and Second Kinds

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Comparisons to Other Open Source Libraries

Modified Bessel Functions of the First and Second Kinds

Spherical Bessel Functions of the First and Second Kinds

TR1 C Functions Quick Reference

-
cyl_neumannf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
cyl_neumannl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
-
-E -
-
-
ellint_1
-
- - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Elliptic Integrals of the First Kind - Legendre Form

TR1 C Functions Quick Reference

-
ellint_1f
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
ellint_1l
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
ellint_2
-
- - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Elliptic Integrals of the Second Kind - Legendre Form

TR1 C Functions Quick Reference

-
ellint_2f
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
ellint_2l
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
ellint_3
-
- - - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Elliptic Integrals of the Third Kind - Legendre Form

Known Issues, and TODO List

TR1 C Functions Quick Reference

-
ellint_3f
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
ellint_3l
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
erf
-
- - - - - - - - - - - - - - - -

About the Math Toolkit

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Calling User Defined Error Handlers

Comparing Compilers

Comparisons to Other Open Source Libraries

Conceptual Requirements for Real Number Types

Credits and Acknowledgements

Directory and File Structure

Error Function Inverses

Error Functions

Getting the Best Performance from this Library

History and What's New

Performance Tuning Macros

-
erfc
-
- - - - - - - - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Comparisons to Other Open Source Libraries

Error Function Inverses

Error Functions

History and What's New

Incomplete Gamma Functions

Normal (Gaussian) Distribution

The Remez Method

-
erfcf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
erfcl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
erff
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
erfl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
exp2
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
exp2f
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
exp2l
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
expint
-
- - - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Exponential Integral Ei

Exponential Integral En

TR1 C Functions Quick Reference

-
expintf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
expintl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
expm1
-
- - - - - - - - - - - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Comparisons to Other Open Source Libraries

expm1

Exponential Distribution

Extreme Value Distribution

Gamma

Pareto Distribution

powm1

Rayleigh Distribution

sqrt1pm1

Weibull Distribution

-
expm1f
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
expm1l
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
-
-F -
-
-
fdim
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
fdimf
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
fdiml
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
fma
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
fmaf
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
fmal
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
fmax
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
fmaxf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
fmaxl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
fmin
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
fminf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
fminl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

FP_INFINITE
-

Floating-Point Classification: Infinities and NaN's

+

Floating-Point Classification: Infinities and NaNs

FP_NAN
-

Floating-Point Classification: Infinities and NaN's

+

Floating-Point Classification: Infinities and NaNs

FP_NORMAL
-

Floating-Point Classification: Infinities and NaN's

+

Floating-Point Classification: Infinities and NaNs

FP_SUBNORMAL
-

Floating-Point Classification: Infinities and NaN's

+

Floating-Point Classification: Infinities and NaNs

FP_ZERO
-

Floating-Point Classification: Infinities and NaN's

-
-
-H -
-
-
-I -
-
-
-L -
-
-
laguerre
-
- - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Laguerre (and Associated) Polynomials

TR1 C Functions Quick Reference

-
laguerref
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
laguerrel
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
legendre
-
- - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Legendre (and Associated) Polynomials

TR1 C Functions Quick Reference

-
legendref
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
legendrel
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
lgamma
-
- - - - - - - - - - - - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Comparisons to Other Open Source Libraries

Directory and File Structure

Gamma

Graphing, Profiling, and Generating Test Data for Special Functions

History and What's New

Hypergeometric Distribution

Log Gamma

Negative Binomial Distribution

Relative Error and Testing

Setting Polices at Namespace Scope

The Lanczos Approximation

-
lgammaf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
lgammal
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
llrint
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
llrintf
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
llrintl
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
llround
-
- - - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Conceptual Requirements for Real Number Types

Rounding Functions

-
llroundf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
llroundl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
log1p
-
- - - - - - - - - - - - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Comparisons to Other Open Source Libraries

Exponential Distribution

Extreme Value Distribution

Geometric Distribution

Known Issues, and TODO List

Log Gamma

log1p

Rayleigh Distribution

Series Evaluation

sqrt1pm1

Weibull Distribution

-
log1pf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
log1pl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
log2
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Compile Time Power of a Runtime Base

-
log2f
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
log2l
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
logb
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
logbf
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
logbl
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
lrint
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
lrintf
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
lrintl
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
lround
-
- - - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Conceptual Requirements for Real Number Types

Rounding Functions

-
lroundf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
lroundl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
-
-N -
-
-
-R -
-
-
remainder
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

The Remez Method

-
remainderf
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
remainderl
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
remquo
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
remquof
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
remquol
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
riemann_zeta
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
riemann_zetaf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
riemann_zetal
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
rint
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
rintf
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
rintl
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
round
-
- - - - - - - - - - - - - - - - - - - - - -

Additional Implementation Notes

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Conceptual Requirements for Real Number Types

Discrete Quantile Policies

Error Function Inverses

Error Functions

Error Handling

Error Handling Policies

Find Scale (Standard Deviation) Example

Generic operations common to all distributions are non-member functions

Geometric Distribution Examples

Incomplete Gamma Function Inverses

Root Finding Without Derivatives: Bisection, Bracket and TOMS748

Rounding Functions

The Incomplete Beta Function Inverses

The Remez Method

Truncation Functions

Understanding Quantiles of Discrete Distributions

Using Macros to Change the Policy Defaults

-
roundf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
roundl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
-
-S -
-
-
scalbln
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
scalblnf
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
scalblnl
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
scalbn
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
scalbnf
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
scalbnl
-
- - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
sph_bessel
-
- - - - - - -

Bessel Function Overview

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Calculation of the Type of the Result

Spherical Bessel Functions of the First and Second Kinds

TR1 C Functions Quick Reference

-
sph_besself
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
sph_bessell
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
sph_legendre
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
sph_legendref
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
sph_legendrel
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
sph_neumann
-
- - - - - -

Bessel Function Overview

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Spherical Bessel Functions of the First and Second Kinds

TR1 C Functions Quick Reference

-
sph_neumannf
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
sph_neumannl
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
-
-T -
-
diff --git a/doc/sf_and_dist/html/index/s16.html b/doc/sf_and_dist/html/index/s16.html index 96d8166f8..dde0572d0 100644 --- a/doc/sf_and_dist/html/index/s16.html +++ b/doc/sf_and_dist/html/index/s16.html @@ -23,17 +23,18 @@

-Index

-

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

+Index
+

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

-A +A
-
About the Math Toolkit
+
accuracy
- - + + +

beta

erf

Additional Implementation Notes

Frequently Asked Questions FAQ

log1p

acosh
@@ -54,8 +55,6 @@

C99 and TR1 C Functions Overview

C99 C Functions

-
Advancing a Floating Point Value by a Specific Representation Distance (ULP) float_advance
-

float_advance

asinh
@@ -99,7 +98,6 @@

asinh

-

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Legendre (and Associated) Polynomials

TR1 C Functions Quick Reference

assoc_legendref
@@ -135,7 +133,7 @@
-B +B
bernoulli
@@ -149,15 +147,6 @@
bernoulli_distribution

Bernoulli Distribution

-
Bessel Function Overview
-
- - - - - - -

cyl_bessel_i

cyl_bessel_j

cyl_bessel_k

cyl_neumann

sph_bessel

sph_neumann

Bessel Functions of the First and Second Kinds
@@ -170,50 +159,23 @@

cyl_bessel_j

beta
- - - - - - - - - - - - - - - - - - - - - - - -

About the Math Toolkit

Additional Implementation Notes

Beta

Beta Distribution

Binomial Coefficients

Binomial Distribution

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Chi Squared Distribution

Conceptual Requirements for Real Number Types

Credits and Acknowledgements

Derivative of the Incomplete Beta Function

Directory and File Structure

Distribution Construction Example

Distributions are Objects

Estimating how large a sample size would have to become in order to give a significant Students-t test result with a single sample test

Estimating the Required Sample Sizes for a Chi-Square Test for the Standard Deviation

F Distribution

Graphing, Profiling, and Generating Test Data for Special Functions

History and What's New

Incomplete Beta Functions

Negative Binomial Distribution

Noncentral Beta Distribution

Noncentral F Distribution

Noncentral T Distribution

Ratios of Gamma Functions

Students t Distribution

Tables of the power function of the χ 2 test.

The Incomplete Beta Function Inverses

The Lanczos Approximation

TR1 C Functions Quick Reference

Triangular Distribution

Weibull Distribution

Beta Distribution
-

beta

beta_distribution

find_beta

policy_type

value_type

-
betac
-

Incomplete Beta Functions

betaf
@@ -231,22 +193,14 @@
binomial

C99 and C++ TR1 C-style Functions

Binomial Distribution

Binomial Coefficients
-
- - -

beta

binomial_coefficient

+

beta

Binomial Distribution
- - -

beta

binomial

binomial_distribution

find_lower_bound_on_p

find_upper_bound_on_p

policy_type

value_type

-
binomial_coefficient
-

Binomial Coefficients

binomial_distribution

Binomial Distribution

BOOST_DEFINE_MATH_CONSTANT
@@ -383,7 +337,7 @@

Configuration Macros

-C +C
-
Calculation of the Type of the Result
-
- - -

cyl_bessel_j

sph_bessel

Calling User Defined Error Handlers
- - - - - - - - - -

BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS

erf

msg

promote_args

tgamma

user_denorm_error

user_domain_error

user_evaluation_error

user_indeterminate_result_error

user_overflow_error

user_pole_error

user_rounding_error

user_underflow_error

cauchy
@@ -847,8 +780,6 @@ - -

C99 and TR1 C Functions Overview

C99 C Functions

cbrt

Comparisons to Other Open Source Libraries

Directory and File Structure

Root Finding With Derivatives: Newton-Raphson, Halley & Schroeder

cbrtf
@@ -863,11 +794,8 @@

C99 and TR1 C Functions Overview

C99 C Functions

-
cdf
-
- - -

Extras/Future Directions

Non-Member Properties

+
changesign
+

Sign Manipulation Functions

Changing the Policy Defaults
@@ -876,16 +804,10 @@

BOOST_MATH_ASSERT_UNDEFINED_POLICY

Changing the Policy on an Ad Hoc Basis for the Special Functions

tgamma

-
checked_narrowing_cast
-

Error Handling

-
chf
-

Non-Member Properties

Chi Squared Distribution
- -

beta

chi_squared

chi_squared_distribution

find_degrees_of_freedom

policy_type

value_type

@@ -893,27 +815,10 @@

Chi Squared Distribution

chi_squared_distribution

Chi Squared Distribution

-
Comparing Compilers
-

erf

-
Comparisons to Other Open Source Libraries
-
- - - - - - - - - - - -

cbrt

cyl_bessel_i

cyl_bessel_j

cyl_bessel_k

cyl_neumann

erf

erfc

expm1

lgamma

log1p

tgamma

Compile Time Power of a Runtime Base
-

BOOST_MATH_OVERFLOW_ERROR_POLICY

log2

user_overflow_error

Compilers

BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS

@@ -935,49 +840,9 @@

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_2
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_2f
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_2l
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_3
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_3f
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
comp_ellint_3l
-
- - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

Conceptual Requirements for Real Number Types
- - - -

beta

erf

Lanczos approximation

llround

lround

round

trunc

@@ -1005,15 +870,24 @@

BOOST_MATH_STD_USING

BOOST_MATH_USE_C99

-
Continued Fraction Evaluation
+
conf_hyperg
- - + + + +

continued_fraction_a

continued_fraction_b

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
conf_hypergf
+
+ + + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

+
conf_hypergl
+
+ + +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
continued_fraction_a
-

Continued Fraction Evaluation

-
continued_fraction_b
-

Continued Fraction Evaluation

copysign
@@ -1033,20 +907,11 @@

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
Credits and Acknowledgements
-
- - -

beta

erf

cyl_bessel_i
- - - -

Bessel Function Overview

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Comparisons to Other Open Source Libraries

History and What's New

Modified Bessel Functions of the First and Second Kinds

Noncentral Chi-Squared Distribution

TR1 C Functions Quick Reference

cyl_bessel_if
@@ -1063,14 +928,9 @@
cyl_bessel_j
- - - - -

Bessel Function Overview

Bessel Functions of the First and Second Kinds

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Calculation of the Type of the Result

Comparisons to Other Open Source Libraries

Modified Bessel Functions of the First and Second Kinds

Spherical Bessel Functions of the First and Second Kinds

TR1 C Functions Quick Reference

cyl_bessel_jf
@@ -1087,10 +947,8 @@
cyl_bessel_k
- -

Bessel Function Overview

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Comparisons to Other Open Source Libraries

Modified Bessel Functions of the First and Second Kinds

TR1 C Functions Quick Reference

@@ -1108,13 +966,9 @@
cyl_neumann
- - - -

Bessel Function Overview

Bessel Functions of the First and Second Kinds

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Comparisons to Other Open Source Libraries

Modified Bessel Functions of the First and Second Kinds

Spherical Bessel Functions of the First and Second Kinds

TR1 C Functions Quick Reference

cyl_neumannf
@@ -1131,52 +985,19 @@
-D +D
default_policy

Policy Class Reference

denorm_error_type

Policy Class Reference

-
Derivative of the Incomplete Beta Function
-
- - -

beta

ibeta_derivative

-
Derivative of the Incomplete Gamma Function
-

gamma_p_derivative

Digamma
-
- - -

digamma

Lanczos approximation

-
digamma
-

Digamma

-
Directory and File Structure
-
- - - - - -

beta

cbrt

erf

lgamma

tgamma

-
Discrete Quantile Policies
-

round

+

Lanczos approximation

discrete_quantile_type

Policy Class Reference

-
Distribution Algorithms
-
- - -

find_location

find_scale

-
Distributions are Objects
-

beta

domain_error_type

Policy Class Reference

-
Double Factorial
-

double_factorial

-
double_factorial
-

Double Factorial

double_t
@@ -1185,11 +1006,9 @@

C99 and C++ TR1 C-style Functions

-E +E
-
e
-

Numeric Constants

ellint_1
@@ -1233,7 +1052,6 @@ -

C99 and C++ TR1 C-style Functions

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Elliptic Integrals of the Third Kind - Legendre Form

Known Issues, and TODO List

TR1 C Functions Quick Reference

ellint_3f
@@ -1264,34 +1082,18 @@

Root Finding Without Derivatives: Bisection, Bracket and TOMS748

erf
- - - - - - - - - - -

About the Math Toolkit

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Calling User Defined Error Handlers

Comparing Compilers

Comparisons to Other Open Source Libraries

Conceptual Requirements for Real Number Types

Credits and Acknowledgements

Directory and File Structure

Error Function Inverses

Error Functions

Getting the Best Performance from this Library

History and What's New

Performance Tuning Macros

erfc
- - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Comparisons to Other Open Source Libraries

Error Function Inverses

Error Functions

History and What's New

Incomplete Gamma Functions

Normal (Gaussian) Distribution

The Remez Method

erfcf
@@ -1305,8 +1107,6 @@

C99 and TR1 C Functions Overview

C99 C Functions

-
erfc_inv
-

Error Function Inverses

erff
@@ -1319,63 +1119,21 @@

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
erf_inv
-

Error Function Inverses

-
Error Function Inverses
-
- - - - - -

erf

erfc

erfc_inv

erf_inv

round

Error Functions
-

erf

erfc

round

-
Error Handling
-
- - - - -

checked_narrowing_cast

round

tgamma

trunc

-
Error Handling Policies
-
- - - - - - - - - - - -

round

tgamma

trunc

user_denorm_error

user_domain_error

user_evaluation_error

user_indeterminate_result_error

user_overflow_error

user_pole_error

user_rounding_error

user_underflow_error

-
evaluate_even_polynomial
-

Polynomial and Rational Function Evaluation

-
evaluate_odd_polynomial
-

Polynomial and Rational Function Evaluation

-
evaluate_polynomial
-

Polynomial and Rational Function Evaluation

-
evaluate_rational
-

Polynomial and Rational Function Evaluation

evaluation_error_type

Policy Class Reference

Examples
- -

beta

BOOST_MATH_DISCRETE_QUANTILE_POLICY

BOOST_MATH_DOMAIN_ERROR_POLICY

BOOST_MATH_OVERFLOW_ERROR_POLICY

cauchy

negative_binomial

normal

round

exp2
@@ -1417,16 +1175,7 @@ - - - - - - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Comparisons to Other Open Source Libraries

expm1

Exponential Distribution

Extreme Value Distribution

Gamma

Pareto Distribution

powm1

Rayleigh Distribution

sqrt1pm1

Weibull Distribution

expm1f
@@ -1444,10 +1193,8 @@

Exponential Distribution

Exponential Distribution
- -

expm1

exponential

exponential_distribution

log1p

policy_type

value_type

@@ -1457,14 +1204,10 @@

expint

exponential_distribution

Exponential Distribution

-
Extras/Future Directions
-

cdf

Extreme Value Distribution
- -

expm1

extreme_value

extreme_value_distribution

log1p

value_type

extreme_value
@@ -1473,28 +1216,22 @@

Extreme Value Distribution

-F +F
F Distribution
-

beta

fisher_f

fisher_f_distribution

value_type

-
Factorial
+
Facets for Floating-Point Infinities and NaNs
- - - + +

factorial

max_factorial

tgamma

nonfinite_num_get

nonfinite_num_put

-
factorial
-

Factorial

-
Falling Factorial
-

falling_factorial

-
falling_factorial
-

Falling Factorial

+
Factorial
+

max_factorial

fdim
@@ -1510,47 +1247,8 @@

C99 and C++ TR1 C-style Functions

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
Finding the Next Greater Representable Value (float_next)
-
- - -

float_next

nextafter

Finding the Next Representable Value in a Specific Direction (nextafter)
-
- - -

nextafter

nexttoward

-
Finding the Next Smaller Representable Value (float_prior)
-
- - -

float_prior

nextafter

-
find_beta
-

Beta Distribution

-
find_degrees_of_freedom
-
- - - -

Chi Squared Distribution

Noncentral Chi-Squared Distribution

Students t Distribution

-
find_location
-

Distribution Algorithms

-
find_lower_bound_on_p
-
- - - -

Binomial Distribution

Geometric Distribution

Negative Binomial Distribution

-
find_non_centrality
-

Noncentral Chi-Squared Distribution

-
find_scale
-

Distribution Algorithms

-
find_upper_bound_on_p
-
- - - -

Binomial Distribution

Geometric Distribution

Negative Binomial Distribution

+

nextafter

fisher_f
@@ -1558,23 +1256,19 @@

F Distribution

fisher_f_distribution

F Distribution

-
Floating-Point Classification: Infinities and NaN's
+
Floating-Point Classification: Infinities and NaNs
- - - - - - + + + + + + + + + +

FP_INFINITE

FP_NAN

FP_NORMAL

FP_SUBNORMAL

FP_ZERO

isnan

fpclassify

FP_INFINITE

FP_NAN

FP_NORMAL

FP_SUBNORMAL

FP_ZERO

isfinite

isinf

isnan

isnormal

-
float_advance
-

Advancing a Floating Point Value by a Specific Representation Distance (ULP) float_advance

-
float_distance
-

Calculating the Representation Distance Between Two Floating Point Values (ULP) float_distance

-
float_next
-

Finding the Next Greater Representable Value (float_next)

-
float_prior
-

Finding the Next Smaller Representable Value (float_prior)

float_t
@@ -1632,28 +1326,29 @@

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

+
fpclassify
+

Floating-Point Classification: Infinities and NaNs

FP_INFINITE
-

Floating-Point Classification: Infinities and NaN's

+

Floating-Point Classification: Infinities and NaNs

FP_NAN
-

Floating-Point Classification: Infinities and NaN's

+

Floating-Point Classification: Infinities and NaNs

FP_NORMAL
-

Floating-Point Classification: Infinities and NaN's

+

Floating-Point Classification: Infinities and NaNs

FP_SUBNORMAL
-

Floating-Point Classification: Infinities and NaN's

+

Floating-Point Classification: Infinities and NaNs

FP_ZERO
-

Floating-Point Classification: Infinities and NaN's

+

Floating-Point Classification: Infinities and NaNs

+
Frequently Asked Questions FAQ
+

accuracy

-G +G
Gamma
- - -

expm1

Lanczos approximation

lgamma

tgamma

tgamma1pm1

gamma
@@ -1670,58 +1365,28 @@
gamma_distribution

Gamma (and Erlang) Distribution

-
gamma_p
-

Incomplete Gamma Functions

-
gamma_p_derivative
-

Derivative of the Incomplete Gamma Function

-
gamma_p_inv
-

Incomplete Gamma Function Inverses

-
gamma_p_inva
-

Incomplete Gamma Function Inverses

-
gamma_q
-

Incomplete Gamma Functions

-
gamma_q_inv
-

Incomplete Gamma Function Inverses

-
gamma_q_inva
-

Incomplete Gamma Function Inverses

-
Generic operations common to all distributions are non-member functions
-

round

geometric

Geometric Distribution

Geometric Distribution
- - -

find_lower_bound_on_p

find_upper_bound_on_p

geometric

geometric_distribution

log1p

policy_type

value_type

geometric_distribution

Geometric Distribution

-
Getting the Best Performance from this Library
-

erf

-
get_user_parameter_info
-

Graphing, Profiling, and Generating Test Data for Special Functions

Graphing, Profiling, and Generating Test Data for Special Functions
- - -

beta

get_user_parameter_info

lgamma

test_data

upper_incomplete_gamma_fract

value_type

-H +H
-I +I
-
ibeta
-

Incomplete Beta Functions

-
ibetac
-

Incomplete Beta Functions

-
ibetac_inv
-

The Incomplete Beta Function Inverses

-
ibetac_inva
-

The Incomplete Beta Function Inverses

-
ibetac_invb
-

The Incomplete Beta Function Inverses

-
ibeta_derivative
-

Derivative of the Incomplete Beta Function

-
ibeta_inv
-

The Incomplete Beta Function Inverses

-
ibeta_inva
-

The Incomplete Beta Function Inverses

-
ibeta_invb
-

The Incomplete Beta Function Inverses

ilogb
@@ -1847,52 +1481,24 @@

C99 and C++ TR1 C-style Functions

Implementation Notes
- + - -

beta

accuracy

BOOST_DEFINE_MATH_CONSTANT

BOOST_MATH_DOMAIN_ERROR_POLICY

round

scale

triangular_distribution

Incomplete Beta Function Inverses
-
- - - - - - - - -

beta

ibetac_inv

ibetac_inva

ibetac_invb

ibeta_inv

ibeta_inva

ibeta_invb

round

+

beta

Incomplete Beta Functions
-
- - - - -

beta

betac

ibeta

ibetac

-
Incomplete Gamma Function Inverses
-
- - - - - -

gamma_p_inv

gamma_p_inva

gamma_q_inv

gamma_q_inva

round

+

beta

Incomplete Gamma Functions
- - - -

erfc

gamma_p

gamma_q

Lanczos approximation

tgamma

tgamma_lower

indeterminate_result_error_type

Policy Class Reference

-
Internal Floating-point Promotion Policies
-

tgamma

+
Introduction
+

nan

Inverse Chi Squared Distribution
@@ -1924,38 +1530,29 @@

inverse_chi_squared

Inverse Gaussian (or Inverse Normal) Distribution

inverse_gaussian_distribution

Inverse Gaussian (or Inverse Normal) Distribution

-
iround
-

Rounding Functions

+
isfinite
+

Floating-Point Classification: Infinities and NaNs

+
isinf
+

Floating-Point Classification: Infinities and NaNs

isnan
-

Floating-Point Classification: Infinities and NaN's

+

Floating-Point Classification: Infinities and NaNs

+
isnormal
+

Floating-Point Classification: Infinities and NaNs

Iteration Limits Policies

BOOST_MATH_MAX_ROOT_ITERATION_POLICY

BOOST_MATH_MAX_SERIES_ITERATION_POLICY

-
itrunc
-

Truncation Functions

-K +K
-
kahan_sum_series
-

Series Evaluation

Known Issues, and TODO List
-
- - - - -

ellint_3

Lanczos approximation

log1p

tgamma

-
kurtosis
-

Non-Member Properties

-
kurtosis_excess
-

Non-Member Properties

+

Lanczos approximation

-L +L
laguerre
@@ -1966,10 +1563,7 @@

TR1 C Functions Quick Reference

Laguerre (and Associated) Polynomials
-
- - -

laguerre

laguerre_next

+

laguerre

laguerref
@@ -1982,8 +1576,6 @@

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
laguerre_next
-

Laguerre (and Associated) Polynomials

Lanczos approximation
@@ -1995,7 +1587,6 @@ - @@ -2019,17 +1610,8 @@

Beta

Incomplete Gamma Functions

Known Issues, and TODO List

Lanczos approximation

lgamma

Log Gamma

Negative Binomial Distribution

Performance Tuning Macros

-

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Legendre (and Associated) Polynomials

TR1 C Functions Quick Reference

-
Legendre (and Associated) Polynomials
-
- - - - - -

assoc_legendre

legendre

legendre_next

legendre_p

legendre_q

legendref
@@ -2042,28 +1624,13 @@

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
legendre_next
-

Legendre (and Associated) Polynomials

-
legendre_p
-

Legendre (and Associated) Polynomials

-
legendre_q
-

Legendre (and Associated) Polynomials

lgamma
- - - - - - - - -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Comparisons to Other Open Source Libraries

Directory and File Structure

Gamma

Graphing, Profiling, and Generating Test Data for Special Functions

History and What's New

Hypergeometric Distribution

Log Gamma

Negative Binomial Distribution

Relative Error and Testing

Setting Polices at Namespace Scope

The Lanczos Approximation

lgammaf
@@ -2097,7 +1664,6 @@ -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Conceptual Requirements for Real Number Types

Rounding Functions

llroundf
@@ -2112,13 +1678,10 @@

C99 and TR1 C Functions Overview

C99 C Functions

-
lltrunc
-

Truncation Functions

Log Gamma
-

Lanczos approximation

lgamma

log1p

tgamma

Log Normal Distribution
@@ -2130,21 +1693,13 @@
log1p
+ - - - - - - - - -

accuracy

BOOST_HAS_LOG1P

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Comparisons to Other Open Source Libraries

Exponential Distribution

Extreme Value Distribution

Geometric Distribution

Known Issues, and TODO List

Log Gamma

log1p

Rayleigh Distribution

Series Evaluation

sqrt1pm1

Weibull Distribution

log1pf
@@ -2226,7 +1781,6 @@ -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Conceptual Requirements for Real Number Types

Rounding Functions

lroundf
@@ -2241,37 +1795,23 @@

C99 and TR1 C Functions Overview

C99 C Functions

-
ltrunc
-

Truncation Functions

-M +M
-
make_policy
-

Policy Class Reference

Mathematically Undefined Function Policies

BOOST_MATH_ASSERT_UNDEFINED_POLICY

max_factorial

Factorial

-
mean
-

Non-Member Properties

-
median
-

Non-Member Properties

-
mode
-

Non-Member Properties

Modified Bessel Functions of the First and Second Kinds
- -

cyl_bessel_i

cyl_bessel_j

cyl_bessel_k

cyl_neumann

-
msg
-

Calling User Defined Error Handlers

-N +N
Namespaces
@@ -2280,6 +1820,8 @@
+ +

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Introduction

Reference

nanf
@@ -2308,11 +1850,7 @@
Negative Binomial Distribution
- - - - @@ -2325,16 +1863,12 @@

beta

find_lower_bound_on_p

find_upper_bound_on_p

Lanczos approximation

lgamma

negative_binomial

negative_binomial_distribution

policy_type

negative_binomial_distribution

Negative Binomial Distribution

-
newton_raphson_iterate
-

Root Finding With Derivatives: Newton-Raphson, Halley & Schroeder

nextafter
- -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Finding the Next Greater Representable Value (float_next)

Finding the Next Representable Value in a Specific Direction (nextafter)

Finding the Next Smaller Representable Value (float_prior)

nextafterf
@@ -2353,7 +1887,6 @@ -

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Finding the Next Representable Value in a Specific Direction (nextafter)

nexttowardf
@@ -2367,22 +1900,6 @@

C99 and TR1 C Functions Overview

C99 C Functions

-
Non-Member Properties
-
- - - - - - - - - - - - - -

cdf

chf

hazard

kurtosis

kurtosis_excess

mean

median

mode

pdf

quantile

skewness

standard_deviation

variance

Noncentral Beta Distribution
@@ -2393,9 +1910,6 @@

beta

Noncentral Chi-Squared Distribution
- - - @@ -2403,7 +1917,6 @@

cyl_bessel_i

find_degrees_of_freedom

find_non_centrality

non_central_chi_squared

non_central_chi_squared_distribution

policy_type

Noncentral F Distribution
- @@ -2411,12 +1924,15 @@

beta

non_central_f

non_central_f_distribution

policy_type

Noncentral T Distribution
-

beta

non_central_t

non_central_t_distribution

policy_type

value_type

+
nonfinite_num_get
+

Facets for Floating-Point Infinities and NaNs

+
nonfinite_num_put
+

Facets for Floating-Point Infinities and NaNs

non_central_beta

Noncentral Beta Distribution

non_central_beta_distribution
@@ -2433,8 +1949,6 @@

Noncentral T Distribution

non_central_t_distribution

Noncentral T Distribution

-
norm
-

Setting Policies at Namespace or Translation Unit Scope

normal
@@ -2453,33 +1967,28 @@

Geometric Distribution Examples

Policy Class Reference

normal_distribution

Normal (Gaussian) Distribution

-
Numeric Constants
-

e

-O +O
overflow_error_type

Policy Class Reference

-P +P
-
Polynomial and Rational Function Evaluation
-
- - - - - -

evaluate_even_polynomial

evaluate_odd_polynomial

evaluate_polynomial

evaluate_rational

T

Polynomials

value_type

-
powm1
-
- - -

expm1

powm1

-
Precision Policies
-

tgamma

precision_type

Policy Class Reference

promote_args
@@ -2581,28 +2073,13 @@

Policy Class Reference

-Q +R
-
quantile
-

Non-Member Properties

-
-
-R -
-
-
Ratios of Gamma Functions
-
- - - -

beta

tgamma_delta_ratio

tgamma_ratio

rayleigh

Rayleigh Distribution

Rayleigh Distribution
- - @@ -2610,21 +2087,14 @@

expm1

log1p

policy_type

rayleigh

rayleigh_distribution

rayleigh_distribution

Rayleigh Distribution

+
Reference
+

nan

References

Lanczos approximation

-
Relative Error and Testing
-
- - - -

lgamma

relative_error

tgamma

-
relative_error
-

Relative Error and Testing

remainder
-

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

The Remez Method

remainderf
@@ -2636,12 +2106,6 @@

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
Remez Method
-
- - - -

erfc

remainder

round

remquo
@@ -2657,10 +2121,6 @@

C99 and C++ TR1 C-style Functions

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
Representation Distance Between Two Floating Point Values (ULP) float_distance
-

float_distance

-
Riemann Zeta Function
-

zeta

riemann_zeta
@@ -2694,49 +2154,22 @@

C99 and C++ TR1 C-style Functions

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

-
Rising Factorial
-

rising_factorial

-
rising_factorial
-

Rising Factorial

Root Finding With Derivatives: Newton-Raphson, Halley & Schroeder
-
- - - - - -

cbrt

halley_iterate

newton_raphson_iterate

schroeder_iterate

z

+

cbrt

Root Finding Without Derivatives: Bisection, Bracket and TOMS748
-

eps_tolerance

equal_ceil

equal_floor

equal_nearest_integer

round

round
- - - - - - - - - - - - - - - -

Additional Implementation Notes

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

Conceptual Requirements for Real Number Types

Discrete Quantile Policies

Error Function Inverses

Error Functions

Error Handling

Error Handling Policies

Find Scale (Standard Deviation) Example

Generic operations common to all distributions are non-member functions

Geometric Distribution Examples

Incomplete Gamma Function Inverses

Root Finding Without Derivatives: Bisection, Bracket and TOMS748

Rounding Functions

The Incomplete Beta Function Inverses

The Remez Method

Truncation Functions

Understanding Quantiles of Discrete Distributions

Using Macros to Change the Policy Defaults

roundf
@@ -2746,7 +2179,6 @@
Rounding Functions
- @@ -2761,7 +2193,7 @@

iround

llround

lround

round

-S +S
-
scale
-

Additional Implementation Notes

-
schroeder_iterate
-

Root Finding With Derivatives: Newton-Raphson, Halley & Schroeder

Series Evaluation
- -

kahan_sum_series

log1p

log1p_series

sum_series

Setting Polices at Namespace Scope
@@ -2819,43 +2245,32 @@ -

BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS

cauchy

gamma

norm

normal

promote_args

tgamma

Setting Policies for Distributions on an Ad Hoc Basis

fisher_f

+
sign
+

Sign Manipulation Functions

Sign Manipulation Functions
-

copysign

-
sinc_pi
-

sinc_pi

-
sinhc_pi
-

sinhc_pi

-
skewness
-

Non-Member Properties

+
+ + + + +

changesign

copysign

sign

signbit

+
signbit
+

Sign Manipulation Functions

Spherical Bessel Functions of the First and Second Kinds
- -

cyl_bessel_j

cyl_neumann

sph_bessel

sph_neumann

-
Spherical Harmonics
-
- - -

spherical_harmonic_i

spherical_harmonic_r

-
spherical_harmonic_i
-

Spherical Harmonics

-
spherical_harmonic_r
-

Spherical Harmonics

sph_bessel
- -

Bessel Function Overview

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Calculation of the Type of the Result

Spherical Bessel Functions of the First and Second Kinds

TR1 C Functions Quick Reference

@@ -2891,7 +2306,6 @@
sph_neumann
- @@ -2909,18 +2323,8 @@

Bessel Function Overview

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

Spherical Bessel Functions of the First and Second Kinds

C99 and TR1 C Functions Overview

TR1 C Functions Quick Reference

-
sqrt1pm1
-
- - - -

expm1

log1p

sqrt1pm1

-
standard_deviation
-

Non-Member Properties

Students t Distribution
- - @@ -2933,15 +2337,11 @@

beta

find_degrees_of_freedom

policy_type

students_t

students_t_distribution

students_t_distribution

Students t Distribution

-
sum_series
-

Series Evaluation

-T +T
-
tgamma1pm1
-

Gamma

tgammaf
@@ -2981,12 +2369,6 @@

C99 and C++ TR1 C-style Functions

C99 and TR1 C Functions Overview

C99 C Functions

-
tgamma_delta_ratio
-

Ratios of Gamma Functions

-
tgamma_lower
-

Incomplete Gamma Functions

-
tgamma_ratio
-

Ratios of Gamma Functions

TR1 C Functions Quick Reference
@@ -3001,12 +2383,9 @@ - - - - - - + + + @@ -3060,7 +2439,6 @@

assoc_laguerre

comp_ellint_1

comp_ellint_1f

comp_ellint_1l

comp_ellint_2

comp_ellint_2f

comp_ellint_2l

comp_ellint_3

comp_ellint_3f

comp_ellint_3l

conf_hyperg

conf_hypergf

conf_hypergl

cyl_bessel_i

cyl_bessel_if

cyl_bessel_il

Triangular Distribution

Triangular Distribution
- @@ -3077,18 +2455,10 @@ - -

beta

policy_type

triangular

triangular_distribution

C99 and TR1 C Functions Overview

C99 C Functions

Conceptual Requirements for Real Number Types

Error Handling

Error Handling Policies

Truncation Functions

Truncation Functions
-
- - - - - -

itrunc

lltrunc

ltrunc

round

trunc

+

trunc

truncf
@@ -3103,13 +2473,11 @@

C99 and C++ TR1 C-style Functions

-U +U
underflow_error_type

Policy Class Reference

-
Understanding Quantiles of Discrete Distributions
-

round

uniform

Uniform Distribution

Uniform Distribution
@@ -3122,47 +2490,6 @@

Uniform Distribution

upper_incomplete_gamma_fract

Graphing, Profiling, and Generating Test Data for Special Functions

-
user_denorm_error
-
- - -

Calling User Defined Error Handlers

Error Handling Policies

-
user_domain_error
-
- - -

Calling User Defined Error Handlers

Error Handling Policies

-
user_evaluation_error
-
- - -

Calling User Defined Error Handlers

Error Handling Policies

-
user_indeterminate_result_error
-
- - -

Calling User Defined Error Handlers

Error Handling Policies

-
user_overflow_error
-
- - - -

Calling User Defined Error Handlers

Compile Time Power of a Runtime Base

Error Handling Policies

-
user_pole_error
-
- - -

Calling User Defined Error Handlers

Error Handling Policies

-
user_rounding_error
-
- - -

Calling User Defined Error Handlers

Error Handling Policies

-
user_underflow_error
-
- - -

Calling User Defined Error Handlers

Error Handling Policies

Using Macros to Change the Policy Defaults
@@ -3180,18 +2507,14 @@ -

BOOST_MATH_ASSERT_UNDEFINED_POLICY

BOOST_MATH_PROMOTE_FLOAT_POLICY

BOOST_MATH_ROUNDING_ERROR_POLICY

BOOST_MATH_UNDERFLOW_ERROR_POLICY

round

Using With MPFR / GMP - a High-Precision Floating-Point Library
-
- - -

Lanczos approximation

tgamma

+

Lanczos approximation

Using With NTL - a High-Precision Floating-Point Library

Lanczos approximation

-V +V
value_type
@@ -3229,20 +2552,15 @@

Uniform Distribution

Weibull Distribution

-
variance
-

Non-Member Properties

-W +W
weibull

Weibull Distribution

Weibull Distribution
- - - @@ -3251,15 +2569,6 @@
weibull_distribution

beta

expm1

log1p

policy_type

value_type

weibull

Weibull Distribution

-
-Z -
-
diff --git a/doc/sf_and_dist/html/math_toolkit/backgrounders/implementation.html b/doc/sf_and_dist/html/math_toolkit/backgrounders/implementation.html index 3125e3531..9503ca873 100644 --- a/doc/sf_and_dist/html/math_toolkit/backgrounders/implementation.html +++ b/doc/sf_and_dist/html/math_toolkit/backgrounders/implementation.html @@ -33,7 +33,7 @@ and reflect more the general implementation philosophy used.

- + Implemention philosophy
@@ -85,7 +85,7 @@ These could still provide sufficient accuracy for some speed-critical applications.

- + Accuracy and Representation of Test Values
@@ -130,7 +130,7 @@ binary value).

- + Tolerance of Tests
@@ -156,7 +156,7 @@ first that the suffix L is present, and then that the tolerance is big enough.

- + Handling Unsuitable Arguments
@@ -224,7 +224,7 @@

- + Handling of Functions that are Not Mathematically defined
@@ -258,7 +258,7 @@

- + Median of distributions
@@ -293,7 +293,7 @@ Basic Statistics. give more detail, in particular for discrete distributions.

- + Handling of Floating-Point Infinity
@@ -337,7 +337,7 @@ handling policies.

- + Scale, Shape and Location
@@ -364,7 +364,7 @@ functions, they can be added if required.

- + Notes on Implementation of Specific Functions & Distributions
@@ -376,7 +376,7 @@ lower = -1, mode = 0 and upper = 1 would be more suitable.
- + Rational Approximations Used
@@ -419,7 +419,7 @@ to the "true" minimax solution.

- + Representation of Mathematical Constants
@@ -480,7 +480,7 @@ double p = boost::math::constants::pi(); // Context does not allow for disambiguation of overloaded function
- + Thread safety
@@ -505,7 +505,7 @@ the right thing here at some point.

- + Sources of Test Data
@@ -546,7 +546,7 @@ the underlying special function is known to be difficult to implement.

- + Creating and Managing the Equations
@@ -731,7 +731,7 @@ done HTML: this needs further investigation.

- + Producing Graphs
diff --git a/doc/sf_and_dist/html/math_toolkit/backgrounders/lanczos.html b/doc/sf_and_dist/html/math_toolkit/backgrounders/lanczos.html index 349b125b0..d29f2e20b 100644 --- a/doc/sf_and_dist/html/math_toolkit/backgrounders/lanczos.html +++ b/doc/sf_and_dist/html/math_toolkit/backgrounders/lanczos.html @@ -27,7 +27,7 @@ The Lanczos Approximation
- + Motivation

@@ -99,7 +99,7 @@ functions divided by large powers into single (simpler) expressions.

- + The Approximation
@@ -161,7 +161,7 @@

- + Computing the Coefficients
@@ -205,7 +205,7 @@ multiplied by F as the last step.

- + Choosing the Right Parameters
@@ -229,7 +229,7 @@ computing to float precision with double precision arithmetic.

-

Table 56. Optimal choices for N and g when computing with guard digits (source: +

Table 57. Optimal choices for N and g when computing with guard digits (source: Pugh)

@@ -372,7 +372,7 @@ exactly matches the machine epsilon for the type in question.

-

Table 57. Optimum value for N and g when computing at fixed precision

+

Table 58. Optimum value for N and g when computing at fixed precision

@@ -535,7 +535,7 @@ is exact, and so isn't used for the gamma function.

- + References
    diff --git a/doc/sf_and_dist/html/math_toolkit/backgrounders/refs.html b/doc/sf_and_dist/html/math_toolkit/backgrounders/refs.html index ccf625a12..b74723671 100644 --- a/doc/sf_and_dist/html/math_toolkit/backgrounders/refs.html +++ b/doc/sf_and_dist/html/math_toolkit/backgrounders/refs.html @@ -27,7 +27,7 @@ References
- + General references
@@ -98,7 +98,7 @@ Library (version 2), Walter E. Brown

- + Calculators

@@ -120,7 +120,7 @@ Binomial Probability Distribution Calculator.

- + Other Libraries

diff --git a/doc/sf_and_dist/html/math_toolkit/backgrounders/relative_error.html b/doc/sf_and_dist/html/math_toolkit/backgrounders/relative_error.html index 2cf67b3dd..e2e2caaf7 100644 --- a/doc/sf_and_dist/html/math_toolkit/backgrounders/relative_error.html +++ b/doc/sf_and_dist/html/math_toolkit/backgrounders/relative_error.html @@ -78,7 +78,7 @@ of binary digits. You have been warned!

- + The Impossibility of Zero Error
diff --git a/doc/sf_and_dist/html/math_toolkit/backgrounders/remez.html b/doc/sf_and_dist/html/math_toolkit/backgrounders/remez.html index 1b2a3523b..50b38fb3a 100644 --- a/doc/sf_and_dist/html/math_toolkit/backgrounders/remez.html +++ b/doc/sf_and_dist/html/math_toolkit/backgrounders/remez.html @@ -94,7 +94,7 @@ are located!

- + The Remez Method
@@ -174,7 +174,7 @@
- + Remez Step 1
@@ -205,7 +205,7 @@ to 5.6x10-4.

- + Remez Step 2
@@ -234,7 +234,7 @@ In our example we perform multi-point exchange.

- + Iteration

@@ -250,7 +250,7 @@ remez-4

- + Rational Approximations
@@ -299,7 +299,7 @@ number of terms overall.

- + Practical Considerations
@@ -407,7 +407,7 @@ desired minimax solution (5x10-4).

- + Remez Method Checklist
@@ -461,7 +461,7 @@
- + References

diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dist_algorithms.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dist_algorithms.html index d2ff162b6..f1b07b2fc 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dist_algorithms.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dist_algorithms.html @@ -28,7 +28,7 @@ Algorithms

- + Finding the Location and Scale for Normal and similar distributions
@@ -50,7 +50,7 @@ using boost::math::complement; // Will be needed by users who want to use complements.
- + find_location function
@@ -80,7 +80,7 @@ }} // namespaces
- + find_scale function
diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/bernoulli_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/bernoulli_dist.html index 1f1c97f97..15ac17e7d 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/bernoulli_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/bernoulli_dist.html @@ -87,7 +87,7 @@

- + Member Functions
@@ -103,7 +103,7 @@ Returns the success_fraction parameter of this distribution.

- + Non-member Accessors
@@ -128,7 +128,7 @@ exception and make an error message available.

- + Accuracy

@@ -136,7 +136,7 @@ and so should have errors within an epsilon or two.

- + Implementation

@@ -327,7 +327,7 @@

- + References
    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/beta_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/beta_dist.html index 32c777542..3485abed7 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/beta_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/beta_dist.html @@ -132,12 +132,12 @@ whose apex is away from the centre (where x = half).

    - + Member Functions
    - + Constructor
    beta_distribution(RealType alpha, RealType beta);
    @@ -164,7 +164,7 @@
                 yellow in the graph above).
               

    - + Parameter Accessors
    @@ -188,7 +188,7 @@ assert(mybeta.beta() == 5.); // mybeta.beta() returns 5
    - + Parameter Estimators
    @@ -241,7 +241,7 @@ Returns the value of β   that gives: cdf(beta_distribution<RealType>(alpha, beta), x) == probability.

    - + Non-member Accessor Functions
    @@ -263,7 +263,7 @@ Mathworld.

    - + Applications

    @@ -276,7 +276,7 @@ statistical inference.

    - + Related distributions
    @@ -303,7 +303,7 @@ Distribution with its p parameter set to x.

    - + Accuracy

    @@ -315,7 +315,7 @@ please refer to these functions for information on accuracy.

    - + Implementation

    @@ -594,7 +594,7 @@

- + References

diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/binomial_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/binomial_dist.html index 73ba1bbc1..1973c364c 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/binomial_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/binomial_dist.html @@ -161,12 +161,12 @@

- + Member Functions
- + Construct
binomial_distribution(RealType n, RealType p);
@@ -183,7 +183,7 @@
             otherwise calls domain_error.
           

- + Accessors
RealType success_fraction() const;
@@ -199,7 +199,7 @@
             was constructed.
           

- + Lower Bound on the Success Fraction
@@ -305,7 +305,7 @@ limits illustrated in the case of the binomial. Biometrika 26 404-413.

- + Upper Bound on the Success Fraction
@@ -383,7 +383,7 @@
- + Estimating the Number of Trials Required for a Certain Number of Successes
@@ -425,7 +425,7 @@ of seeing 10 events that occur with frequency one half.

- + Estimating the Maximum Number of Trials to Ensure no more than a Certain Number of Successes @@ -473,7 +473,7 @@ Worked Example.

- + Non-member Accessors
@@ -622,7 +622,7 @@
- + Examples

@@ -630,7 +630,7 @@ examples are available illustrating the use of the binomial distribution.

- + Accuracy

@@ -640,7 +640,7 @@ please refer to these functions for information on accuracy.

- + Implementation

@@ -884,7 +884,7 @@

- + References
    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/cauchy_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/cauchy_dist.html index b4830197a..010654627 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/cauchy_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/cauchy_dist.html @@ -88,7 +88,7 @@

    - + Member Functions
    @@ -114,7 +114,7 @@ Returns the scale parameter of the distribution.

    - + Non-member Accessors
    @@ -148,7 +148,7 @@ The domain of the random variable is [-[max_value], +[min_value]].

    - + Accuracy

    @@ -157,7 +157,7 @@ have very low error rates.

    - + Implementation

    @@ -273,7 +273,7 @@

- + References
    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/chi_squared_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/chi_squared_dist.html index f7653c358..25e1a6c27 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/chi_squared_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/chi_squared_dist.html @@ -87,7 +87,7 @@ independent, normally distributed random

    - + Member Functions
    @@ -170,7 +170,7 @@ independent, normally distributed random NIST Engineering Statistics Handbook, Section 7.2.3.2.

    - + Non-member Accessors
    @@ -196,7 +196,7 @@ independent, normally distributed random The domain of the random variable is [0, +∞].

    - + Examples

    @@ -204,7 +204,7 @@ independent, normally distributed random are available illustrating the use of the Chi Squared Distribution.

    - + Accuracy

    @@ -212,7 +212,7 @@ independent, normally distributed random gamma functions: please refer to the accuracy data for those functions.

    - + Implementation

    @@ -379,7 +379,7 @@ independent, normally distributed random

- + References
    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/exp_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/exp_dist.html index b3682cbd8..085abbf90 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/exp_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/exp_dist.html @@ -71,7 +71,7 @@

    - + Member Functions
    @@ -91,7 +91,7 @@ Accessor function returns the lambda parameter of the distribution.

    - + Non-member Accessors
    @@ -111,7 +111,7 @@ The domain of the random variable is [0, +∞].

    - + Accuracy

    @@ -122,7 +122,7 @@ should have very low error rates.

    - + Implementation

    @@ -283,7 +283,7 @@

- + references
    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/extreme_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/extreme_dist.html index d33bfb65c..4612ad54c 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/extreme_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/extreme_dist.html @@ -100,7 +100,7 @@

    - + Member Functions
    @@ -125,7 +125,7 @@ Returns the scale parameter of the distribution.

    - + Non-member Accessors
    @@ -145,7 +145,7 @@ The domain of the random parameter is [-∞, +∞].

    - + Accuracy

    @@ -154,7 +154,7 @@ very low error rates.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/f_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/f_dist.html index d1561957d..17de4917e 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/f_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/f_dist.html @@ -80,7 +80,7 @@

    - + Member Functions
    @@ -106,7 +106,7 @@ Returns the denominator degrees of freedom parameter of the distribution.

    - + Non-member Accessors
    @@ -126,7 +126,7 @@ The domain of the random variable is [0, +∞].

    - + Examples

    @@ -134,7 +134,7 @@ are available illustrating the use of the F Distribution.

    - + Accuracy

    @@ -143,7 +143,7 @@ refer to those functions for accuracy data.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/gamma_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/gamma_dist.html index 13971981c..559e95cbc 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/gamma_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/gamma_dist.html @@ -137,7 +137,7 @@ than a dedicated Erlang Distribution.

    - + Member Functions
    @@ -162,7 +162,7 @@ Returns the scale parameter of this distribution.

    - + Non-member Accessors
    @@ -182,7 +182,7 @@ The domain of the random variable is [0,+∞].

    - + Accuracy

    @@ -194,7 +194,7 @@ refer to the accuracy data for those functions for more information.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/geometric_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/geometric_dist.html index 46a3adeac..89fff8778 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/geometric_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/geometric_dist.html @@ -146,7 +146,7 @@

    - + Related Distributions
    @@ -206,12 +206,12 @@
- + Member Functions
- + Constructor
geometric_distribution(RealType p);
@@ -226,7 +226,7 @@
             1.
           

- + Accessors
RealType success_fraction() const; // successes / trials (0 <= p <= 1)
@@ -253,7 +253,7 @@
             Binomial Distribution for more discussion.
           

- + Lower Bound on success_fraction Parameter p
@@ -308,7 +308,7 @@ vol. 48, no3, 605-621.

- + Upper Bound on success_fraction Parameter p
@@ -363,7 +363,7 @@ vol. 48, no3, 605-621.

- + Estimating Number of Trials to Ensure at Least a Certain Number of Failures
@@ -415,7 +415,7 @@ probability of observing k failures or fewer.

- + Estimating Number of Trials to Ensure a Maximum Number of Failures or Less
@@ -463,7 +463,7 @@ probability of observing more than k failures.

- + Non-member Accessors
@@ -611,7 +611,7 @@
- + Accuracy

@@ -622,7 +622,7 @@ for example to 10 decimal digits (from 16).

- + Implementation

diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/hypergeometric_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/hypergeometric_dist.html index 19cac83c7..0a586f7ab 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/hypergeometric_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/hypergeometric_dist.html @@ -102,7 +102,7 @@

- + Member Functions
@@ -131,7 +131,7 @@ from the population N.

- + Non-member Accessors
@@ -185,7 +185,7 @@
- + Accuracy

@@ -211,7 +211,7 @@ meaningless for N >= 1015.

- + Testing

@@ -223,7 +223,7 @@ this implementation and NTL::RR.

- + Implementation

diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_chi_squared_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_chi_squared_dist.html index 942e73d22..dd15e5f6a 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_chi_squared_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_chi_squared_dist.html @@ -198,7 +198,7 @@

- + Member Functions
@@ -225,7 +225,7 @@ Returns the scale ξ parameter of this distribution.

- + Non-member Accessors
@@ -255,7 +255,7 @@

- + Accuracy

@@ -271,7 +271,7 @@ iteration is involved, as for the estimation of degrees of freedom.

- + Implementation

@@ -452,7 +452,7 @@

- + References
    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_gamma_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_gamma_dist.html index 464526e62..abaa38cf1 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_gamma_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_gamma_dist.html @@ -130,7 +130,7 @@

    - + Member Functions
    @@ -154,7 +154,7 @@ Returns the β scale parameter of this inverse gamma distribution.

    - + Non-member Accessors
    @@ -184,7 +184,7 @@

- + Accuracy

@@ -198,7 +198,7 @@ >14 decimal digits accuracy for 64-bit double.

- + Implementation

diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_gaussian_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_gaussian_dist.html index aeb4969d8..e8fcb2c8c 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_gaussian_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_gaussian_dist.html @@ -146,7 +146,7 @@ the __wald_distrib (where mean μ is unity) is also provided.

- + Member Functions
@@ -171,7 +171,7 @@ Returns the scale λ parameter of this distribution.

- + Non-member Accessors
@@ -201,7 +201,7 @@

- + Accuracy

@@ -212,7 +212,7 @@ to a few epsilon, >14 decimal digits accuracy for 64-bit double.

- + Implementation

@@ -390,7 +390,7 @@

- + References
    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/laplace_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/laplace_dist.html index d94ce6aca..c064fba5e 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/laplace_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/laplace_dist.html @@ -81,7 +81,7 @@

    - + Member Functions
    @@ -113,7 +113,7 @@ Returns the scale parameter of this distribution.

    - + Non-member Accessors
    @@ -133,7 +133,7 @@ The domain of the random variable is [-∞,+∞].

    - + Accuracy

    @@ -141,7 +141,7 @@ log and exp functions and as such should have very small errors.

    - + Implementation

    @@ -329,7 +329,7 @@

- + References
    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/logistic_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/logistic_dist.html index 33bc55517..e5f34f7b0 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/logistic_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/logistic_dist.html @@ -72,7 +72,7 @@

    - + Member Functions
    @@ -98,7 +98,7 @@ Returns the scale of this distribution.

    - + Non-member Accessors
    @@ -128,7 +128,7 @@ as special cases if RealType and +overflow_error respectively.

    - + Accuracy

    @@ -140,7 +140,7 @@ as special cases if RealType error can be guarenteed.

    - + Implementation
    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/lognormal_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/lognormal_dist.html index 6612d0cd0..c29a89d40 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/lognormal_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/lognormal_dist.html @@ -88,7 +88,7 @@

    - + Member Functions
    @@ -121,7 +121,7 @@ Returns the scale parameter of this distribution.

    - + Non-member Accessors
    @@ -141,7 +141,7 @@ The domain of the random variable is [0,+∞].

    - + Accuracy

    @@ -150,7 +150,7 @@ function, and as such should have very low error rates.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_beta_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_beta_dist.html index ec8b92e83..7fd4c5e6c 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_beta_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_beta_dist.html @@ -96,7 +96,7 @@ is a central χ2 random variable with

    - + Member Functions
    @@ -128,7 +128,7 @@ is a central χ2 random variable with was constructed.

    - + Non-member Accessors
    @@ -156,7 +156,7 @@ is a central χ2 random variable with The domain of the random variable is [0, 1].

    - + Accuracy

    @@ -299,7 +299,7 @@ is a central χ2 random variable with functions are broadly similar.

    - + Tests

    @@ -311,7 +311,7 @@ is a central χ2 random variable with tests.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_chi_squared_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_chi_squared_dist.html index bead336a7..dbc6a232a 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_chi_squared_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_chi_squared_dist.html @@ -110,7 +110,7 @@

    - + Member Functions
    @@ -183,7 +183,7 @@ == q.

    - + Non-member Accessors
    @@ -203,7 +203,7 @@ The domain of the random variable is [0, +∞].

    - + Examples

    @@ -211,7 +211,7 @@ example for the noncentral chi-squared distribution.

    - + Accuracy

    @@ -359,7 +359,7 @@ produce an accuracy greater than the square root of the machine epsilon.

    - + Tests

    @@ -373,7 +373,7 @@ to at least 50 decimal digits - and is the used for our accuracy tests.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_f_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_f_dist.html index 15baf4e88..681c6faa0 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_f_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_f_dist.html @@ -95,7 +95,7 @@ random variable with v1

    - + Member Functions
    @@ -127,7 +127,7 @@ random variable with v1 which this object was constructed.

    - + Non-member Accessors
    @@ -147,7 +147,7 @@ random variable with v1 The domain of the random variable is [0, +∞].

    - + Accuracy

    @@ -155,7 +155,7 @@ random variable with v1 Beta Distribution: refer to that distribution for accuracy data.

    - + Tests

    @@ -164,7 +164,7 @@ random variable with v1 Math library statistical package and its pbeta and dbeta functions.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_t_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_t_dist.html index 94af031b8..11a801743 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_t_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_t_dist.html @@ -85,7 +85,7 @@

    - + Member Functions
    @@ -111,7 +111,7 @@ which this object was constructed.

    - + Non-member Accessors
    @@ -131,7 +131,7 @@ The domain of the random variable is [-∞, +∞].

    - + Accuracy

    @@ -255,7 +255,7 @@ epsilon.

    - + Tests

    @@ -270,7 +270,7 @@ least 50 decimal places.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/negative_binomial_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/negative_binomial_dist.html index ba5677117..446ac4291 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/negative_binomial_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/negative_binomial_dist.html @@ -123,7 +123,7 @@

    - + Related Distributions
    @@ -195,12 +195,12 @@
    - + Member Functions
    - + Construct
    negative_binomial_distribution(RealType r, RealType p);
    @@ -216,7 +216,7 @@
                 <= 1.
               

    - + Accessors
    RealType success_fraction() const; // successes / trials (0 <= p <= 1)
    @@ -237,7 +237,7 @@
                 Distribution for more discussion.
               

    - + Lower Bound on Parameter p
    @@ -298,7 +298,7 @@ vol. 48, no3, 605-621.

    - + Upper Bound on Parameter p
    @@ -358,7 +358,7 @@ vol. 48, no3, 605-621.

    - + Estimating Number of Trials to Ensure at Least a Certain Number of Failures
    @@ -409,7 +409,7 @@ probability of observing k failures or fewer.

    - + Estimating Number of Trials to Ensure a Maximum Number of Failures or Less
    @@ -457,7 +457,7 @@ probability of observing more than k failures.

    - + Non-member Accessors
    @@ -606,7 +606,7 @@

- + Accuracy

@@ -616,7 +616,7 @@ please refer to these functions for information on accuracy.

- + Implementation

diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/normal_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/normal_dist.html index 111d5b935..9dd7fbd9d 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/normal_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/normal_dist.html @@ -79,7 +79,7 @@

- + Member Functions
@@ -109,7 +109,7 @@ be used generically).

- + Non-member Accessors
@@ -131,7 +131,7 @@ and complement cdf -∞ = 1 and +∞ = 0, if RealType permits.

- + Accuracy

@@ -139,7 +139,7 @@ function, and as such should have very low error rates.

- + Implementation

diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/pareto.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/pareto.html index 53219189f..b45d1e139 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/pareto.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/pareto.html @@ -86,12 +86,12 @@

- + Related distributions
- + Member Functions
@@ -117,7 +117,7 @@ Returns the shape parameter of this distribution.

- + Non-member Accessors
@@ -137,7 +137,7 @@ The supported domain of the random variable is [scale, ∞].

- + Accuracy

@@ -150,7 +150,7 @@ zero) see also why complements?.

- + Implementation

@@ -318,7 +318,7 @@

- + References
    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/poisson_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/poisson_dist.html index 06d88f20d..85c6bfeef 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/poisson_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/poisson_dist.html @@ -116,7 +116,7 @@
- + Member Functions
@@ -131,7 +131,7 @@ Returns the mean of this distribution.

- + Non-member Accessors
@@ -151,7 +151,7 @@ The domain of the random variable is [0, ∞].

- + Accuracy

@@ -165,7 +165,7 @@ using an iterative method with a lower tolerance to avoid excessive computation.

- + Implementation

diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/rayleigh.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/rayleigh.html index 0872da035..7a2633c7f 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/rayleigh.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/rayleigh.html @@ -86,7 +86,7 @@

- + Related distributions
@@ -102,7 +102,7 @@ distribution.

- + Member Functions
@@ -121,7 +121,7 @@ Returns the sigma parameter of this distribution.

- + Non-member Accessors
@@ -141,7 +141,7 @@ The domain of the random variable is [0, max_value].

- + Accuracy

@@ -151,7 +151,7 @@ using NTL RR type with 150-bit accuracy, about 50 decimal digits.

- + Implementation

@@ -320,7 +320,7 @@

- + References
    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/students_t_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/students_t_dist.html index b59d77015..f8ed15f76 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/students_t_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/students_t_dist.html @@ -97,7 +97,7 @@

    - + Member Functions
    @@ -174,7 +174,7 @@ Engineering Statistics Handbook.

    - + Non-member Accessors
    @@ -194,7 +194,7 @@ The domain of the random variable is [-∞, +∞].

    - + Examples

    @@ -202,7 +202,7 @@ are available illustrating the use of the Student's t distribution.

    - + Accuracy

    @@ -211,7 +211,7 @@ inverses, refer to accuracy data on those functions for more information.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/triangular_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/triangular_dist.html index fb2e73e18..3a5386d1f 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/triangular_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/triangular_dist.html @@ -128,7 +128,7 @@

    - + Member Functions
    @@ -163,7 +163,7 @@ (default+1).

    - + Non-member Accessors
    @@ -184,7 +184,7 @@ range is lower <= x <= upper.

    - + Accuracy

    @@ -193,7 +193,7 @@ with arguments nearing the extremes of zero and unity.

    - + Implementation

    @@ -378,7 +378,7 @@ Calculate and plot probability distributions

    - + References
      diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/uniform_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/uniform_dist.html index 25d2a8c69..cb56cd703 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/uniform_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/uniform_dist.html @@ -117,7 +117,7 @@

      - + Member Functions
      @@ -144,7 +144,7 @@ Returns the upper parameter of this distribution.

      - + Non-member Accessors
      @@ -165,7 +165,7 @@ range is only lower <= x <= upper.

      - + Accuracy

      @@ -173,7 +173,7 @@ and so should have errors within an epsilon or two.

      - + Implementation

      @@ -337,7 +337,7 @@

    - + References
      diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/weibull_dist.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/weibull_dist.html index c28cc833b..27813ce4a 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/weibull_dist.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/weibull_dist.html @@ -100,7 +100,7 @@

      - + Related distributions
      @@ -114,7 +114,7 @@ Distributions, Theory and Applications Samuel Kotz & Saralees Nadarajah.

      - + Member Functions
      @@ -140,7 +140,7 @@ Returns the scale parameter of this distribution.

      - + Non-member Accessors
      @@ -160,7 +160,7 @@ The domain of the random variable is [0, ∞].

      - + Accuracy

      @@ -170,7 +170,7 @@ as such should have very low error rates.

      - + Implementation

      @@ -337,7 +337,7 @@

    - + References
      diff --git a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/nmp.html b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/nmp.html index 497bd14ee..c36ba88f6 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/nmp.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/nmp.html @@ -37,7 +37,7 @@ the function you want if you already know its name.

      - + Function Index
        @@ -94,7 +94,7 @@
      - + Conceptual Index
        @@ -180,7 +180,7 @@
      - + Cumulative Distribution Function
      template <class RealType, class Policy>
      @@ -203,7 +203,7 @@
                 cdf
               

      - + Complement of the Cumulative Distribution Function
      template <class Distribution, class RealType>
      @@ -243,7 +243,7 @@
                 complement is useful and when it should be used.
               

      - + Hazard Function
      template <class RealType, class Policy>
      @@ -271,7 +271,7 @@
                 

    - + Cumulative Hazard Function
    template <class RealType, class Policy>
    @@ -298,7 +298,7 @@
               

- + mean
template<class RealType, class Policy>
@@ -313,7 +313,7 @@
           distribution).
         

- + median
template<class RealType, class Policy>
@@ -323,7 +323,7 @@
           Returns the median of the distribution dist.
         

- + mode
template<class RealType, Policy>
@@ -337,7 +337,7 @@
           if the distribution does not have a defined mode.
         

- + Probability Density Function
template <class RealType, class Policy>
@@ -365,7 +365,7 @@
           pdf
         

- + Range
template<class RealType, class Policy>
@@ -375,7 +375,7 @@
           Returns the valid range of the random variable over distribution dist.
         

- + Quantile
template <class RealType, class Policy>
@@ -405,7 +405,7 @@
           quantile
         

- + Quantile from the complement of the probability.

@@ -450,7 +450,7 @@ survival_inv

- + Standard Deviation
template <class RealType, class Policy>
@@ -464,7 +464,7 @@
           if the distribution does not have a defined standard deviation.
         

- + support
template<class RealType, class Policy>
@@ -481,7 +481,7 @@
           where the pdf is zero, and the cdf zero or unity.
         

- + Variance
template <class RealType, class Policy>
@@ -495,7 +495,7 @@
           if the distribution does not have a defined variance.
         

- + Skewness
template <class RealType, class Policy>
@@ -509,7 +509,7 @@
           if the distribution does not have a defined skewness.
         

- + Kurtosis
template <class RealType, class Policy>
@@ -551,7 +551,7 @@
           'Proper' kurtosis can have a value from zero to + infinity.
         

- + Kurtosis excess
template <class RealType, Policy>
@@ -585,7 +585,7 @@
           The kurtosis excess of a normal distribution is zero.
         

- + P and Q

@@ -595,7 +595,7 @@ returned by these functions.

- + Percent Point Function or Percentile

@@ -603,7 +603,7 @@ the Quantile.

- + Inverse CDF Function.

@@ -611,14 +611,14 @@ Quantile.

- + Inverse Survival Function.

The inverse of the survival function, is the same as computing the quantile from the complement of the probability.

- + Probability Mass Function

@@ -631,7 +631,7 @@ applies to continuous distributions.

- + Lower Critical Value.

@@ -640,7 +640,7 @@ the Quantile.

- + Upper Critical Value.

@@ -650,7 +650,7 @@ complement of the probability.

- + Survival Function

diff --git a/doc/sf_and_dist/html/math_toolkit/dist/future.html b/doc/sf_and_dist/html/math_toolkit/dist/future.html index 50afab276..a28dbba1c 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/future.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/future.html @@ -27,7 +27,7 @@ Extras/Future Directions

- + Adding Additional Location and Scale Parameters
@@ -55,7 +55,7 @@ functions.

- + An "any_distribution" class
@@ -91,7 +91,7 @@ investigation.

- + Higher Level Hypothesis Tests
@@ -111,7 +111,7 @@ expected_mean.

- + Integration With Statistical Accumulators
diff --git a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/binom_eg/binomial_quiz_example.html b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/binom_eg/binomial_quiz_example.html index 2785c7a11..f01867991 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/binom_eg/binomial_quiz_example.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/binom_eg/binomial_quiz_example.html @@ -379,7 +379,7 @@ Probability of getting between 1 and 8 answers right by guessing is 0.9825 Probability of getting between 4 and 4 answers right by guessing is 0.2252
- + Using Binomial distribution moments
@@ -406,7 +406,7 @@ Mode (the most frequent) is 4 Skewness is 0.2887
- + Quantiles

diff --git a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/cs_eg/chi_sq_intervals.html b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/cs_eg/chi_sq_intervals.html index 1a7873a00..a02997a1a 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/cs_eg/chi_sq_intervals.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/cs_eg/chi_sq_intervals.html @@ -139,7 +139,7 @@ _____________________________________________ is between 0.00551 and 0.00729.

- + Confidence intervals as a function of the number of observations
diff --git a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/dist_construct_eg.html b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/dist_construct_eg.html index 412f3ecf3..f59dfdc78 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/dist_construct_eg.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/dist_construct_eg.html @@ -246,7 +246,7 @@ error C3861: 'mybetad0': identifier not found
negative_binomial_distribution<MyFPType>  mydist6(8, 1); // Integer arguments -> MyFPType.
 
- + Default arguments to distribution constructors.
diff --git a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/find_eg/find_location_eg.html b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/find_eg/find_location_eg.html index 7eeb116be..10c9ec9f9 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/find_eg/find_location_eg.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/find_eg/find_location_eg.html @@ -138,7 +138,7 @@ Normal distribution with mean = 0, standard deviation 1, has fraction > -2, p Normal distribution with mean = 1.09023 has fraction > -2, p = 0.999
- + Controlling Error Handling from find_location
diff --git a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/find_eg/find_mean_and_sd_eg.html b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/find_eg/find_mean_and_sd_eg.html index 7d979de0e..f9409478c 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/find_eg/find_mean_and_sd_eg.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/find_eg/find_mean_and_sd_eg.html @@ -57,7 +57,7 @@

- + Using find_location and find_scale to meet dispensing and measurement specifications
@@ -193,7 +193,7 @@

- + Using Cauchy-Lorentz instead of normal distribution
@@ -305,7 +305,7 @@ of estimating these intervals.

- + Changing the scale or standard deviation
diff --git a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/find_eg/find_scale_eg.html b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/find_eg/find_scale_eg.html index 0f2920492..4d98f4c52 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/find_eg/find_scale_eg.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/find_eg/find_scale_eg.html @@ -137,7 +137,7 @@ Normal distribution with mean = 0 has fraction > -2, p = 0.97725 Normal distribution with mean = 0 has fraction > -2, p = 0.999
- + Controlling how Errors from find_scale are handled
diff --git a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/geometric_eg.html b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/geometric_eg.html index 6f4aa5a26..b198d32f6 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/geometric_eg.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/geometric_eg.html @@ -94,7 +94,7 @@ error message instead of an abrupt (and silent) program abort.

- + Throwing a dice
@@ -288,7 +288,7 @@ replicated in C++ if desired.

- + Surveying customers to find one with a faulty product
@@ -333,7 +333,7 @@

- + Basket Ball Shooters
@@ -393,7 +393,7 @@ the best shooters, compared to the 0.03 of the mediocre.

- + Estimating failures
@@ -489,7 +489,7 @@ Number of failures argument is -1, but must be >= 0 !

- See full source C++ of this example at geometric_examples.cpp + See full source C++ of this example at geometric_examples.cpp

See diff --git a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/normal_example/normal_misc.html b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/normal_example/normal_misc.html index 7a8691f6f..892118f4f 100644 --- a/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/normal_example/normal_misc.html +++ b/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/normal_example/normal_misc.html @@ -32,7 +32,7 @@ illustrates their use.

- + Traditional Tables
@@ -230,7 +230,7 @@ the two tails is 0.025 + 0.025 = 0.05,

- + Standard deviations either side of the Mean
@@ -280,12 +280,12 @@ Fraction 3 standard deviations within either side of mean is 0.997300203936740 estimated the standard deviation from only a few measurements.

- + Some simple examples
- + Life of light bulbs
@@ -351,7 +351,7 @@ Fraction 3 standard deviations within either side of mean is 0.997300203936740

- + How many onions?
@@ -396,7 +396,7 @@ Fraction 3 standard deviations within either side of mean is 0.997300203936740

- + Packing beef
@@ -565,7 +565,7 @@ Fraction 3 standard deviations within either side of mean is 0.997300203936740 a few measurements.

- + Length of bolts
diff --git a/doc/sf_and_dist/html/math_toolkit/extern_c/c99.html b/doc/sf_and_dist/html/math_toolkit/extern_c/c99.html index e267cb9b2..6072d64d0 100644 --- a/doc/sf_and_dist/html/math_toolkit/extern_c/c99.html +++ b/doc/sf_and_dist/html/math_toolkit/extern_c/c99.html @@ -27,7 +27,7 @@ C99 C Functions
- + Supported C99 Functions
@@ -138,7 +138,7 @@ acosh(2); // integer argument is treated as a double, returns double.
- + Quick Reference

diff --git a/doc/sf_and_dist/html/math_toolkit/extern_c/tr1.html b/doc/sf_and_dist/html/math_toolkit/extern_c/tr1.html index d2295e2b4..ad4d28d23 100644 --- a/doc/sf_and_dist/html/math_toolkit/extern_c/tr1.html +++ b/doc/sf_and_dist/html/math_toolkit/extern_c/tr1.html @@ -258,7 +258,7 @@

- + Usage Recomendations

@@ -295,7 +295,7 @@ this can be a big win.

- + Supported C99 Functions
@@ -391,7 +391,7 @@ }}}} // namespaces
- + Supported TR1 Functions
@@ -520,7 +520,7 @@ type calculation rules
.

- + Currently Unsupported C99 Functions
@@ -585,7 +585,7 @@ long double scalbnl(long double x, int ex);
- + Currently Unsupported TR1 Functions
diff --git a/doc/sf_and_dist/html/math_toolkit/extern_c/tr1_ref.html b/doc/sf_and_dist/html/math_toolkit/extern_c/tr1_ref.html index 350f5e5cf..082d33d05 100644 --- a/doc/sf_and_dist/html/math_toolkit/extern_c/tr1_ref.html +++ b/doc/sf_and_dist/html/math_toolkit/extern_c/tr1_ref.html @@ -28,7 +28,7 @@ Reference
- + Supported TR1 Functions
@@ -163,7 +163,7 @@ expint(2); // integer argument is treated as a double, returns double.
- + Quick Reference
// [5.2.1.1] associated Laguerre polynomials:
@@ -494,7 +494,7 @@
         for the full template (header only) version of this function.
       

- + Currently Unsupported TR1 Functions
diff --git a/doc/sf_and_dist/html/math_toolkit/main_overview/building.html b/doc/sf_and_dist/html/math_toolkit/main_overview/building.html index c7612f110..65bbc9128 100644 --- a/doc/sf_and_dist/html/math_toolkit/main_overview/building.html +++ b/doc/sf_and_dist/html/math_toolkit/main_overview/building.html @@ -28,7 +28,7 @@ a Boost.Math Library, and its Examples and Tests
- + Building a Library (shared, dynamic .dll or static .lib)
@@ -100,7 +100,7 @@ building the sources. Boost.Build will do this automatically when appropriate.

- + Building the Examples
@@ -111,7 +111,7 @@ the Boost headers are in your compilers #include search path.

- + Building the Tests
diff --git a/doc/sf_and_dist/html/math_toolkit/main_overview/directories.html b/doc/sf_and_dist/html/math_toolkit/main_overview/directories.html index 183097a5f..630721b58 100644 --- a/doc/sf_and_dist/html/math_toolkit/main_overview/directories.html +++ b/doc/sf_and_dist/html/math_toolkit/main_overview/directories.html @@ -28,7 +28,7 @@ File Structure
- + boost/math
@@ -73,7 +73,7 @@
- + boost/libs
diff --git a/doc/sf_and_dist/html/math_toolkit/main_overview/error_handling.html b/doc/sf_and_dist/html/math_toolkit/main_overview/error_handling.html index 79d362f57..a485221c2 100644 --- a/doc/sf_and_dist/html/math_toolkit/main_overview/error_handling.html +++ b/doc/sf_and_dist/html/math_toolkit/main_overview/error_handling.html @@ -27,7 +27,7 @@ Error Handling
- + Quick Reference
@@ -747,7 +747,7 @@ boost::math::policies::overflow_error;.

- + Rationale

@@ -766,7 +766,7 @@

- + Finding More Information
@@ -788,7 +788,7 @@ The various kind of errors are described in more detail below.

- + Domain Errors

@@ -859,7 +859,7 @@ for more details.

- + Evaluation at a pole

@@ -897,7 +897,7 @@ for more details.

- + Numeric Overflow

@@ -921,7 +921,7 @@ doesn't support infinities, the maximum value for the type is returned.

- + Numeric Underflow

@@ -943,7 +943,7 @@ an std::underflow_error C++ exception.

- + Denormalisation Errors

@@ -965,7 +965,7 @@ throws an std::underflow_error C++ exception.

- + Evaluation Errors

@@ -1001,7 +1001,7 @@ for more details.

- + Indeterminate Result Errors

@@ -1029,7 +1029,7 @@ the result of 00 is 1, even though the result is actually mathematically indeterminate.

- + Rounding Errors

@@ -1068,7 +1068,7 @@ for more details.

- + Errors from typecasts

diff --git a/doc/sf_and_dist/html/math_toolkit/main_overview/faq.html b/doc/sf_and_dist/html/math_toolkit/main_overview/faq.html index d4455c763..150768354 100644 --- a/doc/sf_and_dist/html/math_toolkit/main_overview/faq.html +++ b/doc/sf_and_dist/html/math_toolkit/main_overview/faq.html @@ -174,6 +174,11 @@ be able to gain a little more speed at the expense of accuracy. See detailed suggestions and results on performance. +

  • + How do I handle infinity and NaNs portably?
    + See nonfinite fp_facets + for Facets for Floating-Point Infinities and NaNs. +
  • Where are the pre-built libraries?
    Good news - you probably don't need any! - just #include <boost/math/distribution_you_want>. diff --git a/doc/sf_and_dist/html/math_toolkit/main_overview/history1.html b/doc/sf_and_dist/html/math_toolkit/main_overview/history1.html index 020fbdab6..ffe28cb3b 100644 --- a/doc/sf_and_dist/html/math_toolkit/main_overview/history1.html +++ b/doc/sf_and_dist/html/math_toolkit/main_overview/history1.html @@ -27,8 +27,25 @@ History and What's New +
    + + Boost-1.47 +
    +
      +
    • + Added changesign function to sign.hpp to facilitate addition of nonfinite + facets. +
    • +
    • + Addition of nonfinite facetsfrom Johan Rade, with tests, examples of + use for C99 format infinity and NaN, and documentation. +
    • +
    • + Added tests and documentation of changesign from Johan Rade. +
    • +
    - + Boost-1.46.1
    • @@ -36,7 +53,7 @@ #5113.
    - + Boost-1.46.0
      @@ -47,11 +64,11 @@ Added information about configuration macros.
    • - Added support for mpreal as a real-numered type. + Added support for mpreal as a real-numbered type.
    - + Boost-1.45.0
      @@ -68,7 +85,7 @@
    - + Boost-1.44.0
      @@ -82,7 +99,7 @@
    - + Boost-1.41.0
    • @@ -90,7 +107,7 @@ and its inverse.
    - + Boost-1.40.0
      @@ -127,7 +144,7 @@
    - + Boost-1.38.0
      @@ -139,14 +156,14 @@
    - + Boost-1.37.0
    • Improved accuracy and testing of the inverse hypergeometric functions.
    - + Boost-1.36.0
      @@ -179,7 +196,7 @@
    - + Boost-1.35.0: Post Review First Official Release
    @@ -211,7 +228,7 @@
  • - + Milestone 4: Second Review Candidate (1st March 2007)
    @@ -225,7 +242,7 @@
    - + Milestone 3: First Review Candidate (31st Dec 2006)
    @@ -253,7 +270,7 @@
    - + Milestone 2: Released September 10th 2006
    @@ -289,7 +306,7 @@
    - + Milestone 1: Released March 31st 2006
    diff --git a/doc/sf_and_dist/html/math_toolkit/main_overview/intro.html b/doc/sf_and_dist/html/math_toolkit/main_overview/intro.html index a6acd7700..50a7380fc 100644 --- a/doc/sf_and_dist/html/math_toolkit/main_overview/intro.html +++ b/doc/sf_and_dist/html/math_toolkit/main_overview/intro.html @@ -30,7 +30,7 @@ This library is divided into three interconnected parts:

    - + Statistical Distributions
    @@ -56,7 +56,7 @@ tests.

    - + Mathematical Special Functions
    @@ -83,7 +83,7 @@ double.

    - + Implementation Toolkit
    diff --git a/doc/sf_and_dist/html/math_toolkit/main_overview/navigation.html b/doc/sf_and_dist/html/math_toolkit/main_overview/navigation.html index 4547c0d01..aa624f307 100644 --- a/doc/sf_and_dist/html/math_toolkit/main_overview/navigation.html +++ b/doc/sf_and_dist/html/math_toolkit/main_overview/navigation.html @@ -31,7 +31,7 @@ as handy shortcuts for common navigation tasks.

    - + Shortcuts
    diff --git a/doc/sf_and_dist/html/math_toolkit/main_overview/tr1.html b/doc/sf_and_dist/html/math_toolkit/main_overview/tr1.html index 2dc628a00..5c66f0974 100644 --- a/doc/sf_and_dist/html/math_toolkit/main_overview/tr1.html +++ b/doc/sf_and_dist/html/math_toolkit/main_overview/tr1.html @@ -259,7 +259,7 @@

    - + Usage Recomendations
    @@ -297,7 +297,7 @@ this can be a big win.

    - + Supported C99 Functions
    @@ -393,7 +393,7 @@ }}}} // namespaces
    - + Supported TR1 Functions
    @@ -522,7 +522,7 @@ type calculation rules
    .

    - + Currently Unsupported C99 Functions
    @@ -587,7 +587,7 @@ long double scalbnl(long double x, int ex);
    - + Currently Unsupported TR1 Functions
    diff --git a/doc/sf_and_dist/html/math_toolkit/perf/comp_compilers.html b/doc/sf_and_dist/html/math_toolkit/perf/comp_compilers.html index 36f00ba4e..3e553468d 100644 --- a/doc/sf_and_dist/html/math_toolkit/perf/comp_compilers.html +++ b/doc/sf_and_dist/html/math_toolkit/perf/comp_compilers.html @@ -35,7 +35,7 @@ in this respect).

    -

    Table 51. Performance Comparison of Various Windows Compilers

    +

    Table 52. Performance Comparison of Various Windows Compilers

    diff --git a/doc/sf_and_dist/html/math_toolkit/perf/comparisons.html b/doc/sf_and_dist/html/math_toolkit/perf/comparisons.html index 24a5fefcd..e262f0b1a 100644 --- a/doc/sf_and_dist/html/math_toolkit/perf/comparisons.html +++ b/doc/sf_and_dist/html/math_toolkit/perf/comparisons.html @@ -46,7 +46,7 @@

    - + Comparison to GSL-1.13 and Cephes
    @@ -344,7 +344,7 @@

    - +INF [1] + +INF [1]

    @@ -423,7 +423,7 @@

    -

    17.89[2]

    +

    17.89[2]

    (4.248e-005s)

    @@ -548,11 +548,11 @@ -

    [1] +

    [1] Cephes gets stuck in an infinite loop while trying to execute our test cases.

    -

    [2] +

    [2] The performance here is dominated by a few cases where the parameters grow very large: faster asymptotic expansions are available, but are of limited (or even frankly terrible) precision. The @@ -563,7 +563,7 @@

    - + Comparison to the R and DCDFLIB Statistical Libraries on Windows
    @@ -574,7 +574,7 @@ (R-2.9.2 appears not to be buildable with Visual C++).

    -

    Table 54. A Comparison to the R Statistical Library on Windows XP

    +

    Table 55. A Comparison to the R Statistical Library on Windows XP

    @@ -659,7 +659,7 @@

    -

    67.66[1]

    +

    67.66[1]

    (3.366e-004s)

    @@ -1088,7 +1088,7 @@

    -

    3.60[2]

    +

    3.60[2]

    (5.987e-007s)

    @@ -1317,7 +1317,7 @@

    -

    43.43[3]

    +

    43.43[3]

    (3.732e-004s)

    @@ -1387,7 +1387,7 @@

    -

    393.90[4]

    +

    393.90[4]

    (2.673e-002s)

    @@ -1523,7 +1523,7 @@

    -

    1.00[5]

    +

    1.00[5]

    (4.411e-004s)

    @@ -1809,28 +1809,28 @@

    -

    [1] +

    [1] There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.

    -

    [2] +

    [2] This result is somewhat misleading: for small values of the parameters there is virtually no difference between the two libraries, but for large values the Boost implementation is much slower, albeit with much improved precision.

    -

    [3] +

    [3] The R library appears to use a linear-search strategy, that can perform very badly in a small number of pathological cases, but may or may not be more efficient in "typical" cases

    -

    [4] +

    [4] There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.

    -

    [5] +

    [5] There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result. @@ -1839,7 +1839,7 @@


    - + Comparison to the R Statistical Library on Linux
    @@ -1849,7 +1849,7 @@ G++ 4.3.3 using -O3 -DNDEBUG=1.

    -

    Table 55. A Comparison to the R Statistical Library on Linux

    +

    Table 56. A Comparison to the R Statistical Library on Linux

    @@ -1934,7 +1934,7 @@

    -

    30.51[1]

    +

    30.51[1]

    (3.616e-004s)

    @@ -2363,7 +2363,7 @@

    -

    2.20[2]

    +

    2.20[2]

    (3.522e-007s)

    @@ -2592,7 +2592,7 @@

    -

    25.92[3]

    +

    25.92[3]

    (4.407e-004s)

    @@ -2662,7 +2662,7 @@

    -

    144.91[4]

    +

    144.91[4]

    (3.214e-002s)

    @@ -2798,7 +2798,7 @@

    -

    1.00[5]

    +

    1.00[5]

    (5.916e-004s)

    @@ -3084,28 +3084,28 @@

    -

    [1] +

    [1] There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.

    -

    [2] +

    [2] This result is somewhat misleading: for small values of the parameters there is virtually no difference between the two libraries, but for large values the Boost implementation is much slower, albeit with much improved precision.

    -

    [3] +

    [3] The R library appears to use a linear-search strategy, that can perform very badly in a small number of pathological cases, but may or may not be more efficient in "typical" cases

    -

    [4] +

    [4] There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.

    -

    [5] +

    [5] There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result. diff --git a/doc/sf_and_dist/html/math_toolkit/perf/getting_best.html b/doc/sf_and_dist/html/math_toolkit/perf/getting_best.html index a9ef76714..0081042ee 100644 --- a/doc/sf_and_dist/html/math_toolkit/perf/getting_best.html +++ b/doc/sf_and_dist/html/math_toolkit/perf/getting_best.html @@ -33,7 +33,7 @@ penalty for using the library in debug mode can be quite large.

    -

    Table 50. Performance Comparison of Release and Debug Settings

    +

    Table 51. Performance Comparison of Release and Debug Settings

    diff --git a/doc/sf_and_dist/html/math_toolkit/perf/tuning.html b/doc/sf_and_dist/html/math_toolkit/perf/tuning.html index 37235d960..765c666b2 100644 --- a/doc/sf_and_dist/html/math_toolkit/perf/tuning.html +++ b/doc/sf_and_dist/html/math_toolkit/perf/tuning.html @@ -238,7 +238,7 @@ highly vectorisable processors in the future.

    -

    Table 52. A Comparison of Polynomial Evaluation Methods

    +

    Table 53. A Comparison of Polynomial Evaluation Methods

    @@ -638,7 +638,7 @@ tutorial.

    -

    Table 53. Performance Comparison with and Without Internal Promotion to long +

    Table 54. Performance Comparison with and Without Internal Promotion to long double

    diff --git a/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/discrete_quant_ref.html b/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/discrete_quant_ref.html index 95ec08245..8e79f575b 100644 --- a/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/discrete_quant_ref.html +++ b/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/discrete_quant_ref.html @@ -55,7 +55,7 @@ can take have the following meanings:

    - + real

    @@ -89,7 +89,7 @@ = 68.1584.

    - + integer_round_outwards

    @@ -143,7 +143,7 @@ in each tail.

    - + integer_round_inwards

    @@ -202,7 +202,7 @@ in each tail.

    - + integer_round_down

    @@ -210,7 +210,7 @@ or a lower quantile.

    - + integer_round_up

    @@ -218,7 +218,7 @@ a lower quantile.

    - + integer_round_nearest

    diff --git a/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/error_handling_policies.html b/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/error_handling_policies.html index a0d7bc1be..6329048d1 100644 --- a/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/error_handling_policies.html +++ b/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/error_handling_policies.html @@ -39,7 +39,7 @@

    - + Available Actions When an Error is Raised
    @@ -62,7 +62,7 @@ The various enumerated values have the following meanings:

    - + throw_on_error

    @@ -174,7 +174,7 @@

    - + errno_on_error

    @@ -289,7 +289,7 @@

    - + ignore_error

    @@ -402,7 +402,7 @@

    - + user_error

    @@ -451,7 +451,7 @@ here.

    - + Kinds of Error Raised
    @@ -691,7 +691,7 @@
    - + Examples

    diff --git a/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/internal_promotion.html b/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/internal_promotion.html index c31c722f2..d58b526bf 100644 --- a/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/internal_promotion.html +++ b/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/internal_promotion.html @@ -85,7 +85,7 @@

    - + Examples

    diff --git a/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/policy_defaults.html b/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/policy_defaults.html index 9c79f2ded..daf615c1c 100644 --- a/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/policy_defaults.html +++ b/doc/sf_and_dist/html/math_toolkit/policy/pol_ref/policy_defaults.html @@ -61,7 +61,7 @@ then you can do so by defining various macros in boost/math/tools/user.hpp.

    - + BOOST_MATH_DOMAIN_ERROR_POLICY

    @@ -71,7 +71,7 @@ ignore_error or user_error.

    - + BOOST_MATH_POLE_ERROR_POLICY

    @@ -81,7 +81,7 @@ ignore_error or user_error.

    - + BOOST_MATH_OVERFLOW_ERROR_POLICY

    @@ -91,7 +91,7 @@ ignore_error or user_error.

    - + BOOST_MATH_ROUNDING_ERROR_POLICY

    @@ -101,7 +101,7 @@ ignore_error or user_error.

    - + BOOST_MATH_EVALUATION_ERROR_POLICY

    @@ -111,7 +111,7 @@ ignore_error or user_error.

    - + BOOST_MATH_UNDERFLOW_ERROR_POLICY

    @@ -121,7 +121,7 @@ ignore_error or user_error.

    - + BOOST_MATH_DENORM_ERROR_POLICY

    @@ -131,7 +131,7 @@ ignore_error or user_error.

    - + BOOST_MATH_INDETERMINATE_RESULT_ERROR_POLICY

    @@ -142,7 +142,7 @@ ignore_error or user_error.

    - + BOOST_MATH_DIGITS10_POLICY

    @@ -153,7 +153,7 @@ recommended that you change this from the default.

    - + BOOST_MATH_PROMOTE_FLOAT_POLICY

    @@ -165,7 +165,7 @@ off.

    - + BOOST_MATH_PROMOTE_DOUBLE_POLICY

    @@ -177,7 +177,7 @@ off.

    - + BOOST_MATH_DISCRETE_QUANTILE_POLICY

    @@ -188,7 +188,7 @@ Defaults to integer_round_outwards.

    - + BOOST_MATH_ASSERT_UNDEFINED_POLICY

    @@ -201,7 +201,7 @@ whether or not a particular property is well defined.

    - + BOOST_MATH_MAX_SERIES_ITERATION_POLICY

    @@ -210,7 +210,7 @@ Defaults to 1000000.

    - + BOOST_MATH_MAX_ROOT_ITERATION_POLICY

    @@ -219,7 +219,7 @@ Defaults to 200.

    - + Example

    diff --git a/doc/sf_and_dist/html/math_toolkit/policy/pol_tutorial/understand_dis_quant.html b/doc/sf_and_dist/html/math_toolkit/policy/pol_tutorial/understand_dis_quant.html index 9be7d37cd..f37e5ed9a 100644 --- a/doc/sf_and_dist/html/math_toolkit/policy/pol_tutorial/understand_dis_quant.html +++ b/doc/sf_and_dist/html/math_toolkit/policy/pol_tutorial/understand_dis_quant.html @@ -177,7 +177,7 @@ base your comparisons on CDF's instead.

    - + Other Rounding Policies are Available
    diff --git a/doc/sf_and_dist/html/math_toolkit/special/bessel/bessel.html b/doc/sf_and_dist/html/math_toolkit/special/bessel/bessel.html index e216c2a79..74089b1f3 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/bessel/bessel.html +++ b/doc/sf_and_dist/html/math_toolkit/special/bessel/bessel.html @@ -28,7 +28,7 @@ of the First and Second Kinds
    - + Synopsis
    template <class T1, class T2>
    @@ -44,7 +44,7 @@
     calculated-result-type cyl_neumann(T1 v, T2 x, const Policy&);
     
    - + Description

    @@ -105,7 +105,7 @@

    - + Testing

    @@ -114,7 +114,7 @@ (with all the special case handling removed).

    - + Accuracy

    @@ -489,7 +489,7 @@ were found.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/bessel/bessel_over.html b/doc/sf_and_dist/html/math_toolkit/special/bessel/bessel_over.html index 2a3edfbd9..dca8bf811 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/bessel/bessel_over.html +++ b/doc/sf_and_dist/html/math_toolkit/special/bessel/bessel_over.html @@ -28,7 +28,7 @@ Overview

    - + Ordinary Bessel Functions
    @@ -103,7 +103,7 @@ and is known as either a Bessel

    - + Modified Bessel Functions
    @@ -167,7 +167,7 @@ respectively:

    - + Spherical Bessel Functions
    diff --git a/doc/sf_and_dist/html/math_toolkit/special/bessel/mbessel.html b/doc/sf_and_dist/html/math_toolkit/special/bessel/mbessel.html index 4f0247a90..dc9a60d2a 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/bessel/mbessel.html +++ b/doc/sf_and_dist/html/math_toolkit/special/bessel/mbessel.html @@ -28,7 +28,7 @@ Functions of the First and Second Kinds
    - + Synopsis
    template <class T1, class T2>
    @@ -44,7 +44,7 @@
     calculated-result-type cyl_bessel_k(T1 v, T2 x, const Policy&);
     
    - + Description

    @@ -104,7 +104,7 @@

    - + Testing

    @@ -113,7 +113,7 @@ (with all the special case handling removed).

    - + Accuracy

    @@ -321,7 +321,7 @@

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/bessel/sph_bessel.html b/doc/sf_and_dist/html/math_toolkit/special/bessel/sph_bessel.html index 67a478758..7fab8e00b 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/bessel/sph_bessel.html +++ b/doc/sf_and_dist/html/math_toolkit/special/bessel/sph_bessel.html @@ -28,7 +28,7 @@ Functions of the First and Second Kinds

    - + Synopsis
    template <class T1, class T2>
    @@ -44,7 +44,7 @@
     calculated-result-type sph_neumann(unsigned v, T2 x, const Policy&);
     
    - + Description

    @@ -92,7 +92,7 @@ for small x:

    - + Testing

    @@ -101,7 +101,7 @@ for small x: implementation (with all the special case handling removed).

    - + Accuracy

    @@ -111,7 +111,7 @@ for small x: refer to these functions for accuracy data.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_1.html b/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_1.html index 744b6e47a..0fb5f999c 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_1.html +++ b/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_1.html @@ -28,7 +28,7 @@ of the First Kind - Legendre Form

    - + Synopsis

    @@ -55,7 +55,7 @@ }} // namespaces

    - + Description

    @@ -113,7 +113,7 @@ it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

    - + Accuracy

    @@ -225,7 +225,7 @@

    - + Testing

    @@ -235,7 +235,7 @@ this implementation.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_2.html b/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_2.html index 068c0006a..8556335ce 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_2.html +++ b/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_2.html @@ -28,7 +28,7 @@ of the Second Kind - Legendre Form

    - + Synopsis

    @@ -55,7 +55,7 @@ }} // namespaces

    - + Description

    @@ -113,7 +113,7 @@ it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

    - + Accuracy

    @@ -225,7 +225,7 @@

    - + Testing

    @@ -235,7 +235,7 @@ this implementation.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_3.html b/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_3.html index 7baca2422..9443957a0 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_3.html +++ b/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_3.html @@ -28,7 +28,7 @@ of the Third Kind - Legendre Form

    - + Synopsis

    @@ -55,7 +55,7 @@ }} // namespaces

    - + Description

    @@ -119,7 +119,7 @@ it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

    - + Accuracy

    @@ -231,7 +231,7 @@

    - + Testing

    @@ -241,7 +241,7 @@ this implementation.

    - + Implementation

    @@ -278,7 +278,7 @@ Π(n, φ+mπ, k) = Π(n, φ, k) + 2mΠ(n, k) ; n <= 1

    - Π(n, φ+mπ, k) = Π(n, φ, k) ; n > 1 [1] + Π(n, φ+mπ, k) = Π(n, φ, k) ; n > 1 [1]

    are used to move φ   to the range [0, π/2]. @@ -298,7 +298,7 @@



    -

    [1] +

    [1] I haven't been able to find a literature reference for this relation, but it appears to be the convention used by Mathematica. Intuitively the first 2 * m * Π(n, k) terms cancel out as the diff --git a/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_carlson.html b/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_carlson.html index 1cf0d37f5..df29c09fc 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_carlson.html +++ b/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_carlson.html @@ -28,7 +28,7 @@ Integrals - Carlson Form

    - + Synopsis

    @@ -100,7 +100,7 @@ }} // namespaces

    - + Description

    @@ -216,7 +216,7 @@

    - + Testing

    @@ -239,7 +239,7 @@ to verify their correctness: see the above Carlson paper for details.

    - + Accuracy

    @@ -393,7 +393,7 @@

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_intro.html b/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_intro.html index a7499311b..679dc5920 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_intro.html +++ b/doc/sf_and_dist/html/math_toolkit/special/ellint/ellint_intro.html @@ -49,14 +49,14 @@ Elliptic integral.

    - + Notation

    All variables are real numbers unless otherwise noted.

    - + Definition

    @@ -245,7 +245,7 @@

    - + Duplication Theorem

    @@ -256,7 +256,7 @@

    - + Carlson's Formulas

    @@ -273,7 +273,7 @@

    - + Numerical Algorithms
    @@ -287,7 +287,7 @@ integrals with satisfactory precisions.

    - + References

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/expint/expint_i.html b/doc/sf_and_dist/html/math_toolkit/special/expint/expint_i.html index a37ebc4bf..d6b10b3c9 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/expint/expint_i.html +++ b/doc/sf_and_dist/html/math_toolkit/special/expint/expint_i.html @@ -28,7 +28,7 @@ Ei

    - + Synopsis

    @@ -58,7 +58,7 @@ it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

    - + Description
    template <class T>
    @@ -78,7 +78,7 @@
               
             

    - + Accuracy

    @@ -202,7 +202,7 @@ slightly over the range [4,6].

    - + Testing

    @@ -217,7 +217,7 @@ check.

    - + Implementation

    @@ -247,7 +247,7 @@ a minimax rational approximation rescaled so that it is evaluated over [-1,1]. Note that while the rational approximation over [0,6] converges rapidly to the minimax solution it is rather ill-conditioned in practice. - Cody and Thacher [2] experienced the same issue and converted the polynomials into + Cody and Thacher [2] experienced the same issue and converted the polynomials into Chebeshev form to ensure stable computation. By experiment we found that the polynomials are just as stable in polynomial as Chebyshev form, provided they are computed over the interval [-1,1]. @@ -277,7 +277,7 @@



    -

    [2] +

    [2] W. J. Cody and H. C. Thacher, Jr., Rational Chebyshev approximations for the exponential integral E1(x), Math. Comp. 22 (1968), 641-649, and W. J. Cody and H. C. Thacher, Jr., Chebyshev approximations for the exponential diff --git a/doc/sf_and_dist/html/math_toolkit/special/expint/expint_n.html b/doc/sf_and_dist/html/math_toolkit/special/expint/expint_n.html index 874f489c8..d5e95bd57 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/expint/expint_n.html +++ b/doc/sf_and_dist/html/math_toolkit/special/expint/expint_n.html @@ -28,7 +28,7 @@ En

    - + Synopsis

    @@ -58,7 +58,7 @@ it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

    - + Description
    template <class T>
    @@ -78,7 +78,7 @@
               
             

    - + Accuracy

    @@ -220,7 +220,7 @@

    - + Testing

    @@ -235,7 +235,7 @@ check.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_binomial.html b/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_binomial.html index cf26610d6..9b1894226 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_binomial.html +++ b/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_binomial.html @@ -90,7 +90,7 @@

    - + Accuracy

    @@ -99,14 +99,14 @@ function for larger arguments.

    - + Testing

    The spot tests for the binomial coefficients use data generated by functions.wolfram.com.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_double_factorial.html b/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_double_factorial.html index ab2f755d1..430453322 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_double_factorial.html +++ b/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_double_factorial.html @@ -106,7 +106,7 @@

    - + Accuracy

    @@ -114,14 +114,14 @@ so error rates should be no more than a couple of epsilon higher.

    - + Testing

    The spot tests for the double factorial use data generated by functions.wolfram.com.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_factorial.html b/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_factorial.html index 00e180223..809b8aebf 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_factorial.html +++ b/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_factorial.html @@ -27,7 +27,7 @@ Factorial

    - + Synopsis

    @@ -54,7 +54,7 @@ }} // namespaces

    - + Description
    @@ -157,7 +157,7 @@ the size of further tables that depend on the factorials.

    - + Accuracy

    @@ -166,7 +166,7 @@ will be the same as for tgamma.

    - + Testing

    @@ -175,7 +175,7 @@ function handle those cases already.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_falling_factorial.html b/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_falling_factorial.html index 4b862d666..09003cae1 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_falling_factorial.html +++ b/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_falling_factorial.html @@ -71,7 +71,7 @@ the type of the result is T.

    - + Accuracy

    @@ -79,14 +79,14 @@ function.

    - + Testing

    The spot tests for the falling factorials use data generated by functions.wolfram.com.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_rising_factorial.html b/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_rising_factorial.html index 34ca091a9..e44054eda 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_rising_factorial.html +++ b/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_rising_factorial.html @@ -75,7 +75,7 @@ the type of the result is T.

    - + Accuracy

    @@ -83,14 +83,14 @@ function.

    - + Testing

    The spot tests for the rising factorials use data generated by functions.wolfram.com.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/inv_hyper/acosh.html b/doc/sf_and_dist/html/math_toolkit/special/inv_hyper/acosh.html index ca9b89f4c..777ff9015 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/inv_hyper/acosh.html +++ b/doc/sf_and_dist/html/math_toolkit/special/inv_hyper/acosh.html @@ -62,14 +62,14 @@

    - + Accuracy

    Generally accuracy is to within 1 or 2 epsilon across all supported platforms.

    - + Testing

    @@ -85,7 +85,7 @@ to at least 50 decimal digits.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/inv_hyper/asinh.html b/doc/sf_and_dist/html/math_toolkit/special/inv_hyper/asinh.html index beb1c928a..c9d9822c6 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/inv_hyper/asinh.html +++ b/doc/sf_and_dist/html/math_toolkit/special/inv_hyper/asinh.html @@ -57,14 +57,14 @@ it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

    - + Accuracy

    Generally accuracy is to within 1 or 2 epsilon across all supported platforms.

    - + Testing

    @@ -80,7 +80,7 @@ to at least 50 decimal digits.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/inv_hyper/atanh.html b/doc/sf_and_dist/html/math_toolkit/special/inv_hyper/atanh.html index 88afa9510..b64906065 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/inv_hyper/atanh.html +++ b/doc/sf_and_dist/html/math_toolkit/special/inv_hyper/atanh.html @@ -71,14 +71,14 @@ denoting

    - + Accuracy

    Generally accuracy is to within 1 or 2 epsilon across all supported platforms.

    - + Testing

    @@ -94,7 +94,7 @@ denoting to at least 50 decimal digits.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/powers/cbrt.html b/doc/sf_and_dist/html/math_toolkit/special/powers/cbrt.html index 8d04e84f0..3143cc57e 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/powers/cbrt.html +++ b/doc/sf_and_dist/html/math_toolkit/special/powers/cbrt.html @@ -66,7 +66,7 @@

    - + Accuracy

    @@ -74,7 +74,7 @@ should have approximately 2 epsilon accuracy.

    - + Testing

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/powers/ct_pow.html b/doc/sf_and_dist/html/math_toolkit/special/powers/ct_pow.html index b3b351db2..9f4cd83be 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/powers/ct_pow.html +++ b/doc/sf_and_dist/html/math_toolkit/special/powers/ct_pow.html @@ -32,7 +32,7 @@ computes the compile-time integral power of a run-time base.

    - + Synopsis

    @@ -49,7 +49,7 @@ }}

    - + Rationale and Usage
    @@ -91,7 +91,7 @@ Only 3 different products were actually computed.

    - + Return Type

    @@ -112,7 +112,7 @@

    - + Policies

    @@ -121,7 +121,7 @@ it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

    - + Error Handling
    @@ -227,7 +227,7 @@ doubleresult=pow<-5>(base);
    - + Acknowledgements

    @@ -238,7 +238,7 @@ improving the implementation.

    - + References

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/powers/expm1.html b/doc/sf_and_dist/html/math_toolkit/special/powers/expm1.html index 8a2c3b380..ed79aaf0a 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/powers/expm1.html +++ b/doc/sf_and_dist/html/math_toolkit/special/powers/expm1.html @@ -75,7 +75,7 @@

    - + Accuracy

    @@ -83,7 +83,7 @@ should have approximately 1 epsilon accuracy.

    - + Testing

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/powers/hypot.html b/doc/sf_and_dist/html/math_toolkit/special/powers/hypot.html index 7f8c9ca67..367f7c1a3 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/powers/hypot.html +++ b/doc/sf_and_dist/html/math_toolkit/special/powers/hypot.html @@ -53,7 +53,7 @@ in such a representable.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/powers/log1p.html b/doc/sf_and_dist/html/math_toolkit/special/powers/log1p.html index cb1d1b2d7..0afff0f73 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/powers/log1p.html +++ b/doc/sf_and_dist/html/math_toolkit/special/powers/log1p.html @@ -88,7 +88,7 @@

    - + Accuracy

    @@ -96,7 +96,7 @@ should have approximately 1 epsilon accuracy.

    - + Testing

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/powers/powm1.html b/doc/sf_and_dist/html/math_toolkit/special/powers/powm1.html index 3effbe272..c0eefc58e 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/powers/powm1.html +++ b/doc/sf_and_dist/html/math_toolkit/special/powers/powm1.html @@ -69,14 +69,14 @@

    - + Accuracy

    Should have approximately 2-3 epsilon accuracy.

    - + Testing

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/powers/sqrt1pm1.html b/doc/sf_and_dist/html/math_toolkit/special/powers/sqrt1pm1.html index d1249075b..8467942a5 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/powers/sqrt1pm1.html +++ b/doc/sf_and_dist/html/math_toolkit/special/powers/sqrt1pm1.html @@ -71,7 +71,7 @@

    - + Accuracy

    @@ -79,7 +79,7 @@ should have approximately 3 epsilon accuracy.

    - + Testing

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_beta/beta_derivative.html b/doc/sf_and_dist/html/math_toolkit/special/sf_beta/beta_derivative.html index c214c678a..43d5c103b 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_beta/beta_derivative.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_beta/beta_derivative.html @@ -28,7 +28,7 @@ of the Incomplete Beta Function

    - + Synopsis

    @@ -49,7 +49,7 @@ }} // namespaces

    - + Description

    @@ -71,14 +71,14 @@ it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

    - + Accuracy

    Almost identical to the incomplete beta function ibeta.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_beta/beta_function.html b/doc/sf_and_dist/html/math_toolkit/special/sf_beta/beta_function.html index abb53f35e..8e2aba032 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_beta/beta_function.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_beta/beta_function.html @@ -27,7 +27,7 @@ Beta

    - + Synopsis

    @@ -48,7 +48,7 @@ }} // namespaces

    - + Description

    @@ -81,7 +81,7 @@ type calculation rules when T1 and T2 are different types.

    - + Accuracy

    @@ -239,7 +239,7 @@ very small.

    - + Testing

    @@ -248,7 +248,7 @@ at 1000-bit precision.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_beta/ibeta_function.html b/doc/sf_and_dist/html/math_toolkit/special/sf_beta/ibeta_function.html index 3bc2995a3..593057935 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_beta/ibeta_function.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_beta/ibeta_function.html @@ -28,7 +28,7 @@ Beta Functions

    - + Synopsis

    @@ -67,7 +67,7 @@ }} // namespaces

    - + Description

    @@ -158,7 +158,7 @@

    - + Accuracy

    @@ -865,7 +865,7 @@


    - + Testing

    @@ -883,7 +883,7 @@ have test data that is fully independent of the code.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_beta/ibeta_inv_function.html b/doc/sf_and_dist/html/math_toolkit/special/sf_beta/ibeta_inv_function.html index d0ed00d8f..6851231e5 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_beta/ibeta_inv_function.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_beta/ibeta_inv_function.html @@ -87,7 +87,7 @@ }} // namespaces

    - + Description

    @@ -288,7 +288,7 @@ it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

    - + Accuracy

    @@ -300,7 +300,7 @@ or 1.

    - + Testing

    @@ -324,7 +324,7 @@

    - + Implementation of ibeta_inv and ibetac_inv
    @@ -492,7 +492,7 @@ rapidly converges on the true value.

    - + Implementation of inverses on the a and b parameters
    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_erf/error_function.html b/doc/sf_and_dist/html/math_toolkit/special/sf_erf/error_function.html index eab39db89..1fce31d5f 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_erf/error_function.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_erf/error_function.html @@ -27,7 +27,7 @@ Error Functions
    - + Synopsis

    @@ -63,7 +63,7 @@ it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

    - + Description
    template <class T>
    @@ -100,7 +100,7 @@
               
             

    - + Accuracy

    @@ -525,7 +525,7 @@

    - + Testing

    @@ -540,7 +540,7 @@ check.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_erf/error_inv.html b/doc/sf_and_dist/html/math_toolkit/special/sf_erf/error_inv.html index 2fc001ec5..ec5d4f253 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_erf/error_inv.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_erf/error_inv.html @@ -28,7 +28,7 @@ Inverses

    - + Synopsis

    @@ -64,7 +64,7 @@ it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

    - + Description
    template <class T>
    @@ -98,7 +98,7 @@
               
             

    - + Accuracy

    @@ -108,7 +108,7 @@ error functions.

    - + Testing

    @@ -131,7 +131,7 @@

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/digamma.html b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/digamma.html index 04d6d60b2..254cc7020 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/digamma.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/digamma.html @@ -27,7 +27,7 @@ Digamma

    - + Synopsis

    @@ -48,7 +48,7 @@ }} // namespaces

    - + Description

    @@ -77,7 +77,7 @@ T otherwise.

    - + Accuracy

    @@ -265,7 +265,7 @@ absolute error will remain very low.

    - + Testing

    @@ -275,7 +275,7 @@ see below).

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/gamma_derivatives.html b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/gamma_derivatives.html index 6684ebcc5..e434934e3 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/gamma_derivatives.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/gamma_derivatives.html @@ -28,7 +28,7 @@ of the Incomplete Gamma Function

    - + Synopsis

    @@ -49,7 +49,7 @@ }} // namespaces

    - + Description

    @@ -75,7 +75,7 @@ otherwise the return type is simply T1.

    - + Accuracy

    @@ -83,7 +83,7 @@ refer to the documentation for that function for more information.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/gamma_ratios.html b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/gamma_ratios.html index beaf22d0b..7dcd835d2 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/gamma_ratios.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/gamma_ratios.html @@ -51,7 +51,7 @@ }} // namespaces

    - + Description
    template <class T1, class T2> 
    @@ -107,7 +107,7 @@
               
             

    - + Accuracy

    @@ -317,7 +317,7 @@

    - + Testing

    @@ -326,7 +326,7 @@ a deliberately naive calculation of Γ(x)/Γ(y).

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/igamma.html b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/igamma.html index 21f590152..d58856306 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/igamma.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/igamma.html @@ -28,7 +28,7 @@ Functions

    - + Synopsis

    @@ -67,7 +67,7 @@ }} // namespaces

    - + Description

    @@ -155,7 +155,7 @@

    - + Accuracy

    @@ -823,7 +823,7 @@

    - + Testing

    @@ -839,7 +839,7 @@ fraction (see below) is unstable for small a and z.

    - + Implementation

    @@ -1008,7 +1008,7 @@ by Temme (see references below).

    - + References
      diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/igamma_inv.html b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/igamma_inv.html index 4fd952b9c..2710e61f5 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/igamma_inv.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/igamma_inv.html @@ -28,7 +28,7 @@ Gamma Function Inverses
    - + Synopsis

    @@ -67,7 +67,7 @@ }} // namespaces

    - + Description

    @@ -168,7 +168,7 @@ 0.

    - + Accuracy

    @@ -182,7 +182,7 @@ functions.

    - + Testing

    @@ -206,7 +206,7 @@

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/lgamma.html b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/lgamma.html index 7f52ea1d4..4e6381d58 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/lgamma.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/lgamma.html @@ -27,7 +27,7 @@ Log Gamma

    - + Synopsis

    @@ -54,7 +54,7 @@ }} // namespaces

    - + Description

    @@ -93,7 +93,7 @@ T otherwise.

    - + Accuracy

    @@ -344,7 +344,7 @@

    - + Testing

    @@ -355,7 +355,7 @@ Random tests in key problem areas are also used.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/tgamma.html b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/tgamma.html index a60ec7dd6..c74c873ae 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/tgamma.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/tgamma.html @@ -27,7 +27,7 @@ Gamma

    - + Synopsis

    @@ -54,7 +54,7 @@ }} // namespaces

    - + Description
    template <class T>
    @@ -119,7 +119,7 @@
               it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.
             

    - + Accuracy

    @@ -374,7 +374,7 @@

    - + Testing

    @@ -389,7 +389,7 @@ a lanczos approximation accurate to around 100 decimal digits.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_poly/hermite.html b/doc/sf_and_dist/html/math_toolkit/special/sf_poly/hermite.html index d214fd35b..42e0ac8c6 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_poly/hermite.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_poly/hermite.html @@ -27,7 +27,7 @@ Hermite Polynomials

    - + Synopsis

    @@ -51,7 +51,7 @@ }} // namespaces

    - + Description

    @@ -131,7 +131,7 @@

    - + Accuracy

    @@ -248,7 +248,7 @@ is very close to a root.

    - + Testing

    @@ -258,7 +258,7 @@ precision.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_poly/laguerre.html b/doc/sf_and_dist/html/math_toolkit/special/sf_poly/laguerre.html index 1785e1ac2..8d6d2ad97 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_poly/laguerre.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_poly/laguerre.html @@ -28,7 +28,7 @@ Associated) Polynomials

    - + Synopsis

    @@ -62,7 +62,7 @@ }} // namespaces

    - + Description

    @@ -205,7 +205,7 @@

    - + Accuracy

    @@ -422,7 +422,7 @@ is very close to a root.

    - + Testing

    @@ -432,7 +432,7 @@ precision.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_poly/legendre.html b/doc/sf_and_dist/html/math_toolkit/special/sf_poly/legendre.html index 532ac8f08..945034f81 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_poly/legendre.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_poly/legendre.html @@ -28,7 +28,7 @@ Associated) Polynomials

    - + Synopsis

    @@ -79,7 +79,7 @@ it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

    - + Description
    template <class T>
    @@ -295,7 +295,7 @@
     
     
     
    - + Accuracy

    @@ -676,7 +676,7 @@ given here.

    - + Testing

    @@ -686,7 +686,7 @@ precision.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/sf_poly/sph_harm.html b/doc/sf_and_dist/html/math_toolkit/special/sf_poly/sph_harm.html index b1022fefa..96d5e5ed5 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/sf_poly/sph_harm.html +++ b/doc/sf_and_dist/html/math_toolkit/special/sf_poly/sph_harm.html @@ -27,7 +27,7 @@ Spherical Harmonics

    - + Synopsis

    @@ -60,7 +60,7 @@ }} // namespaces

    - + Description

    @@ -150,7 +150,7 @@

    - + Accuracy

    @@ -271,7 +271,7 @@ arbitrarily large when the function is very close to a root.

    - + Testing

    @@ -281,7 +281,7 @@ precision.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/special/zetas/zeta.html b/doc/sf_and_dist/html/math_toolkit/special/zetas/zeta.html index 930621d5e..4ef7f3eee 100644 --- a/doc/sf_and_dist/html/math_toolkit/special/zetas/zeta.html +++ b/doc/sf_and_dist/html/math_toolkit/special/zetas/zeta.html @@ -27,7 +27,7 @@ Riemann Zeta Function

    - + Synopsis

    @@ -57,7 +57,7 @@ it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

    - + Description
    template <class T>
    @@ -80,7 +80,7 @@
               
             

    - + Accuracy

    @@ -229,7 +229,7 @@

    - + Testing

    @@ -244,7 +244,7 @@ check.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/status/credits.html b/doc/sf_and_dist/html/math_toolkit/status/credits.html index 8f3ae32e3..b749b1996 100644 --- a/doc/sf_and_dist/html/math_toolkit/status/credits.html +++ b/doc/sf_and_dist/html/math_toolkit/status/credits.html @@ -53,7 +53,18 @@ code.

    - Johan Råde wrote the optimised floating point classification code. + Johan Råde wrote the optimised floating-point classification and manipulation + code, and nonfinite facets to permit C99 output of infinities and NaNs. (nonfinite + facets were not added until Boost 1.47 but had been in use with Boost.Spirit). + This library was based on a suggestion from Robert Ramey, author of Boost.Serialization. + Paul A. Bristow expressed the need for better handling of Input + & Output of NaN and infinity for the C++ Standard Library and + suggested following the C99 format. +

    +

    + Håkan Ardö, Boris Gubenko, John Maddock, Markus Schöpflin and Olivier Verdier + tested the floating-point library and Martin Bonner, Peter Dimov and John + Maddock provided valuable advice.

    Gautam Sewani coded the logistic distribution as part of a Google Summer diff --git a/doc/sf_and_dist/html/math_toolkit/status/history1.html b/doc/sf_and_dist/html/math_toolkit/status/history1.html index 8734954e4..7bef6de00 100644 --- a/doc/sf_and_dist/html/math_toolkit/status/history1.html +++ b/doc/sf_and_dist/html/math_toolkit/status/history1.html @@ -26,8 +26,25 @@

    +
    + + Boost-1.47 +
    +
      +
    • + Added changesign function to sign.hpp to facilitate addition of nonfinite + facets. +
    • +
    • + Addition of nonfinite facetsfrom Johan Rade, with tests, examples of + use for C99 format infinity and NaN, and documentation. +
    • +
    • + Added tests and documentation of changesign from Johan Rade. +
    • +
    - + Boost-1.46.1
    • @@ -35,7 +52,7 @@ #5113.
    - + Boost-1.46.0
      @@ -46,11 +63,11 @@ Added information about configuration macros.
    • - Added support for mpreal as a real-numered type. + Added support for mpreal as a real-numbered type.
    - + Boost-1.45.0
      @@ -67,7 +84,7 @@
    - + Boost-1.44.0
      @@ -81,7 +98,7 @@
    - + Boost-1.41.0
    • @@ -89,7 +106,7 @@ and its inverse.
    - + Boost-1.40.0
      @@ -126,7 +143,7 @@
    - + Boost-1.38.0
      @@ -138,14 +155,14 @@
    - + Boost-1.37.0
    • Improved accuracy and testing of the inverse hypergeometric functions.
    - + Boost-1.36.0
      @@ -178,7 +195,7 @@
    - + Boost-1.35.0: Post Review First Official Release
    @@ -210,7 +227,7 @@
    - + Milestone 4: Second Review Candidate (1st March 2007)
    @@ -224,7 +241,7 @@
    - + Milestone 3: First Review Candidate (31st Dec 2006)
    @@ -252,7 +269,7 @@
    - + Milestone 2: Released September 10th 2006
    @@ -288,7 +305,7 @@
    - + Milestone 1: Released March 31st 2006
    diff --git a/doc/sf_and_dist/html/math_toolkit/status/issues.html b/doc/sf_and_dist/html/math_toolkit/status/issues.html index ad2535b68..eddfc5f79 100644 --- a/doc/sf_and_dist/html/math_toolkit/status/issues.html +++ b/doc/sf_and_dist/html/math_toolkit/status/issues.html @@ -40,7 +40,7 @@ with it.

    - + tgamma
    • @@ -48,7 +48,7 @@ be optimized any further? (low priority)
    - + Incomplete Beta
    • @@ -56,7 +56,7 @@ b (medium priority).
    - + Inverse Gamma
    • @@ -64,7 +64,7 @@ is good enough (Medium Priority).
    - + Polynomials
    • @@ -74,7 +74,7 @@ not (Low Priority).
    - + Elliptic Integrals
      @@ -127,7 +127,7 @@
    - + Inverse Hyperbolic Functions
    @@ -137,7 +137,7 @@ This is probably only an issue for very high precision types (Low Priority).
    - + Statistical distributions
    @@ -146,7 +146,7 @@ for very large degrees of freedom?
    - + Feature Requests

    diff --git a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/cf.html b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/cf.html index a5bed6fc3..b802d9b02 100644 --- a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/cf.html +++ b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/cf.html @@ -28,7 +28,7 @@ Evaluation

    - + Synopsis

    @@ -78,7 +78,7 @@ }}} // namespaces

    - + Description

    @@ -178,7 +178,7 @@ a continued fraction for convergence.

    - + Implementation

    @@ -188,7 +188,7 @@ Lentz, W.J. 1976, Applied Optics, vol. 15, pp. 668-671.

    - + Examples

    diff --git a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/constants.html b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/constants.html index 53b9fb90f..ab38823bf 100644 --- a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/constants.html +++ b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/constants.html @@ -28,7 +28,7 @@ Constants

    - + Synopsis

    @@ -59,7 +59,7 @@ }}} // namespaces

    - + Description

    diff --git a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/minima.html b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/minima.html index 12965aa19..d2e323f95 100644 --- a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/minima.html +++ b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/minima.html @@ -28,7 +28,7 @@ Minima: Brent's algorithm

    - + synopsis

    @@ -45,7 +45,7 @@ std::pair<T, T> brent_find_minima(F f, T min, T max, int bits, boost::uintmax_t& max_iter);

    - + Description

    @@ -90,7 +90,7 @@ the abscissa at the minima and the value of f(x) at the minima.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/rational.html b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/rational.html index d5ec09bda..6df6d86f9 100644 --- a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/rational.html +++ b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/rational.html @@ -28,7 +28,7 @@ and Rational Function Evaluation

    - + synopsis

    @@ -79,7 +79,7 @@ V evaluate_rational(const T* num, const U* denom, V z, unsigned count);

    - + Description

    @@ -193,7 +193,7 @@ evaluation with compile-time array sizes may offer slightly better performance.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/roots.html b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/roots.html index 0f160500e..883d4a2b0 100644 --- a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/roots.html +++ b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/roots.html @@ -28,7 +28,7 @@ With Derivatives: Newton-Raphson, Halley & Schroeder

    - + Synopsis

    @@ -62,7 +62,7 @@ }}} // namespaces

    - + Description

    @@ -206,7 +206,7 @@

    - + Newton Raphson Method
    @@ -224,7 +224,7 @@ iteration.

    - + Halley's Method
    @@ -246,7 +246,7 @@ iteration.

    - + Schroeder's Method
    @@ -270,7 +270,7 @@ iteration.

    - + Example

    diff --git a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/roots2.html b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/roots2.html index 8700fb789..aad0827f5 100644 --- a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/roots2.html +++ b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/roots2.html @@ -28,7 +28,7 @@ Without Derivatives: Bisection, Bracket and TOMS748

    - + Synopsis

    @@ -144,7 +144,7 @@ }}} // namespaces

    - + Description

    @@ -181,7 +181,7 @@ to be used only rarely, but may be useful in some specific circumstances.

    - + Bisection
    template <class F, class T, class Tol>
    @@ -280,7 +280,7 @@
               tol was satisfied.
             

    - + Bracket and solve
    @@ -388,7 +388,7 @@ was satisfied.

    - + Algorithm TOMS 748: Alefeld, Potra and Shi: Enclosing zeros of continuous functions
    @@ -554,7 +554,7 @@ as soon as both ends of the interval round to the same nearest integer.

    - + Implementation

    diff --git a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/series_evaluation.html b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/series_evaluation.html index 632bbf9d8..415dcc2d2 100644 --- a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/series_evaluation.html +++ b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/series_evaluation.html @@ -28,7 +28,7 @@ Evaluation

    - + Synopsis

    @@ -70,7 +70,7 @@ }}} // namespaces

    - + Description

    @@ -127,7 +127,7 @@ summation in this way.

    - + Example

    diff --git a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/tuples.html b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/tuples.html index 159c61566..aed7a2ec3 100644 --- a/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/tuples.html +++ b/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/tuples.html @@ -27,7 +27,7 @@ Tuples

    - + Synopsis

    @@ -38,7 +38,7 @@

    - + Description

    diff --git a/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/error_test.html b/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/error_test.html index 71aa7d4ee..86b8665b0 100644 --- a/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/error_test.html +++ b/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/error_test.html @@ -28,7 +28,7 @@ Error and Testing

    - + Synopsis

    @@ -45,7 +45,7 @@ test_result<see-below> test(const A& a, F1 test_func, F2 expect_func);

    - + Description
    template <class T>
    @@ -157,7 +157,7 @@
               is mainly a debugging/development aid (and a good place for a breakpoint).
             

    - + Example

    diff --git a/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/polynomials.html b/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/polynomials.html index 6f15c0c7b..f897078de 100644 --- a/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/polynomials.html +++ b/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/polynomials.html @@ -27,7 +27,7 @@ Polynomials

    - + Synopsis

    @@ -103,7 +103,7 @@ }}} // namespaces

    - + Description

    diff --git a/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/test_data.html b/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/test_data.html index e86580cdb..70783476f 100644 --- a/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/test_data.html +++ b/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/test_data.html @@ -46,7 +46,7 @@

    - + Synopsis
    namespace boost{ namespace math{ namespace tools{
    @@ -147,7 +147,7 @@
     }}} // namespaces
     
    - + Description

    @@ -177,7 +177,7 @@

    - + Example 1: Output Data for Graph Plotting
    @@ -211,7 +211,7 @@

    - + Example 2: Creating Test Data
    @@ -376,7 +376,7 @@ used by default as it's rather hard on the compiler when the table is large.

    - + Example 3: Profiling a Continued Fraction for Convergence and Accuracy
    @@ -482,7 +482,7 @@ of a and z.

    - + reference

    diff --git a/doc/sf_and_dist/html/math_toolkit/using_udt.html b/doc/sf_and_dist/html/math_toolkit/using_udt.html index 86e5eee6f..2d07e0a76 100644 --- a/doc/sf_and_dist/html/math_toolkit/using_udt.html +++ b/doc/sf_and_dist/html/math_toolkit/using_udt.html @@ -32,6 +32,7 @@ Floating-Point Library

    Using With MPFR / GMP - a High-Precision Floating-Point Library
    +
    e_float Support
    Conceptual Requirements for Real Number Types
    Conceptual Requirements diff --git a/doc/sf_and_dist/html/math_toolkit/using_udt/archetypes.html b/doc/sf_and_dist/html/math_toolkit/using_udt/archetypes.html index b67508766..d32535cbe 100644 --- a/doc/sf_and_dist/html/math_toolkit/using_udt/archetypes.html +++ b/doc/sf_and_dist/html/math_toolkit/using_udt/archetypes.html @@ -39,7 +39,7 @@
    - + Real concept

    @@ -84,7 +84,7 @@ declaration.

    - + Testing the real concept

    @@ -130,7 +130,7 @@ double, also tests real_concept.

    - + Distribution Concept

    @@ -166,7 +166,7 @@ class for distribution types.

    - + Testing the distribution concept

    diff --git a/doc/sf_and_dist/html/math_toolkit/using_udt/concepts.html b/doc/sf_and_dist/html/math_toolkit/using_udt/concepts.html index 4952a487d..241b7a445 100644 --- a/doc/sf_and_dist/html/math_toolkit/using_udt/concepts.html +++ b/doc/sf_and_dist/html/math_toolkit/using_udt/concepts.html @@ -6,7 +6,7 @@ - + @@ -20,7 +20,7 @@
    -PrevUpHomeNext +PrevUpHomeNext

    @@ -42,7 +42,7 @@ behaves just like a built in floating point type.

    - + Basic Arithmetic Requirements
    @@ -1035,7 +1035,7 @@
    - + Standard Library Support Requirements
    @@ -1361,7 +1361,7 @@
    -PrevUpHomeNext +PrevUpHomeNext
    diff --git a/doc/sf_and_dist/html/math_toolkit/using_udt/e_float.html b/doc/sf_and_dist/html/math_toolkit/using_udt/e_float.html new file mode 100644 index 000000000..8636d9926 --- /dev/null +++ b/doc/sf_and_dist/html/math_toolkit/using_udt/e_float.html @@ -0,0 +1,59 @@ + + + +e_float Support + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + +

    + This library can be used with e_float + (TOMS Algorithm 910) via the header: +

    +
    <boost/math/bindings/e_float.hpp>
    +
    +

    + And the type boost::math::ef::e_float: + this type is a thin wrapper class around ::e_float which provides the necessary + syntactic sugar to make everything "just work". +

    +

    + There is also a concept checking test program for e_float support here. +

    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/sf_and_dist/html/math_toolkit/using_udt/use_mpfr.html b/doc/sf_and_dist/html/math_toolkit/using_udt/use_mpfr.html index 768ad1918..c8cd1646f 100644 --- a/doc/sf_and_dist/html/math_toolkit/using_udt/use_mpfr.html +++ b/doc/sf_and_dist/html/math_toolkit/using_udt/use_mpfr.html @@ -7,7 +7,7 @@ - + @@ -20,7 +20,7 @@

    -PrevUpHomeNext +PrevUpHomeNext

    @@ -105,7 +105,7 @@
    -PrevUpHomeNext +PrevUpHomeNext
    diff --git a/doc/sf_and_dist/html/math_toolkit/utils.html b/doc/sf_and_dist/html/math_toolkit/utils.html index f8f328187..63a0f7cb4 100644 --- a/doc/sf_and_dist/html/math_toolkit/utils.html +++ b/doc/sf_and_dist/html/math_toolkit/utils.html @@ -36,9 +36,18 @@ Part Splitting (modf)

    Floating-Point Classification: - Infinities and NaN's
    + Infinities and NaNs
    Sign Manipulation Functions
    +
    Facets for Floating-Point + Infinities and NaNs
    +
    +
    Introduction
    +
    Reference
    +
    Examples
    +
    Portability
    +
    Design Rationale
    +
    Floating-Point Representation Distance (ULP), and Finding Adjacent Floating-Point Values
    diff --git a/doc/sf_and_dist/html/math_toolkit/utils/fp_facets.html b/doc/sf_and_dist/html/math_toolkit/utils/fp_facets.html new file mode 100644 index 000000000..fe3650621 --- /dev/null +++ b/doc/sf_and_dist/html/math_toolkit/utils/fp_facets.html @@ -0,0 +1,91 @@ + + + +Facets for Floating-Point Infinities and NaNs + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + + +
    + + Synopsis +
    +
    namespace boost{ namespace math
    +{
    +  // Values for flags. 
    +  const int legacy;
    +  const int signed_zero;
    +  const int trap_infinity;
    +  const int trap_nan;
    +
    +  template<
    +      class CharType,
    +      class OutputIterator = std::ostreambuf_iterator<CharType> 
    +  >
    +  class nonfinite_num_put : public std::num_put<CharType, OutputIterator>
    +  { 
    +  public:
    +      explicit nonfinite_num_put(int flags = 0);
    +  };
    +
    +  template<
    +      class CharType,
    +      class InputIterator = std::istreambuf_iterator<CharType>
    +  >
    +  class nonfinite_num_get : public std::num_get<CharType, InputIterator>
    +  {
    +  public:
    +      explicit nonfinite_num_get(int flags = 0);  // legacy, sign_zero ...
    +  }; 
    +}} // namespace boost namespace math
    +
    +

    + To use these facets +

    +
    #include <boost\math\special_functions\nonfinite_num_facets.hpp>
    +
    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/examples.html b/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/examples.html new file mode 100644 index 000000000..8f1a438d6 --- /dev/null +++ b/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/examples.html @@ -0,0 +1,249 @@ + + + +Examples + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + +
    + + Simple + example with std::stringstreams +
    +

    + +

    +
    locale old_locale;
    +locale tmp_locale(old_locale, new nonfinite_num_put<char>);
    +locale new_locale(tmp_locale, new nonfinite_num_get<char>);
    +
    +

    +

    +

    + +

    +
    stringstream ss;
    +ss.imbue(new_locale);
    +double inf = numeric_limits<double>::infinity();
    +ss << inf; // Write out.
    +assert(ss.str() == "inf");
    +double r;
    +ss >> r; // Read back in.
    +assert(inf == r); // Confirms that the double values really are identical.
    +
    +cout << "infinity output was " << ss.str() << endl;
    +cout << "infinity input was " << r << endl;
    +// But the string representation of r displayed will be the native type
    +// because, when it was constructed, cout had NOT been imbued
    +// with the new locale containing the nonfinite_numput facet.
    +// So the cout output will be "1.#INF on MS platforms
    +// and may be "inf" or other string representation on other platforms.
    +
    +
    +

    +

    +
    + + Use + with lexical_cast +
    +

    + Without using a new locale that contains the nonfinite facets, lexical_cast is not portable (and often + fails) if nonfinite values are found. +

    +

    + +

    +
    locale old_locale;
    +locale tmp_locale(old_locale, new nonfinite_num_put<char>);
    +locale new_locale(tmp_locale, new nonfinite_num_get<char>);
    +
    +

    +

    +

    + Although other examples imbue individual streams with the new locale, for + the streams constructed inside lexical_cast, it is necesary to assign to + a global locale. +

    +
    locale::global(new_locale);
    +
    +

    + lexical_cast then works + as expected, even with infinity and NaNs. +

    +
    double x = boost::lexical_cast<double>("inf");
    +assert(x == std::numeric:limits<double>::infinity());
    +
    +string s = boost::lexical_cast<string>(numeric_limits<double>::infinity());
    +assert(s == "inf");
    +
    +
    + + + + + +
    [Warning]Warning

    + You should be aware that the C++ specification does not explicitly require + that input from decimal digits strings converts with rounding to the + nearest representable floating-point binary value. (In contrast, decimal + digits read by the compiler, for example by an assignment like double d + = 1.234567890123456789, + are guaranteed to assign the nearest representable value to double d). + This implies that, no matter how many decimal digits you provide, there + is a potential uncertainty of 1 least significant bit in the resulting + binary value. +

    +

    + See for + more information on nearest representable and rounding. +

    +

    + Most iostream libraries do in fact achieve the desirable nearest + representable floating-point binary value for all values of + input. However one popular STL library does not quite achieve this for + 64-bit doubles. See Decimal + digit string input to double may be 1 bit wrong for the bizarre + full details. +

    +

    + If you are expecting to 'round-trip' lexical_cast + or serialization, for example + archiving and loading, and want to be absolutely + certain that you will always get an exactly identical double value binary + pattern, you should use the suggested 'workaround' below that + is believed to work on all platforms. +

    +

    + You should output using all potentially significant decimal digits, by + setting stream precision to std::numeric_limits<double>::max_digits10, + (or for the appropriate floating-point type, if not double) and crucially, + require scientific + format, not fixed + or automatic (default), for example: +

    +
    double output_value = any value;
    +std::stringstream s;
    +s << setprecison(std::numeric_limits<double>::max_digits10) << scientific << output_value;
    +s >> input_value;
    +
    +
    + + Use + with serialization archives +
    +

    + It is vital that the same locale is used when an archive is saved and when + it is loaded. Otherwise, loading the archive may fail. By default, archives + are saved and loaded with a classic C locale with a boost::archive::codecvt_null + facet added. Normally you do not have to worry about that. +

    +

    + The constructors for the archive classes, as a side-effect, imbue the stream + with such a locale. However, if you want to use the facets nonfinite_num_put and nonfinite_num_get + with archives, then you have to manage the locale manually. That is done + by calling the archive constructor with the flag boost::archive::no_codecvt, + thereby ensuring that the archive constructor will not + imbue the stream with a new locale. +

    +

    + The following code shows how to use nonfinite_num_put + with a text_oarchive. +

    +
    locale default_locale(locale::classic(), new boost::archive::codecvt_null<char>);
    +locale my_locale(default_locale, new nonfinite_num_put<char>);
    +
    +ofstream ofs("test.txt");
    +ofs.imbue(my_locale);
    +
    +boost::archive::text_oarchive oa(ofs, no_codecvt);
    +
    +double x = numeric_limits<double>::infinity();
    +oa & x;
    +
    +

    + The same method works with nonfinite_num_get + and text_iarchive. +

    +

    + If you use the nonfinite_num_put + with trap_infinity and/or + trap_nan flag with a serialization + archive, then you must set the exception mask of the stream. Serialization + archives do not check the stream state. +

    +
    + + Other + examples +
    +

    + nonfinite_facet_simple.cpp + give some more simple demonstrations of the difference between using classic + C locale and constructing a C99 infinty and NaN compliant locale for input + and output. +

    +

    + See nonfinite_facet_sstream.cpp + for this example of use with std::stringstreams. +

    +

    + For an example of how to enforce the MSVC 'legacy' "1.#INF" and + "1.#QNAN" representations of infinity and NaNs, for input and + output, see nonfinite_legacy.cpp. +

    +

    + Treatment of signaling NaN is demonstrated at ../../../example/nonfinite_signaling_NaN.cpp +

    +

    + Example ../../../example/nonfinite_loopback_ok.cpp + shows loopback works OK. +

    +

    + Example ../../../example/nonfinite_num_facet.cpp + shows output and re-input of various finite and nonfinite values. +

    +

    + A very basic example of using Boost.Archive is at ../../../example/nonfinite_serialization_archives.cpp. +

    +

    + A full demonstration of serialization by Francois Mauger is at ../../../example/nonfinite_num_facet_serialization.cpp +

    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/intro.html b/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/intro.html new file mode 100644 index 000000000..10ec552e3 --- /dev/null +++ b/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/intro.html @@ -0,0 +1,382 @@ + + + +Introduction + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + +
    + + The Problem +
    +

    + The C++98 standard does not specify how infinity and + NaN are represented in text streams. As a result, + different platforms use different string representations. This can cause + undefined behavior when text files are moved between different platforms. + Some platforms cannot even input parse their own output! So 'route-tripping' + or loopback of output to input is not possible. For instance, the following + test fails with MSVC: +

    +
    stringstream ss;
    +double inf = numeric_limits<double>::infinity();
    +double r;
    +ss << inf; // Write out.
    +ss >> r; // Read back in.
    +
    +cout << "infinity output was " << inf << endl; // 1.#INF
    +cout << "infinity input was " << r << endl; // 1
    +
    +assert(inf == y); // Fails!
    +
    +
    + + The Solution +
    +

    + The facets nonfinite_num_put + and nonfinite_num_get format + and parse all floating-point numbers, including infinity + and NaN, in a consistent + and portable manner. +

    +

    + The following test succeeds with MSVC. +

    +

    + +

    +
    locale old_locale;
    +locale tmp_locale(old_locale, new nonfinite_num_put<char>);
    +locale new_locale(tmp_locale, new nonfinite_num_get<char>);
    +
    +

    +

    +
    + + + + + +
    [Tip]Tip
    +

    + To add two facets, nonfinite_num_put + and nonfinite_num_get, + you may have to add one at a time, using a temporary locale. +

    +

    + Or you can create a new locale in one step +

    +

    + std::locale new_locale(std::locale(std::locale(std::locale(), new boost::math::nonfinite_num_put<char>), new boost::math::nonfinite_num_get<char>)); +

    +

    + and, for example, use it to imbue an input and output stringstream. +

    +
    +

    + +

    +
    stringstream ss;
    +ss.imbue(new_locale);
    +double inf = numeric_limits<double>::infinity();
    +ss << inf; // Write out.
    +assert(ss.str() == "inf");
    +double r;
    +ss >> r; // Read back in.
    +assert(inf == r); // Confirms that the double values really are identical.
    +
    +cout << "infinity output was " << ss.str() << endl;
    +cout << "infinity input was " << r << endl;
    +// But the string representation of r displayed will be the native type
    +// because, when it was constructed, cout had NOT been imbued
    +// with the new locale containing the nonfinite_numput facet.
    +// So the cout output will be "1.#INF on MS platforms
    +// and may be "inf" or other string representation on other platforms.
    +
    +
    +

    +

    +
    + + C++0X + standard for output of infinity and NaN +
    +

    + C++0X + (final) draft standard does not explicitly specify the representation + (and input) of nonfinite values, leaving it implementation-defined. So + without some specific action, input and output of nonfinite values is not + portable. +

    +
    + + C99 + standard for output of infinity and NaN +
    +

    + The C99 + standard does specify how infinity + and NaN are formatted by printf and similar output functions, and parsed + by scanf and similar input functions. +

    +

    + The following string representations are used: +

    +
    +

    Table 50. C99 Representation of Infinity and NaN

    +
    ++++ + + + + + + + + + + + + + + + + + + + + + + +
    +

    + number +

    +
    +

    + string +

    +
    +

    + Positive infinity +

    +
    +

    + "inf" or "infinity" +

    +
    +

    + Positive NaN +

    +
    +

    + "nan" or "nan(...)" +

    +
    +

    + Negative infinity +

    +
    +

    + "-inf" or "-infinity" +

    +
    +

    + Negative NaN +

    +
    +

    + "-nan" or "-nan(...)" +

    +
    +
    +

    + So following C99 provides a sensible 'standard' way of handling input and + output of nonfinites in C++, and this implementation follows most of these + formats. +

    +
    + + Signaling + NaNs +
    +

    + A particular type of NaN is the signaling NaN. The usual mechanism of signaling + is by raising a floating-point exception. Signaling NaNs are defined by + IEEE + 754-2008. +

    +

    + Floating-point values with layout s111 1111 1axx + xxxx xxxx xxxx xxxx xxxx where s is the sign, x + is the payload, and bit a determines the type of NaN. +

    +

    + If bit a = 1, it is a quiet NaN. +

    +

    + If bit a is zero and the payload x + is nonzero, then it is a signaling NaN. +

    +

    + Although there has been theoretical interest in the ability of a signaling + NaN to raise an exception, for example to prevent use of an uninitialised + variable, in practice there appears to be no useful application of signaling + NaNs for most current processors. C++0X + 18.3.2.2 still specifies a (implementation-defined) representation + for signaling NaN, and static constexpr bool + has_signaling_NaN a method of + checking if a floating-point type has a representation for signaling NaN. +

    +

    + But in practice, most platforms treat signaling NaNs in the same as quiet + NaNs. So, for example, they are represented by "nan" on output + in C99 + format, and output as 1.#QNAN + by Microsoft compilers. +

    +
    + + + + + +
    [Note]Note
    +

    + The C99 standard does not distinguish between the quiet NaN and signaling + NaN values. A quiet NaN propagates through almost every arithmetic operation + without raising a floating-point exception; a signaling NaN generally + raises a floating-point exception when occurring as an arithmetic operand. +

    +

    + C99 specification does not define the behavior of signaling NaNs. NaNs + created by IEC 60559 operations are always quiet. Therefore this implementation + follows C99, and treats the signaling NaN bit as just a part of the NaN + payload field. So this implementation does not distinguish between the + two classes of NaN. +

    +
    +
    + + + + + +
    [Note]Note
    +

    + An implementation may give zero and non-numeric values (such as infinities + and NaNs) a sign or may leave them unsigned. Wherever such values are + unsigned, any requirement in the C99 Standard to retrieve the sign shall + produce an unspecified sign, and any requirement to set the sign shall + be ignored. +

    +

    + This might apply to user-defined types, but in practice built-in floating-point + types float, double and long + double have well-behaved signs. +

    +
    +

    + The numbers can be of type float, + double and long + double. An optional + sign can be + used with positive numbers (controlled by ios manipulator showpos). The function printf and similar C++ functions use + standard formatting flags to put all lower or all upper case (controlled + by std::ios manipulator uppercase + and lowercase). +

    +

    + The function scanf and + similar input functions are case-insensitive. +

    +

    + The dots in nan(...) + stand for an arbitrary string. The meaning of that string is implementation + dependent. It can be used to convey extra information about the NaN, from + the 'payload'. A particular value of the payload might be used to indicate + a missing value, for example. +

    +

    + This library uses the string representations specified by the C99 standard. +

    +

    + An example of an implementation that optionally includes the NaN payload + information is at AIX + NaN fprintf. That implementation specifies for Binary Floating + Point NANs: +

    +
      +
    • + A NaN ordinal sequence is a left-parenthesis character '(', followed + by a digit sequence representing an integer n, where 1 <= n <= + INT_MAX-1, followed by a right-parenthesis character ')'. +
    • +
    • + The integer value, n, is determined by the fraction bits of the NaN + argument value as follows: +
    • +
    • + For a signalling NaN value, NaN fraction bits are reversed (left to + right) to produce bits (right to left) of an even integer value, 2*n. + Then formatted output functions produce a (signalling) NaN ordinal + sequence corresponding to the integer value n. +
    • +
    • + For a quiet NaN value, NaN fraction bits are reversed (left to right) + to produce bits (right to left) of an odd integer value, 2*n-1. Then + formatted output functions produce a (quiet) NaN ordinal sequence corresponding + to the integer value n. +
    • +
    +
    + + + + + +
    [Warning]Warning

    + This implementation does not (yet) provide output of, or access to, the + NaN payload. +

    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/portability.html b/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/portability.html new file mode 100644 index 000000000..6e7cd00aa --- /dev/null +++ b/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/portability.html @@ -0,0 +1,50 @@ + + + +Portability + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + +

    + This library uses the floating-point number classification and sign-bit + from Boost.Math library, and should work on all platforms where that library + works. See the portability information for that library. +

    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/rationale.html b/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/rationale.html new file mode 100644 index 000000000..3178c0bc6 --- /dev/null +++ b/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/rationale.html @@ -0,0 +1,67 @@ + + + +Design Rationale + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + +
      +
    • + The flags are implemented as a const data member of the facet. Facets + are reference counted, and locales can share facets. Therefore changing + the flags of a facet would have effects that are hard to predict. An + alternative design would be to implement the flags using std::ios_base::xalloc and std::ios_base::iword. + Then one could safely modify the flags, and one could define manipulators + that do so. However, for that to work with dynamically linked libraries, + a .cpp + file would have to be added to the library. It was judged be more desirable + to have a headers only library, than to have mutable flags and manipulators. +
    • +
    • + The facet nonfinite_num_put + throws an exception when the trap_infinity + or trap_nan flag is + set and an attempt is made to format infinity or NaN. It would be better + if the facet set the fail bit of the stream. However, facets derived + from std::num_put do not have access to the + stream state. +
    • +
    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/reference.html b/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/reference.html new file mode 100644 index 000000000..06fa98c59 --- /dev/null +++ b/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/reference.html @@ -0,0 +1,463 @@ + + + +Reference + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + +
    + + The + Facet nonfinite_num_put +
    +
    template<
    +  class CharType, class OutputIterator = std::ostreambuf_iterator<CharType>
    +        >
    +class nonfinite_num_put;
    +
    +

    + The class nonfinite_num_put<CharType, OutputIterator> is derived from std::num_put<CharType, OutputIterator>. Thus it is a facet that formats numbers. + The first template argument is the character type of the formatted strings, + usually char or wchar_t. The second template argument is + the type of iterator used to write the strings. It is required to be an + output iterator. Usually the default std::ostreambuf_iterator + is used. The public interface of the class consists of a single constructor + only: +

    +
    nonfinite_num_put(int flags = 0);
    +
    +

    + The flags argument (effectively optional because a default of no_flags is provided) is discussed below. + The class template nonfinite_num_put + is defined in the header boost/math/nonfinite_num_facets.hpp + and lives in the namespace boost::math. +

    +

    + Unlike the C++ Standard facet std::num_put, + the facet nonfinite_num_put + formats infinity and NaN in a consistent and portable manner. + It uses the following string representations: +

    +
    ++++ + + + + + + + + + + + + + + + + + + + + + + +
    +

    + Number +

    +
    +

    + String +

    +
    +

    + Positive infinity +

    +
    +

    + inf +

    +
    +

    + Positive NaN +

    +
    +

    + nan +

    +
    +

    + Negative infinity +

    +
    +

    + -inf +

    +
    +

    + Negative NaN +

    +
    +

    + -nan +

    +
    +

    + The numbers can be of type float, + double and long + double. The strings can be in all + lower case or all upper case. An optional + sign can be used with positive + numbers. This can be controlled with the uppercase, + lowercase, showpos and noshowpos + manipulators. Formatting of integers, boolean values and finite floating-point + numbers is simply delegated to the normal std::num_put. +

    +
    + + Facet + nonfinite_num_get +
    +
    template<class CharType, class InputIterator = std::istreambuf_iterator<CharType> > class nonfinite_num_get;
    +
    +

    + The class nonfinite_num_get<CharType, InputIterator> is derived from std::num_get<CharType, IntputIterator>. Thus it is a facet that parses strings + that represent numbers. The first template argument is the character type + of the strings, usually char + or wchar_t. The second template + argument is the type of iterator used to read the strings. It is required + to be an input iterator. Usually the default is used. The public interface + of the class consists of a single constructor only: +

    +
    nonfinite_num_get(int flags = 0);
    +
    +

    + The flags argument is discussed below. The class + template nonfinite_num_get + is defined in the header boost/math/nonfinite_num_facets.hpp + and lives in the namespace boost::math. +

    +

    + Unlike the facet std::num_get, the facet nonfinite_num_get + parses strings that represent infinity + and NaN in a consistent + and portable manner. It recognizes precisely the string representations + specified by the C99 standard: +

    +
    ++++ + + + + + + + + + + + + + + + + + + + + + + +
    +

    + Number +

    +
    +

    + String +

    +
    +

    + Positive infinity +

    +
    +

    + inf, infinity +

    +
    +

    + Positive NaN +

    +
    +

    + nan, nan(...) +

    +
    +

    + Negative infinity +

    +
    +

    + -inf, -infinity +

    +
    +

    + Negative NaN +

    +
    +

    + -nan, -nan(...) +

    +
    +

    + The numbers can be of type float, + double and long + double. The facet is case-insensitive. + An optional + sign can be used with positive numbers. The dots in nan(...) + stand for an arbitrary string usually containing the NaN payload. + Parsing of strings that represent integers, boolean values and finite floating-point + numbers is delegated to std::num_get. +

    +

    + When the facet parses a string that represents infinity + on a platform that lacks infinity, then the fail bit of the stream is set. +

    +

    + When the facet parses a string that represents NaN + on a platform that lacks NaN, then the fail bit of the stream is set. +

    +
    + + Flags +
    +

    + The constructors for nonfinite_num_put + and nonfinite_num_get take + an optional bit flags argument. There are four different bit flags: +

    +
      +
    • + legacy +
    • +
    • + signed_zero +
    • +
    • + trap_infinity +
    • +
    • + trap_nan +
    • +
    +

    + The flags can be combined with the OR operator|. +

    +

    + The flags are defined in the header boost/math/nonfinite_num_facets.hpp + and live in the namespace boost::math. +

    +
    + + legacy +
    +

    + The legacy flag has no effect with the output facet nonfinite_num_put. +

    +

    + If the legacy flag is used with the nonfinite_num_get + input facet, then the facet will recognize all the following string representations + of infinity and NaN: +

    +
    ++++ + + + + + + + + + + + + + + + + + + + + + + +
    +

    + Number +

    +
    +

    + String +

    +
    +

    + Positive infinity +

    +
    +

    + inf, infinity, one#inf +

    +
    +

    + Positive NaN +

    +
    +

    + nan, nan(...), nanq, nans, qnan, snan, one#ind, one#qnan, one#snan +

    +
    +

    + Negative infinity +

    +
    +

    + -inf, -infinity, -one#inf +

    +
    +

    + Negative NaN +

    +
    +

    + -nan, -nan(...), -nanq, -nans, -qnan, -snan, -one#ind, - one#qnan, + -one#snan +

    +
    +
      +
    • + The numbers can be of type float, + double and long double. +
    • +
    • + The facet is case-insensitive. +
    • +
    • + An optional + sign can + be used with the positive values. +
    • +
    • + The dots in nan(...) + stand for an arbitrary string. +
    • +
    • + one stands for any + string that std::num_get parses as the number 1, typically "1.#INF", "1.QNAN" + but also "000001.#INF"... +
    • +
    +

    + The list includes a number of non-standard string representations of infinity + and NaN that are used by various existing implementations of the C++ standard + library, and also string representations used by other programming languages. +

    +
    + + signed_zero +
    +

    + If the signed_zero flag + is used with nonfinite_num_put, + then the facet will distinguish between positive and negative zero. It + will format positive zero as "0" or "+0" and negative + zero as "-0". The string representation of positive zero can + be controlled with the showpos + and noshowpos manipulators. +

    +

    + The signed_zero flag + has no effect with the input facet nonfinite_num_get. + The input facet nonfinite_num_get + always parses "0" and "+0" as positive zero and "-0" + as negative zero, as do most implementations of std::num_get. +

    +
    + + trap_infinity +
    +

    + If the trap_infinity flag + is used with nonfinite_num_put, + then the facet will throw an exception of type std::ios_base::failure + when an attempt is made to format positive or negative infinity. If the + facet is called from a stream insertion operator, then the stream will + catch that exception and set either its fail + bit or its bad + bit. Which bit is set is platform + dependent. +

    +

    + If the trap_infinity flag + is used with nonfinite_num_get, + then the facet will set the fail + bit of the stream when an attempt + is made to parse a string that represents positive or negative infinity. +

    +

    + (See Design Rationale below for a discussion of this inconsistency.) +

    +
    + + trap_nan +
    +

    + Same as trap_infinity, + but positive and negative NaN are trapped instead. +

    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/sf_and_dist/html/math_toolkit/utils/fpclass.html b/doc/sf_and_dist/html/math_toolkit/utils/fpclass.html index 5ab26a33e..5b51753cd 100644 --- a/doc/sf_and_dist/html/math_toolkit/utils/fpclass.html +++ b/doc/sf_and_dist/html/math_toolkit/utils/fpclass.html @@ -1,7 +1,7 @@ -Floating-Point Classification: Infinities and NaN's +Floating-Point Classification: Infinities and NaNs @@ -24,11 +24,11 @@
    - + Synopsis
    #define FP_ZERO        /* implementation specific value */
    @@ -58,7 +58,7 @@
             to use these functions.
           

    - + Description

    @@ -216,6 +216,23 @@ Returns true only if z is a normal number (not zero, infinite, NaN, or denormalised).

    +
    + + Floating-point + format +
    +

    + If you wish to find details of the floating-point format for any particular + processor, there is a program +

    +

    + inspect_fp.cpp +

    +

    + by Johan Rade which can be used to print out the processor type, endianness, + and detailed bit layout of a selection of floating-point values, including + infinity and NaNs. +

    diff --git a/doc/sf_and_dist/html/math_toolkit/utils/next_float.html b/doc/sf_and_dist/html/math_toolkit/utils/next_float.html index beb06b058..eb1fa2d8f 100644 --- a/doc/sf_and_dist/html/math_toolkit/utils/next_float.html +++ b/doc/sf_and_dist/html/math_toolkit/utils/next_float.html @@ -6,7 +6,7 @@ - + @@ -20,7 +20,7 @@

    -PrevUpHomeNext +PrevUpHomeNext

    @@ -46,7 +46,8 @@

    Most decimal values, for example 0.1, cannot be exactly represented as floating-point - values, but will be stored as the closest representable floating-point. + values, but will be stored as the closest + representable floating-point.

    Functions are provided for finding adjacent greater and lesser floating-point @@ -76,7 +77,7 @@


    -PrevUpHomeNext +PrevUpHomeNext
    diff --git a/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_advance.html b/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_advance.html index d23e6de74..f40ff20a7 100644 --- a/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_advance.html +++ b/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_advance.html @@ -32,7 +32,7 @@ number of ULP.

    - + Synopsis

    @@ -50,7 +50,7 @@ }} // namespaces

    - + Description - float_advance
    diff --git a/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_distance.html b/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_distance.html index 8851c36fe..9c1ec2233 100644 --- a/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_distance.html +++ b/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_distance.html @@ -34,7 +34,7 @@ different.

    - + Synopsis

    @@ -52,7 +52,7 @@ }} // namespaces

    - + Description - float_distance
    diff --git a/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_next.html b/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_next.html index ad7bdd44a..6992535df 100644 --- a/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_next.html +++ b/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_next.html @@ -28,7 +28,7 @@ Next Greater Representable Value (float_next)
    - + Synopsis

    @@ -46,7 +46,7 @@ }} // namespaces

    - + Description - float_next
    diff --git a/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_prior.html b/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_prior.html index a9523382d..3131f114f 100644 --- a/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_prior.html +++ b/doc/sf_and_dist/html/math_toolkit/utils/next_float/float_prior.html @@ -28,7 +28,7 @@ the Next Smaller Representable Value (float_prior)
    - + Synopsis

    @@ -46,7 +46,7 @@ }} // namespaces

    - + Description - float_prior
    diff --git a/doc/sf_and_dist/html/math_toolkit/utils/next_float/nextafter.html b/doc/sf_and_dist/html/math_toolkit/utils/next_float/nextafter.html index 6ec51bf0b..e05e05b5d 100644 --- a/doc/sf_and_dist/html/math_toolkit/utils/next_float/nextafter.html +++ b/doc/sf_and_dist/html/math_toolkit/utils/next_float/nextafter.html @@ -28,7 +28,7 @@ Next Representable Value in a Specific Direction (nextafter)
    - + Synopsis

    @@ -46,7 +46,7 @@ }} // namespaces

    - + Description - nextafter
    @@ -76,7 +76,7 @@ returns an overflow_error.

    - + Examples - nextafter
    diff --git a/doc/sf_and_dist/html/math_toolkit/utils/rounding/modf.html b/doc/sf_and_dist/html/math_toolkit/utils/rounding/modf.html index 051ec51b7..bd38b4e12 100644 --- a/doc/sf_and_dist/html/math_toolkit/utils/rounding/modf.html +++ b/doc/sf_and_dist/html/math_toolkit/utils/rounding/modf.html @@ -7,7 +7,7 @@ - + diff --git a/doc/sf_and_dist/html/math_toolkit/utils/sign_functions.html b/doc/sf_and_dist/html/math_toolkit/utils/sign_functions.html index c89873441..e292a8bdc 100644 --- a/doc/sf_and_dist/html/math_toolkit/utils/sign_functions.html +++ b/doc/sf_and_dist/html/math_toolkit/utils/sign_functions.html @@ -6,8 +6,8 @@ - - + +
    @@ -20,7 +20,7 @@

    -PrevUpHomeNext +PrevUpHomeNext

    @@ -28,7 +28,7 @@ Functions

    - + Synopsis

    @@ -49,10 +49,13 @@ template <class T> inline T copysign (const T& x, const T& y); +template <class T> +inline T changesign (const T& z); + }} // namespaces

    - + Description
    template<class T> 
    @@ -62,16 +65,25 @@
             Returns a non-zero value if the sign bit is set in variable x,
             otherwise 0.
           

    +
    + + + + + +
    [Important]Important

    + The return value from this function is zero or not-zero + and not zero or one. +

    template <class T>
     inline int sign (const T& z);
     

    - Returns 1 if x - > 0, + Returns 1 if x + > 0, -1 - if x < - 0, and 0 - if x is zero. + if x < 0, and 0 + if x is zero.

    template <class T>
     inline T copysign (const T& x, const T& y);
    @@ -79,6 +91,151 @@
     

    Sets the sign of x to be the same as the sign of y.

    +

    + See C99 + 7.12.11.1 The copysign functions for more detail. +

    +
    template <class T>
    +inline T changesign (const T& z);
    +
    +

    + Returns a floating point number with a binary representation where the signbit + is the opposite of the sign bit in x, and where the + other bits are the same as in x. +

    +

    + This function is widely available, but not specified in any standards. +

    +

    + Rationale: Not specified by TR1, but changesign(x) + is both easier to read and more efficient than +

    +
    copysign(x, signbit(x) ? 1.0 : -1.0);
    +
    +

    + For finite values, this function has the same effect as simple negation, + the assignment z = -z, but for nonfinite values, infinities + and NaNs, the changesign(x) function + may be the only portable way to ensure that the sign bit is changed. +

    +
    + + Sign bits +
    +

    + One of the bits in the binary representation of a floating-point number gives + the sign, and the remaining bits give the absolute value. That bit is known + as the sign bit. The sign bit is set = 1 for negative numbers, and is not + set = 0 for positive numbers. (This is true for all binary representations + of floating point numbers that are used by modern microprocessors.) +

    +

    + C++ + TR1 specifies copysign + functions and function templates for accessing the sign bit. +

    +

    + For user-defined types (UDT), the sign may be stored in some other way. They + may also not provide infinity or NaNs. To use these functions with a UDT, + it may be necessary to explicitly specialize then for UDT type T. +

    +
    + + Examples +
    +
    signbit(3.5) is zero (or false)
    +signbit(-7.1) is 1 (or true)
    +copysign(4.2, 7.9) is 4.2
    +copysign(3.5 -1.4) is -3.5
    +copysign(-4.2, 1.0) is 4.2
    +copysign(-8.6, -3.3) is -8.6
    +changesign(6.9) is -6.9
    +changesign(-1.8) is 1.8
    +
    +
    + + Portability +
    +

    + The library supports the following binary floating-point formats: +

    +
      +
    • + IEEE 754 single precision +
    • +
    • + IEEE 754 double precision +
    • +
    • + IEEE 754 extended double precision with 15 exponent bits +
    • +
    • + Intel extended double precision +
    • +
    • + PowerPC extended double precision +
    • +
    • + Motorola 68K extended double precision +
    • +
    +

    + The library does not support the VAX floating-point formats. (These are available + on VMS, but the default on VMS is the IEEE 754 floating-point format.) +

    +

    + The main portability issues are: +

    +
      +
    • + Unsupported floating point formats +
    • +
    • + The library depends on the header boost/detail/endian.hpp +
    • +
    • + Code such as #if defined(__ia64) || defined(__ia64__) + || defined(_M_IA64) is used to determine the processor type. +
    • +
    +

    + The library has passed all tests on the following platforms: +

    +
      +
    • + Win32 / MSVC 7.1 / 10.0 / x86 +
    • +
    • + Win32 / Intel C++ 7.1, 8.1, 9.1 / x86 +
    • +
    • + Mac OS X / GCC 3.3, 4.0 / ppc +
    • +
    • + Linux / Intel C++ 9.1 / x86, ia64 +
    • +
    • + Linux / GCC 3.3 / x86, x64, ia64, ppc, hppa, mips, m68k +
    • +
    • + Linux / GCC 3.4 / x64 +
    • +
    • + HP-UX / aCC, GCC 4.1 / ia64 +
    • +
    • + HP-UX / aCC / hppa +
    • +
    • + Tru64 / Compaq C++ 7.1 / alpha +
    • +
    • + VMS / HP C++ 7.1 / alpha (in IEEE floating point mode) +
    • +
    • + VMS / HP C++ 7.2 / ia64 (in IEEE floating point mode) +
    • +
    @@ -92,7 +249,7 @@

    -PrevUpHomeNext +PrevUpHomeNext
    diff --git a/doc/sf_and_dist/index.idx b/doc/sf_and_dist/index.idx index 410f19c6f..a6c3a37d7 100644 --- a/doc/sf_and_dist/index.idx +++ b/doc/sf_and_dist/index.idx @@ -10,7 +10,14 @@ !exclude row_type size_type tag traits !exclude a abs acos add asin atan atan2 b begin bracket ceil check clear !exclude cos cosh digits end exp fabs floor fmod frexp g if in log log10 -!exclude modf pow real result sin sinh sqrt swap tan tanh +!exclude modf pow real result sin sinh sqrt swap tan tanh s f z +# +# These next two are spuriously found as function names, take them out +# and re-add them as macros: +# +!exclude BOOST_MATH_INSTRUMENT_CODE BOOST_MATH_INSTRUMENT_VARIABLE +BOOST_MATH_INSTRUMENT_VARIABLE "" "" macro_name +BOOST_MATH_INSTRUMENT_CODE "" "" macro_name !rewrite-name "(?i)(?:A|The)\s+(.*)" "\1" !rewrite-name "Additional Implementation Notes" "Implementation Notes" @@ -21,3 +28,5 @@ + + diff --git a/doc/sf_and_dist/math.qbk b/doc/sf_and_dist/math.qbk index 9ef647827..5587cc5a2 100644 --- a/doc/sf_and_dist/math.qbk +++ b/doc/sf_and_dist/math.qbk @@ -163,6 +163,7 @@ and use the function's name as the link text.] [def __isnan [link math_toolkit.special.fpclass isnan]] [def __isinf [link math_toolkit.special.fpclass isinf]] [def __isnormal [link math_toolkit.special.fpclass isnormal]] +[def __fp_facets [link math_toolkit.utils.fp_facets nonfinite fp_facets]] [/powers etc] [def __expm1 [link math_toolkit.special.powers.expm1 expm1]] @@ -434,6 +435,7 @@ and as a CD ISBN 0-9504833-2-X 978-0-9504833-2-0, Classification 519.2-dc22. [include rounding_func.qbk] [include fpclassify.qbk] [include sign.qbk] +[include fp_facets.qbk] [include float_next.qbk] [endsect] diff --git a/doc/sf_and_dist/roadmap.qbk b/doc/sf_and_dist/roadmap.qbk index e97589ac3..ce55a773b 100644 --- a/doc/sf_and_dist/roadmap.qbk +++ b/doc/sf_and_dist/roadmap.qbk @@ -1,5 +1,12 @@ [template history[] +[h4 Boost-1.47] + +* Added changesign function to sign.hpp to facilitate addition of nonfinite facets. +* Addition of nonfinite facetsfrom Johan Rade, with tests, +examples of use for C99 format infinity and NaN, and documentation. +* Added tests and documentation of changesign from Johan Rade. + [h4 Boost-1.46.1] * Fixed issues [@https://svn.boost.org/trac/boost/ticket/5095 #5095], [@https://svn.boost.org/trac/boost/ticket/5095 #5113]. @@ -8,7 +15,7 @@ * Added Wald, Inverse Gaussian and geometric distributions. * Added information about configuration macros. -* Added support for mpreal as a real-numered type. +* Added support for mpreal as a real-numbered type. [h4 Boost-1.45.0] diff --git a/doc/sf_and_dist/sign.qbk b/doc/sf_and_dist/sign.qbk index 7c83d0bf8..559820dba 100644 --- a/doc/sf_and_dist/sign.qbk +++ b/doc/sf_and_dist/sign.qbk @@ -16,6 +16,9 @@ template inline T copysign (const T& x, const T& y); + + template + inline T changesign (const T& z); }} // namespaces @@ -25,20 +28,108 @@ int signbit(T x); Returns a non-zero value if the sign bit is set in variable /x/, otherwise `0`. + +[important The return value from this function is zero or /not-zero/ and [*not] zero or one.] template inline int sign (const T& z); -Returns `1` if `x > 0`, `-1` if `x < 0`, and `0` if x is zero. +Returns `1` if /x/ `> 0`, `-1` if /x/ `< 0`, and `0` if /x/ is zero. template inline T copysign (const T& x, const T& y); Sets the sign of /x/ to be the same as the sign of /y/. +See [@http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf C99 7.12.11.1 The copysign functions] +for more detail. + + template + inline T changesign (const T& z); + +Returns a floating point number with a binary representation +where the signbit is the opposite of the sign bit in /x/, +and where the other bits are the same as in /x/. + +This function is widely available, but not specified in any standards. + +Rationale: Not specified by TR1, but `changesign(x)` +is both easier to read and more efficient than + + copysign(x, signbit(x) ? 1.0 : -1.0); + +For finite values, this function has the same effect as simple negation, +the assignment z = -z, but for nonfinite values, +[@http://en.wikipedia.org/wiki/Infinity#Computing infinities] +and [@http://en.wikipedia.org/wiki/NaN NaNs], +the `changesign(x)` function may be the only portable way +to ensure that the sign bit is changed. + +[h5 Sign bits] +One of the bits in the binary representation of a floating-point number gives the sign, +and the remaining bits give the absolute value. +That bit is known as the sign bit. +The sign bit is set = 1 for negative numbers, and is not set = 0 for positive numbers. +(This is true for all binary representations of floating point numbers +that are used by modern microprocessors.) + +[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf C++ TR1] +specifies `copysign` functions and function templates for accessing the sign bit. + +For user-defined types (UDT), the sign may be stored in some other way. +They may also not provide infinity or NaNs. +To use these functions with a UDT, +it may be necessary to explicitly specialize then for UDT type T. + +[h5 Examples] + + signbit(3.5) is zero (or false) + signbit(-7.1) is 1 (or true) + copysign(4.2, 7.9) is 4.2 + copysign(3.5 -1.4) is -3.5 + copysign(-4.2, 1.0) is 4.2 + copysign(-8.6, -3.3) is -8.6 + changesign(6.9) is -6.9 + changesign(-1.8) is 1.8 + +[h5 Portability] + +The library supports the following binary floating-point formats: + +* IEEE 754 single precision +* IEEE 754 double precision +* IEEE 754 extended double precision with 15 exponent bits +* Intel extended double precision +* PowerPC extended double precision +* Motorola 68K extended double precision + +The library does not support the VAX floating-point formats. +(These are available on VMS, but the default on VMS is the IEEE 754 floating-point format.) + +The main portability issues are: + +* Unsupported floating point formats +* The library depends on the header boost/detail/endian.hpp +* Code such as `#if defined(__ia64) || defined(__ia64__) || defined(_M_IA64)` +is used to determine the processor type. + +The library has passed all tests on the following platforms: + +* Win32 / MSVC 7.1 / 10.0 / x86 +* Win32 / Intel C++ 7.1, 8.1, 9.1 / x86 +* Mac OS X / GCC 3.3, 4.0 / ppc +* Linux / Intel C++ 9.1 / x86, ia64 +* Linux / GCC 3.3 / x86, x64, ia64, ppc, hppa, mips, m68k +* Linux / GCC 3.4 / x64 +* HP-UX / aCC, GCC 4.1 / ia64 +* HP-UX / aCC / hppa +* Tru64 / Compaq C++ 7.1 / alpha +* VMS / HP C++ 7.1 / alpha (in IEEE floating point mode) +* VMS / HP C++ 7.2 / ia64 (in IEEE floating point mode) + [endsect][/section:sign_functions Sign Manipulation Functions] [/ - Copyright 2006 John Maddock and Paul A. Bristow. + Copyright 2006 John Maddock and Paul A. Bristow 2011. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). diff --git a/example/Jamfile.v2 b/example/Jamfile.v2 index 94798e2db..84d5aea5f 100644 --- a/example/Jamfile.v2 +++ b/example/Jamfile.v2 @@ -1,7 +1,7 @@ # \libs\math\example\jamfile.v2 -# Runs statistics examples +# Runs statistics and floating-point examples. # Copyright 2007 John Maddock -# Copyright Paul A. Bristow 2007, 2010. +# Copyright Paul A. Bristow 2007, 2010, 2011. # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -16,6 +16,10 @@ project intel:-Qwd264,239 msvc:all msvc:on + msvc:_CRT_SECURE_NO_DEPRECATE + msvc:_SCL_SECURE_NO_DEPRECATE + msvc:_SCL_SECURE_NO_WARNINGS + msvc:_CRT_SECURE_NO_WARNINGS msvc:/wd4996 msvc:/wd4512 msvc:/wd4610 @@ -24,6 +28,8 @@ project msvc:/wd4701 msvc:/wd4127 msvc:/wd4305 + #-msvc:/Za # nonfinite Serialization examples fail link if disable MS extensions, + # because serialization library is built with MS extensions enabled (default). ../../.. ; @@ -54,6 +60,16 @@ run neg_binom_confidence_limits.cpp ; run neg_binomial_sample_sizes.cpp ; run negative_binomial_example1.cpp ; run negative_binomial_example2.cpp ; + +run nonfinite_num_facet.cpp ; +run nonfinite_facet_simple.cpp ; +run nonfinite_num_facet_serialization.cpp ../../serialization/build//boost_serialization ; +# run lexical_cast_native.cpp ; # Expected to fail on some (but not all) platforms. +run lexical_cast_nonfinite_facets.cpp ; +run nonfinite_loopback_ok.cpp ; +run nonfinite_serialization_archives.cpp ../../serialization/build//boost_serialization ; +run nonfinite_facet_sstream.cpp ; + run normal_misc_examples.cpp ; run policy_eg_1.cpp ; run policy_eg_10.cpp ; diff --git a/example/inspect_fp.cpp b/example/inspect_fp.cpp new file mode 100644 index 000000000..0838b8ddd --- /dev/null +++ b/example/inspect_fp.cpp @@ -0,0 +1,224 @@ +// inspect.cpp + +// Copyright (c) 2006 Johan Rade + +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +//------------------------------------- + +#include + +#include +#include +#include +#include + +//------------------------------------------------------------------------------ + +bool is_big_endian() +{ + float x = 1.0f; + unsigned char first_byte; + memcpy(&first_byte, &x, 1); + return first_byte != 0; +} + +//------------------------------------------------------------------------------ + +void print_processor(); +void print_endianness(); +template void print_table(); +template void print_row(const char* name, T val, bool ok = true); + +//------------------------------------------------------------------------------ + +int main() +{ + std::cout << '\n'; + + print_processor(); + + print_endianness(); + + std::cout << "---------- float --------------------\n\n"; + print_table(); + + std::cout << "---------- double -------------------\n\n"; + print_table(); + + std::cout << "---------- long double --------------\n\n"; + print_table(); + + return 0; +} + +//------------------------------------------------------------------------------ + +void print_processor() +{ +#if defined(__i386) || defined(__i386__) || defined(_M_IX86) \ + || defined(__amd64) || defined(__amd64__) || defined(_M_AMD64) \ + || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) + + std::cout << "Processor: x86 or x64\n\n"; + +#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) + + std::cout << "Processor: ia64\n\n"; + +#elif defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) \ + || defined(__ppc) || defined(__ppc__) || defined(__PPC__) + + std::cout << "Processor: PowerPC\n\n"; + +#elif defined(__m68k) || defined(__m68k__) \ + || defined(__mc68000) || defined(__mc68000__) \ + + std::cout << "Processor: Motorola 68K\n\n"; + +#else + + std::cout << "Processor: Unknown\n\n"; + +#endif +} + +void print_endianness() +{ + if(is_big_endian()) + std::cout << "This platform is big-endian.\n"; + else + std::cout << "This platform is little-endian.\n"; + +#ifdef BOOST_BIG_ENDIAN + std::cout << "BOOST_BIG_ENDIAN is defined.\n\n"; +#endif +#if defined BOOST_LITTLE_ENDIAN + std::cout << "BOOST_LITTTLE_ENDIAN is defined.\n\n"; +#endif +} + +//.............................................................................. + +template void print_table() +{ + print_row("0", (T)0); + print_row("sn.min", std::numeric_limits::denorm_min(), + std::numeric_limits::has_denorm); + print_row("-sn.min", -std::numeric_limits::denorm_min(), + std::numeric_limits::has_denorm); + print_row("n.min/256", (std::numeric_limits::min)()/256); + print_row("n.min/2", (std::numeric_limits::min)()/2); + print_row("-n.min/2", -(std::numeric_limits::min)()/2); + print_row("n.min", (std::numeric_limits::min)()); + print_row("1", (T)1); + print_row("3/4", (T)3/(T)4); + print_row("4/3", (T)4/(T)3); + print_row("max", (std::numeric_limits::max)()); + print_row("inf", std::numeric_limits::infinity(), + std::numeric_limits::has_infinity); + print_row("q.nan", std::numeric_limits::quiet_NaN(), + std::numeric_limits::has_quiet_NaN); + print_row("s.nan", std::numeric_limits::signaling_NaN(), + std::numeric_limits::has_signaling_NaN); + + std::cout << "\n\n"; +} + +template +void print_row(const char* name, T val, bool ok) +{ + std::cout << std::left << std::setw(10) << name << std::right; + + std::cout << std::hex << std::setfill('0'); + + if(ok) { + if(is_big_endian()) { + for(size_t i = 0; i < sizeof(T); ++i) { + unsigned char c = *(reinterpret_cast(&val) + i); + std::cout << std::setw(2) + << static_cast(c) << ' '; + } + } + else { + for(size_t i = sizeof(T) - 1; i < sizeof(T); --i) { + unsigned char c = *(reinterpret_cast(&val) + i); + std::cout << std::setw(2) + << static_cast(c) << ' '; + } + } + } + else { + for(size_t i = 0; i < sizeof(T); ++i) + std::cout << "-- "; + } + + std::cout << '\n'; + std::cout << std::dec << std::setfill(' '); +} + +/* + +Sample output on an AMD Quadcore running MSVC 10 + + Processor: x86 or x64 + + This platform is little-endian. + BOOST_LITTTLE_ENDIAN is defined. + + ---------- float -------------------- + + 0 00 00 00 00 + sn.min 00 00 00 01 + -sn.min 80 00 00 01 + n.min/256 00 00 80 00 + n.min/2 00 40 00 00 + -n.min/2 80 40 00 00 + n.min 00 80 00 00 + 1 3f 80 00 00 + 3/4 3f 40 00 00 + 4/3 3f aa aa ab + max 7f 7f ff ff + inf 7f 80 00 00 + q.nan 7f c0 00 00 + s.nan 7f c0 00 01 + + + ---------- double ------------------- + + 0 00 00 00 00 00 00 00 00 + sn.min 00 00 00 00 00 00 00 01 + -sn.min 80 00 00 00 00 00 00 01 + n.min/256 00 00 10 00 00 00 00 00 + n.min/2 00 08 00 00 00 00 00 00 + -n.min/2 80 08 00 00 00 00 00 00 + n.min 00 10 00 00 00 00 00 00 + 1 3f f0 00 00 00 00 00 00 + 3/4 3f e8 00 00 00 00 00 00 + 4/3 3f f5 55 55 55 55 55 55 + max 7f ef ff ff ff ff ff ff + inf 7f f0 00 00 00 00 00 00 + q.nan 7f f8 00 00 00 00 00 00 + s.nan 7f f8 00 00 00 00 00 01 + + + ---------- long double -------------- + + 0 00 00 00 00 00 00 00 00 + sn.min 00 00 00 00 00 00 00 01 + -sn.min 80 00 00 00 00 00 00 01 + n.min/256 00 00 10 00 00 00 00 00 + n.min/2 00 08 00 00 00 00 00 00 + -n.min/2 80 08 00 00 00 00 00 00 + n.min 00 10 00 00 00 00 00 00 + 1 3f f0 00 00 00 00 00 00 + 3/4 3f e8 00 00 00 00 00 00 + 4/3 3f f5 55 55 55 55 55 55 + max 7f ef ff ff ff ff ff ff + inf 7f f0 00 00 00 00 00 00 + q.nan 7f f8 00 00 00 00 00 00 + s.nan 7f f8 00 00 00 00 00 01 + + */ diff --git a/example/inverse_gaussian_example.cpp b/example/inverse_gaussian_example.cpp index 155b531b7..4f212aa5e 100644 --- a/example/inverse_gaussian_example.cpp +++ b/example/inverse_gaussian_example.cpp @@ -8,7 +8,7 @@ // or copy at http://www.boost.org/LICENSE_1_0.txt) // Example of using the Inverse Gaussian (or Inverse Normal) distribution. -// The Wald Distribution is +// The Wald Distribution is // Note that this file contains Quickbook mark-up as well as code @@ -72,22 +72,22 @@ int main() cout.precision(17); // std::numeric_limits::max_digits10; for 64-bit doubles. // Traditional tables and values. - double step = 0.2; // in z + double step = 0.2; // in z double range = 4; // min and max z = -range to +range. // Construct a (standard) inverse gaussian distribution s - inverse_gaussian w11(1, 1); + inverse_gaussian w11(1, 1); // (default mean = units, and standard deviation = unity) cout << "(Standard) Inverse Gaussian distribution, mean = "<< w11.mean() << ", scale = " << w11.scale() << endl; /*` First the probability distribution function (pdf). - */ + */ cout << "Probability distribution function (pdf) values" << endl; cout << " z " " pdf " << endl; cout.precision(5); for (double z = (numeric_limits::min)(); z < range + step; z += step) { - cout << left << setprecision(3) << setw(6) << z << " " + cout << left << setprecision(3) << setw(6) << z << " " << setprecision(precision) << setw(12) << pdf(w11, z) << endl; } cout.precision(6); // default @@ -100,13 +100,13 @@ int main() cout << " z " " cdf " << endl; for (double z = (numeric_limits::min)(); z < range + step; z += step) { - cout << left << setprecision(3) << setw(6) << z << " " + cout << left << setprecision(3) << setw(6) << z << " " << setprecision(precision) << setw(12) << cdf(w11, z) << endl; } /*`giving the following table: [pre - z pdf - 2.23e-308 -1.#IND + z pdf + 2.23e-308 -1.#IND 0.2 0.90052111680384117 0.4 1.0055127039453111 0.6 0.75123750098955733 @@ -127,9 +127,9 @@ int main() 3.6 0.022840312999395804 3.8 0.019196657941016954 4 0.016189699458236451 - Integral (area under the curve) from 0 up to z (cdf) - z cdf - 2.23e-308 0 + Integral (area under the curve) from 0 up to z (cdf) + z cdf + 2.23e-308 0 0.2 0.063753567519976254 0.4 0.2706136704424541 0.6 0.44638391340412931 @@ -152,7 +152,7 @@ int main() 4 0.97907636417888622 ] -/*`We can get the inverse, the quantile, percentile, percentage point, or critical value +/*`We can get the inverse, the quantile, percentile, percentage point, or critical value for a probability for a few probability from the above table, for z = 0.4, 1.0, 2.0: */ cout << quantile(w11, 0.27061367044245421 ) << endl; // 0.4 @@ -174,7 +174,7 @@ for a probability for a few probability from the above table, for z = 0.4, 1.0, // formatC(SuppDists::qinvGauss(0.3649755481729598, 1, 1), digits=17) [1] "0.50000000969034875" - + // formatC(SuppDists::dinvGauss(0.01, 1, 1), digits=17) [1] "2.0811768202028392e-19" // formatC(SuppDists::pinvGauss(0.01, 1, 1), digits=17) [1] "4.122313403318778e-23" @@ -193,12 +193,12 @@ for a probability for a few probability from the above table, for z = 0.4, 1.0, //double p = pdf(w11, x); //double c = cdf(w11, x); // cdf(1, 1, 1) = 0.66810200122317065 //cout << "cdf(" << x << ", " << w11.mean() << ", "<< w11.scale() << ") = " << c << endl; // cdf(x, 1, 1) 0.27061367044245421 - //cout << "pdf(" << x << ", " << w11.mean() << ", "<< w11.scale() << ") = " << p << endl; + //cout << "pdf(" << x << ", " << w11.mean() << ", "<< w11.scale() << ") = " << p << endl; //double q = quantile(w11, c); //cout << "quantile(w11, " << c << ") = " << q << endl; //cout << "quantile(w11, 4.122313403318778e-23) = "<< quantile(w11, 4.122313403318778e-23) << endl; // quantile - //cout << "quantile(w11, 4.8791443010851493e-219) = " << quantile(w11, 4.8791443010851493e-219) << endl; // quantile + //cout << "quantile(w11, 4.8791443010851493e-219) = " << quantile(w11, 4.8791443010851493e-219) << endl; // quantile //double c1 = 1 - cdf(w11, x); // 1 - cdf(1, 1, 1) = 0.33189799877682935 //cout << "1 - cdf(" << x << ", " << w11.mean() << ", " << w11.scale() << ") = " << c1 << endl; // cdf(x, 1, 1) 0.27061367044245421 @@ -210,7 +210,7 @@ for a probability for a few probability from the above table, for z = 0.4, 1.0, //cout << "quantile(w11, " << c << ") = "<< quantile(w11, c) << endl; // quantile = 0.99999999999999978 == x = 1 //cout << "quantile(w11, " << c << ") = "<< quantile(w11, 1 - c) << endl; // quantile complement. quantile(w11, 0.66810200122317065) = 0.46336593652340152 // cout << "quantile(complement(w11, " << c << ")) = " << quantile(complement(w11, c)) << endl; // quantile complement = 0.46336593652340163 - + // cdf(1, 1, 1) = 0.66810200122317065 // 1 - cdf(1, 1, 1) = 0.33189799877682935 // cdf(complement(1, 1, 1)) = 0.33189799877682929 @@ -219,21 +219,21 @@ for a probability for a few probability from the above table, for z = 0.4, 1.0, // 1 - quantile(w11, 0.66810200122317065) = 2.2204460492503131e-016 // quantile(complement(w11, 0.33189799877682929)) = 0.99999999999999989 - + // qinvgauss(c, 1, 1) = 0.3999999999999998 // SuppDists::qinvGauss(0.270613670442454, 1, 1) [1] 0.4 - + /* - double qs = pinvgaussU(c, 1, 1); // + double qs = pinvgaussU(c, 1, 1); // cout << "qinvgaussU(c, 1, 1) = " << qs << endl; // qinvgaussU(c, 1, 1) = 0.86567442459240929 - // > z=q - exp(c) * p [1] 0.8656744 qs 0.86567442459240929 double + // > z=q - exp(c) * p [1] 0.8656744 qs 0.86567442459240929 double // Is this the complement? cout << "qgamma(0.2, 0.5, 1) expect 0.0320923 = " << qgamma(0.2, 0.5, 1) << endl; // qgamma(0.2, 0.5, 1) expect 0.0320923 = 0.032092377333650807 - - cout << "qinvgauss(pinvgauss(x, 1, 1) = " << q + + cout << "qinvgauss(pinvgauss(x, 1, 1) = " << q << ", diff = " << x - q << ", fraction = " << (x - q) /x << endl; // 0.5 */ // > SuppDists::pinvGauss(0.02, 1,1) [1] 4.139176e-12 @@ -241,15 +241,15 @@ for a probability for a few probability from the above table, for z = 0.4, 1.0, // pinvGauss(1,1,1) = 0.668102 C++ == 0.66810200122317065 - // qinvGauss(0.668102,1,1) = 1 + // qinvGauss(0.668102,1,1) = 1 // SuppDists::pinvGauss(0.3,1,1) = 0.1657266 // cout << "qinvGauss(0.0040761113207110162, 1, 1) = " << qinvgauss(0.0040761113207110162, 1, 1) << endl; //cout << "quantile(s, 0.1657266) = " << quantile(s, 0.1657266) << endl; // expect 1. - //wald s12(2, 1); + //wald s12(2, 1); //cout << "qinvGauss(0.3, 2, 1) = " << qinvgauss(0.3, 2, 1) << endl; // SuppDists::qinvGauss(0.3,2,1) == 0.58288065635052944 - //// but actually get qinvGauss(0.3, 2, 1) = 0.58288064777632187 + //// but actually get qinvGauss(0.3, 2, 1) = 0.58288064777632187 //cout << "cdf(s12, 0.3) = " << cdf(s12, 0.3) << endl; // cdf(s12, 0.3) = 0.10895339868447573 // using boost::math::wald; @@ -295,8 +295,8 @@ for a probability for a few probability from the above table, for z = 0.4, 1.0, cout.precision(6); // Restore to default. } // try catch(const std::exception& e) - { // Always useful to include try & catch blocks because default policies - // are to throw exceptions on arguments that cause errors like underflow, overflow. + { // Always useful to include try & catch blocks because default policies + // are to throw exceptions on arguments that cause errors like underflow, overflow. // Lacking try & catch blocks, the program will abort without a message below, // which may give some helpful clues as to the cause of the exception. std::cout << @@ -309,14 +309,14 @@ for a probability for a few probability from the above table, for z = 0.4, 1.0, /* Output is: - + inverse_gaussian_example.cpp inverse_gaussian_example.vcxproj -> J:\Cpp\MathToolkit\test\Math_test\Debug\inverse_gaussian_example.exe Example: Inverse Gaussian Distribution. (Standard) Inverse Gaussian distribution, mean = 1, scale = 1 Probability distribution function (pdf) values - z pdf - 2.23e-308 -1.#IND + z pdf + 2.23e-308 -1.#IND 0.2 0.90052111680384117 0.4 1.0055127039453111 0.6 0.75123750098955733 @@ -337,9 +337,9 @@ inverse_gaussian_example.cpp 3.6 0.022840312999395804 3.8 0.019196657941016954 4 0.016189699458236451 - Integral (area under the curve) from 0 up to z (cdf) - z cdf - 2.23e-308 0 + Integral (area under the curve) from 0 up to z (cdf) + z cdf + 2.23e-308 0 0.2 0.063753567519976254 0.4 0.2706136704424541 0.6 0.44638391340412931 @@ -377,33 +377,33 @@ inverse_gaussian_example.cpp > SuppDists::dinvGauss(0.3, 1, 1) [1] 1.072888 > SuppDists::dinvGauss(0.1, 1, 1) [1] 0.2197948 > SuppDists::dinvGauss(0.2, 1, 1) [1] 0.9005211 -> +> x = 0.3 [1, 1] 1.0728879234594337 // R SuppDists::dinvGauss(0.3, 1, 1) [1] 1.072888 x = 1 [1, 1] 0.3989422804014327 - 0 " NA" + 0 " NA" 1 "0.3989422804014327" - 2 "0.10984782236693059" + 2 "0.10984782236693059" 3 "0.039418357969819733" 4 "0.016189699458236468" - 5 "0.007204168934430732" - 6 "0.003379893528659049" + 5 "0.007204168934430732" + 6 "0.003379893528659049" 7 "0.0016462878258114036" 8 "0.00082460931140859956" 9 "0.00042207355643694234" 10 "0.00021979480031862676" -[1] " NA" " 0.690988298942671" "0.11539974210409144" +[1] " NA" " 0.690988298942671" "0.11539974210409144" [4] "0.01799698883772935" "0.0029555399206496469" "0.00050863023587406587" [7] "9.0761842931362914e-05" "1.6655279133132795e-05" "3.1243174913715429e-06" [10] "5.96530227727434e-07" "1.1555606328299836e-07" matC(dinvGauss(0:10, 1, 3), digits=17) df = 3 -[1] " NA" " 0.690988298942671" "0.11539974210409144" +[1] " NA" " 0.690988298942671" "0.11539974210409144" [4] "0.01799698883772935" "0.0029555399206496469" "0.00050863023587406587" [7] "9.0761842931362914e-05" "1.6655279133132795e-05" "3.1243174913715429e-06" [10] "5.96530227727434e-07" "1.1555606328299836e-07" diff --git a/example/lexical_cast_native.cpp b/example/lexical_cast_native.cpp new file mode 100644 index 000000000..aaee6b5d5 --- /dev/null +++ b/example/lexical_cast_native.cpp @@ -0,0 +1,133 @@ +/** lexical_cast_nonfinite_facets.cpp +* +* Copyright (c) 2011 Paul A. Bristow +* +* Distributed under the Boost Software License, Version 1.0. +* (See accompanying file LICENSE_1_0.txt +* or copy at http://www.boost.org/LICENSE_1_0.txt) +* +* This very simple program illustrates how to use the +* `boost/math/nonfinite_num_facets.hpp' with lexical cast +* to obtain C99 representation of infinity and NaN. +* This example is from the original Floating Point Utilities contribution by Johan Rade. +* Floating Point Utility library has been accepted into Boost, +* but the utilities are incorporated into Boost.Math library. +* +\file + +\brief A very simple example of using lexical cast with +non_finite_num facet for C99 standard output of infinity and NaN. + +\detail This example shows how to create a C99 non-finite locale, +and imbue input and output streams with the non_finite_num put and get facets. +This allows lexical_cast output and input of infinity and NaN in a Standard portable way, +This permits 'loop-back' of output back into input (and portably across different system too). + +*/ + +#include +using boost::math::nonfinite_num_get; +using boost::math::nonfinite_num_put; + +#include +using boost::lexical_cast; + +#include +using std::cout; +using std::endl; +using std::cerr; + +#include +using std::setw; +using std::left; +using std::right; +using std::internal; + +#include +using std::string; + +#include +using std::istringstream; + +#include +using std::numeric_limits; + +#include +using std::locale; + +#include + +int main () +{ + std::cout << "lexical_cast example (NOT using finite_num_facet)." << std::endl; + + if((std::numeric_limits::has_infinity == false) || (std::numeric_limits::infinity() == 0)) + { + std::cout << "Infinity not supported on this platform." << std::endl; + return 0; + } + + if((std::numeric_limits::has_quiet_NaN == false) || (std::numeric_limits::quiet_NaN() == 0)) + { + std::cout << "NaN not supported on this platform." << std::endl; + return 0; + } + + // Some tests that are expected to fail on some platforms. + // (But these tests are expected to pass using non_finite num_put and num_get facets). + + // Use the current 'native' default locale. + std::locale default_locale (std::locale::classic ()); // Note the currrent (default C) locale. + + // Create plus and minus infinity. + double plus_infinity = +std::numeric_limits::infinity(); + double minus_infinity = -std::numeric_limits::infinity(); + + // and create a NaN (NotANumber). + double NaN = +std::numeric_limits::quiet_NaN (); + + // Output the nonfinite values using the current (default C) locale. + // The default representations differ from system to system, + // for example, using Microsoft compilers, 1.#INF, -1.#INF, and 1.#QNAN. + cout << "Using default locale" << endl; + cout << "+std::numeric_limits::infinity() = " << plus_infinity << endl; + cout << "-std::numeric_limits::infinity() = " << minus_infinity << endl; + cout << "+std::numeric_limits::quiet_NaN () = " << NaN << endl; + + // Checks below are expected to fail on some platforms! + + // Now try some 'round-tripping', 'reading' "inf" + double x = boost::lexical_cast("inf"); + // and check we get a floating-point infinity. + BOOST_ASSERT(x == std::numeric_limits::infinity()); + + // Check we can convert the other way from floating-point infinity, + string s = boost::lexical_cast(numeric_limits::infinity()); + // to a C99 string representation as "inf". + BOOST_ASSERT(s == "inf"); + + // Finally try full 'round-tripping' (in both directions): + BOOST_ASSERT(lexical_cast(lexical_cast(numeric_limits::infinity())) + == numeric_limits::infinity()); + BOOST_ASSERT(lexical_cast(lexical_cast("inf")) == "inf"); + + return 0; +} // int main() + +/* + +Output: + +from MSVC 10, fails (as expected) + + lexical_cast_native.vcxproj -> J:\Cpp\fp_facet\fp_facet\Debug\lexical_cast_native.exe + lexical_cast example (NOT using finite_num_facet). + Using default locale + +std::numeric_limits::infinity() = 1.#INF + -std::numeric_limits::infinity() = -1.#INF + +std::numeric_limits::quiet_NaN () = 1.#QNAN +C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: The command ""J:\Cpp\fp_facet\fp_facet\Debug\lexical_cast_native.exe" +C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: :VCEnd" exited with code 3. + + +*/ diff --git a/example/lexical_cast_nonfinite_facets.cpp b/example/lexical_cast_nonfinite_facets.cpp new file mode 100644 index 000000000..71360915d --- /dev/null +++ b/example/lexical_cast_nonfinite_facets.cpp @@ -0,0 +1,131 @@ +/** lexical_cast_nonfinite_facets.cpp +* +* Copyright (c) 2011 Paul A. Bristow +* +* Distributed under the Boost Software License, Version 1.0. +* (See accompanying file LICENSE_1_0.txt +* or copy at http://www.boost.org/LICENSE_1_0.txt) +* +* This very simple program illustrates how to use the +* `boost/math/nonfinite_num_facets.hpp' with lexical cast +* to obtain C99 representation of infinity and NaN. +* This example is from the original Floating Point Utilities contribution by Johan Rade. +* Floating Point Utility library has been accepted into Boost, +* but the utilities are incorporated into Boost.Math library. +* +\file + +\brief A very simple example of using lexical cast with +non_finite_num facet for C99 standard output of infinity and NaN. + +\detail This example shows how to create a C99 non-finite locale, +and imbue input and output streams with the non_finite_num put and get facets. +This allows lexical_cast output and input of infinity and NaN in a Standard portable way, +This permits 'loop-back' of output back into input (and portably across different system too). + +See also lexical_cast_native.cpp which is expected to fail on many systems, +but might succeed if the default locale num_put and num_get facets +comply with C99 nonfinite input and output specification. + +*/ + +#include +using boost::math::nonfinite_num_get; +using boost::math::nonfinite_num_put; + +#include +using boost::lexical_cast; + +#include +using std::cout; +using std::endl; +using std::cerr; + +#include +using std::setw; +using std::left; +using std::right; +using std::internal; + +#include +using std::string; + +#include +using std::istringstream; + +#include +using std::numeric_limits; + +#include +using std::locale; + +#include + +int main () +{ + std::cout << "finite_num_facet with lexical_cast example." << std::endl; + + // Example of using non_finite num_put and num_get facets with lexical_cast. + //locale old_locale; + //locale tmp_locale(old_locale, new nonfinite_num_put); + //// Create a new temporary output locale, and add the output nonfinite_num_put facet. + + //locale new_locale(tmp_locale, new nonfinite_num_get); + // Create a new output locale (from the tmp locale), and add the input nonfinite_num_get facet. + + // Note that you can only add facets one at a time, + // unless you chain thus: + + std::locale new_locale(std::locale(std::locale(), + new boost::math::nonfinite_num_put), + new boost::math::nonfinite_num_get); + + locale::global(new_locale); // Newly constructed streams + // (including those streams inside lexical_cast) + // now use new_locale with nonfinite facets. + + // Output using the new locale. + cout << "Using C99_out_locale " << endl; + cout.imbue(new_locale); + // Necessary because cout already constructed using default C locale, + // and default facets for nonfinites. + + // Create plus and minus infinity. + double plus_infinity = +std::numeric_limits::infinity(); + double minus_infinity = -std::numeric_limits::infinity(); + + // and create a NaN (NotANumber) + double NaN = +std::numeric_limits::quiet_NaN (); + cout << "+std::numeric_limits::infinity() = " << plus_infinity << endl; + cout << "-std::numeric_limits::infinity() = " << minus_infinity << endl; + cout << "+std::numeric_limits::quiet_NaN () = " << NaN << endl; + + // Now try some 'round-tripping', 'reading' "inf" + double x = boost::lexical_cast("inf"); + // and check we get a floating-point infinity. + BOOST_ASSERT(x == std::numeric_limits::infinity()); + + // Check we can convert the other way from floating-point infinity, + string s = boost::lexical_cast(numeric_limits::infinity()); + // to a C99 string representation as "inf". + BOOST_ASSERT(s == "inf"); + + // Finally try full 'round-tripping' (in both directions): + BOOST_ASSERT(lexical_cast(lexical_cast(numeric_limits::infinity())) + == numeric_limits::infinity()); + BOOST_ASSERT(lexical_cast(lexical_cast("inf")) == "inf"); + + return 0; +} // int main() + +/* + +Output: + + finite_num_facet with lexical_cast example. + Using C99_out_locale + +std::numeric_limits::infinity() = inf + -std::numeric_limits::infinity() = -inf + +std::numeric_limits::quiet_NaN () = nan + +*/ diff --git a/example/nonfinite_facet_simple.cpp b/example/nonfinite_facet_simple.cpp new file mode 100644 index 000000000..9a0a2027f --- /dev/null +++ b/example/nonfinite_facet_simple.cpp @@ -0,0 +1,259 @@ +/** nonfinite_num_facet.cpp +* +* Copyright (c) 2011 Paul A. Bristow +* +* Distributed under the Boost Software License, Version 1.0. +* (See accompanying file LICENSE_1_0.txt +* or copy at http://www.boost.org/LICENSE_1_0.txt) +* +* This very simple program illustrates how to use the +* `boost/math/nonfinite_num_facets.hpp' to obtain C99 +* representation of infinity and NaN. +* (from the original +* Floating Point Utilities contribution by Johan Rade. +* Floating Point Utility library has been accepted into Boost, +* but the utilities are incorporated into Boost.Math library. +* +\file + +\brief A very simple example of using non_finite_num facet for +C99 standard output of infinity and NaN. + +\detail Provided infinity and nan are supported, +this example shows how to create a C99 non-finite locale, +and imbue input and output streams with the non_finite_num put and get facets. +This allow output and input of infinity and NaN in a Standard portable way, +This permits 'loop-back' of output back into input (and portably across different system too). +This is particularly useful when used with Boost.Seralization so that non-finite NaNs and infinity +values in text and xml archives can be handled correctly and portably. + +*/ + +#ifdef _MSC_VER +# pragma warning (disable : 4127) // conditional expression is constant. +#endif + +#include +using std::cout; +using std::endl; +using std::cerr; + +#include +using std::setw; +using std::left; +using std::right; +using std::internal; + +#include +using std::string; + +#include +using std::istringstream; + +#include +using std::numeric_limits; + +#include +using std::locale; + +#include +// from Johan Rade Floating Point Utilities. + +int main () +{ + std::cout << "Nonfinite_num_facet very simple example." << std::endl; + + if((std::numeric_limits::has_infinity == 0) || (std::numeric_limits::infinity() == 0)) + { + std::cout << "Infinity not supported on this platform." << std::endl; + return 0; + } + + if((std::numeric_limits::has_quiet_NaN == 0) || (std::numeric_limits::quiet_NaN() == 0)) + { + std::cout << "NaN not supported on this platform." << std::endl; + return 0; + } + + std::locale default_locale (std::locale::classic ()); // Note the currrent (default C) locale. + + // Create plus and minus infinity. + double plus_infinity = +std::numeric_limits::infinity(); + double minus_infinity = -std::numeric_limits::infinity(); + + // and create a NaN (NotANumber) + double NaN = +std::numeric_limits::quiet_NaN (); + + // Output the nonfinite values using the current (default C) locale. + // The default representations differ from system to system, + // for example, using Microsoft compilers, 1.#INF, -1.#INF, and 1.#QNAN. + cout << "Using C locale" << endl; + cout << "+std::numeric_limits::infinity() = " << plus_infinity << endl; + cout << "-std::numeric_limits::infinity() = " << minus_infinity << endl; + cout << "+std::numeric_limits::quiet_NaN () = " << NaN << endl; + + // Create a new output locale, and add the nonfinite_num_put facet + std::locale C99_out_locale (default_locale, new boost::math::nonfinite_num_put); + // and imbue the cout stream with the new locale. + cout.imbue (C99_out_locale); + + // Or for the same effect more concisely: + cout.imbue (locale(locale(), new boost::math::nonfinite_num_put)); + + // Output using the new locale + cout << "Using C99_out_locale " << endl; + cout << "+std::numeric_limits::infinity() = " << plus_infinity << endl; + cout << "-std::numeric_limits::infinity() = " << minus_infinity << endl; + cout << "+std::numeric_limits::quiet_NaN () = " << NaN << endl; + + + // Create a string with the expected C99 representation of plus infinity. + std::string inf = "inf"; + { // Try to read an infinity value using the default C locale. + // Create an input stream which will provide "inf" + std::istringstream iss (inf); + + // Create a double ready to take the input, + double infinity; + // and read "inf" from the stringstream: + iss >> infinity; + + // This will not work on all platforms! + if (! iss) + { // Reading infinity went wrong! + std::cerr << "C locale input format error!" << std::endl; + } + } // Using default C locale. + + { // Now retry using C99 facets. + // Create a new input locale and add the nonfinite_num_get facet. + std::locale C99_in_locale (default_locale, new boost::math::nonfinite_num_get); + + // Create an input stream which will provide "inf". + std::istringstream iss (inf); + // Imbue the stream with the C99 input locale. + iss.imbue (C99_in_locale); + + // Create a double ready to take the input, + double infinity; + // and read from the stringstream: + iss >> infinity; + + if (! iss) + { // Reading infinity went wrong! + std::cout << "C99 input format error!" << std::endl; + } + // Expect to get an infinity, which will display still using the C99 locale as "inf" + cout << "infinity in C99 representation is " << infinity << endl; + + // To check, we can switch back to the default C locale. + cout.imbue (default_locale); + cout << "infinity in default C representation is " << infinity << endl; + } // using C99 locale. + + { + // A 'loop-back example, output to a stringstream, and reading it back in. + // Create C99 input and output locales. + std::locale C99_out_locale (default_locale, new boost::math::nonfinite_num_put); + std::locale C99_in_locale (default_locale, new boost::math::nonfinite_num_get); + + std::ostringstream oss; + oss.imbue(C99_out_locale); + oss << plus_infinity; + + std::istringstream iss(oss.str()); // So stream contains "inf". + iss.imbue (C99_in_locale); + + std::string s; + + iss >> s; + + cout.imbue(C99_out_locale); + if (oss.str() != s) + { + cout << plus_infinity << " != " << s << " loopback failed!" << endl; + } + else + { + cout << plus_infinity << " == " << s << " as expected." << endl; + } + } + + + // Example varying the width and position of the nonfinite representations. + // With the nonfinite_num_put and _get facets, the width of the output is constant. + + #ifdef BOOST_NO_NUMERIC_LIMITS_LOWEST + cout << "BOOST_NO_NUMERIC_LIMITS_LOWEST is defined, so no max_digits10 available." << endl; + std::streamsize max_digits10 = 2 + std::numeric_limits::digits * 30103UL / 100000UL; +#else + // Can use new C++0X max_digits10 (the maximum potentially significant digits). + std::streamsize max_digits10 = std::numeric_limits::max_digits10; +#endif + cout << "std::numeric_limits::max_digits10 is " << max_digits10 << endl; + cout.precision(max_digits10); + + double pi = 3.141592653589793238462643383279502884197169399375105820974944; + // Expect 17 (probably) decimal digits (regardless of locale). + // cout has the default locale. + cout << "pi = " << pi << endl; // pi = 3.1415926535897931 + cout.imbue (C99_out_locale); // Use cout with the C99 locale + // (expect the same output for a double). + cout << "pi = " << pi << endl; // pi = 3.1415926535897931 + + cout << "infinity in C99 representation is " << plus_infinity << endl; + + //int width = 2; // Check effect if width too small is OK. + // (There was a disturbed layout on older MSVC?). + int width = 20; + + // Similarly if we can switch back to the default C locale. + cout.imbue (default_locale); + cout << "infinity in default C representation is " << plus_infinity << endl; + cout << "infinity in default C representation (setw(" << width << ") is " << setw(width) << plus_infinity <<'|' << endl; + cout << "infinity in default C representation (setw(" << width << ") is " << left << setw(width) << plus_infinity <<'|' << endl; + cout << "infinity in default C representation (setw(" << width << ") is " << internal << setw(width) << plus_infinity <<'|' << endl; + + cout.imbue (C99_out_locale); + cout << "infinity in C99 representation (setw(" << width << ") is " << right << setw(width) << plus_infinity <<'|'<< endl; + cout << "infinity in C99 representation (setw(" << width << ") is " << left << setw(width) << plus_infinity <<'|'<< endl; + cout << "infinity in C99 representation (setw(" << width << ") is " << internal << setw(width) << plus_infinity <<'|'<< endl; + + return 0; +} // int main() + +// end of test_nonfinite_num_facets.cpp + +/* + +Output: + +simple_nonfinite_facet.vcxproj -> J:\Cpp\MathToolkit\test\Math_test\Release\nonfinite_facet_simple.exe + Nonfinite_num_facet very simple example. + Using C locale + +std::numeric_limits::infinity() = 1.#INF + -std::numeric_limits::infinity() = -1.#INF + +std::numeric_limits::quiet_NaN () = 1.#QNAN + Using C99_out_locale + +std::numeric_limits::infinity() = inf + -std::numeric_limits::infinity() = -inf + +std::numeric_limits::quiet_NaN () = nan + infinity in C99 representation is inf + infinity in default C representation is 1.#INF + 3 + 3 + inf == inf as expected. + std::numeric_limits::max_digits10 is 17 + pi = 3.1415926535897931 + C locale input format error! + pi = 3.1415926535897931 + infinity in C99 representation is inf + infinity in default C representation is 1.#INF + infinity in default C representation (setw(20) is 1.#INF| + infinity in default C representation (setw(20) is 1.#INF | + infinity in default C representation (setw(20) is 1.#INF| + infinity in C99 representation (setw(20) is inf| + infinity in C99 representation (setw(20) is inf | + infinity in C99 representation (setw(20) is inf| + +*/ diff --git a/example/nonfinite_facet_sstream.cpp b/example/nonfinite_facet_sstream.cpp new file mode 100644 index 000000000..686ff94c2 --- /dev/null +++ b/example/nonfinite_facet_sstream.cpp @@ -0,0 +1,132 @@ +// nonfinite_facet_sstream.cpp + +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +// Copyright (c) 2006 Johan Rade +// Copyright (c) 2011 Paul A. Bristow + +/*! +\file +\brief Examples of nonfinite with output and input facets and stringstreams. + +\detail Contruct a new locale with the nonfinite_num_put and nonfinite_num_get +facets and imbue istringstream, ostringstream and stringstreams, +showing output and input (and loopback for the stringstream). + +*/ + +#include +using boost::math::nonfinite_num_put; +using boost::math::nonfinite_num_get; + +using boost::math::legacy; + +#include +using std::cout; +using std::endl; +#include +using std::locale; + +#include +using std::stringstream; +using std::istringstream; +using std::ostringstream; + +#include +using std::numeric_limits; + +#include + +int main() +{ + //[nonfinite_facets_sstream_1 + locale old_locale; + locale tmp_locale(old_locale, new nonfinite_num_put); + locale new_locale(tmp_locale, new nonfinite_num_get); + //] [/nonfinite_facets_sstream_1] + + // Note that to add two facets, nonfinite_num_put and nonfinite_num_get, + // you have to add one at a time, using a temporary locale. + + { + ostringstream oss; + oss.imbue(new_locale); + double inf = numeric_limits::infinity(); + oss << inf; // Write out. + cout << "infinity output was " << oss.str() << endl; + assert(oss.str() == "inf"); + } + { + istringstream iss; + iss.str("inf"); + iss.imbue(new_locale); + double inf; + iss >> inf; // Read from "inf" + cout << "Infinity input was " << iss.str() << endl; + assert(inf == numeric_limits::infinity()); + } + + { + //[nonfinite_facets_sstream_2 + stringstream ss; + ss.imbue(new_locale); + double inf = numeric_limits::infinity(); + ss << inf; // Write out. + assert(ss.str() == "inf"); + double r; + ss >> r; // Read back in. + assert(inf == r); // Confirms that the double values really are identical. + + cout << "infinity output was " << ss.str() << endl; + cout << "infinity input was " << r << endl; + // But the string representation of r displayed will be the native type + // because, when it was constructed, cout had NOT been imbued + // with the new locale containing the nonfinite_numput facet. + // So the cout output will be "1.#INF on MS platforms + // and may be "inf" or other string representation on other platforms. + + //] [/nonfinite_facets_sstream_2] + } + + { + stringstream ss; + ss.imbue(new_locale); + + double nan = numeric_limits::quiet_NaN(); + ss << nan; // Write out. + assert(ss.str() == "nan"); + + double v; + ss >> v; // Read back in. + + cout << "NaN output was " << ss.str() << endl; + cout << "NaN input was " << v << endl; + + // assert(nan == v); // Always fails because NaN == NaN fails! + // assert(nan == numeric_limits::quiet_NaN()); asserts! + + // And the string representation will be the native type + // because cout has NOT been imbued with a locale containing + // the nonfinite_numput facet. + // So the output will be "1.#QNAN on MS platforms + // and may be "nan" or other string representation on other platforms. + } + +} // int main() + + +/* +//[nonfinite_facet_sstream_output + +infinity output was inf +Infinity input was inf +infinity output was inf +infinity input was 1.#INF +NaN output was nan +NaN input was 1.#QNAN + +//] [nonfinite_facet_sstream_output] +*/ + diff --git a/example/nonfinite_legacy.cpp b/example/nonfinite_legacy.cpp new file mode 100644 index 000000000..11b84e6a2 --- /dev/null +++ b/example/nonfinite_legacy.cpp @@ -0,0 +1,94 @@ +// nonfinite_legacy.cpp + +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +// Copyright (c) 2006 Johan Rade +// Copyright (c) 2011 Paul A. Bristow + +/*! +\file +\brief Basic tests of nonfinite loopback with output and input facet. + +\detail Basic loopback test outputs using the so-called 'legacy' facets, +"1.#INF" and "1.#QNAN". + +and reads back in using nonfinite input 'legacy' facet, and +(if possible) checks if loopback OK. + +*/ + +#include +using boost::math::nonfinite_num_put; +using boost::math::nonfinite_num_get; + +using boost::math::legacy; + +#include +using std::cout; +using std::endl; + +#include +using std::setfill; +using std::setw; + +#include +using std::locale; + +#include +using std::stringstream; +#include +using std::numeric_limits; + +#include + +int main() +{ + // Create a new locale with both the nonfinite facets. + std::locale new_locale(std::locale(std::locale(), + new boost::math::nonfinite_num_put), + new boost::math::nonfinite_num_get); + + { + stringstream ss; + ss.imbue(new_locale); + double inf = numeric_limits::infinity(); + ss << inf; // Write out. + double r; + ss >> r; // Read back in. + + cout << "infinity output was " << inf << endl; + cout << "infinity input was " << r << endl; + + assert(inf == r); + } + { + stringstream ss; + ss.imbue(new_locale); + + double nan = numeric_limits::quiet_NaN(); + ss << nan; // Write out. + double v; + ss >> v; // Read back in. + + cout << "NaN output was " << nan << endl; + cout << "NaN input was " << v << endl; + + // assert(nan == v); // Always fails because NaN == NaN fails! + // assert(nan == numeric_limits::quiet_NaN()); asserts! + } + +} // int main() + +/* + +Output: + +infinity output was 1.#INF +infinity input was 1.#INF +NaN output was 1.#QNAN +NaN input was 1.#QNAN + +*/ + diff --git a/example/nonfinite_loopback_ok.cpp b/example/nonfinite_loopback_ok.cpp new file mode 100644 index 000000000..adeea76c3 --- /dev/null +++ b/example/nonfinite_loopback_ok.cpp @@ -0,0 +1,89 @@ +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +// Copyright (c) 2006 Johan Rade +// Copyright (c) 2011 Paul A. Bristow + +/*! +\file +\brief Basic tests of nonfinite loopback. + +\detail Basic loopback test outputs using nonfinite facets +(output and input) and reads back in, and checks if loopback OK. + +Expected to work portably on all platforms. + +*/ + +#ifdef _MSC_VER +# pragma warning(disable : 4702) +# pragma warning(disable : 4127) // conditional expression is constant. +#endif + +#include +using boost::math::nonfinite_num_get; +using boost::math::nonfinite_num_put; + +#include +using std::cout; +using std::endl; + +#include +using std::locale; + +#include +using std::stringstream; +#include +using std::numeric_limits; + +#include + +int main() +{ + + if((std::numeric_limits::has_infinity == false) || (std::numeric_limits::infinity() == 0)) + { + std::cout << "Infinity not supported on this platform." << std::endl; + return 0; + } + + if((std::numeric_limits::has_quiet_NaN == false) || (std::numeric_limits::quiet_NaN() == 0)) + { + std::cout << "NaN not supported on this platform." << std::endl; + return 0; + } + //locale old_locale; // Current global locale. + // Create tmp_locale and store the output nonfinite_num_put facet in it. + //locale tmp_locale(old_locale, new nonfinite_num_put); + // Create new_locale and store the input nonfinite_num_get facet in it. + //locale new_locale(tmp_locale, new nonfinite_num_get); + // Can only add one facet at a time, hence need a tmp_locale. + // Unless we write: + + std::locale new_locale(std::locale(std::locale(std::locale(), + new boost::math::nonfinite_num_put), + new boost::math::nonfinite_num_get)); + + stringstream ss; // Both input and output, so need both get and put facets. + + ss.imbue(new_locale); + + double inf = numeric_limits::infinity(); + ss << inf; // Write out. + double r; + ss >> r; // Read back in. + + assert(inf == r); // OK MSVC <= 10.0! + +} // int main() + +/* + +Output: + +nonfinite_loopback_ok.vcxproj -> J:\Cpp\fp_facet\fp_facet\Debug\nonfinite_loopback_ok.exe + +*/ + + diff --git a/example/nonfinite_num_facet.cpp b/example/nonfinite_num_facet.cpp new file mode 100644 index 000000000..c9fbbddfb --- /dev/null +++ b/example/nonfinite_num_facet.cpp @@ -0,0 +1,291 @@ +/** nonfinite_num_facet.cpp + * + * Copyright (c) 2011 Francois Mauger + * Copyright (c) 2011 Paul A. Bristow + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt + * or copy at http://www.boost.org/LICENSE_1_0.txt) + * + * This simple program illustrates how to use the + * `boost/math/nonfinite_num_facets.hpp' material from the original + * Floating Point Utilities contribution by Johan Rade. + * Floating Point Utility library has been accepted into Boost, + * but the utilities have been/will be incorporated into Boost.Math library. + * +\file + +\brief A fairly simple example of using non_finite_num facet for +C99 standard output of infinity and NaN. + +\detail This program illustrates how to use the + `boost/math/nonfinite_num_facets.hpp' material from the original + Floating Point Utilities contribution by Johan Rade. + Floating Point Utility library has been accepted into Boost, + but the utilities have been/will be incorporated into Boost.Math library. + + Based on an example from Francois Mauger. + + Double and float variables are assigned ordinary finite values (pi), + and nonfinite like infinity and NaN. + + These values are then output and read back in, and then redisplayed. + +*/ + +#ifdef _MSC_VER +# pragma warning(disable : 4127) // conditional expression is constant. +#endif + +#include +#include +using std::cout; +using std::endl; + +#include // numeric_limits +using std::numeric_limits; + +#include + +#include + +static const char sep = ','; // Separator of bracketed float and double values. + +// Use max_digits10 (or equivalent) to obtain +// all potentially significant decimal digits for the floating-point types. + +#ifdef BOOST_NO_NUMERIC_LIMITS_LOWEST + std::streamsize max_digits10_float = 2 + std::numeric_limits::digits * 30103UL / 100000UL; + std::streamsize max_digits10_double = 2 + std::numeric_limits::digits * 30103UL / 100000UL; +#else + // Can use new C++0X max_digits10 (the maximum potentially significant digits). + std::streamsize max_digits10_float = std::numeric_limits::max_digits10; + std::streamsize max_digits10_double = std::numeric_limits::max_digits10; +#endif + + +/* A class with a float and a double */ +struct foo +{ + foo () : fvalue (3.1415927F), dvalue (3.1415926535897931) + { + } + // Set both the values to -infinity : + void minus_infinity () + { + fvalue = -std::numeric_limits::infinity (); + dvalue = -std::numeric_limits::infinity (); + return; + } + // Set the values to +infinity : + void plus_infinity () + { + fvalue = +std::numeric_limits::infinity (); + dvalue = +std::numeric_limits::infinity (); + return; + } + // Set the values to NaN : + void nan () + { + fvalue = +std::numeric_limits::quiet_NaN (); + dvalue = +std::numeric_limits::quiet_NaN (); + return; + } + // Print a foo: + void print (std::ostream & a_out, const std::string & a_title) + { + if (a_title.empty ()) a_out << "foo"; + else a_out << a_title; + a_out << " : " << std::endl; + a_out << "|-- " << "fvalue = "; + + a_out.precision (max_digits10_float); + a_out << fvalue << std::endl; + a_out << "`-- " << "dvalue = "; + a_out.precision (max_digits10_double); + a_out << dvalue << std::endl; + return; + } + + // I/O operators for a foo structure of a float and a double : + friend std::ostream & operator<< (std::ostream & a_out, const foo & a_foo); + friend std::istream & operator>> (std::istream & a_in, foo & a_foo); + + // Attributes : + float fvalue; // Single precision floating number. + double dvalue; // Double precision floating number. +}; + +std::ostream & operator<< (std::ostream & a_out, const foo & a_foo) +{ // Output bracketed FPs, for example "(3.1415927,3.1415926535897931)" + a_out.precision (max_digits10_float); + a_out << "(" << a_foo.fvalue << sep ; + a_out.precision (max_digits10_double); + a_out << a_foo.dvalue << ")"; + return a_out; +} + +std::istream & operator>> (std::istream & a_in, foo & a_foo) +{ // Input bracketed floating-point values into a foo structure, + // for example from "(3.1415927,3.1415926535897931)" + char c = 0; + a_in.get (c); + if (c != '(') + { + std::cerr << "ERROR: operator>> No ( " << std::endl; + a_in.setstate(std::ios::failbit); + return a_in; + } + float f; + a_in >> std::ws >> f; + if (! a_in) + { + return a_in; + } + a_in >> std::ws; + a_in.get (c); + if (c != sep) + { + std::cerr << "ERROR: operator>> c='" << c << "'" << std::endl; + std::cerr << "ERROR: operator>> No '" << sep << "'" << std::endl; + a_in.setstate(std::ios::failbit); + return a_in; + } + double d; + a_in >> std::ws >> d; + if (! a_in) + { + return a_in; + } + a_in >> std::ws; + a_in.get (c); + if (c != ')') + { + std::cerr << "ERROR: operator>> No ) " << std::endl; + a_in.setstate(std::ios::failbit); + return a_in; + } + a_foo.fvalue = f; + a_foo.dvalue = d; + return a_in; +} // std::istream & operator>> (std::istream & a_in, foo & a_foo) + +int main () +{ + std::cout << "nonfinite_num_facet simple example." << std::endl; + + if((std::numeric_limits::has_infinity == false) || (std::numeric_limits::infinity() == 0)) + { + std::cout << "Infinity not supported on this platform." << std::endl; + return 0; + } + + if((std::numeric_limits::has_quiet_NaN == false) || (std::numeric_limits::quiet_NaN() == 0)) + { + std::cout << "NaN not supported on this platform." << std::endl; + return 0; + } + +#ifdef BOOST_NO_NUMERIC_LIMITS_LOWEST + cout << "BOOST_NO_NUMERIC_LIMITS_LOWEST is defined, so no max_digits10 available either:" + "\n we'll have to calculate our own version." << endl; +#endif + std::cout << "std::numeric_limits::max_digits10 is " << max_digits10_float << endl; + std::cout << "std::numeric_limits::max_digits10 is " << max_digits10_double << endl; + + std::locale the_default_locale (std::locale::classic ()); + + { + std::cout << "Write to a string buffer (using default locale) :" << std::endl; + foo f0; // pi + foo f1; f1.minus_infinity (); + foo f2; f2.plus_infinity (); + foo f3; f3.nan (); + + f0.print (std::cout, "f0"); // pi + f1.print (std::cout, "f1"); // +inf + f2.print (std::cout, "f2"); // -inf + f3.print (std::cout, "f3"); // NaN + + std::ostringstream oss; + std::locale C99_out_locale (the_default_locale, new boost::math::nonfinite_num_put); + oss.imbue (C99_out_locale); + oss.precision (15); + oss << f0 << f1 << f2 << f3; + std::cout << "Output in C99 format is: \"" << oss.str () << "\"" << std::endl; + std::cout << "Output done." << std::endl; + } + + { + std::string the_string = "(3.1415927,3.1415926535897931)(-inf,-inf)(inf,inf)(nan,nan)"; // C99 format + // Must have correct separator! + std::cout << "Read C99 format from a string buffer containing \"" << the_string << "\""<< std::endl; + + std::locale C99_in_locale (the_default_locale, new boost::math::nonfinite_num_get); + std::istringstream iss (the_string); + iss.imbue (C99_in_locale); + + foo f0, f1, f2, f3; + iss >> f0 >> f1 >> f2 >> f3; + if (! iss) + { + std::cerr << "Input Format error !" << std::endl; + } + else + { + std::cerr << "Input OK." << std::endl; + cout << "Display in default locale format " << endl; + f0.print (std::cout, "f0"); + f1.print (std::cout, "f1"); + f2.print (std::cout, "f2"); + f3.print (std::cout, "f3"); + } + std::cout << "Input done." << std::endl; + } + + std::cout << "End nonfinite_num_facet.cpp" << std::endl; + return 0; +} // int main() + + // end of test_nonfinite_num_facets.cpp + +/* + +Output: + +nonfinite_num_facet simple example. + std::numeric_limits::max_digits10 is 8 + std::numeric_limits::max_digits10 is 17 + Write to a string buffer (using default locale) : + f0 : + |-- fvalue = 3.1415927 + `-- dvalue = 3.1415926535897931 + f1 : + |-- fvalue = -1.#INF + `-- dvalue = -1.#INF + f2 : + |-- fvalue = 1.#INF + `-- dvalue = 1.#INF + f3 : + |-- fvalue = 1.#QNAN + `-- dvalue = 1.#QNAN + Output in C99 format is: "(3.1415927,3.1415926535897931)(-inf,-inf)(inf,inf)(nan,nan)" + Output done. + Read C99 format from a string buffer containing "(3.1415927,3.1415926535897931)(-inf,-inf)(inf,inf)(nan,nan)" + Display in default locale format + f0 : + |-- fvalue = 3.1415927 + `-- dvalue = 3.1415926535897931 + f1 : + |-- fvalue = -1.#INF + `-- dvalue = -1.#INF + f2 : + |-- fvalue = 1.#INF + `-- dvalue = 1.#INF + f3 : + |-- fvalue = 1.#QNAN + `-- dvalue = 1.#QNAN + Input done. + End nonfinite_num_facet.cpp + +*/ diff --git a/example/nonfinite_num_facet_serialization.cpp b/example/nonfinite_num_facet_serialization.cpp new file mode 100644 index 000000000..8977ca55b --- /dev/null +++ b/example/nonfinite_num_facet_serialization.cpp @@ -0,0 +1,429 @@ +/** nonfinite_num_facet_serialization.cpp + * + * Copyright (c) 2011 Francois Mauger + * Copyright (c) 2011 Paul A. Bristow + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt + * or copy at http://www.boost.org/LICENSE_1_0.txt) + * + * This sample program by Francois Mauger illustrates how to use the + * `boost/math/nonfinite_num_facets.hpp' material from the original + * Floating Point Utilities contribution by Johan Rade. Here it is + * shown how non finite floating number can be serialized and + * deserialized from I/O streams and/or Boost text/XML archives. It + * produces two archives stored in `test.txt' and `test.xml' files. + * + * Tested with Boost 1.44, gcc 4.4.1, Linux/i686 (32bits). + * Tested with Boost.1.46.1 MSVC 10.0 32 bit. + */ + +#ifdef _MSC_VER +# pragma warning(push) +//# pragma warning(disable : 4100) // unreferenced formal parameter. +#endif + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +// from the Floating Point Utilities : +#include + +static const char sep = ','; // Separator of bracketed float and double values. + +// Use max_digits10 (or equivalent) to obtain +// all potentially significant decimal digits for the floating-point types. + +#ifdef BOOST_NO_NUMERIC_LIMITS_LOWEST + std::streamsize max_digits10_float = 2 + std::numeric_limits::digits * 30103UL / 100000UL; + std::streamsize max_digits10_double = 2 + std::numeric_limits::digits * 30103UL / 100000UL; +#else + // Can use new C++0X max_digits10 (the maximum potentially significant digits). + std::streamsize max_digits10_float = std::numeric_limits::max_digits10; + std::streamsize max_digits10_double = std::numeric_limits::max_digits10; +#endif + + +/* A class with a float and a double */ +struct foo +{ + foo () : fvalue (3.1415927F), dvalue (3.1415926535897931) + { // Construct using 32 and 64-bit max_digits10 decimal digits value of pi. + } + // Set the values at -infinity : + void minus_infinity () + { + fvalue = -std::numeric_limits::infinity (); + dvalue = -std::numeric_limits::infinity (); + return; + } + // Set the values at +infinity : + void plus_infinity () + { + fvalue = +std::numeric_limits::infinity (); + dvalue = +std::numeric_limits::infinity (); + return; + } + // Set the values at NaN : + void nan () + { + fvalue = +std::numeric_limits::quiet_NaN (); + dvalue = +std::numeric_limits::quiet_NaN (); + return; + } + // Print : + void print (std::ostream & a_out, const std::string & a_title) + { + if (a_title.empty ()) a_out << "foo"; + else a_out << a_title; + a_out << " : " << std::endl; + a_out << "|-- " << "fvalue = "; + a_out.precision (7); + a_out << fvalue << std::endl; + a_out << "`-- " << "dvalue = "; + a_out.precision (15); + a_out << dvalue << std::endl; + return; + } + + // I/O operators : + friend std::ostream & operator<< (std::ostream & a_out, const foo & a_foo); + friend std::istream & operator>> (std::istream & a_in, foo & a_foo); + + // Boost serialization : + template + void serialize (Archive & ar, int /*version*/) + { + ar & BOOST_SERIALIZATION_NVP (fvalue); + ar & BOOST_SERIALIZATION_NVP (dvalue); + return; + } + + // Attributes : + float fvalue; // Single precision floating-point number. + double dvalue; // Double precision floating-point number. +}; + +std::ostream & operator<< (std::ostream & a_out, const foo & a_foo) +{ // Output bracketed FPs, for example "(3.1415927,3.1415926535897931)" + a_out.precision (max_digits10_float); + a_out << "(" << a_foo.fvalue << sep ; + a_out.precision (max_digits10_double); + a_out << a_foo.dvalue << ")"; + return a_out; +} + +std::istream & operator>> (std::istream & a_in, foo & a_foo) +{ // Input bracketed floating-point values into a foo structure, + // for example from "(3.1415927,3.1415926535897931)" + char c = 0; + a_in.get (c); + if (c != '(') + { + std::cerr << "ERROR: operator>> No ( " << std::endl; + a_in.setstate(std::ios::failbit); + return a_in; + } + float f; + a_in >> std::ws >> f; + if (! a_in) + { + return a_in; + } + a_in >> std::ws; + a_in.get (c); + if (c != sep) + { + std::cerr << "ERROR: operator>> c='" << c << "'" << std::endl; + std::cerr << "ERROR: operator>> No '" << sep << "'" << std::endl; + a_in.setstate(std::ios::failbit); + return a_in; + } + double d; + a_in >> std::ws >> d; + if (! a_in) + { + return a_in; + } + a_in >> std::ws; + a_in.get (c); + if (c != ')') + { + std::cerr << "ERROR: operator>> No ) " << std::endl; + a_in.setstate(std::ios::failbit); + return a_in; + } + a_foo.fvalue = f; + a_foo.dvalue = d; + return a_in; +} + +int main (void) +{ + std::clog << std::endl + << "Nonfinite_serialization.cpp' example program." << std::endl; + +#ifdef BOOST_NO_NUMERIC_LIMITS_LOWEST + std::cout << "BOOST_NO_NUMERIC_LIMITS_LOWEST is defined, so no max_digits10 available either," + "using our own version instead." << std::endl; +#endif + std::cout << "std::numeric_limits::max_digits10 is " << max_digits10_float << std::endl; + std::cout << "std::numeric_limits::max_digits10 is " << max_digits10_double << std::endl; + + std::locale the_default_locale (std::locale::classic (), + new boost::archive::codecvt_null); + + // Demonstrate use of nonfinite facets with stringstreams. + { + std::clog << "Construct some foo structures with a finite and nonfinites." << std::endl; + foo f0; + foo f1; f1.minus_infinity (); + foo f2; f2.plus_infinity (); + foo f3; f3.nan (); + // Display them. + f0.print (std::clog, "f0"); + f1.print (std::clog, "f1"); + f2.print (std::clog, "f2"); + f3.print (std::clog, "f3"); + std::clog << " Write to a string buffer." << std::endl; + + std::ostringstream oss; + std::locale the_out_locale (the_default_locale, new boost::math::nonfinite_num_put); + oss.imbue (the_out_locale); + oss.precision (max_digits10_double); + oss << f0 << f1 << f2 << f3; + std::clog << "Output is: `" << oss.str () << "'" << std::endl; + std::clog << "Done output to ostringstream." << std::endl; + } + + { + std::clog << "Read foo structures from a string buffer." << std::endl; + + std::string the_string = "(3.1415927,3.1415926535897931)(-inf,-inf)(inf,inf)(nan,nan)"; + std::clog << "Input is: `" << the_string << "'" << std::endl; + + std::locale the_in_locale (the_default_locale, new boost::math::nonfinite_num_get); + std::istringstream iss (the_string); + iss.imbue (the_in_locale); + + foo f0, f1, f2, f3; + iss >> f0 >> f1 >> f2 >> f3; + if (! iss) + { + std::cerr << "Format error !" << std::endl; + } + else + { + std::cerr << "Read OK." << std::endl; + f0.print (std::clog, "f0"); + f1.print (std::clog, "f1"); + f2.print (std::clog, "f2"); + f3.print (std::clog, "f3"); + } + std::clog << "Done input from istringstream." << std::endl; + } + + { // Demonstrate use of nonfinite facets for Serialization with Boost text archives. + std::clog << "Serialize (using Boost text archive)." << std::endl; + // Construct some foo structures with a finite and nonfinites. + foo f0; + foo f1; f1.minus_infinity (); + foo f2; f2.plus_infinity (); + foo f3; f3.nan (); + // Display them. + f0.print (std::clog, "f0"); + f1.print (std::clog, "f1"); + f2.print (std::clog, "f2"); + f3.print (std::clog, "f3"); + + std::locale the_out_locale (the_default_locale, new boost::math::nonfinite_num_put); + std::ofstream fout ("nonfinite_archive_test.txt"); + fout.imbue (the_out_locale); + boost::archive::text_oarchive toar (fout, boost::archive::no_codecvt); + // Write to archive. + toar & f0; + toar & f1; + toar & f2; + toar & f3; + std::clog << "Done." << std::endl; + } + + { + std::clog << "Deserialize (Boost text archive)..." << std::endl; + std::locale the_in_locale (the_default_locale, new boost::math::nonfinite_num_get); + std::ifstream fin ("nonfinite_archive_test.txt"); + fin.imbue (the_in_locale); + boost::archive::text_iarchive tiar (fin, boost::archive::no_codecvt); + foo f0, f1, f2, f3; + // Read from archive. + tiar & f0; + tiar & f1; + tiar & f2; + tiar & f3; + // Display foos. + f0.print (std::clog, "f0"); + f1.print (std::clog, "f1"); + f2.print (std::clog, "f2"); + f3.print (std::clog, "f3"); + + std::clog << "Done." << std::endl; + } + + { // Demonstrate use of nonfinite facets for Serialization with Boost XML Archive. + std::clog << "Serialize (Boost XML archive)..." << std::endl; + // Construct some foo structures with a finite and nonfinites. + foo f0; + foo f1; f1.minus_infinity (); + foo f2; f2.plus_infinity (); + foo f3; f3.nan (); + // Display foos. + f0.print (std::clog, "f0"); + f1.print (std::clog, "f1"); + f2.print (std::clog, "f2"); + f3.print (std::clog, "f3"); + + std::locale the_out_locale (the_default_locale, new boost::math::nonfinite_num_put); + std::ofstream fout ("nonfinite_XML_archive_test.txt"); + fout.imbue (the_out_locale); + boost::archive::xml_oarchive xoar (fout, boost::archive::no_codecvt); + + xoar & BOOST_SERIALIZATION_NVP (f0); + xoar & BOOST_SERIALIZATION_NVP (f1); + xoar & BOOST_SERIALIZATION_NVP (f2); + xoar & BOOST_SERIALIZATION_NVP (f3); + std::clog << "Done." << std::endl; + } + + { + std::clog << "Deserialize (Boost XML archive)..." << std::endl; + std::locale the_in_locale (the_default_locale, new boost::math::nonfinite_num_get); + std::ifstream fin ("nonfinite_XML_archive_test.txt"); + fin.imbue (the_in_locale); + boost::archive::xml_iarchive xiar (fin, boost::archive::no_codecvt); + foo f0, f1, f2, f3; + + xiar & BOOST_SERIALIZATION_NVP (f0); + xiar & BOOST_SERIALIZATION_NVP (f1); + xiar & BOOST_SERIALIZATION_NVP (f2); + xiar & BOOST_SERIALIZATION_NVP (f3); + + f0.print (std::clog, "f0"); + f1.print (std::clog, "f1"); + f2.print (std::clog, "f2"); + f3.print (std::clog, "f3"); + + std::clog << "Done." << std::endl; + } + + std::clog << "End nonfinite_serialization.cpp' example program." << std::endl; + return 0; +} + +/* + +Output: + + Nonfinite_serialization.cpp' example program. + std::numeric_limits::max_digits10 is 8 + std::numeric_limits::max_digits10 is 17 + Construct some foo structures with a finite and nonfinites. + f0 : + |-- fvalue = 3.141593 + `-- dvalue = 3.14159265358979 + f1 : + |-- fvalue = -1.#INF + `-- dvalue = -1.#INF + f2 : + |-- fvalue = 1.#INF + `-- dvalue = 1.#INF + f3 : + |-- fvalue = 1.#QNAN + `-- dvalue = 1.#QNAN + Write to a string buffer. + Output is: `(3.1415927,3.1415926535897931)(-inf,-inf)(inf,inf)(nan,nan)' + Done output to ostringstream. + Read foo structures from a string buffer. + Input is: `(3.1415927,3.1415926535897931)(-inf,-inf)(inf,inf)(nan,nan)' + Read OK. + f0 : + |-- fvalue = 3.141593 + `-- dvalue = 3.14159265358979 + f1 : + |-- fvalue = -1.#INF + `-- dvalue = -1.#INF + f2 : + |-- fvalue = 1.#INF + `-- dvalue = 1.#INF + f3 : + |-- fvalue = 1.#QNAN + `-- dvalue = 1.#QNAN + Done input from istringstream. + Serialize (using Boost text archive). + f0 : + |-- fvalue = 3.141593 + `-- dvalue = 3.14159265358979 + f1 : + |-- fvalue = -1.#INF + `-- dvalue = -1.#INF + f2 : + |-- fvalue = 1.#INF + `-- dvalue = 1.#INF + f3 : + |-- fvalue = 1.#QNAN + `-- dvalue = 1.#QNAN + Done. + Deserialize (Boost text archive)... + f0 : + |-- fvalue = 3.141593 + `-- dvalue = 3.14159265358979 + f1 : + |-- fvalue = -1.#INF + `-- dvalue = -1.#INF + f2 : + |-- fvalue = 1.#INF + `-- dvalue = 1.#INF + f3 : + |-- fvalue = 1.#QNAN + `-- dvalue = 1.#QNAN + Done. + Serialize (Boost XML archive)... + f0 : + |-- fvalue = 3.141593 + `-- dvalue = 3.14159265358979 + f1 : + |-- fvalue = -1.#INF + `-- dvalue = -1.#INF + f2 : + |-- fvalue = 1.#INF + `-- dvalue = 1.#INF + f3 : + |-- fvalue = 1.#QNAN + `-- dvalue = 1.#QNAN + Done. + Deserialize (Boost XML archive)... + f0 : + |-- fvalue = 3.141593 + `-- dvalue = 3.14159265358979 + f1 : + |-- fvalue = -1.#INF + `-- dvalue = -1.#INF + f2 : + |-- fvalue = 1.#INF + `-- dvalue = 1.#INF + f3 : + |-- fvalue = 1.#QNAN + `-- dvalue = 1.#QNAN + Done. + End nonfinite_serialization.cpp' example program. + + */ diff --git a/example/nonfinite_serialization_archives.cpp b/example/nonfinite_serialization_archives.cpp new file mode 100644 index 000000000..0ab158bc9 --- /dev/null +++ b/example/nonfinite_serialization_archives.cpp @@ -0,0 +1,137 @@ +/** nonfinite_serialization_archives.cpp +* +* Copyright (c) 2011 Paul A. Bristow +* +* Distributed under the Boost Software License, Version 1.0. +* (See accompanying file LICENSE_1_0.txt +* or copy at http://www.boost.org/LICENSE_1_0.txt) +* +* This very simple program illustrates how to use the +* `boost/math/nonfinite_num_facets.hpp' to obtain C99 +* representation of infinity and NaN. +* From the original Floating Point Utilities contribution by Johan Rade. +* Floating Point Utility library has been accepted into Boost, +* but the utilities are incorporated into Boost.Math library. +* +\file + +\brief A simple example of using non_finite_num facet for +C99 standard output of infinity and NaN in serialization archives. + +\detail This example shows how to create a C99 non-finite locale, +and imbue input and output streams with the non_finite_num put and get facets. +This allow output and input of infinity and NaN in a Standard portable way, +This permits 'loop-back' of output back into input (and portably across different system too). +This is particularly useful when used with Boost.Seralization so that non-finite NaNs and infinity +values in text and xml archives can be handled correctly and portably. + +*/ + + +#ifdef _MSC_VER +# pragma warning (disable :4224) +# pragma warning(disable : 4127) // conditional expression is constant. +#endif + + +#include +using boost::archive::text_oarchive; +#include +using boost::archive::codecvt_null; +using boost::archive::no_codecvt; + +#include +using boost::math::nonfinite_num_get; +using boost::math::nonfinite_num_put; + +#include +using std::cout; +using std::endl; +using std::cerr; + +#include +using std::setw; +using std::left; +using std::right; +using std::internal; + +#include +using std::string; + +#include +using std::istringstream; + +#include +using std::ofstream; + +#include +using std::numeric_limits; + +#include +using std::locale; + + +/* +Use with serialization archives. + +It is important that the same locale is used +when an archive is saved and when it is loaded. +Otherwise, loading the archive may fail. + +By default, archives are saved and loaded with a classic C locale with a +`boost::archive::codecvt_null` facet added. +Normally you do not have to worry about that. +The constructors for the archive classes, as a side-effect, +imbue the stream with such a locale. + +However, if you want to use the facets `nonfinite_num_put` and `nonfinite_num_get` +with archives,`then you have to manage the locale manually. + +That is done by calling the archive constructor with the flag `boost::archive::no_codecvt`. +Then the archive constructor will not imbue the stream with a new locale. + +The following code shows how to use `nonfinite_num_put` with a `text_oarchive`: + +*/ + +int main() +{ + + if((std::numeric_limits::has_infinity == false) || (std::numeric_limits::infinity() == 0)) + { + std::cout << "Infinity not supported on this platform." << std::endl; + return 0; + } + + if((std::numeric_limits::has_quiet_NaN == false) || (std::numeric_limits::quiet_NaN() == 0)) + { + std::cout << "NaN not supported on this platform." << std::endl; + return 0; + } + + locale default_locale(locale::classic(), new boost::archive::codecvt_null); + // codecvt_null so the archive constructor will not imbue the stream with a new locale. + + locale my_locale(default_locale, new nonfinite_num_put); + // Add nonfinite_num_put facet to locale. + + ofstream ofs("test.txt"); + ofs.imbue(my_locale); + + boost::archive::text_oarchive oa(ofs, no_codecvt); + + double x = numeric_limits::infinity(); + oa & x; + + +} // int main() + + +/* The same method works with nonfinite_num_get and text_iarchive. + +If you use the trap_infinity and trap_nan flags with a serialization archive, +then you must set the exception mask of the stream. +Serialization archives do not check the stream state. + + +*/ diff --git a/example/nonfinite_signaling_NaN.cpp b/example/nonfinite_signaling_NaN.cpp new file mode 100644 index 000000000..98ccdd1d9 --- /dev/null +++ b/example/nonfinite_signaling_NaN.cpp @@ -0,0 +1,189 @@ +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +// Copyright (c) 2006 Johan Rade +// Copyright (c) 2011 Paul A. Bristow + +/*! +\file +\brief Tests of nonfinite signaling NaN loopback. + +\detail nonfinite signaling NaN +test outputs using nonfinite facets +(output and input) and reads back in, and checks if loopback OK. + +Not expected to work on all platforms (if any). But shows that on MSVC, +this legacy locale can ensure a consistent quiet NaN input from representations +"1.#QNAN", "1.#SNAN" and "1.#IND" + +*/ + +#ifdef _MSC_VER +# pragma warning(disable : 4702) +#endif + +#include +using boost::math::nonfinite_num_get; +using boost::math::nonfinite_num_put; + +#include +using std::cout; +using std::endl; + +#include +using std::locale; + +#include +using std::string; + +#include + using std::stringstream; + using std::istringstream; + +#include +using std::numeric_limits; + +int main() +{ + if((std::numeric_limits::has_infinity == false) || (std::numeric_limits::infinity() == 0)) + { + std::cout << "Infinity not supported on this platform." << std::endl; + return 0; + } + + if((std::numeric_limits::has_quiet_NaN == false) || (std::numeric_limits::quiet_NaN() == 0)) + { + std::cout << "NaN not supported on this platform." << std::endl; + return 0; + } + + locale default_locale; // Current global locale. + // Try to use the default locale first. + // On MSVC this doesn't work. + + { // Try Quiet NaN + stringstream ss; // Both input and output. + ss.imbue(default_locale); // Redundant, of course. + string infs; + if(numeric_limits::has_quiet_NaN) + { // Make sure quiet NaN is specialised for type double. + double qnan = numeric_limits::quiet_NaN(); + ss << qnan; // Output quiet_NaN. + infs = ss.str(); // + } + else + { // Need to provide a suitable string for quiet NaN. + infs = "1.#QNAN"; + ss << infs; + } + double r; + ss >> r; // Read back in. + + cout << "quiet_NaN output was " << infs << endl; // "1.#QNAN" + cout << "quiet_NaN input was " << r << endl; // "1" + } + +#if (!defined __BORLANDC__ && !defined __CODEGEARC__) + // These compilers trap when trying to create a signaling_NaN! + { // Try Signaling NaN + stringstream ss; // Both input and output. + ss.imbue(default_locale); // Redundant, of course. + string infs; + if(numeric_limits::has_signaling_NaN) + { // Make sure signaling NaN is specialised for type double. + double qnan = numeric_limits::signaling_NaN(); + ss << qnan; // Output signaling_NaN. + infs = ss.str(); // + } + else + { // Need to provide a suitable string for signaling NaN. + infs = "1.#SNAN"; + ss << infs; + } + double r; + ss >> r; // Read back in. + + cout << "signaling_NaN output was " << infs << endl; // "1.#QNAN" (or "1.#SNAN"?) + cout << "signaling_NaN input was " << r << endl; // "1" + } +#endif // Not Borland or CodeGear. + + // Create legacy_locale and store the nonfinite_num_get facet (with legacy flag) in it. + locale legacy_locale(default_locale, new nonfinite_num_get(boost::math::legacy)); + // Note that the legacy flag has no effect on the nonfinite_num_put output facet. + + cout << "Use legacy locale." << endl; + + { // Try infinity. + stringstream ss; // Both input and output. + ss.imbue(legacy_locale); + string infs; + if(numeric_limits::has_infinity) + { // Make sure infinity is specialised for type double. + double inf = numeric_limits::infinity(); + ss << inf; // Output infinity. + infs = ss.str(); // + } + else + { // Need to provide a suitable string for infinity. + infs = "1.#INF"; + ss << infs; + } + double r; + ss >> r; // Read back in. + + cout << "infinity output was " << infs << endl; // "1.#INF" + cout << "infinity input was " << r << endl; // "1.#INF" + } + + { // Try input of "1.#SNAN". + //double inf = numeric_limits::signaling_NaN(); // Assigns "1.#QNAN" on MSVC. + // So must use explicit string "1.#SNAN" instead. + stringstream ss; // Both input and output. + ss.imbue(legacy_locale); + string s = "1.#SNAN"; + + ss << s; // Write out. + double r; + + ss >> r; // Read back in. + + cout << "SNAN output was " << s << endl; // "1.#SNAN" + cout << "SNAN input was " << r << endl; // "1.#QNAN" + } + + { // Try input of "1.#IND" . + stringstream ss; // Both input and output. + ss.imbue(legacy_locale); + string s = "1.#IND"; + ss << s; // Write out. + double r; + ss >> r; // Read back in. + + cout << "IND output was " << s << endl; // "1.#IND" + cout << "IND input was " << r << endl; // "1.#QNAN" + } + +} // int main() + +/* + +Output: + nonfinite_signaling_NaN.vcxproj -> J:\Cpp\fp_facet\fp_facet\Debug\nonfinite_signaling_NaN.exe + + quiet_NaN output was 1.#QNAN + quiet_NaN input was 1 + signaling_NaN output was 1.#QNAN + signaling_NaN input was 1 + Use legacy locale. + infinity output was 1.#INF + infinity input was 1.#INF + SNAN output was 1.#SNAN + SNAN input was 1.#QNAN + IND output was 1.#IND + IND input was 1.#QNAN + + +*/ + diff --git a/example/test_nonfinite_loopback.cpp b/example/test_nonfinite_loopback.cpp new file mode 100644 index 000000000..c7b8e4204 --- /dev/null +++ b/example/test_nonfinite_loopback.cpp @@ -0,0 +1,97 @@ +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +// Copyright (c) 2006 Johan Rade +// Copyright (c) 2011 Paul A. Bristow + +/*! +\file +\brief Basic tests of native nonfinite loopback. + +\detail Basic loopback test outputs using the platforms built-in facets +and reads back in, and checks if loopback OK. + +Using MSVC this doesn't work OK: +input produces just "1" instead of "1.#QNAN", 1.#SNAN" or 1.#IND"! + +*/ + +#include +using std::cout; +using std::endl; +#include +using std::locale; +#include +using std::string; +#include + using std::stringstream; +#include +using std::numeric_limits; + +int main() +{ + locale default_locale; // Current global locale. + // Try to use the default locale first. + // On MSVC this doesn't work. + + { // Try infinity. + stringstream ss; // Both input and output. + ss.imbue(default_locale); // Redundant, of course. + string infs; + if(numeric_limits::has_infinity) + { // Make sure infinity is specialised for type double. + double inf = numeric_limits::infinity(); + ss << inf; // Output infinity. + infs = ss.str(); // + } + else + { // Need to provide a suitable string for infinity. + infs = "1.#INF"; // Might suit MSVC? + ss << infs; + } + double r; + ss >> r; // Read back in. + + cout << "infinity output was " << infs << endl; // "1.#INF" + cout << "infinity input was " << r << endl; // "1" + } + + { // Try Quiet NaN + stringstream ss; // Both input and output. + ss.imbue(default_locale); // Redundant, of course. + string infs; + if(numeric_limits::has_quiet_NaN) + { // Make sure quiet NaN is specialised for type double. + double qnan = numeric_limits::quiet_NaN(); + ss << qnan; // Output quiet_NaN. + infs = ss.str(); // + } + else + { // Need to provide a suitable string for quiet_NAN. + infs = "1.#QNAN"; + ss << infs; + } + double r; + ss >> r; // Read back in. + + cout << "quiet_NaN output was " << infs << endl; // "1.#QNAN" + cout << "quiet_NaN input was " << r << endl; // "1#" + } + + +} // int main() + +/* + +Output (MSVC Version 10.0): + + + infinity output was 1.#INF + infinity input was 1 + quiet_NaN output was 1.#QNAN + quiet_NaN input was 1 + + +*/ + diff --git a/include/boost/math/bindings/e_float.hpp b/include/boost/math/bindings/e_float.hpp new file mode 100644 index 000000000..d3d72e7ce --- /dev/null +++ b/include/boost/math/bindings/e_float.hpp @@ -0,0 +1,803 @@ +// Copyright John Maddock 2008. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Wrapper that works with mpfr_class defined in gmpfrxx.h +// See http://math.berkeley.edu/~wilken/code/gmpfrxx/ +// Also requires the gmp and mpfr libraries. +// + +#ifndef BOOST_MATH_E_FLOAT_BINDINGS_HPP +#define BOOST_MATH_E_FLOAT_BINDINGS_HPP + +#include + + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace boost{ namespace math{ namespace ef{ + +class e_float +{ +public: + // Constructors: + e_float() {} + e_float(const ::e_float& c) : m_value(c){} + e_float(char c) + { + m_value = ::e_float(c); + } +#ifndef BOOST_NO_INTRINSIC_WCHAR_T + e_float(wchar_t c) + { + m_value = ::e_float(c); + } +#endif + e_float(unsigned char c) + { + m_value = ::e_float(c); + } + e_float(signed char c) + { + m_value = ::e_float(c); + } + e_float(unsigned short c) + { + m_value = ::e_float(c); + } + e_float(short c) + { + m_value = ::e_float(c); + } + e_float(unsigned int c) + { + m_value = ::e_float(c); + } + e_float(int c) + { + m_value = ::e_float(c); + } + e_float(unsigned long c) + { + m_value = ::e_float((UINT64)c); + } + e_float(long c) + { + m_value = ::e_float((INT64)c); + } +#ifdef BOOST_HAS_LONG_LONG + e_float(boost::ulong_long_type c) + { + m_value = ::e_float(c); + } + e_float(boost::long_long_type c) + { + m_value = ::e_float(c); + } +#endif + e_float(float c) + { + assign_large_real(c); + } + e_float(double c) + { + assign_large_real(c); + } + e_float(long double c) + { + assign_large_real(c); + } + + // Assignment: + e_float& operator=(char c) { m_value = ::e_float(c); return *this; } + e_float& operator=(unsigned char c) { m_value = ::e_float(c); return *this; } + e_float& operator=(signed char c) { m_value = ::e_float(c); return *this; } +#ifndef BOOST_NO_INTRINSIC_WCHAR_T + e_float& operator=(wchar_t c) { m_value = ::e_float(c); return *this; } +#endif + e_float& operator=(short c) { m_value = ::e_float(c); return *this; } + e_float& operator=(unsigned short c) { m_value = ::e_float(c); return *this; } + e_float& operator=(int c) { m_value = ::e_float(c); return *this; } + e_float& operator=(unsigned int c) { m_value = ::e_float(c); return *this; } + e_float& operator=(long c) { m_value = ::e_float((INT64)c); return *this; } + e_float& operator=(unsigned long c) { m_value = ::e_float((UINT64)c); return *this; } +#ifdef BOOST_HAS_LONG_LONG + e_float& operator=(boost::long_long_type c) { m_value = ::e_float(c); return *this; } + e_float& operator=(boost::ulong_long_type c) { m_value = ::e_float(c); return *this; } +#endif + e_float& operator=(float c) { assign_large_real(c); return *this; } + e_float& operator=(double c) { assign_large_real(c); return *this; } + e_float& operator=(long double c) { assign_large_real(c); return *this; } + + // Access: + ::e_float& value(){ return m_value; } + ::e_float const& value()const{ return m_value; } + + // Member arithmetic: + e_float& operator+=(const e_float& other) + { m_value += other.value(); return *this; } + e_float& operator-=(const e_float& other) + { m_value -= other.value(); return *this; } + e_float& operator*=(const e_float& other) + { m_value *= other.value(); return *this; } + e_float& operator/=(const e_float& other) + { m_value /= other.value(); return *this; } + e_float operator-()const + { return -m_value; } + e_float const& operator+()const + { return *this; } + +private: + ::e_float m_value; + + template + void assign_large_real(const V& a) + { + using std::frexp; + using std::ldexp; + using std::floor; + if (a == 0) { + m_value = ::ef::zero(); + return; + } + + if (a == 1) { + m_value = ::ef::one(); + return; + } + + if ((boost::math::isinf)(a)) + { + m_value = a > 0 ? m_value.my_value_inf() : -m_value.my_value_inf(); + return; + } + if((boost::math::isnan)(a)) + { + m_value = m_value.my_value_nan(); + return; + } + + int e; + long double f, term; + ::e_float t; + m_value = ::ef::zero(); + + f = frexp(a, &e); + + ::e_float shift = ::ef::pow2(30); + + while(f) + { + // extract 30 bits from f: + f = ldexp(f, 30); + term = floor(f); + e -= 30; + m_value *= shift; + m_value += ::e_float(static_cast(term)); + f -= term; + } + m_value *= ::ef::pow2(e); + } +}; + + +// Non-member arithmetic: +inline e_float operator+(const e_float& a, const e_float& b) +{ + e_float result(a); + result += b; + return result; +} +inline e_float operator-(const e_float& a, const e_float& b) +{ + e_float result(a); + result -= b; + return result; +} +inline e_float operator*(const e_float& a, const e_float& b) +{ + e_float result(a); + result *= b; + return result; +} +inline e_float operator/(const e_float& a, const e_float& b) +{ + e_float result(a); + result /= b; + return result; +} + +// Comparison: +inline bool operator == (const e_float& a, const e_float& b) +{ return a.value() == b.value() ? true : false; } +inline bool operator != (const e_float& a, const e_float& b) +{ return a.value() != b.value() ? true : false;} +inline bool operator < (const e_float& a, const e_float& b) +{ return a.value() < b.value() ? true : false; } +inline bool operator <= (const e_float& a, const e_float& b) +{ return a.value() <= b.value() ? true : false; } +inline bool operator > (const e_float& a, const e_float& b) +{ return a.value() > b.value() ? true : false; } +inline bool operator >= (const e_float& a, const e_float& b) +{ return a.value() >= b.value() ? true : false; } + +std::istream& operator >> (std::istream& is, e_float& f) +{ + return is >> f.value(); +} + +std::ostream& operator << (std::ostream& os, const e_float& f) +{ + return os << f.value(); +} + +inline e_float fabs(const e_float& v) +{ + return ::ef::fabs(v.value()); +} + +inline e_float abs(const e_float& v) +{ + return ::ef::fabs(v.value()); +} + +inline e_float floor(const e_float& v) +{ + return ::ef::floor(v.value()); +} + +inline e_float ceil(const e_float& v) +{ + return ::ef::ceil(v.value()); +} + +inline e_float pow(const e_float& v, const e_float& w) +{ + return ::ef::pow(v.value(), w.value()); +} + +inline e_float pow(const e_float& v, int i) +{ + return ::ef::pow(v.value(), ::e_float(i)); +} + +inline e_float exp(const e_float& v) +{ + return ::ef::exp(v.value()); +} + +inline e_float log(const e_float& v) +{ + return ::ef::log(v.value()); +} + +inline e_float sqrt(const e_float& v) +{ + return ::ef::sqrt(v.value()); +} + +inline e_float sin(const e_float& v) +{ + return ::ef::sin(v.value()); +} + +inline e_float cos(const e_float& v) +{ + return ::ef::cos(v.value()); +} + +inline e_float tan(const e_float& v) +{ + return ::ef::tan(v.value()); +} + +inline e_float acos(const e_float& v) +{ + return ::ef::acos(v.value()); +} + +inline e_float asin(const e_float& v) +{ + return ::ef::asin(v.value()); +} + +inline e_float atan(const e_float& v) +{ + return ::ef::atan(v.value()); +} + +inline e_float ldexp(const e_float& v, int e) +{ + return v.value() * ::ef::pow2(e); +} + +inline e_float frexp(const e_float& v, int* expon) +{ + double d; + INT64 i; + v.value().extract_parts(d, i); + *expon = static_cast(i); + return v.value() * ::ef::pow2(-i); +} + +inline e_float sinh (const e_float& x) +{ + return ::ef::sinh(x.value()); +} + +inline e_float cosh (const e_float& x) +{ + return ::ef::cosh(x.value()); +} + +inline e_float tanh (const e_float& x) +{ + return ::ef::tanh(x.value()); +} + +inline e_float asinh (const e_float& x) +{ + return ::ef::asinh(x.value()); +} + +inline e_float acosh (const e_float& x) +{ + return ::ef::acosh(x.value()); +} + +inline e_float atanh (const e_float& x) +{ + return ::ef::atanh(x.value()); +} + +e_float fmod(const e_float& v1, const e_float& v2) +{ + e_float n; + if(v1 < 0) + n = ceil(v1 / v2); + else + n = floor(v1 / v2); + return v1 - n * v2; +} + +} namespace detail{ + +template <> +inline int fpclassify_imp< boost::math::ef::e_float> BOOST_NO_MACRO_EXPAND(boost::math::ef::e_float x, const generic_tag&) +{ + if(x.value().isnan()) + return FP_NAN; + if(x.value().isinf()) + return FP_INFINITE; + if(x == 0) + return FP_ZERO; + return FP_NORMAL; +} + +} namespace ef{ + +template +inline int itrunc(const e_float& v, const Policy& pol) +{ + BOOST_MATH_STD_USING + e_float r = boost::math::trunc(v, pol); + if(fabs(r) > (std::numeric_limits::max)()) + return static_cast(policies::raise_rounding_error("boost::math::itrunc<%1%>(%1%)", 0, 0, v, pol)); + return static_cast(r.value().extract_int64()); +} + +template +inline long ltrunc(const e_float& v, const Policy& pol) +{ + BOOST_MATH_STD_USING + e_float r = boost::math::trunc(v, pol); + if(fabs(r) > (std::numeric_limits::max)()) + return static_cast(policies::raise_rounding_error("boost::math::ltrunc<%1%>(%1%)", 0, 0L, v, pol)); + return static_cast(r.value().extract_int64()); +} + +#ifdef BOOST_HAS_LONG_LONG +template +inline boost::long_long_type lltrunc(const e_float& v, const Policy& pol) +{ + BOOST_MATH_STD_USING + e_float r = boost::math::trunc(v, pol); + if(fabs(r) > (std::numeric_limits::max)()) + return static_cast(policies::raise_rounding_error("boost::math::lltrunc<%1%>(%1%)", 0, v, 0LL, pol).value().extract_int64()); + return static_cast(r.value().extract_int64()); +} +#endif + +template +inline int iround(const e_float& v, const Policy& pol) +{ + BOOST_MATH_STD_USING + e_float r = boost::math::round(v, pol); + if(fabs(r) > (std::numeric_limits::max)()) + return static_cast(policies::raise_rounding_error("boost::math::iround<%1%>(%1%)", 0, v, 0, pol).value().extract_int64()); + return static_cast(r.value().extract_int64()); +} + +template +inline long lround(const e_float& v, const Policy& pol) +{ + BOOST_MATH_STD_USING + e_float r = boost::math::round(v, pol); + if(fabs(r) > (std::numeric_limits::max)()) + return static_cast(policies::raise_rounding_error("boost::math::lround<%1%>(%1%)", 0, v, 0L, pol).value().extract_int64()); + return static_cast(r.value().extract_int64()); +} + +#ifdef BOOST_HAS_LONG_LONG +template +inline boost::long_long_type llround(const e_float& v, const Policy& pol) +{ + BOOST_MATH_STD_USING + e_float r = boost::math::round(v, pol); + if(fabs(r) > (std::numeric_limits::max)()) + return static_cast(policies::raise_rounding_error("boost::math::llround<%1%>(%1%)", 0, v, 0LL, pol).value().extract_int64()); + return static_cast(r.value().extract_int64()); +} +#endif + +}}} + +namespace std{ + + template<> + class numeric_limits< ::boost::math::ef::e_float> : public numeric_limits< ::e_float> + { + public: + static const ::boost::math::ef::e_float (min) (void) + { + return (numeric_limits< ::e_float>::min)(); + } + static const ::boost::math::ef::e_float (max) (void) + { + return (numeric_limits< ::e_float>::max)(); + } + static const ::boost::math::ef::e_float epsilon (void) + { + return (numeric_limits< ::e_float>::epsilon)(); + } + static const ::boost::math::ef::e_float round_error(void) + { + return (numeric_limits< ::e_float>::round_error)(); + } + static const ::boost::math::ef::e_float infinity (void) + { + return (numeric_limits< ::e_float>::infinity)(); + } + static const ::boost::math::ef::e_float quiet_NaN (void) + { + return (numeric_limits< ::e_float>::quiet_NaN)(); + } + // + // e_float's supplied digits member is wrong + // - it should be same the same as digits 10 + // - given that radix is 10. + // + static const int digits = digits10; + }; + +} // namespace std + +namespace boost{ namespace math{ + +namespace policies{ + +template +struct precision< ::boost::math::ef::e_float, Policy> +{ + typedef typename Policy::precision_type precision_type; + typedef digits2<((::std::numeric_limits< ::boost::math::ef::e_float>::digits10 + 1) * 1000L) / 301L> digits_2; + typedef typename mpl::if_c< + ((digits_2::value <= precision_type::value) + || (Policy::precision_type::value <= 0)), + // Default case, full precision for RealType: + digits_2, + // User customised precision: + precision_type + >::type type; +}; + +} + +namespace tools{ + +template <> +inline int digits< ::boost::math::ef::e_float>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC( ::boost::math::ef::e_float)) +{ + return ((::std::numeric_limits< ::boost::math::ef::e_float>::digits10 + 1) * 1000L) / 301L; +} + +template <> +inline ::boost::math::ef::e_float root_epsilon< ::boost::math::ef::e_float>() +{ + return detail::root_epsilon_imp(static_cast< ::boost::math::ef::e_float const*>(0), mpl::int_<0>()); +} + +template <> +inline ::boost::math::ef::e_float forth_root_epsilon< ::boost::math::ef::e_float>() +{ + return detail::forth_root_epsilon_imp(static_cast< ::boost::math::ef::e_float const*>(0), mpl::int_<0>()); +} + +} + +namespace lanczos{ + +template +struct lanczos +{ + typedef typename mpl::if_c< + std::numeric_limits< ::e_float>::digits10 < 22, + lanczos13UDT, + typename mpl::if_c< + std::numeric_limits< ::e_float>::digits10 < 36, + lanczos22UDT, + typename mpl::if_c< + std::numeric_limits< ::e_float>::digits10 < 50, + lanczos31UDT, + typename mpl::if_c< + std::numeric_limits< ::e_float>::digits10 < 110, + lanczos61UDT, + undefined_lanczos + >::type + >::type + >::type + >::type type; +}; + +} // namespace lanczos + +template +inline boost::math::ef::e_float skewness(const extreme_value_distribution& /*dist*/) +{ + // + // This is 12 * sqrt(6) * zeta(3) / pi^3: + // See http://mathworld.wolfram.com/ExtremeValueDistribution.html + // + return boost::lexical_cast("1.1395470994046486574927930193898461120875997958366"); +} + +template +inline boost::math::ef::e_float skewness(const rayleigh_distribution& /*dist*/) +{ + // using namespace boost::math::constants; + return boost::lexical_cast("0.63111065781893713819189935154422777984404221106391"); + // Computed using NTL at 150 bit, about 50 decimal digits. + // return 2 * root_pi() * pi_minus_three() / pow23_four_minus_pi(); +} + +template +inline boost::math::ef::e_float kurtosis(const rayleigh_distribution& /*dist*/) +{ + // using namespace boost::math::constants; + return boost::lexical_cast("3.2450893006876380628486604106197544154170667057995"); + // Computed using NTL at 150 bit, about 50 decimal digits. + // return 3 - (6 * pi() * pi() - 24 * pi() + 16) / + // (four_minus_pi() * four_minus_pi()); +} + +template +inline boost::math::ef::e_float kurtosis_excess(const rayleigh_distribution& /*dist*/) +{ + //using namespace boost::math::constants; + // Computed using NTL at 150 bit, about 50 decimal digits. + return boost::lexical_cast("0.2450893006876380628486604106197544154170667057995"); + // return -(6 * pi() * pi() - 24 * pi() + 16) / + // (four_minus_pi() * four_minus_pi()); +} // kurtosis + +namespace detail{ + +// +// Version of Digamma accurate to ~100 decimal digits. +// +template +boost::math::ef::e_float digamma_imp(boost::math::ef::e_float x, const mpl::int_<0>* , const Policy& pol) +{ + // + // This handles reflection of negative arguments, and all our + // eboost::math::ef::e_floator handling, then forwards to the T-specific approximation. + // + BOOST_MATH_STD_USING // ADL of std functions. + + boost::math::ef::e_float result = 0; + // + // Check for negative arguments and use reflection: + // + if(x < 0) + { + // Reflect: + x = 1 - x; + // Argument reduction for tan: + boost::math::ef::e_float remainder = x - floor(x); + // Shift to negative if > 0.5: + if(remainder > 0.5) + { + remainder -= 1; + } + // + // check for evaluation at a negative pole: + // + if(remainder == 0) + { + return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", 0, (1-x), pol); + } + result = constants::pi() / tan(constants::pi() * remainder); + } + result += big_digamma(x); + return result; +} +boost::math::ef::e_float bessel_i0(boost::math::ef::e_float x) +{ + static const boost::math::ef::e_float P1[] = { + boost::lexical_cast("-2.2335582639474375249e+15"), + boost::lexical_cast("-5.5050369673018427753e+14"), + boost::lexical_cast("-3.2940087627407749166e+13"), + boost::lexical_cast("-8.4925101247114157499e+11"), + boost::lexical_cast("-1.1912746104985237192e+10"), + boost::lexical_cast("-1.0313066708737980747e+08"), + boost::lexical_cast("-5.9545626019847898221e+05"), + boost::lexical_cast("-2.4125195876041896775e+03"), + boost::lexical_cast("-7.0935347449210549190e+00"), + boost::lexical_cast("-1.5453977791786851041e-02"), + boost::lexical_cast("-2.5172644670688975051e-05"), + boost::lexical_cast("-3.0517226450451067446e-08"), + boost::lexical_cast("-2.6843448573468483278e-11"), + boost::lexical_cast("-1.5982226675653184646e-14"), + boost::lexical_cast("-5.2487866627945699800e-18"), + }; + static const boost::math::ef::e_float Q1[] = { + boost::lexical_cast("-2.2335582639474375245e+15"), + boost::lexical_cast("7.8858692566751002988e+12"), + boost::lexical_cast("-1.2207067397808979846e+10"), + boost::lexical_cast("1.0377081058062166144e+07"), + boost::lexical_cast("-4.8527560179962773045e+03"), + boost::lexical_cast("1.0"), + }; + static const boost::math::ef::e_float P2[] = { + boost::lexical_cast("-2.2210262233306573296e-04"), + boost::lexical_cast("1.3067392038106924055e-02"), + boost::lexical_cast("-4.4700805721174453923e-01"), + boost::lexical_cast("5.5674518371240761397e+00"), + boost::lexical_cast("-2.3517945679239481621e+01"), + boost::lexical_cast("3.1611322818701131207e+01"), + boost::lexical_cast("-9.6090021968656180000e+00"), + }; + static const boost::math::ef::e_float Q2[] = { + boost::lexical_cast("-5.5194330231005480228e-04"), + boost::lexical_cast("3.2547697594819615062e-02"), + boost::lexical_cast("-1.1151759188741312645e+00"), + boost::lexical_cast("1.3982595353892851542e+01"), + boost::lexical_cast("-6.0228002066743340583e+01"), + boost::lexical_cast("8.5539563258012929600e+01"), + boost::lexical_cast("-3.1446690275135491500e+01"), + boost::lexical_cast("1.0"), + }; + boost::math::ef::e_float value, factor, r; + + BOOST_MATH_STD_USING + using namespace boost::math::tools; + + if (x < 0) + { + x = -x; // even function + } + if (x == 0) + { + return static_cast(1); + } + if (x <= 15) // x in (0, 15] + { + boost::math::ef::e_float y = x * x; + value = evaluate_polynomial(P1, y) / evaluate_polynomial(Q1, y); + } + else // x in (15, \infty) + { + boost::math::ef::e_float y = 1 / x - 1 / 15; + r = evaluate_polynomial(P2, y) / evaluate_polynomial(Q2, y); + factor = exp(x) / sqrt(x); + value = factor * r; + } + + return value; +} + +boost::math::ef::e_float bessel_i1(boost::math::ef::e_float x) +{ + static const boost::math::ef::e_float P1[] = { + lexical_cast("-1.4577180278143463643e+15"), + lexical_cast("-1.7732037840791591320e+14"), + lexical_cast("-6.9876779648010090070e+12"), + lexical_cast("-1.3357437682275493024e+11"), + lexical_cast("-1.4828267606612366099e+09"), + lexical_cast("-1.0588550724769347106e+07"), + lexical_cast("-5.1894091982308017540e+04"), + lexical_cast("-1.8225946631657315931e+02"), + lexical_cast("-4.7207090827310162436e-01"), + lexical_cast("-9.1746443287817501309e-04"), + lexical_cast("-1.3466829827635152875e-06"), + lexical_cast("-1.4831904935994647675e-09"), + lexical_cast("-1.1928788903603238754e-12"), + lexical_cast("-6.5245515583151902910e-16"), + lexical_cast("-1.9705291802535139930e-19"), + }; + static const boost::math::ef::e_float Q1[] = { + lexical_cast("-2.9154360556286927285e+15"), + lexical_cast("9.7887501377547640438e+12"), + lexical_cast("-1.4386907088588283434e+10"), + lexical_cast("1.1594225856856884006e+07"), + lexical_cast("-5.1326864679904189920e+03"), + lexical_cast("1.0"), + }; + static const boost::math::ef::e_float P2[] = { + lexical_cast("1.4582087408985668208e-05"), + lexical_cast("-8.9359825138577646443e-04"), + lexical_cast("2.9204895411257790122e-02"), + lexical_cast("-3.4198728018058047439e-01"), + lexical_cast("1.3960118277609544334e+00"), + lexical_cast("-1.9746376087200685843e+00"), + lexical_cast("8.5591872901933459000e-01"), + lexical_cast("-6.0437159056137599999e-02"), + }; + static const boost::math::ef::e_float Q2[] = { + lexical_cast("3.7510433111922824643e-05"), + lexical_cast("-2.2835624489492512649e-03"), + lexical_cast("7.4212010813186530069e-02"), + lexical_cast("-8.5017476463217924408e-01"), + lexical_cast("3.2593714889036996297e+00"), + lexical_cast("-3.8806586721556593450e+00"), + lexical_cast("1.0"), + }; + boost::math::ef::e_float value, factor, r, w; + + BOOST_MATH_STD_USING + using namespace boost::math::tools; + + w = abs(x); + if (x == 0) + { + return static_cast(0); + } + if (w <= 15) // w in (0, 15] + { + boost::math::ef::e_float y = x * x; + r = evaluate_polynomial(P1, y) / evaluate_polynomial(Q1, y); + factor = w; + value = factor * r; + } + else // w in (15, \infty) + { + boost::math::ef::e_float y = 1 / w - boost::math::ef::e_float(1) / 15; + r = evaluate_polynomial(P2, y) / evaluate_polynomial(Q2, y); + factor = exp(w) / sqrt(w); + value = factor * r; + } + + if (x < 0) + { + value *= -value; // odd function + } + return value; +} + +} // namespace detail + +}} +#endif // BOOST_MATH_E_FLOAT_BINDINGS_HPP + diff --git a/include/boost/math/concepts/distributions.hpp b/include/boost/math/concepts/distributions.hpp index 5758e1429..2e0037787 100644 --- a/include/boost/math/concepts/distributions.hpp +++ b/include/boost/math/concepts/distributions.hpp @@ -130,66 +130,118 @@ struct DistributionConcept // The result values are ignored in all these checks. value_type v = cdf(dist, x); v = cdf(complement(dist, x)); + suppress_unused_variable_warning(v); v = pdf(dist, x); + suppress_unused_variable_warning(v); v = quantile(dist, x); + suppress_unused_variable_warning(v); v = quantile(complement(dist, x)); + suppress_unused_variable_warning(v); v = mean(dist); + suppress_unused_variable_warning(v); v = mode(dist); + suppress_unused_variable_warning(v); v = standard_deviation(dist); + suppress_unused_variable_warning(v); v = variance(dist); + suppress_unused_variable_warning(v); v = hazard(dist, x); + suppress_unused_variable_warning(v); v = chf(dist, x); + suppress_unused_variable_warning(v); v = coefficient_of_variation(dist); + suppress_unused_variable_warning(v); v = skewness(dist); + suppress_unused_variable_warning(v); v = kurtosis(dist); + suppress_unused_variable_warning(v); v = kurtosis_excess(dist); + suppress_unused_variable_warning(v); v = median(dist); + suppress_unused_variable_warning(v); std::pair pv; pv = range(dist); + suppress_unused_variable_warning(pv); pv = support(dist); + suppress_unused_variable_warning(pv); float f = 1; v = cdf(dist, f); + suppress_unused_variable_warning(v); v = cdf(complement(dist, f)); + suppress_unused_variable_warning(v); v = pdf(dist, f); + suppress_unused_variable_warning(v); v = quantile(dist, f); + suppress_unused_variable_warning(v); v = quantile(complement(dist, f)); + suppress_unused_variable_warning(v); v = hazard(dist, f); + suppress_unused_variable_warning(v); v = chf(dist, f); + suppress_unused_variable_warning(v); double d = 1; v = cdf(dist, d); + suppress_unused_variable_warning(v); v = cdf(complement(dist, d)); + suppress_unused_variable_warning(v); v = pdf(dist, d); + suppress_unused_variable_warning(v); v = quantile(dist, d); + suppress_unused_variable_warning(v); v = quantile(complement(dist, d)); + suppress_unused_variable_warning(v); v = hazard(dist, d); + suppress_unused_variable_warning(v); v = chf(dist, d); + suppress_unused_variable_warning(v); #ifndef TEST_MPFR long double ld = 1; v = cdf(dist, ld); + suppress_unused_variable_warning(v); v = cdf(complement(dist, ld)); + suppress_unused_variable_warning(v); v = pdf(dist, ld); + suppress_unused_variable_warning(v); v = quantile(dist, ld); + suppress_unused_variable_warning(v); v = quantile(complement(dist, ld)); + suppress_unused_variable_warning(v); v = hazard(dist, ld); + suppress_unused_variable_warning(v); v = chf(dist, ld); + suppress_unused_variable_warning(v); #endif int i = 1; v = cdf(dist, i); + suppress_unused_variable_warning(v); v = cdf(complement(dist, i)); + suppress_unused_variable_warning(v); v = pdf(dist, i); + suppress_unused_variable_warning(v); v = quantile(dist, i); + suppress_unused_variable_warning(v); v = quantile(complement(dist, i)); + suppress_unused_variable_warning(v); v = hazard(dist, i); + suppress_unused_variable_warning(v); v = chf(dist, i); + suppress_unused_variable_warning(v); unsigned long li = 1; v = cdf(dist, li); + suppress_unused_variable_warning(v); v = cdf(complement(dist, li)); + suppress_unused_variable_warning(v); v = pdf(dist, li); + suppress_unused_variable_warning(v); v = quantile(dist, li); + suppress_unused_variable_warning(v); v = quantile(complement(dist, li)); + suppress_unused_variable_warning(v); v = hazard(dist, li); + suppress_unused_variable_warning(v); v = chf(dist, li); + suppress_unused_variable_warning(v); test_extra_members(dist); } template @@ -207,11 +259,13 @@ struct DistributionConcept value_type r1 = d.alpha(); value_type r2 = d.beta(); r1 = boost::math::beta_distribution::find_alpha(r1, r2); + suppress_unused_variable_warning(r1); r1 = boost::math::beta_distribution::find_beta(r1, r2); + suppress_unused_variable_warning(r1); r1 = boost::math::beta_distribution::find_alpha(r1, r2, r1); + suppress_unused_variable_warning(r1); r1 = boost::math::beta_distribution::find_beta(r1, r2, r1); - (void)r1; // warning suppression - (void)r2; // warning suppression + suppress_unused_variable_warning(r1); } template static void test_extra_members(const boost::math::binomial_distribution& d) @@ -226,14 +280,14 @@ struct DistributionConcept r = Distribution::find_upper_bound_on_p(r, r, r, Distribution::jeffreys_prior_interval); r = Distribution::find_minimum_number_of_trials(r, r, r); r = Distribution::find_maximum_number_of_trials(r, r, r); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::cauchy_distribution& d) { value_type r = d.location(); r = d.scale(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::chi_squared_distribution& d) @@ -241,48 +295,48 @@ struct DistributionConcept value_type r = d.degrees_of_freedom(); r = Distribution::find_degrees_of_freedom(r, r, r, r); r = Distribution::find_degrees_of_freedom(r, r, r, r, r); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::exponential_distribution& d) { value_type r = d.lambda(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::extreme_value_distribution& d) { value_type r = d.scale(); r = d.location(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::fisher_f_distribution& d) { value_type r = d.degrees_of_freedom1(); r = d.degrees_of_freedom2(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::gamma_distribution& d) { value_type r = d.scale(); r = d.shape(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::inverse_chi_squared_distribution& d) { value_type r = d.scale(); r = d.degrees_of_freedom(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::inverse_gamma_distribution& d) { value_type r = d.scale(); r = d.shape(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::hypergeometric_distribution& d) @@ -290,28 +344,28 @@ struct DistributionConcept unsigned u = d.defective(); u = d.sample_count(); u = d.total(); - (void)u; // warning suppression + suppress_unused_variable_warning(u); } template static void test_extra_members(const boost::math::laplace_distribution& d) { value_type r = d.scale(); r = d.location(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::logistic_distribution& d) { value_type r = d.scale(); r = d.location(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::lognormal_distribution& d) { value_type r = d.scale(); r = d.location(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::negative_binomial_distribution& d) @@ -322,7 +376,7 @@ struct DistributionConcept r = Distribution::find_upper_bound_on_p(r, r, r); r = Distribution::find_minimum_number_of_trials(r, r, r); r = Distribution::find_maximum_number_of_trials(r, r, r); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::non_central_beta_distribution& d) @@ -418,14 +472,17 @@ struct DistributionConcept (void)r; // warning suppression } private: + static Distribution* pd; static Distribution& get_object() { - // will never get called: - static char buf[sizeof(Distribution)]; - return * reinterpret_cast(buf); + // In reality this will never get called: + return *pd; } }; // struct DistributionConcept +template +Distribution* DistributionConcept::pd = 0; + } // namespace concepts } // namespace math } // namespace boost diff --git a/include/boost/math/concepts/real_type_concept.hpp b/include/boost/math/concepts/real_type_concept.hpp index 481c82774..f6ec01621 100644 --- a/include/boost/math/concepts/real_type_concept.hpp +++ b/include/boost/math/concepts/real_type_concept.hpp @@ -44,17 +44,29 @@ struct RealTypeConcept r = o / r; bool b; b = r == o; + suppress_unused_variable_warning(b); b = o == r; + suppress_unused_variable_warning(b); b = r != o; + suppress_unused_variable_warning(b); b = o != r; + suppress_unused_variable_warning(b); b = r <= o; + suppress_unused_variable_warning(b); b = o <= r; + suppress_unused_variable_warning(b); b = r >= o; + suppress_unused_variable_warning(b); b = o >= r; + suppress_unused_variable_warning(b); b = r < o; + suppress_unused_variable_warning(b); b = o < r; + suppress_unused_variable_warning(b); b = r > o; + suppress_unused_variable_warning(b); b = o > r; + suppress_unused_variable_warning(b); } void constraints() diff --git a/include/boost/math/distributions/bernoulli.hpp b/include/boost/math/distributions/bernoulli.hpp index 137ed0f20..cfa3ecf84 100644 --- a/include/boost/math/distributions/bernoulli.hpp +++ b/include/boost/math/distributions/bernoulli.hpp @@ -153,7 +153,7 @@ namespace boost { // Probability Density/Mass Function. BOOST_FPU_EXCEPTION_GUARD // Error check: - RealType result; // of checks. + RealType result = 0; // of checks. if(false == bernoulli_detail::check_dist_and_k( "boost::math::pdf(bernoulli_distribution<%1%>, %1%)", dist.success_fraction(), // 0 to 1 @@ -178,7 +178,7 @@ namespace boost { // Cumulative Distribution Function Bernoulli. RealType p = dist.success_fraction(); // Error check: - RealType result; + RealType result = 0; if(false == bernoulli_detail::check_dist_and_k( "boost::math::cdf(bernoulli_distribution<%1%>, %1%)", p, @@ -204,7 +204,7 @@ namespace boost bernoulli_distribution const& dist = c.dist; RealType p = dist.success_fraction(); // Error checks: - RealType result; + RealType result = 0; if(false == bernoulli_detail::check_dist_and_k( "boost::math::cdf(bernoulli_distribution<%1%>, %1%)", p, @@ -229,7 +229,7 @@ namespace boost // Return the number of expected successes k either 0 or 1. // for a given probability p. - RealType result; // of error checks: + RealType result = 0; // of error checks: if(false == bernoulli_detail::check_dist_and_prob( "boost::math::quantile(bernoulli_distribution<%1%>, %1%)", dist.success_fraction(), @@ -257,7 +257,7 @@ namespace boost // Error checks: RealType q = c.param; const bernoulli_distribution& dist = c.dist; - RealType result; + RealType result = 0; if(false == bernoulli_detail::check_dist_and_prob( "boost::math::quantile(bernoulli_distribution<%1%>, %1%)", dist.success_fraction(), diff --git a/include/boost/math/distributions/beta.hpp b/include/boost/math/distributions/beta.hpp index 0573d1d01..ef052599f 100644 --- a/include/boost/math/distributions/beta.hpp +++ b/include/boost/math/distributions/beta.hpp @@ -187,7 +187,7 @@ namespace boost RealType variance) // Expected value of variance. { static const char* function = "boost::math::beta_distribution<%1%>::find_alpha"; - RealType result; // of error checks. + RealType result = 0; // of error checks. if(false == beta_detail::check_mean( function, mean, &result, Policy()) @@ -206,7 +206,7 @@ namespace boost RealType variance) // Expected value of variance. { static const char* function = "boost::math::beta_distribution<%1%>::find_beta"; - RealType result; // of error checks. + RealType result = 0; // of error checks. if(false == beta_detail::check_mean( function, mean, &result, Policy()) @@ -229,7 +229,7 @@ namespace boost RealType probability) // cdf { static const char* function = "boost::math::beta_distribution<%1%>::find_alpha"; - RealType result; // of error checks. + RealType result = 0; // of error checks. if(false == beta_detail::check_prob( function, probability, &result, Policy()) @@ -253,7 +253,7 @@ namespace boost RealType probability) // probability cdf. { static const char* function = "boost::math::beta_distribution<%1%>::find_beta"; - RealType result; // of error checks. + RealType result = 0; // of error checks. if(false == beta_detail::check_prob( function, probability, &result, Policy()) @@ -376,7 +376,7 @@ namespace boost RealType b = dist.beta(); // Argument checks: - RealType result; + RealType result = 0; if(false == beta_detail::check_dist_and_x( function, a, b, x, @@ -399,7 +399,7 @@ namespace boost RealType b = dist.beta(); // Argument checks: - RealType result; + RealType result = 0; if(false == beta_detail::check_dist_and_x( function, a, b, x, @@ -433,7 +433,7 @@ namespace boost RealType b = dist.beta(); // Argument checks: - RealType result; + RealType result = 0; if(false == beta_detail::check_dist_and_x( function, a, b, x, @@ -468,7 +468,7 @@ namespace boost static const char* function = "boost::math::quantile(beta_distribution<%1%> const&, %1%)"; - RealType result; // of argument checks: + RealType result = 0; // of argument checks: RealType a = dist.alpha(); RealType b = dist.beta(); if(false == beta_detail::check_dist_and_prob( @@ -502,7 +502,7 @@ namespace boost // Error checks: RealType q = c.param; const beta_distribution& dist = c.dist; - RealType result; + RealType result = 0; RealType a = dist.alpha(); RealType b = dist.beta(); if(false == beta_detail::check_dist_and_prob( diff --git a/include/boost/math/distributions/binomial.hpp b/include/boost/math/distributions/binomial.hpp index ff70b819c..c73df929f 100644 --- a/include/boost/math/distributions/binomial.hpp +++ b/include/boost/math/distributions/binomial.hpp @@ -203,7 +203,7 @@ namespace boost // // Error checks: BOOST_MATH_STD_USING // ADL of std names - RealType result; + RealType result = 0; RealType trials = dist.trials(); RealType success_fraction = dist.success_fraction(); if(false == binomial_detail::check_dist_and_prob( @@ -317,7 +317,7 @@ namespace boost { static const char* function = "boost::math::binomial_distribution<%1%>::find_lower_bound_on_p"; // Error checks: - RealType result; + RealType result = 0; if(false == binomial_detail::check_dist_and_k( function, trials, RealType(0), successes, &result, Policy()) && @@ -342,7 +342,7 @@ namespace boost { static const char* function = "boost::math::binomial_distribution<%1%>::find_upper_bound_on_p"; // Error checks: - RealType result; + RealType result = 0; if(false == binomial_detail::check_dist_and_k( function, trials, RealType(0), successes, &result, Policy()) && @@ -369,7 +369,7 @@ namespace boost { static const char* function = "boost::math::binomial_distribution<%1%>::find_minimum_number_of_trials"; // Error checks: - RealType result; + RealType result = 0; if(false == binomial_detail::check_dist_and_k( function, k, p, k, &result, Policy()) && @@ -388,7 +388,7 @@ namespace boost { static const char* function = "boost::math::binomial_distribution<%1%>::find_maximum_number_of_trials"; // Error checks: - RealType result; + RealType result = 0; if(false == binomial_detail::check_dist_and_k( function, k, p, k, &result, Policy()) && @@ -446,7 +446,7 @@ namespace boost RealType n = dist.trials(); // Error check: - RealType result; + RealType result = 0; // initialization silences some compiler warnings if(false == binomial_detail::check_dist_and_k( "boost::math::pdf(binomial_distribution<%1%> const&, %1%)", n, @@ -524,7 +524,7 @@ namespace boost RealType p = dist.success_fraction(); // Error check: - RealType result; + RealType result = 0; if(false == binomial_detail::check_dist_and_k( "boost::math::cdf(binomial_distribution<%1%> const&, %1%)", n, @@ -598,7 +598,7 @@ namespace boost RealType p = dist.success_fraction(); // Error checks: - RealType result; + RealType result = 0; if(false == binomial_detail::check_dist_and_k( "boost::math::cdf(binomial_distribution<%1%> const&, %1%)", n, diff --git a/include/boost/math/distributions/cauchy.hpp b/include/boost/math/distributions/cauchy.hpp index 0a818568c..0c93febaa 100644 --- a/include/boost/math/distributions/cauchy.hpp +++ b/include/boost/math/distributions/cauchy.hpp @@ -56,7 +56,7 @@ RealType cdf_imp(const cauchy_distribution& dist, const RealTy // BOOST_MATH_STD_USING // for ADL of std functions static const char* function = "boost::math::cdf(cauchy<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType location = dist.location(); RealType scale = dist.scale(); if(false == detail::check_location(function, location, &result, Policy())) @@ -105,7 +105,7 @@ RealType quantile_imp( static const char* function = "boost::math::quantile(cauchy<%1%>&, %1%)"; BOOST_MATH_STD_USING // for ADL of std functions - RealType result; + RealType result = 0; RealType location = dist.location(); RealType scale = dist.scale(); if(false == detail::check_location(function, location, &result, Policy())) @@ -197,7 +197,7 @@ inline RealType pdf(const cauchy_distribution& dist, const Rea BOOST_MATH_STD_USING // for ADL of std functions static const char* function = "boost::math::pdf(cauchy<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType location = dist.location(); RealType scale = dist.scale(); if(false == detail::check_scale("boost::math::pdf(cauchy<%1%>&, %1%)", scale, &result, Policy())) diff --git a/include/boost/math/distributions/exponential.hpp b/include/boost/math/distributions/exponential.hpp index 44bf04240..62b858c87 100644 --- a/include/boost/math/distributions/exponential.hpp +++ b/include/boost/math/distributions/exponential.hpp @@ -102,7 +102,7 @@ inline RealType pdf(const exponential_distribution& dist, cons static const char* function = "boost::math::pdf(const exponential_distribution<%1%>&, %1%)"; RealType lambda = dist.lambda(); - RealType result; + RealType result = 0; if(0 == detail::verify_lambda(function, lambda, &result, Policy())) return result; if(0 == detail::verify_exp_x(function, x, &result, Policy())) @@ -118,7 +118,7 @@ inline RealType cdf(const exponential_distribution& dist, cons static const char* function = "boost::math::cdf(const exponential_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType lambda = dist.lambda(); if(0 == detail::verify_lambda(function, lambda, &result, Policy())) return result; @@ -136,7 +136,7 @@ inline RealType quantile(const exponential_distribution& dist, static const char* function = "boost::math::quantile(const exponential_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType lambda = dist.lambda(); if(0 == detail::verify_lambda(function, lambda, &result, Policy())) return result; @@ -159,7 +159,7 @@ inline RealType cdf(const complemented2_type inline RealType mean(const exponential_distribution& dist) { - RealType result; + RealType result = 0; RealType lambda = dist.lambda(); if(0 == detail::verify_lambda("boost::math::mean(const exponential_distribution<%1%>&)", lambda, &result, Policy())) return result; @@ -208,7 +208,7 @@ inline RealType mean(const exponential_distribution& dist) template inline RealType standard_deviation(const exponential_distribution& dist) { - RealType result; + RealType result = 0; RealType lambda = dist.lambda(); if(0 == detail::verify_lambda("boost::math::standard_deviation(const exponential_distribution<%1%>&)", lambda, &result, Policy())) return result; diff --git a/include/boost/math/distributions/extreme_value.hpp b/include/boost/math/distributions/extreme_value.hpp index eeb94e750..3cf94d4b3 100644 --- a/include/boost/math/distributions/extreme_value.hpp +++ b/include/boost/math/distributions/extreme_value.hpp @@ -94,7 +94,7 @@ inline RealType pdf(const extreme_value_distribution& dist, co RealType a = dist.location(); RealType b = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::verify_scale_b("boost::math::pdf(const extreme_value_distribution<%1%>&, %1%)", b, &result, Policy())) return result; result = exp((a-x)/b) * exp(-exp((a-x)/b)) / b; @@ -108,7 +108,7 @@ inline RealType cdf(const extreme_value_distribution& dist, co RealType a = dist.location(); RealType b = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::verify_scale_b("boost::math::cdf(const extreme_value_distribution<%1%>&, %1%)", b, &result, Policy())) return result; @@ -126,7 +126,7 @@ RealType quantile(const extreme_value_distribution& dist, cons RealType a = dist.location(); RealType b = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::verify_scale_b(function, b, &result, Policy())) return result; if(0 == detail::check_probability(function, p, &result, Policy())) @@ -149,7 +149,7 @@ inline RealType cdf(const complemented2_type&, %1%)", b, &result, Policy())) return result; @@ -168,7 +168,7 @@ RealType quantile(const complemented2_type& dist) { RealType a = dist.location(); RealType b = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::verify_scale_b("boost::math::mean(const extreme_value_distribution<%1%>&)", b, &result, Policy())) return result; return a + constants::euler() * b; @@ -201,7 +201,7 @@ inline RealType standard_deviation(const extreme_value_distribution&)", b, &result, Policy())) return result; return constants::pi() * b / sqrt(static_cast(6)); diff --git a/include/boost/math/distributions/fisher_f.hpp b/include/boost/math/distributions/fisher_f.hpp index fe7fa06d2..07bcc81a6 100644 --- a/include/boost/math/distributions/fisher_f.hpp +++ b/include/boost/math/distributions/fisher_f.hpp @@ -76,7 +76,7 @@ RealType pdf(const fisher_f_distribution& dist, const RealType RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; static const char* function = "boost::math::pdf(fisher_f_distribution<%1%> const&, %1%)"; if(false == detail::check_df( function, df1, &error_result, Policy()) @@ -133,7 +133,7 @@ inline RealType cdf(const fisher_f_distribution& dist, const R RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( @@ -168,7 +168,7 @@ inline RealType quantile(const fisher_f_distribution& dist, co RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( @@ -194,7 +194,7 @@ inline RealType cdf(const complemented2_type& dist) RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( @@ -274,7 +274,7 @@ inline RealType variance(const fisher_f_distribution& dist) RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( @@ -295,7 +295,7 @@ inline RealType mode(const fisher_f_distribution& dist) RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( @@ -326,7 +326,7 @@ inline RealType skewness(const fisher_f_distribution& dist) RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( @@ -357,7 +357,7 @@ inline RealType kurtosis_excess(const fisher_f_distribution& d RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( diff --git a/include/boost/math/distributions/gamma.hpp b/include/boost/math/distributions/gamma.hpp index 059c1466e..c15973bac 100644 --- a/include/boost/math/distributions/gamma.hpp +++ b/include/boost/math/distributions/gamma.hpp @@ -125,7 +125,7 @@ inline RealType pdf(const gamma_distribution& dist, const Real RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; if(false == detail::check_gamma_x(function, x, &result, Policy())) @@ -149,7 +149,7 @@ inline RealType cdf(const gamma_distribution& dist, const Real RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; if(false == detail::check_gamma_x(function, x, &result, Policy())) @@ -169,7 +169,7 @@ inline RealType quantile(const gamma_distribution& dist, const RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; if(false == detail::check_probability(function, p, &result, Policy())) @@ -193,7 +193,7 @@ inline RealType cdf(const complemented2_type& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; @@ -257,7 +257,7 @@ inline RealType variance(const gamma_distribution& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; @@ -275,7 +275,7 @@ inline RealType mode(const gamma_distribution& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; @@ -304,7 +304,7 @@ inline RealType skewness(const gamma_distribution& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; @@ -322,7 +322,7 @@ inline RealType kurtosis_excess(const gamma_distribution& dist RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; diff --git a/include/boost/math/distributions/geometric.hpp b/include/boost/math/distributions/geometric.hpp index 5c6dbb6bb..51e55e69f 100644 --- a/include/boost/math/distributions/geometric.hpp +++ b/include/boost/math/distributions/geometric.hpp @@ -146,7 +146,7 @@ namespace boost RealType alpha) // alpha 0.05 equivalent to 95% for one-sided test. { static const char* function = "boost::math::geometric<%1%>::find_lower_bound_on_p"; - RealType result; // of error checks. + RealType result = 0; // of error checks. RealType successes = 1; RealType failures = trials - successes; if(false == detail::check_probability(function, alpha, &result, Policy()) @@ -171,7 +171,7 @@ namespace boost RealType alpha) // alpha 0.05 equivalent to 95% for one-sided test. { static const char* function = "boost::math::geometric<%1%>::find_upper_bound_on_p"; - RealType result; // of error checks. + RealType result = 0; // of error checks. RealType successes = 1; RealType failures = trials - successes; if(false == geometric_detail::check_dist_and_k( @@ -205,7 +205,7 @@ namespace boost { static const char* function = "boost::math::geometric<%1%>::find_minimum_number_of_trials"; // Error checks: - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_k( function, p, k, &result, Policy()) && detail::check_probability(function, alpha, &result, Policy())) @@ -223,7 +223,7 @@ namespace boost { static const char* function = "boost::math::geometric<%1%>::find_maximum_number_of_trials"; // Error checks: - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_k( function, p, k, &result, Policy()) && detail::check_probability(function, alpha, &result, Policy())) @@ -317,7 +317,7 @@ namespace boost static const char* function = "boost::math::pdf(const geometric_distribution<%1%>&, %1%)"; RealType p = dist.success_fraction(); - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_k( function, p, @@ -356,7 +356,7 @@ namespace boost // If necessary, it has already been promoted from an integral type. RealType p = dist.success_fraction(); // Error check: - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_k( function, p, @@ -389,7 +389,7 @@ namespace boost geometric_distribution const& dist = c.dist; RealType p = dist.success_fraction(); // Error check: - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_k( function, p, @@ -416,7 +416,7 @@ namespace boost RealType success_fraction = dist.success_fraction(); // Check dist and x. - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_prob (function, success_fraction, x, &result, Policy())) { @@ -465,7 +465,7 @@ namespace boost RealType x = c.param; const geometric_distribution& dist = c.dist; RealType success_fraction = dist.success_fraction(); - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_prob( function, success_fraction, diff --git a/include/boost/math/distributions/hypergeometric.hpp b/include/boost/math/distributions/hypergeometric.hpp index afbb5212d..63d1356a2 100644 --- a/include/boost/math/distributions/hypergeometric.hpp +++ b/include/boost/math/distributions/hypergeometric.hpp @@ -120,7 +120,7 @@ namespace boost { namespace math { inline RealType pdf(const hypergeometric_distribution& dist, const unsigned& x) { static const char* function = "boost::math::pdf(const hypergeometric_distribution<%1%>&, const %1%&)"; - RealType result; + RealType result = 0; if(!dist.check_params(function, &result)) return result; if(!dist.check_x(x, function, &result)) @@ -148,7 +148,7 @@ namespace boost { namespace math { inline RealType cdf(const hypergeometric_distribution& dist, const unsigned& x) { static const char* function = "boost::math::cdf(const hypergeometric_distribution<%1%>&, const %1%&)"; - RealType result; + RealType result = 0; if(!dist.check_params(function, &result)) return result; if(!dist.check_x(x, function, &result)) @@ -176,7 +176,7 @@ namespace boost { namespace math { inline RealType cdf(const complemented2_type, unsigned>& c) { static const char* function = "boost::math::cdf(const hypergeometric_distribution<%1%>&, const %1%&)"; - RealType result; + RealType result = 0; if(!c.dist.check_params(function, &result)) return result; if(!c.dist.check_x(c.param, function, &result)) @@ -206,7 +206,7 @@ namespace boost { namespace math { BOOST_MATH_STD_USING // for ADL of std functions // Checking function argument - RealType result; + RealType result = 0; const char* function = "boost::math::quantile(const hypergeometric_distribution<%1%>&, %1%)"; if (false == dist.check_params(function, &result)) return result; if(false == detail::check_probability(function, p, &result, Policy())) return result; @@ -220,7 +220,7 @@ namespace boost { namespace math { BOOST_MATH_STD_USING // for ADL of std functions // Checking function argument - RealType result; + RealType result = 0; const char* function = "quantile(const complemented2_type, %1%>&)"; if (false == c.dist.check_params(function, &result)) return result; if(false == detail::check_probability(function, c.param, &result, Policy())) return result; diff --git a/include/boost/math/distributions/inverse_gamma.hpp b/include/boost/math/distributions/inverse_gamma.hpp index 4a2c3eaaf..88083e084 100644 --- a/include/boost/math/distributions/inverse_gamma.hpp +++ b/include/boost/math/distributions/inverse_gamma.hpp @@ -150,7 +150,7 @@ inline RealType pdf(const inverse_gamma_distribution& dist, co RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_inverse_gamma(function, scale, shape, &result, Policy())) { // distribution parameters bad. return result; @@ -198,7 +198,7 @@ inline RealType cdf(const inverse_gamma_distribution& dist, co RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_inverse_gamma(function, scale, shape, &result, Policy())) { // distribution parameters bad. return result; @@ -227,7 +227,7 @@ inline RealType quantile(const inverse_gamma_distribution& dis RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_inverse_gamma(function, scale, shape, &result, Policy())) return result; if(false == detail::check_probability(function, p, &result, Policy())) @@ -253,7 +253,7 @@ inline RealType cdf(const complemented2_type& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_scale(function, scale, &result, Policy())) { @@ -329,7 +329,7 @@ inline RealType variance(const inverse_gamma_distribution& dis RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_scale(function, scale, &result, Policy())) { return result; @@ -355,7 +355,7 @@ inline RealType mode(const inverse_gamma_distribution& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_inverse_gamma(function, scale, shape, &result, Policy())) { return result; @@ -381,7 +381,7 @@ inline RealType skewness(const inverse_gamma_distribution& dis RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_scale(function, scale, &result, Policy())) { @@ -408,7 +408,7 @@ inline RealType kurtosis_excess(const inverse_gamma_distribution& dis RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_scale(function, scale, &result, Policy())) { diff --git a/include/boost/math/distributions/inverse_gaussian.hpp b/include/boost/math/distributions/inverse_gaussian.hpp index 6803273bc..67c1b4109 100644 --- a/include/boost/math/distributions/inverse_gaussian.hpp +++ b/include/boost/math/distributions/inverse_gaussian.hpp @@ -136,7 +136,7 @@ inline RealType pdf(const inverse_gaussian_distribution& dist, RealType scale = dist.scale(); RealType mean = dist.mean(); - RealType result; + RealType result = 0; static const char* function = "boost::math::pdf(const inverse_gaussian_distribution<%1%>&, %1%)"; if(false == detail::check_scale(function, scale, &result, Policy())) { @@ -170,7 +170,7 @@ inline RealType cdf(const inverse_gaussian_distribution& dist, RealType scale = dist.scale(); RealType mean = dist.mean(); static const char* function = "boost::math::cdf(const inverse_gaussian_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(false == detail::check_scale(function, scale, &result, Policy())) { return result; @@ -317,7 +317,7 @@ inline RealType quantile(const inverse_gaussian_distribution& RealType scale = dist.scale(); static const char* function = "boost::math::quantile(const inverse_gaussian_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(false == detail::check_scale(function, scale, &result, Policy())) return result; if(false == detail::check_location(function, mean, &result, Policy())) @@ -375,7 +375,7 @@ inline RealType cdf(const complemented2_type& dist, const Re BOOST_MATH_STD_USING // for ADL of std functions // Checking function argument - RealType result; + RealType result = 0; const char* function = "boost::math::pdf(const laplace_distribution<%1%>&, %1%))"; if (false == dist.check_parameters(function, &result)) return result; if (false == detail::check_x(function, x, &result, Policy())) return result; @@ -126,7 +126,7 @@ inline RealType cdf(const laplace_distribution& dist, const Re BOOST_MATH_STD_USING // for ADL of std functions // Checking function argument - RealType result; + RealType result = 0; const char* function = "boost::math::cdf(const laplace_distribution<%1%>&, %1%)"; if (false == dist.check_parameters(function, &result)) return result; if (false == detail::check_x(function, x, &result, Policy())) return result; @@ -157,7 +157,7 @@ inline RealType quantile(const laplace_distribution& dist, con BOOST_MATH_STD_USING // for ADL of std functions. // Checking function argument - RealType result; + RealType result = 0; const char* function = "boost::math::quantile(const laplace_distribution<%1%>&, %1%)"; if (false == dist.check_parameters(function, &result)) return result; if(false == detail::check_probability(function, p, &result, Policy())) return result; @@ -199,7 +199,7 @@ inline RealType cdf(const complemented2_type& dist, const RealTyp static const char* function = "boost::math::pdf(const lognormal_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(0 == detail::check_scale(function, sigma, &result, Policy())) return result; if(0 == detail::check_lognormal_x(function, x, &result, Policy())) @@ -125,7 +125,7 @@ inline RealType cdf(const lognormal_distribution& dist, const static const char* function = "boost::math::cdf(const lognormal_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(0 == detail::check_lognormal_x(function, x, &result, Policy())) return result; @@ -143,7 +143,7 @@ inline RealType quantile(const lognormal_distribution& dist, c static const char* function = "boost::math::quantile(const lognormal_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(0 == detail::check_probability(function, p, &result, Policy())) return result; @@ -163,7 +163,7 @@ inline RealType cdf(const complemented2_type& dist) RealType mu = dist.location(); RealType sigma = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::check_scale("boost::math::mean(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; @@ -217,7 +217,7 @@ inline RealType variance(const lognormal_distribution& dist) RealType mu = dist.location(); RealType sigma = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::check_scale("boost::math::variance(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; @@ -232,7 +232,7 @@ inline RealType mode(const lognormal_distribution& dist) RealType mu = dist.location(); RealType sigma = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::check_scale("boost::math::mode(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; @@ -258,7 +258,7 @@ inline RealType skewness(const lognormal_distribution& dist) RealType ss = sigma * sigma; RealType ess = exp(ss); - RealType result; + RealType result = 0; if(0 == detail::check_scale("boost::math::skewness(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; @@ -274,7 +274,7 @@ inline RealType kurtosis(const lognormal_distribution& dist) RealType sigma = dist.scale(); RealType ss = sigma * sigma; - RealType result; + RealType result = 0; if(0 == detail::check_scale("boost::math::kurtosis(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; @@ -290,7 +290,7 @@ inline RealType kurtosis_excess(const lognormal_distribution& RealType sigma = dist.scale(); RealType ss = sigma * sigma; - RealType result; + RealType result = 0; if(0 == detail::check_scale("boost::math::kurtosis_excess(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; diff --git a/include/boost/math/distributions/negative_binomial.hpp b/include/boost/math/distributions/negative_binomial.hpp index 521b52756..28ce4b996 100644 --- a/include/boost/math/distributions/negative_binomial.hpp +++ b/include/boost/math/distributions/negative_binomial.hpp @@ -165,7 +165,7 @@ namespace boost RealType alpha) // alpha 0.05 equivalent to 95% for one-sided test. { static const char* function = "boost::math::negative_binomial<%1%>::find_lower_bound_on_p"; - RealType result; // of error checks. + RealType result = 0; // of error checks. RealType failures = trials - successes; if(false == detail::check_probability(function, alpha, &result, Policy()) && negative_binomial_detail::check_dist_and_k( @@ -190,7 +190,7 @@ namespace boost RealType alpha) // alpha 0.05 equivalent to 95% for one-sided test. { static const char* function = "boost::math::negative_binomial<%1%>::find_upper_bound_on_p"; - RealType result; // of error checks. + RealType result = 0; // of error checks. RealType failures = trials - successes; if(false == negative_binomial_detail::check_dist_and_k( function, successes, RealType(0), failures, &result, Policy()) @@ -222,7 +222,7 @@ namespace boost { static const char* function = "boost::math::negative_binomial<%1%>::find_minimum_number_of_trials"; // Error checks: - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_k( function, RealType(1), p, k, &result, Policy()) && detail::check_probability(function, alpha, &result, Policy())) @@ -239,7 +239,7 @@ namespace boost { static const char* function = "boost::math::negative_binomial<%1%>::find_maximum_number_of_trials"; // Error checks: - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_k( function, RealType(1), p, k, &result, Policy()) && detail::check_probability(function, alpha, &result, Policy())) @@ -343,7 +343,7 @@ namespace boost RealType r = dist.successes(); RealType p = dist.success_fraction(); - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_k( function, r, @@ -370,7 +370,7 @@ namespace boost RealType p = dist.success_fraction(); RealType r = dist.successes(); // Error check: - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_k( function, r, @@ -399,7 +399,7 @@ namespace boost RealType p = dist.success_fraction(); RealType r = dist.successes(); // Error check: - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_k( function, r, @@ -435,7 +435,7 @@ namespace boost RealType p = dist.success_fraction(); RealType r = dist.successes(); // Check dist and P. - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_prob (function, r, p, P, &result, Policy())) { @@ -509,7 +509,7 @@ namespace boost const negative_binomial_distribution& dist = c.dist; RealType p = dist.success_fraction(); RealType r = dist.successes(); - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_prob( function, r, diff --git a/include/boost/math/distributions/normal.hpp b/include/boost/math/distributions/normal.hpp index 69da2dc38..baeecf634 100644 --- a/include/boost/math/distributions/normal.hpp +++ b/include/boost/math/distributions/normal.hpp @@ -106,7 +106,7 @@ inline RealType pdf(const normal_distribution& dist, const Rea // return 0; //} - RealType result; + RealType result = 0; if(false == detail::check_scale(function, sd, &result, Policy())) { return result; @@ -138,7 +138,7 @@ inline RealType cdf(const normal_distribution& dist, const Rea RealType sd = dist.standard_deviation(); RealType mean = dist.mean(); static const char* function = "boost::math::cdf(const normal_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(false == detail::check_scale(function, sd, &result, Policy())) { return result; @@ -179,7 +179,7 @@ inline RealType quantile(const normal_distribution& dist, cons RealType mean = dist.mean(); static const char* function = "boost::math::quantile(const normal_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(false == detail::check_scale(function, sd, &result, Policy())) return result; if(false == detail::check_location(function, mean, &result, Policy())) @@ -218,7 +218,7 @@ inline RealType cdf(const complemented2_type::pareto_distribution", scale, shape, &result, Policy()); } @@ -182,7 +182,7 @@ namespace boost static const char* function = "boost::math::pdf(const pareto_distribution<%1%>&, %1%)"; RealType scale = dist.scale(); RealType shape = dist.shape(); - RealType result; + RealType result = 0; if(false == (detail::check_pareto_x(function, x, &result, Policy()) && detail::check_pareto(function, scale, shape, &result, Policy()))) return result; @@ -201,7 +201,7 @@ namespace boost static const char* function = "boost::math::cdf(const pareto_distribution<%1%>&, %1%)"; RealType scale = dist.scale(); RealType shape = dist.shape(); - RealType result; + RealType result = 0; if(false == (detail::check_pareto_x(function, x, &result, Policy()) && detail::check_pareto(function, scale, shape, &result, Policy()))) @@ -222,7 +222,7 @@ namespace boost { BOOST_MATH_STD_USING // for ADL of std function pow. static const char* function = "boost::math::quantile(const pareto_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType scale = dist.scale(); RealType shape = dist.shape(); if(false == (detail::check_probability(function, p, &result, Policy()) @@ -249,7 +249,7 @@ namespace boost { BOOST_MATH_STD_USING // for ADL of std function pow. static const char* function = "boost::math::cdf(const pareto_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType x = c.param; RealType scale = c.dist.scale(); RealType shape = c.dist.shape(); @@ -271,7 +271,7 @@ namespace boost { BOOST_MATH_STD_USING // for ADL of std function pow. static const char* function = "boost::math::quantile(const pareto_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType q = c.param; RealType scale = c.dist.scale(); RealType shape = c.dist.shape(); @@ -296,7 +296,7 @@ namespace boost template inline RealType mean(const pareto_distribution& dist) { - RealType result; + RealType result = 0; static const char* function = "boost::math::mean(const pareto_distribution<%1%>&, %1%)"; if(false == detail::check_pareto(function, dist.scale(), dist.shape(), &result, Policy())) { @@ -322,7 +322,7 @@ namespace boost template inline RealType median(const pareto_distribution& dist) { - RealType result; + RealType result = 0; static const char* function = "boost::math::median(const pareto_distribution<%1%>&, %1%)"; if(false == detail::check_pareto(function, dist.scale(), dist.shape(), &result, Policy())) { @@ -335,7 +335,7 @@ namespace boost template inline RealType variance(const pareto_distribution& dist) { - RealType result; + RealType result = 0; RealType scale = dist.scale(); RealType shape = dist.shape(); static const char* function = "boost::math::variance(const pareto_distribution<%1%>&, %1%)"; @@ -361,7 +361,7 @@ namespace boost inline RealType skewness(const pareto_distribution& dist) { BOOST_MATH_STD_USING - RealType result; + RealType result = 0; RealType shape = dist.shape(); static const char* function = "boost::math::pdf(const pareto_distribution<%1%>&, %1%)"; if(false == detail::check_pareto(function, dist.scale(), shape, &result, Policy())) @@ -386,7 +386,7 @@ namespace boost template inline RealType kurtosis(const pareto_distribution& dist) { - RealType result; + RealType result = 0; RealType shape = dist.shape(); static const char* function = "boost::math::pdf(const pareto_distribution<%1%>&, %1%)"; if(false == detail::check_pareto(function, dist.scale(), shape, &result, Policy())) @@ -410,7 +410,7 @@ namespace boost template inline RealType kurtosis_excess(const pareto_distribution& dist) { - RealType result; + RealType result = 0; RealType shape = dist.shape(); static const char* function = "boost::math::pdf(const pareto_distribution<%1%>&, %1%)"; if(false == detail::check_pareto(function, dist.scale(), shape, &result, Policy())) diff --git a/include/boost/math/distributions/poisson.hpp b/include/boost/math/distributions/poisson.hpp index 3cb06e0f4..3dd58f80c 100644 --- a/include/boost/math/distributions/poisson.hpp +++ b/include/boost/math/distributions/poisson.hpp @@ -316,7 +316,7 @@ namespace boost RealType mean = dist.mean(); // Error check: - RealType result; + RealType result = 0; if(false == poisson_detail::check_dist_and_k( "boost::math::pdf(const poisson_distribution<%1%>&, %1%)", mean, @@ -362,7 +362,7 @@ namespace boost RealType mean = dist.mean(); // Error checks: - RealType result; + RealType result = 0; if(false == poisson_detail::check_dist_and_k( "boost::math::cdf(const poisson_distribution<%1%>&, %1%)", mean, @@ -414,7 +414,7 @@ namespace boost RealType mean = dist.mean(); // Error checks: - RealType result; + RealType result = 0; if(false == poisson_detail::check_dist_and_k( "boost::math::cdf(const poisson_distribution<%1%>&, %1%)", mean, @@ -443,7 +443,7 @@ namespace boost inline RealType quantile(const poisson_distribution& dist, const RealType& p) { // Quantile (or Percent Point) Poisson function. // Return the number of expected events k for a given probability p. - RealType result; // of Argument checks: + RealType result = 0; // of Argument checks: if(false == poisson_detail::check_prob( "boost::math::quantile(const poisson_distribution<%1%>&, %1%)", p, @@ -514,7 +514,7 @@ namespace boost // Error checks: RealType q = c.param; const poisson_distribution& dist = c.dist; - RealType result; // of argument checks. + RealType result = 0; // of argument checks. if(false == poisson_detail::check_prob( "boost::math::quantile(const poisson_distribution<%1%>&, %1%)", q, diff --git a/include/boost/math/distributions/rayleigh.hpp b/include/boost/math/distributions/rayleigh.hpp index 2aeef4d64..1ffb9dc0a 100644 --- a/include/boost/math/distributions/rayleigh.hpp +++ b/include/boost/math/distributions/rayleigh.hpp @@ -98,7 +98,7 @@ inline RealType pdf(const rayleigh_distribution& dist, const R BOOST_MATH_STD_USING // for ADL of std function exp. RealType sigma = dist.sigma(); - RealType result; + RealType result = 0; static const char* function = "boost::math::pdf(const rayleigh_distribution<%1%>&, %1%)"; if(false == detail::verify_sigma(function, sigma, &result, Policy())) { @@ -118,7 +118,7 @@ inline RealType cdf(const rayleigh_distribution& dist, const R { BOOST_MATH_STD_USING // for ADL of std functions - RealType result; + RealType result = 0; RealType sigma = dist.sigma(); static const char* function = "boost::math::cdf(const rayleigh_distribution<%1%>&, %1%)"; if(false == detail::verify_sigma(function, sigma, &result, Policy())) @@ -138,7 +138,7 @@ inline RealType quantile(const rayleigh_distribution& dist, co { BOOST_MATH_STD_USING // for ADL of std functions - RealType result; + RealType result = 0; RealType sigma = dist.sigma(); static const char* function = "boost::math::quantile(const rayleigh_distribution<%1%>&, %1%)"; if(false == detail::verify_sigma(function, sigma, &result, Policy())) @@ -163,7 +163,7 @@ inline RealType cdf(const complemented2_type inline RealType mean(const rayleigh_distribution& dist) { - RealType result; + RealType result = 0; RealType sigma = dist.sigma(); static const char* function = "boost::math::mean(const rayleigh_distribution<%1%>&, %1%)"; if(false == detail::verify_sigma(function, sigma, &result, Policy())) @@ -225,7 +225,7 @@ inline RealType mean(const rayleigh_distribution& dist) template inline RealType variance(const rayleigh_distribution& dist) { - RealType result; + RealType result = 0; RealType sigma = dist.sigma(); static const char* function = "boost::math::variance(const rayleigh_distribution<%1%>&, %1%)"; if(false == detail::verify_sigma(function, sigma, &result, Policy())) diff --git a/include/boost/math/distributions/triangular.hpp b/include/boost/math/distributions/triangular.hpp index 5030081db..ee607e177 100644 --- a/include/boost/math/distributions/triangular.hpp +++ b/include/boost/math/distributions/triangular.hpp @@ -199,7 +199,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType mode = dist.mode(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function, lower, mode, upper, &result, Policy())) { return result; @@ -237,7 +237,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType mode = dist.mode(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function, lower, mode, upper, &result, Policy())) { return result; @@ -273,7 +273,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType mode = dist.mode(); RealType upper = dist.upper(); - RealType result; // of checks + RealType result = 0; // of checks if(false == detail::check_triangular(function,lower, mode, upper, &result, Policy())) { return result; @@ -316,7 +316,7 @@ namespace boost{ namespace math RealType mode = c.dist.mode(); RealType upper = c.dist.upper(); RealType x = c.param; - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function, lower, mode, upper, &result, Policy())) { return result; @@ -352,7 +352,7 @@ namespace boost{ namespace math RealType m = c.dist.mode(); RealType u = c.dist.upper(); RealType q = c.param; // probability 0 to 1. - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function, l, m, u, &result, Policy())) { return result; @@ -399,7 +399,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType mode = dist.mode(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function, lower, mode, upper, &result, Policy())) { return result; @@ -415,7 +415,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType mode = dist.mode(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function, lower, mode, upper, &result, Policy())) { return result; @@ -428,7 +428,7 @@ namespace boost{ namespace math { static const char* function = "boost::math::mode(const triangular_distribution<%1%>&)"; RealType mode = dist.mode(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular_mode(function, mode, &result, Policy())) { // This should never happen! return result; @@ -442,7 +442,7 @@ namespace boost{ namespace math BOOST_MATH_STD_USING // ADL of std functions. static const char* function = "boost::math::median(const triangular_distribution<%1%>&)"; RealType mode = dist.mode(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular_mode(function, mode, &result, Policy())) { // This should never happen! return result; @@ -469,7 +469,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType mode = dist.mode(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function,lower, mode, upper, &result, Policy())) { return result; @@ -485,7 +485,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType upper = dist.upper(); RealType mode = dist.mode(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function,lower, mode, upper, &result, Policy())) { return result; @@ -500,7 +500,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType upper = dist.upper(); RealType mode = dist.mode(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function,lower, mode, upper, &result, Policy())) { return result; diff --git a/include/boost/math/distributions/uniform.hpp b/include/boost/math/distributions/uniform.hpp index 2e17e18e7..5d967a17f 100644 --- a/include/boost/math/distributions/uniform.hpp +++ b/include/boost/math/distributions/uniform.hpp @@ -161,7 +161,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::pdf(const uniform_distribution<%1%>&, %1%)", lower, upper, &result, Policy())) { return result; @@ -186,7 +186,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::cdf(const uniform_distribution<%1%>&, %1%)",lower, upper, &result, Policy())) { return result; @@ -211,7 +211,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks + RealType result = 0; // of checks if(false == detail::check_uniform("boost::math::quantile(const uniform_distribution<%1%>&, %1%)",lower, upper, &result, Policy())) { return result; @@ -237,7 +237,7 @@ namespace boost{ namespace math RealType lower = c.dist.lower(); RealType upper = c.dist.upper(); RealType x = c.param; - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::cdf(const uniform_distribution<%1%>&, %1%)", lower, upper, &result, Policy())) { return result; @@ -263,7 +263,7 @@ namespace boost{ namespace math RealType lower = c.dist.lower(); RealType upper = c.dist.upper(); RealType q = c.param; - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::quantile(const uniform_distribution<%1%>&, %1%)", lower, upper, &result, Policy())) { return result; @@ -285,7 +285,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::mean(const uniform_distribution<%1%>&)", lower, upper, &result, Policy())) { return result; @@ -298,7 +298,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::variance(const uniform_distribution<%1%>&)", lower, upper, &result, Policy())) { return result; @@ -312,7 +312,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::mode(const uniform_distribution<%1%>&)", lower, upper, &result, Policy())) { return result; @@ -326,7 +326,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::median(const uniform_distribution<%1%>&)", lower, upper, &result, Policy())) { return result; @@ -338,7 +338,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::skewness(const uniform_distribution<%1%>&)",lower, upper, &result, Policy())) { return result; @@ -351,7 +351,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::kurtosis_execess(const uniform_distribution<%1%>&)", lower, upper, &result, Policy())) { return result; diff --git a/include/boost/math/distributions/weibull.hpp b/include/boost/math/distributions/weibull.hpp index e47437ff3..6b5c7db34 100644 --- a/include/boost/math/distributions/weibull.hpp +++ b/include/boost/math/distributions/weibull.hpp @@ -126,7 +126,7 @@ inline RealType pdf(const weibull_distribution& dist, const Re RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) return result; if(false == detail::check_weibull_x(function, x, &result, Policy())) @@ -152,7 +152,7 @@ inline RealType cdf(const weibull_distribution& dist, const Re RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) return result; if(false == detail::check_weibull_x(function, x, &result, Policy())) @@ -173,7 +173,7 @@ inline RealType quantile(const weibull_distribution& dist, con RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) return result; if(false == detail::check_probability(function, p, &result, Policy())) @@ -197,7 +197,7 @@ inline RealType cdf(const complemented2_type& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) return result; @@ -259,7 +259,7 @@ inline RealType variance(const weibull_distribution& dist) static const char* function = "boost::math::variance(const weibull_distribution<%1%>)"; - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) { return result; @@ -281,7 +281,7 @@ inline RealType mode(const weibull_distribution& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) { return result; @@ -302,7 +302,7 @@ inline RealType median(const weibull_distribution& dist) RealType shape = dist.shape(); // Wikipedia k RealType scale = dist.scale(); // Wikipedia lambda - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) { return result; @@ -322,7 +322,7 @@ inline RealType skewness(const weibull_distribution& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) { return result; @@ -348,7 +348,7 @@ inline RealType kurtosis_excess(const weibull_distribution& di RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) return result; diff --git a/include/boost/math/octonion.hpp b/include/boost/math/octonion.hpp index c9c05dd85..ce1b66f1d 100644 --- a/include/boost/math/octonion.hpp +++ b/include/boost/math/octonion.hpp @@ -4713,11 +4713,11 @@ namespace boost } else if (n == 0) { - return(octonion(1)); + return(octonion(static_cast(1))); } else /* n < 0 */ { - return(pow(octonion(1)/o,-n)); + return(pow(octonion(static_cast(1))/o,-n)); } } diff --git a/include/boost/math/policies/error_handling.hpp b/include/boost/math/policies/error_handling.hpp index 198cd020b..833ae4901 100644 --- a/include/boost/math/policies/error_handling.hpp +++ b/include/boost/math/policies/error_handling.hpp @@ -616,7 +616,7 @@ inline R checked_narrowing_cast(T val, const char* function) // // Most of what follows will evaluate to a no-op: // - R result; + R result = 0; if(detail::check_overflow(val, &result, function, overflow_type())) return result; if(detail::check_underflow(val, &result, function, underflow_type())) diff --git a/include/boost/math/policies/policy.hpp b/include/boost/math/policies/policy.hpp index b66cd7f92..355bf18fd 100644 --- a/include/boost/math/policies/policy.hpp +++ b/include/boost/math/policies/policy.hpp @@ -738,6 +738,7 @@ struct basic_digits : public mpl::int_{ }; template struct precision { + BOOST_STATIC_ASSERT( ::std::numeric_limits::radix == 2); typedef typename Policy::precision_type precision_type; typedef basic_digits digits_t; typedef typename mpl::if_< @@ -775,6 +776,7 @@ struct precision template struct precision { + BOOST_STATIC_ASSERT((::std::numeric_limits::radix == 2) || ((::std::numeric_limits::is_specialized == 0) || (::std::numeric_limits::digits == 0))); #ifndef __BORLANDC__ typedef typename Policy::precision_type precision_type; typedef typename mpl::if_c< @@ -896,8 +898,10 @@ inline T get_epsilon_imp(mpl::true_ const&) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); + BOOST_STATIC_ASSERT( ::std::numeric_limits::radix == 2); #else BOOST_ASSERT(::std::numeric_limits::is_specialized); + BOOST_ASSERT(::std::numeric_limits::radix == 2); #endif typedef typename boost::math::policies::precision::type p_t; typedef mpl::bool_::digits> is_small_int; @@ -916,7 +920,7 @@ inline T get_epsilon_imp(mpl::false_ const&) template inline T get_epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) { - typedef mpl::bool_< std::numeric_limits::is_specialized > tag_type; + typedef mpl::bool_< (std::numeric_limits::is_specialized && (std::numeric_limits::radix == 2)) > tag_type; return detail::get_epsilon_imp(tag_type()); } diff --git a/include/boost/math/quaternion.hpp b/include/boost/math/quaternion.hpp index bbccce1b6..bbe767d22 100644 --- a/include/boost/math/quaternion.hpp +++ b/include/boost/math/quaternion.hpp @@ -1887,11 +1887,11 @@ namespace boost } else if (n == 0) { - return(quaternion(1)); + return(quaternion(static_cast(1))); } else /* n < 0 */ { - return(pow(quaternion(1)/q,-n)); + return(pow(quaternion(static_cast(1))/q,-n)); } } diff --git a/include/boost/math/special_functions/atanh.hpp b/include/boost/math/special_functions/atanh.hpp index 5932af899..d447e2057 100644 --- a/include/boost/math/special_functions/atanh.hpp +++ b/include/boost/math/special_functions/atanh.hpp @@ -64,7 +64,7 @@ namespace boost else if(x > 1 - tools::epsilon()) { // Infinity: - return -policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, 0, pol); } else if(x > 1) { diff --git a/include/boost/math/special_functions/beta.hpp b/include/boost/math/special_functions/beta.hpp index 0e17af242..b68834c75 100644 --- a/include/boost/math/special_functions/beta.hpp +++ b/include/boost/math/special_functions/beta.hpp @@ -326,6 +326,10 @@ T ibeta_power_terms(T a, T b2 = (y * cgh) / bgh; l1 = a * log(b1); l2 = b * log(b2); + BOOST_MATH_INSTRUMENT_VARIABLE(b1); + BOOST_MATH_INSTRUMENT_VARIABLE(b2); + BOOST_MATH_INSTRUMENT_VARIABLE(l1); + BOOST_MATH_INSTRUMENT_VARIABLE(l2); if((l1 >= tools::log_max_value()) || (l1 <= tools::log_min_value()) || (l2 >= tools::log_max_value()) @@ -384,9 +388,8 @@ T ibeta_power_terms(T a, return pow(x, a) * pow(y, b); } - T result; + T result= 0; // assignment here silences warnings later - T prefix = 1; T c = a + b; // integration limits for the gamma functions: @@ -519,7 +522,6 @@ T ibeta_series(T a, T b, T x, T s0, const boost::math::lanczos::undefined_lanczo if(normalised) { - T prefix = 1; T c = a + b; // figure out integration limits for the gamma function: diff --git a/include/boost/math/special_functions/cbrt.hpp b/include/boost/math/special_functions/cbrt.hpp index c5421344f..0fc6e0742 100644 --- a/include/boost/math/special_functions/cbrt.hpp +++ b/include/boost/math/special_functions/cbrt.hpp @@ -90,6 +90,8 @@ T cbrt_imp(T z, const Policy& pol) typedef typename largest_cbrt_int_type::type shift_type; + BOOST_STATIC_ASSERT( ::std::numeric_limits::radix == 2); + if(abs(i_exp3) < std::numeric_limits::digits) { if(i_exp3 > 0) diff --git a/include/boost/math/special_functions/detail/fp_traits.hpp b/include/boost/math/special_functions/detail/fp_traits.hpp index 0f311b639..54d45917b 100644 --- a/include/boost/math/special_functions/detail/fp_traits.hpp +++ b/include/boost/math/special_functions/detail/fp_traits.hpp @@ -552,12 +552,13 @@ struct select_native template struct fp_traits { + typedef BOOST_DEDUCED_TYPENAME size_to_precision::value>::type precision; #if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && !defined(BOOST_MATH_DISABLE_STD_FPCLASSIFY) typedef typename select_native::type type; #else - typedef BOOST_DEDUCED_TYPENAME size_to_precision::value>::type precision; typedef fp_traits_non_native type; #endif + typedef fp_traits_non_native sign_change_type; }; //------------------------------------------------------------------------------ diff --git a/include/boost/math/special_functions/detail/t_distribution_inv.hpp b/include/boost/math/special_functions/detail/t_distribution_inv.hpp index 8f7f0e6fd..bb6bc848a 100644 --- a/include/boost/math/special_functions/detail/t_distribution_inv.hpp +++ b/include/boost/math/special_functions/detail/t_distribution_inv.hpp @@ -529,7 +529,10 @@ inline T fast_students_t_quantile(T df, T p, const Policy& pol) typedef mpl::bool_< (std::numeric_limits::digits <= 53) && - (std::numeric_limits::is_specialized)> tag_type; + (std::numeric_limits::is_specialized) + && + (std::numeric_limits::radix == 2) + > tag_type; return policies::checked_narrowing_cast(fast_students_t_quantile_imp(static_cast(df), static_cast(p), pol, static_cast(0)), "boost::math::students_t_quantile<%1%>(%1%,%1%,%1%)"); } diff --git a/include/boost/math/special_functions/gamma.hpp b/include/boost/math/special_functions/gamma.hpp index 5d414259b..461adf397 100644 --- a/include/boost/math/special_functions/gamma.hpp +++ b/include/boost/math/special_functions/gamma.hpp @@ -1,3 +1,4 @@ + // Copyright John Maddock 2006-7. // Copyright Paul A. Bristow 2007. @@ -150,6 +151,7 @@ T gamma_imp(T z, const Policy& pol, const L& l) if(z <= -20) { result = gamma_imp(T(-z), pol, l) * sinpx(z); + BOOST_MATH_INSTRUMENT_VARIABLE(result); if((fabs(result) < 1) && (tools::max_value() * fabs(result) < boost::math::constants::pi())) return policies::raise_overflow_error(function, "Result of tgamma is too large to represent.", pol); result = -boost::math::constants::pi() / result; @@ -157,6 +159,7 @@ T gamma_imp(T z, const Policy& pol, const L& l) return policies::raise_underflow_error(function, "Result of tgamma is too small to represent.", pol); if((boost::math::fpclassify)(result) == (int)FP_SUBNORMAL) return policies::raise_denorm_error(function, "Result of tgamma is denormalized.", result, pol); + BOOST_MATH_INSTRUMENT_VARIABLE(result); return result; } @@ -167,29 +170,41 @@ T gamma_imp(T z, const Policy& pol, const L& l) z += 1; } } + BOOST_MATH_INSTRUMENT_VARIABLE(result); if((floor(z) == z) && (z < max_factorial::value)) { result *= unchecked_factorial(itrunc(z, pol) - 1); + BOOST_MATH_INSTRUMENT_VARIABLE(result); } else { result *= L::lanczos_sum(z); + BOOST_MATH_INSTRUMENT_VARIABLE(result); + BOOST_MATH_INSTRUMENT_VARIABLE(tools::log_max_value()); if(z * log(z) > tools::log_max_value()) { // we're going to overflow unless this is done with care: T zgh = (z + static_cast(L::g()) - boost::math::constants::half()); + BOOST_MATH_INSTRUMENT_VARIABLE(zgh); if(log(zgh) * z / 2 > tools::log_max_value()) return policies::raise_overflow_error(function, "Result of tgamma is too large to represent.", pol); T hp = pow(zgh, (z / 2) - T(0.25)); + BOOST_MATH_INSTRUMENT_VARIABLE(hp); result *= hp / exp(zgh); + BOOST_MATH_INSTRUMENT_VARIABLE(result); if(tools::max_value() / hp < result) return policies::raise_overflow_error(function, "Result of tgamma is too large to represent.", pol); result *= hp; + BOOST_MATH_INSTRUMENT_VARIABLE(result); } else { T zgh = (z + static_cast(L::g()) - boost::math::constants::half()); + BOOST_MATH_INSTRUMENT_VARIABLE(zgh); + BOOST_MATH_INSTRUMENT_VARIABLE(pow(zgh, z - boost::math::constants::half())); + BOOST_MATH_INSTRUMENT_VARIABLE(exp(zgh)); result *= pow(zgh, z - boost::math::constants::half()) / exp(zgh); + BOOST_MATH_INSTRUMENT_VARIABLE(result); } } return result; diff --git a/include/boost/math/special_functions/math_fwd.hpp b/include/boost/math/special_functions/math_fwd.hpp index d25181eb2..14364a3d5 100644 --- a/include/boost/math/special_functions/math_fwd.hpp +++ b/include/boost/math/special_functions/math_fwd.hpp @@ -641,6 +641,18 @@ namespace boost template bool isnormal BOOST_NO_MACRO_EXPAND(T t); + template + int signbit BOOST_NO_MACRO_EXPAND(T x); + + template + int sign BOOST_NO_MACRO_EXPAND(const T& z); + + template + T copysign BOOST_NO_MACRO_EXPAND(const T& x, const T& y); + + template + T changesign BOOST_NO_MACRO_EXPAND(const T& z); + // Exponential integrals: namespace detail{ @@ -880,7 +892,6 @@ namespace boost inline typename boost::math::tools::promote_args::type falling_factorial(RT x, unsigned n){ return boost::math::falling_factorial(x, n, Policy()); }\ template \ inline typename boost::math::tools::promote_args::type rising_factorial(RT x, unsigned n){ return boost::math::rising_factorial(x, n, Policy()); }\ - using boost::math::fpclassify;\ \ template \ inline typename boost::math::tools::promote_args::type tgamma(RT z){ return boost::math::tgamma(z, Policy()); }\ @@ -1003,6 +1014,10 @@ namespace boost using boost::math::isinf;\ using boost::math::isnan;\ using boost::math::isnormal;\ + using boost::math::signbit;\ + using boost::math::sign;\ + using boost::math::copysign;\ + using boost::math::changesign;\ \ template \ inline typename boost::math::tools::promote_args::type expint(T const& z, U const& u)\ diff --git a/include/boost/math/special_functions/nonfinite_num_facets.hpp b/include/boost/math/special_functions/nonfinite_num_facets.hpp new file mode 100644 index 000000000..8ee9170e1 --- /dev/null +++ b/include/boost/math/special_functions/nonfinite_num_facets.hpp @@ -0,0 +1,543 @@ +#ifndef BOOST_MATH_NONFINITE_NUM_FACETS_HPP +#define BOOST_MATH_NONFINITE_NUM_FACETS_HPP + +// Copyright (c) 2006 Johan Rade +// Copyright 2011 Paul A. Bristow (comments) + +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* +\file + +\brief non_finite_num facets for C99 standard output of infinity and NaN. + +\details See fuller documentation at Boost.Math Facets + for Floating-Point Infinities and NaNs. +*/ + +#include +#include +#include +#include + +#include + +#include +#include + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable : 4127) // conditional expression is constant. +# pragma warning(disable : 4706) // assignment within conditional expression. +# pragma warning(disable : 4224) // formal parameter 'version' was previously defined as a type. +#endif + +namespace boost { + namespace math { + + // flags (enums can be ORed together) ----------------------------------- + + const int legacy = 0x1; //!< get facet will recognize most string representations of infinity and NaN. + const int signed_zero = 0x2; //!< put facet will distinguish between positive and negative zero. + const int trap_infinity = 0x4; /*!< put facet will throw an exception of type std::ios_base::failure + when an attempt is made to format positive or negative infinity. + get will set the fail bit of the stream when an attempt is made + to parse a string that represents positive or negative sign infinity. + */ + const int trap_nan = 0x8; /*!< put facet will throw an exception of type std::ios_base::failure + when an attempt is made to format positive or negative NaN. + get will set the fail bit of the stream when an attempt is made + to parse a string that represents positive or negative sign infinity. + */ + + // class nonfinite_num_put ----------------------------------------------------- + + template< + class CharType, + class OutputIterator = std::ostreambuf_iterator + > + class nonfinite_num_put : public std::num_put + { + public: + explicit nonfinite_num_put(int flags = 0) : flags_(flags) {} + + protected: + virtual OutputIterator do_put( + OutputIterator it, std::ios_base& iosb, + CharType fill, double val) const + { + put_and_reset_width(it, iosb, fill, val); + return it; + } + + virtual OutputIterator do_put( + OutputIterator it, std::ios_base& iosb, + CharType fill, long double val) const + { + put_and_reset_width(it, iosb, fill, val); + return it; + } + + private: + template void put_and_reset_width( + OutputIterator& it, std::ios_base& iosb, + CharType fill, ValType val) const + { + put_impl(it, iosb, fill, val); + iosb.width(0); + } + + template void put_impl( + OutputIterator& it, std::ios_base& iosb, + CharType fill, ValType val) const + { + switch((boost::math::fpclassify)(val)) { + + case FP_INFINITE: + if(flags_ & trap_infinity) + throw std::ios_base::failure("Infinity"); + else if((boost::math::signbit)(val)) + put_num_and_fill(it, iosb, "-", "inf", fill); + else if(iosb.flags() & std::ios_base::showpos) + put_num_and_fill(it, iosb, "+", "inf", fill); + else + put_num_and_fill(it, iosb, "", "inf", fill); + break; + + case FP_NAN: + if(flags_ & trap_nan) + throw std::ios_base::failure("NaN"); + else if((boost::math::signbit)(val)) + put_num_and_fill(it, iosb, "-", "nan", fill); + else if(iosb.flags() & std::ios_base::showpos) + put_num_and_fill(it, iosb, "+", "nan", fill); + else + put_num_and_fill(it, iosb, "", "nan", fill); + break; + + case FP_ZERO: + if(flags_ & signed_zero) { + if((boost::math::signbit)(val)) + put_num_and_fill(it, iosb, "-", "0", fill); + else if(iosb.flags() & std::ios_base::showpos) + put_num_and_fill(it, iosb, "+", "0", fill); + else + put_num_and_fill(it, iosb, "", "0", fill); + } + else + put_num_and_fill(it, iosb, "", "0", fill); + break; + + default: + it = std::num_put::do_put( + it, iosb, fill, val); + break; + } + } + + void put_num_and_fill( + OutputIterator& it, std::ios_base& iosb, const char* prefix, + const char* body, CharType fill) const + { + int width = (int)strlen(prefix) + (int)strlen(body); + std::ios_base::fmtflags adjust + = iosb.flags() & std::ios_base::adjustfield; + const std::ctype& ct + = std::use_facet >(iosb.getloc()); + + if(adjust != std::ios_base::internal && adjust != std::ios_base::left) + put_fill(it, iosb, fill, width); + + while(*prefix) + *it = ct.widen(*(prefix++)); + + if(adjust == std::ios_base::internal) + put_fill(it, iosb, fill, width); + + if(iosb.flags() & std::ios_base::uppercase) { + while(*body) + *it = ct.toupper(ct.widen(*(body++))); + } + else { + while(*body) + *it = ct.widen(*(body++)); + } + + if(adjust == std::ios_base::left) + put_fill(it, iosb, fill, width); + } + + void put_fill( + OutputIterator& it, std::ios_base& iosb, + CharType fill, int width) const + { + for(std::streamsize i = iosb.width() - static_cast(width); i > 0; --i) + *it = fill; + } + + private: + const int flags_; + }; + + + // class nonfinite_num_get ------------------------------------------------------ + + template< + class CharType, + class InputIterator = std::istreambuf_iterator + > + class nonfinite_num_get : public std::num_get + { + + public: + explicit nonfinite_num_get(int flags = 0) : flags_(flags) + {} + + protected: // float, double and long double versions of do_get. + virtual InputIterator do_get( + InputIterator it, InputIterator end, std::ios_base& iosb, + std::ios_base::iostate& state, float& val) const + { + get_and_check_eof(it, end, iosb, state, val); + return it; + } + + virtual InputIterator do_get( + InputIterator it, InputIterator end, std::ios_base& iosb, + std::ios_base::iostate& state, double& val) const + { + get_and_check_eof(it, end, iosb, state, val); + return it; + } + + virtual InputIterator do_get( + InputIterator it, InputIterator end, std::ios_base& iosb, + std::ios_base::iostate& state, long double& val) const + { + get_and_check_eof(it, end, iosb, state, val); + return it; + } + + //.............................................................................. + + private: + template static ValType positive_nan() + { + // On some platforms quiet_NaN() may be negative. + return (boost::math::copysign)( + std::numeric_limits::quiet_NaN(), static_cast(1) + ); + // static_cast(1) added Paul A. Bristow 5 Apr 11 + } + + template void get_and_check_eof + ( + InputIterator& it, InputIterator end, std::ios_base& iosb, + std::ios_base::iostate& state, ValType& val + ) const + { + get_signed(it, end, iosb, state, val); + if(it == end) + state |= std::ios_base::eofbit; + } + + template void get_signed + ( + InputIterator& it, InputIterator end, std::ios_base& iosb, + std::ios_base::iostate& state, ValType& val + ) const + { + const std::ctype& ct + = std::use_facet >(iosb.getloc()); + + char c = peek_char(it, end, ct); + + bool negative = (c == '-'); + + if(negative || c == '+') + { + ++it; + c = peek_char(it, end, ct); + if(c == '-' || c == '+') + { // Without this check, "++5" etc would be accepted. + state |= std::ios_base::failbit; + return; + } + } + + get_unsigned(it, end, iosb, ct, state, val); + + if(negative) + { + val = (boost::math::changesign)(val); + } + } // void get_signed + + template void get_unsigned + ( //! Get an unsigned floating-point value into val, + //! but checking for letters indicating non-finites. + InputIterator& it, InputIterator end, std::ios_base& iosb, + const std::ctype& ct, + std::ios_base::iostate& state, ValType& val + ) const + { + switch(peek_char(it, end, ct)) + { + case 'i': + get_i(it, end, ct, state, val); + break; + + case 'n': + get_n(it, end, ct, state, val); + break; + + case 'q': + case 's': + get_q(it, end, ct, state, val); + break; + + default: // Got a normal floating-point value into val. + it = std::num_get::do_get( + it, end, iosb, state, val); + if((flags_ & legacy) && val == static_cast(1) + && peek_char(it, end, ct) == '#') + get_one_hash(it, end, ct, state, val); + break; + } + } // get_unsigned + + //.......................................................................... + + template void get_i + ( // Get the rest of all strings starting with 'i', expect "inf", "infinity". + InputIterator& it, InputIterator end, const std::ctype& ct, + std::ios_base::iostate& state, ValType& val + ) const + { + if(!std::numeric_limits::has_infinity + || (flags_ & trap_infinity)) + { + state |= std::ios_base::failbit; + return; + } + + ++it; + if(!match_string(it, end, ct, "nf")) + { + state |= std::ios_base::failbit; + return; + } + + if(peek_char(it, end, ct) != 'i') + { + val = std::numeric_limits::infinity(); // "inf" + return; + } + + ++it; + if(!match_string(it, end, ct, "nity")) + { // Expected "infinity" + state |= std::ios_base::failbit; + return; + } + + val = std::numeric_limits::infinity(); // "infinity" + } // void get_i + + template void get_n + ( // Get expected strings after 'n', "nan", "nanq", "nans", "nan(...)" + InputIterator& it, InputIterator end, const std::ctype& ct, + std::ios_base::iostate& state, ValType& val + ) const + { + if(!std::numeric_limits::has_quiet_NaN + || (flags_ & trap_nan)) { + state |= std::ios_base::failbit; + return; + } + + ++it; + if(!match_string(it, end, ct, "an")) + { + state |= std::ios_base::failbit; + return; + } + + switch(peek_char(it, end, ct)) { + case 'q': + case 's': + if(flags_ && legacy) + ++it; + break; // "nanq", "nans" + + case '(': // Optional payload field in (...) follows. + { + ++it; + char c; + while((c = peek_char(it, end, ct)) + && c != ')' && c != ' ' && c != '\n' && c != '\t') + ++it; + if(c != ')') + { // Optional payload field terminator missing! + state |= std::ios_base::failbit; + return; + } + ++it; + break; // "nan(...)" + } + + default: + break; // "nan" + } + + val = positive_nan(); + } // void get_n + + template void get_q + ( // Get expected rest of string starting with 'q': "qnan". + InputIterator& it, InputIterator end, const std::ctype& ct, + std::ios_base::iostate& state, ValType& val + ) const + { + if(!std::numeric_limits::has_quiet_NaN + || (flags_ & trap_nan) || !(flags_ & legacy)) + { + state |= std::ios_base::failbit; + return; + } + + ++it; + if(!match_string(it, end, ct, "nan")) + { + state |= std::ios_base::failbit; + return; + } + + val = positive_nan(); // "QNAN" + } // void get_q + + template void get_one_hash + ( // Get expected string after having read "1.#": "1.#IND", "1.#QNAN", "1.#SNAN". + InputIterator& it, InputIterator end, const std::ctype& ct, + std::ios_base::iostate& state, ValType& val + ) const + { + + ++it; + switch(peek_char(it, end, ct)) + { + case 'i': // from IND (indeterminate), considered same a QNAN. + get_one_hash_i(it, end, ct, state, val); // "1.#IND" + return; + + case 'q': // from QNAN + case 's': // from SNAN - treated the same as QNAN. + if(std::numeric_limits::has_quiet_NaN + && !(flags_ & trap_nan)) + { + ++it; + if(match_string(it, end, ct, "nan")) + { // "1.#QNAN", "1.#SNAN" + // ++it; // removed as caused assert() cannot increment iterator). +// (match_string consumes string, so not needed?). +// https://svn.boost.org/trac/boost/ticket/5467 +// Change in nonfinite_num_facet.hpp Paul A. Bristow 11 Apr 11 makes legacy_test.cpp work OK. + val = positive_nan(); // "1.#QNAN" + return; + } + } + break; + + default: + break; + } + + state |= std::ios_base::failbit; + } // void get_one_hash + + template void get_one_hash_i + ( // Get expected strings after 'i', "1.#INF", 1.#IND". + InputIterator& it, InputIterator end, const std::ctype& ct, + std::ios_base::iostate& state, ValType& val + ) const + { + ++it; + + if(peek_char(it, end, ct) == 'n') + { + ++it; + switch(peek_char(it, end, ct)) + { + case 'f': // "1.#INF" + if(std::numeric_limits::has_infinity + && !(flags_ & trap_infinity)) + { + ++it; + val = std::numeric_limits::infinity(); + return; + } + break; + + case 'd': // 1.#IND" + if(std::numeric_limits::has_quiet_NaN + && !(flags_ & trap_nan)) + { + ++it; + val = positive_nan(); + return; + } + break; + + default: + break; + } + } + + state |= std::ios_base::failbit; + } // void get_one_hash_i + + //.......................................................................... + + char peek_char + ( //! \return next char in the input buffer, ensuring lowercase (but do not 'consume' char). + InputIterator& it, InputIterator end, + const std::ctype& ct + ) const + { + if(it == end) return 0; + return ct.narrow(ct.tolower(*it), 0); // Always tolower to ensure case insensitive. + } + + bool match_string + ( //! Match remaining chars to expected string (case insensitive), + //! consuming chars that match OK. + //! \return true if matched expected string, else false. + InputIterator& it, InputIterator end, + const std::ctype& ct, + const char* s + ) const + { + while(it != end && *s && *s == ct.narrow(ct.tolower(*it), 0)) + { + ++s; + ++it; // + } + return !*s; + } // bool match_string + + private: + const int flags_; + }; // + + //------------------------------------------------------------------------------ + + } // namespace math +} // namespace boost + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif diff --git a/include/boost/math/special_functions/sign.hpp b/include/boost/math/special_functions/sign.hpp index 88db77729..6de88b29a 100644 --- a/include/boost/math/special_functions/sign.hpp +++ b/include/boost/math/special_functions/sign.hpp @@ -1,4 +1,7 @@ // (C) Copyright John Maddock 2006. +// (C) Copyright Johan Rade 2006. +// (C) Copyright Paul A. Bristow 2011 (added changesign). + // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -18,6 +21,8 @@ namespace boost{ namespace math{ namespace detail { + // signbit + #ifdef BOOST_MATH_USE_STD_FPCLASSIFY template inline int signbit_impl(T x, native_tag const&) @@ -58,10 +63,51 @@ namespace detail { return a & traits::sign ? 1 : 0; } + + // Changesign + + template + inline T (changesign_impl)(T x, generic_tag const&) + { + return -x; + } + + template + inline T (changesign_impl)(T x, generic_tag const&) + { + return -x; + } + + + template + inline T changesign_impl(T x, ieee_copy_all_bits_tag const&) + { + typedef BOOST_DEDUCED_TYPENAME fp_traits::sign_change_type traits; + + BOOST_DEDUCED_TYPENAME traits::bits a; + traits::get_bits(x,a); + a ^= traits::sign; + traits::set_bits(x,a); + return x; + } + + template + inline T (changesign_impl)(T x, ieee_copy_leading_bits_tag const&) + { + typedef BOOST_DEDUCED_TYPENAME fp_traits::sign_change_type traits; + + BOOST_DEDUCED_TYPENAME traits::bits a; + traits::get_bits(x,a); + a ^= traits::sign; + traits::set_bits(x,a); + return x; + } + + } // namespace detail template int (signbit)(T x) -{ //!< \brief return true if floating-point type t is NaN (Not A Number). +{ typedef typename detail::fp_traits::type traits; typedef typename traits::method method; typedef typename boost::is_floating_point::type fp_tag; @@ -74,11 +120,20 @@ inline int sign BOOST_NO_MACRO_EXPAND(const T& z) return (z == 0) ? 0 : (boost::math::signbit)(z) ? -1 : 1; } +template T (changesign)(const T& x) +{ //!< \brief return unchanged binary pattern of x, except for change of sign bit. + typedef typename detail::fp_traits::sign_change_type traits; + typedef typename traits::method method; + typedef typename boost::is_floating_point::type fp_tag; + + return detail::changesign_impl(x, method()); +} + template inline T copysign BOOST_NO_MACRO_EXPAND(const T& x, const T& y) { BOOST_MATH_STD_USING - return fabs(x) * ((boost::math::signbit)(y) ? -1 : 1); + return (boost::math::signbit)(x) != (boost::math::signbit)(y) ? (boost::math::changesign)(x) : x; } } // namespace math diff --git a/include/boost/math/tools/config.hpp b/include/boost/math/tools/config.hpp index e2429133f..736fedee5 100644 --- a/include/boost/math/tools/config.hpp +++ b/include/boost/math/tools/config.hpp @@ -253,9 +253,15 @@ inline T max BOOST_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c, T d) return (std::max)((std::max)(a, b), (std::max)(c, d)); } } // namespace tools + +template +void suppress_unused_variable_warning(const T&) +{ +} + }} // namespace boost namespace math -#if (defined(__linux__) && !defined(__UCLIBC__)) || defined(__QNX__) || defined(__IBMCPP__) +#if ((defined(__linux__) && !defined(__UCLIBC__)) || defined(__QNX__) || defined(__IBMCPP__)) && !defined(BOOST_NO_FENV_H) #include diff --git a/include/boost/math/tools/precision.hpp b/include/boost/math/tools/precision.hpp index e7695e92a..54cadcc96 100644 --- a/include/boost/math/tools/precision.hpp +++ b/include/boost/math/tools/precision.hpp @@ -45,8 +45,10 @@ inline int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); + BOOST_STATIC_ASSERT( ::std::numeric_limits::radix == 2); #else BOOST_ASSERT(::std::numeric_limits::is_specialized); + BOOST_ASSERT(::std::numeric_limits::radix == 2); #endif return std::numeric_limits::digits; } @@ -303,14 +305,14 @@ inline T forth_root_epsilon_imp(const T*, const Tag&) template inline T root_epsilon() { - typedef mpl::int_::digits> tag_type; + typedef mpl::int_< (::std::numeric_limits::radix == 2) ? std::numeric_limits::digits : 0> tag_type; return detail::root_epsilon_imp(static_cast(0), tag_type()); } template inline T forth_root_epsilon() { - typedef mpl::int_::digits> tag_type; + typedef mpl::int_< (::std::numeric_limits::radix == 2) ? std::numeric_limits::digits : 0> tag_type; return detail::forth_root_epsilon_imp(static_cast(0), tag_type()); } diff --git a/include/boost/math/tr1.hpp b/include/boost/math/tr1.hpp index 2fb2f291c..e057c3403 100644 --- a/include/boost/math/tr1.hpp +++ b/include/boost/math/tr1.hpp @@ -104,6 +104,7 @@ namespace boost{ namespace math{ namespace tr1{ extern "C"{ # include #endif +#if !defined(__cplusplus) && defined(FLT_EVAL_METHOD) && (FLT_EVAL_METHOD > 2) #ifndef FLT_EVAL_METHOD typedef float float_t; typedef double double_t; @@ -117,6 +118,7 @@ typedef double double_t; typedef long double float_t; typedef long double double_t; #endif +#endif // C99 Functions: double BOOST_MATH_TR1_DECL boost_acosh BOOST_PREVENT_MACRO_SUBSTITUTION(double x) BOOST_MATH_C99_THROW_SPEC; @@ -829,7 +831,7 @@ template inline typename tools::promote_args::type comp_ellint_1 BOOST_PREVENT_MACRO_SUBSTITUTION(T k) { return boost::math::tr1::comp_ellint_1 BOOST_PREVENT_MACRO_SUBSTITUTION(static_cast::type>(k)); } -// [5.2.1.5] BOOST_PREVENT_MACRO_SUBSTITUTION(complete) elliptic integral of the second kind: +// [5.2.1.5] (complete) elliptic integral of the second kind: inline float comp_ellint_2f(float k) { return boost::math::tr1::boost_comp_ellint_2f(k); } inline double comp_ellint_2(double k) @@ -844,7 +846,7 @@ template inline typename tools::promote_args::type comp_ellint_2(T k) { return boost::math::tr1::comp_ellint_2(static_cast::type> BOOST_PREVENT_MACRO_SUBSTITUTION(k)); } -// [5.2.1.6] BOOST_PREVENT_MACRO_SUBSTITUTION(complete) elliptic integral of the third kind: +// [5.2.1.6] (complete) elliptic integral of the third kind: inline float comp_ellint_3f(float k, float nu) { return boost::math::tr1::boost_comp_ellint_3f(k, nu); } inline double comp_ellint_3(double k, double nu) @@ -1105,805 +1107,7 @@ inline typename tools::promote_args::type sph_neumann BOOST_PREVENT_MACRO_SUB #else // __cplusplus -// C99 Functions: -#ifdef acosh -#undef acosh -#endif -#define acosh boost_acosh -#ifdef acoshf -#undef acoshf -#endif -#define acoshf boost_acoshf -#ifdef acoshl -#undef acoshl -#endif -#define acoshl boost_acoshl - -#ifdef asinh -#undef asinh -#endif -#define asinh boost_asinh -#ifdef asinhf -#undef asinhf -#endif -#define asinhf boost_asinhf -#ifdef asinhl -#undef asinhl -#endif -#define asinhl boost_asinhl - -#ifdef atanh -#undef atanh -#endif -#define atanh boost_atanh -#ifdef atanhf -#undef atanhf -#endif -#define atanhf boost_atanhf -#ifdef atanhl -#undef atanhl -#endif -#define atanhl boost_atanhl - -#ifdef cbrt -#undef cbrt -#endif -#define cbrt boost_cbrt -#ifdef cbrtf -#undef cbrtf -#endif -#define cbrtf boost_cbrtf -#ifdef cbrtl -#undef cbrtl -#endif -#define cbrtl boost_cbrtl - -#ifdef copysign -#undef copysign -#endif -#define copysign boost_copysign -#ifdef copysignf -#undef copysignf -#endif -#define copysignf boost_copysignf -#ifdef copysignl -#undef copysignl -#endif -#define copysignl boost_copysignl - -#ifdef erf -#undef erf -#endif -#define erf boost_erf -#ifdef erff -#undef erff -#endif -#define erff boost_erff -#ifdef erfl -#undef erfl -#endif -#define erfl boost_erfl - -#ifdef erfc -#undef erfc -#endif -#define erfc boost_erfc -#ifdef erfcf -#undef erfcf -#endif -#define erfcf boost_erfcf -#ifdef erfcl -#undef erfcl -#endif -#define erfcl boost_erfcl - -#if 0 -#ifdef exp2 -#undef exp2 -#endif -#define exp2 boost_exp2 -#ifdef exp2f -#undef exp2f -#endif -#define exp2f boost_exp2f -#ifdef exp2l -#undef exp2l -#endif -#define exp2l boost_exp2l -#endif - -#ifdef expm1 -#undef expm1 -#endif -#define expm1 boost_expm1 -#ifdef expm1f -#undef expm1f -#endif -#define expm1f boost_expm1f -#ifdef expm1l -#undef expm1l -#endif -#define expm1l boost_expm1l - -#if 0 -#ifdef fdim -#undef fdim -#endif -#define fdim boost_fdim -#ifdef fdimf -#undef fdimf -#endif -#define fdimf boost_fdimf -#ifdef fdiml -#undef fdiml -#endif -#define fdiml boost_fdiml -#ifdef acosh -#undef acosh -#endif -#define fma boost_fma -#ifdef fmaf -#undef fmaf -#endif -#define fmaf boost_fmaf -#ifdef fmal -#undef fmal -#endif -#define fmal boost_fmal -#endif - -#ifdef fmax -#undef fmax -#endif -#define fmax boost_fmax -#ifdef fmaxf -#undef fmaxf -#endif -#define fmaxf boost_fmaxf -#ifdef fmaxl -#undef fmaxl -#endif -#define fmaxl boost_fmaxl - -#ifdef fmin -#undef fmin -#endif -#define fmin boost_fmin -#ifdef fminf -#undef fminf -#endif -#define fminf boost_fminf -#ifdef fminl -#undef fminl -#endif -#define fminl boost_fminl - -#ifdef hypot -#undef hypot -#endif -#define hypot boost_hypot -#ifdef hypotf -#undef hypotf -#endif -#define hypotf boost_hypotf -#ifdef hypotl -#undef hypotl -#endif -#define hypotl boost_hypotl - -#if 0 -#ifdef ilogb -#undef ilogb -#endif -#define ilogb boost_ilogb -#ifdef ilogbf -#undef ilogbf -#endif -#define ilogbf boost_ilogbf -#ifdef ilogbl -#undef ilogbl -#endif -#define ilogbl boost_ilogbl -#endif - -#ifdef lgamma -#undef lgamma -#endif -#define lgamma boost_lgamma -#ifdef lgammaf -#undef lgammaf -#endif -#define lgammaf boost_lgammaf -#ifdef lgammal -#undef lgammal -#endif -#define lgammal boost_lgammal - -#ifdef BOOST_HAS_LONG_LONG -#if 0 -#ifdef llrint -#undef llrint -#endif -#define llrint boost_llrint -#ifdef llrintf -#undef llrintf -#endif -#define llrintf boost_llrintf -#ifdef llrintl -#undef llrintl -#endif -#define llrintl boost_llrintl -#endif -#ifdef llround -#undef llround -#endif -#define llround boost_llround -#ifdef llroundf -#undef llroundf -#endif -#define llroundf boost_llroundf -#ifdef llroundl -#undef llroundl -#endif -#define llroundl boost_llroundl -#endif - -#ifdef log1p -#undef log1p -#endif -#define log1p boost_log1p -#ifdef log1pf -#undef log1pf -#endif -#define log1pf boost_log1pf -#ifdef log1pl -#undef log1pl -#endif -#define log1pl boost_log1pl - -#if 0 -#ifdef log2 -#undef log2 -#endif -#define log2 boost_log2 -#ifdef log2f -#undef log2f -#endif -#define log2f boost_log2f -#ifdef log2l -#undef log2l -#endif -#define log2l boost_log2l - -#ifdef logb -#undef logb -#endif -#define logb boost_logb -#ifdef logbf -#undef logbf -#endif -#define logbf boost_logbf -#ifdef logbl -#undef logbl -#endif -#define logbl boost_logbl - -#ifdef lrint -#undef lrint -#endif -#define lrint boost_lrint -#ifdef lrintf -#undef lrintf -#endif -#define lrintf boost_lrintf -#ifdef lrintl -#undef lrintl -#endif -#define lrintl boost_lrintl -#endif - -#ifdef lround -#undef lround -#endif -#define lround boost_lround -#ifdef lroundf -#undef lroundf -#endif -#define lroundf boost_lroundf -#ifdef lroundl -#undef lroundl -#endif -#define lroundl boost_lroundl - -#if 0 -#ifdef nan -#undef nan -#endif -#define nan boost_nan -#ifdef nanf -#undef nanf -#endif -#define nanf boost_nanf -#ifdef nanl -#undef nanl -#endif -#define nanl boost_nanl - -#ifdef nearbyint -#undef nearbyint -#endif -#define nearbyint boost_nearbyint -#ifdef nearbyintf -#undef nearbyintf -#endif -#define nearbyintf boost_nearbyintf -#ifdef nearbyintl -#undef nearbyintl -#endif -#define nearbyintl boost_nearbyintl -#endif - -#ifdef nextafter -#undef nextafter -#endif -#define nextafter boost_nextafter -#ifdef nextafterf -#undef nextafterf -#endif -#define nextafterf boost_nextafterf -#ifdef nextafterl -#undef nextafterl -#endif -#define nextafterl boost_nextafterl - -#ifdef nexttoward -#undef nexttoward -#endif -#define nexttoward boost_nexttoward -#ifdef nexttowardf -#undef nexttowardf -#endif -#define nexttowardf boost_nexttowardf -#ifdef nexttowardl -#undef nexttowardl -#endif -#define nexttowardl boost_nexttowardl - -#if 0 -#ifdef remainder -#undef remainder -#endif -#define remainder boost_remainder -#ifdef remainderf -#undef remainderf -#endif -#define remainderf boost_remainderf -#ifdef remainderl -#undef remainderl -#endif -#define remainderl boost_remainderl - -#ifdef remquo -#undef remquo -#endif -#define remquo boost_remquo -#ifdef remquof -#undef remquof -#endif -#define remquof boost_remquof -#ifdef remquol -#undef remquol -#endif -#define remquol boost_remquol - -#ifdef rint -#undef rint -#endif -#define rint boost_rint -#ifdef rintf -#undef rintf -#endif -#define rintf boost_rintf -#ifdef rintl -#undef rintl -#endif -#define rintl boost_rintl -#endif - -#ifdef round -#undef round -#endif -#define round boost_round -#ifdef roundf -#undef roundf -#endif -#define roundf boost_roundf -#ifdef roundl -#undef roundl -#endif -#define roundl boost_roundl - -#if 0 -#ifdef scalbln -#undef scalbln -#endif -#define scalbln boost_scalbln -#ifdef scalblnf -#undef scalblnf -#endif -#define scalblnf boost_scalblnf -#ifdef scalblnl -#undef scalblnl -#endif -#define scalblnl boost_scalblnl - -#ifdef scalbn -#undef scalbn -#endif -#define scalbn boost_scalbn -#ifdef scalbnf -#undef scalbnf -#endif -#define scalbnf boost_scalbnf -#ifdef scalbnl -#undef scalbnl -#endif -#define scalbnl boost_scalbnl -#endif - -#ifdef tgamma -#undef tgamma -#endif -#define tgamma boost_tgamma -#ifdef tgammaf -#undef tgammaf -#endif -#define tgammaf boost_tgammaf -#ifdef tgammal -#undef tgammal -#endif -#define tgammal boost_tgammal - -#ifdef trunc -#undef trunc -#endif -#define trunc boost_trunc -#ifdef truncf -#undef truncf -#endif -#define truncf boost_truncf -#ifdef truncl -#undef truncl -#endif -#define truncl boost_truncl - -// [5.2.1.1] associated Laguerre polynomials: -#ifdef assoc_laguerre -#undef assoc_laguerre -#endif -#define assoc_laguerre boost_assoc_laguerre -#ifdef assoc_laguerref -#undef assoc_laguerref -#endif -#define assoc_laguerref boost_assoc_laguerref -#ifdef assoc_laguerrel -#undef assoc_laguerrel -#endif -#define assoc_laguerrel boost_assoc_laguerrel - -// [5.2.1.2] associated Legendre functions: -#ifdef assoc_legendre -#undef assoc_legendre -#endif -#define assoc_legendre boost_assoc_legendre -#ifdef assoc_legendref -#undef assoc_legendref -#endif -#define assoc_legendref boost_assoc_legendref -#ifdef assoc_legendrel -#undef assoc_legendrel -#endif -#define assoc_legendrel boost_assoc_legendrel - -// [5.2.1.3] beta function: -#ifdef beta -#undef beta -#endif -#define beta boost_beta -#ifdef betaf -#undef betaf -#endif -#define betaf boost_betaf -#ifdef betal -#undef betal -#endif -#define betal boost_betal - -// [5.2.1.4] (complete) elliptic integral of the first kind: -#ifdef comp_ellint_1 -#undef comp_ellint_1 -#endif -#define comp_ellint_1 boost_comp_ellint_1 -#ifdef comp_ellint_1f -#undef comp_ellint_1f -#endif -#define comp_ellint_1f boost_comp_ellint_1f -#ifdef comp_ellint_1l -#undef comp_ellint_1l -#endif -#define comp_ellint_1l boost_comp_ellint_1l - -// [5.2.1.5] (complete) elliptic integral of the second kind: -#ifdef comp_ellint_2 -#undef comp_ellint_2 -#endif -#define comp_ellint_2 boost_comp_ellint_2 -#ifdef comp_ellint_2f -#undef comp_ellint_2f -#endif -#define comp_ellint_2f boost_comp_ellint_2f -#ifdef comp_ellint_2l -#undef comp_ellint_2l -#endif -#define comp_ellint_2l boost_comp_ellint_2l - -// [5.2.1.6] (complete) elliptic integral of the third kind: -#ifdef comp_ellint_3 -#undef comp_ellint_3 -#endif -#define comp_ellint_3 boost_comp_ellint_3 -#ifdef comp_ellint_3f -#undef comp_ellint_3f -#endif -#define comp_ellint_3f boost_comp_ellint_3f -#ifdef comp_ellint_3l -#undef comp_ellint_3l -#endif -#define comp_ellint_3l boost_comp_ellint_3l - -#if 0 -// [5.2.1.7] confluent hypergeometric functions: -#ifdef conf_hyper -#undef conf_hyper -#endif -#define conf_hyper boost_conf_hyper -#ifdef conf_hyperf -#undef conf_hyperf -#endif -#define conf_hyperf boost_conf_hyperf -#ifdef conf_hyperl -#undef conf_hyperl -#endif -#define conf_hyperl boost_conf_hyperl -#endif - -// [5.2.1.8] regular modified cylindrical Bessel functions: -#ifdef cyl_bessel_i -#undef cyl_bessel_i -#endif -#define cyl_bessel_i boost_cyl_bessel_i -#ifdef cyl_bessel_if -#undef cyl_bessel_if -#endif -#define cyl_bessel_if boost_cyl_bessel_if -#ifdef cyl_bessel_il -#undef cyl_bessel_il -#endif -#define cyl_bessel_il boost_cyl_bessel_il - -// [5.2.1.9] cylindrical Bessel functions (of the first kind): -#ifdef cyl_bessel_j -#undef cyl_bessel_j -#endif -#define cyl_bessel_j boost_cyl_bessel_j -#ifdef cyl_bessel_jf -#undef cyl_bessel_jf -#endif -#define cyl_bessel_jf boost_cyl_bessel_jf -#ifdef cyl_bessel_jl -#undef cyl_bessel_jl -#endif -#define cyl_bessel_jl boost_cyl_bessel_jl - -// [5.2.1.10] irregular modified cylindrical Bessel functions: -#ifdef cyl_bessel_k -#undef cyl_bessel_k -#endif -#define cyl_bessel_k boost_cyl_bessel_k -#ifdef cyl_bessel_kf -#undef cyl_bessel_kf -#endif -#define cyl_bessel_kf boost_cyl_bessel_kf -#ifdef cyl_bessel_kl -#undef cyl_bessel_kl -#endif -#define cyl_bessel_kl boost_cyl_bessel_kl - -// [5.2.1.11] cylindrical Neumann functions BOOST_MATH_C99_THROW_SPEC; -// cylindrical Bessel functions (of the second kind): -#ifdef cyl_neumann -#undef cyl_neumann -#endif -#define cyl_neumann boost_cyl_neumann -#ifdef cyl_neumannf -#undef cyl_neumannf -#endif -#define cyl_neumannf boost_cyl_neumannf -#ifdef cyl_neumannl -#undef cyl_neumannl -#endif -#define cyl_neumannl boost_cyl_neumannl - -// [5.2.1.12] (incomplete) elliptic integral of the first kind: -#ifdef ellint_1 -#undef ellint_1 -#endif -#define ellint_1 boost_ellint_1 -#ifdef ellint_1f -#undef ellint_1f -#endif -#define ellint_1f boost_ellint_1f -#ifdef ellint_1l -#undef ellint_1l -#endif -#define ellint_1l boost_ellint_1l - -// [5.2.1.13] (incomplete) elliptic integral of the second kind: -#ifdef ellint_2 -#undef ellint_2 -#endif -#define ellint_2 boost_ellint_2 -#ifdef ellint_2f -#undef ellint_2f -#endif -#define ellint_2f boost_ellint_2f -#ifdef ellint_2l -#undef ellint_2l -#endif -#define ellint_2l boost_ellint_2l - -// [5.2.1.14] (incomplete) elliptic integral of the third kind: -#ifdef ellint_3 -#undef ellint_3 -#endif -#define ellint_3 boost_ellint_3 -#ifdef ellint_3f -#undef ellint_3f -#endif -#define ellint_3f boost_ellint_3f -#ifdef ellint_3l -#undef ellint_3l -#endif -#define ellint_3l boost_ellint_3l - -// [5.2.1.15] exponential integral: -#ifdef expint -#undef expint -#endif -#define expint boost_expint -#ifdef expintf -#undef expintf -#endif -#define expintf boost_expintf -#ifdef expintl -#undef expintl -#endif -#define expintl boost_expintl - -// [5.2.1.16] Hermite polynomials: -#ifdef hermite -#undef hermite -#endif -#define hermite boost_hermite -#ifdef hermitef -#undef hermitef -#endif -#define hermitef boost_hermitef -#ifdef hermitel -#undef hermitel -#endif -#define hermitel boost_hermitel - -#if 0 -// [5.2.1.17] hypergeometric functions: -#ifdef hyperg -#undef hyperg -#endif -#define hyperg boost_hyperg -#ifdef hypergf -#undef hypergf -#endif -#define hypergf boost_hypergf -#ifdef hypergl -#undef hypergl -#endif -#define hypergl boost_hypergl -#endif - -// [5.2.1.18] Laguerre polynomials: -#ifdef laguerre -#undef laguerre -#endif -#define laguerre boost_laguerre -#ifdef laguerref -#undef laguerref -#endif -#define laguerref boost_laguerref -#ifdef laguerrel -#undef laguerrel -#endif -#define laguerrel boost_laguerrel - -// [5.2.1.19] Legendre polynomials: -#ifdef legendre -#undef legendre -#endif -#define legendre boost_legendre -#ifdef legendref -#undef legendref -#endif -#define legendref boost_legendref -#ifdef legendrel -#undef legendrel -#endif -#define legendrel boost_legendrel - -// [5.2.1.20] Riemann zeta function: -#ifdef riemann_zeta -#undef riemann_zeta -#endif -#define riemann_zeta boost_riemann_zeta -#ifdef riemann_zetaf -#undef riemann_zetaf -#endif -#define riemann_zetaf boost_riemann_zetaf -#ifdef riemann_zetal -#undef riemann_zetal -#endif -#define riemann_zetal boost_riemann_zetal - -// [5.2.1.21] spherical Bessel functions (of the first kind): -#ifdef sph_bessel -#undef sph_bessel -#endif -#define sph_bessel boost_sph_bessel -#ifdef sph_besself -#undef sph_besself -#endif -#define sph_besself boost_sph_besself -#ifdef sph_bessell -#undef sph_bessell -#endif -#define sph_bessell boost_sph_bessell - -// [5.2.1.22] spherical associated Legendre functions: -#ifdef sph_legendre -#undef sph_legendre -#endif -#define sph_legendre boost_sph_legendre -#ifdef sph_legendref -#undef sph_legendref -#endif -#define sph_legendref boost_sph_legendref -#ifdef sph_legendrel -#undef sph_legendrel -#endif -#define sph_legendrel boost_sph_legendrel - -// [5.2.1.23] spherical Neumann functions BOOST_MATH_C99_THROW_SPEC; -// spherical Bessel functions (of the second kind): -#ifdef sph_neumann -#undef sph_neumann -#endif -#define sph_neumann boost_sph_neumann -#ifdef sph_neumannf -#undef sph_neumannf -#endif -#define sph_neumannf boost_sph_neumannf -#ifdef sph_neumannl -#undef sph_neumannl -#endif -#define sph_neumannl boost_sph_neumannl +#include #endif // __cplusplus diff --git a/include/boost/math/tr1_c_macros.ipp b/include/boost/math/tr1_c_macros.ipp new file mode 100644 index 000000000..c173639af --- /dev/null +++ b/include/boost/math/tr1_c_macros.ipp @@ -0,0 +1,810 @@ +// Copyright John Maddock 2008-11. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_MATH_C_MACROS_IPP +#define BOOST_MATH_C_MACROS_IPP + +// C99 Functions: +#ifdef acosh +#undef acosh +#endif +#define acosh boost_acosh +#ifdef acoshf +#undef acoshf +#endif +#define acoshf boost_acoshf +#ifdef acoshl +#undef acoshl +#endif +#define acoshl boost_acoshl + +#ifdef asinh +#undef asinh +#endif +#define asinh boost_asinh +#ifdef asinhf +#undef asinhf +#endif +#define asinhf boost_asinhf +#ifdef asinhl +#undef asinhl +#endif +#define asinhl boost_asinhl + +#ifdef atanh +#undef atanh +#endif +#define atanh boost_atanh +#ifdef atanhf +#undef atanhf +#endif +#define atanhf boost_atanhf +#ifdef atanhl +#undef atanhl +#endif +#define atanhl boost_atanhl + +#ifdef cbrt +#undef cbrt +#endif +#define cbrt boost_cbrt +#ifdef cbrtf +#undef cbrtf +#endif +#define cbrtf boost_cbrtf +#ifdef cbrtl +#undef cbrtl +#endif +#define cbrtl boost_cbrtl + +#ifdef copysign +#undef copysign +#endif +#define copysign boost_copysign +#ifdef copysignf +#undef copysignf +#endif +#define copysignf boost_copysignf +#ifdef copysignl +#undef copysignl +#endif +#define copysignl boost_copysignl + +#ifdef erf +#undef erf +#endif +#define erf boost_erf +#ifdef erff +#undef erff +#endif +#define erff boost_erff +#ifdef erfl +#undef erfl +#endif +#define erfl boost_erfl + +#ifdef erfc +#undef erfc +#endif +#define erfc boost_erfc +#ifdef erfcf +#undef erfcf +#endif +#define erfcf boost_erfcf +#ifdef erfcl +#undef erfcl +#endif +#define erfcl boost_erfcl + +#if 0 +#ifdef exp2 +#undef exp2 +#endif +#define exp2 boost_exp2 +#ifdef exp2f +#undef exp2f +#endif +#define exp2f boost_exp2f +#ifdef exp2l +#undef exp2l +#endif +#define exp2l boost_exp2l +#endif + +#ifdef expm1 +#undef expm1 +#endif +#define expm1 boost_expm1 +#ifdef expm1f +#undef expm1f +#endif +#define expm1f boost_expm1f +#ifdef expm1l +#undef expm1l +#endif +#define expm1l boost_expm1l + +#if 0 +#ifdef fdim +#undef fdim +#endif +#define fdim boost_fdim +#ifdef fdimf +#undef fdimf +#endif +#define fdimf boost_fdimf +#ifdef fdiml +#undef fdiml +#endif +#define fdiml boost_fdiml +#ifdef acosh +#undef acosh +#endif +#define fma boost_fma +#ifdef fmaf +#undef fmaf +#endif +#define fmaf boost_fmaf +#ifdef fmal +#undef fmal +#endif +#define fmal boost_fmal +#endif + +#ifdef fmax +#undef fmax +#endif +#define fmax boost_fmax +#ifdef fmaxf +#undef fmaxf +#endif +#define fmaxf boost_fmaxf +#ifdef fmaxl +#undef fmaxl +#endif +#define fmaxl boost_fmaxl + +#ifdef fmin +#undef fmin +#endif +#define fmin boost_fmin +#ifdef fminf +#undef fminf +#endif +#define fminf boost_fminf +#ifdef fminl +#undef fminl +#endif +#define fminl boost_fminl + +#ifdef hypot +#undef hypot +#endif +#define hypot boost_hypot +#ifdef hypotf +#undef hypotf +#endif +#define hypotf boost_hypotf +#ifdef hypotl +#undef hypotl +#endif +#define hypotl boost_hypotl + +#if 0 +#ifdef ilogb +#undef ilogb +#endif +#define ilogb boost_ilogb +#ifdef ilogbf +#undef ilogbf +#endif +#define ilogbf boost_ilogbf +#ifdef ilogbl +#undef ilogbl +#endif +#define ilogbl boost_ilogbl +#endif + +#ifdef lgamma +#undef lgamma +#endif +#define lgamma boost_lgamma +#ifdef lgammaf +#undef lgammaf +#endif +#define lgammaf boost_lgammaf +#ifdef lgammal +#undef lgammal +#endif +#define lgammal boost_lgammal + +#ifdef BOOST_HAS_LONG_LONG +#if 0 +#ifdef llrint +#undef llrint +#endif +#define llrint boost_llrint +#ifdef llrintf +#undef llrintf +#endif +#define llrintf boost_llrintf +#ifdef llrintl +#undef llrintl +#endif +#define llrintl boost_llrintl +#endif +#ifdef llround +#undef llround +#endif +#define llround boost_llround +#ifdef llroundf +#undef llroundf +#endif +#define llroundf boost_llroundf +#ifdef llroundl +#undef llroundl +#endif +#define llroundl boost_llroundl +#endif + +#ifdef log1p +#undef log1p +#endif +#define log1p boost_log1p +#ifdef log1pf +#undef log1pf +#endif +#define log1pf boost_log1pf +#ifdef log1pl +#undef log1pl +#endif +#define log1pl boost_log1pl + +#if 0 +#ifdef log2 +#undef log2 +#endif +#define log2 boost_log2 +#ifdef log2f +#undef log2f +#endif +#define log2f boost_log2f +#ifdef log2l +#undef log2l +#endif +#define log2l boost_log2l + +#ifdef logb +#undef logb +#endif +#define logb boost_logb +#ifdef logbf +#undef logbf +#endif +#define logbf boost_logbf +#ifdef logbl +#undef logbl +#endif +#define logbl boost_logbl + +#ifdef lrint +#undef lrint +#endif +#define lrint boost_lrint +#ifdef lrintf +#undef lrintf +#endif +#define lrintf boost_lrintf +#ifdef lrintl +#undef lrintl +#endif +#define lrintl boost_lrintl +#endif + +#ifdef lround +#undef lround +#endif +#define lround boost_lround +#ifdef lroundf +#undef lroundf +#endif +#define lroundf boost_lroundf +#ifdef lroundl +#undef lroundl +#endif +#define lroundl boost_lroundl + +#if 0 +#ifdef nan +#undef nan +#endif +#define nan boost_nan +#ifdef nanf +#undef nanf +#endif +#define nanf boost_nanf +#ifdef nanl +#undef nanl +#endif +#define nanl boost_nanl + +#ifdef nearbyint +#undef nearbyint +#endif +#define nearbyint boost_nearbyint +#ifdef nearbyintf +#undef nearbyintf +#endif +#define nearbyintf boost_nearbyintf +#ifdef nearbyintl +#undef nearbyintl +#endif +#define nearbyintl boost_nearbyintl +#endif + +#ifdef nextafter +#undef nextafter +#endif +#define nextafter boost_nextafter +#ifdef nextafterf +#undef nextafterf +#endif +#define nextafterf boost_nextafterf +#ifdef nextafterl +#undef nextafterl +#endif +#define nextafterl boost_nextafterl + +#ifdef nexttoward +#undef nexttoward +#endif +#define nexttoward boost_nexttoward +#ifdef nexttowardf +#undef nexttowardf +#endif +#define nexttowardf boost_nexttowardf +#ifdef nexttowardl +#undef nexttowardl +#endif +#define nexttowardl boost_nexttowardl + +#if 0 +#ifdef remainder +#undef remainder +#endif +#define remainder boost_remainder +#ifdef remainderf +#undef remainderf +#endif +#define remainderf boost_remainderf +#ifdef remainderl +#undef remainderl +#endif +#define remainderl boost_remainderl + +#ifdef remquo +#undef remquo +#endif +#define remquo boost_remquo +#ifdef remquof +#undef remquof +#endif +#define remquof boost_remquof +#ifdef remquol +#undef remquol +#endif +#define remquol boost_remquol + +#ifdef rint +#undef rint +#endif +#define rint boost_rint +#ifdef rintf +#undef rintf +#endif +#define rintf boost_rintf +#ifdef rintl +#undef rintl +#endif +#define rintl boost_rintl +#endif + +#ifdef round +#undef round +#endif +#define round boost_round +#ifdef roundf +#undef roundf +#endif +#define roundf boost_roundf +#ifdef roundl +#undef roundl +#endif +#define roundl boost_roundl + +#if 0 +#ifdef scalbln +#undef scalbln +#endif +#define scalbln boost_scalbln +#ifdef scalblnf +#undef scalblnf +#endif +#define scalblnf boost_scalblnf +#ifdef scalblnl +#undef scalblnl +#endif +#define scalblnl boost_scalblnl + +#ifdef scalbn +#undef scalbn +#endif +#define scalbn boost_scalbn +#ifdef scalbnf +#undef scalbnf +#endif +#define scalbnf boost_scalbnf +#ifdef scalbnl +#undef scalbnl +#endif +#define scalbnl boost_scalbnl +#endif + +#ifdef tgamma +#undef tgamma +#endif +#define tgamma boost_tgamma +#ifdef tgammaf +#undef tgammaf +#endif +#define tgammaf boost_tgammaf +#ifdef tgammal +#undef tgammal +#endif +#define tgammal boost_tgammal + +#ifdef trunc +#undef trunc +#endif +#define trunc boost_trunc +#ifdef truncf +#undef truncf +#endif +#define truncf boost_truncf +#ifdef truncl +#undef truncl +#endif +#define truncl boost_truncl + +// [5.2.1.1] associated Laguerre polynomials: +#ifdef assoc_laguerre +#undef assoc_laguerre +#endif +#define assoc_laguerre boost_assoc_laguerre +#ifdef assoc_laguerref +#undef assoc_laguerref +#endif +#define assoc_laguerref boost_assoc_laguerref +#ifdef assoc_laguerrel +#undef assoc_laguerrel +#endif +#define assoc_laguerrel boost_assoc_laguerrel + +// [5.2.1.2] associated Legendre functions: +#ifdef assoc_legendre +#undef assoc_legendre +#endif +#define assoc_legendre boost_assoc_legendre +#ifdef assoc_legendref +#undef assoc_legendref +#endif +#define assoc_legendref boost_assoc_legendref +#ifdef assoc_legendrel +#undef assoc_legendrel +#endif +#define assoc_legendrel boost_assoc_legendrel + +// [5.2.1.3] beta function: +#ifdef beta +#undef beta +#endif +#define beta boost_beta +#ifdef betaf +#undef betaf +#endif +#define betaf boost_betaf +#ifdef betal +#undef betal +#endif +#define betal boost_betal + +// [5.2.1.4] (complete) elliptic integral of the first kind: +#ifdef comp_ellint_1 +#undef comp_ellint_1 +#endif +#define comp_ellint_1 boost_comp_ellint_1 +#ifdef comp_ellint_1f +#undef comp_ellint_1f +#endif +#define comp_ellint_1f boost_comp_ellint_1f +#ifdef comp_ellint_1l +#undef comp_ellint_1l +#endif +#define comp_ellint_1l boost_comp_ellint_1l + +// [5.2.1.5] (complete) elliptic integral of the second kind: +#ifdef comp_ellint_2 +#undef comp_ellint_2 +#endif +#define comp_ellint_2 boost_comp_ellint_2 +#ifdef comp_ellint_2f +#undef comp_ellint_2f +#endif +#define comp_ellint_2f boost_comp_ellint_2f +#ifdef comp_ellint_2l +#undef comp_ellint_2l +#endif +#define comp_ellint_2l boost_comp_ellint_2l + +// [5.2.1.6] (complete) elliptic integral of the third kind: +#ifdef comp_ellint_3 +#undef comp_ellint_3 +#endif +#define comp_ellint_3 boost_comp_ellint_3 +#ifdef comp_ellint_3f +#undef comp_ellint_3f +#endif +#define comp_ellint_3f boost_comp_ellint_3f +#ifdef comp_ellint_3l +#undef comp_ellint_3l +#endif +#define comp_ellint_3l boost_comp_ellint_3l + +#if 0 +// [5.2.1.7] confluent hypergeometric functions: +#ifdef conf_hyper +#undef conf_hyper +#endif +#define conf_hyper boost_conf_hyper +#ifdef conf_hyperf +#undef conf_hyperf +#endif +#define conf_hyperf boost_conf_hyperf +#ifdef conf_hyperl +#undef conf_hyperl +#endif +#define conf_hyperl boost_conf_hyperl +#endif + +// [5.2.1.8] regular modified cylindrical Bessel functions: +#ifdef cyl_bessel_i +#undef cyl_bessel_i +#endif +#define cyl_bessel_i boost_cyl_bessel_i +#ifdef cyl_bessel_if +#undef cyl_bessel_if +#endif +#define cyl_bessel_if boost_cyl_bessel_if +#ifdef cyl_bessel_il +#undef cyl_bessel_il +#endif +#define cyl_bessel_il boost_cyl_bessel_il + +// [5.2.1.9] cylindrical Bessel functions (of the first kind): +#ifdef cyl_bessel_j +#undef cyl_bessel_j +#endif +#define cyl_bessel_j boost_cyl_bessel_j +#ifdef cyl_bessel_jf +#undef cyl_bessel_jf +#endif +#define cyl_bessel_jf boost_cyl_bessel_jf +#ifdef cyl_bessel_jl +#undef cyl_bessel_jl +#endif +#define cyl_bessel_jl boost_cyl_bessel_jl + +// [5.2.1.10] irregular modified cylindrical Bessel functions: +#ifdef cyl_bessel_k +#undef cyl_bessel_k +#endif +#define cyl_bessel_k boost_cyl_bessel_k +#ifdef cyl_bessel_kf +#undef cyl_bessel_kf +#endif +#define cyl_bessel_kf boost_cyl_bessel_kf +#ifdef cyl_bessel_kl +#undef cyl_bessel_kl +#endif +#define cyl_bessel_kl boost_cyl_bessel_kl + +// [5.2.1.11] cylindrical Neumann functions BOOST_MATH_C99_THROW_SPEC; +// cylindrical Bessel functions (of the second kind): +#ifdef cyl_neumann +#undef cyl_neumann +#endif +#define cyl_neumann boost_cyl_neumann +#ifdef cyl_neumannf +#undef cyl_neumannf +#endif +#define cyl_neumannf boost_cyl_neumannf +#ifdef cyl_neumannl +#undef cyl_neumannl +#endif +#define cyl_neumannl boost_cyl_neumannl + +// [5.2.1.12] (incomplete) elliptic integral of the first kind: +#ifdef ellint_1 +#undef ellint_1 +#endif +#define ellint_1 boost_ellint_1 +#ifdef ellint_1f +#undef ellint_1f +#endif +#define ellint_1f boost_ellint_1f +#ifdef ellint_1l +#undef ellint_1l +#endif +#define ellint_1l boost_ellint_1l + +// [5.2.1.13] (incomplete) elliptic integral of the second kind: +#ifdef ellint_2 +#undef ellint_2 +#endif +#define ellint_2 boost_ellint_2 +#ifdef ellint_2f +#undef ellint_2f +#endif +#define ellint_2f boost_ellint_2f +#ifdef ellint_2l +#undef ellint_2l +#endif +#define ellint_2l boost_ellint_2l + +// [5.2.1.14] (incomplete) elliptic integral of the third kind: +#ifdef ellint_3 +#undef ellint_3 +#endif +#define ellint_3 boost_ellint_3 +#ifdef ellint_3f +#undef ellint_3f +#endif +#define ellint_3f boost_ellint_3f +#ifdef ellint_3l +#undef ellint_3l +#endif +#define ellint_3l boost_ellint_3l + +// [5.2.1.15] exponential integral: +#ifdef expint +#undef expint +#endif +#define expint boost_expint +#ifdef expintf +#undef expintf +#endif +#define expintf boost_expintf +#ifdef expintl +#undef expintl +#endif +#define expintl boost_expintl + +// [5.2.1.16] Hermite polynomials: +#ifdef hermite +#undef hermite +#endif +#define hermite boost_hermite +#ifdef hermitef +#undef hermitef +#endif +#define hermitef boost_hermitef +#ifdef hermitel +#undef hermitel +#endif +#define hermitel boost_hermitel + +#if 0 +// [5.2.1.17] hypergeometric functions: +#ifdef hyperg +#undef hyperg +#endif +#define hyperg boost_hyperg +#ifdef hypergf +#undef hypergf +#endif +#define hypergf boost_hypergf +#ifdef hypergl +#undef hypergl +#endif +#define hypergl boost_hypergl +#endif + +// [5.2.1.18] Laguerre polynomials: +#ifdef laguerre +#undef laguerre +#endif +#define laguerre boost_laguerre +#ifdef laguerref +#undef laguerref +#endif +#define laguerref boost_laguerref +#ifdef laguerrel +#undef laguerrel +#endif +#define laguerrel boost_laguerrel + +// [5.2.1.19] Legendre polynomials: +#ifdef legendre +#undef legendre +#endif +#define legendre boost_legendre +#ifdef legendref +#undef legendref +#endif +#define legendref boost_legendref +#ifdef legendrel +#undef legendrel +#endif +#define legendrel boost_legendrel + +// [5.2.1.20] Riemann zeta function: +#ifdef riemann_zeta +#undef riemann_zeta +#endif +#define riemann_zeta boost_riemann_zeta +#ifdef riemann_zetaf +#undef riemann_zetaf +#endif +#define riemann_zetaf boost_riemann_zetaf +#ifdef riemann_zetal +#undef riemann_zetal +#endif +#define riemann_zetal boost_riemann_zetal + +// [5.2.1.21] spherical Bessel functions (of the first kind): +#ifdef sph_bessel +#undef sph_bessel +#endif +#define sph_bessel boost_sph_bessel +#ifdef sph_besself +#undef sph_besself +#endif +#define sph_besself boost_sph_besself +#ifdef sph_bessell +#undef sph_bessell +#endif +#define sph_bessell boost_sph_bessell + +// [5.2.1.22] spherical associated Legendre functions: +#ifdef sph_legendre +#undef sph_legendre +#endif +#define sph_legendre boost_sph_legendre +#ifdef sph_legendref +#undef sph_legendref +#endif +#define sph_legendref boost_sph_legendref +#ifdef sph_legendrel +#undef sph_legendrel +#endif +#define sph_legendrel boost_sph_legendrel + +// [5.2.1.23] spherical Neumann functions BOOST_MATH_C99_THROW_SPEC; +// spherical Bessel functions (of the second kind): +#ifdef sph_neumann +#undef sph_neumann +#endif +#define sph_neumann boost_sph_neumann +#ifdef sph_neumannf +#undef sph_neumannf +#endif +#define sph_neumannf boost_sph_neumannf +#ifdef sph_neumannl +#undef sph_neumannl +#endif +#define sph_neumannl boost_sph_neumannl + +#endif // BOOST_MATH_C_MACROS_IPP \ No newline at end of file diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 2f366b28c..0ce242550 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -15,6 +15,7 @@ import pch ; local ntl-path = [ modules.peek : NTL_PATH ] ; local gmp_path = [ modules.peek : GMP_PATH ] ; +local e_float_path = [ modules.peek : E_FLOAT_PATH ] ; project : requirements @@ -52,6 +53,7 @@ project BOOST_UBLAS_UNSUPPORTED_COMPILER=0 . $(ntl-path)/include + $(e_float_path) $(gmp_path) $(gmp_path)/mpfr $(gmp_path)/gmpfrxx $(gmp_path)/mpfrc++ ; @@ -785,12 +787,20 @@ run ../quaternion/quaternion_mult_incl_test.cpp ../quaternion/quaternion_mi1.cpp ../quaternion/quaternion_mi2.cpp ../../test/build//boost_unit_test_framework/static ; - + + +run test_legacy_nonfinite.cpp ../../test/build//boost_test_exec_monitor ; +run test_basic_nonfinite.cpp ../../test/build//boost_test_exec_monitor ; +run test_lexical_cast.cpp ../../test/build//boost_test_exec_monitor ; +run test_nonfinite_trap.cpp ../../test/build//boost_test_exec_monitor ; +run test_signed_zero.cpp ../../test/build//boost_test_exec_monitor ; + run complex_test.cpp ../../test/build//boost_test_exec_monitor ; compile ntl_concept_check.cpp : [ check-target-builds ../config//has_ntl_rr : : no ] ; compile mpfr_concept_check.cpp : [ check-target-builds ../config//has_mpfr_class : : no ] ; compile mpreal_concept_check.cpp : [ check-target-builds ../config//has_mpreal : : no ] ; +compile e_float_concept_check.cpp : [ check-target-builds ../config//has_e_float : : no ] ; compile test_common_factor_gmpxx.cpp : [ check-target-builds ../config//has_gmpxx : : no ] ; build-project ../example ; diff --git a/test/almost_equal.ipp b/test/almost_equal.ipp new file mode 100644 index 000000000..107ee65e5 --- /dev/null +++ b/test/almost_equal.ipp @@ -0,0 +1,20 @@ +#ifndef BOOST_MATH_ALMOST_EQUAL_HPP +#define BOOST_MATH_ALMOST_EQUAL_HPP + +// Copyright (c) 2006 Johan Rade + +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include + +template +bool almost_equal(ValType a, ValType b) +{ + const ValType e = static_cast(0.00001); + return (a - e * std::abs(a) <= b + e * std::abs(b)) + && (a + e * std::abs(a) >= b - e * std::abs(b)); +} + +#endif diff --git a/test/compile_test/instantiate.hpp b/test/compile_test/instantiate.hpp index 53db8e7cf..d6c1dfb3a 100644 --- a/test/compile_test/instantiate.hpp +++ b/test/compile_test/instantiate.hpp @@ -179,6 +179,10 @@ void instantiate(RealType) (boost::math::isnormal)(v1); (boost::math::isnan)(v1); (boost::math::isinf)(v1); + (boost::math::signbit)(v1); + (boost::math::copysign)(v1, v2); + (boost::math::changesign)(v1); + (boost::math::sign)(v1); boost::math::log1p(v1); boost::math::expm1(v1); boost::math::cbrt(v1); @@ -298,11 +302,6 @@ void instantiate(RealType) boost::math::ibetac_invb(v1, v2, v3, pol); boost::math::gamma_p_derivative(v2, v3, pol); boost::math::ibeta_derivative(v1, v2, v3, pol); - (boost::math::fpclassify)(v1); - (boost::math::isfinite)(v1); - (boost::math::isnormal)(v1); - (boost::math::isnan)(v1); - (boost::math::isinf)(v1); boost::math::log1p(v1, pol); boost::math::expm1(v1, pol); boost::math::cbrt(v1, pol); @@ -428,6 +427,10 @@ void instantiate(RealType) (test::isnormal)(v1); (test::isnan)(v1); (test::isinf)(v1); + (test::signbit)(v1); + (test::copysign)(v1, v2); + (test::changesign)(v1); + (test::sign)(v1); test::log1p(v1); test::expm1(v1); test::cbrt(v1); diff --git a/test/e_float_concept_check.cpp b/test/e_float_concept_check.cpp new file mode 100644 index 000000000..74149fbc8 --- /dev/null +++ b/test/e_float_concept_check.cpp @@ -0,0 +1,40 @@ + +// Copyright John Maddock 2011. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// +// This tests two things: that e_float meets our +// conceptual requirements, and that we can instantiate +// all our distributions and special functions on this type. +// +#define BOOST_MATH_ASSERT_UNDEFINED_POLICY false +#define TEST_MPFR + +#ifdef _MSC_VER +# pragma warning(disable:4800) +# pragma warning(disable:4512) +# pragma warning(disable:4127) +# pragma warning(disable:4512) +# pragma warning(disable:4503) // decorated name length exceeded, name was truncated +#endif + +#define E_FLOAT_TYPE_EFX + +#include + +#include +#include "compile_test/instantiate.hpp" + +void foo() +{ + instantiate(boost::math::ef::e_float()); +} + +int main() +{ + BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept)); +} + + diff --git a/test/s_.ipp b/test/s_.ipp new file mode 100644 index 000000000..6df30043f --- /dev/null +++ b/test/s_.ipp @@ -0,0 +1,64 @@ +#ifndef BOOST_MATH_S__HPP +#define BOOST_MATH_S__HPP + +// Copyright (c) 2006 Johan Rade + +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +// The macro S_ lets you write +// +// basic_string s = S_("foo"); +// CharType c = S_('a'); +// +// provided that CharType is char or wchar_t + +#include + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable : 4512) +#endif + +//------------------------------------------------------------------------------ + +#define S_(a) make_literal_helper(a, L##a) + +class char_literal_helper { +public: + char_literal_helper(char c, wchar_t wc) : c_(c), wc_(wc) {} + operator char() { return c_; } + operator wchar_t() { return wc_; } +private: + const char c_; + const wchar_t wc_; +}; + +class string_literal_helper { +public: + string_literal_helper(const char* s, const wchar_t* ws) : s_(s), ws_(ws) {} + operator std::string() { return s_; } + operator std::wstring() { return ws_; } +private: + const char* s_; + const wchar_t* ws_; +}; + +inline char_literal_helper make_literal_helper(char c, wchar_t wc) +{ + return char_literal_helper(c, wc); +} + +inline string_literal_helper make_literal_helper(const char* s, const wchar_t* ws) +{ + return string_literal_helper(s, ws); +} + +//------------------------------------------------------------------------------ + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif diff --git a/test/test_archive.cpp b/test/test_archive.cpp new file mode 100644 index 000000000..5a04dcc8f --- /dev/null +++ b/test/test_archive.cpp @@ -0,0 +1,239 @@ +// Copyright (c) 2006 Johan Rade +// Copyright (c) 2011 Paul A. Bristow - filename changes for boost-trunk. + +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +//#ifdef _MSC_VER +//# pragma warning(disable : 4511 4512 4702) +//#endif + +#define BOOST_TEST_MAIN + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "almost_equal.ipp" + +namespace { + +// The anonymous namespace resolves ambiguities on platforms +// with fpclassify etc functions at global scope. + +using namespace boost::archive; + +using namespace boost::math; +using boost::math::signbit; +using boost::math::changesign; +using boost::math::isnan; + +//------------------------------------------------------------------------------ + +void archive_basic_test(); +void archive_put_trap_test(); +void archive_get_trap_test(); + +BOOST_AUTO_TEST_CASE(archive_test) +{ + archive_basic_test(); + archive_put_trap_test(); + archive_get_trap_test(); +} + +//------------------------------------------------------------------------------ + +template +void archive_basic_test_impl(); + +void archive_basic_test() +{ + archive_basic_test_impl(); + archive_basic_test_impl(); + archive_basic_test_impl< + char, text_oarchive, text_iarchive, long double>(); + archive_basic_test_impl< + wchar_t, text_woarchive, text_wiarchive, float>(); + archive_basic_test_impl< + wchar_t, text_woarchive, text_wiarchive, double>(); + archive_basic_test_impl< + wchar_t, text_woarchive, text_wiarchive, long double>(); +} + +template +void archive_basic_test_impl() +{ + if((std::numeric_limits::has_infinity == 0) || (std::numeric_limits::infinity() == 0)) + return; + std::locale default_locale(std::locale::classic(), + new boost::archive::codecvt_null); + std::locale tmp_locale(default_locale, new nonfinite_num_put); + std::locale my_locale(tmp_locale, new nonfinite_num_get); + + std::basic_stringstream ss; + ss.imbue(my_locale); + + ValType a1 = static_cast(0); + ValType a2 = static_cast(2307.35); + ValType a3 = std::numeric_limits::infinity(); + BOOST_CHECK((boost::math::isinf)(a3)); + ValType a4 = std::numeric_limits::quiet_NaN(); + BOOST_CHECK((boost::math::isnan)(a4)); + ValType a5 = std::numeric_limits::signaling_NaN(); + BOOST_CHECK((boost::math::isnan)(a5)); + ValType a6 = (changesign)(static_cast(0)); + ValType a7 = static_cast(-57.13); + ValType a8 = -std::numeric_limits::infinity(); + BOOST_CHECK((boost::math::isinf)(a8)); + ValType a9 = -std::numeric_limits::quiet_NaN(); + BOOST_CHECK((boost::math::isnan)(a9)); + ValType a10 = -std::numeric_limits::signaling_NaN(); + BOOST_CHECK((boost::math::isnan)(a10)); + + { + OArchiveType oa(ss, no_codecvt); + oa & a1 & a2 & a3 & a4 & a5 & a6 & a7 & a8 & a9 & a10; + } + + ValType b1, b2, b3, b4, b5, b6, b7, b8, b9, b10; + + { + IArchiveType ia(ss, no_codecvt); + ia & b1 & b2 & b3 & b4 & b5 & b6 & b7 & b8 & b9 & b10; + } + + BOOST_CHECK(a1 == b1); + BOOST_CHECK(almost_equal(a2, b2)); + BOOST_CHECK(a3 == b3); + BOOST_CHECK((isnan)(b4)); + BOOST_CHECK(!(signbit)(b4)); + BOOST_CHECK((isnan)(b5)); + BOOST_CHECK(!(signbit)(b5)); + BOOST_CHECK(a6 == b6); + BOOST_CHECK(almost_equal(a7, b7)); + BOOST_CHECK(a8 == b8); + BOOST_CHECK((isnan)(b9)); + BOOST_CHECK((signbit)(b9)); + BOOST_CHECK((isnan)(b10)); + BOOST_CHECK((signbit)(b10)); +} + +//------------------------------------------------------------------------------ + +template +void archive_put_trap_test_impl(); + +void archive_put_trap_test() +{ + archive_put_trap_test_impl(); + archive_put_trap_test_impl(); + archive_put_trap_test_impl< + char, text_oarchive, text_iarchive, long double>(); + archive_put_trap_test_impl< + wchar_t, text_woarchive, text_wiarchive, float>(); + archive_put_trap_test_impl< + wchar_t, text_woarchive, text_wiarchive, double>(); + archive_put_trap_test_impl< + wchar_t, text_woarchive, text_wiarchive, long double>(); +} + +template +void archive_put_trap_test_impl() +{ + if((std::numeric_limits::has_infinity == 0) || (std::numeric_limits::infinity() == 0)) + return; + + std::locale default_locale(std::locale::classic(), + new boost::archive::codecvt_null); + std::locale new_locale(default_locale, + new nonfinite_num_put(trap_infinity)); + + std::basic_stringstream ss; + ss.exceptions(std::ios_base::failbit | std::ios_base::badbit); + ss.imbue(new_locale); + + ValType a = std::numeric_limits::infinity(); + + OArchiveType oa(ss, no_codecvt); + + try { + oa & a; + } + catch(std::exception&) { + ss.clear(); + return; + } + + BOOST_CHECK(false); +} + +//------------------------------------------------------------------------------ + +template +void archive_get_trap_test_impl(); + +void archive_get_trap_test() +{ + archive_get_trap_test_impl(); + archive_get_trap_test_impl(); + archive_get_trap_test_impl< + char, text_oarchive, text_iarchive, long double>(); + archive_get_trap_test_impl< + wchar_t, text_woarchive, text_wiarchive, float>(); + archive_get_trap_test_impl< + wchar_t, text_woarchive, text_wiarchive, double>(); + archive_get_trap_test_impl< + wchar_t, text_woarchive, text_wiarchive, long double>(); +} + +template +void archive_get_trap_test_impl() +{ + if((std::numeric_limits::has_infinity == 0) || (std::numeric_limits::infinity() == 0)) + return; + + std::locale default_locale(std::locale::classic(), + new boost::archive::codecvt_null); + std::locale tmp_locale(default_locale, new nonfinite_num_put); + std::locale my_locale(tmp_locale, + new nonfinite_num_get(trap_nan)); + + std::basic_stringstream ss; + ss.exceptions(std::ios_base::failbit); + ss.imbue(my_locale); + + ValType a = -std::numeric_limits::quiet_NaN(); + + { + OArchiveType oa(ss, no_codecvt); + oa & a; + } + + ValType b; + { + IArchiveType ia(ss, no_codecvt); + try { + ia & b; + } + catch(std::exception&) { + return; + } + } + + BOOST_CHECK(false); +} + +//------------------------------------------------------------------------------ + +} // anonymous namespace diff --git a/test/test_basic_nonfinite.cpp b/test/test_basic_nonfinite.cpp new file mode 100644 index 000000000..1b8fc518b --- /dev/null +++ b/test/test_basic_nonfinite.cpp @@ -0,0 +1,272 @@ +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +// Copyright (c) 2006 Johan Rade +// Copyright (c) 2011 Paul A. Bristow comments +// Copyright (c) 2011 John Maddock +/*! +\file +\brief Basic tests of the nonfinite num facets. + +\detail If has_infinity and has_nan, then +basic_test outputs using nonfinite_num_put facet +and reads back in using nonfinite_num_ facet, +and checks loopback OK. + +Also checks that output of infinity, -infinity and NaN are as expected, +using C99 specification "nan -nan nan -nan" and "inf -inf". +Also includes a few combinations of display manipulators +(left, right, internal, showpos) +and checks that can input C99 infinity and NaN too. + +*/ + +#ifdef _MSC_VER +# pragma warning(disable : 4702) // Unreachable code. +#endif + +#include +#include +#include + +#define BOOST_TEST_MAIN + +#include + +#include "almost_equal.ipp" +#include "S_.ipp" + +#include + +namespace +{ // The anonymous namespace resolves ambiguities on + // platforms with fpclassify etc functions at global scope. + +using namespace boost::math; +using boost::math::signbit; +using boost::math::changesign; +using boost::math::isnan; + +//------------------------------------------------------------------------------ + +void basic_test_finite(); +void basic_test_inf(); +void basic_test_nan(); +void basic_test_format(); + +BOOST_AUTO_TEST_CASE(basic_test) +{ + basic_test_finite(); + basic_test_inf(); + basic_test_nan(); + basic_test_format(); +} + +//------------------------------------------------------------------------------ + +template void basic_test_finite_impl(); + +void basic_test_finite() +{ + basic_test_finite_impl(); + basic_test_finite_impl(); + basic_test_finite_impl(); + basic_test_finite_impl(); + basic_test_finite_impl(); + basic_test_finite_impl(); +} + +template void basic_test_finite_impl() +{ + if((std::numeric_limits::has_infinity == 0) || (std::numeric_limits::infinity() == 0)) + return; + + std::locale old_locale; + std::locale tmp_locale(old_locale, new nonfinite_num_put); + std::locale new_locale(tmp_locale, new nonfinite_num_get); + + std::basic_stringstream ss; + ss.imbue(new_locale); + + ValType a1 = (ValType)1.2; + ValType a2 = (ValType)-3.5; + ValType a3 = (std::numeric_limits::max)(); + ValType a4 = -(std::numeric_limits::max)(); + ss << a1 << ' ' << a2 << ' ' << a3 << ' ' << a4; + + ValType b1, b2, b3, b4; + ss >> b1 >> b2 >> b3 >> b4; + + BOOST_CHECK(almost_equal(b1, a1)); + BOOST_CHECK(almost_equal(b2, a2)); + BOOST_CHECK(almost_equal(b3, a3)); + BOOST_CHECK(almost_equal(b4, a4)); + BOOST_CHECK(b3 != std::numeric_limits::infinity()); + BOOST_CHECK(b4 != -std::numeric_limits::infinity()); + BOOST_CHECK(ss.rdstate() == std::ios_base::eofbit); + + ss.clear(); + ss.str(S_("")); + + ss << "++5"; + ValType b5; + ss >> b5; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit); +} + +//------------------------------------------------------------------------------ + +template void basic_test_inf_impl(); + +void basic_test_inf() +{ + basic_test_inf_impl(); + basic_test_inf_impl(); + basic_test_inf_impl(); + basic_test_inf_impl(); + basic_test_inf_impl(); + basic_test_inf_impl(); +} + +template void basic_test_inf_impl() +{ + if((std::numeric_limits::has_infinity == 0) || (std::numeric_limits::infinity() == 0)) + return; + + std::locale old_locale; + std::locale tmp_locale(old_locale, new nonfinite_num_put); + std::locale new_locale(tmp_locale, new nonfinite_num_get); + + std::basic_stringstream ss; + ss.imbue(new_locale); + + ValType a1 = std::numeric_limits::infinity(); + ValType a2 = -std::numeric_limits::infinity(); + + BOOST_CHECK((boost::math::isinf)(a1)); + BOOST_CHECK((boost::math::isinf)(a2)); + + ss << a1 << ' ' << a2; + + std::basic_string s = S_("inf -inf"); + BOOST_CHECK(ss.str() == s); + + ss << " infinity"; // Alternative C99 representation of infinity. + + ValType b1, b2, b3; + ss >> b1; + ss >> b2; + ss >> b3; + + BOOST_CHECK(b1 == a1); + BOOST_CHECK(b2 == a2); + BOOST_CHECK(b3 == std::numeric_limits::infinity()); + BOOST_CHECK(ss.rdstate() == std::ios_base::eofbit); +} + +//------------------------------------------------------------------------------ + +template void basic_test_nan_impl(); + +void basic_test_nan() +{ + basic_test_nan_impl(); + basic_test_nan_impl(); + basic_test_nan_impl(); + basic_test_nan_impl(); + basic_test_nan_impl(); + basic_test_nan_impl(); +} + +template void basic_test_nan_impl() +{ + if((std::numeric_limits::has_quiet_NaN == 0) || (std::numeric_limits::quiet_NaN() == 0)) + return; + + std::locale old_locale; + std::locale tmp_locale(old_locale, new nonfinite_num_put); + std::locale new_locale(tmp_locale, new nonfinite_num_get); + + std::basic_stringstream ss; + ss.imbue(new_locale); + + ValType a1 = std::numeric_limits::quiet_NaN(); + ValType a2 = (boost::math::changesign)(std::numeric_limits::quiet_NaN()); + ValType a3 = std::numeric_limits::signaling_NaN(); + ValType a4 = (boost::math::changesign)(std::numeric_limits::signaling_NaN()); + ss << a1 << ' ' << a2 << ' ' << a3 << ' ' << a4; + + BOOST_CHECK((boost::math::isnan)(a1) && (boost::math::isnan)(a2) && (boost::math::isnan)(a3) && (boost::math::isnan)(a4)); + + std::basic_string s = S_("nan -nan nan -nan"); + BOOST_CHECK(ss.str() == s); + + // Alternative C99 representation of NaN. + ss << " nan(foo)"; + + ValType b1, b2, b3, b4, b5; + ss >> b1 >> b2 >> b3 >> b4 >> b5; + + BOOST_CHECK((isnan)(b1)); + BOOST_CHECK((isnan)(b2)); + BOOST_CHECK((isnan)(b3)); + BOOST_CHECK((isnan)(b4)); + BOOST_CHECK((isnan)(b5)); + + BOOST_CHECK(!(signbit)(b1)); + BOOST_CHECK((signbit)(b2)); + BOOST_CHECK(!(signbit)(b3)); + BOOST_CHECK((signbit)(b4)); + BOOST_CHECK(!(signbit)(b5)); + + BOOST_CHECK(ss.rdstate() == std::ios_base::eofbit); +} + +//------------------------------------------------------------------------------ + +template void basic_test_format_impl(); + +void basic_test_format() +{ + basic_test_format_impl(); + basic_test_format_impl(); + basic_test_format_impl(); + basic_test_format_impl(); + basic_test_format_impl(); + basic_test_format_impl(); +} + +template void basic_test_format_impl() +{ + if((std::numeric_limits::has_infinity == 0) || (std::numeric_limits::infinity() == 0)) + return; + + std::locale old_locale; + std::locale tmp_locale(old_locale, new nonfinite_num_put); + std::locale new_locale(tmp_locale, new nonfinite_num_get); + + std::basic_stringstream ss; + ss.imbue(new_locale); + + ValType a = std::numeric_limits::infinity(); + + BOOST_CHECK((boost::math::isinf)(a)); + + ss << std::setw(6) << a; // Expect right justified in field of six, so 3 leading spaces. + ss << '|'; + ss << std::setw(2) << a; // Too narrow for "inf", but should still be "inf". + ss << '|'; + ss << std::left << std::setw(5) << a; // 5 - 3 leaves two trailing spaces. + ss << '|'; + ss << std::showpos << std::internal << std::setw(7) << a; // 3 internal spaces between + and "inf". + ss << '|'; + ss << std::uppercase << std::right << std::setw(6) << a; // still showpos, so "space, space, +INF". + + std::basic_string s = S_(" inf|inf|inf |+ inf| +INF"); + BOOST_CHECK(ss.str() == s); +} + +//------------------------------------------------------------------------------ + +} // anonymous namespace diff --git a/test/test_legacy_nonfinite.cpp b/test/test_legacy_nonfinite.cpp new file mode 100644 index 000000000..4ebf8c99e --- /dev/null +++ b/test/test_legacy_nonfinite.cpp @@ -0,0 +1,185 @@ +// Copyright (c) 2006 Johan Rade +// Copyright (c) 2011 Paul A. Bristow comments +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +/*! +\file +\brief Legacy (non-C99) tests of the nonfinite num facets. + +\detail legacy_test outputs using nonfinite_num_put facet +with legacy flag, and reads back in using nonfinite_num_ facet, +and checks loopback OK. + +Also checks that output of infinity, -infinity and NaN are as expected, +including the 'legacy' "1.#IND", "1.#QNAN", "1.#SNAN" representations +(was used by MSVC but now all represented on output by "1.#QNAN") +and qnan snan nanq nans (used by other systems) +excluding C99 specification "nan -nan nan -nan" and "inf -inf". +*/ + +#ifdef _MSC_VER +# pragma warning(disable : 4702) +#endif + +#include +#include +#include + +#define BOOST_TEST_MAIN +#include + +//#include "almost_equal.hpp" +//#include "S_.hpp" + +#include + +namespace { + +// The anonymous namespace resolves ambiguities on platforms +// with fpclassify etc functions declared at global scope. + +using namespace boost::math; +using boost::math::signbit; +using boost::math::changesign; +using boost::math::isnan; + +//------------------------------------------------------------------------------ + +void legacy_test_inf(); +void legacy_test_nan(); + +BOOST_AUTO_TEST_CASE(legacy_test) +{ + legacy_test_inf(); + legacy_test_nan(); +} + +//------------------------------------------------------------------------------ + +template void legacy_test_inf_impl(); + +void legacy_test_inf() +{ + legacy_test_inf_impl(); + legacy_test_inf_impl(); + legacy_test_inf_impl(); + legacy_test_inf_impl(); + legacy_test_inf_impl(); + legacy_test_inf_impl(); +} + +template void legacy_test_inf_impl() +{ + std::locale old_locale; + std::locale new_locale(old_locale, new nonfinite_num_get(legacy)); + + std::basic_stringstream ss; + ss.imbue(new_locale); + + ValType a1 = std::numeric_limits::infinity(); + ValType a2 = -std::numeric_limits::infinity(); + ss << a1 << ' ' << a2; + + ss << " 1.#INF"; + + ValType b1, b2, b3; + ss >> b1 >> b2 >> b3; + + BOOST_CHECK(b1 == a1); + BOOST_CHECK(b2 == a2); + BOOST_CHECK(b3 == std::numeric_limits::infinity()); + BOOST_CHECK(ss.rdstate() == std::ios_base::eofbit); +} + +//------------------------------------------------------------------------------ + +template void legacy_test_nan_impl(); + +void legacy_test_nan() +{ + legacy_test_nan_impl(); + legacy_test_nan_impl(); + legacy_test_nan_impl(); + legacy_test_nan_impl(); + legacy_test_nan_impl(); + legacy_test_nan_impl(); +} + +template void legacy_test_nan_impl() +{ + std::locale old_locale; + std::locale new_locale(old_locale, new nonfinite_num_get(legacy)); + + std::basic_stringstream ss; + ss.imbue(new_locale); + + ValType a1 = std::numeric_limits::quiet_NaN(); + ValType a2 = -std::numeric_limits::quiet_NaN(); + ValType a3 = std::numeric_limits::signaling_NaN(); + ValType a4 = -std::numeric_limits::signaling_NaN(); + ss << a1 << ' ' << a2 << ' ' << a3 << ' ' << a4; + + ss << " qnan snan nanq nans 1.#IND 1.#QNAN 1.#SNAN"; + + ValType b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11; + ss >> b1 >> b2 >> b3 >> b4 >> b5 >> b6 >> b7 >> b8 >> b9 >> b10 >> b11; + + // std::cout << b11 << std::endl; // Confirms that legacy + // IND, SNAN and QNAN are considered the same, + // and both output the legacy string "1.#QNAN". + + BOOST_CHECK((isnan)(b1)); + BOOST_CHECK((isnan)(b2)); + BOOST_CHECK((isnan)(b3)); + BOOST_CHECK((isnan)(b4)); + BOOST_CHECK((isnan)(b5)); + BOOST_CHECK((isnan)(b6)); + BOOST_CHECK((isnan)(b7)); + BOOST_CHECK((isnan)(b8)); + BOOST_CHECK((isnan)(b9)); + BOOST_CHECK((isnan)(b10)); + BOOST_CHECK((isnan)(b11)); // Johan V3 1.#SNAN failed on MSVC 10. + // Change in nonfinite_num_facet.hpp Paul A. Bristow 11 Apr 11 makes work OK. +/* + // These tests fail on platforms, such as gcc, + // that use the same representation of +nan and -nan. + + BOOST_CHECK(!(signbit)(b1)); + BOOST_CHECK((signbit)(b2)); + BOOST_CHECK(!(signbit)(b3)); + BOOST_CHECK((signbit)(b4)); +*/ + BOOST_CHECK(!(signbit)(b5)); + BOOST_CHECK(!(signbit)(b6)); + BOOST_CHECK(!(signbit)(b7)); + BOOST_CHECK(!(signbit)(b8)); + BOOST_CHECK(!(signbit)(b9)); + BOOST_CHECK(!(signbit)(b10)); + BOOST_CHECK(!(signbit)(b11)); // Johan V3 1.#SNAN failed MSVC 10. + + BOOST_CHECK(ss.rdstate() == std::ios_base::eofbit); // Fails if SNAN test fails. +} + +//------------------------------------------------------------------------------ + +} // anonymous namespace + +/* + +Output: + + legacy_test.vcxproj -> J:\Cpp\fp_facet\fp_facet\Debug\legacy_test.exe + Running 1 test case... + 1.#QNAN + 1.#QNAN + 1.#QNAN + 1.#QNAN + 1.#QNAN + 1.#QNAN + + *** No errors detected + + +*/ diff --git a/test/test_lexical_cast.cpp b/test/test_lexical_cast.cpp new file mode 100644 index 000000000..36807511d --- /dev/null +++ b/test/test_lexical_cast.cpp @@ -0,0 +1,122 @@ + +// Copyright (c) 2006 Johan Rade + +// Copyright (c) 2011 Paul A. Bristow incorporated Boost.Math + +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +//#ifdef _MSC_VER +//# pragma warning(disable : 4127 4511 4512 4701 4702) +//#endif + +#define BOOST_TEST_MAIN + +#include +#include +#include +#include +#include + +#include +#include +#include +#include "almost_equal.ipp" +#include "S_.ipp" + +namespace { + +// the anonymous namespace resolves ambiguities on platforms +// with fpclassify etc functions at global scope + +using boost::lexical_cast; + +using namespace boost::math; +using boost::math::signbit; +using boost::math::changesign; +using boost::math::isnan; + +//------------------------------------------------------------------------------ + +template void lexical_cast_test_impl(); + +BOOST_AUTO_TEST_CASE(lexical_cast_test) +{ + lexical_cast_test_impl(); + lexical_cast_test_impl(); + lexical_cast_test_impl(); + lexical_cast_test_impl(); + lexical_cast_test_impl(); + lexical_cast_test_impl(); +} + +template void lexical_cast_test_impl() +{ + if((std::numeric_limits::has_infinity == 0) || (std::numeric_limits::infinity() == 0)) + return; + if((std::numeric_limits::has_quiet_NaN == 0) || (std::numeric_limits::quiet_NaN() == 0)) + return; + + std::locale old_locale; + std::locale tmp_locale(old_locale, + new nonfinite_num_put(signed_zero)); + std::locale new_locale(tmp_locale, new nonfinite_num_get); + std::locale::global(new_locale); + + ValType a1 = static_cast(0); + ValType a2 = static_cast(13); + ValType a3 = std::numeric_limits::infinity(); + ValType a4 = std::numeric_limits::quiet_NaN(); + ValType a5 = std::numeric_limits::signaling_NaN(); + ValType a6 = (changesign)(static_cast(0)); + ValType a7 = static_cast(-57); + ValType a8 = -std::numeric_limits::infinity(); + ValType a9 = (changesign)(std::numeric_limits::quiet_NaN()); + ValType a10 = (changesign)(std::numeric_limits::signaling_NaN()); + + std::basic_string s1 = S_("0"); + std::basic_string s2 = S_("13"); + std::basic_string s3 = S_("inf"); + std::basic_string s4 = S_("nan"); + std::basic_string s5 = S_("nan"); + std::basic_string s6 = S_("-0"); + std::basic_string s7 = S_("-57"); + std::basic_string s8 = S_("-inf"); + std::basic_string s9 = S_("-nan"); + std::basic_string s10 = S_("-nan"); + + BOOST_CHECK(lexical_cast >(a1) == s1); + BOOST_CHECK(lexical_cast >(a2) == s2); + BOOST_CHECK(lexical_cast >(a3) == s3); + BOOST_CHECK(lexical_cast >(a4) == s4); + BOOST_CHECK(lexical_cast >(a5) == s5); + BOOST_CHECK(lexical_cast >(a6) == s6); + BOOST_CHECK(lexical_cast >(a7) == s7); + BOOST_CHECK(lexical_cast >(a8) == s8); + BOOST_CHECK(lexical_cast >(a9) == s9); + BOOST_CHECK(lexical_cast >(a10) == s10); + + BOOST_CHECK(lexical_cast(s1) == a1); + BOOST_CHECK(!(signbit)(lexical_cast(s1))); + BOOST_CHECK(lexical_cast(s2) == a2); + BOOST_CHECK(lexical_cast(s3) == a3); + BOOST_CHECK((isnan)(lexical_cast(s4))); + BOOST_CHECK(!(signbit)(lexical_cast(s4))); + BOOST_CHECK((isnan)(lexical_cast(s5))); + BOOST_CHECK(!(signbit)(lexical_cast(s5))); + BOOST_CHECK(lexical_cast(a6) == a6); + BOOST_CHECK((signbit)(lexical_cast(s6))); + BOOST_CHECK(lexical_cast(s7) == a7); + BOOST_CHECK(lexical_cast(s8) == a8); + BOOST_CHECK((isnan)(lexical_cast(s9))); + BOOST_CHECK((signbit)(lexical_cast(s9))); + BOOST_CHECK((isnan)(lexical_cast(s10))); + BOOST_CHECK((signbit)(lexical_cast(s10))); + + std::locale::global(old_locale); +} + +//------------------------------------------------------------------------------ + +} // anonymous namespace diff --git a/test/test_nonfinite_trap.cpp b/test/test_nonfinite_trap.cpp new file mode 100644 index 000000000..628ae9e91 --- /dev/null +++ b/test/test_nonfinite_trap.cpp @@ -0,0 +1,235 @@ +// Copyright (c) 2006 Johan Rade +// Copyright (c) 2011 Paul A. Bristow To incorporate into Boost.Math + +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifdef _MSC_VER +# pragma warning(disable : 4702) +#endif + +#define BOOST_TEST_MAIN + +#include +#include +#include +#include "almost_equal.ipp" +#include "S_.ipp" +#include + +namespace { + +// the anonymous namespace resolves ambiguities on platforms +// with fpclassify etc functions at global scope + +using namespace boost::math; +using boost::math::signbit; +using boost::math::changesign; +using boost::math::isnan; + +//------------------------------------------------------------------------------ + +void trap_test_finite(); +void trap_test_inf(); +void trap_test_nan(); + +BOOST_AUTO_TEST_CASE(trap_test) +{ + trap_test_finite(); + trap_test_inf(); + trap_test_nan(); +} + +//------------------------------------------------------------------------------ + +template void trap_test_finite_impl(); + +void trap_test_finite() +{ + trap_test_finite_impl(); + trap_test_finite_impl(); + trap_test_finite_impl(); + trap_test_finite_impl(); + trap_test_finite_impl(); + trap_test_finite_impl(); +} + +template void trap_test_finite_impl() +{ + std::locale old_locale; + std::locale tmp_locale(old_locale, + new nonfinite_num_put(trap_infinity | trap_nan)); + std::locale new_locale(tmp_locale, + new nonfinite_num_get(trap_infinity | trap_nan)); + + std::basic_stringstream ss; + ss.imbue(new_locale); + + ValType a1 = (ValType)1.2; + ValType a2 = (ValType)-3.5; + ValType a3 = (std::numeric_limits::max)(); + ValType a4 = -(std::numeric_limits::max)(); + ss << a1 << ' ' << a2 << ' ' << a3 << ' ' << a4; + + ValType b1, b2, b3, b4; + ss >> b1 >> b2 >> b3 >> b4; + + BOOST_CHECK(almost_equal(b1, a1)); + BOOST_CHECK(almost_equal(b2, a2)); + BOOST_CHECK(almost_equal(b3, a3)); + BOOST_CHECK(almost_equal(b4, a4)); + BOOST_CHECK(b3 != std::numeric_limits::infinity()); + BOOST_CHECK(b4 != -std::numeric_limits::infinity()); + BOOST_CHECK(ss.rdstate() == std::ios_base::eofbit); + + ss.clear(); + ss.str(S_("")); + + ss << "++5"; + ValType b5; + ss >> b5; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit); +} + +//------------------------------------------------------------------------------ + +template void trap_test_inf_impl(); +template void trap_test_put_inf_impl(); +template void trap_test_get_inf_impl(); + +void trap_test_inf() +{ + trap_test_inf_impl(); + trap_test_inf_impl(); + trap_test_inf_impl(); + trap_test_inf_impl(); + trap_test_inf_impl(); + trap_test_inf_impl(); +} + +template void trap_test_inf_impl() +{ + trap_test_put_inf_impl(); + trap_test_get_inf_impl(); +} + +template void trap_test_put_inf_impl() +{ + std::locale old_locale; + std::locale new_locale(old_locale, + new nonfinite_num_put(trap_infinity)); + + std::basic_stringstream ss; + ss.imbue(new_locale); + + ValType a1 = std::numeric_limits::infinity(); + ss << a1; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit + || ss.rdstate() == std::ios_base::badbit); + ss.clear(); + + ValType a2 = -std::numeric_limits::infinity(); + ss << a2; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit + || ss.rdstate() == std::ios_base::badbit); +} + +template void trap_test_get_inf_impl() +{ + std::locale old_locale; + std::locale tmp_locale(old_locale, new nonfinite_num_put); + std::locale new_locale(tmp_locale, + new nonfinite_num_get(trap_infinity)); + + std::basic_stringstream ss; + ss.imbue(new_locale); + + ValType a1 = std::numeric_limits::infinity(); + ss << a1; + ValType b1; + ss >> b1; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit); + + ss.clear(); + ss.str(S_("")); + + ValType a2 = -std::numeric_limits::infinity(); + ss << a2; + ValType b2; + ss >> b2; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit); +} + +//------------------------------------------------------------------------------ + +template void trap_test_nan_impl(); +template void trap_test_put_nan_impl(); +template void trap_test_get_nan_impl(); + +void trap_test_nan() +{ + trap_test_nan_impl(); + trap_test_nan_impl(); + trap_test_nan_impl(); + trap_test_nan_impl(); + trap_test_nan_impl(); + trap_test_nan_impl(); +} + +template void trap_test_nan_impl() +{ + trap_test_put_nan_impl(); + trap_test_get_nan_impl(); +} + +template void trap_test_put_nan_impl() +{ + std::locale old_locale; + std::locale new_locale(old_locale, + new nonfinite_num_put(trap_nan)); + + std::basic_stringstream ss; + ss.imbue(new_locale); + + ValType a1 = std::numeric_limits::quiet_NaN(); + ss << a1; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit + || ss.rdstate() == std::ios_base::badbit); + ss.clear(); + + ValType a2 = std::numeric_limits::signaling_NaN(); + ss << a2; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit + || ss.rdstate() == std::ios_base::badbit); +} + +template void trap_test_get_nan_impl() +{ + std::locale old_locale; + std::locale tmp_locale(old_locale, new nonfinite_num_put); + std::locale new_locale(tmp_locale, + new nonfinite_num_get(trap_nan)); + + std::basic_stringstream ss; + ss.imbue(new_locale); + + ValType a1 = std::numeric_limits::quiet_NaN(); + ss << a1; + ValType b1; + ss >> b1; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit); + + ss.clear(); + ss.str(S_("")); + + ValType a2 = std::numeric_limits::signaling_NaN(); + ss << a2; + ValType b2; + ss >> b2; + BOOST_CHECK(ss.rdstate() == std::ios_base::failbit); +} + +//------------------------------------------------------------------------------ + +} // anonymous namespace diff --git a/test/test_sign.cpp b/test/test_sign.cpp index c60afbdc2..0cc90a1b9 100644 --- a/test/test_sign.cpp +++ b/test/test_sign.cpp @@ -1,5 +1,5 @@ // Copyright John Maddock 2008 - +// (C) Copyright Paul A. Bristow 2011 (added tests for changesign) // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt @@ -27,6 +27,15 @@ void test_spots(RealType /*T*/, const char* /*type_name*/) RealType c = -1; BOOST_CHECK_EQUAL((boost::math::signbit)(a), 0); BOOST_CHECK_EQUAL((boost::math::sign)(a), 0); + BOOST_CHECK_EQUAL((boost::math::changesign)(b), RealType(-1)); + BOOST_CHECK_EQUAL((boost::math::changesign)(c), RealType(+1)); + BOOST_CHECK_EQUAL((boost::math::changesign)(a), RealType(0)); + + // Compare to formula for changsign(x) = copysign(x, signbit(x) ? 1.0 : -1.0) + BOOST_CHECK_EQUAL((boost::math::changesign)(b), + boost::math::copysign(b, boost::math::signbit(b) ? RealType(1.) : RealType(-1.) )); + + BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(1)); BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(1)); a = 1; @@ -49,6 +58,7 @@ void test_spots(RealType /*T*/, const char* /*type_name*/) BOOST_CHECK_EQUAL((boost::math::sign)(a), -1); BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(-1)); BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(-1)); + if(std::numeric_limits::has_infinity) { a = std::numeric_limits::infinity(); @@ -56,11 +66,14 @@ void test_spots(RealType /*T*/, const char* /*type_name*/) BOOST_CHECK_EQUAL((boost::math::sign)(a), 1); BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(1)); BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(1)); + BOOST_CHECK_EQUAL((boost::math::changesign)(a), -a); + a = -std::numeric_limits::infinity(); BOOST_CHECK((boost::math::signbit)(a) != 0); BOOST_CHECK_EQUAL((boost::math::sign)(a), -1); BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(-1)); BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(-1)); + BOOST_CHECK_EQUAL((boost::math::changesign)(a), -a); } #if !defined(__SUNPRO_CC) && !defined(BOOST_INTEL) if(std::numeric_limits::has_quiet_NaN) @@ -70,11 +83,17 @@ void test_spots(RealType /*T*/, const char* /*type_name*/) BOOST_CHECK_EQUAL((boost::math::sign)(a), 1); BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(1)); BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(1)); + // BOOST_CHECK_EQUAL((boost::math::changesign)(a), -a); // NaN comparison fails always! + BOOST_CHECK((boost::math::signbit)((boost::math::changesign)(a)) != 0); + a = -std::numeric_limits::quiet_NaN(); BOOST_CHECK((boost::math::signbit)(a) != 0); BOOST_CHECK_EQUAL((boost::math::sign)(a), -1); BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(-1)); BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(-1)); + //BOOST_CHECK_EQUAL((boost::math::changesign)(a), -a); // NaN comparison fails always! + BOOST_CHECK_EQUAL((boost::math::signbit)((boost::math::changesign)(a)), 0); + } #endif // diff --git a/test/test_signed_zero.cpp b/test/test_signed_zero.cpp new file mode 100644 index 000000000..45186da2b --- /dev/null +++ b/test/test_signed_zero.cpp @@ -0,0 +1,89 @@ +// Copyright (c) 2006 Johan Rade +// Copyright (c) 2011 Paul A. Bristow To incorporate into Boost.Math + +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifdef _MSC_VER +# pragma warning(disable : 4702) // Unreachable code. +# pragma warning(disable : 4127) // expression is constant. +#endif + +#define BOOST_TEST_MAIN + +#include +#include +#include +#include + +#include +#include +#include "almost_equal.ipp" +#include "S_.ipp" + +namespace { + +// the anonymous namespace resolves ambiguities on platforms +// with fpclassify etc functions at global scope + +using namespace boost::math; +using boost::math::signbit; +using boost::math::changesign; +using boost::math::isnan; + +//------------------------------------------------------------------------------ + +template void signed_zero_test_impl(); + +BOOST_AUTO_TEST_CASE(signed_zero_test) +{ + signed_zero_test_impl(); + signed_zero_test_impl(); + signed_zero_test_impl(); + signed_zero_test_impl(); + signed_zero_test_impl(); + signed_zero_test_impl(); +} + +template void signed_zero_test_impl() +{ + + if (signbit(static_cast(-1e-6f)/(std::numeric_limits::max)()) != -0) + { + BOOST_MESSAGE("Signed zero is not supported on this platform."); + return; + } + + + std::locale old_locale; + std::locale tmp_locale( + old_locale, new nonfinite_num_put(signed_zero)); + std::locale new_locale(tmp_locale, new nonfinite_num_get); + + std::basic_stringstream ss; + ss.imbue(new_locale); + + ValType a1 = static_cast(0); + ValType a2 = (changesign)(static_cast(0)); + BOOST_CHECK(!(signbit)(a1)); + BOOST_CHECK((signbit)(a2)); + + ss << a1 << ' ' << a2; + + std::basic_string s = S_("0 -0"); + BOOST_CHECK(ss.str() == s); + + ValType b1, b2; + ss >> b1 >> b2; + + BOOST_CHECK(b1 == a1); + BOOST_CHECK(b2 == a2); + BOOST_CHECK(!(signbit)(b1)); + BOOST_CHECK((signbit)(b2)); + BOOST_CHECK(ss.rdstate() == std::ios_base::eofbit); +} + +//------------------------------------------------------------------------------ + +} // anonymous namespace