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
// SPDX-License-Identifier: AGPL-3.0-or-later
//! Sparse linear algebra for large-scale scientific computing
//!
//! Provides sparse matrix representations and solvers for problems where
//! dense matrices would be prohibitively expensive. Essential for:
//! - Large HFB basis sets (nuclear physics)
//! - Finite element methods
//! - Graph algorithms
//! - Machine learning on sparse data
//!
//! # Precision Philosophy
//!
//! **Both CPU and GPU use f64 by default.**
//! GPU solvers use native WGSL f64 via SPIR-V/Vulkan, bypassing CUDA's
//! artificial fp64 throttle for 1:2-3 FP64:FP32 performance.
//!
//! # Storage Formats
//!
//! - **COO** (Coordinate): Easy construction, inefficient operations
//! - **CSR** (Compressed Sparse Row): Efficient row access, `SpMV`
//! - **CSC** (Compressed Sparse Column): Efficient column access
//!
//! # Solvers
//!
//! ## CPU Solvers
//! - **CG** (`cg_solve`): Conjugate Gradient for SPD matrices
//! - **`BiCGSTAB`** (`bicgstab_solve`): For general non-symmetric matrices
//! - **Jacobi** (`jacobi_solve`): Simple iterative method
//!
//! ## GPU Solvers (f64)
//! - **`CgGpu`** (`CgGpu::solve`): GPU-accelerated Conjugate Gradient (SPD)
//! - **`BiCgStabGpu`** (`BiCgStabGpu::solve`): GPU-accelerated `BiCGSTAB` (non-symmetric)
//!
//! ## Eigensolvers
//! - **`sparse_eigh`**: Lanczos-based eigenvalues for sparse symmetric matrices
//! - **`sparse_eigh_smallest`**: k smallest eigenvalues (extremal convergence)
//! - **`sparse_eigh_largest`**: k largest eigenvalues
//!
//! # Example
//!
//! ```
//! use barracuda::linalg::sparse::{CsrMatrix, cg_solve};
//!
//! // Build a sparse SPD matrix
//! let matrix = CsrMatrix::from_triplets(3, 3, &[
//! (0, 0, 4.0), (0, 1, -1.0),
//! (1, 0, -1.0), (1, 1, 4.0), (1, 2, -1.0),
//! (2, 1, -1.0), (2, 2, 4.0),
//! ]);
//!
//! let b = vec![1.0, 2.0, 3.0];
//! let x = cg_solve(&matrix, &b, 1e-10, 100)?;
//! # Ok::<(), barracuda::error::BarracudaError>(())
//! ```
//!
//! # Reference
//!
//! - hotSpring Phase 5 Handoff: Large HFB basis sets requirement
//! - Saad, Y. (2003). Iterative Methods for Sparse Linear Systems
// EVOLVED: Extracted common GPU helpers (Feb 14, 2026)
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;