[/ 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 ` namespace boost{ namespace multiprecision{ template class mpfi_float_backend; typedef number > mpfi_float_50; typedef number > mpfifloat_100; typedef number > mpfifloat_500; typedef number > mpfi_float_1000; typedef number > 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 >` are copy constructible and assignable from: * The [mpfi] native type `mpfi_t`. * The `number` wrappers around [mpfi] or [mpfr]: `number >` and `number >`. * There is a two argument constructor taking two `number >` 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 number, ExpressionTemplates> lower(const number, ExpressionTemplates>& val); Returns the lower end of the interval. template number, ExpressionTemplates> upper(const number, ExpressionTemplates>& val); Returns the upper end of the interval. template number, ExpressionTemplates> median(const number, ExpressionTemplates>& val); Returns the mid point of the interval. template number, ExpressionTemplates> width(const number, ExpressionTemplates>& val); Returns the absolute width of the interval. template number, ExpressionTemplates> intersect( const number, ExpressionTemplates>& a, const number, 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 number, ExpressionTemplates> hull( const number, ExpressionTemplates>& a, const number, ExpressionTemplates>& b); Returns the interval which is the union of ['a] and ['b]. template bool overlap(const number, ExpressionTemplates>& a, const number, ExpressionTemplates>& b); Returns `true` only if the intervals ['a] and ['b] overlap. template bool in(const number, ExpressionTemplates1>& a, const number, ExpressionTemplates2>& b); Returns `true` only if point ['a] is contained within the interval ['b]. template bool zero_in(const number, ExpressionTemplates>& a); Returns `true` only if the interval ['a] contains the value zero. template bool subset(const number, ExpressionTemplates>& a, const number, ExpressionTemplates>& b); Returns `true` only if ['a] is a subset of ['b]. template bool proper_subset(const number, ExpressionTemplates>& a, const number, ExpressionTemplates>& b); Returns `true` only if ['a] is a proper subset of ['b]. template bool empty(const number, ExpressionTemplates>& a); Returns `true` only if ['a] is an empty interval, equivalent to `upper(a) < lower(a)`. template bool singleton(const number, 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]