sigma  1.0.0
Loading...
Searching...
No Matches
sigma::detail_ Namespace Reference

The namespace that contains the implementation details of the library. More...

Classes

struct  rounded_transc_guarded
 Outward rounding for the transcendental functions. More...
class  Setter
 Modifies an unceratin variable. More...

Typedefs

template<typename T>
using interval_policies_t
 The policies the boost interval underlying sigma::Interval uses.
template<typename T>
using boost_interval_t = boost::numeric::interval<T, interval_policies_t<T>>
 The boost interval type sigma::Interval wraps.

Functions

template<typename T>
boost_interval_t< T > to_boost_ (const Interval< T > &a)
 Convert a sigma::Interval into the boost interval it wraps.
template<typename T>
Interval< T > from_boost_ (const boost_interval_t< T > &x)
 Convert a boost interval into a sigma::Interval.
template<typename T>
void assert_within_unit_ (const Interval< T > &a, bool open, const std::string &name)
 Throws unless every value in a lies in the unit interval.
template<typename T>
boost_interval_t< T > to_boost_ (const GeneralInterval< T > &a)
 Convert a sigma::GeneralInterval into a boost interval.
template<typename T>
GeneralInterval< T > general_from_boost_ (const boost_interval_t< T > &x, bool left_open=false, bool right_open=false)
 Convert a boost interval into a sigma::GeneralInterval.
template<typename T>
void assert_within_unit_ (const GeneralInterval< T > &a, bool open, const std::string &name)
 Throws unless every value in a lies in the unit interval.
template<typename T>
std::pair< bool, bool > integer_pow_openness_ (const GeneralInterval< T > &a, long long n)
 The openness of the bounds of pow(a, n) for a positive integer n.
template<typename T, typename U>
boost_interval_t< T > exponent_interval_ (const U &exp)
 The exponent of a non-integer pow(), as an interval.
template<typename IntervalType>
Triplex< IntervalType > make_triplex_ (IntervalType bounds, typename IntervalType::value_t nominal)
 Assembles a triplex from the result of an operation.
template<typename IntervalType, typename BoundsFunction, typename NominalFunction>
Triplex< IntervalType > apply_unary_ (const Triplex< IntervalType > &a, BoundsFunction &&bounds_fxn, NominalFunction &&nominal_fxn)
 Applies a unary function to a triplex.
template<typename T>
void inplace_unary (Uncertain< T > &c, T mean, T dcda)
 Generalized Inplace Unary Changes.
template<typename T>
Uncertain< T > unary_result (const Uncertain< T > &a, T mean, T dcda)
 Generalized Unary Changes.
template<typename T>
void inplace_binary (Uncertain< T > &c, const Uncertain< T > &b, T mean, T dcda, T dcdb)
 Generalized Inplace Binary Changes.
template<typename FunctionType, typename NumericType>
NumericType numeric_derivative (FunctionType f, NumericType a)
 Compute the numeric derivative of a function.

Variables

constexpr double pi = 3.14159265358979323846
 Value of Pi.

Detailed Description

The namespace that contains the implementation details of the library.

This is the namespace details not intended for user interaction.

Typedef Documentation

◆ interval_policies_t

template<typename T>
using sigma::detail_::interval_policies_t
Initial value:
boost::numeric::interval_lib::policies<
boost::numeric::interval_lib::save_state<rounded_transc_guarded<T>>,
boost::numeric::interval_lib::checking_base<T>>

The policies the boost interval underlying sigma::Interval uses.

Two deviations from boost's defaults:

  • The rounding policy is rounded_transc_guarded, so the transcendental functions of boost/numeric/interval/transc.hpp are available at all, and outwardly rounded when they are used. It extends, rather than replaces, the rounded_arith_opp arithmetic boost defaults to.
  • The checking policy is checking_base rather than boost's default checking_strict. checking_strict inherits checking_no_empty, whose empty_lower() throws, and boost's log()/sqrt()/asin() signal a domain violation by returning an empty interval. checking_base lets that empty interval come back as a value, which sigma::Interval then maps onto its own representation of the empty set.
Template Parameters
TThe floating point type of the bounds.

Function Documentation

◆ apply_unary_()

