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 X\underbar{X} and X\overline{\text{X}} such that XXX\underbar{X} \leq X \leq \overline{\text{X}}.

I:={xRn,m,...  |  xi,j,xi,j,xi,j,i=1,,nj=1,,m}\mathcal{I} := \left\{ x \in \mathbb{R}^{n,m,...} \; \middle\vert \; \begin{array}{c} \underbar{x}_{i,j,\ldots} \leq x_{i,j,\ldots} \leq \overline{\text{x}}_{i,j,\ldots} \\ \forall{i=1,\ldots,n} \\ \forall{j=1,\ldots,m} \\ \vdots \end{array} \right\}
__init__(inf=None, sup=None, dtype=None, device=None)[source]#

Create an interval

If inf and sup are both None, an empty interval is created. If only one of inf or sup is None, the interval is created as a point interval where inf = 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:

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

device

The device of an interval properties return 'cpu', 'cuda:0', or ...

dtype

The data type of an interval properties return torch.float or torch.double

inf

The infimum of an interval return <torch.Tensor> ,shape [n,m]

shape

The shape of elements (infimum or supremum) of an interval

sup

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:

torch.Tensor

cpu()[source]#

Change the device of an interval to CPU

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:

int

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:

int

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:

torch.Tensor

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]

t()[source]#

Transposes the interval

Returns:

transposed interval

Return type:

interval

to(dtype=None, device=None)[source]#

Change the device and data type of an interval dtype: torch.float or torch.double device: ‘cpu’, ‘gpu’, ‘cuda:0’, …