Skip to content

Support for complex numbers #625

@alexander-held

Description

@alexander-held

Describe the potential feature

Currently the library does not support complex numbers, causing e.g.

import awkward as ak
import vector

arr = ak.Array(
    [{"x": 1, "y": 2, "z": 3 + 3j, "t": 5 + 3j}],
    with_name="Vector4D",
    behavior=vector.backends.awkward.behavior,
)
arr.tau

to fail since np.copysign does not seem to handle complex numbers (see e.g. np.copysign(ak.Array([1, 1j]), ak.Array([1, -1]))).

I ran into this while solving for object kinematics in constrained systems, where the violation of assumptions (e.g. on-shell decay) can result in imaginary contributions to the kinematics. Another example might be math with tachyons. For my use case I can in practice work around this by making all relevant numbers real before hitting any vector codepaths that would otherwise fail.

I am opening this issue to have a place to track the topic and potential interest in vector with complex numbers as I have not seen this discussed previously.

Motivation

No response

Possible Implementation

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions