Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- cimport numpy as np
- cimport cython
- FTYPE = np.float
- ctypedef np.float32_t FTYPE_t
- @cython.boundscheck(False)
- cdef np.ndarray[np.int32_t, ndim=1] _calc_density(np.ndarray[FTYPE_t, ndim=2] normals, float r):
- cdef np.ndarray[np.int32_t, ndim=1] density = np.zeros(normals.shape[0], dtype=np.int32)
- cdef Py_ssize_t i, j, t
- cdef float s, distance
- s = r**2
- t = normals.shape[0]
- print "Hi"
- for i in range(t):
- density[i] = 0
- for j in range(i):
- print i, j
- distance = (normals[i, 0] - normals[j, 0])**2 \
- + (normals[i, 1] - normals[j, 1])**2 \
- + (normals[i, 2] - normals[j, 2])**2
- if distance <= s:
- density[i] += 1
- density[j] += 1
- return density
- def calc_density(normals, r):
- return _calc_density(normals, r)
Advertisement
Add Comment
Please, Sign In to add comment