lloca.utils.orthogonalize_3d
Orthogonalization of euclidean vectors.
Functions
|
Wrapper for orthogonalization of euclidean vectors. |
|
Cross product orthogonalization algorithm for euclidean vectors. |
|
Gram-Schmidt orthogonalization algorithm for euclidean vectors. |
|
If the cross product of two vectors is small, the vectors are collinear. |
- lloca.utils.orthogonalize_3d.orthogonalize_3d(vecs, method='gramschmidt', eps_norm=None, eps_reg=None, return_reg=False)[source]
Wrapper for orthogonalization of euclidean vectors.
- Parameters:
vecs (list of torch.Tensor) – List of torch.tensor of shape (…, 3) Vectors to be orthogonalized
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 (float or None) – Controls the scale of the regularization for collinear vectors.
return_reg (bool) – If True, additionally return the number of regularized vectors for collinearity.
- Returns:
orthogonal_vecs (list of torch.Tensor) – List of orthogonalized vectors of shape (…, 3)
reg_collinear (int) – Number of vectors that were regularized due to collinearity.
- lloca.utils.orthogonalize_3d.orthogonalize_cross_3d(vecs, eps_norm=None)[source]
Cross product orthogonalization algorithm for euclidean vectors. This approach is equivalent to the Gram-Schmidt procedure for unlimited precision, but for limited precision it is more stable.
- Parameters:
vecs (torch.Tensor) – Two vectors of shape (…, 2, 3).
eps_norm (float or None) – Numerical regularization for the normalization of the vectors.
- Returns:
orthogonal_vecs – Three orthogonalized vectors of shape (…, 3, 3), where dim=-2 counts the vectors.
- Return type:
torch.Tensor
- lloca.utils.orthogonalize_3d.orthogonalize_gramschmidt_3d(vecs, eps_norm=None)[source]
Gram-Schmidt orthogonalization algorithm for euclidean vectors.
- Parameters:
vecs (torch.Tensor) – Two vectors of shape (…, 2, 3).
eps_norm (float or None) – Numerical regularization for the normalization of the vectors.
- Returns:
orthogonal_vecs – Three orthogonalized vectors of shape (…, 3, 3), where dim=-2 counts the vectors.
- Return type:
torch.Tensor
- lloca.utils.orthogonalize_3d.regularize_collinear(vecs, eps_reg=None)[source]
If the cross product of two vectors is small, the vectors are collinear. In this case, we add a small amount of noise to the second vector to regularize the orthogonalization.
- Parameters:
vecs (list of torch.Tensor) – List with 2 vectors of shape (…, 3).
eps_reg (float or None) – Regularization epsilon, controls the scale of the noise added to the second vector. If None, use the smallest representable value for the vectors dtype.
- Returns:
vecs (list of torch.Tensor) – List with 2 vectors of shape (…, 3), where the second vector is regularized if collinear.
reg_collinear (int) – Number of vectors that were regularized due to collinearity.