I want to apply SSE instructions to a vector containing complex numbers. Without SSE instructions, I can do it with the following code. However, when I apply SSE instructions, I don't know how to get the calculated real and imaginary part back to the array. How can I solve this?
complex double * complexScaling(complex double *input, double c, int length)
{
for(int i=0; i<length; i++) {
input[i] = c*input[i];
}
return input;
}
complex double * complexScalingSSE(complex double *input, double c, int length)
{
__m128d multiplier,real,imag;
multiplier = _mm_set1_pd(c);
for(int i=0; i<length; i+=2) {
real = _mm_set_pd(creal(input[i]),creal(input[i+1]));
real = _mm_mul_pd(real, multiplier);
imag = _mm_set_pd(cimag(input[i]),cimag(input[i+1]));
imag = _mm_mul_pd(imag, multiplier);
}
return input;
}
set(var, var)will generate really annoying code. The only safe set is with constant arguments. - harold