-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusymqr_test.jl
51 lines (47 loc) · 1.15 KB
/
usymqr_test.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using IterativeSolvers
include("usymqr.jl")
using Base.Test
using LinearMaps
function unsymmetric_problem(T, n)
A = rand(T, n, n)
x = ones(T, n)
b = A * x
A, x, b
end
srand(123)
n = 100
T = Float32
A, x, b = unsymmetric_problem(T, n)
tol = sqrt(eps(real(T)))
x0 = rand(T, n)
x1, hist1 = usymqr(A, b, maxiter = 10n, tol = tol, log = true)
hist1.isconverged
hist1[:resnorm]
norm(b - A * x1) / norm(b) ≤ tol
isa(hist1, ConvergenceHistory)
# @testset "Unsymmetric Matrix{$T}" for T in (Float32, Float64)
# A, x, b = unsymmetric_problem(T, n)
# tol = sqrt(eps(real(T)))
# x0 = rand(T, n)
#
# x1, hist1 = usymqr(A, b, maxiter = 10n, tol = tol, log = true)
#
# @test isa(hist1, ConvergenceHistory)
# @test norm(b - A * x1) / norm(b) ≤ tol
# @test hist1.isconverged
# end
#
# @testset "SparseMatrixCSC{$T}" for T in (Float32, Float64)
# A = let
# B = sprand(n, n, 2 / n)
# end
#
# x = ones(T, n)
# b = A * x
# tol = sqrt(eps(real(T)))
#
# x_approx, hist = usymqr(A, b, maxiter = 10n, tol = tol, log = true)
#
# @test norm(b - A * x_approx) / norm(b) ≤ tol
# @test hist.isconverged
# end