@@ -110,8 +110,10 @@ positive semi-definite matrix `A`. This is the return type of [`cholesky(_, Val(
110110the corresponding matrix factorization function.
111111
112112The 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]`.
115117
116118The following functions are available for `CholeskyPivoted` objects:
117119[`size`](@ref), [`\\ `](@ref), [`inv`](@ref), [`det`](@ref), and [`rank`](@ref).
@@ -120,25 +122,28 @@ Iterating the decomposition produces the components `L` and `U`.
120122
121123# Examples
122124```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];
128126
129- julia> C = cholesky(A, Val(true))
127+ julia> A = X * X';
128+
129+ julia> C = cholesky(A, Val(true), check = false)
130130CholeskyPivoted{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
136137permutation:
137- 3 -element Vector{Int64}:
138- 3
138+ 4 -element Vector{Int64}:
139+ 4
139140 2
141+ 3
140142 1
141143
144+ julia> C.U[1:C.rank, :]' * C.U[1:C.rank, :] ≈ A[C.p, C.p]
145+ true
146+
142147julia> l, u = C; # destructuring via iteration
143148
144149julia> l == C.L && u == C.U
@@ -398,8 +403,9 @@ and return a [`CholeskyPivoted`](@ref) factorization. The matrix `A` can either
398403or [`Hermitian`](@ref) [`StridedMatrix`](@ref) or a *perfectly* symmetric or Hermitian `StridedMatrix`.
399404
400405The triangular Cholesky factor can be obtained from the factorization `F` via `F.L` and `F.U`,
401- and the permutation via `F.p`, where `A[F.p, F.p] ≈ F.U' * F.U ≈ F.L * F.L'`, or alternatively
402- `A ≈ F.U[:, F.p]' * F.U[:, F.p] ≈ F.L[F.p, :] * F.L[F.p, :]'`.
406+ and the permutation via `F.p`, where `A[F.p, F.p] ≈ Ur' * Ur ≈ Lr * Lr'` with `Ur = F.U[1:F.rank, :]`
407+ and `Lr = F.L[:, 1:F.rank]`, or alternatively `A ≈ Up' * Up ≈ Lp * Lp'` with
408+ `Up = F.U[1:F.rank, invperm(F.p)]` and `Lp = F.L[invperm(F.p), 1:F.rank]`.
403409
404410The following functions are available for `CholeskyPivoted` objects:
405411[`size`](@ref), [`\\ `](@ref), [`inv`](@ref), [`det`](@ref), and [`rank`](@ref).
@@ -416,26 +422,26 @@ validity (via [`issuccess`](@ref)) lies with the user.
416422
417423# Examples
418424```jldoctest
419- julia> A = [4. 12. -16.; 12. 37. -43.; -16. -43. 98.]
420- 3×3 Matrix{Float64}:
421- 4.0 12.0 -16.0
422- 12.0 37.0 -43.0
423- -16.0 -43.0 98.0
425+ julia> X = [1.0, 2.0, 3.0, 4.0];
426+
427+ julia> A = X * X';
424428
425- julia> C = cholesky(A, Val(true))
429+ julia> C = cholesky(A, Val(true), check = false )
426430CholeskyPivoted{Float64, Matrix{Float64}}
427- U factor with rank 3:
428- 3×3 UpperTriangular{Float64, Matrix{Float64}}:
429- 9.89949 -4.34366 -1.61624
430- ⋅ 4.25825 1.1694
431- ⋅ ⋅ 0.142334
431+ U factor with rank 1:
432+ 4×4 UpperTriangular{Float64, Matrix{Float64}}:
433+ 4.0 2.0 3.0 1.0
434+ ⋅ 0.0 6.0 2.0
435+ ⋅ ⋅ 9.0 3.0
436+ ⋅ ⋅ ⋅ 1.0
432437permutation:
433- 3 -element Vector{Int64}:
434- 3
438+ 4 -element Vector{Int64}:
439+ 4
435440 2
441+ 3
436442 1
437443
438- julia> C.U[:, C.p ]' * C.U[:, C.p ] ≈ A
444+ julia> C.U[1:C.rank, : ]' * C.U[1:C.rank, : ] ≈ A[C.p, C.p]
439445true
440446
441447julia> l, u = C; # destructuring via iteration
0 commit comments