Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66944 - in sandbox/math_constants: boost/math/constants libs/math/doc libs/math/doc/html libs/math/doc/html/images libs/math/doc/html/images/callouts libs/math/doc/html/math_constants
From: john_at_[hidden]
Date: 2010-12-01 08:46:13


Author: johnmaddock
Date: 2010-12-01 08:46:11 EST (Wed, 01 Dec 2010)
New Revision: 66944
URL: http://svn.boost.org/trac/boost/changeset/66944

Log:
Add docs, tweak constexp support.
Added:
   sandbox/math_constants/libs/math/doc/
   sandbox/math_constants/libs/math/doc/Jamfile.v2 (contents, props changed)
   sandbox/math_constants/libs/math/doc/constants.qbk (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/
   sandbox/math_constants/libs/math/doc/html/boostbook.css (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/
   sandbox/math_constants/libs/math/doc/html/images/alert.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/blank.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/
   sandbox/math_constants/libs/math/doc/html/images/callouts/1.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/1.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/10.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/10.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/11.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/11.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/12.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/12.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/13.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/13.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/14.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/14.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/15.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/15.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/16.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/17.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/18.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/19.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/2.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/2.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/20.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/21.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/22.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/23.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/24.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/25.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/26.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/27.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/28.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/29.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/3.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/3.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/30.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/4.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/4.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/5.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/5.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/6.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/6.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/7.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/7.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/8.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/8.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/9.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/callouts/9.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/caution.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/caution.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/draft.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/home.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/home.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/important.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/important.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/next.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/next.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/next_disabled.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/note.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/note.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/prev.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/prev.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/prev_disabled.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/smiley.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/tip.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/tip.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/toc-blank.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/toc-minus.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/toc-plus.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/up.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/up.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/up_disabled.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/warning.png (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/images/warning.svg (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/index.html (contents, props changed)
   sandbox/math_constants/libs/math/doc/html/math_constants/
   sandbox/math_constants/libs/math/doc/html/math_constants/tutorial.html (contents, props changed)
Text files modified:
   sandbox/math_constants/boost/math/constants/constants.hpp | 12 ++++++------
   1 files changed, 6 insertions(+), 6 deletions(-)

Modified: sandbox/math_constants/boost/math/constants/constants.hpp
==============================================================================
--- sandbox/math_constants/boost/math/constants/constants.hpp (original)
+++ sandbox/math_constants/boost/math/constants/constants.hpp 2010-12-01 08:46:11 EST (Wed, 01 Dec 2010)
@@ -110,11 +110,11 @@
       BOOST_MATH_CONSTANT_THREAD_HELPER(name, string_)\
       return BOOST_JOIN(string_get_, name)<T>();\
    }\
- template <class T> inline T BOOST_JOIN(get_, name)(const mpl::int_<construct_from_float>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
+ template <class T> inline BOOST_CONSTEXPR T BOOST_JOIN(get_, name)(const mpl::int_<construct_from_float>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
    { return BOOST_JOIN(BOOST_JOIN(x, BOOST_JOIN(e, exp)), F); }\
- template <class T> inline T BOOST_JOIN(get_, name)(const mpl::int_<construct_from_double>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
+ template <class T> inline BOOST_CONSTEXPR T BOOST_JOIN(get_, name)(const mpl::int_<construct_from_double>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
    { return BOOST_JOIN(x, BOOST_JOIN(e, exp)); }\
- template <class T> inline T BOOST_JOIN(get_, name)(const mpl::int_<construct_from_long_double>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
+ template <class T> inline BOOST_CONSTEXPR T BOOST_JOIN(get_, name)(const mpl::int_<construct_from_long_double>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
    { return BOOST_JOIN(BOOST_JOIN(x, BOOST_JOIN(e, exp)), L); }\
    /* This one is for very high precision that is none the less known at compile time: */ \
    template <class T, int N> inline T BOOST_JOIN(compute_get_, name)(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>) BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
@@ -122,7 +122,7 @@
    template <class T, int N> inline T BOOST_JOIN(get_, name)(const mpl::int_<N>& n BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
    {\
       BOOST_MATH_CONSTANT_THREAD_HELPER(name, compute_)\
- BOOST_JOIN(compute_get_, name)<T, N>(); \
+ return BOOST_JOIN(compute_get_, name)<T, N>(); \
    }\
    /* This one is for true arbitary precision, which may well vary at runtime: */ \
    template <class T> inline T BOOST_JOIN(get_, name)(const mpl::int_<0>& n BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
@@ -131,9 +131,9 @@
    \
    \
    /* The actual forwarding function: */ \
- template <class T, class Policy> inline T name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T) BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(Policy))\
+ template <class T, class Policy> inline BOOST_CONSTEXPR T name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T) BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(Policy))\
    { return detail:: BOOST_JOIN(get_, name)<T>(typename construction_traits<T, Policy>::type()); }\
- template <class T> inline T name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
+ template <class T> inline BOOST_CONSTEXPR T name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
    { return name<T, boost::math::policies::policy<> >(); }\
    \
    \

Added: sandbox/math_constants/libs/math/doc/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/math_constants/libs/math/doc/Jamfile.v2 2010-12-01 08:46:11 EST (Wed, 01 Dec 2010)
@@ -0,0 +1,68 @@
+
+# Copyright John Maddock 2005. 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)
+
+using quickbook ;
+
+path-constant images_location : html ;
+
+xml constants : constants.qbk ;
+boostbook standalone
+ :
+ constants
+ :
+ # Path for links to Boost:
+ #<xsl:param>boost.root=../../../../..
+
+ # Some general style settings:
+ <xsl:param>table.footnote.number.format=1
+ <xsl:param>footnote.number.format=1
+
+ # HTML options first:
+ # Use graphics not text for navigation:
+ <xsl:param>navig.graphics=1
+ # How far down we chunk nested sections, basically all of them:
+ <xsl:param>chunk.section.depth=0
+ # Don't put the first section on the same page as the TOC:
+ <xsl:param>chunk.first.sections=0
+ # How far down sections get TOC's
+ <xsl:param>toc.section.depth=10
+ # Max depth in each TOC:
+ <xsl:param>toc.max.depth=4
+ # How far down we go with TOC's
+ #<xsl:param>generate.section.toc.level=0
+ # Index on type:
+ <xsl:param>index.on.type=1
+
+ # PDF Options:
+ # TOC Generation: this is needed for FOP-0.9 and later:
+ <xsl:param>fop1.extensions=0
+ <format>pdf:<xsl:param>xep.extensions=1
+ # TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9!
+ <format>pdf:<xsl:param>fop.extensions=0
+ <format>pdf:<xsl:param>fop1.extensions=0
+ # No indent on body text:
+ <format>pdf:<xsl:param>body.start.indent=0pt
+ # Margin size:
+ <format>pdf:<xsl:param>page.margin.inner=0.5in
+ # Margin size:
+ <format>pdf:<xsl:param>page.margin.outer=0.5in
+ # Paper type = A4
+ <format>pdf:<xsl:param>paper.type=A4
+ # Yes, we want graphics for admonishments:
+ <xsl:param>admon.graphics=1
+ # Set this one for PDF generation *only*:
+ # default pnd graphics are awful in PDF form,
+ # better use SVG's instead:
+ <format>pdf:<xsl:param>admon.graphics.extension=".svg"
+ <format>pdf:<xsl:param>use.role.for.mediaobject=1
+ <format>pdf:<xsl:param>preferred.mediaobject.role=print
+ <format>pdf:<xsl:param>img.src.path=$(images_location)/
+ <format>pdf:<xsl:param>draft.mode="no"
+ <format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/math/doc/sf_and_dist/html
+ ;
+
+install pdf-install : standalone : <location>. <install-type>PDF ;
+
+

Added: sandbox/math_constants/libs/math/doc/constants.qbk
==============================================================================
--- (empty file)
+++ sandbox/math_constants/libs/math/doc/constants.qbk 2010-12-01 08:46:11 EST (Wed, 01 Dec 2010)
@@ -0,0 +1,225 @@
+[article Math Constants
+ [quickbook 1.5]
+ [copyright 2010 John Maddock, Paul A. Bristow]
+ [/purpose ISBN 0-9504833-2-X 978-0-9504833-2-0, Classification 519.2-dc22]
+ [license
+ 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])
+ ]
+ [authors [Maddock, John], [Bristow, Paul A.]]
+ [/last-revision $Date: 2010-11-25 09:56:01 +0000 (Thu, 25 Nov 2010) $]
+]
+
+[section:tutorial Tutorial]
+
+[section:non_templ Use in non-template code]
+
+When using the constants at fixed precision in non-template code, you can simply
+add a using declaration to make the constants of the correct precision for your code
+visible in the current scope, and then use each constant as a simple variable:
+
+ #include <boost/math/constants.hpp>
+
+ double area(double r)
+ {
+ using boost::math::double_constants;
+ return pi * r * r;
+ }
+
+Had our function been written as taking a `float` rather than a `double`
+we could have written instead:
+
+ #include <boost/math/constants.hpp>
+
+ float area(float r)
+ {
+ using boost::math::float_constants;
+ return pi * r * r;
+ }
+
+Likewise constants that are suitable for use at `long double` precision
+are available in the namespace `boost::math::long_double_constants`.
+
+[endsect]
+[section:templ Use in template code]
+
+When using the constants inside a function template, we need to ensure that
+we use the a constant of the correct precision for our template parameters.
+We can do this by calling the function-template versions of the constants
+like this:
+
+ #include <boost/math/constants.hpp>
+
+ template <class Real>
+ Real area(Real r)
+ {
+ using namespace boost::math::constants;
+ return pi<Real>() * r * r;
+ }
+
+Although this syntax is a little less "cute" than the non-template version
+the code is no less efficient (at least for the builtin types float, double and long double)
+- the function template versions of the constants are simple inline functions that
+return a constant of the correct precision for the type used. In addition these
+functions are declared `constexp` for those compilers that support this, allowing
+the result to be used in constant-expressions provided the template argument is a literal type.
+
+[endsect]
+[section:user_def Use With User Defined Types]
+
+The syntax for using the constants with user-defined types is the same as it is in
+the template clase, which is to say we use:
+
+ #include <boost/math/constants.hpp>
+
+ boost::math::constants::pi<UserDefinedType>();
+
+However, since the precision of the user-defined type may be much greater than that
+of the builtin floating pointer types, how the value returned is created is as follows:
+
+* If the precision of the type is known at compile time:
+ * If the precision is less than or equal to that of a `float` and the type is constructable from a `float`
+ then our code returns a `float` literal. If the user-defined type is a literal type
+ then the function call that returns the constant will be a `constexp`.
+ * If the precision is less than or equal to that of a `double` and the type is constructable from a `double`
+ then our code returns a `double` literal. If the user-defined type is a literal type
+ then the function call that returns the constant will be a `constexp`.
+ * If the precision is less than or equal to that of a `long double` and the type is constructable from a `long double`
+ then our code returns a `long double` literal. If the user-defined type is a literal type
+ then the function call that returns the constant will be a `constexp`.
+ * If the precision is less than 100 decimal digits, then the constant will be constructed
+ (just the once, then cached in a thread safe manner) from a string representation of the constant.
+ * Otherwise the value is computed (just once, then cached in a thread safe manner).
+* If the precision is unknown at compile time then:
+ * If the runtime precision (obtained from a call to `boost::math::tools::digits<T>()`) is
+ less than 100 decimal digits, then the constant is constructed "on the fly" from the string
+ representation of the constant.
+ * Otherwise the value is constructed "on the fly" by calculating then value of the constant
+ using the current default precision of the type. Note that this can make use of the constants
+ rather expensive.
+
+In addition, it is possible to pass a "Policy" type as a second template argument, and use this to control
+the precision:
+
+ #include <boost/math/constants/constants.hpp>
+
+ typedef boost::math::policies::policy<boost::math::policies::digits2<80> > my_policy_type;
+ boost::math::constants::pi<MyType, my_policy_type>();
+
+Note that Boost.Math doesn't know how to control the internal precision of `MyType`, the policy
+just controls how the selection process above is carried out, and the calculation precision
+if the result is computed.
+
+It is also possible to control which method is used to construct the constant by specialising
+the traits class `construction_traits`:
+
+ namespace boost{ namespace math{ namespace constant{
+
+ template <class T, class Policy>
+ struct construction_traits
+ {
+ typedef mpl::int_<N> type;
+ };
+
+ }}} // namespaces
+
+Where /N/ takes one of the following values:
+
+[table
+[[N][Meaning]]
+[[0][The precision is unavailable at compile time, either construct from a string or calculate on the fly
+ depending upon the runtime precision.]]
+[[1][Return a float precision constant.]]
+[[2][Return a double precision constant.]]
+[[3][Return a long double precision constant.]]
+[[4][Construct the result from the string representation, and cache the result.]]
+[[Any other value N][Sets the compile time precision to N bits.]]
+]
+
+Finally, sice it can be tricky to diagnose what meta-programmed code is doing, there is a
+diagnostic routine that prints information about how this library will handle a specific type,
+it can be used like this:
+
+ #include <boost/math/constants/info.hpp>
+
+ int main()
+ {
+ boost::math::constants::print_info_on_type<MyType>();
+ }
+
+If you wish you can also pass an optional std::ostream argument to the `print_info_on_type` function.
+Typical output for a user-defined type looks like this:
+
+[pre
+Information on the Implementation and Handling of
+Mathematical Constants for Type class boost::math::concepts::real_concept
+
+Checking for std::numeric_limits<class boost::math::concepts::real_concept> specialisation: no
+boost::math::policies::precision<class boost::math::concepts::real_concept, Policy>
+reports that there is no compile type precision available.
+boost::math::tools::digits<class boost::math::concepts::real_concept>()
+reports that the current runtime precision is
+53 binary digits.
+No compile time precision is available, the construction method
+will be decided at runtime and results will not be cached
+- this may lead to poor runtime performance.
+Current runtime precision indicates that
+the constant will be constructed from a string on each call.
+]
+
+[endsect]
+[endsect]
+
+[section:constants The constants]
+
+TODO!!
+
+[endsect]
+
+[section:new_const Defining New Constants]
+
+The library provides some helper code to assist in defining new constants, the process
+for defining a constant called "boost" goes like this:
+
+1. Define a function that calculates the value of the constant, this should be a template
+function, and be placed in boost/math/constants/calculate_constants.hpp if the constant is to be
+added to this library, or else defined at the top of your source file if not. The function should look like this:
+
+ namespace boost{ namespace math{ namespace constants{ namespace detail{
+
+ template <class Real, int N>
+ Real calculate_boost((const mpl::int_<N>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+ {
+ int required_precision = N ? N : tools::digits<Real>();
+ Real result = /* value computed to required_precision bits */ ;
+ return result;
+ }
+
+ }}}} // namespaces
+
+2. You will need an arbitary precision type to use to calculate the value - this library
+currently supports either NTL::RR or mpfr_class used via the bindings in boost/math/bindings.
+The default is to use NTL::RR unles you define `USE_MPFR` at the start of your program.
+
+3. The complete program to calculate the constant is then:
+
+ #define USE_MPFR // if required
+ #include <boost/math/constants/generate.hpp>
+
+ int main()
+ {
+ BOOST_CONSTANTS_GENERATE(boost);
+ }
+
+The output from the program is a snippet of C++ code (actually a macro call) that can be cut and pasted
+into boost/math/constants/constants.hpp or else into your own code:
+
+[pre
+BOOST_DEFINE_MATH_CONSTANT(boost, 3.141592653589793238462643383279502884, 19716939937510582097494459230781640628620899862803482534211706798, 0);
+]
+
+This code snippet declares the float, double and long double versions of the constant, plus a string representation correct to 100 decimal
+digits, and all the meta-programming machinary needed to select between them.
+
+[endsect]

Added: sandbox/math_constants/libs/math/doc/html/boostbook.css
==============================================================================
--- (empty file)
+++ sandbox/math_constants/libs/math/doc/html/boostbook.css 2010-12-01 08:46:11 EST (Wed, 01 Dec 2010)
@@ -0,0 +1,601 @@
+/*=============================================================================
+ Copyright (c) 2004 Joel de Guzman
+ http://spirit.sourceforge.net/
+
+ Distributed under the Boost Software License, Version 1.0. (See accompany-
+ ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+/*=============================================================================
+ Body defaults
+=============================================================================*/
+
+ body
+ {
+ margin: 1em;
+ font-family: sans-serif;
+ }
+
+/*=============================================================================
+ Paragraphs
+=============================================================================*/
+
+ p
+ {
+ text-align: left;
+ font-size: 10pt;
+ line-height: 1.15;
+ }
+
+/*=============================================================================
+ Program listings
+=============================================================================*/
+
+ /* Code on paragraphs */
+ p tt.computeroutput
+ {
+ font-size: 9pt;
+ }
+
+ pre.synopsis
+ {
+ font-size: 9pt;
+ margin: 1pc 4% 0pc 4%;
+ padding: 0.5pc 0.5pc 0.5pc 0.5pc;
+ }
+
+ .programlisting,
+ .screen
+ {
+ font-size: 9pt;
+ display: block;
+ margin: 1pc 4% 0pc 4%;
+ padding: 0.5pc 0.5pc 0.5pc 0.5pc;
+ }
+
+ /* Program listings in tables don't get borders */
+ td .programlisting,
+ td .screen
+ {
+ margin: 0pc 0pc 0pc 0pc;
+ padding: 0pc 0pc 0pc 0pc;
+ }
+
+/*=============================================================================
+ Headings
+=============================================================================*/
+
+ h1, h2, h3, h4, h5, h6
+ {
+ text-align: left;
+ margin: 1em 0em 0.5em 0em;
+ font-weight: bold;
+ }
+
+ h1 { font: 140% }
+ h2 { font: bold 140% }
+ h3 { font: bold 130% }
+ h4 { font: bold 120% }
+ h5 { font: italic 110% }
+ h6 { font: italic 100% }
+
+ /* Top page titles */
+ title,
+ h1.title,
+ h2.title
+ h3.title,
+ h4.title,
+ h5.title,
+ h6.title,
+ .refentrytitle
+ {
+ font-weight: bold;
+ margin-bottom: 1pc;
+ }
+
+ h1.title { font-size: 140% }
+ h2.title { font-size: 140% }
+ h3.title { font-size: 130% }
+ h4.title { font-size: 120% }
+ h5.title { font-size: 110% }
+ h6.title { font-size: 100% }
+
+ .section h1
+ {
+ margin: 0em 0em 0.5em 0em;
+ font-size: 140%;
+ }
+
+ .section h2 { font-size: 140% }
+ .section h3 { font-size: 130% }
+ .section h4 { font-size: 120% }
+ .section h5 { font-size: 110% }
+ .section h6 { font-size: 100% }
+
+ /* Code on titles */
+ h1 tt.computeroutput { font-size: 140% }
+ h2 tt.computeroutput { font-size: 140% }
+ h3 tt.computeroutput { font-size: 130% }
+ h4 tt.computeroutput { font-size: 130% }
+ h5 tt.computeroutput { font-size: 130% }
+ h6 tt.computeroutput { font-size: 130% }
+
+
+/*=============================================================================
+ Author
+=============================================================================*/
+
+ h3.author
+ {
+ font-size: 100%
+ }
+
+/*=============================================================================
+ Lists
+=============================================================================*/
+
+ li
+ {
+ font-size: 10pt;
+ line-height: 1.3;
+ }
+
+ /* Unordered lists */
+ ul
+ {
+ text-align: left;
+ }
+
+ /* Ordered lists */
+ ol
+ {
+ text-align: left;
+ }
+
+/*=============================================================================
+ Links
+=============================================================================*/
+
+ a
+ {
+ text-decoration: none; /* no underline */
+ }
+
+ a:hover
+ {
+ text-decoration: underline;
+ }
+
+/*=============================================================================
+ Spirit style navigation
+=============================================================================*/
+
+ .spirit-nav
+ {
+ text-align: right;
+ }
+
+ .spirit-nav a
+ {
+ color: white;
+ padding-left: 0.5em;
+ }
+
+ .spirit-nav img
+ {
+ border-width: 0px;
+ }
+
+/*=============================================================================
+ Copyright footer
+=============================================================================*/
+ .copyright-footer
+ {
+ text-align: right;
+ font-size: 70%;
+ }
+
+ .copyright-footer p
+ {
+ text-align: right;
+ font-size: 80%;
+ }
+
+/*=============================================================================
+ Table of contents
+=============================================================================*/
+
+ .toc
+ {
+ margin: 1pc 4% 0pc 4%;
+ padding: 0.1pc 1pc 0.1pc 1pc;
+ font-size: 80%;
+ line-height: 1.15;
+ }
+
+ .boost-toc
+ {
+ float: right;
+ padding: 0.5pc;
+ }
+
+ /* Code on toc */
+ .toc .computeroutput { font-size: 120% }
+
+/*=============================================================================
+ Tables
+=============================================================================*/
+
+ .table-title,
+ div.table p.title
+ {
+ margin-left: 4%;
+ padding-right: 0.5em;
+ padding-left: 0.5em;
+ }
+
+ .informaltable table,
+ .table table
+ {
+ width: 92%;
+ margin-left: 4%;
+ margin-right: 4%;
+ }
+
+ div.informaltable table,
+ div.table table
+ {
+ padding: 4px;
+ }
+
+ /* Table Cells */
+ div.informaltable table tr td,
+ div.table table tr td
+ {
+ padding: 0.5em;
+ text-align: left;
+ font-size: 9pt;
+ }
+
+ div.informaltable table tr th,
+ div.table table tr th
+ {
+ padding: 0.5em 0.5em 0.5em 0.5em;
+ border: 1pt solid white;
+ font-size: 80%;
+ }
+
+ table.simplelist
+ {
+ width: auto !important;
+ margin: 0em !important;
+ padding: 0em !important;
+ border: none !important;
+ }
+ table.simplelist td
+ {
+ margin: 0em !important;
+ padding: 0em !important;
+ text-align: left !important;
+ font-size: 9pt !important;
+ border: none !important;
+ }
+
+/*=============================================================================
+ Blurbs
+=============================================================================*/
+
+ div.note,
+ div.tip,
+ div.important,
+ div.caution,
+ div.warning,
+ p.blurb
+ {
+ font-size: 9pt; /* A little bit smaller than the main text */
+ line-height: 1.2;
+ display: block;
+ margin: 1pc 4% 0pc 4%;
+ padding: 0.5pc 0.5pc 0.5pc 0.5pc;
+ }
+
+ p.blurb img
+ {
+ padding: 1pt;
+ }
+
+/*=============================================================================
+ Variable Lists
+=============================================================================*/
+
+ div.variablelist
+ {
+ margin: 1em 0;
+ }
+
+ /* Make the terms in definition lists bold */
+ div.variablelist dl dt,
+ span.term
+ {
+ font-weight: bold;
+ font-size: 10pt;
+ }
+
+ div.variablelist table tbody tr td
+ {
+ text-align: left;
+ vertical-align: top;
+ padding: 0em 2em 0em 0em;
+ font-size: 10pt;
+ margin: 0em 0em 0.5em 0em;
+ line-height: 1;
+ }
+
+ div.variablelist dl dt
+ {
+ margin-bottom: 0.2em;
+ }
+
+ div.variablelist dl dd
+ {
+ margin: 0em 0em 0.5em 2em;
+ font-size: 10pt;
+ }
+
+ div.variablelist table tbody tr td p,
+ div.variablelist dl dd p
+ {
+ margin: 0em 0em 0.5em 0em;
+ line-height: 1;
+ }
+
+/*=============================================================================
+ Misc
+=============================================================================*/
+
+ /* Title of books and articles in bibliographies */
+ span.title
+ {
+ font-style: italic;
+ }
+
+ span.underline
+ {
+ text-decoration: underline;
+ }
+
+ span.strikethrough
+ {
+ text-decoration: line-through;
+ }
+
+ /* Copyright, Legal Notice */
+ div div.legalnotice p
+ {
+ text-align: left
+ }
+
+/*=============================================================================
+ Colors
+=============================================================================*/
+
+ @media screen
+ {
+ body {
+ background-color: #FFFFFF;
+ color: #000000;
+ }
+
+ /* Syntax Highlighting */
+ .keyword { color: #0000AA; }
+ .identifier { color: #000000; }
+ .special { color: #707070; }
+ .preprocessor { color: #402080; }
+ .char { color: teal; }
+ .comment { color: #800000; }
+ .string { color: teal; }
+ .number { color: teal; }
+ .white_bkd { background-color: #FFFFFF; }
+ .dk_grey_bkd { background-color: #999999; }
+
+ /* Links */
+ a, a .keyword, a .identifier, a .special, a .preprocessor
+ a .char, a .comment, a .string, a .number
+ {
+ color: #005a9c;
+ }
+
+ a:visited, a:visited .keyword, a:visited .identifier,
+ a:visited .special, a:visited .preprocessor a:visited .char,
+ a:visited .comment, a:visited .string, a:visited .number
+ {
+ color: #9c5a9c;
+ }
+
+ h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
+ h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover,
+ h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited
+ {
+ text-decoration: none; /* no underline */
+ color: #000000;
+ }
+
+ /* Copyright, Legal Notice */
+ .copyright
+ {
+ color: #666666;
+ font-size: small;
+ }
+
+ div div.legalnotice p
+ {
+ color: #666666;
+ }
+
+ /* Program listing */
+ pre.synopsis
+ {
+ border: 1px solid #DCDCDC;
+ }
+
+ .programlisting,
+ .screen
+ {
+ border: 1px solid #DCDCDC;
+ }
+
+ td .programlisting,
+ td .screen
+ {
+ border: 0px solid #DCDCDC;
+ }
+
+ /* Blurbs */
+ div.note,
+ div.tip,
+ div.important,
+ div.caution,
+ div.warning,
+ p.blurb
+ {
+ border: 1px solid #DCDCDC;
+ }
+
+ /* Table of contents */
+ .toc
+ {
+ border: 1px solid #DCDCDC;
+ }
+
+ /* Tables */
+ div.informaltable table tr td,
+ div.table table tr td
+ {
+ border: 1px solid #DCDCDC;
+ }
+
+ div.informaltable table tr th,
+ div.table table tr th
+ {
+ background-color: #F0F0F0;
+ border: 1px solid #DCDCDC;
+ }
+
+ .copyright-footer
+ {
+ color: #8F8F8F;
+ }
+
+ /* Misc */
+ span.highlight
+ {
+ color: #00A000;
+ }
+ }
+
+ @media print
+ {
+ /* Links */
+ a
+ {
+ color: black;
+ }
+
+ a:visited
+ {
+ color: black;
+ }
+
+ .spirit-nav
+ {
+ display: none;
+ }
+
+ /* Program listing */
+ pre.synopsis
+ {
+ border: 1px solid gray;
+ }
+
+ .programlisting,
+ .screen
+ {
+ border: 1px solid gray;
+ }
+
+ td .programlisting,
+ td .screen
+ {
+ border: 0px solid #DCDCDC;
+ }
+
+ /* Table of contents */
+ .toc
+ {
+ border: 1px solid gray;
+ }
+
+ .informaltable table,
+ .table table
+ {
+ border: 1px solid gray;
+ border-collapse: collapse;
+ }
+
+ /* Tables */
+ div.informaltable table tr td,
+ div.table table tr td
+ {
+ border: 1px solid gray;
+ }
+
+ div.informaltable table tr th,
+ div.table table tr th
+ {
+ border: 1px solid gray;
+ }
+
+ table.simplelist tr td
+ {
+ border: none !important;
+ }
+
+ /* Misc */
+ span.highlight
+ {
+ font-weight: bold;
+ }
+ }
+
+/*=============================================================================
+ Images
+=============================================================================*/
+
+ span.inlinemediaobject img
+ {
+ vertical-align: middle;
+ }
+
+/*==============================================================================
+ Super and Subscript: style so that line spacing isn't effected, see
+ http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=1&postId=5341
+==============================================================================*/
+
+sup,
+sub {
+ height: 0;
+ line-height: 1;
+ vertical-align: baseline;
+ _vertical-align: bottom;
+ position: relative;
+
+}
+
+sup {
+ bottom: 1ex;
+}
+
+sub {
+ top: .5ex;
+}
+

Added: sandbox/math_constants/libs/math/doc/html/images/alert.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/blank.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/1.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/1.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/10.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/10.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/11.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/11.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/12.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/12.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/13.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/13.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/14.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/14.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/15.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/15.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/16.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/17.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/18.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/19.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/2.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/2.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/20.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/21.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/22.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/23.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/24.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/25.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/26.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/27.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/28.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/29.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/3.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/3.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/30.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/4.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/4.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/5.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/5.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/6.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/6.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/7.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/7.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/8.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/8.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/9.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/callouts/9.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/caution.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/caution.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/draft.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/home.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/home.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/important.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/important.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/next.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/next.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/next_disabled.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/note.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/note.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/prev.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/prev.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/prev_disabled.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/smiley.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/tip.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/tip.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/toc-blank.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/toc-minus.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/toc-plus.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/up.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/up.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/up_disabled.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/warning.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/images/warning.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_constants/libs/math/doc/html/index.html
==============================================================================
--- (empty file)
+++ sandbox/math_constants/libs/math/doc/html/index.html 2010-12-01 08:46:11 EST (Wed, 01 Dec 2010)
@@ -0,0 +1,432 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Math Constants</title>
+<link rel="stylesheet" href="boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
+<link rel="home" href="index.html" title="Math Constants">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr><td valign="top"></td></tr></table>
+<hr>
+<div class="spirit-nav"></div>
+<div class="article" lang="en">
+<div class="titlepage">
+<div>
+<div><h2 class="title">
+<a name="math_constants"></a>Math Constants</h2></div>
+<div><div class="authorgroup">
+<div class="author"><h3 class="author">
+<span class="firstname">John</span> <span class="surname">Maddock</span>
+</h3></div>
+<div class="author"><h3 class="author">
+<span class="firstname">Paul A.</span> <span class="surname">Bristow</span>
+</h3></div>
+</div></div>
+<div><p class="copyright">Copyright &#169; 2010 John Maddock, Paul A. Bristow</p></div>
+<div><div class="legalnotice">
+<a name="id978745"></a><p>
+ 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)
+ </p>
+</div></div>
+</div>
+<hr>
+</div>
+<div class="toc">
+<p><b>Table of Contents</b></p>
+<dl>
+<dt><span class="section"> Tutorial</span></dt>
+<dd><dl>
+<dt><span class="section"><a href="index.html#math_constants.tutorial.non_templ"> Use in non-template
+ code</a></span></dt>
+<dt><span class="section"> Use in template code</span></dt>
+<dt><span class="section"><a href="index.html#math_constants.tutorial.user_def"> Use With User Defined
+ Types</a></span></dt>
+</dl></dd>
+<dt><span class="section"> The constants</span></dt>
+<dt><span class="section"> Defining New Constants</span></dt>
+</dl>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="math_constants.tutorial"></a><a class="link" href="index.html#math_constants.tutorial" title="Tutorial"> Tutorial</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="index.html#math_constants.tutorial.non_templ"> Use in non-template
+ code</a></span></dt>
+<dt><span class="section"> Use in template code</span></dt>
+<dt><span class="section"><a href="index.html#math_constants.tutorial.user_def"> Use With User Defined
+ Types</a></span></dt>
+</dl></div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="math_constants.tutorial.non_templ"></a><a class="link" href="index.html#math_constants.tutorial.non_templ" title="Use in non-template code"> Use in non-template
+ code</a>
+</h3></div></div></div>
+<p>
+ When using the constants at fixed precision in non-template code, you can
+ simply add a using declaration to make the constants of the correct precision
+ for your code visible in the current scope, and then use each constant as
+ a simple variable:
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">constants</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">double</span> <span class="identifier">area</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">r</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">double_constants</span><span class="special">;</span>
+ <span class="keyword">return</span> <span class="identifier">pi</span> <span class="special">*</span> <span class="identifier">r</span> <span class="special">*</span> <span class="identifier">r</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ Had our function been written as taking a <code class="computeroutput"><span class="keyword">float</span></code>
+ rather than a <code class="computeroutput"><span class="keyword">double</span></code> we could
+ have written instead:
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">constants</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">float</span> <span class="identifier">area</span><span class="special">(</span><span class="keyword">float</span> <span class="identifier">r</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">float_constants</span><span class="special">;</span>
+ <span class="keyword">return</span> <span class="identifier">pi</span> <span class="special">*</span> <span class="identifier">r</span> <span class="special">*</span> <span class="identifier">r</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ Likewise constants that are suitable for use at <code class="computeroutput"><span class="keyword">long</span>
+ <span class="keyword">double</span></code> precision are available in
+ the namespace <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">long_double_constants</span></code>.
+ </p>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="math_constants.tutorial.templ"></a><a class="link" href="index.html#math_constants.tutorial.templ" title="Use in template code"> Use in template code</a>
+</h3></div></div></div>
+<p>
+ When using the constants inside a function template, we need to ensure that
+ we use the a constant of the correct precision for our template parameters.
+ We can do this by calling the function-template versions of the constants
+ like this:
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">constants</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Real</span><span class="special">&gt;</span>
+<span class="identifier">Real</span> <span class="identifier">area</span><span class="special">(</span><span class="identifier">Real</span> <span class="identifier">r</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">constants</span><span class="special">;</span>
+ <span class="keyword">return</span> <span class="identifier">pi</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">&gt;()</span> <span class="special">*</span> <span class="identifier">r</span> <span class="special">*</span> <span class="identifier">r</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ Although this syntax is a little less "cute" than the non-template
+ version the code is no less efficient (at least for the builtin types float,
+ double and long double) - the function template versions of the constants
+ are simple inline functions that return a constant of the correct precision
+ for the type used. In addition these functions are declared <code class="computeroutput"><span class="identifier">constexp</span></code> for those compilers that support
+ this, allowing the result to be used in constant-expressions provided the
+ template argument is a literal type.
+ </p>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="math_constants.tutorial.user_def"></a><a class="link" href="index.html#math_constants.tutorial.user_def" title="Use With User Defined Types"> Use With User Defined
+ Types</a>
+</h3></div></div></div>
+<p>
+ The syntax for using the constants with user-defined types is the same as
+ it is in the template clase, which is to say we use:
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">constants</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">constants</span><span class="special">::</span><span class="identifier">pi</span><span class="special">&lt;</span><span class="identifier">UserDefinedType</span><span class="special">&gt;();</span>
+</pre>
+<p>
+ However, since the precision of the user-defined type may be much greater
+ than that of the builtin floating pointer types, how the value returned is
+ created is as follows:
+ </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+ If the precision of the type is known at compile time:
+ <div class="itemizedlist"><ul type="circle">
+<li>
+ If the precision is less than or equal to that of a <code class="computeroutput"><span class="keyword">float</span></code> and the type is constructable
+ from a <code class="computeroutput"><span class="keyword">float</span></code> then
+ our code returns a <code class="computeroutput"><span class="keyword">float</span></code>
+ literal. If the user-defined type is a literal type then the function
+ call that returns the constant will be a <code class="computeroutput"><span class="identifier">constexp</span></code>.
+ </li>
+<li>
+ If the precision is less than or equal to that of a <code class="computeroutput"><span class="keyword">double</span></code> and the type is constructable
+ from a <code class="computeroutput"><span class="keyword">double</span></code> then
+ our code returns a <code class="computeroutput"><span class="keyword">double</span></code>
+ literal. If the user-defined type is a literal type then the function
+ call that returns the constant will be a <code class="computeroutput"><span class="identifier">constexp</span></code>.
+ </li>
+<li>
+ If the precision is less than or equal to that of a <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">double</span></code>
+ and the type is constructable from a <code class="computeroutput"><span class="keyword">long</span>
+ <span class="keyword">double</span></code> then our code returns
+ a <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">double</span></code>
+ literal. If the user-defined type is a literal type then the function
+ call that returns the constant will be a <code class="computeroutput"><span class="identifier">constexp</span></code>.
+ </li>
+<li>
+ If the precision is less than 100 decimal digits, then the constant
+ will be constructed (just the once, then cached in a thread safe
+ manner) from a string representation of the constant.
+ </li>
+<li>
+ Otherwise the value is computed (just once, then cached in a thread
+ safe manner).
+ </li>
+</ul></div>
+ </li>
+<li>
+ If the precision is unknown at compile time then:
+ <div class="itemizedlist"><ul type="circle">
+<li>
+ If the runtime precision (obtained from a call to <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">digits</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;()</span></code>)
+ is less than 100 decimal digits, then the constant is constructed
+ "on the fly" from the string representation of the constant.
+ </li>
+<li>
+ Otherwise the value is constructed "on the fly" by calculating
+ then value of the constant using the current default precision
+ of the type. Note that this can make use of the constants rather
+ expensive.
+ </li>
+</ul></div>
+ </li>
+</ul></div>
+<p>
+ In addition, it is possible to pass a "Policy" type as a second
+ template argument, and use this to control the precision:
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">constants</span><span class="special">/</span><span class="identifier">constants</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">policy</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">digits2</span><span class="special">&lt;</span><span class="number">80</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">my_policy_type</span><span class="special">;</span>
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">constants</span><span class="special">::</span><span class="identifier">pi</span><span class="special">&lt;</span><span class="identifier">MyType</span><span class="special">,</span> <span class="identifier">my_policy_type</span><span class="special">&gt;();</span>
+</pre>
+<p>
+ Note that Boost.Math doesn't know how to control the internal precision of
+ <code class="computeroutput"><span class="identifier">MyType</span></code>, the policy just controls
+ how the selection process above is carried out, and the calculation precision
+ if the result is computed.
+ </p>
+<p>
+ It is also possible to control which method is used to construct the constant
+ by specialising the traits class <code class="computeroutput"><span class="identifier">construction_traits</span></code>:
+ </p>
+<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">constant</span><span class="special">{</span>
+
+<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Policy</span><span class="special">&gt;</span>
+<span class="keyword">struct</span> <span class="identifier">construction_traits</span>
+<span class="special">{</span>
+ <span class="keyword">typedef</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">int_</span><span class="special">&lt;</span><span class="identifier">N</span><span class="special">&gt;</span> <span class="identifier">type</span><span class="special">;</span>
+<span class="special">};</span>
+
+<span class="special">}}}</span> <span class="comment">// namespaces
+</span></pre>
+<p>
+ Where <span class="emphasis"><em>N</em></span> takes one of the following values:
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ N
+ </p>
+ </th>
+<th>
+ <p>
+ Meaning
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ 0
+ </p>
+ </td>
+<td>
+ <p>
+ The precision is unavailable at compile time, either construct
+ from a string or calculate on the fly depending upon the runtime
+ precision.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ 1
+ </p>
+ </td>
+<td>
+ <p>
+ Return a float precision constant.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ 2
+ </p>
+ </td>
+<td>
+ <p>
+ Return a double precision constant.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ 3
+ </p>
+ </td>
+<td>
+ <p>
+ Return a long double precision constant.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ 4
+ </p>
+ </td>
+<td>
+ <p>
+ Construct the result from the string representation, and cache
+ the result.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ Any other value N
+ </p>
+ </td>
+<td>
+ <p>
+ Sets the compile time precision to N bits.
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+<p>
+ Finally, sice it can be tricky to diagnose what meta-programmed code is doing,
+ there is a diagnostic routine that prints information about how this library
+ will handle a specific type, it can be used like this:
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">constants</span><span class="special">/</span><span class="identifier">info</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">constants</span><span class="special">::</span><span class="identifier">print_info_on_type</span><span class="special">&lt;</span><span class="identifier">MyType</span><span class="special">&gt;();</span>
+<span class="special">}</span>
+</pre>
+<p>
+ If you wish you can also pass an optional std::ostream argument to the <code class="computeroutput"><span class="identifier">print_info_on_type</span></code> function. Typical output
+ for a user-defined type looks like this:
+ </p>
+<pre class="programlisting">Information on the Implementation and Handling of
+Mathematical Constants for Type class boost::math::concepts::real_concept
+
+Checking for std::numeric_limits&lt;class boost::math::concepts::real_concept&gt; specialisation: no
+boost::math::policies::precision&lt;class boost::math::concepts::real_concept, Policy&gt;
+reports that there is no compile type precision available.
+boost::math::tools::digits&lt;class boost::math::concepts::real_concept&gt;()
+reports that the current runtime precision is
+53 binary digits.
+No compile time precision is available, the construction method
+will be decided at runtime and results will not be cached
+- this may lead to poor runtime performance.
+Current runtime precision indicates that
+the constant will be constructed from a string on each call.
+</pre>
+</div>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="math_constants.constants"></a><a class="link" href="index.html#math_constants.constants" title="The constants"> The constants</a>
+</h2></div></div></div>
+<p>
+ TODO!!
+ </p>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="math_constants.new_const"></a><a class="link" href="index.html#math_constants.new_const" title="Defining New Constants"> Defining New Constants</a>
+</h2></div></div></div>
+<p>
+ The library provides some helper code to assist in defining new constants,
+ the process for defining a constant called "boost" goes like this:
+ </p>
+<p>
+ 1. Define a function that calculates the value of the constant, this should
+ be a template function, and be placed in boost/math/constants/calculate_constants.hpp
+ if the constant is to be added to this library, or else defined at the top
+ of your source file if not. The function should look like this:
+ </p>
+<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">constants</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">detail</span><span class="special">{</span>
+
+<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Real</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">N</span><span class="special">&gt;</span>
+<span class="identifier">Real</span> <span class="identifier">calculate_boost</span><span class="special">((</span><span class="keyword">const</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">int_</span><span class="special">&lt;</span><span class="identifier">N</span><span class="special">&gt;&amp;</span> <span class="identifier">BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC</span><span class="special">(</span><span class="identifier">T</span><span class="special">))</span>
+<span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">required_precision</span> <span class="special">=</span> <span class="identifier">N</span> <span class="special">?</span> <span class="identifier">N</span> <span class="special">:</span> <span class="identifier">tools</span><span class="special">::</span><span class="identifier">digits</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">&gt;();</span>
+ <span class="identifier">Real</span> <span class="identifier">result</span> <span class="special">=</span> <span class="comment">/* value computed to required_precision bits */</span> <span class="special">;</span>
+ <span class="keyword">return</span> <span class="identifier">result</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="special">}}}}</span> <span class="comment">// namespaces
+</span></pre>
+<p>
+ 2. You will need an arbitary precision type to use to calculate the value -
+ this library currently supports either NTL::RR or mpfr_class used via the bindings
+ in boost/math/bindings. The default is to use NTL::RR unles you define <code class="computeroutput"><span class="identifier">USE_MPFR</span></code> at the start of your program.
+ </p>
+<p>
+ 3. The complete program to calculate the constant is then:
+ </p>
+<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">USE_MPFR</span> <span class="comment">// if required
+</span><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">constants</span><span class="special">/</span><span class="identifier">generate</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">BOOST_CONSTANTS_GENERATE</span><span class="special">(</span><span class="identifier">boost</span><span class="special">);</span>
+<span class="special">}</span>
+</pre>
+<p>
+ The output from the program is a snippet of C++ code (actually a macro call)
+ that can be cut and pasted into boost/math/constants/constants.hpp or else
+ into your own code:
+ </p>
+<pre class="programlisting">BOOST_DEFINE_MATH_CONSTANT(boost, 3.141592653589793238462643383279502884, 19716939937510582097494459230781640628620899862803482534211706798, 0);
+</pre>
+<p>
+ This code snippet declares the float, double and long double versions of the
+ constant, plus a string representation correct to 100 decimal digits, and all
+ the meta-programming machinary needed to select between them.
+ </p>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"><p><small>Last revised: December 01, 2010 at 13:39:54 GMT</small></p></td>
+<td align="right"><div class="copyright-footer"></div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav"></div>
+</body>
+</html>

Added: sandbox/math_constants/libs/math/doc/html/math_constants/tutorial.html
==============================================================================
--- (empty file)
+++ sandbox/math_constants/libs/math/doc/html/math_constants/tutorial.html 2010-12-01 08:46:11 EST (Wed, 01 Dec 2010)
@@ -0,0 +1,172 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Tutorial</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
+<link rel="home" href="../index.html" title="Math Constants">
+<link rel="up" href="../index.html" title="Math Constants">
+<link rel="prev" href="../index.html" title="Math Constants">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr><td valign="top"></td></tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../index.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="math_constants.tutorial"></a><a class="link" href="tutorial.html" title="Tutorial"> Tutorial</a>
+</h2></div></div></div>
+<a name="math_constants.tutorial.use_in_non_template_code"></a><h5>
+<a name="id1012468"></a>
+ <a class="link" href="tutorial.html#math_constants.tutorial.use_in_non_template_code">Use in non-template
+ code</a>
+ </h5>
+<p>
+ When using the constants at fixed precision in non-template code, you can simply
+ add a using declaration to make the constants of the correct precision for
+ your code visible in the current scope, and then use each constant as a simple
+ variable:
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">constants</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">double</span> <span class="identifier">area</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">r</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">double_constants</span><span class="special">;</span>
+ <span class="keyword">return</span> <span class="identifier">pi</span> <span class="special">*</span> <span class="identifier">r</span> <span class="special">*</span> <span class="identifier">r</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ Had our function been written as taking a <code class="computeroutput"><span class="keyword">float</span></code>
+ rather than a <code class="computeroutput"><span class="keyword">double</span></code> we could
+ have written instead:
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">constants</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">float</span> <span class="identifier">area</span><span class="special">(</span><span class="keyword">float</span> <span class="identifier">r</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">float_constants</span><span class="special">;</span>
+ <span class="keyword">return</span> <span class="identifier">pi</span> <span class="special">*</span> <span class="identifier">r</span> <span class="special">*</span> <span class="identifier">r</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ Likewise constants that are suitable for use at <code class="computeroutput"><span class="keyword">long</span>
+ <span class="keyword">double</span></code> precision are available in the
+ namespace <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">long_double_constants</span></code>.
+ </p>
+<a name="math_constants.tutorial.use_in_template_code"></a><h5>
+<a name="id1012814"></a>
+ <a class="link" href="tutorial.html#math_constants.tutorial.use_in_template_code">Use in template
+ code</a>
+ </h5>
+<p>
+ When using the constants inside a function template, we need to ensure that
+ we use the a constant of the correct precision for our template parameters.
+ We can do this by calling the function-template versions of the constants like
+ this:
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">constants</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Real</span><span class="special">&gt;</span>
+<span class="identifier">Real</span> <span class="identifier">area</span><span class="special">(</span><span class="identifier">Real</span> <span class="identifier">r</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">constants</span><span class="special">;</span>
+ <span class="keyword">return</span> <span class="identifier">pi</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">&gt;()</span> <span class="special">*</span> <span class="identifier">r</span> <span class="special">*</span> <span class="identifier">r</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ Although this syntax is a little less "cute" than the non-template
+ version the code is no less efficient (at least for the builtin types float,
+ double and long double) - the function template versions of the constants are
+ simple inline functions that return a constant of the correct precision for
+ the type used. In addition these functions are declared <code class="computeroutput"><span class="identifier">constexp</span></code>
+ for those compilers that support this, allowing the result to be used in constant-expressions
+ provided the template argument is a literal type.
+ </p>
+<a name="math_constants.tutorial.use_with_user_defined_types"></a><h5>
+<a name="id1013016"></a>
+ <a class="link" href="tutorial.html#math_constants.tutorial.use_with_user_defined_types">Use With
+ User Defined Types</a>
+ </h5>
+<p>
+ The syntax for using the constants with user-defined types is the same as it
+ is in the template clase, which is to say we use:
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">constants</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">constants</span><span class="special">::</span><span class="identifier">pi</span><span class="special">&lt;</span><span class="identifier">UserDefinedType</span><span class="special">&gt;();</span>
+</pre>
+<p>
+ However, since the precision of the user-defined type may be much greater than
+ that of the builtin floating pointer types, how the value returned is created
+ is as follows:
+ </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+ If the precision of the type is known at compile time:
+ <div class="itemizedlist"><ul type="circle">
+<li>
+ If the precision is less than or equal to that of a <code class="computeroutput"><span class="keyword">float</span></code> and the type is constructable
+ from a <code class="computeroutput"><span class="keyword">float</span></code> then our
+ code returns a <code class="computeroutput"><span class="keyword">float</span></code>
+ literal. If the user-defined type is a literal type then the function
+ call that returns the constant will be a <code class="computeroutput"><span class="identifier">constexp</span></code>.
+ </li>
+<li>
+ If the precision is less than or equal to that of a <code class="computeroutput"><span class="keyword">double</span></code> and the type is constructable
+ from a <code class="computeroutput"><span class="keyword">double</span></code> then our
+ code returns a <code class="computeroutput"><span class="keyword">double</span></code>
+ literal. If the user-defined type is a literal type then the function
+ call that returns the constant will be a <code class="computeroutput"><span class="identifier">constexp</span></code>.
+ </li>
+<li>
+ If the precision is less than or equal to that of a <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">double</span></code>
+ and the type is constructable from a <code class="computeroutput"><span class="keyword">long</span>
+ <span class="keyword">double</span></code> then our code returns
+ a <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">double</span></code>
+ literal. If the user-defined type is a literal type then the function
+ call that returns the constant will be a <code class="computeroutput"><span class="identifier">constexp</span></code>.
+ </li>
+<li>
+ If the precision is less than 100 decimal digits, then the constant
+ will be constructed (just the once, then cached in a thread safe
+ manner) from a string representation of the constant.
+ </li>
+<li>
+ Otherwise the value is computed (just once, then cached in a thread
+ safe manner).
+ </li>
+</ul></div>
+ </li>
+<li>
+ If the precision is unknown at compile time then:
+ <div class="itemizedlist"><ul type="circle">
+<li>
+ If the runtime precision (obtained from a call to <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">digits</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;()</span></code>) is less than 100 decimal digits,
+ then the constant is constructed "on the fly" from the
+ string representation of the constant.
+ </li>
+<li>
+ Otherwise the value is constructed "on the fly" by calculating
+ then value of the constant using the current default precision of
+ the type. Note that this can make use of the constants rather expensive.
+ </li>
+</ul></div>
+ </li>
+</ul></div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2010 John Maddock, Paul A. Bristow<p>
+ 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)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../index.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a>
+</div>
+</body>
+</html>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk