Skip to content

Commit

Permalink
Inlined various C functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnl committed Nov 24, 2014
1 parent ce2509e commit d405d02
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion scikits/pulsefit/fit_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def view(
correct=True, pulse_add_len=None, pulse_min_dist=0,
return_blocks=False, debug=True, cb=None):

plt.interactive(True)
plt.ion()

def _view_block(b):
fig = plt.gcf()
Expand Down
24 changes: 12 additions & 12 deletions src/ampfit_mle.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ PyMODINIT_FUNC initampfit_mle_c(void) {
*****************************************************************************/

// calc_lam_ij computes a single entry in the lambda matrix.
npy_float64 calc_lam_ij(npy_int64 i0, // Index of first pulse.
npy_int64 i1, // Index of second pulse.
npy_int64 n_r, // Block data length.
npy_float64 *p, // Pulse shape.
npy_int64 n_p // Pulse length.
) {
inline npy_float64 calc_lam_ij(npy_int64 i0, // Index of first pulse.
npy_int64 i1, // Index of second pulse.
npy_int64 n_r, // Block data length.
npy_float64 *p, // Pulse shape.
npy_int64 n_p // Pulse length.
) {
// Note that it's required that i1 >= i0.
npy_int64 di = i1 - i0;
npy_int64 imax = MIN(n_p - di, n_r - i0 - di);
Expand Down Expand Up @@ -95,12 +95,12 @@ static PyObject *compute_lambda_matrix(PyObject *self, PyObject *args) {
*****************************************************************************/

// calc_phi_i computes a single element of the phi array.
npy_float64 calc_phi_i(npy_int64 idx, // Pulse index.
npy_float64 *r, // Raw data.
npy_int64 n_r, // Raw data length
npy_float64 *p, // Pulse shape.
npy_int64 n_p // Pulse length.
) {
inline npy_float64 calc_phi_i(npy_int64 idx, // Pulse index.
npy_float64 *r, // Raw data.
npy_int64 n_r, // Raw data length
npy_float64 *p, // Pulse shape.
npy_int64 n_p // Pulse length.
) {
npy_int64 i;
npy_int64 imax = MIN(n_p, n_r - idx);
npy_float64 phii = 0;
Expand Down
64 changes: 32 additions & 32 deletions src/moving_median.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ typedef struct _mm_handle mm_handle;
* Return the index of the smallest child of the node. The pointer
* child will also be set.
*/
npy_int64 get_smallest_child(mm_node **heap,
npy_int64 size,
npy_int64 idx,
mm_node **child) {
inline npy_int64 get_smallest_child(mm_node **heap,
npy_int64 size,
npy_int64 idx,
mm_node **child) {
npy_int64 i0 = FC_IDX(idx);
npy_int64 i1 = i0 + NUM_CHILDREN;
i1 = min(i1, size);
Expand All @@ -86,10 +86,10 @@ npy_int64 get_smallest_child(mm_node **heap,
* Return the index of the largest child of the node. The pointer
* child will also be set.
*/
npy_int64 get_largest_child(mm_node **heap,
npy_int64 size,
npy_int64 idx,
mm_node **child) {
inline npy_int64 get_largest_child(mm_node **heap,
npy_int64 size,
npy_int64 idx,
mm_node **child) {
npy_int64 i0 = FC_IDX(idx);
npy_int64 i1 = i0 + NUM_CHILDREN;
i1 = min(i1, size);
Expand Down Expand Up @@ -122,11 +122,11 @@ npy_int64 get_largest_child(mm_node **heap,
/*
* Move the given node up through the heap to the appropriate position.
*/
void move_up_small(mm_node **heap,
npy_int64 idx,
mm_node *node,
npy_int64 p_idx,
mm_node *parent) {
inline void move_up_small(mm_node **heap,
npy_int64 idx,
mm_node *node,
npy_int64 p_idx,
mm_node *parent) {
do {
SWAP_NODES(heap, idx, node, p_idx, parent);
if(idx == 0) {
Expand All @@ -140,10 +140,10 @@ void move_up_small(mm_node **heap,
/*
* Move the given node down through the heap to the appropriate position.
*/
void move_down_small(mm_node **heap,
npy_int64 size,
npy_int64 idx,
mm_node *node) {
inline void move_down_small(mm_node **heap,
npy_int64 size,
npy_int64 idx,
mm_node *node) {
mm_node *child;
npy_float64 val = node->val;
npy_int64 c_idx = get_largest_child(heap, size, idx, &child);
Expand All @@ -158,11 +158,11 @@ void move_down_small(mm_node **heap,
* Move the given node down through the heap to the appropriate
* position.
*/
void move_down_large(mm_node **heap,
npy_int64 idx,
mm_node *node,
npy_int64 p_idx,
mm_node *parent) {
inline void move_down_large(mm_node **heap,
npy_int64 idx,
mm_node *node,
npy_int64 p_idx,
mm_node *parent) {
do {
SWAP_NODES(heap, idx, node, p_idx, parent);
if(idx == 0) {
Expand All @@ -176,10 +176,10 @@ void move_down_large(mm_node **heap,
/*
* Move the given node up through the heap to the appropriate position.
*/
void move_up_large(mm_node **heap,
npy_int64 size,
npy_int64 idx,
mm_node *node) {
inline void move_up_large(mm_node **heap,
npy_int64 size,
npy_int64 idx,
mm_node *node) {
mm_node *child;
npy_float64 val = node->val;
npy_int64 c_idx = get_smallest_child(heap, size, idx, &child);
Expand All @@ -193,12 +193,12 @@ void move_up_large(mm_node **heap,
/*
* Swap the heap heads.
*/
void swap_heap_heads(mm_node **s_heap,
npy_int64 n_s,
mm_node **l_heap,
npy_int64 n_l,
mm_node *s_node,
mm_node *l_node) {
inline void swap_heap_heads(mm_node **s_heap,
npy_int64 n_s,
mm_node **l_heap,
npy_int64 n_l,
mm_node *s_node,
mm_node *l_node) {
s_node->small = 0;
l_node->small = 1;
s_heap[0] = l_node;
Expand Down

0 comments on commit d405d02

Please sign in to comment.