zonopy.interval#
- class zonopy.interval(inf=None, sup=None, dtype=None, device=None)[source]#
Bases:
object
N-rank tensor intervals
An interval is a set of real numbers that includes all numbers between two given numbers. Here, we define an interval as a set of real numbers given infinum and supremum tensors and such that .
- __init__(inf=None, sup=None, dtype=None, device=None)[source]#
Create an interval
If
inf
andsup
are bothNone
, an empty interval is created. If only one ofinf
orsup
isNone
, the interval is created as a point interval whereinf = sup
.- Parameters:
inf (torch.Tensor, optional) – infimum of the interval. Defaults to None.
sup (torch.Tensor, optional) – supremum of the interval. Defaults to None.
dtype (torch.dtype, optional) – data type of the interval. If None, the data type is inferred from the input tensors. Defaults to None.
device (torch.device, optional) – device of the interval. If None, the device is inferred from the input tensors. Defaults to None.
- Raises:
AssertionError – If the shapes of
inf
andsup
do not match.AssertionError – If the devices of
inf
andsup
do not match.AssertionError – If
inf
is not less than or equal tosup
entry-wise andzonopy.internal.__debug_extra__
is True.
Methods
__init__
([inf, sup, dtype, device])Create an interval
center
()Compute the center of the interval
cpu
()Change the device of an interval to CPU
dim
()Returns the number of dimensions of the interval
numel
()Returns the total number of elements in the interval
rad
()Compute the radius of the interval
t
()Transposes the interval
to
([dtype, device])Change the device and data type of an interval dtype: torch.float or torch.double device: 'cpu', 'gpu', 'cuda:0', ...
Attributes
The device of an interval properties return 'cpu', 'cuda:0', or ...
The data type of an interval properties return torch.float or torch.double
The infimum of an interval return <torch.Tensor> ,shape [n,m]
The shape of elements (infimum or supremum) of an interval
The supremum of an interval return <torch.Tensor> ,shape [n,m]
- center() torch.Tensor [source]#
Compute the center of the interval
The center of the interval is the midpoint of the infimum and supremum.
- Returns:
center of the interval
- Return type:
- property device#
The device of an interval properties return ‘cpu’, ‘cuda:0’, or …
- dim() int [source]#
Returns the number of dimensions of the interval
- Returns:
number of dimensions of the interval
- Return type:
- property dtype#
The data type of an interval properties return torch.float or torch.double
- property inf#
The infimum of an interval return <torch.Tensor> ,shape [n,m]
- numel() int [source]#
Returns the total number of elements in the interval
- Returns:
number of elements in the interval
- Return type:
- rad() torch.Tensor [source]#
Compute the radius of the interval
The radius of the interval is half of the difference between the supremum and infimum. It can be viewed as the distance from the center to the infimum or supremum.
- Returns:
radius of the interval
- Return type:
- property shape#
The shape of elements (infimum or supremum) of an interval
- property sup#
The supremum of an interval return <torch.Tensor> ,shape [n,m]