The SKIRT project
advanced radiative transfer for astrophysics
Range Class Reference

#include <Range.hpp>

Public Member Functions

constexpr Range ()
constexpr Range (double min, double max)
bool contains (const Range &range) const
bool contains (double x) const
bool containsFuzzy (double x, double eps=1e-14) const
bool empty () const
Rangeextend (const Range &range)
Rangeextend (double x)
RangeextendWithRedshift (double z)
Rangeintersect (const Range &range)
double max () const
double mid () const
double min () const
void set (double min, double max)
double width () const

Protected Attributes

double _max
double _min

Detailed Description

Range is a low-level class for working with ranges: each instance represents a range with a minimum and maximum value. The class is fully implemented inline (in this header file). Most compilers optimize away all overhead so that using this class is just as efficient as directly writing the code in terms of the range components.

Constructor & Destructor Documentation

◆ Range() [1/2]

Range::Range ( )
inlineconstexpr

This is the default constructor; the minimum and maximum values are initialized to zero.

◆ Range() [2/2]

Range::Range ( double min,
double max )
inlineconstexpr

This constructor initializes the range to the minimum and maximum values provided as arguments.

Member Function Documentation

◆ contains() [1/2]

bool Range::contains ( const Range & range) const
inline

This function returns true if the given range is inside the receiving range, and false otherwise.

◆ contains() [2/2]

bool Range::contains ( double x) const
inline

This function returns true if the given value is inside the range, and false otherwise.

◆ containsFuzzy()

bool Range::containsFuzzy ( double x,
double eps = 1e-14 ) const
inline

This function returns true if the given value is inside the range, with the given fuzzyness factor, and false otherwise.

◆ empty()

bool Range::empty ( ) const
inline

This function returns true if the range is empty (its minimum is larger than or equal to its maximum), and false otherwise.

◆ extend() [1/2]

Range & Range::extend ( const Range & range)
inline

This function updates the range so that it represents the union of the original range with the other range given as an argument. If the two ranges do not overlap, the resulting range will include the interval between the input ranges.

◆ extend() [2/2]

Range & Range::extend ( double x)
inline

This function updates the range so that it includes the specified value.

◆ extendWithRedshift()

Range & Range::extendWithRedshift ( double z)
inline

This function extends the range with a factor of (1+z) on each side.

◆ intersect()

Range & Range::intersect ( const Range & range)
inline

This function updates the range so that it represents the intersection of the original range with the other range given as an argument. If the two ranges do not overlap, the resulting range will have a minimum larger than or equal to its maximum.

◆ max()

double Range::max ( ) const
inline

This function returns the maximum value of the range.

◆ mid()

double Range::mid ( ) const
inline

This function returns the middle value of the range.

◆ min()

double Range::min ( ) const
inline

This function returns the minimum value of the range.

◆ set()

void Range::set ( double min,
double max )
inline

This function sets the range to the minimum and maximum values provided as arguments.

◆ width()

double Range::width ( ) const
inline

This function returns the width of the range, i.e. the maximum value minus the minimum value.


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