Skip to content

Commit

Permalink
add cython
Browse files Browse the repository at this point in the history
  • Loading branch information
liang committed Sep 24, 2017
1 parent 494caed commit 97c66c4
Show file tree
Hide file tree
Showing 11 changed files with 16,074 additions and 0 deletions.
Empty file added cython/__init__.py
Empty file.
Binary file added cython/__init__.pyc
Binary file not shown.
Binary file added cython/build/temp.linux-x86_64-2.7/heatmap.o
Binary file not shown.
Binary file added cython/build/temp.linux-x86_64-2.7/pafmap.o
Binary file not shown.
7,693 changes: 7,693 additions & 0 deletions cython/heatmap.c

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions cython/heatmap.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cimport cython
import numpy as np
cimport numpy as np

DTYPE = np.float
ctypedef np.float_t DTYPE_t

def putGaussianMaps(np.ndarray[DTYPE_t, ndim = 2] entry, DTYPE_t rows,
DTYPE_t cols, DTYPE_t center_x, DTYPE_t center_y, DTYPE_t stride,
int grid_x, int grid_y, DTYPE_t sigma):
cdef DTYPE_t start = stride / 2.0 - 0.5
cdef DTYPE_t x, y, d2

for g_y in range(grid_y):
for g_x in range(grid_x):
x = start + g_x * stride
y = start + g_y * stride
d2 = (x - center_x) * (x - center_x) + (y - center_y) * (y - center_y)
exponent = d2 / 2.0 / sigma / sigma
if (exponent > 4.6052):
continue
entry[g_y, g_x] += np.exp(-exponent)
if (entry[g_y, g_x] > 1):
entry[g_y, g_x] = 1
return entry
Binary file added cython/heatmap.so
Binary file not shown.
Loading

0 comments on commit 97c66c4

Please sign in to comment.