From 815508e1a4a70f052f143c8b21712cd45d2f7a9f Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Mon, 20 Sep 2010 11:41:17 -0700 Subject: [PATCH] Allow in-pace add/subtract of scalars. --- pyopencl/array.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pyopencl/array.py b/pyopencl/array.py index a3c28c34..a193aaa4 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -347,12 +347,20 @@ class Array(object): return result def __iadd__(self, other): - self._axpbyz(self, 1, self, 1, other) - return self + if isinstance(other, Array): + self._axpbyz(self, 1, self, 1, other) + return self + else: + self._axpbz(self, 1, self, other) + return self def __isub__(self, other): - self._axpbyz(self, 1, self, -1, other) - return self + if isinstance(other, Array): + self._axpbyz(self, 1, self, -1, other) + return self + else: + self._axpbz(self, 1, self, -other) + return self def __neg__(self): result = self._new_like_me() -- GitLab