template<typename IntervalType, typename BoundsFunction, typename NominalFunction>
Triplex< IntervalType > sigma::detail_::apply_unary_ ( const Triplex< IntervalType > & a,
BoundsFunction && bounds_fxn,
NominalFunction && nominal_fxn )

Applies a unary function to a triplex.

Code factorization for the elementary functions.

Template Parameters
IntervalTypeThe interval type of the triplex.
BoundsFunctionThe type of a callable taking an IntervalType and returning an IntervalType.
NominalFunctionThe type of a callable taking a value_t and returning something convertible to value_t.
Parameters
[in]aThe argument.
[in]bounds_fxnComputes the bounds of the result from those of a.
[in]nominal_fxnComputes the nominal value of the result from that of a.
Returns
The function applied to a.
Exceptions
std::domain_errorif bounds_fxn rejects the bounds of a. Strong throw guarantee.

◆ assert_within_unit_() [1/2]

template<typename T>
void sigma::detail_::assert_within_unit_ ( const GeneralInterval< T > & a,
bool open,
const std::string & name )

Throws unless every value in a lies in the unit interval.

The openness-aware counterpart of the Interval overload. Whether a bound at plus or minus one is in domain depends on both open and the openness of that bound, since an open bound is not a value the interval contains: \( (-1, 1) \) is an acceptable argument to the inverse hyperbolic tangent, and \( [-1, 1] \) is not.

Template Parameters
TThe value type of the interval.
Parameters
[in]aThe interval to check. Must not be empty.
[in]openIs the domain the open unit interval? False for the closed one.
[in]nameThe name of the function being checked, for the error message.
Exceptions
std::domain_errorif a contains a value outside the domain. Strong throw guarantee.
std::domain_errorif a is empty. Strong throw guarantee.

◆ assert_within_unit_() [2/2]

template<typename T>
void sigma::detail_::assert_within_unit_ ( const Interval< T > & a,
bool open,
const std::string & name )

Throws unless every value in a lies in the unit interval.

Code factorization for the three functions whose domain is the unit interval: arcsine and arccosine take the closed \( [-1, 1] \), and the inverse hyperbolic tangent the open \( (-1, 1) \). The bounds of a are members of it, so for the open domain a bound at plus or minus one is out of domain.

Template Parameters
TThe value type of the interval.
Parameters
[in]aThe interval to check. Must not be empty.
[in]openIs the domain the open unit interval? False for the closed one.
[in]nameThe name of the function being checked, for the error message.
Exceptions
std::domain_errorif a contains a value outside the domain. Strong throw guarantee.
std::domain_errorif a is empty. Strong throw guarantee.

◆ exponent_interval_()

template<typename T, typename U>
boost_interval_t< T > sigma::detail_::exponent_interval_ ( const U & exp)

The exponent of a non-integer pow(), as an interval.

Converting exp to the interval's value type may not be exact, e.g., when a double exponent is applied to an IFloat. When it is not, the exponent is widened to the pair of representable values bracketing it so the enclosure remains valid.

Template Parameters
TThe value type of the interval.
UThe numeric type of the exponent.
Parameters
[in]expThe exponent to convert.
Returns
An interval containing exp.
Exceptions
noneNo throw guarantee.

◆ from_boost_()

template<typename T>
Interval< T > sigma::detail_::from_boost_ ( const boost_interval_t< T > & x)

Convert a boost interval into a sigma::Interval.

Template Parameters
TThe value type of the interval.
Parameters
[in]xThe interval to convert.
Returns
An interval with the bounds of x. An empty boost interval, which is how boost signals that a function was given an argument outside its domain, converts to the empty sigma::Interval.
Exceptions
noneNo throw guarantee.

◆ general_from_boost_()

template<typename T>
GeneralInterval< T > sigma::detail_::general_from_boost_ ( const boost_interval_t< T > & x,
bool left_open = false,
bool right_open = false )

Convert a boost interval into a sigma::GeneralInterval.

Template Parameters
TThe value type of the interval.
Parameters
[in]xThe interval to convert.
[in]left_openShould the lower bound of the result be open?
[in]right_openShould the upper bound of the result be open?
Returns
An interval with the bounds of x and the requested openness. An empty boost interval converts to the empty sigma::GeneralInterval. An infinite bound is always open, regardless of what the caller requested, since it is not a value the interval contains.
Exceptions
noneNo throw guarantee.

◆ inplace_binary()

