Skip to content

Commit b236c25

Browse files
added fallback for constructor for arbitrary factorization inputs
1 parent 0401d6b commit b236c25

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "UpdatableCholeskyFactorizations"
22
uuid = "1a1c1746-0e7b-45d0-811e-72e8bb59686c"
33
authors = ["Sebastian Ament <sebastianeament@gmail.com>"]
4-
version = "1.1.0"
4+
version = "1.1.1"
55

66
[deps]
77
LazyInverses = "9f18896c-49a9-43cc-8eef-c455a8a119c6"

src/cholesky.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function LinearAlgebra.Cholesky(F::UpdatableCholesky)
4242
end
4343

4444
# converting Cholesky factorization to UpdatableCholesky
45-
function UpdatableCholeskyFactorizations.updatable_cholesky(C::Union{Cholesky, CholeskyPivoted}, m::Int = size(C, 1); check::Bool = true)
45+
function updatable_cholesky(C::Union{Cholesky, CholeskyPivoted}, m::Int = size(C, 1); check::Bool = true)
4646
U_full = zeros(eltype(C), m, m) # in principle, could do this in place
4747
n = size(C, 1)
4848
U = C.U
@@ -53,6 +53,12 @@ function UpdatableCholeskyFactorizations.updatable_cholesky(C::Union{Cholesky, C
5353
UpdatableCholesky(U_full, n, C.info)
5454
end
5555

56+
# fall-back for arbitrary factorization object
57+
function updatable_cholesky(F::Factorization, m::Int = size(F, 1); check::Bool = true)
58+
updatable_cholesky(Hermitian(Matrix(F)), m, check = check)
59+
end
60+
61+
5662
function Base.getproperty(F::UpdatableCholesky, s::Symbol)
5763
if s == :U
5864
U = @view F.U_full[1:F.n, 1:F.n]

test/cholesky.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ using Test
4949
@test size(C2) == size(C)
5050

5151
# conversion from cholesky type
52+
# TODO: test for CholeskyPivoted
5253
UC2 = updatable_cholesky(C2)
5354
@test UC2 isa UpdatableCholesky
5455
@test UC2.U C2.U
5556

57+
# testing constructor with arbitrary factorization input
58+
@test Matrix(updatable_cholesky(qr(A))) A
59+
5660
# adding rows and columns
5761
for i in 1:n
5862
ai = @view A_full[1:n+i, n+i]

0 commit comments

Comments
 (0)