Configuration options

The IntervalArithmetic.jl package provides a configure function (not exported) that allows users to fine-tune certain aspects of the package’s behavior. This is particularly useful for controlling trade-offs between computational speed and rigor.

Warning

The configure function redefines methods that alter the internal behavior of IntervalArithmetic. This persists across the current Julia session and affect all subsequent interval arithmetic computations.

Each keyword argument sets a specific configuration option:

  • numtype: control the default numerical type used to represent the bounds of the intervals.
  • flavor: control the flavor type of the intervals.
  • rounding: control the rounding type.
  • power: control the implementation used for the interval power operation, that is, the computation of x^n where x is an interval and n is a number. The choice of power implementation has implications for both performance and accuracy.
  • matmul: control the matrix multiplication algorithm.
  • nthreads: control the number of threads used by the :fast matrix multiplication algorithm.
julia> using IntervalArithmeticjulia> x = interval(π)Interval{Float64}(3.141592653589793, 3.1415926535897936, com, true)julia> IntervalArithmetic.configure(; power = :slow)Configuration options:  - bound type: Float64  - flavor: set_based  - interval rounding: correct  - power mode: slow  - matrix multiplication mode: fast  - number of threads for `:fast` matrix multiplication mode: 2julia> radius(x^3)7.105427357601002e-15julia> IntervalArithmetic.configure(; power = :fast) # defaultConfiguration options:  - bound type: Float64  - flavor: set_based  - interval rounding: correct  - power mode: fast  - matrix multiplication mode: fast  - number of threads for `:fast` matrix multiplication mode: 2julia> radius(x^3)1.4210854715202004e-14
IntervalArithmetic.configureFunction
configure(; numtype=Float64, flavor=:set_based, rounding=:correct, power=:fast, matmul=:fast, nthreads=IntervalArithmetic.default_threads())

Configure the default behavior for:

  • Bound Type: The default numerical type used for interval endpoints. The default is Float64, but any subtype of IntervalArithmetic.NumTypes may be used to adjust precision, or specific numerical requirements.

  • Flavor: The interval interpretation according to the IEEE Standard 1788-2015. The default is the set-based flavor, which excludes infinity from intervals. Learn more: IntervalArithmetic.Flavor.

  • Interval Rounding: The rounding behavior for interval arithmetic operations. By default, the library employs correct rounding to ensure that bounds are computed as tightly as possible. Learn more: IntervalArithmetic.IntervalRounding.

  • Power mode: The performance setting for computing powers. The default is an efficient algorithm prioritizing performance over precision. Learn more: IntervalArithmetic.PowerMode.

  • Matrix Multiplication mode: The performance setting for computing matrix multiplications. The default is an efficient algorithm prioritizing performance over precision. Learn more: IntervalArithmetic.MatMulMode.

  • Number of threads: The number of threads used by the custom BLAS library backing the :fast matrix multiplication mode. By default, it matches the number of threads Julia uses for its own BLAS library. Learn more: IntervalArithmetic.default_threads.

Each keyword defaults to the value currently in use, so that only the given options are modified.

source
IntervalArithmetic.FlavorType
Flavor{F}

A flavor defining how an interval behaves in edge cases. For instance, infinity may or not be considered part of unbounded intervals.

Some flavors F include:

  • :set_based (default): elements of an interval are real numbers. In particular, infinity is never part of an interval. This flavor is described and required in Part 2 of the IEEE Standard 1788-2015. Edge cases: - any unbounded interval does not contain infinity. - $[0, 0] / [0, 0] = \emptyset$. - $x / [0, 0] = \emptyset$ for any interval $x$. - $x \times [0, 0] = [0, 0]$ for any interval $x$.
  • :cset: elements of an interval are either real numbers, or $\pm \infty$, applying standard rule for arithmetic with infinity. Edge cases: - any unbounded interval contains infinity. - $[0, 0] / [0, 0] = [-\infty, \infty]$. - $x / [0, 0] = [-\infty, \infty]$ for any interval $x$. - $x \times [0, 0] = [-\infty, \infty]$ for any unbounded interval $x$.
Note

Currently only the flavor :set_based is supported and implemented.

Examples

julia> IntervalArithmetic.is_valid_interval(Inf, Inf)falsejulia> isempty_interval(bareinterval(0)/bareinterval(0))truejulia> isempty_interval(bareinterval(1)/bareinterval(0))truejulia> isempty_interval(bareinterval(-Inf, Inf)/bareinterval(0))truejulia> isthinzero(bareinterval(0)*bareinterval(-Inf, Inf))true
source
IntervalArithmetic.PowerModeType
PowerMode

Power mode type for ^.

Available mode types:

  • :fast (default): x ^ y is semantically equivalent to fastpow(x, y), unless isthininteger(y) is true in which case it is semantically equivalent to fastpown(x, sup(y)).
  • :slow: x ^ y is semantically equivalent to pow(x, y), unless isthininteger(y) is true in which case it is semantically equivalent to pown(x, sup(y)).
source
IntervalArithmetic.MatMulModeType
MatMulMode{T}

Matrix multiplication mode type.

Available mode types:

  • :fast (default): Rump's algorithm.
  • :slow (always used for high-precision number types, e.g., BigFloat): generic algorithm.
source