Intersection#
Module for Intersection class.
- class Intersection(geometries)[source]#
Bases:
OperationInterface
PINA implementation of Intersection of Domains. Given two sets \(A\) and \(B\) then the domain difference is defined as:
\[A \cap B = \{x \mid x \in A \land x \in B\},\]with \(x\) a point in \(\mathbb{R}^N\) and \(N\) the dimension of the geometry space.
- Parameters:
geometries (list) – A list of geometries from
pina.geometry
such asEllipsoidDomain
orCartesianDomain
. The intersection will be taken between all the geometries in the list. The resulting geometry will be the intersection of all the geometries in the list.- Example:
>>> # Create two ellipsoid domains >>> ellipsoid1 = EllipsoidDomain({'x': [-1, 1], 'y': [-1, 1]}) >>> ellipsoid2 = EllipsoidDomain({'x': [0, 2], 'y': [0, 2]}) >>> # Create a Intersection of the ellipsoid domains >>> intersection = Intersection([ellipsoid1, ellipsoid2])
- is_inside(point, check_border=False)[source]#
Check if a point is inside the
Intersection
domain.- Parameters:
point (torch.Tensor) – Point to be checked.
check_border (bool) – If
True
, the border is considered inside.
- Returns:
True
if the point is inside the Intersection domain,False
otherwise.- Return type:
- sample(n, mode='random', variables='all')[source]#
Sample routine for
Intersection
domain.- Parameters:
- Returns:
Returns
LabelTensor
of n sampled points.- Return type:
- Example:
>>> # Create two Cartesian domains >>> cartesian1 = CartesianDomain({'x': [0, 2], 'y': [0, 2]}) >>> cartesian2 = CartesianDomain({'x': [1, 3], 'y': [1, 3]}) >>> # Create a Intersection of the ellipsoid domains >>> intersection = Intersection([cartesian1, cartesian2]) >>> # Sample >>> intersection.sample(n=5) LabelTensor([[1.7697, 1.8654], [1.2841, 1.1208], [1.7289, 1.9843], [1.3332, 1.2448], [1.9902, 1.4458]]) >>> len(intersection.sample(n=5) 5