spd_learn.functional.get_loewner_threshold#
- spd_learn.functional.get_loewner_threshold(eigenvalues: Tensor, *, config: NumericalConfig | None = None) float[source]#
Get threshold for detecting equal eigenvalues in Loewner matrix.
The Loewner matrix computation requires special handling when eigenvalues are equal or nearly equal. This function returns an appropriate threshold for detecting such cases.
- Parameters:
eigenvalues (torch.Tensor) – The eigenvalues (used to determine dtype).
config (NumericalConfig, optional) – Configuration to use. If None, uses the global
numerical_config.
- Returns:
The threshold for eigenvalue equality detection.
- Return type:
Notes
The threshold is computed as:
threshold = scale * max(1, |eigenvalues|.max()) * eps
This adaptive threshold accounts for the magnitude of eigenvalues, providing better numerical stability for matrices with large eigenvalues.