1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// ~/cartan/cartan-core/src/retraction.rs
//! The `Retraction` trait: cheap approximations to the exponential map.
//!
//! A retraction is a smooth map R: TM -> M that approximates the exponential
//! map to first order. Specifically, for any manifold point p and tangent
//! vector v, a retraction R_p: T_pM -> M must satisfy:
//!
//! 1. R_p(0) = p (centered at p)
//! 2. DR_p(0) = id_{T_pM} (first-order consistency with exp)
//!
//! Retractions are cheaper than exact exp in many cases:
//! - Stiefel manifold: QR retraction is O(nk^2) vs exp at O((n+k)^3)
//! - Sphere: normalization retraction (p + v) / ||p + v|| vs sin/cos
//! - Grassmann: QR retraction
//!
//! The Manifold trait's default retract() calls exp(). Manifolds that have
//! a cheaper retraction implement this trait and override it. Generic
//! algorithms that only need first-order convergence (SGD, momentum methods)
//! should prefer retract() over exp() for speed.
//!
//! ## References
//!
//! - Absil, Mahony, Sepulchre. "Optimization Algorithms on Matrix Manifolds."
//! Princeton, 2008. Definition 4.1.1 (Retraction).
//! - Absil and Malick. "Projection-like Retractions on Matrix Manifolds."
//! SIAM Journal on Optimization, 2012.
use crate::;
/// A manifold equipped with a cheap retraction.
///
/// Implement this trait to provide a faster alternative to exp() for
/// first-order optimization methods. The retract() method here overrides
/// the default retract() from Manifold.
///
/// # Supertraiting Manifold
///
/// Retraction requires Self: Manifold so that implementors must provide
/// the full manifold structure. This ensures that a type claiming to have
/// a retraction also has exp/log/inner/etc.