sigma  1.0.0
Loading...
Searching...
No Matches
general_convert.hpp File Reference

Conversions between sigma::GeneralInterval and the boost interval its closure wraps. More...

#include "sigma/interval/detail_/convert.hpp"
#include "sigma/interval/general_interval.hpp"
#include <stdexcept>
#include <string>

Go to the source code of this file.

Namespaces

namespace  sigma
 The primary namespace for the sigma library.
namespace  sigma::detail_
 The namespace that contains the implementation details of the library.

Functions

template<typename T>
boost_interval_t< T > sigma::detail_::to_boost_ (const GeneralInterval< T > &a)
 Convert a sigma::GeneralInterval into a boost interval.
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<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.

Detailed Description

Conversions between sigma::GeneralInterval and the boost interval its closure wraps.

The elementary functions of a GeneralInterval hand the bounds to boost, exactly as those of an Interval do, and then restore the openness of the bounds, which boost does not track.

Note
On openness. Each caller states what the openness of the result should be:
  • For a monotonically increasing function the bounds of the result come from the bounds of the input, so the input's openness carries over unchanged.
  • For a monotonically decreasing function the bounds swap, and so does their openness.
  • When a bound comes from an interior extremum (the maximum of cos, the minimum of cosh) or from a clamp (the 0 of sqrt, the \( \pm\pi/2 \) of asin), it does not correspond to an input bound at all. Such a bound is reported closed: the value really is attained, and in the cases where it is not, a closed bound is a superset of an open one and therefore still a valid enclosure.