2016-10-14 1 views
0

Ich habe nicht zu viel Erfahrung intrinsics in C unter Verwendung von Mein Problem dieser Funktion wie __m128 alpha verwenden ist,Wie kann ich in einer __m128 Variablen eine ganze komplexe Zahl haben? nur

void function(complex float* A, complex float* B, complex float alpha) { 

ich will, aber wenn ich diese

__m128 alfa = _mm_load_ps((float const *)&alpha); 

alfa bekommt den reellen Teil der komplexen Zahl.

Wie kann ich in __m128 alfa die ganze komplexe Zahl haben?

Antwort

1

Dieser Code funktionierte gut für mich:

complex float a __attribute__ ((aligned (16))) = 5 + 10*I; 
__m128 f = _mm_load_ps((float const *)&a); // requires 16B alignment 
float *p = (float *)&f; 
printf("real(0): %f, imag(1): %f, (2): %f, (3): %f\n", p[0], p[1], p[2], p[3]); 

druckt

real(0): 5.000000, imag(1): 10.000000, (2): 0.000000, (3): 0.000000 

Sind Sie sicher, alpha einen von Null imaginären Teil hat? Woher weißt du, dass du nur den echten Teil bekommst?

+0

Ich habe dieses komplexe float versucht alphaA __attribute__ ((aligned (16))) = alpha; – CSR95

+0

gefolgt von diesem Ausdruck __m128 alfa = _mm_load_ps ((float const *) & alphaA); aber ich bekomme das mit Ihrem Ausdruck: real (0): 0,335223, imag (1): -0,911647, (2): 0,335223, (3): -0,911647. Die Sache ist, dass ich 2 komplexe Zahlen multiplizieren möchte, also denke ich, dass das der richtige Weg ist. Hast du eine Ahnung wie die Multiplikation ist? – CSR95

+0

Welchen Wert hat Alpha? – Phil

Verwandte Themen