Hi All,
I was just experimenting with a Float32 matrix because I want to see if it’s faster and with enough precision.
However to my surprise, I realized that this is not doing what I am expecting:
- backslash '' (ldiv) is promoting the type and returning Float64
- Trying to use cholesky(A) returns an unexpected error
- Trying to use directly CHOLMOD.Sparse also promotes to Float64
I don’t know if I’m missing something here.
Does anyone have an idea that could point me to the right direction?
I know that CHOLMOD can handle double and single precision floats, but I can’t find where is this being promoted.
using Random: seed!
using SparseArraysThis text will be hidden
using LinearAlgebra
using SuiteSparse.CHOLMOD
seed!(1234)
n = 10
A = sprand(Float32, n, n, 0.1)
b = randn(Float32, n, 1)
A = A + A' + 10*I #10×10 SparseMatrixCSC{Float32,Int64}
isposdef!(A) #true
issymmetric(A) #true
A\b # 10×1 Array{Float64,2}
typeof(A) # SparseMatrixCSC{Float32,Int64}
F = cholesky(A) # ERROR: ArgumentError: sparse matrix is not symmetric/Hermitian
CHOLMOD.Sparse(A) #10×10 Sparse{Float64}