Skip to content

Commit 43541f1

Browse files
haampieandreasnoack
authored andcommitted
Fix IterativeSolvers.jl for Julia 0.7 (#162)
* Escape backslash * Fix Bidiagonal deprecation * Comment out the assertion that breaks on 0.7 * Test whether convergence history objects are returned when log = true * Check uplo on .7 and isupper on .6
1 parent d41f60d commit 43541f1

File tree

13 files changed

+22
-10
lines changed

13 files changed

+22
-10
lines changed

src/lsmr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ lsmr(A, b; kwargs...) = lsmr!(zerox(A, b), A, b; kwargs...)
1212
"""
1313
lsmr!(x, A, b; kwargs...) -> x, [history]
1414
15-
Minimizes ``\|Ax - b\|^2 + \|λx\|^2`` in the Euclidean norm. If multiple solutions
15+
Minimizes ``\\|Ax - b\\|^2 + \\|λx\\|^2`` in the Euclidean norm. If multiple solutions
1616
exists the minimum norm solution is returned.
1717
1818
The method is based on the Golub-Kahan bidiagonalization process. It is

src/lsqr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ lsqr(A, b; kwargs...) = lsqr!(zerox(A, b), A, b; kwargs...)
1010
"""
1111
lsqr!(x, A, b; kwargs...) -> x, [history]
1212
13-
Minimizes ``\|Ax - b\|^2 + \|damp*x\|^2`` in the Euclidean norm. If multiple solutions
13+
Minimizes ``\\|Ax - b\\|^2 + \\|damp*x\\|^2`` in the Euclidean norm. If multiple solutions
1414
exists returns the minimal norm solution.
1515
1616
The method is based on the Golub-Kahan bidiagonalization process.

src/svdl.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,8 @@ function build(log::ConvergenceHistory, A, q::AbstractVector{T}, k::Int) where {
356356
p = A*q
357357
α = convert(Tr, norm(p))
358358
@blas! p *= inv(α)
359-
extend!(log, A, PartialFactorization(
360-
reshape(p, m, 1), reshape(q, n, 1), Bidiagonal([α], Tr[], true), β
361-
), k)
359+
bidiag = Bidiagonal([α], Tr[], @static VERSION < v"0.7.0-DEV.884" ? true : :U)
360+
extend!(log, A, PartialFactorization(reshape(p, m, 1), reshape(q, n, 1), bidiag, β), k)
362361
end
363362

364363

@@ -445,7 +444,9 @@ function harmonicrestart!(A, L::PartialFactorization{T,Tr},
445444
#Compute scaled residual from the harmonic Ritz problem
446445
r0 = zeros(Tr, m)
447446
r0[end] = 1
448-
isa(L.B, Bidiagonal) && @assert L.B.isupper
447+
if isa(L.B, Bidiagonal)
448+
@assert @static VERSION < v"0.7.0-DEV.884" ? L.B.isupper : L.B.uplo == 'U'
449+
end
449450
r = try
450451
#(L.B\r0)
451452
A_ldiv_B!(L.B, r0)

test/bicgstabl.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ n = 20
1616
@testset "BiCGStab($l)" for l = (2, 4)
1717
# Solve without preconditioner
1818
x1, his1 = bicgstabl(A, b, l, max_mv_products = 100, log = true, tol = tol)
19+
@test isa(his1, ConvergenceHistory)
1920
@test norm(A * x1 - b) / norm(b) tol
2021

2122
# Do an exact LU decomp of a nearby matrix

test/cg.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ srand(1234321)
1818
tol = eps(real(T))
1919

2020
x,ch = cg(A, b; tol=tol, maxiter=2n, log=true)
21+
@test isa(ch, ConvergenceHistory)
2122
@test norm(A*x - b) / norm(b) tol
2223
@test ch.isconverged
2324

test/chebyshev.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ srand(1234321)
2626
tol = (eps(real(T)))
2727

2828
x, history = chebyshev(A, b, λ_min, λ_max, tol=tol, maxiter=10n, log=true)
29+
@test isa(history, ConvergenceHistory)
2930
@test history.isconverged
3031
@test norm(A * x - b) / norm(b) tol
3132

test/gmres.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ n = 10
1717

1818
# Test optimality condition: residual should be non-increasing
1919
x, history = gmres(A, b, log = true, restart = 3, maxiter = 10, tol = tol);
20+
@test isa(history, ConvergenceHistory)
2021
@test all(diff(history[:resnorm]) .<= 0.0)
2122

2223
# Left exact preconditioner

test/idrs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ srand(1234567)
1414

1515
@testset "Without residual smoothing" begin
1616
x, history = idrs(A, b, log=true)
17+
@test isa(history, ConvergenceHistory)
1718
@test history.isconverged
1819
@test norm(A * x - b) / norm(b) tol
1920
end

test/lsmr.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ end
101101
@testset "Small dense matrix" for T = (Float32, Float64)
102102
A = rand(T, 10, 5)
103103
b = rand(T, 10)
104-
x = lsmr(A, b)
104+
x, history = lsmr(A, b, log = true)
105+
@test isa(history, ConvergenceHistory)
105106
@test norm(x - A\b) eps(T)
106107
end
107108

test/lsqr.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ srand(1234321)
1010
A = rand(T, 10, 5)
1111
b = rand(T, 10)
1212
x, history = lsqr(A, b, log = true)
13+
@test isa(history, ConvergenceHistory)
1314
@test norm(x - A\b) eps(T)
1415
@test history.isconverged
1516
@test last(history[:resnorm]) norm(b - A * x) atol=eps(T)

0 commit comments

Comments
 (0)