ArraysΒΆ

For every basic data type that SIMDy supports there is specialized class for storing elements of that type. So for example if you want array that holds int32 elements there is class array_int32. Below you see example how to create an array add some elements and modify it.

from simdy import array_float64, float64

arr = array_float64()
arr.append(float64(2))
arr.append(float64(1))
arr.append(float64(-2))
arr[1] = float64(4)

for i in range(len(arr)):
print(arr[i])

Inside of SIMDy kernels you can only modifies contents of array. Reason for this is because inside of SIMDy kernels memory allocations are not allowed. Continuing on above example simple kernel is written that whill modify array.

from simdy import simdy_kernel

@simdy_kernel
def init_array(arr: array_float64):
    for i in range(len(arr)):
        arr[i] = float64(i)

init_array(arr)
for i in range(len(arr)):
    print(arr[i])