File tree Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ julia> C.U
6565 ⋅ ⋅ 3.0
6666
6767julia> C.L
68- 3×3 LowerTriangular{Float64, Matrix{Float64}}:
68+ 3×3 LowerTriangular{Float64, Adjoint{ Matrix{Float64} }}:
6969 2.0 ⋅ ⋅
7070 6.0 1.0 ⋅
7171 -8.0 5.0 3.0
@@ -530,7 +530,7 @@ julia> C.U
530530 ⋅ ⋅ 3.0
531531
532532julia> C.L
533- 3×3 LowerTriangular{Float64, Matrix{Float64}}:
533+ 3×3 LowerTriangular{Float64, Adjoint{ Matrix{Float64} }}:
534534 2.0 ⋅ ⋅
535535 6.0 1.0 ⋅
536536 -8.0 5.0 3.0
@@ -668,14 +668,14 @@ function _choleskyUfactor(Cfactors, Cuplo)
668668 if Cuplo === ' U'
669669 return UpperTriangular (Cfactors)
670670 else
671- return copy ( LowerTriangular (Cfactors)' )
671+ return LowerTriangular (Cfactors)'
672672 end
673673end
674674function _choleskyLfactor (Cfactors, Cuplo)
675675 if Cuplo === ' L'
676676 return LowerTriangular (Cfactors)
677677 else
678- return copy ( UpperTriangular (Cfactors)' )
678+ return UpperTriangular (Cfactors)'
679679 end
680680end
681681
Original file line number Diff line number Diff line change 595595 B = cholesky (A)
596596 B32 = cholesky (Float32 .(A))
597597 @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} }
601601 @test B. U ≈ B32. U
602602 @test B. L ≈ B32. L
603603 @test B. UL ≈ B32. UL
658658 end
659659end
660660
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 (Val (true ), Val (false ))
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+
661679end # module TestCholesky
You can’t perform that action at this time.
0 commit comments