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
// SPDX-License-Identifier: AGPL-3.0-or-later
//! Triangular Solve - Forward/Backward Substitution - Pure WGSL
//!
//! **Deep Debt Principles**:
//! - ✅ Pure WGSL implementation (GPU-optimized)
//! - ✅ Safe Rust wrapper (no unsafe code)
//! - ✅ Hardware-agnostic via WebGPU
//! - ✅ Complete implementation (production-ready)
//! - ✅ Runtime-configured matrix size
//! - ✅ Capability-based dispatch
//!
//! ## Algorithm
//!
//! Solves triangular linear systems:
//! ```text
//! Forward: L·x = b (lower triangular L)
//! Backward: Uᵀ·x = b (upper triangular U or transpose of lower)
//!
//! Used after Cholesky: A = L·Lᵀ
//! 1. Solve L·z = b (forward)
//! 2. Solve Lᵀ·x = z (backward)
//! Result: x solves A·x = b
//! ```
//!
//! ## Precision Support
//!
//! - `execute()` - f32 precision
//! - `TriangularSolveF64::execute()` - f64 precision (science-grade)
//! - `TriangularSolveF64::execute_transpose()` - Solve using Lᵀ (for Cholesky step 2)
//!
//! ## Use Case
//!
//! **RBF Surrogate Learning** (hotSpring physics integration):
//! - After Cholesky: K = L·Lᵀ
//! - Solve K·w = y → solve L·(Lᵀ·w) = y
//! - Step 1: L·z = y (forward) → z
//! - Step 2: Lᵀ·w = z (backward) → w
//! - Result: w are the RBF weights
//!
//! ## References
//!
//! - Golub & Van Loan, "Matrix Computations", Section 3.1
//! - Used in `scipy.linalg.solve_triangular`
//! - Completes the Cholesky solve pipeline
pub use f32TriangularSolve;
pub use f64TriangularSolveF64;