HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Friends
v1::interval< T > Struct Template Reference

#include <hikogui/numeric/interval.hpp>

Public Types

using value_type = T
 
using bound_type = simd<value_type, 2>
 

Public Member Functions

constexpr interval (interval const &rhs) noexcept=default
 
constexpr interval (interval &&rhs) noexcept=default
 
constexpr intervaloperator= (interval const &rhs) noexcept=default
 
constexpr intervaloperator= (interval &&rhs) noexcept=default
 
constexpr interval () noexcept
 Default construct an interval.
 
constexpr interval (value_type lower, value_type upper) noexcept
 Construct an interval from a lower and upper bounds.
 
constexpr bool holds_invariant () const noexcept
 
constexpr value_type lower () const noexcept
 Get the lower bound of the interval.
 
constexpr value_type upper () const noexcept
 Get the upper bound of the interval.
 
constexpr value_type delta () const noexcept
 The distance between lower and upper bound.
 
constexpr bool is_value () const noexcept
 Check if the interval is one value.
 
constexpr bool is_range () const noexcept
 Check if the interval is a range of values.
 
template<numeric_limited T>
constexpr bool type_contains_range () const noexcept
 Check if a given type can hold all values in the interval.
 
template<numeric_limited T>
constexpr bool range_contains_type () const noexcept
 Check if all the values in a type is inside the interval.
 
 operator bool () const noexcept
 Check if the interval is true.
 
constexpr interval operator- () const noexcept
 
constexpr interval operator+ (interval const &rhs) const noexcept
 
constexpr interval operator- (interval const &rhs) const noexcept
 
constexpr interval operator* (interval const &rhs) const noexcept
 
constexpr interval positive_mul (interval const &rhs) const noexcept
 Multiply two positive intervals.
 
constexpr interval operator/ (interval const &rhs) const noexcept
 
constexpr interval operator% (interval const &rhs) const noexcept
 
intervaloperator+= (interval const &rhs) noexcept
 
intervaloperator-= (interval const &rhs) noexcept
 
intervaloperator*= (interval const &rhs) noexcept
 
constexpr bool is_fully_inside (interval const &other) const noexcept
 Check if the current interval is fully inside the other interval.
 

Static Public Member Functions

static constexpr interval raw (bound_type bounds) noexcept
 Construct an interval from a bound_type value.
 

Data Fields

bound_type v
 

Friends

constexpr interval reciprocal (interval const &rhs) noexcept
 
constexpr interval abs (interval const &rhs) noexcept
 
constexpr interval square (interval const &rhs) noexcept
 
constexpr bool operator== (value_type const &lhs, interval const &rhs) noexcept
 
constexpr auto operator<=> (value_type const &lhs, interval const &rhs) noexcept
 

Detailed Description

template<numeric_limited T>
struct v1::interval< T >

Interval arithmetic.

Based on: "INTERVAL ARITHMETIC USING SSE-2 (DRAFT)" - BRANIMIR LAMBOV

This interval is implemented with a negated upper bound, this allows the rounding direction to negative infinity.

Template Parameters
TA type for which std::numeric_limits<T> is implemented.

Constructor & Destructor Documentation

◆ interval() [1/2]

template<numeric_limited T>
constexpr v1::interval< T >::interval ( )
inlineconstexprnoexcept

Default construct an interval.

The interval includes all values of the value_type.

◆ interval() [2/2]

template<numeric_limited T>
constexpr v1::interval< T >::interval ( value_type lower,
value_type upper )
inlineconstexprnoexcept

Construct an interval from a lower and upper bounds.

Parameters
lowerThe lower bound.
upperThe upper bound.

Member Function Documentation

◆ delta()

template<numeric_limited T>
constexpr value_type v1::interval< T >::delta ( ) const
inlineconstexprnoexcept

The distance between lower and upper bound.

Returns
the difference between the lower and upper bound. Must be always larger or equal to zero.

◆ is_fully_inside()

template<numeric_limited T>
constexpr bool v1::interval< T >::is_fully_inside ( interval< T > const & other) const
inlineconstexprnoexcept

Check if the current interval is fully inside the other interval.

Parameters
otherThe other interval.
Returns
true If this interval is fully inside the other interval.

◆ is_range()

template<numeric_limited T>
constexpr bool v1::interval< T >::is_range ( ) const
inlineconstexprnoexcept

Check if the interval is a range of values.

Returns
true if the delta is greater than zero.

◆ is_value()

template<numeric_limited T>
constexpr bool v1::interval< T >::is_value ( ) const
inlineconstexprnoexcept

Check if the interval is one value.

Returns
true if the delta is zero.

◆ lower()

template<numeric_limited T>
constexpr value_type v1::interval< T >::lower ( ) const
inlineconstexprnoexcept

Get the lower bound of the interval.

Returns
The lower bound.

◆ operator bool()

template<numeric_limited T>
v1::interval< T >::operator bool ( ) const
inlinenoexcept

Check if the interval is true.

Returns
false if both the lower and upper bound are zero.

◆ positive_mul()

template<numeric_limited T>
constexpr interval v1::interval< T >::positive_mul ( interval< T > const & rhs) const
inlineconstexprnoexcept

Multiply two positive intervals.

◆ range_contains_type()

template<numeric_limited T>
template<numeric_limited T>
constexpr bool v1::interval< T >::range_contains_type ( ) const
inlineconstexprnoexcept

Check if all the values in a type is inside the interval.

◆ raw()

template<numeric_limited T>
static constexpr interval v1::interval< T >::raw ( bound_type bounds)
inlinestaticconstexprnoexcept

Construct an interval from a bound_type value.

Parameters
boundsThe bounds x=lower, y=-upper.
Returns
An interval.

◆ type_contains_range()

template<numeric_limited T>
template<numeric_limited T>
constexpr bool v1::interval< T >::type_contains_range ( ) const
inlineconstexprnoexcept

Check if a given type can hold all values in the interval.

◆ upper()

template<numeric_limited T>
constexpr value_type v1::interval< T >::upper ( ) const
inlineconstexprnoexcept

Get the upper bound of the interval.

Returns
The upper bound.

The documentation for this struct was generated from the following file: