Skip to content

Complex + dualcache #47

@moble

Description

@moble

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. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions