Ok. You may want to add a test for it in test_gpuarray. I send you a
possible patch.
Also. Do you think adding a ones function is not a good idea ? I figured it
would get
pycuda a little bit closer to numpy.

patch :

diff --git a/test/test_gpuarray.py b/test/test_gpuarray.py
index 361377b..a99136f 100644
--- a/test/test_gpuarray.py
+++ b/test/test_gpuarray.py
@@ -128,6 +128,19 @@ class TestGPUArray:


     @mark_cuda_test
+    def test_iaddition_array(self):
+        """Test the inplace addition of two arrays."""
+
+        a = numpy.array([1,2,3,4,5,6,7,8,9,10]).astype(numpy.float32)
+        a_gpu = gpuarray.to_gpu(a)
+        a_gpu += a_gpu
+        a_added = a_gpu.get()
+
+        assert (a+a == a_added).all()
+
+
+
+    @mark_cuda_test
     def test_addition_scalar(self):
         """Test the addition of an array and a scalar."""

@@ -139,6 +152,19 @@ class TestGPUArray:



+    @mark_cuda_test
+    def test_iaddition_scalar(self):
+        """Test the inplace addition of an array and a scalar."""
+
+        a = numpy.array([1,2,3,4,5,6,7,8,9,10]).astype(numpy.float32)
+        a_gpu = gpuarray.to_gpu(a)
+        a_gpu += 7
+        a_added = a_gpu.get()
+
+        assert (7+a == a_added).all()
+
+
+

     @mark_cuda_test
     def test_substract_array(self):
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda

Reply via email to