template<typename T>
void sigma::detail_::inplace_binary ( Uncertain< T > & c,
const Uncertain< T > & b,
T mean,
T dcda,
T dcdb )

Generalized Inplace Binary Changes.

Template Parameters
TThe value type of the variable
Parameters
cThe variable being altered
bThe variable whose dependencies are being added to c's
meanThe new mean value of the variable
dcdaThe partial derivative being added to the chain from a
dcdbThe partial derivative being added to the chain from b
Exceptions
noneNo throw guarantee

◆ inplace_unary()

template<typename T>
void sigma::detail_::inplace_unary ( Uncertain< T > & c,
T mean,
T dcda )

Generalized Inplace Unary Changes.

Template Parameters
TThe value type of the variable
Parameters
cThe variable being altered
meanThe new mean value of the variable
dcdaThe partial derivative being added to the chain
Exceptions
noneNo throw guarantee

◆ integer_pow_openness_()

template<typename T>
std::pair< bool, bool > sigma::detail_::integer_pow_openness_ ( const GeneralInterval< T > & a,
long long n )

The openness of the bounds of pow(a, n) for a positive integer n.

Mirrors the case analysis boost::numeric::pow performs on the sign of the bounds, since it is that analysis which decides where the bounds of the result come from.

Template Parameters
TThe value type of the interval.
Parameters
[in]aThe base. Must not be empty.
[in]nThe exponent. Must be positive.
Returns
The openness of the lower and upper bound, respectively.
Exceptions
std::domain_errorif a is empty. Strong throw guarantee.

◆ make_triplex_()

template<typename IntervalType>
Triplex< IntervalType > sigma::detail_::make_triplex_ ( IntervalType bounds,
typename IntervalType::value_t nominal )

Assembles a triplex from the result of an operation.

Every operation on a triplex computes its bounds and its nominal value separately and then hands them to this function, which applies the widening rule: a finite nominal that is not a member of bounds widens bounds to include it. The nominal value itself is never moved. A non-finite nominal is kept as is and bounds are left alone, so the result does not satisfy the class invariant, which is exactly what happens in ordinary floating point.

Template Parameters
IntervalTypeThe interval type of the triplex.
Parameters
[in]boundsThe bounds the interval operation produced.
[in]nominalThe nominal value the scalar operation produced.
Returns
The triplex with nominal value nominal and bounds bounds, widened if needed.
Exceptions
noneNo throw guarantee.

◆ numeric_derivative()

template<typename FunctionType, typename NumericType>
NumericType sigma::detail_::numeric_derivative ( FunctionType f,
NumericType a )

Compute the numeric derivative of a function.

Template Parameters
FunctionTypeThe type of the function f
NumericTypeThe numeric type of a
Parameters
fThe function whose derivative is computed
aThe value aroud which the derivative of f is computed
Returns
The derivative of f evaluated at a.
Exceptions
noneNo throw guarantee

◆ to_boost_() [1/2]

template<typename T>
boost_interval_t< T > sigma::detail_::to_boost_ ( const GeneralInterval< T > & a)

Convert a sigma::GeneralInterval into a boost interval.

Template Parameters
TThe value type of the interval.
Parameters
[in]aThe interval to convert. Must not be empty.
Returns
A boost interval with the same bounds as a. The openness of a's bounds is not represented in the result.
Exceptions
std::domain_errorif a is empty. Strong throw guarantee.

◆ to_boost_() [2/2]

template<typename T>
boost_interval_t< T > sigma::detail_::to_boost_ ( const Interval< T > & a)

Convert a sigma::Interval into the boost interval it wraps.

Template Parameters
TThe value type of the interval.
Parameters
[in]aThe interval to convert. Must not be empty.
Returns
A boost interval with the same bounds as a.
Exceptions
std::domain_errorif a is empty. Strong throw guarantee.

◆ unary_result()

template<typename T>
Uncertain< T > sigma::detail_::unary_result ( const Uncertain< T > & a,
T mean,
T dcda )

Generalized Unary Changes.

Template Parameters
TThe value type of the variable
Parameters
aThe variable being altered copied
meanThe new mean value of the variable
dcdaThe partial derivative being added to the chain
Returns
A variable with the new mean value and the dependencies of a altered by dcda.
Exceptions
noneNo throw guarantee