summaryrefslogtreecommitdiff
path: root/tests/linalg_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/linalg_test.py')
-rw-r--r--tests/linalg_test.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/linalg_test.py b/tests/linalg_test.py
index b490813..f5e947e 100644
--- a/tests/linalg_test.py
+++ b/tests/linalg_test.py
@@ -29,6 +29,7 @@ float3divfloat = mod.get_function('float3divfloat')
float3divfloatequal = mod.get_function('float3divfloatequal')
floatdivfloat3 = mod.get_function('floatdivfloat3')
dot = mod.get_function('dot')
+cross = mod.get_function('cross')
size = {'block': (100,1,1), 'grid': (1,1)}
@@ -40,6 +41,10 @@ a['x'] = np.random.random_sample(size=a.size)
a['y'] = np.random.random_sample(size=a.size)
a['z'] = np.random.random_sample(size=a.size)
+b['x'] = np.random.random_sample(size=b.size)
+b['y'] = np.random.random_sample(size=b.size)
+b['z'] = np.random.random_sample(size=b.size)
+
def testfloat3add():
dest = np.empty(a.size, dtype=float3)
float3add(cuda.In(a), cuda.In(b), cuda.Out(dest), **size)
@@ -173,3 +178,13 @@ def testdot():
dot(cuda.In(a), cuda.In(b), cuda.Out(dest), **size)
if not np.allclose(a['x']*b['x'] + a['y']*b['y'] + a['z']*b['z'], dest):
assert False
+
+def testcross():
+ dest = np.empty(a.size, dtype=float3)
+ cross(cuda.In(a), cuda.In(b), cuda.Out(dest), **size)
+ for u, v, wdest in zip(a,b,dest):
+ w = np.cross((u['x'], u['y'], u['z']),(v['x'],v['y'],v['z']))
+ if not np.allclose(wdest['x'], w[0]) or \
+ not np.allclose(wdest['y'], w[1]) or \
+ not np.allclose(wdest['z'], w[2]):
+ assert False