spd_learn.functional.spd_to_log_tokens#

spd_learn.functional.spd_to_log_tokens(x: Tensor, *, preserve_norm: bool = False, eigenvalue_floor: float | None = None, matrix_scale: float = 1.0) → Tensor[source]#

Map SPD matrices to upper-triangle log coordinates.

Parameters:
  • x (torch.Tensor) – Real matrices of shape (…, n, n); SPD unless an explicit floor is supplied.

  • preserve_norm (bool, default=False) – Scale off-diagonal coordinates by sqrt(2).

  • eigenvalue_floor (float or None) – Explicit eigenvalue floor before the logarithm; None disables it.

  • matrix_scale (float, default=1.0) – Positive matrix multiplier before the logarithm.

Returns:

Log coordinates of shape (…, n * (n + 1) // 2).

Return type:

torch.Tensor

Notes

Scaling precedes flooring and the logarithm. An explicit floor is lossy; the host numerical log floor also applies.