-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
I installed hope from the git and run the following:
import numpy as np
import hope
@hope.jit
def pdf(density, dims, center, w2D, r50, b, a):
for x in range(dims[0]):
for y in range(dims[1]):
dr = np.sqrt((x - center[0]) ** 2 + (y - center[1]) ** 2)
density[x, y] = np.sum(w2D * 2 * (b - 1) / (2 * np.pi * (r50 * a)**2) * (1 + (dr / (r50 * a))**2)**(-b))
return density
with:
python -m timeit -s 'import numpy as np; b = 3.5; a = 1. / np.sqrt(2. ** (1. / (b - 1.)) - 1.) ; r50=20;center = np.array([10.141, 10.414]);dims = np.array([20, 20]) ; x1D = np.array([ 0.5 - 0.9491079123427585245262 / 2 , 0.5 - 0.7415311855993944398639 / 2 , 0.5 - 0.4058451513773971669066 / 2 , 0.5 , 0.5 + 0.4058451513773971669066 / 2 , 0.5 + 0.7415311855993944398639 / 2 , 0.5 + 0.9491079123427585245262 / 2 ], dtype=np.float32) ; w1D = np.array([ 0.1294849661688696932706 / 2 , 0.2797053914892766679015 / 2 , 0.38183005050511894495 / 2 , 0.4179591836734693877551 / 2 , 0.38183005050511894495 / 2 , 0.2797053914892766679015 / 2 , 0.1294849661688696932706 / 2 ], dtype=np.float32) ; w2D = np.outer(w1D, w1D) ; from pdf import pdf; density = np.zeros(dims, dtype=np.float32)' 'pdf(density, dims, center, w2D, r50, b, a)'
and the output is rather slow compared to the expected result. C++ module runs at the expected speed, so what did I do wrong?
Metadata
Metadata
Assignees
Labels
No labels