You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nowadays ForwardDiff seems to work nicely when using Complex (internally, at least), so I was trying to use dualcache with a complex array. Unfortunately, it seems like the more interesting methods of get_tmp base the returned eltype on the type of u (which is always some kind of Real) rather than on the type underlying the DiffCache. I wonder if it might be possible to generalize that.
It is possible to work around this by constructing the cache as zd = dualcache(reinterpret(reshape, T, z)) and then unpacking it inside the function as
ztmp =get_tmp(zd, t)
z =reinterpret(reshape, Complex{eltype(z)}, ztmp)
Obviously, this is ugly, as well as hard to remember to do. I've fallen into this trap a few times, getting weird error messages far from the source of the problem. Automatic handling of Complex would really make things nicer for me. :)
The text was updated successfully, but these errors were encountered:
Sorry, I am not usually dealing with models where complex numbers appear (unless I am doing something wrong :)); can you provide a MWE that illustrates the issue and what you are trying to accomplish?
Nowadays ForwardDiff seems to work nicely when using Complex (internally, at least), so I was trying to use
dualcache
with a complex array. Unfortunately, it seems like the more interesting methods ofget_tmp
base the returned eltype on the type ofu
(which is always some kind of Real) rather than on the type underlying theDiffCache
. I wonder if it might be possible to generalize that.It is possible to work around this by constructing the cache as
zd = dualcache(reinterpret(reshape, T, z))
and then unpacking it inside the function asObviously, this is ugly, as well as hard to remember to do. I've fallen into this trap a few times, getting weird error messages far from the source of the problem. Automatic handling of Complex would really make things nicer for me. :)
The text was updated successfully, but these errors were encountered: