Skip to content

Commit 7ddb8e4

Browse files
authored
Merge pull request #436 from tkoolen/tk/reduce-test-time
Reduce test time
2 parents b528a58 + 3efec6a commit 7ddb8e4

File tree

4 files changed

+41
-45
lines changed

4 files changed

+41
-45
lines changed

test/det.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@test det(@SMatrix [0 1; 1 0]) == -1
55
@test logdet(@SMatrix Complex{Float64}[0 1; 1 0]) == log(det(@SMatrix Complex{Float64}[0 1; 1 0]))
66
@test det(one(SMatrix{3,3})*im) == det([1.0*im 0.0 0.0; 0.0 1.0*im 0.0; 0.0 0.0 1.0*im])
7-
7+
88
@test det(@SMatrix [0 1 0; 1 0 0; 0 0 1]) == -1
99
m = [0.570085 0.667147 0.264427 0.561446
1010
0.115197 0.141744 0.83314 0.0457302
@@ -24,8 +24,8 @@
2424
@test det(Mtag) == det(Array(Mtag))
2525
end
2626

27-
# lu-based (sz in 5:14) and fallback (sz > 15)
28-
for sz in (5, 14, 15, 50), typ in (Float64, Complex{Float64})
27+
# lu-based (sz up to 14) and fallback (sz >= 15)
28+
for sz in (5, 8, 15), typ in (Float64, Complex{Float64})
2929
A = rand(typ, sz, sz)
3030
SA = SMatrix{sz,sz,typ}(A)
3131
@test det(A) det(SA)

test/inv.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ end
2525
@test inv(@SMatrix [1+im 2 0; 1 2-im 1; 1 1 2+im])::SMatrix [2-2im -3+1im 1-1im
2626
-1+0im 2+1im -1+0im
2727
0+1im 0-1im 1-0.0im]/2
28-
28+
2929
m = randn(Float64, 10,10) + 10*I # well conditioned
3030
@test inv(SMatrix{10,10}(m))::StaticMatrix inv(m)
3131

@@ -90,12 +90,10 @@ end
9090
@test inv(SMatrix{5,5}(m))::StaticMatrix inv(m)
9191
end
9292

93-
@testset "Matrix inverse NxN, N > 5" begin
94-
for sz in (5, 14, 15, 50), typ in (Float64, Complex{Float64})
95-
A = rand(typ, sz, sz)
96-
SA = SMatrix{sz,sz,typ}(A)
97-
@test inv(A) inv(SA)
98-
end
93+
@testset "Matrix inverse ($typ, $sz×$sz)" for sz in (5, 8, 15), typ in (Float64, Complex{Float64})
94+
A = rand(typ, sz, sz)
95+
SA = SMatrix{sz,sz,typ}(A)
96+
@test inv(A) inv(SA)
9997
end
10098

10199
#-------------------------------------------------------------------------------

test/lu.jl

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,39 @@
11
using StaticArrays, Compat.Test
22

3-
@testset "LU decomposition (pivot=$pivot)" for pivot in (true, false)
4-
@testset "$m×$n" for m in [0:4..., 15, 50], n in [0:4..., 15, 50]
5-
a = SMatrix{m,n,Int}(1:(m*n))
6-
l, u, p = @inferred(lu(a, Val{pivot}))
3+
@testset "LU decomposition ($m×$n, pivot=$pivot)" for pivot in (true, false), m in [0:4..., 15], n in [0:4..., 15]
4+
a = SMatrix{m,n,Int}(1:(m*n))
5+
l, u, p = @inferred(lu(a, Val{pivot}))
76

8-
# expected types
9-
@test p isa SVector{m,Int}
10-
if m==n
11-
@test l isa LowerTriangular{<:Any,<:SMatrix{m,n}}
12-
@test u isa UpperTriangular{<:Any,<:SMatrix{m,n}}
13-
else
14-
@test l isa SMatrix{m,min(m,n)}
15-
@test u isa SMatrix{min(m,n),n}
16-
end
17-
18-
if pivot
19-
# p is a permutation
20-
@test sort(p) == collect(1:m)
21-
else
22-
@test p == collect(1:m)
23-
end
7+
# expected types
8+
@test p isa SVector{m,Int}
9+
if m==n
10+
@test l isa LowerTriangular{<:Any,<:SMatrix{m,n}}
11+
@test u isa UpperTriangular{<:Any,<:SMatrix{m,n}}
12+
else
13+
@test l isa SMatrix{m,min(m,n)}
14+
@test u isa SMatrix{min(m,n),n}
15+
end
2416

25-
# l is unit lower triangular
26-
for i=1:m, j=(i+1):size(l,2)
27-
@test iszero(l[i,j])
28-
end
29-
for i=1:size(l,2)
30-
@test l[i,i] == 1
31-
end
17+
if pivot
18+
# p is a permutation
19+
@test sort(p) == collect(1:m)
20+
else
21+
@test p == collect(1:m)
22+
end
3223

33-
# u is upper triangular
34-
for i=1:size(u,1), j=1:i-1
35-
@test iszero(u[i,j])
36-
end
24+
# l is unit lower triangular
25+
for i=1:m, j=(i+1):size(l,2)
26+
@test iszero(l[i,j])
27+
end
28+
for i=1:size(l,2)
29+
@test l[i,i] == 1
30+
end
3731

38-
# decomposition is correct
39-
@test l*u a[p,:]
32+
# u is upper triangular
33+
for i=1:size(u,1), j=1:i-1
34+
@test iszero(u[i,j])
4035
end
36+
37+
# decomposition is correct
38+
@test l*u a[p,:]
4139
end

test/solve.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using StaticArrays, Compat.Test
22

33
@testset "Solving linear system" begin
4-
@testset "Problem size: $n x $n. Matrix type: $m. Element type: $elty" for n in (1,2,3,4,5,14,15,50),
4+
@testset "Problem size: $n x $n. Matrix type: $m. Element type: $elty" for n in (1,2,3,4,5,8,15),
55
(m, v) in ((SMatrix{n,n}, SVector{n}), (MMatrix{n,n}, MVector{n})),
66
elty in (Float64, Int)
77

@@ -18,7 +18,7 @@ using StaticArrays, Compat.Test
1818
end
1919

2020
@testset "Solving linear system (multiple RHS)" begin
21-
@testset "Problem size: $n x $n. Matrix type: $m1. Element type: $elty" for n in (1,2,3,4,5,14,15,50),
21+
@testset "Problem size: $n x $n. Matrix type: $m1. Element type: $elty" for n in (1,2,3,4,5,8,15),
2222
(m1, m2) in ((SMatrix{n,n}, SMatrix{n,2}), (MMatrix{n,n}, MMatrix{n,2})),
2323
elty in (Float64, Int)
2424

0 commit comments

Comments
 (0)