diff options
Diffstat (limited to 'vector.py')
-rw-r--r-- | vector.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/vector.py b/vector.py new file mode 100644 index 0000000..7b36e07 --- /dev/null +++ b/vector.py @@ -0,0 +1,13 @@ +import numpy as np +from pycuda import gpuarray + +def make_vector(arr, dtype=gpuarray.vec.float3): + if len(arr.shape) != 2 or arr.shape[-1] != 3: + raise Exception('shape mismatch') + + x = np.empty(arr.shape[0], dtype) + x['x'] = arr[:,0] + x['y'] = arr[:,1] + x['z'] = arr[:,2] + + return x |