JuliaDiff / SparseDiffTools.jl

Fast jacobian computation through sparsity exploitation and matrix coloring
MIT License
237 stars 41 forks source link

complex number support? #148

Open Roger-luo opened 2 years ago

Roger-luo commented 2 years ago

I ran into this problem by using the AutoTsit5(Rosenbrock23()) on shordinger function (an equation that has a complex valued state), basically it seems the following line

https://github.com/JuliaDiff/SparseDiffTools.jl/blob/fb09091c195311ab622ced4889694e889631c980/src/differentiation/compute_jacobian_ad.jl#L29

won't run if x is complex-valued. I'm not sure how should this be generalized however...

ChrisRackauckas commented 2 years ago

AutoTsit5(Rosenbrock23(autodiff=false)) does that work?

Roger-luo commented 2 years ago

yes, @ChrisRackauckas that works! I'm not sure what's the difference with or without AD tho?

ChrisRackauckas commented 2 years ago

Not much. In some very numerically ill-conditioned problems it can matter, but most tests show little performance difference. It's really just a safety difference.