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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//! # RuVector Math
//!
//! Advanced mathematics for next-generation vector search and AI governance, featuring:
//!
//! ## Core Modules
//!
//! - **Optimal Transport**: Wasserstein distances, Sinkhorn algorithm, Sliced Wasserstein
//! - **Information Geometry**: Fisher Information, Natural Gradient, K-FAC
//! - **Product Manifolds**: Mixed-curvature spaces (Euclidean × Hyperbolic × Spherical)
//! - **Spherical Geometry**: Geodesics on the n-sphere for cyclical patterns
//!
//! ## Theoretical CS Modules (New)
//!
//! - **Tropical Algebra**: Max-plus semiring for piecewise linear analysis and routing
//! - **Tensor Networks**: TT/Tucker/CP decomposition for memory compression
//! - **Spectral Methods**: Chebyshev polynomials for graph diffusion without eigendecomposition
//! - **Persistent Homology**: TDA for topological drift detection and coherence monitoring
//! - **Polynomial Optimization**: SOS certificates for provable bounds on attention policies
//!
//! ## Design Principles
//!
//! 1. **Pure Rust**: No BLAS/LAPACK dependencies for full WASM compatibility
//! 2. **SIMD-Ready**: Hot paths optimized for auto-vectorization
//! 3. **Numerically Stable**: Log-domain arithmetic, clamping, and stable softmax
//! 4. **Modular**: Each component usable independently
//! 5. **Mincut as Spine**: All modules designed to integrate with mincut governance
//!
//! ## Architecture: Mincut as Unifying Signal
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │ Mincut Governance │
//! │ (Structural tension meter for attention graphs) │
//! └───────────────────────┬─────────────────────────────────────┘
//! │
//! ┌───────────────────┼───────────────────┐
//! ▼ ▼ ▼
//! ┌─────────┐ ┌───────────┐ ┌───────────┐
//! │ Tensor │ │ Spectral │ │ TDA │
//! │ Networks│ │ Methods │ │ Homology │
//! │ (TT) │ │(Chebyshev)│ │ │
//! └─────────┘ └───────────┘ └───────────┘
//! Compress Smooth within Monitor drift
//! representations partitions over time
//!
//! ┌───────────────────┼───────────────────┐
//! ▼ ▼ ▼
//! ┌─────────┐ ┌───────────┐ ┌───────────┐
//! │Tropical │ │ SOS │ │ Optimal │
//! │ Algebra │ │ Certs │ │ Transport │
//! └─────────┘ └───────────┘ └───────────┘
//! Plan safe Certify policy Measure
//! routing paths constraints distributional
//! distances
//! ```
//!
//! ## Quick Start
//!
//! ```rust
//! use ruvector_math::optimal_transport::{SlicedWasserstein, SinkhornSolver, OptimalTransport};
//! use ruvector_math::information_geometry::FisherInformation;
//! use ruvector_math::product_manifold::ProductManifold;
//!
//! // Sliced Wasserstein distance between point clouds
//! let sw = SlicedWasserstein::new(100).with_seed(42);
//! let points_a = vec![vec![0.0, 0.0], vec![1.0, 0.0]];
//! let points_b = vec![vec![0.5, 0.5], vec![1.5, 0.5]];
//! let dist = sw.distance(&points_a, &points_b);
//! assert!(dist > 0.0);
//!
//! // Sinkhorn optimal transport
//! let solver = SinkhornSolver::new(0.1, 100);
//! let cost_matrix = vec![vec![0.0, 1.0], vec![1.0, 0.0]];
//! let weights_a = vec![0.5, 0.5];
//! let weights_b = vec![0.5, 0.5];
//! let result = solver.solve(&cost_matrix, &weights_a, &weights_b).unwrap();
//! assert!(result.converged);
//!
//! // Product manifold operations (Euclidean only for simplicity)
//! let manifold = ProductManifold::new(2, 0, 0);
//! let point_a = vec![0.0, 0.0];
//! let point_b = vec![3.0, 4.0];
//! let dist = manifold.distance(&point_a, &point_b).unwrap();
//! assert!((dist - 5.0).abs() < 1e-10);
//! ```
extern crate alloc;
// Core modules
// New theoretical CS modules
// Re-exports for convenience - Core
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// Re-exports - Tropical Algebra
pub use ;
pub use ;
// Re-exports - Tensor Networks
pub use ;
pub use ;
pub use ;
// Re-exports - Spectral Methods
pub use ScaledLaplacian;
pub use ;
pub use ;
pub use ;
// Re-exports - Homology
pub use ;
pub use ;
pub use ;
// Re-exports - Optimization
pub use ;
pub use ;
pub use ;
/// Prelude module for convenient imports