immrax.inclusion#
- class immrax.inclusion.Interval(lower: Array, upper: Array)#
Bases:
objectInterval: A class to represent an interval in \(\mathbb{R}^n\).
Use the helper functions
interval(),icentpert(),i2centpert(),i2lu(),i2ut(), andut2i()to create and manipulate intervals.Use the transforms
natif(),jacif(),mjacif(),mjacM(), to create inclusion functions.Composable with typical jax transforms, such as
jax.jit(),jax.grad(), andjax.vmap().- Attributes:
- T
- center
- dtype
- ndim
- pert
- shape
- size
- width
Methods
atleast_1d
atleast_2d
atleast_3d
ravel
reshape
transpose
tree_flatten
tree_unflatten
- property center: Array#
- property dtype: dtype#
- property ndim: int#
- property pert: Array#
- reshape(*args, **kwargs)#
- property shape: Tuple[int, ...]#
- property size: int#
- tree_flatten()#
- classmethod tree_unflatten(_, children)#
- property width: Array#
- lower: Array#
- upper: Array#
- immrax.inclusion.interval(lower: Array | ndarray | bool | number | bool | int | float | complex, upper: Array | ndarray | bool | number | bool | int | float | complex | None = None) Interval#
interval: Helper to create a Interval from a lower and upper bound.
- Parameters:
- lowerArrayLike
Lower bound of the interval.
- upperArrayLike
Upper bound of the interval. Set to lower bound if None. Defaults to None.
- lower:ArrayLike
- Returns:
- Interval
[lower, upper], or [lower, lower] if upper is None.
- immrax.inclusion.icopy(i: Interval) Interval#
icopy: Helper to copy an interval.
- Parameters:
- iInterval
interval to copy
- Returns:
- Interval
copy of the interval
- immrax.inclusion.icentpert(cent: Array | ndarray | bool | number | bool | int | float | complex, pert: Array | ndarray | bool | number | bool | int | float | complex) Interval#
icentpert: Helper to create a Interval from a center of an interval and a perturbation.
- Parameters:
- centArrayLike
Center of the interval, i.e., (l + u)/2
- pertArrayLike
l-inf perturbation from the center, i.e., (u - l)/2
- Returns:
- Interval
Interval [cent - pert, cent + pert]
- immrax.inclusion.i2centpert(i: Interval) Tuple[Array, Array]#
i2centpert: Helper to get the center and perturbation from the center of a Interval.
- Parameters:
- iInterval
_description_
- Returns:
- Tuple[jax.Array, jax.Array]
((l + u)/2, (u - l)/2)
- immrax.inclusion.i2lu(i: Interval) Tuple[Array, Array]#
i2lu: Helper to get the lower and upper bound of a Interval.
- Parameters:
- intervalInterval
_description_
- Returns:
- Tuple[jax.Array, jax.Array]
(l, u)
- immrax.inclusion.lu2i(l: Array, u: Array) Interval#
lu2i: Helper to create a Interval from a lower and upper bound.
- Parameters:
- ljax.Array
Lower bound of the interval.
- ujax.Array
Upper bound of the interval.
- Returns:
- Interval
[l, u]
- immrax.inclusion.i2ut(i: Interval) Array#
i2ut: Helper to convert an interval to an upper triangular coordinate in \(\mathbb{R}\times\mathbb{R}\).
- Parameters:
- intervalInterval
interval to convert
- Returns:
- jax.Array
upper triangular coordinate in \(\mathbb{R}\times\mathbb{R}\)
- immrax.inclusion.ut2i(coordinate: Array, n: int | None = None) Interval#
ut2i: Helper to convert an upper triangular coordinate in \(\mathbb{R}\times\mathbb{R}\) to an interval.
- Parameters:
- coordinatejax.Array
upper triangular coordinate to convert
- nint
length of interval, automatically determined if None. Defaults to None.
- Returns:
- Interval
interval representation of the coordinate
- immrax.inclusion.iconcatenate(intervals: Iterable[Interval], axis: int = 0) Interval#
iconcatenate: Helper to concatenate intervals (cartesian product).
- Parameters:
- intervalsIterable[Interval]
intervals to concatenate
- axisint
axis to concatenate on. Defaults to 0.
- Returns:
- Interval
concatenated interval
- immrax.inclusion.izeros(shape: ~typing.Tuple[int], dtype: ~numpy.dtype = <class 'jax.numpy.float32'>) Interval#
izeros: Helper to create a Interval of zeros.
- Parameters:
- shapeTuple[int]
shape of the interval
- dtypenp.dtype
dtype of the interval. Defaults to jnp.float32.
- Returns:
- Interval
interval of zeros
- immrax.inclusion.interval_intersect(Is: Iterable[Interval]) Interval#
interval_intersect: Helper to get the intersection of a list of intervals.
- Parameters:
- IsIterable[Interval]
list of intervals
- Returns:
- Interval
intersection of the intervals
- immrax.inclusion.interval_union(Is: Iterable[Interval]) Interval#
interval_union: Helper to get the union of a list of intervals.
- Parameters:
- IsIterable[Interval]
list of intervals
- Returns:
- Interval
union of the intervals
- immrax.inclusion.natif(f: Callable[[...], Array], *, fixed_argnums: int | Sequence[int] = None) Callable[[...], Interval]#
Creates a Natural Inclusion Function of f.
All (non-fixed) positional arguments are assumed to be replaced with interval arguments for the inclusion function.
- Parameters:
- fCallable[…, jax.Array]
Function to construct Natural Inclusion Function from
- fixed_argnumsint|Sequence[int]
Positional arguments to be treated as jax.Array instead of Interval
- Returns:
- Callable[…, Interval]
Natural Inclusion Function of f
- immrax.inclusion.jacM(f: Callable[[...], Array]) Callable[[...], Interval]#
Creates the M matrices for the Jacobian-based inclusion function.
All positional arguments are assumed to be replaced with interval arguments for the inclusion function.
- Parameters:
- fCallable[…, jax.Array]
Function to construct Jacobian Inclusion Function from
- Returns:
- Callable[…, Interval]
Jacobian-Based Inclusion Function of f
- immrax.inclusion.jacif(f: Callable[[...], Array]) Callable[[...], Interval]#
Creates a Jacobian Inclusion Function of f using natif.
All positional arguments are assumed to be replaced with interval arguments for the inclusion function.
- Parameters:
- fCallable[…, jax.Array]
Function to construct Jacobian Inclusion Function from
- Returns:
- Callable[…, Interval]
Jacobian-Based Inclusion Function of f
- class immrax.inclusion.Permutation(_Permutation__iterable: Iterable = ())#
Bases:
tupleA tuple of \(n\) numbers \((o_i)_{i=1}^n\) such that each \(0\leq o_i \leq n-1\) and each \(o_i\) is unique.
- Attributes:
Methods
count(value, /)Return number of occurrences of value.
index(value[, start, stop])Return first index of value.
sub(i)Returns the sub-permutation of the first i elements.
- property arr: Array#
Returns the Permutation in a jax.Array.
- property mat: Array#
Returns the permutation matrix of the Permutation.
- property mtx: Array#
Returns the replacement matrix of the Permutation.
- sub(i: int) Permutation#
Returns the sub-permutation of the first i elements.
- immrax.inclusion.standard_permutation(n: int) Tuple[Permutation]#
Returns the standard n-permutation \((0,\dots,n-1)\)
- immrax.inclusion.two_permutations(n: int) Tuple[Permutation]#
Returns the two standard n-permutations \((0,\dots,n-1)\) and \((n-1,\dots,0)\)
- immrax.inclusion.all_permutations(n: int) Tuple[Permutation]#
Returns all n-permutations.
- class immrax.inclusion.Corner(_Corner__iterable: Iterable = ())#
Bases:
tupleA tuple of \(n\) elements in \(\{0,1\}\) representing the corners of an \(n\)-dimensional hypercube. 0 is the lower bound, 1 is the upper bound
Methods
count(value, /)Return number of occurrences of value.
index(value[, start, stop])Return first index of value.
- immrax.inclusion.bot_corner(n: int) Tuple[Corner]#
Returns the bottom corner of the n-dimensional hypercube.
- immrax.inclusion.top_corner(n: int) Tuple[Corner]#
Returns the top corner of the n-dimensional hypercube.
- immrax.inclusion.two_corners(n: int) Tuple[Corner]#
Returns the bottom and top corners of the n-dimensional hypercube.
- immrax.inclusion.all_corners(n: int) Tuple[Corner]#
Returns all corners of the n-dimensional hypercube.
- immrax.inclusion.get_corner(M: Interval, c: Corner)#
Gets the corner of the interval M specified by the Corner c.
- immrax.inclusion.get_corners(M: Interval, cs: Tuple[Corner] | None = None)#
Gets the corners of the interval M specified by the Corners cs. Defaults to all corners if None.
- immrax.inclusion.get_sparse_corners(M: Interval)#
Gets the corners of the interval M that are not the same. Will
- immrax.inclusion.mjacif(f: Callable[[...], Array]) Callable[[...], Interval]#
Creates a Mixed Jacobian Inclusion Function of f using natif.
All positional arguments are assumed to be replaced with interval arguments for the inclusion function.
- Parameters:
- fCallable[…, jax.Array]
Function to construct Mixed Jacobian Inclusion Function from
- Returns:
- Callable[…, Interval]
Mixed Jacobian-Based Inclusion Function of f
- immrax.inclusion.mjacM(f: Callable[[...], Array], argnums=None) Callable#
Creates the M matrices for the Mixed Jacobian-based inclusion function.
All positional arguments are assumed to be replaced with interval arguments for the inclusion function.
- Parameters:
- fCallable[…, jax.Array]
Function to construct Mixed Jacobian Inclusion Function from
- Returns:
- Callable[…, Interval]
Mixed Jacobian-Based Inclusion Function of f