@@ -21,7 +21,8 @@ using SciMLBase: SciMLBase, LinearAliasSpecifier, AbstractSciMLOperator,
21
21
using SciMLOperators: SciMLOperators, AbstractSciMLOperator, IdentityOperator,
22
22
MatrixOperator,
23
23
has_ldiv!, issquare
24
- using SciMLLogging: Verbosity, @SciMLMessage , verbosity_to_int, @match , AbstractVerbositySpecifier
24
+ using SciMLLogging: Verbosity, @SciMLMessage , verbosity_to_int, @match ,
25
+ AbstractVerbositySpecifier
25
26
using Setfield: @set , @set!
26
27
using UnPack: @unpack
27
28
using DocStringExtensions: DocStringExtensions
67
68
const useopenblas = false
68
69
end
69
70
70
-
71
71
@reexport using SciMLBase
72
72
73
73
"""
74
74
SciMLLinearSolveAlgorithm <: SciMLBase.AbstractLinearAlgorithm
75
75
76
76
The root abstract type for all linear solver algorithms in LinearSolve.jl.
77
- All concrete linear solver implementations should inherit from one of the
77
+ All concrete linear solver implementations should inherit from one of the
78
78
specialized subtypes rather than directly from this type.
79
79
80
80
This type integrates with the SciMLBase ecosystem, providing a consistent
@@ -92,39 +92,44 @@ matrices (e.g., `A = LU`, `A = QR`, `A = LDL'`) and then solve the system
92
92
using forward/backward substitution.
93
93
94
94
## Characteristics
95
- - Requires concrete matrix representation (`needs_concrete_A() = true`)
96
- - Typically efficient for multiple solves with the same matrix
97
- - Generally provides high accuracy for well-conditioned problems
98
- - Memory requirements depend on the specific factorization type
95
+
96
+ - Requires concrete matrix representation (`needs_concrete_A() = true`)
97
+ - Typically efficient for multiple solves with the same matrix
98
+ - Generally provides high accuracy for well-conditioned problems
99
+ - Memory requirements depend on the specific factorization type
99
100
100
101
## Subtypes
101
- - `AbstractDenseFactorization`: For dense matrix factorizations
102
- - `AbstractSparseFactorization`: For sparse matrix factorizations
102
+
103
+ - `AbstractDenseFactorization`: For dense matrix factorizations
104
+ - `AbstractSparseFactorization`: For sparse matrix factorizations
103
105
104
106
## Examples of concrete subtypes
105
- - `LUFactorization`, `QRFactorization`, `CholeskyFactorization`
106
- - `UMFPACKFactorization`, `KLUFactorization`
107
+
108
+ - `LUFactorization`, `QRFactorization`, `CholeskyFactorization`
109
+ - `UMFPACKFactorization`, `KLUFactorization`
107
110
"""
108
111
abstract type AbstractFactorization <: SciMLLinearSolveAlgorithm end
109
112
110
113
"""
111
114
AbstractSparseFactorization <: AbstractFactorization
112
115
113
116
Abstract type for factorization-based linear solvers optimized for sparse matrices.
114
- These algorithms take advantage of sparsity patterns to reduce memory usage and
117
+ These algorithms take advantage of sparsity patterns to reduce memory usage and
115
118
computational cost compared to dense factorizations.
116
119
117
- ## Characteristics
118
- - Optimized for matrices with many zero entries
119
- - Often use specialized pivoting strategies to preserve sparsity
120
- - May reorder rows/columns to minimize fill-in during factorization
121
- - Typically more memory-efficient than dense methods for sparse problems
120
+ ## Characteristics
121
+
122
+ - Optimized for matrices with many zero entries
123
+ - Often use specialized pivoting strategies to preserve sparsity
124
+ - May reorder rows/columns to minimize fill-in during factorization
125
+ - Typically more memory-efficient than dense methods for sparse problems
122
126
123
127
## Examples of concrete subtypes
124
- - `UMFPACKFactorization`: General sparse LU with partial pivoting
125
- - `KLUFactorization`: Sparse LU optimized for circuit simulation
126
- - `CHOLMODFactorization`: Sparse Cholesky for positive definite systems
127
- - `SparspakFactorization`: Envelope/profile method for sparse systems
128
+
129
+ - `UMFPACKFactorization`: General sparse LU with partial pivoting
130
+ - `KLUFactorization`: Sparse LU optimized for circuit simulation
131
+ - `CHOLMODFactorization`: Sparse Cholesky for positive definite systems
132
+ - `SparspakFactorization`: Envelope/profile method for sparse systems
128
133
"""
129
134
abstract type AbstractSparseFactorization <: AbstractFactorization end
130
135
@@ -136,16 +141,18 @@ These algorithms assume the matrix has no particular sparsity structure and use
136
141
dense linear algebra routines (typically from BLAS/LAPACK) for optimal performance.
137
142
138
143
## Characteristics
139
- - Optimized for matrices with few zeros or no sparsity structure
140
- - Leverage highly optimized BLAS/LAPACK routines when available
141
- - Generally provide excellent performance for moderately-sized dense problems
142
- - Memory usage scales as O(n²) with matrix size
143
-
144
- ## Examples of concrete subtypes
145
- - `LUFactorization`: Dense LU with partial pivoting (via LAPACK)
146
- - `QRFactorization`: Dense QR factorization for overdetermined systems
147
- - `CholeskyFactorization`: Dense Cholesky for symmetric positive definite matrices
148
- - `BunchKaufmanFactorization`: For symmetric indefinite matrices
144
+
145
+ - Optimized for matrices with few zeros or no sparsity structure
146
+ - Leverage highly optimized BLAS/LAPACK routines when available
147
+ - Generally provide excellent performance for moderately-sized dense problems
148
+ - Memory usage scales as O(n²) with matrix size
149
+
150
+ ## Examples of concrete subtypes
151
+
152
+ - `LUFactorization`: Dense LU with partial pivoting (via LAPACK)
153
+ - `QRFactorization`: Dense QR factorization for overdetermined systems
154
+ - `CholeskyFactorization`: Dense Cholesky for symmetric positive definite matrices
155
+ - `BunchKaufmanFactorization`: For symmetric indefinite matrices
149
156
"""
150
157
abstract type AbstractDenseFactorization <: AbstractFactorization end
151
158
@@ -157,23 +164,26 @@ These algorithms solve linear systems by iteratively building an approximation
157
164
from a sequence of Krylov subspaces, without requiring explicit matrix factorization.
158
165
159
166
## Characteristics
160
- - Does not require concrete matrix representation (`needs_concrete_A() = false`)
161
- - Only needs matrix-vector products `A*v` (can work with operators/functions)
162
- - Memory usage typically O(n) or O(kn) where k << n
163
- - Convergence depends on matrix properties (condition number, eigenvalue distribution)
164
- - Often benefits significantly from preconditioning
167
+
168
+ - Does not require concrete matrix representation (`needs_concrete_A() = false`)
169
+ - Only needs matrix-vector products `A*v` (can work with operators/functions)
170
+ - Memory usage typically O(n) or O(kn) where k << n
171
+ - Convergence depends on matrix properties (condition number, eigenvalue distribution)
172
+ - Often benefits significantly from preconditioning
165
173
166
174
## Advantages
167
- - Low memory requirements for large sparse systems
168
- - Can handle matrix-free operators (functions that compute `A*v`)
169
- - Often the only feasible approach for very large systems
170
- - Can exploit matrix structure through specialized operators
175
+
176
+ - Low memory requirements for large sparse systems
177
+ - Can handle matrix-free operators (functions that compute `A*v`)
178
+ - Often the only feasible approach for very large systems
179
+ - Can exploit matrix structure through specialized operators
171
180
172
181
## Examples of concrete subtypes
173
- - `GMRESIteration`: Generalized Minimal Residual method
174
- - `CGIteration`: Conjugate Gradient (for symmetric positive definite systems)
175
- - `BiCGStabLIteration`: Bi-Conjugate Gradient Stabilized
176
- - Wrapped external iterative solvers (KrylovKit.jl, IterativeSolvers.jl)
182
+
183
+ - `GMRESIteration`: Generalized Minimal Residual method
184
+ - `CGIteration`: Conjugate Gradient (for symmetric positive definite systems)
185
+ - `BiCGStabLIteration`: Bi-Conjugate Gradient Stabilized
186
+ - Wrapped external iterative solvers (KrylovKit.jl, IterativeSolvers.jl)
177
187
"""
178
188
abstract type AbstractKrylovSubspaceMethod <: SciMLLinearSolveAlgorithm end
179
189
@@ -184,15 +194,17 @@ Abstract type for linear solvers that wrap custom solving functions or
184
194
provide direct interfaces to specific solve methods. These provide flexibility
185
195
for integrating custom algorithms or simple solve strategies.
186
196
187
- ## Characteristics
188
- - Does not require concrete matrix representation (`needs_concrete_A() = false`)
189
- - Provides maximum flexibility for custom solving strategies
190
- - Can wrap external solver libraries or implement specialized algorithms
191
- - Performance and stability depend entirely on the wrapped implementation
197
+ ## Characteristics
198
+
199
+ - Does not require concrete matrix representation (`needs_concrete_A() = false`)
200
+ - Provides maximum flexibility for custom solving strategies
201
+ - Can wrap external solver libraries or implement specialized algorithms
202
+ - Performance and stability depend entirely on the wrapped implementation
192
203
193
204
## Examples of concrete subtypes
194
- - `LinearSolveFunction`: Wraps arbitrary user-defined solve functions
195
- - `DirectLdiv!`: Direct application of the `\\ ` operator
205
+
206
+ - `LinearSolveFunction`: Wraps arbitrary user-defined solve functions
207
+ - `DirectLdiv!`: Direct application of the `\\ ` operator
196
208
"""
197
209
abstract type AbstractSolveFunction <: SciMLLinearSolveAlgorithm end
198
210
@@ -205,22 +217,27 @@ Trait function that determines whether a linear solver algorithm requires
205
217
a concrete matrix representation or can work with abstract operators.
206
218
207
219
## Arguments
208
- - `alg`: A linear solver algorithm instance
220
+
221
+ - `alg`: A linear solver algorithm instance
209
222
210
223
## Returns
211
- - `true`: Algorithm requires a concrete matrix (e.g., for factorization)
212
- - `false`: Algorithm can work with abstract operators (e.g., matrix-free methods)
224
+
225
+ - `true`: Algorithm requires a concrete matrix (e.g., for factorization)
226
+ - `false`: Algorithm can work with abstract operators (e.g., matrix-free methods)
213
227
214
228
## Usage
229
+
215
230
This trait is used internally by LinearSolve.jl to optimize algorithm dispatch
216
231
and determine when matrix operators need to be converted to concrete arrays.
217
232
218
233
## Algorithm-Specific Behavior
219
- - `AbstractFactorization`: `true` (needs explicit matrix entries for factorization)
220
- - `AbstractKrylovSubspaceMethod`: `false` (only needs matrix-vector products)
221
- - `AbstractSolveFunction`: `false` (depends on the wrapped function's requirements)
234
+
235
+ - `AbstractFactorization`: `true` (needs explicit matrix entries for factorization)
236
+ - `AbstractKrylovSubspaceMethod`: `false` (only needs matrix-vector products)
237
+ - `AbstractSolveFunction`: `false` (depends on the wrapped function's requirements)
222
238
223
239
## Example
240
+
224
241
```julia
225
242
needs_concrete_A(LUFactorization()) # true
226
243
needs_concrete_A(GMRESIteration()) # false
0 commit comments