Skip to content

Commit f49b8d8

Browse files
committed
Remove more uses of Symbol
1 parent b6bd5f5 commit f49b8d8

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/common.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ function Base.setproperty!(cache::LinearCache, name::Symbol, x)
9090
update_cacheval!(cache, :b, x)
9191
elseif name === :cacheval && cache.alg isa DefaultLinearSolver
9292
@assert cache.cacheval isa DefaultLinearSolverInit
93-
return setfield!(cache.cacheval, Symbol(cache.alg.alg), x)
93+
return __setfield!(cache.cacheval, cache.alg, x)
94+
# return setfield!(cache.cacheval, Symbol(cache.alg.alg), x)
9495
end
9596
setfield!(cache, name, x)
9697
end

src/default.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ mutable struct DefaultLinearSolverInit{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
2424
KrylovJL_LSMR::T21
2525
end
2626

27+
@generated function __setfield!(cache::DefaultLinearSolverInit, alg::DefaultLinearSolver, v)
28+
ex = :()
29+
for alg in first.(EnumX.symbol_map(DefaultAlgorithmChoice.T))
30+
newex = quote
31+
setfield!(cache, $(Meta.quot(alg)), v)
32+
end
33+
alg_enum = getproperty(LinearSolve.DefaultAlgorithmChoice, alg)
34+
ex = if ex == :()
35+
Expr(:elseif, :(alg.alg == $(alg_enum)), newex,
36+
:(error("Algorithm Choice not Allowed")))
37+
else
38+
Expr(:elseif, :(alg.alg == $(alg_enum)), newex, ex)
39+
end
40+
end
41+
ex = Expr(:if, ex.args...)
42+
end
43+
2744
# Legacy fallback
2845
# For SciML algorithms already using `defaultalg`, all assume square matrix.
2946
defaultalg(A, b) = defaultalg(A, b, OperatorAssumptions(true))
@@ -218,7 +235,6 @@ function defaultalg(A, b, assump::OperatorAssumptions{Bool})
218235
DefaultLinearSolver(alg)
219236
end
220237

221-
@inline algchoice_to_alg(::Val{alg}) where {alg} = algchoice_to_alg(alg)
222238
function algchoice_to_alg(alg::Symbol)
223239
if alg === :SVDFactorization
224240
SVDFactorization(false, LinearAlgebra.QRIteration())

0 commit comments

Comments
 (0)