Hi Gwenael, A common approach is to use `float2`/`double2` types on the OpenCL side and the corresponding numpy types `complex64`/`complex128`. The C types are structures with fields 'x' and 'y' of the corresponding floating point type. Unfortunately, there are no functions available in OpenCL itself that would treat these structures as complex numbers, and even the operators are intended for a different usage: `float2` * `float2` is not available, and `float2` + `float` adds the second argument to both `x` and `y` fields. But PyOpenCL has a header file with such functions defined, see https://github.com/pyopencl/pyopencl/blob/master/pyopencl/cl/pyopencl-complex.h
Best regards, Bogdan On Wed, May 21, 2014 at 4:51 PM, <[email protected]> wrote: > Hi, > > I am trying to translate a numpy array with complex numbers built in the > Python part of my code into an array for its OpenCL part. Here is the array > I obtain : > mat={{1f, 1f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, > 0.f, 0.f, 0.f, 0.f}, {3f, 634.6002f, 10877545.202f, -348506.5055f, > 1647910.5651f, -2592227.8312f, 1211024.4768f, 240068.1321f, 0.72992f, > 166.0818f, 853.3891f, 1010.2639f, 1341.7248f, 4030.3953f, > (681.5814f,15292.8529f), (1708.439f,8400.4467f), 439.62f, > 0.0000421131454702f}}; > > The complex numbers are the items in brackets (real part, imaginary part). I > wonder if it is the good way for introducing complex numbers in OpenCL. > > When treating an array without complex numbers, I call the array in the > OpenCL script like this: > __constant float* arr = &(mat[matIndex][2]); > I do not find how to call such an array if it contains complex numbers. > > Besides, I have to use special functions (as exponential for instance) on > this array. Does the function exp can deal with complex numbers? > > GGUILLAUME > > > _______________________________________________ > PyOpenCL mailing list > [email protected] > http://lists.tiker.net/listinfo/pyopencl > _______________________________________________ PyOpenCL mailing list [email protected] http://lists.tiker.net/listinfo/pyopencl
