Pairwise Distance Periodic#
periodic
#
| CLASS | DESCRIPTION |
|---|---|
PairwiseDistancePeriodic |
PyTorch module for computing periodic pairwise distances. |
| FUNCTION | DESCRIPTION |
|---|---|
pairwise_distance_periodic |
Compute periodic pairwise distances between tensors. |
Classes#
PairwiseDistancePeriodic(reduce: Literal['mean', 'sum', 'none', None] = None, period: float = 2 * pi, normalize: bool = False)
#
Bases: PairwiseDistance
PyTorch module for computing periodic pairwise distances.
Computes distances for periodic variables (e.g., dihedral angles) where differences are wrapped to [-pi, pi]. This ensures that angles near 0 and 2 pi are treated as close in distance space.
| PARAMETER | DESCRIPTION |
|---|---|
reduce
|
Reduction method for the computed distances.
TYPE:
|
period
|
Period of the periodic variables. Default assumes angles in radians. Use 360.0 for degrees.
TYPE:
|
normalize
|
Whether to normalize distances to unit scale.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
forward_step |
Compute periodic pairwise distances. |
Source code in spectre/pairwise_distance/periodic.py
Functions#
forward_step(X: torch.Tensor, **kwargs) -> torch.Tensor
#
Compute periodic pairwise distances.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Input tensor with shape (n_samples, in_features).
TYPE:
|
**kwargs
|
Additional keyword arguments.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Pairwise distance matrix. |
Source code in spectre/pairwise_distance/periodic.py
Functions#
pairwise_distance_periodic(X: torch.Tensor, Y: torch.Tensor | None = None, reduce: Literal['mean', 'sum', 'none', None] = None, period: float = 2 * torch.pi, normalize: bool = False) -> torch.Tensor
#
Compute periodic pairwise distances between tensors.
Computes distances for periodic variables (e.g., dihedral angles) where differences are wrapped to [-pi, pi]. This ensures that angles near 0 and 2 pi are treated as close in distance space.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Input tensor with shape (n_samples, in_features) containing periodic variables.
TYPE:
|
Y
|
Second tensor with same feature dimension. If None, computes distances within X.
TYPE:
|
reduce
|
Reduction method to apply to distance matrix.
TYPE:
|
period
|
Period of the periodic variables. Use 2π for radians, 360.0 for degrees.
TYPE:
|
normalize
|
Whether to L2-normalize the distance matrix along dimension 1.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Pairwise distance matrix. |