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
//! Pluggable backend trait for linear algebra operations.
//!
//! This module defines the [`Backend`] trait, which abstracts core linear algebra
//! operations (matrix multiply, SVD, QR, Cholesky, eigendecomposition, etc.).
//! Algorithms that need these operations can be generic over `Backend`, allowing
//! the implementation to be swapped at compile time (e.g., pure-Rust `faer` vs
//! system BLAS/LAPACK).
//!
//! The default backend is [`NdarrayFaerBackend`](crate::backend_faer::NdarrayFaerBackend),
//! which delegates to the `faer` crate for high-performance decompositions and
//! uses `ndarray::dot` for general matrix multiply.
//!
//! # Design
//!
//! All methods on `Backend` are associated functions (no `&self`). The backend
//! is a zero-sized type used as a type parameter, not as an instance:
//!
//! ```ignore
//! fn my_algorithm<B: Backend>(data: &Array2<f64>) -> FerroResult<Array1<f64>> {
//! let (u, s, vt) = B::svd(data)?;
//! // ...
//! }
//! ```
use crateFerroResult;
use ;
/// Trait abstracting core linear algebra operations.
///
/// Algorithms that need matrix operations (SVD, QR, eigendecomposition, etc.)
/// can be generic over this trait, allowing the backend to be swapped
/// (e.g., pure-Rust faer vs system BLAS/LAPACK).
///
/// All methods are associated functions operating on `ndarray` arrays.
/// The implementing type is typically a zero-sized struct used solely as
/// a type parameter.