@@ -110,8 +110,10 @@ positive semi-definite matrix `A`. This is the return type of [`cholesky(_, Val(
110
110
the corresponding matrix factorization function.
111
111
112
112
The triangular Cholesky factor can be obtained from the factorization `F::CholeskyPivoted`
113
- via `F.L` and `F.U`, and the permutation via `F.p`, where `A[F.p, F.p] ≈ F.U' * F.U ≈ F.L * F.L'`,
114
- or alternatively `A ≈ F.U[:, F.p]' * F.U[:, F.p] ≈ F.L[F.p, :] * F.L[F.p, :]'`.
113
+ via `F.L` and `F.U`, and the permutation via `F.p`, where `A[F.p, F.p] ≈ Ur' * Ur ≈ Lr * Lr'`
114
+ with `Ur = F.U[1:F.rank, :]` and `Lr = F.L[:, 1:F.rank]`, or alternatively
115
+ `A ≈ Up' * Up ≈ Lp * Lp'` with `Up = F.U[1:F.rank, invperm(F.p)]` and
116
+ `Lp = F.L[invperm(F.p), 1:F.rank]`.
115
117
116
118
The following functions are available for `CholeskyPivoted` objects:
117
119
[`size`](@ref), [`\\ `](@ref), [`inv`](@ref), [`det`](@ref), and [`rank`](@ref).
@@ -120,25 +122,28 @@ Iterating the decomposition produces the components `L` and `U`.
120
122
121
123
# Examples
122
124
```jldoctest
123
- julia> A = [4. 12. -16.; 12. 37. -43.; -16. -43. 98.]
124
- 3×3 Matrix{Float64}:
125
- 4.0 12.0 -16.0
126
- 12.0 37.0 -43.0
127
- -16.0 -43.0 98.0
125
+ julia> X = [1.0, 2.0, 3.0, 4.0];
128
126
129
- julia> C = cholesky(A, Val(true))
127
+ julia> A = X * X';
128
+
129
+ julia> C = cholesky(A, Val(true), check = false)
130
130
CholeskyPivoted{Float64, Matrix{Float64}}
131
- U factor with rank 3:
132
- 3×3 UpperTriangular{Float64, Matrix{Float64}}:
133
- 9.89949 -4.34366 -1.61624
134
- ⋅ 4.25825 1.1694
135
- ⋅ ⋅ 0.142334
131
+ U factor with rank 1:
132
+ 4×4 UpperTriangular{Float64, Matrix{Float64}}:
133
+ 4.0 2.0 3.0 1.0
134
+ ⋅ 0.0 6.0 2.0
135
+ ⋅ ⋅ 9.0 3.0
136
+ ⋅ ⋅ ⋅ 1.0
136
137
permutation:
137
- 3 -element Vector{Int64}:
138
- 3
138
+ 4 -element Vector{Int64}:
139
+ 4
139
140
2
141
+ 3
140
142
1
141
143
144
+ julia> C.U[1:C.rank, :]' * C.U[1:C.rank, :] ≈ A[C.p, C.p]
145
+ true
146
+
142
147
julia> l, u = C; # destructuring via iteration
143
148
144
149
julia> l == C.L && u == C.U
@@ -403,8 +408,9 @@ and return a [`CholeskyPivoted`](@ref) factorization. The matrix `A` can either
403
408
or [`Hermitian`](@ref) [`StridedMatrix`](@ref) or a *perfectly* symmetric or Hermitian `StridedMatrix`.
404
409
405
410
The triangular Cholesky factor can be obtained from the factorization `F` via `F.L` and `F.U`,
406
- and the permutation via `F.p`, where `A[F.p, F.p] ≈ F.U' * F.U ≈ F.L * F.L'`, or alternatively
407
- `A ≈ F.U[:, F.p]' * F.U[:, F.p] ≈ F.L[F.p, :] * F.L[F.p, :]'`.
411
+ and the permutation via `F.p`, where `A[F.p, F.p] ≈ Ur' * Ur ≈ Lr * Lr'` with `Ur = F.U[1:F.rank, :]`
412
+ and `Lr = F.L[:, 1:F.rank]`, or alternatively `A ≈ Up' * Up ≈ Lp * Lp'` with
413
+ `Up = F.U[1:F.rank, invperm(F.p)]` and `Lp = F.L[invperm(F.p), 1:F.rank]`.
408
414
409
415
The following functions are available for `CholeskyPivoted` objects:
410
416
[`size`](@ref), [`\\ `](@ref), [`inv`](@ref), [`det`](@ref), and [`rank`](@ref).
@@ -421,26 +427,26 @@ validity (via [`issuccess`](@ref)) lies with the user.
421
427
422
428
# Examples
423
429
```jldoctest
424
- julia> A = [4. 12. -16.; 12. 37. -43.; -16. -43. 98.]
425
- 3×3 Matrix{Float64}:
426
- 4.0 12.0 -16.0
427
- 12.0 37.0 -43.0
428
- -16.0 -43.0 98.0
430
+ julia> X = [1.0, 2.0, 3.0, 4.0];
431
+
432
+ julia> A = X * X';
429
433
430
- julia> C = cholesky(A, Val(true))
434
+ julia> C = cholesky(A, Val(true), check = false )
431
435
CholeskyPivoted{Float64, Matrix{Float64}}
432
- U factor with rank 3:
433
- 3×3 UpperTriangular{Float64, Matrix{Float64}}:
434
- 9.89949 -4.34366 -1.61624
435
- ⋅ 4.25825 1.1694
436
- ⋅ ⋅ 0.142334
436
+ U factor with rank 1:
437
+ 4×4 UpperTriangular{Float64, Matrix{Float64}}:
438
+ 4.0 2.0 3.0 1.0
439
+ ⋅ 0.0 6.0 2.0
440
+ ⋅ ⋅ 9.0 3.0
441
+ ⋅ ⋅ ⋅ 1.0
437
442
permutation:
438
- 3 -element Vector{Int64}:
439
- 3
443
+ 4 -element Vector{Int64}:
444
+ 4
440
445
2
446
+ 3
441
447
1
442
448
443
- julia> C.U[:, C.p ]' * C.U[:, C.p ] ≈ A
449
+ julia> C.U[1:C.rank, : ]' * C.U[1:C.rank, : ] ≈ A[C.p, C.p]
444
450
true
445
451
446
452
julia> l, u = C; # destructuring via iteration
0 commit comments