pub fn quat_from_scaled_axis<const D: usize>(g: Tensor<D>) -> Tensor<D>Expand description
Materialise a unit quaternion from a scaled rotation vector g ∈ ℝ³
(axis · angle) via the exponential map — the data-dependent “materialise
Rₜ” step, analogous to RoPE’s Δₜ · π · tanh(θₜ) angle.
With ‖g‖ = angle and ĝ = g / angle the axis, returns the unit quaternion
q = (cos(angle/2), sin(angle/2)·ĝ). A vanishing g maps to the identity
(1, 0, 0, 0), so scaling g by a small Δₜ (the discretisation step)
yields a near-identity rotation — exactly the regime where a small step
barely rotates the state. The sin(angle/2)/angle factor is the numerically
stable form of the (otherwise 0/0) per-component scale near g = 0.
§Shapes
g:[..., 3]- out :
[..., 4](ordered(w, x, y, z)), unit norm.