LinearAlgebra.jl
LinearAlgebra.jl copied to clipboard
Unnecessary scalar indexing in `logdet(C::Cholesky)`
Related: https://github.com/JuliaGaussianProcesses/AbstractGPs.jl/pull/329 https://github.com/JuliaLang/julia/blob/master/stdlib/LinearAlgebra/src/cholesky.jl#L672
Can't we do sum(log, real.(diag(C.factors))) ?
Have you tried it with allowscalar(false) (or whatever the correct syntax is)? I don't think diag(C.factors) does anything else than scalar indexing and collecting the resulting vector. That would be worse in general, because it adds an allocation.
Seems like a minimal change is:
@inbounds for i in diagind(C.factors)
dd += log(real(C.factors[i]))
end
Probably that doesn't help with OP's case, however?