Skip to content

Instantly share code, notes, and snippets.

@FrancescAlted
Created January 13, 2022 13:59
Show Gist options
  • Save FrancescAlted/a93cf66d7f12d687f4315d4e21e66433 to your computer and use it in GitHub Desktop.
Save FrancescAlted/a93cf66d7f12d687f4315d4e21e66433 to your computer and use it in GitHub Desktop.
Example of UDF in ironArray
@jit()
def udf_iarray(out: Array(float32, 3),
p1: Array(float32, 3),
p2: Array(float32, 3),
p3: Array(float32, 3)) -> int:
l = p1.window_shape[0]
m = p1.window_shape[1]
n = p1.window_shape[2]
for i in range(l):
for j in range(m):
for k in range(n):
value = math.sin(p1[i,j,k]) * math.sin(p2[i,j,k]) + math.cos(p2[i,j,k])
value *= math.tan(p1[i,j,k])
value += math.cosh(p3[i,j,k]) * 2
if value < 0:
out[i,j,k] = 0
else:
out[i,j,k] = value
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment