Skip to content
Snippets Groups Projects
Commit 3665201f authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Merge pull request #5 from EyNuel/patch-1

added '_add' and '_radd' to pyopencl-complex.h for consistency.
parents e8b58eba 1c328931
No related branches found
No related tags found
No related merge requests found
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
// functions as visible below, e.g. cdouble_log(z). // functions as visible below, e.g. cdouble_log(z).
// //
// Under the hood, the complex types are simply float2 and double2. // Under the hood, the complex types are simply float2 and double2.
// Note that addition (real + complex) and multiplication (complex*complex)
// are defined, but yield wrong results.
#define PYOPENCL_DECLARE_COMPLEX_TYPE_INT(REAL_TP, REAL_3LTR, TPROOT, TP) \ #define PYOPENCL_DECLARE_COMPLEX_TYPE_INT(REAL_TP, REAL_3LTR, TPROOT, TP) \
\ \
...@@ -36,10 +34,18 @@ ...@@ -36,10 +34,18 @@
TP TPROOT##_fromreal(REAL_TP a) { return (TP)(a, 0); } \ TP TPROOT##_fromreal(REAL_TP a) { return (TP)(a, 0); } \
TP TPROOT##_conj(TP a) { return (TP)(a.x, -a.y); } \ TP TPROOT##_conj(TP a) { return (TP)(a.x, -a.y); } \
\ \
TP TPROOT##_add(TP a, TP b) \
{ \
return a+b; \
} \
TP TPROOT##_addr(TP a, REAL_TP b) \ TP TPROOT##_addr(TP a, REAL_TP b) \
{ \ { \
return (TP)(b+a.x, a.y); \ return (TP)(b+a.x, a.y); \
} \ } \
TP TPROOT##_radd(REAL_TP a, TP b) \
{ \
return (TP)(a+b.x, b.y); \
} \
\ \
TP TPROOT##_mul(TP a, TP b) \ TP TPROOT##_mul(TP a, TP b) \
{ \ { \
...@@ -53,6 +59,11 @@ ...@@ -53,6 +59,11 @@
return a*b; \ return a*b; \
} \ } \
\ \
TP TPROOT##_rmul(REAL_TP a, TP b) \
{ \
return a*b; \
} \
\
TP TPROOT##_rdivide(REAL_TP z1, TP z2) \ TP TPROOT##_rdivide(REAL_TP z1, TP z2) \
{ \ { \
if (fabs(z2.x) <= fabs(z2.y)) { \ if (fabs(z2.x) <= fabs(z2.y)) { \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment