11using InfiniteLinearAlgebra, LinearAlgebra, BandedMatrices, ArrayLayouts, LazyBandedMatrices, Test
2- import InfiniteLinearAlgebra: SymmetricBandedLayouts
2+ import InfiniteLinearAlgebra: SymmetricBandedLayouts, AdaptiveCholeskyFactors
33
44@testset " infinite-cholesky" begin
55 S = Symmetric (BandedMatrix (0 => 1 : ∞, 1 => Ones (∞)))
@@ -10,6 +10,28 @@ import InfiniteLinearAlgebra: SymmetricBandedLayouts
1010 b = [randn (10_000 ); zeros (∞)]
1111 @test cholesky (S) \ b ≈ qr (S) \ b ≈ S \ b
1212
13+ @testset " copying and L factor" begin
14+ z = 10_000 ;
15+ A = BandedMatrix (0 => - 2 * (0 : ∞)/ z, 1 => Ones (∞), - 1 => Ones (∞));
16+ M = Symmetric (I- A)
17+ chol = cholesky (M)
18+
19+ # test consistency
20+ @test copy (chol. factors) isa AdaptiveCholeskyFactors
21+ @test copy (chol. factors' ) isa Adjoint
22+ @test copy (transpose (chol. factors)) isa Transpose
23+
24+ # test copy
25+ @test (chol. factors' )[1 : 10 ,1 : 10 ] == copy (chol. factors' )[1 : 10 ,1 : 10 ]
26+ @test transpose (chol. factors)[1 : 10 ,1 : 10 ] == copy (chol. factors' )[1 : 10 ,1 : 10 ]
27+ @test (chol. factors)[1 : 10 ,1 : 10 ] == copy (chol. factors)[1 : 10 ,1 : 10 ]
28+
29+ # test fetching L factor
30+ L = chol. L
31+ U = chol. U
32+ @test L[1 : 10 ,1 : 10 ]' == U[1 : 10 ,1 : 10 ]
33+ end
34+
1335 @testset " singularly perturbed" begin
1436 # using Symmetric(BandedMatrix(...))
1537 ε = 0.0001
@@ -45,4 +67,4 @@ import InfiniteLinearAlgebra: SymmetricBandedLayouts
4567 @test (F. U * F. U' )[1 : 10 ,1 : 10 ] ≈ F. U[1 : 10 ,1 : 12 ] * F. U[1 : 10 ,1 : 12 ]'
4668 @test (F. U' * F. U)[1 : 10 ,1 : 10 ] ≈ S[1 : 10 ,1 : 10 ]
4769 end
48- end
70+ end
0 commit comments