LinearAlgebra.jl icon indicating copy to clipboard operation
LinearAlgebra.jl copied to clipboard

StackOverflow on `cholesky` with sparse Unitful matrix

Open JeffFessler opened this issue 3 years ago • 1 comments

The following simple sparse matrix (with Unitful matrix elements) causes cholesky! to overflow:

using LinearAlgebra: cholesky
using SparseArrays: spdiagm
using Unitful: s
A = spdiagm(Float32.(1:3)*s^2) # unitful sparse array
B = cholesky(A)

ERROR: LoadError: StackOverflowError:
Stacktrace:
 [1] cholesky!(A::LinearAlgebra.Hermitian{Unitful.Quantity{Float32}, SparseArrays.SparseMatrixCSC{Unitful.Quantity{Float32}, Int64}}, ::LinearAlgebra.NoPivot; check::Bool)
   @ LinearAlgebra /Users/freeware/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/LinearAlgebra/src/cholesky.jl:296
 [2] cholesky!(A::LinearAlgebra.Hermitian{Unitful.Quantity{Float32}, SparseArrays.SparseMatrixCSC{Unitful.Quantity{Float32}, Int64}}, ::LinearAlgebra.NoPivot; check::Bool) (repeats 39991 times)
   @ LinearAlgebra /Users/freeware/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/LinearAlgebra/src/cholesky.jl:302

Julia 1.8.3 on a mac.

JeffFessler avatar Nov 21 '22 18:11 JeffFessler