Skip to content

jitx/interval

Package name: jitx/interval

Interval Type

The Interval type is a mechanism for defining inclusive ranges of values. The Interval doesn't have a typical value like Toleranced but does allow infinite intervals which Toleranced does not allow.

An example of an Interval might be the operating temperature range for a design. The typical is not generally specified in datasheets because it is application specific.

References

  • https://en.wikipedia.org/wiki/Interval_arithmetic

Summary

Interval

Interval Type for defining ranges over the Double

Multis

Function Description
min-value? Minimum Value of the range.
max-value? Maximum Value of the range

Functions

Function Description
AnyNumber Unbounded Interval
Interval Constructor for an Interval type.
AtLeast Interval with unbounded maximum and bounded minimum
AtMost Interval with unbounded minimum and bounded maximum

Definitions

Interval

Interval Type for defining ranges over the Double

public deftype Interval <: Equalable & Hashable

This type provides a mechanism to support limited and unlimited ranges. Possible configurations are:

  1. Restricted Ranges:
    1. Defined min and max - restricts the interval to a range.
      1. min is expected to be less than max
      2. This range is inclusive of the end points.
  2. Unrestricted Ranges:
    1. Defined min but no max - This is the AtLeast form.
      1. This form is inclusive of the min value.
    2. Defined max but no min - This is the AtMost form.
      1. This form is inclusive of the max value.
    3. Neither min nor max - This is the AnyNumber form.
      1. This is effectively an infinite interval.

There is no "typical" value for an interval. See Toleranced for a treatment with a "typical" value.

Multis

min-value?

Minimum Value of the range.

public defmulti min-value? (ivl:Interval) -> Double|False

  • Returns Double|False

If this value is false then the range is unbounded on the low end. All implementations of Interval are expected to implement this interface.

max-value?

Maximum Value of the range

public defmulti max-value? (ivl:Interval) -> Double|False

  • Returns Double|False

If this value is false then the range is unbounded on the high end. All implementations of Interval are expected to implement this interface.

Functions

AnyNumber

Unbounded Interval

public defn AnyNumber () -> Interval

  • Returns Interval

This is a helper function for creating an unbounded interval on both ends, i.e. an interval which contains every real number.

Interval

Constructor for an Interval type.

public defn Interval (lo:Double|False, hi:Double|False) -> Interval

  • lo: Double|False - Inclusive min value if not false. Otherwise sets the minimum to unbounded.
  • hi: Double|False - Inclusive max value if not false. Otherwise sets the maximum to unbounded.
  • Returns Interval
  • Throws RuntimeError - If the lo value is greater than the hi value.

AtLeast

Interval with unbounded maximum and bounded minimum

public defn AtLeast (x:Double) -> Interval

  • x: Double - Inclusive low end bound for the interval
  • Returns Interval

This is a helper function for creating a interval that is bounded from below only.

AtMost

Interval with unbounded minimum and bounded maximum

public defn AtMost (x:Double) -> Interval

  • x: Double - Inclusive high end bound for the interval
  • Returns Interval

This is a helper function for creating a interval that is bounded from above only.

Related Packages

Forwarded by package: jitx