Skip to content

Commit 61ea0eb

Browse files
committed
a reasonable test
1 parent 6022080 commit 61ea0eb

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

test/runtests.jl

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@ using LinearSolve
22
using Test
33

44
@testset "LinearSolve.jl" begin
5-
n = 10
6-
A = rand(n, n)
7-
b = rand(n)
5+
using LinearAlgebra
6+
n = 100
7+
x = Array(range(start=-1,stop=1,length=n))
8+
uu= @. sin(pi*x)
9+
10+
dx = 2/(n-1)
11+
12+
AA = Tridiagonal(ones(n-1),-2ones(n),ones(n-1))/(dx*dx)
13+
bb = @. -(pi^2)*uu
14+
id = Matrix(I,n,n)
15+
R = id[2:end-1,:]
16+
17+
A = R * AA * R'
18+
u = R * uu
19+
b = A * u #R * bb
20+
21+
@test isapprox(A*u,b;atol=1e-2)
822
prob = LinearProblem(A, b)
923

10-
x = rand(n)
24+
x = zero(b)
1125

1226
# Factorization
1327
@test A * solve(prob, LUFactorization();) b
@@ -18,10 +32,21 @@ using Test
1832
@test A * solve(prob, KrylovJL(A, b)) b
1933

2034
# make algorithm callable - interoperable with DiffEq ecosystem
21-
@test A * LUFactorization()(x,A,b) b
22-
@test A * KrylovJL()(x,A,b) b
35+
@test A * LUFactorization()(x,A,b) b
36+
@test A * QRFactorization()(x,A,b) b
37+
@test A * SVDFactorization()(x,A,b) b
38+
@test A * KrylovJL()(x,A,b) b
2339

2440
# in place
25-
KrylovJL()(x,A,b)
41+
LUFactorization()(x,A,b)
2642
@test A * x b
43+
QRFactorization()(x,A,b)
44+
@test A * x b
45+
SVDFactorization()(x,A,b)
46+
@test A * x b
47+
KrylovJL()(x,A,b)
48+
@test A * x b
49+
50+
# test on some ODEProblem
51+
# using OrdinaryDiffEq
2752
end

0 commit comments

Comments
 (0)