Skip to content

Commit 641d11e

Browse files
committed
move defaults to func signature
1 parent d95e391 commit 641d11e

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/common.jl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ struct LinearCache{TA,Tb,Tu,Tp,Talg,Tc,Tl,Tr,Ttol}
88
isfresh::Bool # false => cacheval is set wrt A, true => update cacheval wrt A
99
Pl::Tl # store final preconditioner here. not being used rn
1010
Pr::Tr # wrappers are using preconditioner in cache.alg for now
11-
12-
# common arguments
1311
abstol::Ttol
1412
reltol::Ttol
1513
maxiters::Int
@@ -52,7 +50,10 @@ SciMLBase.init(prob::LinearProblem, args...; kwargs...) = SciMLBase.init(prob,no
5250

5351
function SciMLBase.init(prob::LinearProblem, alg::Union{SciMLLinearSolveAlgorithm,Nothing}, args...;
5452
alias_A = false, alias_b = false,
55-
abstol=0, reltol=0, maxiters=0, verbose=false,
53+
abstol=eps(eltype(prob.A)),
54+
reltol=eps(eltype(prob.A)),
55+
maxiters=length(prob.b),
56+
verbose=false,
5657
kwargs...,
5758
)
5859
@unpack A, b, u0, p = prob
@@ -69,11 +70,6 @@ function SciMLBase.init(prob::LinearProblem, alg::Union{SciMLLinearSolveAlgorith
6970
A = alias_A ? A : deepcopy(A)
7071
b = alias_b ? b : deepcopy(b)
7172

72-
73-
abstol = (abstol == 0) ? eps(eltype(A)) : abstol
74-
reltol = (reltol == 0) ? eps(eltype(A)) : reltol
75-
maxiters = (maxiters == 0) ? length(b) : maxiters
76-
7773
cache = LinearCache{
7874
typeof(A),
7975
typeof(b),
@@ -84,7 +80,6 @@ function SciMLBase.init(prob::LinearProblem, alg::Union{SciMLLinearSolveAlgorith
8480
typeof(Pl),
8581
typeof(Pr),
8682
typeof(reltol),
87-
typeof(maxiters)
8883
}(
8984
A,
9085
b,

0 commit comments

Comments
 (0)