|
1 | 1 | using StaticArrays, Base.Test
|
2 | 2 |
|
3 | 3 | @testset "SVD factorization" begin
|
| 4 | + m3 = @SMatrix Float64[3 9 4; 6 6 2; 3 7 9] |
| 5 | + m3c = Complex128.(m3) |
| 6 | + m23 = @SMatrix Float64[3 9 4; 6 6 2] |
| 7 | + |
4 | 8 | @testset "svd" begin
|
5 | 9 | @testinf svdvals(@SMatrix [2 0; 0 0])::StaticVector ≊ [2, 0]
|
6 | 10 | @testinf svdvals((@SMatrix [2 -2; 1 1]) / sqrt(2)) ≊ [2, 1]
|
7 | 11 |
|
8 |
| - m3 = @SMatrix Float64[3 9 4; 6 6 2; 3 7 9] |
9 |
| - @testinf svdvals(m3) ≈ svdvals(Matrix(m3)) |
| 12 | + @testinf svdvals(m3) ≊ svdvals(Matrix(m3)) |
| 13 | + @testinf svdvals(m3c) isa SVector{3,Float64} |
10 | 14 |
|
11 |
| - @testinf svd(m3)[1]::StaticMatrix ≈ svd(Matrix(m3))[1] |
12 |
| - @testinf svd(m3)[2]::StaticVector ≈ svd(Matrix(m3))[2] |
13 |
| - @testinf svd(m3)[3]::StaticMatrix ≈ svd(Matrix(m3))[3] |
| 15 | + @testinf svd(m3)[1]::StaticMatrix ≊ svd(Matrix(m3))[1] |
| 16 | + @testinf svd(m3)[2]::StaticVector ≊ svd(Matrix(m3))[2] |
| 17 | + @testinf svd(m3)[3]::StaticMatrix ≊ svd(Matrix(m3))[3] |
14 | 18 | end
|
15 | 19 |
|
16 | 20 | @testset "svdfact" begin
|
17 | 21 | @test_throws ErrorException svdfact(@SMatrix [1 0; 0 1])[:U]
|
18 | 22 |
|
19 | 23 | @testinf svdfact(@SMatrix [2 0; 0 0]).U === eye(SMatrix{2,2})
|
20 |
| - @testinf svdfact(@SMatrix [2 0; 0 0]).S === SVector(2, 0) |
| 24 | + @testinf svdfact(@SMatrix [2 0; 0 0]).S === SVector(2.0, 0.0) |
21 | 25 | @testinf svdfact(@SMatrix [2 0; 0 0]).Vt === eye(SMatrix{2,2})
|
22 | 26 |
|
23 | 27 | @testinf svdfact((@SMatrix [2 -2; 1 1]) / sqrt(2)).U ≊ [-1 0; 0 1]
|
24 | 28 | @testinf svdfact((@SMatrix [2 -2; 1 1]) / sqrt(2)).S ≊ [2, 1]
|
25 | 29 | @testinf svdfact((@SMatrix [2 -2; 1 1]) / sqrt(2)).Vt ≊ [-1 1; 1 1]/sqrt(2)
|
26 | 30 |
|
27 |
| - m23 = @SMatrix Float64[3 9 4; 6 6 2] |
28 | 31 | @testinf svdfact(m23).U ≊ svdfact(Matrix(m23))[:U]
|
29 | 32 | @testinf svdfact(m23).S ≊ svdfact(Matrix(m23))[:S]
|
30 | 33 | @testinf svdfact(m23).Vt ≊ svdfact(Matrix(m23))[:Vt]
|
31 | 34 |
|
32 | 35 | @testinf svdfact(m23').U ≊ svdfact(Matrix(m23'))[:U]
|
33 | 36 | @testinf svdfact(m23').S ≊ svdfact(Matrix(m23'))[:S]
|
34 | 37 | @testinf svdfact(m23').Vt ≊ svdfact(Matrix(m23'))[:Vt]
|
| 38 | + |
| 39 | + @testinf svdfact(m3c).U ≊ svdfact(Matrix(m3c))[:U] |
| 40 | + @testinf svdfact(m3c).S ≊ svdfact(Matrix(m3c))[:S] |
| 41 | + @testinf svdfact(m3c).Vt ≊ svdfact(Matrix(m3c))[:Vt] |
| 42 | + |
| 43 | + @testinf svdfact(m3c).U isa SMatrix{3,3,Complex128} |
| 44 | + @testinf svdfact(m3c).S isa SVector{3,Float64} |
| 45 | + @testinf svdfact(m3c).Vt isa SMatrix{3,3,Complex128} |
35 | 46 | end
|
36 | 47 | end
|
0 commit comments