Hi All!
I am quite new to GPU programming, but I found some strange behaviour in
the cumath.exp function. Maybe it is well known, but to me it seems that
the real and imaginary part are swapped. Consider the following code:
import pycuda.gpuarray as gpuarray
import pycuda.autoinit
import pycuda.cumath as cumath
import numpy as np
# create some random numbers in the complex plane
random_reals = np.random.rand(100,100)
random_complex = np.exp(1j*random_reals)
# use the same random numbers, but compute the complex numbers on
the GPU
g_random_reals = gpuarray.to_gpu(random_reals)
g_random_complex = cumath.exp(1.j*g_random_reals)
# it seems that the two arrays are not equal
print "Equal: " , np.all(g_random_complex.get().real -
random_complex.real < 1e-12)
# .. but the imaginary part and the real part are just swapped
print "Imag and real swapped 1: " ,
np.all(g_random_complex.get().imag - random_complex.real < 1e-12)
print "Imag and real swapped 2: " ,
np.all(g_random_complex.get().real - random_complex.imag < 1e-12)
prints
Equal: False
Imag and real swapped 1: True
Imag and real swapped 2: True
Is this indeed a bug? Or am I just missing something?
regards,
Dirk
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda