File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,6 +57,28 @@ struct LinearSolveWrapper{A <: LinearSolve.SciMLLinearSolveAlgorithm} <: CoarseS
5757end
5858(p:: LinearSolveWrapper )(A:: AbstractMatrix ) = LinearSolveWrapperInternal (A, p. alg)
5959
60+
61+ """
62+ QRSolver{F} <: CoarseSolver
63+
64+ Coarse solver using Julia's built-in factorizations via `qr()`.
65+ """
66+ struct QRSolver{F} <: CoarseSolver
67+ factorization:: F
68+ function QRSolver (A)
69+ fact = qr (A)
70+ new {typeof(fact)} (fact)
71+ end
72+ end
73+ Base. show (io:: IO , p:: QRSolver ) = print (io, " QRSolver" )
74+
75+ function (solver:: QRSolver )(x, b)
76+ # Handle multiple RHS efficiently
77+ for i ∈ 1 : size (b, 2 )
78+ # Use backslash - Julia's factorizations are optimized for this
79+ x[:, i] = solver. factorization \ b[:, i]
80+ end
81+ end
82+
6083# Guess the best coarse solver based on the matrix type
61- _default_coarse_solver (A) = Pinv
62- _default_coarse_solver (A:: AbstractSparseMatrix{<:Float64} ) = LinearSolveWrapper (LinearSolve. UMFPACKFactorization ())
84+ _default_coarse_solver (A) = QRSolver
You can’t perform that action at this time.
0 commit comments