Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex number operations #2423

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mazimkhan
Copy link

@mazimkhan mazimkhan commented Jan 6, 2025

Introduces basic complex arithmetic for float and integer types. Some masked operations for complex numbers are also included.

A single complex value is formed of a real part which is stored in an even lane, and the imaginary part which is stored in the following odd lane.

All complex operations are written for arm_sve-inl.h and generic_ops-inl.h and a new set of tests is introduced for all the new complex operations.

Copy link

google-cla bot commented Jan 6, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.


Take `j` to be the even values of `i`.

* <code>V **CplxConj**(V v)</code>: returns the complex conjugate of the vector,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion here, but we might consider spelling out Complex for better legibility. (We have SaturatedAdd instead of SatAdd).

* <code>V **MaskedMulCplxConjAddOrZero**(M mask, V a, V b, V c)</code>: returns
`(a[j] + i.a[j + 1])(b[j] - i.b[j + 1]) + (c[j] + i.c[j + 1])` or `0` if
`mask[i]` is false.
* <code>V **MaskedMulCplxConjOrZero**(M mask, V a, V b)</code>: returns
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in other PRs, let's remove the OrZero suffix, use Masked prefix as the _z case and Masked..Or(V no, ..) for the _m case. For MaskedMulCplxOr the c argument is currently last, so let's move it first for consistency and rename to no.

@@ -886,6 +886,32 @@ not a concern, these are equivalent to, and potentially more efficient than,
<code>V **MaskedSatSubOr**(V no, M m, V a, V b)</code>: returns `a[i] +
b[i]` saturated to the minimum/maximum representable value, or `no[i]` if
`m[i]` is false.
#### Complex number operations

Complex types are represented as complex value pairs of real and imaginary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we intend to support (and have a use-case for) integer types? If not, let's mark all of these ops as float-only, with a prefix like * V: f \ (see other examples in this file).

const auto x = DupEven(b);
const auto y = DupOdd(b);

return OddEven(Add(Mul(u, y), Mul(v, x)), Sub(Mul(u, x), Mul(v, y)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we fuse one of the Add+Mul into MulAdd? (also below)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants