Comments (5)
Try this
#include "vectorclass.h"
#include "vectormath_trig.h"
#include "complexvec1.h"
...
Complex4f a = ...
// separate real and imaginary parts
Vec8f b = permute8<0,2,4,6,1,3,5,7>(a.to_vector());
Vec4f re = b.get_low();
Vec4f im = b.get_high();
Vec4f angle = atan2(im,re);
Vec4f radius = sqrt(re*re + im*im);
// join real and imag parts back together
Vec8f c = permute8<0,4,1,5,2,6,3,7>(Vec8f(re,im));
Complex4f d = Complex4f(c); // d = a
from add-on.
I know this way and I also use it, but I think it would be more intuitive and comfortable if you wouldn't have to do this "manually".
from add-on.
It is awkward to make a function with two return values in C++. But it may be useful to have a few examples in the manual showing how to separate real and imaginary parts.
from add-on.
I thought about something like
Vec16f to_deinterleaved_vector() const {
return permute16<0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15>(y);
}
This would drastically reduce the probability of typos in the template argument (and thus bugs which are quite difficult to track down).
I also think it's efficient enough:
https://godbolt.org/z/-zqz6U
Clang generates the same code for the first three variants, but seems to be confused by the fourth.
Which do you think would be the most efficient?
I suppose the
vmovaps ymmword ptr [rsi], ymm2
vmovaps ymmword ptr [rdx], ymm0
vzeroupper
would disappear in practice when the function is inlined by the compiler.
For AVX512 instruction set, there are differences in the generated code:
https://godbolt.org/z/ejkGYL
from add-on.
Functions to interleave and split into real and imag parts are added now
from add-on.
Related Issues (8)
- possible bug in Ranvec1 class version 2.0 under windows 10 x64 with Zen2 cpu? HOT 11
- License HOT 1
- complexvec1.h ignores MAX_VECTOR_SIZE HOT 1
- Code in physical_processors.cpp is not within VCL_NAMESPACE HOT 1
- Small modification of the constructor in ranvec1.h HOT 3
- const pointer parameter for load method in vector_containers.h HOT 1
- const pointers to load and question on casting "SIMD" type to float HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from add-on.