polynomials_on_simplices.calculus.real_interval module

Functionality for working with intervals on the real line.

constrain_to_range(s, min_val, max_val)[source]

Make sure that a value lies in the given (closed) range.

Parameters:
  • s – Value to check.
  • min_val – Lower boundary of the interval.
  • max_val – Upper boundary of the interval.
Returns:

Point closest to the input value which lies in the given range.

Return type:

float

equivalent_periodic_element(a, t)[source]

Get the equivalent scalar in [0, T) for an input scalar a, where two scalars are equivalent if they differ by an integer translation of T.

I.e. consider the equivalence relation \(a ~ b \leftrightarrow b = a + n \cdot T, n \in \mathbb{Z}\), then given a this function returns the unique element b in [0, T) such that a ~ b.

Parameters:
  • a (float) – Input scalar in \((-\infty, \infty)\).
  • t (float) – Period T.
Returns:

Equivalent element b in [0, T).

Return type:

float

in_closed_range(s, min_val, max_val)[source]

Check if a value lies in the closed interval [min_val, max_val].

Parameters:
  • s – Value to check.
  • min_val – Lower boundary of the interval.
  • max_val – Upper boundary of the interval.
Returns:

True/False whether or not the value lies in the closed interval.

Return type:

bool

in_left_closed_range(s, min_val, max_val)[source]

Check if a value lies in the left-closed interval [min_val, max_val).

Parameters:
  • s – Value to check.
  • min_val – Lower boundary of the interval.
  • max_val – Upper boundary of the interval.
Returns:

True/False whether or not the value lies in the left-closed interval.

Return type:

bool

in_open_range(s, min_val, max_val)[source]

Check if a value lies in the open interval (min_val, max_val).

Parameters:
  • s – Value to check.
  • min_val – Lower boundary of the interval.
  • max_val – Upper boundary of the interval.
Returns:

True/False whether or not the value lies in the open interval.

Return type:

bool

in_right_closed_range(s, min_val, max_val)[source]

Check if a value lies in the right-closed interval (min_val, max_val].

Parameters:
  • s – Value to check.
  • min_val – Lower boundary of the interval.
  • max_val – Upper boundary of the interval.
Returns:

True/False whether or not the value lies in the right-closed interval.

Return type:

bool