[vectorIntrinsics] Processing interleaved data formats
Peter A
peter.abeles at gmail.com
Thu Apr 15 01:40:08 UTC 2021
I'm attempting to vectorize interleaved data formats. For example, complex
matrices are often stored in an array where elements alternate between real
and imaginary values. This also comes up in low level image processing,
e.g. YUV to RGB and debayer.
Here's what the actual math looks like for complex multiplication of a
scalar value against a vector:
double realA = ...
double imagA = ...
while (indexB < end) {
double realB = B.data[indexB++];
double imagB = B.data[indexB++];
C.data[indexC++] = realA * realB - imagA * imagB;
C.data[indexC++] = realA * imagB + imagA * realB;
}
My attempts so far have failed since at some point I need to address the
memory not being "continuous" and I resort to non vectorized code. I did a
quick search and it seems like I need to use a "shuffle" command. I did
find a shuffle in the Vector API but it wasn't obvious how to apply it
here, to me at least.
I suspect that some others here know exactly how to approach this problem.
Thanks,
- Peter
P.S. I'm sharing this code so others can learn from it too.
--
"Now, now my good man, this is no time for making enemies." — Voltaire
(1694-1778), on his deathbed in response to a priest asking that he
renounce Satan.
More information about the panama-dev
mailing list