Files
multiprecision/doc/tutorial_interval_mpfi.qbk
ivanpanch 55bf069621 Fix mistakes (#729)
* Update Jamfile.v2

* Update introduction.qbk

* Update tutorial.qbk

* Update tutorial_cpp_int.qbk

* Update tutorial_gmp_int.qbk

* Update tutorial_tommath.qbk

* Update integer_examples.cpp

* Update tutorial_cpp_bin_float.qbk

* Update tutorial_cpp_dec_float.qbk

* Update tutorial_gmp_float.qbk

* Update tutorial_mpfr_float.qbk

* Update tutorial_float128.qbk

* Update tutorial_float_builtin_ctor.qbk

* Update big_seventh.cpp

* Update tutorial_float_eg.qbk

* Update floating_point_examples.cpp

* Update mpfr_precision.cpp

* Update gauss_laguerre_quadrature.cpp

* Update tutorial_interval_mpfi.qbk

* Update tutorial_cpp_complex.qbk

* Update tutorial_mpc_complex.qbk

* Update tutorial_float128_complex.qbk

* Update tutorial_complex_adaptor.qbk

* Update tutorial_rational.qbk

* Update tutorial_tommath_rational.qbk

* Update tutorial_logged_adaptor.qbk

* Update tutorial_debug_adaptor.qbk

* Update tutorial_visualizers.qbk

* Update tutorial_fwd.qbk

* Update tutorial_conversions.qbk

* Update tutorial_random.qbk

* Update random_snips.cpp

* Update tutorial_constexpr.qbk

* Update tutorial_import_export.qbk

* Update cpp_int_import_export.cpp

* Update tutorial_mixed_precision.qbk

* Update tutorial_variable_precision.qbk

* Update scoped_precision_example.cpp

* Update tutorial_numeric_limits.qbk

* Update tutorial_numeric_limits.qbk

* Update numeric_limits_snips.cpp

* Update numeric_limits_snips.cpp

* Update tutorial_numeric_limits.qbk

* Update numeric_limits_snips.cpp

* Update numeric_limits_snips.cpp

* Update tutorial_io.qbk

* Update reference_number.qbk

* Update reference_cpp_bin_float.qbk

* Update reference_cpp_double_fp_backend.qbk

* Update reference_internal_support.qbk

* Update reference_backend_requirements.qbk

* Update performance.qbk

* Update performance_overhead.qbk

* Update performance_real_world.qbk

* Update performance_integer_real_world.qbk

* Update performance_rational_real_world.qbk

* Update reference_number.qbk

* Update tutorial_numeric_limits.qbk

* Update reference_backend_requirements.qbk
2025-08-18 13:14:39 +02:00

148 lines
6.8 KiB
Plaintext

[/
Copyright 2011 - 2020 John Maddock.
Copyright 2013 - 2019 Paul A. Bristow.
Copyright 2013 Christopher Kormanyos.
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).
]
[section:interval Interval Number Types]
There is currently only one interval number type supported - [mpfi].
[section:mpfi mpfi_float]
`#include <boost/multiprecision/mpfi.hpp>`
namespace boost{ namespace multiprecision{
template <unsigned Digits10>
class mpfi_float_backend;
typedef number<mpfi_float_backend<50> > mpfi_float_50;
typedef number<mpfi_float_backend<100> > mpfifloat_100;
typedef number<mpfi_float_backend<500> > mpfifloat_500;
typedef number<mpfi_float_backend<1000> > mpfi_float_1000;
typedef number<mpfi_float_backend<0> > mpfi_float;
}} // namespaces
The `mpfi_float_backend` type is used in conjunction with `number`: It acts as a thin wrapper around the [mpfi] `mpfi_t`
to provide a real-number type that is a drop-in replacement for the native C++ floating-point types, but with
much greater precision and implementing interval arithmetic.
Type `mpfi_float_backend` can be used at fixed precision by specifying a non-zero `Digits10` template parameter, or
at variable precision by setting the template argument to zero. The `typedef`s `mpfi_float_50`, `mpfi_float_100`,
`mpfi_float_500`, `mpfi_float_1000` provide arithmetic types at 50, 100, 500 and 1000 decimal digits precision
respectively. The `typedef mpfi_float` provides a variable precision type whose precision can be controlled via the
`number`s member functions.
[note This type only provides `numeric_limits` support when the precision is fixed at compile time.]
As well as the usual conversions from arithmetic and string types, instances of `number<mpfi_float_backend<N> >` are
copy constructible and assignable from:
* The [mpfi] native type `mpfi_t`.
* The `number` wrappers around [mpfi] or [mpfr]: `number<mpfi_float_backend<M> >` and `number<mpfr_float<M> >`.
* There is a two argument constructor taking two `number<mpfr_float<M> >` arguments specifying the interval.
It's also possible to access the underlying `mpfi_t` via the `data()` member function of `mpfi_float_backend`.
Things you should know when using this type:
* A default constructed `mpfi_float_backend` is set to zero (['Note that this is [*not] the default [mpfi] behavior]).
* No changes are made to [gmp] or [mpfr] global settings, so this type can coexist with existing
[mpfr] or [gmp] code.
* The code can equally use [mpir] in place of [gmp] - indeed that is the preferred option on Win32.
* This backend supports rvalue-references and is move-aware, making instantiations of `number` on this backend move aware.
* Conversion from a string results in a `std::runtime_error` being thrown if the string can not be interpreted
as a valid floating-point number.
* Division by zero results in an infinity.
There are some additional non member functions for working on intervals:
template <unsigned Digits10, expression_template_option ExpressionTemplates>
number<mpfr_float_backend<Digits10>, ExpressionTemplates> lower(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& val);
Returns the lower end of the interval.
template <unsigned Digits10, expression_template_option ExpressionTemplates>
number<mpfr_float_backend<Digits10>, ExpressionTemplates> upper(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& val);
Returns the upper end of the interval.
template <unsigned Digits10, expression_template_option ExpressionTemplates>
number<mpfr_float_backend<Digits10>, ExpressionTemplates> median(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& val);
Returns the mid point of the interval.
template <unsigned Digits10, expression_template_option ExpressionTemplates>
number<mpfr_float_backend<Digits10>, ExpressionTemplates> width(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& val);
Returns the absolute width of the interval.
template <unsigned Digits10, expression_template_option ExpressionTemplates>
number<mpfi_float_backend<Digits10>, ExpressionTemplates> intersect(
const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a,
const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& b);
Returns the interval which is the intersection of the ['a] and ['b]. Returns an
unspecified empty interval if there is no such intersection.
template <unsigned Digits10, expression_template_option ExpressionTemplates>
number<mpfi_float_backend<Digits10>, ExpressionTemplates> hull(
const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a,
const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& b);
Returns the interval which is the union of ['a] and ['b].
template <unsigned Digits10, expression_template_option ExpressionTemplates>
bool overlap(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a,
const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& b);
Returns `true` only if the intervals ['a] and ['b] overlap.
template <unsigned Digits10, expression_template_option ExpressionTemplates1, expression_template_option ExpressionTemplates2>
bool in(const number<mpfr_float_backend<Digits10>, ExpressionTemplates1>& a,
const number<mpfi_float_backend<Digits10>, ExpressionTemplates2>& b);
Returns `true` only if point ['a] is contained within the interval ['b].
template <unsigned Digits10, expression_template_option ExpressionTemplates>
bool zero_in(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a);
Returns `true` only if the interval ['a] contains the value zero.
template <unsigned Digits10, expression_template_option ExpressionTemplates>
bool subset(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a,
const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& b);
Returns `true` only if ['a] is a subset of ['b].
template <unsigned Digits10, expression_template_option ExpressionTemplates>
bool proper_subset(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a,
const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& b);
Returns `true` only if ['a] is a proper subset of ['b].
template <unsigned Digits10, expression_template_option ExpressionTemplates>
bool empty(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a);
Returns `true` only if ['a] is an empty interval, equivalent to `upper(a) < lower(a)`.
template <unsigned Digits10, expression_template_option ExpressionTemplates>
bool singleton(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a);
Returns `true` if `lower(a) == upper(a)`.
[h5 [mpfi] example:]
[mpfi_eg]
[endsect] [section:mpfi mpfi_float]
[endsect] [/section:interval Interval Number Types]