285285Compute the Cholesky factorization of a dense symmetric positive definite matrix `A`
286286and return a `Cholesky` factorization. The matrix `A` can either be a [`Symmetric`](@ref) or [`Hermitian`](@ref)
287287`StridedMatrix` or a *perfectly* symmetric or Hermitian `StridedMatrix`.
288- The triangular Cholesky factor can be obtained from the factorization `F` with: `F[:L] ` and `F[:U] `.
288+ The triangular Cholesky factor can be obtained from the factorization `F` with: `F.L ` and `F.U `.
289289The following functions are available for `Cholesky` objects: [`size`](@ref), [`\\ `](@ref),
290290[`inv`](@ref), [`det`](@ref), [`logdet`](@ref) and [`isposdef`](@ref).
291291
@@ -305,19 +305,19 @@ U factor:
305305 ⋅ 1.0 5.0
306306 ⋅ ⋅ 3.0
307307
308- julia> C[:U]
308+ julia> C.U
3093093×3 UpperTriangular{Float64,Array{Float64,2}}:
310310 2.0 6.0 -8.0
311311 ⋅ 1.0 5.0
312312 ⋅ ⋅ 3.0
313313
314- julia> C[:L]
314+ julia> C.L
3153153×3 LowerTriangular{Float64,Array{Float64,2}}:
316316 2.0 ⋅ ⋅
317317 6.0 1.0 ⋅
318318 -8.0 5.0 3.0
319319
320- julia> C[:L] * C[:U] == A
320+ julia> C.L * C.U == A
321321true
322322```
323323"""
@@ -332,7 +332,7 @@ cholfact(A::Union{StridedMatrix,RealHermSymComplexHerm{<:Real,<:StridedMatrix}},
332332Compute the pivoted Cholesky factorization of a dense symmetric positive semi-definite matrix `A`
333333and return a `CholeskyPivoted` factorization. The matrix `A` can either be a [`Symmetric`](@ref)
334334or [`Hermitian`](@ref) `StridedMatrix` or a *perfectly* symmetric or Hermitian `StridedMatrix`.
335- The triangular Cholesky factor can be obtained from the factorization `F` with: `F[:L] ` and `F[:U] `.
335+ The triangular Cholesky factor can be obtained from the factorization `F` with: `F.L ` and `F.U `.
336336The following functions are available for `PivotedCholesky` objects:
337337[`size`](@ref), [`\\ `](@ref), [`inv`](@ref), [`det`](@ref), and [`rank`](@ref).
338338The argument `tol` determines the tolerance for determining the rank.
@@ -361,14 +361,14 @@ CholeskyPivoted{T}(C::CholeskyPivoted) where {T} =
361361Factorization {T} (C:: CholeskyPivoted{T} ) where {T} = C
362362Factorization {T} (C:: CholeskyPivoted ) where {T} = CholeskyPivoted {T} (C)
363363
364- AbstractMatrix (C:: Cholesky ) = C. uplo == ' U' ? C[ :U ] ' C[ :U ] : C[ :L ] * C[ :L ] '
364+ AbstractMatrix (C:: Cholesky ) = C. uplo == ' U' ? C. U ' C . U : C. L * C . L '
365365AbstractArray (C:: Cholesky ) = AbstractMatrix (C)
366366Matrix (C:: Cholesky ) = Array (AbstractArray (C))
367367Array (C:: Cholesky ) = Matrix (C)
368368
369369function AbstractMatrix (F:: CholeskyPivoted )
370- ip = invperm (F[ :p ] )
371- (F[ :L ] * F[ :U ] )[ip,ip]
370+ ip = invperm (F. p )
371+ (F. L * F. U )[ip,ip]
372372end
373373AbstractArray (F:: CholeskyPivoted ) = AbstractMatrix (F)
374374Matrix (F:: CholeskyPivoted ) = Array (AbstractArray (F))
@@ -380,43 +380,56 @@ copy(C::CholeskyPivoted) = CholeskyPivoted(copy(C.factors), C.uplo, C.piv, C.ran
380380size (C:: Union{Cholesky, CholeskyPivoted} ) = size (C. factors)
381381size (C:: Union{Cholesky, CholeskyPivoted} , d:: Integer ) = size (C. factors, d)
382382
383- function getindex (C:: Cholesky , d:: Symbol )
384- d == :U && return UpperTriangular (Symbol (C. uplo) == d ? C. factors : adjoint (C. factors))
385- d == :L && return LowerTriangular (Symbol (C. uplo) == d ? C. factors : adjoint (C. factors))
386- d == :UL && return Symbol (C. uplo) == :U ? UpperTriangular (C. factors) : LowerTriangular (C. factors)
387- throw (KeyError (d))
388- end
389- function getindex (C:: CholeskyPivoted{T} , d:: Symbol ) where T<: BlasFloat
390- d == :U && return UpperTriangular (Symbol (C. uplo) == d ? C. factors : adjoint (C. factors))
391- d == :L && return LowerTriangular (Symbol (C. uplo) == d ? C. factors : adjoint (C. factors))
392- d == :p && return C. piv
393- if d == :P
383+ function getproperty (C:: Cholesky , d:: Symbol )
384+ Cfactors = getfield (C, :factors )
385+ Cuplo = getfield (C, :uplo )
386+ if d == :U
387+ return UpperTriangular (Symbol (Cuplo) == d ? Cfactors : adjoint (Cfactors))
388+ elseif d == :L
389+ return LowerTriangular (Symbol (Cuplo) == d ? Cfactors : adjoint (Cfactors))
390+ elseif d == :UL
391+ return Symbol (Cuplo) == :U ? UpperTriangular (Cfactors) : LowerTriangular (Cfactors)
392+ else
393+ return getfield (C, d)
394+ end
395+ end
396+ function getproperty (C:: CholeskyPivoted{T} , d:: Symbol ) where T<: BlasFloat
397+ Cfactors = getfield (C, :factors )
398+ Cuplo = getfield (C, :uplo )
399+ if d == :U
400+ return UpperTriangular (Symbol (Cuplo) == d ? Cfactors : adjoint (Cfactors))
401+ elseif d == :L
402+ return LowerTriangular (Symbol (Cuplo) == d ? Cfactors : adjoint (Cfactors))
403+ elseif d == :p
404+ return getfield (C, :piv )
405+ elseif d == :P
394406 n = size (C, 1 )
395407 P = zeros (T, n, n)
396408 for i = 1 : n
397- P[C . piv[i],i] = one (T)
409+ P[getfield (C, : piv) [i], i] = one (T)
398410 end
399411 return P
412+ else
413+ return getfield (C, d)
400414 end
401- throw (KeyError (d))
402415end
403416
404417issuccess (C:: Cholesky ) = C. info == 0
405418
406419function show (io:: IO , mime:: MIME{Symbol("text/plain")} , C:: Cholesky{<:Any,<:AbstractMatrix} )
407420 if issuccess (C)
408421 println (io, summary (C), " \n $(C. uplo) factor:" )
409- show (io, mime, C[ :UL ] )
422+ show (io, mime, C. UL )
410423 else
411424 print (io, " Failed factorization of type $(typeof (C)) " )
412425 end
413426end
414427
415428function show (io:: IO , mime:: MIME{Symbol("text/plain")} , C:: CholeskyPivoted{<:Any,<:AbstractMatrix} )
416429 println (io, summary (C), " \n $(C. uplo) factor with rank $(rank (C)) :" )
417- show (io, mime, C. uplo == ' U' ? C[ :U ] : C[ :L ] )
430+ show (io, mime, C. uplo == ' U' ? C. U : C. L )
418431 println (io, " \n permutation:" )
419- show (io, mime, C[ :p ] )
432+ show (io, mime, C. p )
420433end
421434
422435ldiv! (C:: Cholesky{T,<:AbstractMatrix} , B:: StridedVecOrMat{T} ) where {T<: BlasFloat } =
@@ -534,8 +547,8 @@ rank(C::CholeskyPivoted) = C.rank
534547"""
535548 lowrankupdate!(C::Cholesky, v::StridedVector) -> CC::Cholesky
536549
537- Update a Cholesky factorization `C` with the vector `v`. If `A = C[:U]'C[:U] ` then
538- `CC = cholfact(C[:U]'C[:U] + v*v')` but the computation of `CC` only uses `O(n^2)`
550+ Update a Cholesky factorization `C` with the vector `v`. If `A = C.U'C.U ` then
551+ `CC = cholfact(C.U'C.U + v*v')` but the computation of `CC` only uses `O(n^2)`
539552operations. The input factorization `C` is updated in place such that on exit `C == CC`.
540553The vector `v` is destroyed during the computation.
541554"""
580593"""
581594 lowrankdowndate!(C::Cholesky, v::StridedVector) -> CC::Cholesky
582595
583- Downdate a Cholesky factorization `C` with the vector `v`. If `A = C[:U]'C[:U] ` then
584- `CC = cholfact(C[:U]'C[:U] - v*v')` but the computation of `CC` only uses `O(n^2)`
596+ Downdate a Cholesky factorization `C` with the vector `v`. If `A = C.U'C.U ` then
597+ `CC = cholfact(C.U'C.U - v*v')` but the computation of `CC` only uses `O(n^2)`
585598operations. The input factorization `C` is updated in place such that on exit `C == CC`.
586599The vector `v` is destroyed during the computation.
587600"""
@@ -633,17 +646,17 @@ end
633646"""
634647 lowrankupdate(C::Cholesky, v::StridedVector) -> CC::Cholesky
635648
636- Update a Cholesky factorization `C` with the vector `v`. If `A = C[:U]'C[:U] `
637- then `CC = cholfact(C[:U]'C[:U] + v*v')` but the computation of `CC` only uses
649+ Update a Cholesky factorization `C` with the vector `v`. If `A = C.U'C.U `
650+ then `CC = cholfact(C.U'C.U + v*v')` but the computation of `CC` only uses
638651`O(n^2)` operations.
639652"""
640653lowrankupdate (C:: Cholesky , v:: StridedVector ) = lowrankupdate! (copy (C), copy (v))
641654
642655"""
643656 lowrankdowndate(C::Cholesky, v::StridedVector) -> CC::Cholesky
644657
645- Downdate a Cholesky factorization `C` with the vector `v`. If `A = C[:U]'C[:U] `
646- then `CC = cholfact(C[:U]'C[:U] - v*v')` but the computation of `CC` only uses
658+ Downdate a Cholesky factorization `C` with the vector `v`. If `A = C.U'C.U `
659+ then `CC = cholfact(C.U'C.U - v*v')` but the computation of `CC` only uses
647660`O(n^2)` operations.
648661"""
649662lowrankdowndate (C:: Cholesky , v:: StridedVector ) = lowrankdowndate! (copy (C), copy (v))
0 commit comments