Skip to content

Commit

Permalink
Fix potential uninitialized in Symmetric building of NormalChol cache
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Dec 26, 2023
1 parent 814adc2 commit 43e9e7b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ function init_cacheval(alg::NormalCholeskyFactorization, A, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
assumptions::OperatorAssumptions)
A_ = convert(AbstractMatrix, A)
return ArrayInterface.cholesky_instance(Symmetric((A)' * A), alg.pivot)
return ArrayInterface.cholesky_instance(Symmetric(Matrix{eltype(A)}(undef,0,0)), alg.pivot)
end

function init_cacheval(alg::NormalCholeskyFactorization,
Expand Down
41 changes: 21 additions & 20 deletions test/default_algs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,25 @@ solve(prob)
prob = LinearProblem(sprand(11000, 11000, 0.5), zeros(11000))
solve(prob)

@static if VERSION >= v"v1.9-"
# Test inference
A = rand(4, 4)
b = rand(4)
prob = LinearProblem(A, b)
VERSION v"1.10-" && JET.@test_opt init(prob, nothing)
JET.@test_opt solve(prob, LUFactorization())
JET.@test_opt solve(prob, GenericLUFactorization())
@test_skip JET.@test_opt solve(prob, QRFactorization())
JET.@test_opt solve(prob, DiagonalFactorization())
#JET.@test_opt solve(prob, SVDFactorization())
#JET.@test_opt solve(prob, KrylovJL_GMRES())
# Test inference
A = rand(4, 4)
b = rand(4)
prob = LinearProblem(A, b)
VERSION v"1.10-" && JET.@test_opt init(prob, nothing)
JET.@test_opt solve(prob, LUFactorization())
JET.@test_opt solve(prob, GenericLUFactorization())
@test_skip JET.@test_opt solve(prob, QRFactorization())
JET.@test_opt solve(prob, DiagonalFactorization())
#JET.@test_opt solve(prob, SVDFactorization())
#JET.@test_opt solve(prob, KrylovJL_GMRES())

prob = LinearProblem(sparse(A), b)
#JET.@test_opt solve(prob, UMFPACKFactorization())
#JET.@test_opt solve(prob, KLUFactorization())
#JET.@test_opt solve(prob, SparspakFactorization())
#JET.@test_opt solve(prob)
@inferred solve(prob)
@inferred init(prob, nothing)
end
prob = LinearProblem(sparse(A), b)
#JET.@test_opt solve(prob, UMFPACKFactorization())
#JET.@test_opt solve(prob, KLUFactorization())
#JET.@test_opt solve(prob, SparspakFactorization())
#JET.@test_opt solve(prob)
@inferred solve(prob)
@inferred init(prob, nothing)

prob = LinearProblem(big.(rand(10, 10)), big.(zeros(10)))
solve(prob)

0 comments on commit 43e9e7b

Please sign in to comment.