Skip to content

Commit 38573da

Browse files
bmxammbouyges
andauthored
Add DirectLinearSolver support for length-1 vectors (#200)
* Add DirectLinearSolver support for length-1 vectors * Fix test * remove example from gallery --------- Co-authored-by: mbouyges <maxime.bouyges@onera.fr>
1 parent 96c2a72 commit 38573da

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/settings.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ Specify that linear systems `Ax = b` should be solved with a direct method.
1919
struct DirectLinearSolver <: AbstractSolver end
2020

2121
function (solver::DirectLinearSolver)(
22-
A::Union{AbstractMatrix,Factorization}, _Aᵀ, b::AbstractVector, x0::AbstractVector
22+
A::Union{AbstractMatrix,Factorization,Number},
23+
_Aᵀ,
24+
b::AbstractVector,
25+
x0::AbstractVector,
2326
)
2427
return A \ b
2528
end

test/systematic.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ using TestItems
1919
test_implicit(scen)
2020
test_implicit(scen2)
2121
end
22+
23+
# Test for output vector of length 1
24+
for (linear_solver, backends) in Iterators.product(
25+
[DirectLinearSolver(), IterativeLinearSolver()],
26+
[nothing, (; x=AutoForwardDiff(), y=AutoZygote())],
27+
)
28+
yield()
29+
scen = Scenario(;
30+
solver=x -> (sqrt.(x), nothing),
31+
conditions=(x, y, z) -> y .^ 2 .- x,
32+
x=[1.0],
33+
implicit_kwargs=(; representation, linear_solver, backends),
34+
)
35+
scen2 = add_arg_mult(scen)
36+
test_implicit(scen)
37+
test_implicit(scen2)
38+
end
2239
end;
2340

2441
@testitem "Operator" setup = [TestUtils] begin

0 commit comments

Comments
 (0)