AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
probfd::Interval Struct Reference

#include "probfd/interval.h"

Description

Represents a closed interval over the extended reals as a pair of lower and upper bound.

Public Member Functions

 Interval (value_t val=0_vt)
 Constructs an interval consisting of a single point p.
 
 Interval (value_t lb, value_t ub)
 Constructs an interval from a specified lower and upper bound.
 
Intervaloperator+= (Interval rhs)
 Equivalent to *this = *this + rhs.
 
Intervaloperator*= (value_t scale_factor)
 Equivalent to *this = factor * (*this)
 
double length () const
 Returns the length of the interval. If both bounds are infinity and have the same sign, returns 0.
 
bool bounds_approximately_equal (value_t tolerance=g_epsilon) const
 Checks if the length is below a given tolerance.
 

Public Attributes

value_t lower
 The Lower bound of the interval.
 
value_t upper
 The upper bound of the interval.
 

Constructor & Destructor Documentation

◆ Interval() [1/2]

probfd::Interval::Interval ( value_t val = 0_vt)
explicit

Constructs an interval consisting of a single point p.

◆ Interval() [2/2]

probfd::Interval::Interval ( value_t lb,
value_t ub )
explicit

Constructs an interval from a specified lower and upper bound.

Member Function Documentation

◆ operator+=()

Interval & probfd::Interval::operator+= ( Interval rhs)

Equivalent to *this = *this + rhs.

◆ operator*=()

Interval & probfd::Interval::operator*= ( value_t scale_factor)

Equivalent to *this = factor * (*this)

◆ length()

double probfd::Interval::length ( ) const
nodiscard

Returns the length of the interval. If both bounds are infinity and have the same sign, returns 0.

◆ bounds_approximately_equal()

bool probfd::Interval::bounds_approximately_equal ( value_t tolerance = g_epsilon) const
nodiscard

Checks if the length is below a given tolerance.

See also
Interval::length()

Member Data Documentation

◆ lower

value_t probfd::Interval::lower

The Lower bound of the interval.

◆ upper

value_t probfd::Interval::upper

The upper bound of the interval.