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.
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 ofx^nwherexis an interval andnis 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:fastmatrix 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-14IntervalArithmetic.configure — Function
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 ofIntervalArithmetic.NumTypesmay 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
:fastmatrix 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.
IntervalArithmetic.NumTypes — Type
NumTypesConstant for the supported types of interval bounds. This is set to Union{Rational,AbstractFloat}.
IntervalArithmetic.Flavor — Type
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$.
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))trueIntervalArithmetic.IntervalRounding — Type
IntervalRoundingInterval rounding type.
Available rounding types:
:correct: rounding via RoundingEmulator.jl and CRlibm.jl; fallback to MPFR.:ulp: rounding via CoreMath.jl (default rounding to nearest) withprevfloatandnextfloat; fallback to MPFR.:none: no rounding (non-rigorous numerics).
IntervalArithmetic.PowerMode — Type
PowerModePower mode type for ^.
Available mode types:
:fast(default):x ^ yis semantically equivalent tofastpow(x, y), unlessisthininteger(y)is true in which case it is semantically equivalent tofastpown(x, sup(y)).:slow:x ^ yis semantically equivalent topow(x, y), unlessisthininteger(y)is true in which case it is semantically equivalent topown(x, sup(y)).
IntervalArithmetic.MatMulMode — Type
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.
IntervalArithmetic.default_threads — Function
default_threads()Number of threads used by the :fast matrix multiplication mode when it is not configured explicitly. Half of the available CPU threads are used (all of them on Apple silicon).
See also: IntervalArithmetic.configure.