lloca.utils.orthogonalize_4d
Orthogonalization of Minkowski vectors.
Functions
|
Check that the Lorentz transformation has only one timelike vector. |
|
Normalize a Minkowski vector by the absolute value of the Minkowski norm. |
|
High-level wrapper for orthogonalization of three Minkowski vectors. |
|
Orthogonalization algorithm using repeated cross products. |
|
Gram-Schmidt orthogonalization algorithm for Minkowski vectors. |
|
Wrapper for orthogonalization of Minkowski vectors. |
|
If the cross product of three vectors is close to zero, they are coplanar. |
|
If the Minkowski norm of a vector is close to zero, it is lightlike. |
- lloca.utils.orthogonalize_4d.check_timelike_first(trafo)[source]
Check that the Lorentz transformation has only one timelike vector. This is necessary to ensure that the resulting Lorentz transformation has the correct metric signature (1, -1, -1, -1). Note that the timelike nature of the first vector is enforced by the nonlinearity in the framesnet, this will trigger if numerical instabilities occur in the orthogonalization.
- Parameters:
trafo (torch.Tensor) – Lorentz transformation of shape (…, 4, 4) where the last two dimensions represent the transformation matrix.
- Returns:
trafo – Lorentz transformation of shape (…, 4, 4) with the first vector being timelike.
- Return type:
torch.Tensor
- lloca.utils.orthogonalize_4d.normalize_4d(v, eps=None)[source]
Normalize a Minkowski vector by the absolute value of the Minkowski norm. Note that this norm can be close to zero.
- Parameters:
v (torch.Tensor) – Minkowski vector of shape (…, 4).
eps (float or None) – Small value to avoid division by zero.
- Returns:
Normalized Minkowski vector of shape (…, 4).
- Return type:
torch.Tensor
- lloca.utils.orthogonalize_4d.orthogonalize_4d(vecs, use_float64=True, return_reg=False, checks=False, **kwargs)[source]
High-level wrapper for orthogonalization of three Minkowski vectors.
- Parameters:
vecs (torch.Tensor) – Tensor containing three Minkowski vectors of shape (…, 3, 4).
use_float64 (bool) – If True, use float64 for numerical stability during orthogonalization.
return_reg (bool) – If True, return a tuple with the orthogonalized vectors and the number of regularized vectors for lightlike and coplanar cases.
checks (bool) – If True, perform additional assertion checks on predicted vectors. It may cause slowdowns due to GPU/CPU synchronization, use only for debugging.
kwargs (dict) – Additional keyword arguments passed to the orthogonalization function.
- Returns:
trafo (torch.Tensor) – Lorentz transformation of shape (…, 4, 4) that orthogonalizes the input vectors. The first vector is guaranteed to be timelike.
reg_lightlike (int) – Number of vectors that were regularized due to being lightlike.
reg_coplanar (int) – Number of vectors that were regularized due to coplanarity.
- lloca.utils.orthogonalize_4d.orthogonalize_cross(vecs, eps_norm=None)[source]
Orthogonalization algorithm using repeated cross products. This approach gives the same result as orthogonalize_gramschmidt for unlimited precision, but we find empirically that the Gram-Schmidt approach is more stable.
- Parameters:
vecs (torch.Tensor) – List of three Minkowski vectors of shape (…, 3, 4).
eps_norm (float or None) – Small value to avoid division by zero during normalization.
- Returns:
orthogonal_vecs – List of four orthogonalized Minkowski vectors of shape (…, 4, 4).
- Return type:
torch.Tensor
- lloca.utils.orthogonalize_4d.orthogonalize_gramschmidt(vecs, eps_norm=None)[source]
Gram-Schmidt orthogonalization algorithm for Minkowski vectors.
- Parameters:
vecs (torch.Tensor) – List of three Minkowski vectors of shape (…, 3, 4).
eps_norm (float or None) – Small value to avoid division by zero during normalization.
- Returns:
orthogonal_vecs – List of four orthogonalized Minkowski vectors of shape (…, 4, 4).
- Return type:
torch.Tensor
- lloca.utils.orthogonalize_4d.orthogonalize_wrapper_4d(vecs, method='gramschmidt', eps_norm=None, eps_reg_coplanar=None, eps_reg_lightlike=None, return_reg=False)[source]
Wrapper for orthogonalization of Minkowski vectors.
- Parameters:
vecs (torch.Tensor) – Tensor containing list of three Minkowski vectors of shape (…, 3, 4).
method (str) – Method for orthogonalization. Options are “cross” and “gramschmidt”.
eps_norm (float or None) – Numerical regularization for the normalization of the vectors. If None, use the smallest representable value for the vectors dtype.
eps_reg_coplanar (float or None) – Controls the scale of the regularization for coplanar vectors. eps_reg_coplanar defines the selection threshold.
eps_reg_lightlike (float or None) – Controls the scale of the regularization for lightlike vectors. eps_reg_lightlike defines the selection threshold.
return_reg (bool) – If True, return a tuple with the orthogonalized vectors and the number of regularized vectors for lightlike and coplanar cases.
- Returns:
orthogonal_vecs (torch.Tensor) – Four orthogonalized Minkowski vectors of shape (…, 4, 4).
reg_lightlike (int) – Number of vectors that were regularized due to being lightlike.
reg_coplanar (int) – Number of vectors that were regularized due to coplanarity.
- lloca.utils.orthogonalize_4d.regularize_coplanar(vecs, eps_reg_coplanar=None)[source]
If the cross product of three vectors is close to zero, they are coplanar. In this case, we add a bit of noise to each vector to break the degeneracy and ensure that the orthogonalization works.
- Parameters:
vecs (torch.Tensor) – List of three Minkowski vectors of shape (…, 3, 4).
eps_reg_coplanar (float or None) – Small value to control the scale of the regularization for coplanar vectors. If None, use the smallest representable value for the vectors dtype.
- Returns:
vecs_reg (torch.Tensor) – List of three Minkowski vectors of shape (…, 3, 4) with regularization applied.
reg_coplanar (int) – Number of vectors that were regularized due to coplanarity.
- lloca.utils.orthogonalize_4d.regularize_lightlike(vecs, eps_reg_lightlike=None)[source]
If the Minkowski norm of a vector is close to zero, it is lightlike. In this case, we add a bit of noise to the vector to break the degeneracy and ensure that the orthogonalization works. The noise is sampled such that the resulting vector is timelike.
- Parameters:
vecs (torch.Tensor) – List of three Minkowski vectors of shape (…, 3, 4).
eps_reg_lightlike (float or None) – Small value to control the scale of the regularization for lightlike vectors. If None, use the smallest representable value for the vectors dtype.
- Returns:
vecs_reg (torch.Tensor) – List of three Minkowski vectors of shape (…, 3, 4) with regularization applied.
reg_lightlike (int) – Number of vectors that were regularized due to being lightlike.