Skip to content

Commit

Permalink
format; let failing tests for duals ring
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fu committed Jan 24, 2023
1 parent 974ff9e commit fc4ae65
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/iterative_wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ function SciMLBase.solve(cache::LinearCache, alg::KrylovJL; kwargs...)
N = (N === Identity()) ? I : InvPreconditioner(N)

Ta = eltype(cache.A)

atol = Ta(float(cache.abstol))
rtol = Ta(float(cache.reltol))
itmax = cache.maxiters
verbose = cache.verbose ? 1 : 0

args = (cache.cacheval, cache.A, cache.b)
kwargs = (atol = atol, rtol = rtol, itmax = itmax, verbose = verbose,
history = true, alg.kwargs...)
Expand Down
36 changes: 18 additions & 18 deletions test/basictests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ using Test
import Random

const Dual64 = ForwardDiff.Dual{Nothing, Float64, 1}
Base.:^(x::MultiFloat{T, N}, y::Int) where {T,N} = MultiFloat{T, N}(BigFloat(x)^y)
Base.:^(x::MultiFloat{T, N}, y::Float64) where {T,N} = MultiFloat{T, N}(BigFloat(x)^y)
Base.:^(x::MultiFloat{T, N}, y::Int) where {T, N} = MultiFloat{T, N}(BigFloat(x)^y)
Base.:^(x::MultiFloat{T, N}, y::Float64) where {T, N} = MultiFloat{T, N}(BigFloat(x)^y)

n = 8
A = Matrix(I, n, n)
Expand All @@ -21,7 +21,7 @@ prob2 = LinearProblem(A2, b2; u0 = x2)

cache_kwargs = (; verbose = true, abstol = 1e-8, reltol = 1e-8, maxiter = 30)

function test_interface(alg, prob1, prob2; T=Float64)
function test_interface(alg, prob1, prob2; T = Float64)
A1 = prob1.A .|> T
b1 = prob1.b .|> T
x1 = prob1.u0 .|> T
Expand All @@ -31,7 +31,7 @@ function test_interface(alg, prob1, prob2; T=Float64)

myprob1 = LinearProblem(A1, b1; u0 = x1)
myprob2 = LinearProblem(A2, b2; u0 = x2)

y = solve(myprob1, alg; cache_kwargs...)
@test A1 * y b1

Expand Down Expand Up @@ -154,7 +154,7 @@ end

prob1 = LinearProblem(A1, b1; u0 = x1)
prob2 = LinearProblem(A2, b2; u0 = x2)
test_interface(SparspakFactorization(), prob1, prob2; T=Float64x1)
test_interface(SparspakFactorization(), prob1, prob2; T = Float64x1)
end

@testset "Sparspak Factorization (Float64x2)" begin
Expand All @@ -167,7 +167,7 @@ end

prob1 = LinearProblem(A1, b1; u0 = x1)
prob2 = LinearProblem(A2, b2; u0 = x2)
test_interface(SparspakFactorization(), prob1, prob2; T=Float64x2)
test_interface(SparspakFactorization(), prob1, prob2; T = Float64x2)
end

@testset "Sparspak Factorization (Dual64)" begin
Expand All @@ -180,9 +180,9 @@ end

prob1 = LinearProblem(A1, b1; u0 = x1)
prob2 = LinearProblem(A2, b2; u0 = x2)
test_interface(SparspakFactorization(), prob1, prob2; T=Dual64)
test_interface(SparspakFactorization(), prob1, prob2; T = Dual64)
end

@testset "FastLAPACK Factorizations" begin
A1 = A / 1
b1 = rand(n)
Expand Down Expand Up @@ -232,9 +232,9 @@ end
("MINRES", KrylovJL_MINRES(kwargs...)))
@testset "$(alg[1])" begin
test_interface(alg[2], prob1, prob2)
test_interface(alg[2], prob1, prob2; T=Float64x1)
test_interface(alg[2], prob1, prob2; T=Float64x2)
# test_interface(alg[2], prob1, prob2; T=Dual64)
test_interface(alg[2], prob1, prob2; T = Float64x1)
test_interface(alg[2], prob1, prob2; T = Float64x2)
test_interface(alg[2], prob1, prob2; T = Dual64)
# https://github.com/JuliaSmoothOptimizers/Krylov.jl/issues/646
# ForwardDiff.Dual is a Real, not an AbstractFloat
end
Expand All @@ -251,10 +251,10 @@ end
)
@testset "$(alg[1])" begin
test_interface(alg[2], prob1, prob2)
test_interface(alg[2], prob1, prob2; T=Float64x1)
test_interface(alg[2], prob1, prob2; T=Float64x2)
# test_interface(alg[2], prob1, prob2; T=Dual64)
# https://github.com/JuliaLang/julia/blob/master/stdlib/LinearAlgebra/src/givens.jl#L77
test_interface(alg[2], prob1, prob2; T = Float64x1)
test_interface(alg[2], prob1, prob2; T = Float64x2)
test_interface(alg[2], prob1, prob2; T = Dual64)
# https://github.com/JuliaLang/julia/issues/41753
# ForwardDiff.Dual is a Real, not an AbstractFloat
end
end
Expand All @@ -267,9 +267,9 @@ end
("GMRES", KrylovKitJL_GMRES(kwargs...)))
@testset "$(alg[1])" begin
test_interface(alg[2], prob1, prob2)
test_interface(alg[2], prob1, prob2; T=Float64x1)
test_interface(alg[2], prob1, prob2; T=Float64x2)
test_interface(alg[2], prob1, prob2; T=Dual64)
test_interface(alg[2], prob1, prob2; T = Float64x1)
test_interface(alg[2], prob1, prob2; T = Float64x2)
test_interface(alg[2], prob1, prob2; T = Dual64)
end
@test alg[2] isa KrylovKitJL
end
Expand Down

0 comments on commit fc4ae65

Please sign in to comment.