> Am 17.02.2016 um 17:48 schrieb Andreas Kloeckner <[email protected]>: > > Gregor Thalhammer <[email protected]> writes: >> Using cdouble_real() etc. explicitly instead of direct attribute >> access in pyopencl-complex.h would require to have two implementations >> of each complex math function for cdouble and cfloat. In my opinion >> that is not a sensible option. Now there is only one macro definition >> for both single and double precision complex math. > > No, disagreed. > > Example: > > > #define PYOPENCL_DECLARE_COMPLEX_TYPE_INT(REAL_TP, REAL_3LTR, TPROOT, TP) \ > \ > TP TPROOT##_add(TP a, TP b) \ > { \ > return TPROOT##_new(TPROOT##_real(a) + TPROOT##_real(b), > TPROOT##_imag(a) + TPROOT##_imag(b)); \ > ; \ > } \ > > PYOPENCL_DECLARE_COMPLEX_TYPE(float, FLT); > PYOPENCL_DECLARE_COMPLEX_TYPE(double, DBL); > > Andreas
Ah, you are right, this possibility did not come to my mind. Sorry for the confusion. My initial concern was that ‚a.x + b.x' is slightly less obvious and readable than 'a.real + b.real‘, so I sorted out any other possibility that is significantly more convoluted. Honestly, I do not see the advantage of using 'TPROOT##_real(a)‘ instead of ‚a.x‘, especially in terms of readability. But if you prefer it, it would not be a big issue to change it that way. Gregor _______________________________________________ PyOpenCL mailing list [email protected] https://lists.tiker.net/listinfo/pyopencl
