@@ -595,18 +595,18 @@ end
595
595
B = cholesky (A)
596
596
B32 = cholesky (Float32 .(A))
597
597
@test B isa Cholesky{Float16, Matrix{Float16}}
598
- @test B. U isa UpperTriangular{Float16, Matrix {Float16}}
599
- @test B. L isa LowerTriangular{Float16, Matrix {Float16}}
600
- @test B. UL isa UpperTriangular{Float16, Matrix {Float16}}
598
+ @test B. U isa UpperTriangular{Float16, <: AbstractMatrix {Float16} }
599
+ @test B. L isa LowerTriangular{Float16, <: AbstractMatrix {Float16} }
600
+ @test B. UL isa UpperTriangular{Float16, <: AbstractMatrix {Float16} }
601
601
@test B. U ≈ B32. U
602
602
@test B. L ≈ B32. L
603
603
@test B. UL ≈ B32. UL
604
604
@test Matrix (B) ≈ A
605
605
B = cholesky (A, RowMaximum ())
606
606
B32 = cholesky (Float32 .(A), RowMaximum ())
607
- @test B isa CholeskyPivoted{Float16,Matrix {Float16}}
608
- @test B. U isa UpperTriangular{Float16, Matrix {Float16}}
609
- @test B. L isa LowerTriangular{Float16, Matrix {Float16}}
607
+ @test B isa CholeskyPivoted{Float16, <: AbstractMatrix {Float16} }
608
+ @test B. U isa UpperTriangular{Float16, <: AbstractMatrix {Float16} }
609
+ @test B. L isa LowerTriangular{Float16, <: AbstractMatrix {Float16} }
610
610
@test B. U ≈ B32. U
611
611
@test B. L ≈ B32. L
612
612
@test Matrix (B) ≈ A
658
658
end
659
659
end
660
660
661
+ @testset " accessing both L and U factors should avoid allocations" begin
662
+ n = 30
663
+ A = rand (n, n)
664
+ Apd = A' A
665
+ allowed_cost_of_overhead = 32
666
+ @assert sizeof (Apd) > 4 allowed_cost_of_overhead # ensure that we could positively identify extra copies
667
+
668
+ for uplo in (:L , :U )
669
+ C = Symmetric (Apd, uplo)
670
+ for val in (NoPivot (), RowMaximum ())
671
+ B = cholesky (C, val)
672
+ B. L, B. U # access once to ensure the accessor is compiled already
673
+ @test (@allocated B. L) <= allowed_cost_of_overhead
674
+ @test (@allocated B. U) <= allowed_cost_of_overhead
675
+ end
676
+ end
677
+ end
678
+
661
679
end # module TestCholesky
0 commit comments