Skip to content

Commit 71142f7

Browse files
Fix default tolerance for complex
Fixes #38
1 parent d8054e0 commit 71142f7

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/common.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,15 @@ init_cacheval(alg::Union{SciMLLinearSolveAlgorithm,Nothing}, A, b, u) = nothing
6969

7070
SciMLBase.init(prob::LinearProblem, args...; kwargs...) = SciMLBase.init(prob,nothing,args...;kwargs...)
7171

72+
default_tol(::Type{T}) where T = (eps(T))
73+
default_tol(::Type{Complex{T}}) where T = (eps(T))
74+
default_tol(::Type{<:Rational}) = 0
75+
default_tol(::Type{<:Integer}) = 0
76+
7277
function SciMLBase.init(prob::LinearProblem, alg::Union{SciMLLinearSolveAlgorithm,Nothing}, args...;
7378
alias_A = false, alias_b = false,
74-
abstol=eps(eltype(prob.A)),
75-
reltol=eps(eltype(prob.A)),
79+
abstol=default_tol(prob.A),
80+
reltol=default_tol(prob.A),
7681
maxiters=length(prob.b),
7782
verbose=false,
7883
Pl = nothing,

test/runtests.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,8 @@ end
189189
u = solve(prob1, alg; cache_kwargs...)
190190
@test A1 * u b1
191191

192-
# common interface doesn't support complex types
193-
# https://github.com/SciML/LinearSolve.jl/issues/38
194-
195-
# u = solve(prob2, alg; cache_kwargs...)
196-
# @test A2 * u ≈ b2
192+
u = solve(prob2, alg; cache_kwargs...)
193+
@test A2 * u b2
197194
end
198195

199196
end

0 commit comments

Comments
 (0)