1
1
using InfiniteLinearAlgebra, LinearAlgebra, BandedMatrices, ArrayLayouts, LazyBandedMatrices, Test
2
- import InfiniteLinearAlgebra: SymmetricBandedLayouts
2
+ import InfiniteLinearAlgebra: SymmetricBandedLayouts, AdaptiveCholeskyFactors
3
3
4
4
@testset " infinite-cholesky" begin
5
5
S = Symmetric (BandedMatrix (0 => 1 : ∞, 1 => Ones (∞)))
@@ -10,6 +10,28 @@ import InfiniteLinearAlgebra: SymmetricBandedLayouts
10
10
b = [randn (10_000 ); zeros (∞)]
11
11
@test cholesky (S) \ b ≈ qr (S) \ b ≈ S \ b
12
12
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
+
13
35
@testset " singularly perturbed" begin
14
36
# using Symmetric(BandedMatrix(...))
15
37
ε = 0.0001
@@ -45,4 +67,4 @@ import InfiniteLinearAlgebra: SymmetricBandedLayouts
45
67
@test (F. U * F. U' )[1 : 10 ,1 : 10 ] ≈ F. U[1 : 10 ,1 : 12 ] * F. U[1 : 10 ,1 : 12 ]'
46
68
@test (F. U' * F. U)[1 : 10 ,1 : 10 ] ≈ S[1 : 10 ,1 : 10 ]
47
69
end
48
- end
70
+ end
0 commit comments