|
sigma
1.0.0
|
Implements affine arithmetic that drops negligible error terms. More...
#include <thresholded_affine.hpp>
Classes | |
| struct | Threshold |
| Tag type used to pass the relative threshold to constructors. More... | |
Public Types | |
| using | size_type = std::size_t |
| Type used for indexing and offsets. | |
| using | value_t = ValueType |
| Type used for storing floating point values. | |
| using | error_term_t = typename Affine<ValueType>::error_term_t |
| Opaque type used to store error term information. | |
| using | error_terms_t = typename Affine<ValueType>::error_terms_t |
| Type used to map error terms to their radii. | |
| using | interval_t = typename Affine<ValueType>::interval_t |
| Type of an interval. | |
| using | affine_t = Affine<ValueType> |
| Type of the underlying Affine form. | |
Public Member Functions | |
| ThresholdedAffine () | |
| Constructs an empty ThresholdedAffine. | |
| ThresholdedAffine (value_t center, Threshold t=default_threshold()) | |
| Constructs a ThresholdedAffine from a center value. | |
| ThresholdedAffine (value_t lo, value_t hi, Threshold t=default_threshold()) | |
| Constructs a ThresholdedAffine from a lower and upper bound. | |
| ThresholdedAffine (const interval_t &interval, Threshold t=default_threshold()) | |
| Constructs a ThresholdedAffine from an interval. | |
| ThresholdedAffine (value_t center, error_terms_t radii, Threshold t=default_threshold()) | |
| Constructs a ThresholdedAffine from a center and error terms. | |
| ThresholdedAffine (affine_t a, value_t threshold) | |
| Constructs a ThresholdedAffine by wrapping an Affine form. | |
| ThresholdedAffine (const ThresholdedAffine &other)=default | |
| Copy constructor. | |
| ThresholdedAffine (ThresholdedAffine &&other) noexcept=default | |
| Move constructor. | |
| ThresholdedAffine & | operator= (const ThresholdedAffine &other)=default |
| Copy assignment operator. | |
| ThresholdedAffine & | operator= (ThresholdedAffine &&other) noexcept=default |
| Move assignment operator. | |
| interval_t | range () const |
| Returns the interval represented by *this. | |
| value_t | center () const |
| Returns the center of the affine form. | |
| const error_terms_t & | error_terms () const |
| Returns the error terms of the tracked affine form. | |
| value_t | radius () const |
| Returns the total radius: the sum of the tracked terms. | |
| void | set_center (value_t c) |
| Sets the center of the affine form. | |
| void | add_error_term (error_term_t error_term, value_t r) |
| Adds an error term to the affine form and applies thresholding. | |
| bool | contains (value_t v) const |
Returns whether *this contains a scalar value v. | |
| bool | contains (const interval_t &i) const |
| Returns whether *this contains an interval. | |
| bool | contains (const ThresholdedAffine &other) const |
| Returns whether *this contains another ThresholdedAffine's range. | |
| bool | empty () const noexcept |
| Returns whether *this is empty. | |
| std::string | print_affine_form () const |
| Returns a string of the affine form (tracked terms only). | |
| std::string | print_interval_form () const |
| Returns a string of the interval form. | |
| const affine_t & | affine () const |
| Returns the underlying Affine form (tracked terms only). | |
| value_t | threshold () const |
| Returns the relative threshold. | |
| ThresholdedAffine | operator- () const |
| Returns the additive inverse of *this. | |
| ThresholdedAffine & | operator+= (value_t value) |
| Adds a scalar to *this. | |
| ThresholdedAffine & | operator+= (const ThresholdedAffine &other) |
| Adds another ThresholdedAffine to *this. | |
| ThresholdedAffine | operator+ (value_t value) const |
| Returns the sum of *this and a scalar. | |
| ThresholdedAffine | operator+ (const ThresholdedAffine &other) const |
| Returns the sum of *this and another ThresholdedAffine. | |
| ThresholdedAffine & | operator-= (value_t value) |
| Subtracts a scalar from *this. | |
| ThresholdedAffine & | operator-= (const ThresholdedAffine &other) |
| Subtracts another ThresholdedAffine from *this. | |
| ThresholdedAffine | operator- (value_t value) const |
| Returns the difference of *this and a scalar. | |
| ThresholdedAffine | operator- (const ThresholdedAffine &other) const |
| Returns the difference of *this and another ThresholdedAffine. | |
| ThresholdedAffine & | operator*= (value_t value) |
| Multiplies *this by a scalar. | |
| ThresholdedAffine & | operator*= (const ThresholdedAffine &other) |
| Multiplies *this by another ThresholdedAffine. | |
| ThresholdedAffine | operator* (value_t value) const |
| Multiplies *this by a scalar. | |
| ThresholdedAffine | operator* (const ThresholdedAffine &other) const |
| Multiplies *this by another ThresholdedAffine. | |
| ThresholdedAffine & | operator/= (value_t value) |
| Divides *this by a scalar. | |
| ThresholdedAffine & | operator/= (const ThresholdedAffine &other) |
| Divides *this by another ThresholdedAffine. | |
| ThresholdedAffine | operator/ (value_t value) const |
| Divides *this by a scalar. | |
| ThresholdedAffine | operator/ (const ThresholdedAffine &other) const |
| Divides *this by another ThresholdedAffine. | |
| bool | operator== (const ThresholdedAffine &other) const |
| Checks equality of two ThresholdedAffine forms. | |
| bool | operator!= (const ThresholdedAffine &other) const |
| Checks inequality of two ThresholdedAffine forms. | |
Static Public Member Functions | |
| static constexpr Threshold | default_threshold () |
| Returns the default threshold value. | |
Related Symbols | |
(Note that these are not member symbols.) | |
| template<typename ValueType> | |
| std::ostream & | operator<< (std::ostream &os, const ThresholdedAffine< ValueType > &a) |
| Outputs the range of a ThresholdedAffine to a stream. | |
| template<typename ValueType> | |
| ThresholdedAffine< ValueType > | operator* (ValueType value, const ThresholdedAffine< ValueType > &a) |
| Multiplies a scalar by a ThresholdedAffine. | |
| template<typename T> | |
| ThresholdedAffine< T > | abs (const ThresholdedAffine< T > &a) |
| Absolute value of a ThresholdedAffine. | |
| template<typename T> | |
| ThresholdedAffine< T > | fabs (const ThresholdedAffine< T > &a) |
| Absolute value of a ThresholdedAffine (alias for abs). | |
| template<typename T> | |
| ThresholdedAffine< T > | sqrt (const ThresholdedAffine< T > &a) |
| Square root of a ThresholdedAffine. | |
| template<typename T> | |
| ThresholdedAffine< T > | exp (const ThresholdedAffine< T > &a) |
| Exponential of a ThresholdedAffine. | |
| template<typename T> | |
| ThresholdedAffine< T > | log (const ThresholdedAffine< T > &a) |
| Natural logarithm of a ThresholdedAffine. | |
| template<typename T, typename U> | |
| ThresholdedAffine< T > | pow (const ThresholdedAffine< T > &a, const U &exp) |
| Power of a ThresholdedAffine. | |
Implements affine arithmetic that drops negligible error terms.
| ValueType | The numeric type of the center and error term radii. |
ThresholdedAffine extends standard affine arithmetic with a mechanism to control the number of error symbols carried in an affine form. Each non-affine operation can introduce new error symbols (e.g. multiplication creates a nonlinearity symbol); without pruning, the symbol count grows unboundedly.
This class reduces symbol count by deleting error terms whose relative contribution falls below the threshold. Dropped terms are simply discarded; no separate "lump" radius is retained to account for them.
Constructors accept a Threshold tag type to distinguish the threshold parameter from ordinary value parameters and avoid constructor ambiguity.
|
inline |
Constructs an empty ThresholdedAffine.
The resulting ThresholdedAffine represents the empty set and the threshold is set to the default value.
| none | No throw guarantee |
|
inlineexplicit |
Constructs a ThresholdedAffine from a center value.
| [in] | center | The center value. |
| [in] | t | The relative threshold, defaults to default_threshold(). |
| none | No throw guarantee |
|
inline |
Constructs a ThresholdedAffine from a lower and upper bound.
| [in] | lo | The lower bound. |
| [in] | hi | The upper bound. |
| [in] | t | The relative threshold, defaults to default_threshold(). |
| std::bad_alloc | If memory allocation for the error term fails. |
|
inlineexplicit |
Constructs a ThresholdedAffine from an interval.
| [in] | interval | The interval. |
| [in] | t | The relative threshold, defaults to default_threshold(). |
| std::bad_alloc | If memory allocation for the error term fails. |
|
inline |
Constructs a ThresholdedAffine from a center and error terms.
| [in] | center | The center value. |
| [in] | radii | Map of error symbols to their radii. |
| [in] | t | The relative threshold, defaults to default_threshold(). |
| none | No throw guarantee |
|
inline |
Constructs a ThresholdedAffine by wrapping an Affine form.
Used internally by operations that produce an Affine result and need to re-wrap it as a ThresholdedAffine.
| std::bad_alloc | If memory allocation for the error term fails. Strong throw guarantee. |
|
default |
Copy constructor.
| [in] | other | The ThresholdedAffine to copy. |
| std::bad_alloc | If memory allocation for the error terms fails. Strong throw guarantee. |
|
defaultnoexcept |
Move constructor.
| [in] | other | The ThresholdedAffine to move. |
| none | No throw guarantee |
|
inline |
Adds an error term to the affine form and applies thresholding.
| [in] | error_term | The error symbol. |
| [in] | r | The radius of the new term. |
| None | No throw guarantee. |
|
inline |
|
inline |
Returns the center of the affine form.
| std::domain_error | If *this is empty. |
|
inline |
Returns whether *this contains an interval.
| [in] | i | The interval to test. |
i is in range(). | none | No throw guarantee |
|
inline |
Returns whether *this contains another ThresholdedAffine's range.
| [in] | other | The ThresholdedAffine to test. |
| none | No throw guarantee |
|
inline |
Returns whether *this contains a scalar value v.
| [in] | v | The value to test. |
| none | No throw guarantee |
|
inlinestaticconstexpr |
Returns the default threshold value.
| none | No throw guarantee |
|
inlinenoexcept |
Returns whether *this is empty.
| none | No throw guarantee |
|
inline |
Returns the error terms of the tracked affine form.
| None | No throw guarantee. |
|
inline |
Checks inequality of two ThresholdedAffine forms.
| [in] | other | The form to compare. |
| none | No throw guarantee. |
|
inline |
Multiplies *this by another ThresholdedAffine.
Multiplication introduces a new nonlinearity error term via affine arithmetic, after which sub-threshold terms are dropped.
| [in] | other | The form to multiply by. |
| None | No throw guarantee. |
|
inline |
Multiplies *this by a scalar.
| [in] | value | The scalar to multiply by. |
| None | No throw guarantee. |
|
inline |
Adds another ThresholdedAffine to *this.
The tracked affine terms are combined with normal affine addition (shared symbols may cancel), after which sub-threshold terms are dropped.
| [in] | other | The form to add. |
| None | No throw guarantee. |
|
inline |
Adds a scalar to *this.
| [in] | value | The scalar to add. |
| None | No throw guarantee. |
|
inline |
Returns the additive inverse of *this.
Negation flips the tracked affine terms.
| std::bad_alloc | If memory allocation fails. |
|
inline |
Subtracts another ThresholdedAffine from *this.
Tracked affine terms are combined with normal affine subtraction (shared symbols cancel, capturing dependency), after which sub-threshold terms are dropped.
| [in] | other | The form to subtract. |
| None | No throw guarantee. |
|
inline |
Subtracts a scalar from *this.
| [in] | value | The scalar to subtract. |
| None | No throw guarantee. |
|
inline |
Divides *this by another ThresholdedAffine.
Division is performed by affine arithmetic, after which sub-threshold terms are dropped. The divisor's interval must not contain zero.
| [in] | other | The form to divide by. |
| std::domain_error | If other is empty or its interval contains zero. |
|
inline |
Divides *this by a scalar.
| [in] | value | The scalar to divide by. |
| std::domain_error | If value is zero. |
|
default |
Copy assignment operator.
| [in] | other | The ThresholdedAffine to copy. |
| std::bad_alloc | If memory allocation for the error terms fails. Strong throw guarantee. |
|
defaultnoexcept |
Move assignment operator.
| [in] | other | The ThresholdedAffine to move. |
| none | No throw guarantee |
|
inline |
Checks equality of two ThresholdedAffine forms.
| [in] | other | The form to compare. |
| none | No throw guarantee. |
|
inline |
Returns a string of the affine form (tracked terms only).
| std::bad_alloc | If memory allocation for the string fails. Strong throw guarantee. |
|
inline |
Returns a string of the interval form.
| std::bad_alloc |
|
inline |
Returns the total radius: the sum of the tracked terms.
| std::domain_error | If *this is empty. |
|
inline |
|
inline |
Sets the center of the affine form.
| [in] | c | The new center. |
| None | No throw guarantee. |
|
inline |
Returns the relative threshold.
| none | No throw guarantee |
|
Absolute value of a ThresholdedAffine.
| T | The value type. |
|
Exponential of a ThresholdedAffine.
| T | The value type. |
|
Absolute value of a ThresholdedAffine (alias for abs).
| T | The value type. |
|
Natural logarithm of a ThresholdedAffine.
| T | The value type. |
| std::domain_error | If the range contains non-positive values. |
|
Multiplies a scalar by a ThresholdedAffine.
| ValueType | The value type. |
|
Outputs the range of a ThresholdedAffine to a stream.
| ValueType | The value type. |
|
Power of a ThresholdedAffine.
| T | The value type. |
| U | The exponent type. |
| std::domain_error | See Affine::pow for conditions. |
|
Square root of a ThresholdedAffine.
| T | The value type. |
| std::domain_error | If the range contains negative values. |