Skip to content

Commit c4ca9ff

Browse files
committed
defaults
1 parent 1f7a20b commit c4ca9ff

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/function_call.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
21
""" user passes in inverse function, and arg symbols """
3-
struct FunctionCall{F,A} <: SciMLLinearSolveAlgorithm
2+
struct FunctionCall{F,A} <: AbstractFunctionCall
43
func!::F
54
argnames::A
65

7-
function FunctionCall(func!::Function, argnames::Tuple)
6+
function FunctionCall(func!::Function=LinearAlgebra.ldiv!,
7+
argnames::Tuple=(:u, :A, :b),
8+
)
89
# @assert hasfield(::LinearCache, argnames)
910
# @assert isdefined
1011
new{typeof(func!), typeof(argnames)}(func!, argnames)
@@ -27,7 +28,7 @@ end
2728
##
2829

2930
""" apply ldiv!(A, u) """
30-
struct ApplyLDivBang2Args <: SciMLLinearSolveAlgorithm end
31+
struct ApplyLDivBang2Args <: AbstractFunctionCall end
3132
function SciMLBase.solve(cache::LinearCache, alg::ApplyLDivBang2Args,
3233
args...; kwargs...)
3334
@unpack A, b, u = cache
@@ -37,10 +38,12 @@ function SciMLBase.solve(cache::LinearCache, alg::ApplyLDivBang2Args,
3738
end
3839

3940
""" apply ldiv!(u, A, b) """
40-
struct ApplyLDivBang3Args <: SciMLLinearSolveAlgorithm end
41+
struct ApplyLDivBang3Args <: AbstractFunctionCall end
4142
function SciMLBase.solve(cache::LinearCache, alg::ApplyLDivBang3Args,
4243
args...; kwargs...)
4344
@unpack A, b, u = cache
4445
LinearAlgebra.ldiv!(u, A, b)
4546
return SciMLBase.build_linear_solution(alg,cache.u,nothing,cache)
4647
end
48+
49+
ApplyLDivBang() = ApplyLDivBang3Args()

test/basictests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ end
4848

4949
for alg in (
5050
FunctionCall(LinearAlgebra.ldiv!, (:u, :A, :b)),
51+
ApplyLDivBang(),
5152
ApplyLDivBang2Args(),
5253
ApplyLDivBang3Args(),
5354
)
@@ -85,13 +86,13 @@ end
8586
for alg in (
8687
FunctionCall(LinearAlgebra.ldiv!, (:u, :A, :b)),
8788
FunctionCall(my_inv!, (:A, :u, :b)),
89+
ApplyLDivBang(),
8890
ApplyLDivBang2Args(),
8991
ApplyLDivBang3Args(),
9092
)
9193
test_interface(alg, prob1, prob2)
9294
end
9395
end
94-
9596
end
9697
#=
9798

0 commit comments

Comments
 (0)