Hi Bodgan,

Thank you very much for your response.

If I understand well, I have to introduce '#include <pyopencl-complex.h>' in 
order to deal with complex arrays.

I have reordered the input complex multidimensional array as:

    __constant float2 mat[][18] = {{(float2)(1.0f,0.0f), (float2)(1.0f,0.0f), 
(float2)(0.0f,0.0f), (float2)(0.0f,0.0f), (float2)(0.0f,0.0f), 
(float2)(0.0f,0.0f), (float2)(0.0f,0.0f), (float2)(0.0f,0.0f),  
                                    (float2) (0.0f,0.0f), (float2)(0.0f,0.0f), 
(float2)(0.0f,0.0f), (float2)(0.0f,0.0f), (float2)(0.0f,0.0f), 
(float2)(0.0f,0.0f), (float2)(0.0f,0.0f), (float2)(0.0f,0.0f),  
                                    (float2)(0.0f,0.0f), (float2)(0.0f,0.0f)}, 
                                   {(float2)(3.0f,0.0f), (float2)(634.6f,0.0f), 
(float2)(0.0000000108775f,0.0f), (float2)(-348507f,0.0f), 
(float2)(0.000000164791f,0.0f), (float2)(0.000000-259223f,0.0f), 
                                    (float2)(0.000000121102f,0.0f), 
(float2)(240068f,0.0f), (float2)(0.72992f,0.0f), (float2)(166.082f,0.0f), 
(float2)(853.389f,0.0f), (float2)(1010.26f,0.0f), 
                                    (float2)(1341.72f,0.0f), 
(float2)(4030.4f,0.0f), (float2)(681.581f,15292.9f), 
(float2)(1708.44f,8400.45f), (float2)(439.62f,0.0f), 
(float2)(0.00000421131f,0.0f)}
                                  };

I get the following errors:
    - error: expected a ")
    - error: expression must have a constant value
    - error: expected a "}"

Am I doing something wrong in the definition of the array?

Kind regards,

Gwenaël


----- Mail original -----
> De: "Bogdan Opanchuk" <[email protected]>
> À: "gwenael guillaume" <[email protected]>
> Cc: "Pyopencl" <[email protected]>
> Envoyé: Mercredi 21 Mai 2014 09:41:18
> Objet: Re: [PyOpenCL] Complex number arrays in OpenCL
> 
> 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

Reply via email to