gnp.geometry module

gnp.geometry.surface

class gnp.geometry.surface.SurfacePatch(patch_data: Batch, surface_coefficients: Tensor)[source]

Bases: object

Surface Patch for computing geometric quantities from Legendre Coefficients

property det_metric: Tensor[source]

Compute the determinant of the metric tensor of the surface patches :returns: determinant of the metric tensor of the surface patches :rtype: torch.Tensor

property gaussian_curvature: Tensor[source]

Compute the Gaussian curvature tensor of the surface patches :returns: Gaussian curvature tensor of the surface patches :rtype: torch.Tensor

property inverse_metric: Tensor[source]

Compute the inverse metric tensor of the surface patches :returns: inverse metric tensor of the surface patches :rtype: torch.Tensor

property inverse_metric_derivatives: Tensor[source]

Compute the derivatives of the inverse metric tensor of the surface patches :returns: derivatives of the inverse metric tensor of the surface patches :rtype: torch.Tensor

property laplace_beltrami_first_terms: Tensor[source]

Compute the first terms of the Laplace-Beltrami operator. These terms are multiplied to the second derivatives of the function.

Returns:

The first terms of the laplace-beltrami operator.

Return type:

torch.Tensor

laplace_beltrami_from_coefficients(function_coefficients: Tensor) Tensor[source]

Compute the Laplace-Beltrami operator from the surface coefficients and the function coefficients.

Parameters:

function_coefficients (torch.Tensor) -- Legendre coefficients representing the function.

Returns:

Laplace-Beltrami operator applied to the function.

Return type:

torch.Tensor

property laplace_beltrami_legendre_basis: Tensor[source]

Compute the Laplace-Beltrami operator on each of the Legendre basis functions.

Returns:

(n, 16) tensor containing the Laplace-Beltrami operator applied to the Legendre basis functions.

Return type:

torch.Tensor

property laplace_beltrami_second_terms: Tensor[source]

Compute the second terms of the Laplace-Beltrami operator. These terms are multiplied to the first derivatives of the function.

Returns:

The second terms of the laplace-beltrami operator.

Return type:

torch.Tensor

property local_coordinate_basis: Tensor[source]

Return the local PCA basis coordinates at each point :returns: local coordinates of the surface patches :rtype: torch.Tensor

property mean_curvature: Tensor[source]

Compute the mean curvature tensor of the surface patches :returns: mean curvature tensor of the surface patches :rtype: torch.Tensor

property metric: Tensor[source]

Compute the metric tensor of the surface patches :returns: metric tensor of the surface patches :rtype: torch.Tensor

property normals: Tensor[source]

Compute the normals of the surface patches in global coordinates :returns: normals of the surface patches :rtype: torch.Tensor

property normals_pca: Tensor[source]

Compute the normals of the surface patches in local coordinates :returns: normals of the surface patches :rtype: torch.Tensor

property pca_coordinates: Tensor[source]

Compute the PCA coordinates of the surface patches :returns: PCA coordinates of the surface patches :rtype: torch.Tensor

property shape: Tensor[source]

Compute the shape tensor of the surface patches :returns: shape tensor of the surface patches :rtype: torch.Tensor

property tangents: Tensor[source]

Compute the tangents of the surface patches in global coordinates

Returns:

tangents of the surface patches

Return type:

torch.Tensor

property tangents_pca: Tensor[source]

Compute the tangents of the surface patches in local coordinates

Returns:

tangents of the surface patches

Return type:

torch.Tensor

property weingarten: Tensor[source]

Compute the Weingarten tensor of the surface patches :returns: Weingarten tensor of the surface patches :rtype: torch.Tensor

property xyz_coordinates: Tensor[source]

Compute the xyz coordinates of the surface patches :returns: xyz coordinates of the surface patches :rtype: torch.Tensor

gnp.geometry.legendre

class gnp.geometry.legendre.Legendre1D(degree: int = 3)[source]

Bases: object

Class to compute the Legendre polynomials and their derivatives

evaluate(x: Tensor) Tensor[source]

Evaluate the Legendre polynomials at the input points.

Parameters:

x (torch.Tensor) -- Input points.

Returns:

Legendre polynomials evaluated at the input points.

Return type:

torch.Tensor

first_derivative(x: Tensor) Tensor[source]

Compute the derivative of the Legendre polynomials at the input points.

Parameters:

x (torch.Tensor) -- Input points.

Returns:

Derivative of Legendre polynomials evaluated at the input points.

Return type:

torch.Tensor

second_derivative(x: Tensor) Tensor[source]

Compute the second derivative of the Legendre polynomials at the input points

Parameters:

x (torch.Tensor) -- Input points.

Returns:

Second derivative of Legendre polynomials evaluated at the input points.

Return type:

torch.Tensor

class gnp.geometry.legendre.Legendre2D(degree: int = 3)[source]

Bases: object

batch_ls_best_fit(x: Tensor, batch: LongTensor | None = None) Tensor[source]

Compute the least squares best fit of the Legendre coefficients.

Parameters:
  • x (torch.Tensor) -- (n, 2) tensor of input points.

  • batch (Optional[torch.LongTensor], optional) -- Batch indices. Defaults to None.

Returns:

(num_batches, (degree + 1) ** 2) tensor of Legendre coefficients.

Return type:

torch.Tensor

compute_from_coeffs(values: Tensor, coeffs: Tensor, batch: LongTensor | None = None) Tensor[source]

Compute function values using Legendre coefficients.

Parameters:
  • values (torch.Tensor) -- Values of the Legendre polynomials (or derivatives) at the input points.

  • coeffs (torch.Tensor) -- Legendre basis coefficients.

  • batch (Optional[torch.LongTensor], optional) -- Batch indices. Defaults to None.

Returns:

(n, 1) tensor of function values at the input points.

Return type:

torch.Tensor

derivatives_from_coeffs(xy_data: Tensor, coeffs: Tensor, batch: LongTensor | None = None) Tensor[source]

Compute the derivatives of a function at given points from its Legendre coefficients.

Parameters:
  • xy_data (torch.Tensor) -- (n, 2) tensor of input points.

  • coeffs (torch.Tensor) -- Tensor of Legendre coefficients.

  • batch (Optional[torch.LongTensor], optional) -- Batch indices for parallel computation over many batches. Defaults to None.

Returns:

(n, 5) tensor of function derivatives at the input points.

Return type:

torch.Tensor

evaluate(xy_data: Tensor) Tensor[source]

Evaluate tensor product of Legendre polynomials at the input points.

Parameters:

xy_data (torch.Tensor) -- (n, 2) tensor of input points.

Returns:

(n, (degree + 1) ** 2) tensor of Legendre polynomials evaluated at the input points.

Return type:

torch.Tensor

evaluate_derivatives(xy_data: TensorType) tuple[Tensor][source]

Evaluate the derivatives of the Legendre polynomials at the input points.

Parameters:

xy_data (torch.Tensor) -- (n, 2) tensor of input points.

Returns:

Derivatives of the Legendre polynomials evaluated at the input points.

Return type:

tuple of torch.Tensor

evaluate_from_coeffs(xy_data: Tensor, coeffs: Tensor, batch: LongTensor | None = None) Tensor[source]

Evaluate a function at given points from its Legendre coefficients

Parameters:
  • xy_data (torch.Tensor) -- (n, 2) tensor of input points

  • coeffs (torch.Tensor) -- tensor of legendre coefficients

  • batch (Optional[torch.LongTensor], optional) -- batch indices for parallel computation over many batches. Defaults to None.

Returns:

(n, 1) tensor of function values at the input points

Return type:

torch.Tensor

Module contents