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
69
70
71
72
73
// ~/cartan/cartan-core/src/connection.rs
//! The `Connection` trait: Riemannian Hessian-vector products.
//!
//! The Levi-Civita connection on a Riemannian manifold provides a notion
//! of "derivative of a vector field along a curve." For optimization, the
//! key application is computing the Riemannian Hessian of a cost function,
//! or more precisely, Hessian-vector products (HVPs) needed by second-order
//! methods like Riemannian trust region and Riemannian Newton.
//!
//! ## Hessian-vector products
//!
//! Given a smooth cost function f: M -> R, the Riemannian Hessian at p
//! is a symmetric bilinear form on T_pM. For trust region methods, we need
//! H\[v\] = Hess f(p)\[v\], the action of the Hessian on a tangent vector v.
//!
//! For a Riemannian manifold embedded in Euclidean space, the Riemannian HVP
//! can be computed from the Euclidean Hessian as:
//!
//! Hess f(p)\[v\] = proj_T( D^2 f(p)\[v\] - II(grad f, v) )
//!
//! where II is the second fundamental form (shape operator), and proj_T is
//! the projection onto the tangent space.
//!
//! Alternatively, for cost functions defined via retraction, one uses the
//! differentiated retraction formula from Absil-Mahony-Sepulchre Ch. 5.
//!
//! ## References
//!
//! - Absil, Mahony, Sepulchre. "Optimization Algorithms on Matrix Manifolds."
//! Princeton, 2008. Chapter 5 (Riemannian Hessian and trust region).
//! - Boumal. "An Introduction to Optimization on Smooth Manifolds."
//! Cambridge, 2023. Chapter 6 (connections and Hessian).
//! - do Carmo. "Riemannian Geometry." Chapter 2 (Levi-Civita connection).
use crate::;
/// A manifold with a compatible Levi-Civita connection.
///
/// Implement this trait to enable second-order optimization methods
/// (trust region, Newton) that require Riemannian Hessian-vector products.
///
/// # Supertraiting Manifold
///
/// Connection requires Self: Manifold to ensure that the manifold has
/// the full geometric structure (exp, log, inner, project) before adding
/// the connection. The Levi-Civita connection depends on the metric, so
/// this dependency is semantically required, not just a convenience.