Skip to content

Commit c3cace2

Browse files
committed
Split out SVD tests to make running them faster
1 parent 744f64c commit c3cace2

File tree

3 files changed

+37
-33
lines changed

3 files changed

+37
-33
lines changed

test/linalg.jl

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -147,37 +147,4 @@ using StaticArrays, Base.Test
147147
@test vecnorm(SVector{0, Float64}(()), 1) === 0.
148148
@test trace(SMatrix{0,0,Float64}(())) === 0.
149149
end
150-
151-
@testset "svd" begin
152-
@testinf svdvals(@SMatrix [2 0; 0 0]) [2, 0]
153-
@testinf svdvals((@SMatrix [2 -2; 1 1]) / sqrt(2)) [2, 1]
154-
155-
m3 = @SMatrix Float64[3 9 4; 6 6 2; 3 7 9]
156-
@testinf svdvals(m3) svdvals(Matrix(m3))
157-
158-
@testinf svd(m3)[1] svd(Matrix(m3))[1]
159-
@testinf svd(m3)[2] svd(Matrix(m3))[2]
160-
@testinf svd(m3)[3] svd(Matrix(m3))[3]
161-
end
162-
163-
@testset "svdfact" begin
164-
@test_throws ErrorException svdfact(@SMatrix [1 0; 0 1])[:U]
165-
166-
@testinf svdfact(@SMatrix [2 0; 0 0]).U === eye(SMatrix{2,2})
167-
@testinf svdfact(@SMatrix [2 0; 0 0]).S === SVector(2, 0)
168-
@testinf svdfact(@SMatrix [2 0; 0 0]).Vt === eye(SMatrix{2,2})
169-
170-
@testinf svdfact((@SMatrix [2 -2; 1 1]) / sqrt(2)).U [-1 0; 0 1]
171-
@testinf svdfact((@SMatrix [2 -2; 1 1]) / sqrt(2)).S [2, 1]
172-
@testinf svdfact((@SMatrix [2 -2; 1 1]) / sqrt(2)).Vt [-1 1; 1 1]/sqrt(2)
173-
174-
m23 = @SMatrix Float64[3 9 4; 6 6 2]
175-
@testinf svdfact(m23).U svdfact(Matrix(m23))[:U]
176-
@testinf svdfact(m23).S svdfact(Matrix(m23))[:S]
177-
@testinf svdfact(m23).Vt svdfact(Matrix(m23))[:Vt]
178-
179-
@testinf svdfact(m23').U svdfact(Matrix(m23'))[:U]
180-
@testinf svdfact(m23').S svdfact(Matrix(m23'))[:S]
181-
@testinf svdfact(m23').Vt svdfact(Matrix(m23'))[:Vt]
182-
end
183150
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ include("testutil.jl")
3333
include("chol.jl")
3434
include("deque.jl")
3535
include("io.jl")
36+
include("svd.jl")
3637

3738
include("fixed_size_arrays.jl")
3839
end

test/svd.jl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using StaticArrays, Base.Test
2+
3+
@testset "SVD" begin
4+
@testset "svd" begin
5+
@testinf svdvals(@SMatrix [2 0; 0 0]) [2, 0]
6+
@testinf svdvals((@SMatrix [2 -2; 1 1]) / sqrt(2)) [2, 1]
7+
8+
m3 = @SMatrix Float64[3 9 4; 6 6 2; 3 7 9]
9+
@testinf svdvals(m3) svdvals(Matrix(m3))
10+
11+
@testinf svd(m3)[1] svd(Matrix(m3))[1]
12+
@testinf svd(m3)[2] svd(Matrix(m3))[2]
13+
@testinf svd(m3)[3] svd(Matrix(m3))[3]
14+
end
15+
16+
@testset "svdfact" begin
17+
@test_throws ErrorException svdfact(@SMatrix [1 0; 0 1])[:U]
18+
19+
@testinf svdfact(@SMatrix [2 0; 0 0]).U === eye(SMatrix{2,2})
20+
@testinf svdfact(@SMatrix [2 0; 0 0]).S === SVector(2, 0)
21+
@testinf svdfact(@SMatrix [2 0; 0 0]).Vt === eye(SMatrix{2,2})
22+
23+
@testinf svdfact((@SMatrix [2 -2; 1 1]) / sqrt(2)).U [-1 0; 0 1]
24+
@testinf svdfact((@SMatrix [2 -2; 1 1]) / sqrt(2)).S [2, 1]
25+
@testinf svdfact((@SMatrix [2 -2; 1 1]) / sqrt(2)).Vt [-1 1; 1 1]/sqrt(2)
26+
27+
m23 = @SMatrix Float64[3 9 4; 6 6 2]
28+
@testinf svdfact(m23).U svdfact(Matrix(m23))[:U]
29+
@testinf svdfact(m23).S svdfact(Matrix(m23))[:S]
30+
@testinf svdfact(m23).Vt svdfact(Matrix(m23))[:Vt]
31+
32+
@testinf svdfact(m23').U svdfact(Matrix(m23'))[:U]
33+
@testinf svdfact(m23').S svdfact(Matrix(m23'))[:S]
34+
@testinf svdfact(m23').Vt svdfact(Matrix(m23'))[:Vt]
35+
end
36+
end

0 commit comments

Comments
 (0)