Closed ChrisRackauckas closed 8 years ago
u = A[1,1]*ks[1]
utilde = zero(u+u)
The u+u
part is a little pedantic, since all types I'm aware of do not promote with +
, but better safe than sorry.
This runs into trouble if A
or ks
is empty---see the enormous discussions in core julia about promote_op
, inference, map, etc.
Works great, thanks. I always knew of zeros
but never zero
. Made more robust other places in my codes :+1:
Hey, I am updating DifferentialEquations.jl to have full compatibility with SIUnits.jl, and there's just one little part left to do. The offending code is here:
The problem is
utilde
doesn't get the appropriate units because it's initialized asutilde =0
. I want to set the units of that 0 to the units ofu
(provided by the user), but I don't want to make an array (and doing something likesimilar(u)[1]
seems like it could cause performance issues).Any idea on how to do this?