|
1 | 1 | using Base.Test
|
2 |
| -using LinearAlgebra |
| 2 | +import LinearAlgebra |
| 3 | +import LinearAlgebra: Ac_mul_A_RFP, TriangularRFP |
3 | 4 |
|
4 | 5 | @testset "Rectuangular Full Pack Format" begin
|
5 | 6 |
|
6 |
| - @testset "Element type: $elty. Problem size: $n" for elty in (Float32, Float64, Complex{Float32}, Complex{Float64}), |
7 |
| - n in (6, 7) |
| 7 | + @testset "Core generic functionality" for n in (6, 7), |
| 8 | + uplo in (:U, :L) |
| 9 | + |
| 10 | + A = rand(10, n) |
| 11 | + |
| 12 | + @testset "Hermitian" begin |
| 13 | + AcA_RFP = Ac_mul_A_RFP(A, uplo) |
| 14 | + |
| 15 | + @test size(AcA_RFP, 1) == n |
| 16 | + @test size(AcA_RFP, 2) == n |
| 17 | + @test size(AcA_RFP, 3) == 1 |
| 18 | + @test_throws BoundsError AcA_RFP[0, 1] |
| 19 | + @test_throws BoundsError AcA_RFP[1, 0] |
| 20 | + @test_throws BoundsError AcA_RFP[n + 1, 1] |
| 21 | + @test_throws BoundsError AcA_RFP[1, n + 1] |
| 22 | + |
| 23 | + @test AcA_RFP[2, 1] == AcA_RFP[1, 2] |
| 24 | + @test AcA_RFP[end - 2, end - 1] == AcA_RFP[end - 1, end - 2] |
| 25 | + end |
| 26 | + |
| 27 | + @testset "Triangular" begin |
| 28 | + Atr_RFP = TriangularRFP(triu(A'A), uplo) |
| 29 | + @test size(Atr_RFP, 1) == n |
| 30 | + @test size(Atr_RFP, 2) == n |
| 31 | + @test size(Atr_RFP, 3) == 1 |
| 32 | + |
| 33 | + # Indexing not implemented yet for Atr_RFP |
| 34 | + # @test_throws BoundsError Atr_RFP[0, 1] |
| 35 | + # @test_throws BoundsError Atr_RFP[1, 0] |
| 36 | + # @test_throws BoundsError Atr_RFP[n + 1, 1] |
| 37 | + # @test_throws BoundsError Atr_RFP[1, n + 1] |
| 38 | + |
| 39 | + @test_broken Atr_RFP[2, 1] == Atr_RFP[1, 2] |
| 40 | + @test_broken Atr_RFP[end - 2, end - 1] == Atr_RFP[end - 1, end - 2] |
| 41 | + end |
| 42 | + end |
| 43 | + |
| 44 | + @testset "Hermitian with element type: $elty. Problem size: $n" for elty in (Float32, Float64, Complex{Float32}, Complex{Float64}), |
| 45 | + n in (6, 7), |
| 46 | + uplo in (:L, :U) |
8 | 47 |
|
9 | 48 | A = rand(elty, 10, n)
|
10 | 49 | AcA = A'A
|
11 |
| - AcA_RFP = LinearAlgebra.Ac_mul_A_RFP(A) |
| 50 | + AcA_RFP = Ac_mul_A_RFP(A, uplo) |
12 | 51 | o = ones(elty, n)
|
13 | 52 |
|
14 | 53 | @test AcA ≈ A'A
|
15 | 54 | @test AcA\o ≈ AcA_RFP\o
|
16 | 55 | @test inv(AcA) ≈ inv(AcA_RFP)
|
| 56 | + @test inv(cholfact(AcA)) ≈ inv(factorize(AcA_RFP)) |
| 57 | + end |
| 58 | + |
| 59 | + @testset "Hermitian with element type: $elty. Problem size: $n" for elty in (Float32, Float64, Complex{Float32}, Complex{Float64}), |
| 60 | + n in (6, 7), |
| 61 | + uplo in (:L, :U) |
| 62 | + |
| 63 | + A = triu(rand(elty, n, n)) |
| 64 | + A_RFP = TriangularRFP(A) |
| 65 | + o = ones(elty, n) |
| 66 | + |
| 67 | + @test_broken A ≈ A_RFP |
| 68 | + @test A ≈ full(A_RFP) |
17 | 69 | end
|
18 | 70 | end
|
0 commit comments