dawn@0: /* dawn@0: * rsum_inplace.c dawn@0: * in-place running sum dawn@0: * dawn@0: * Alain de Cheveigné, CNRS/Ircam Jun 2002 dawn@0: * (c) 2002 CNRS dawn@0: */ dawn@0: dawn@0: /* Replaces each sample of the input matrix by the sum of itself and its N-1 dawn@0: * neighbors. The operation is done in-place on the input argument. The last dawn@0: * N-1 samples of each row are invalid. */ dawn@0: dawn@0: #include dawn@0: #include "mex.h" dawn@0: dawn@0: /* #define MWRAP */ dawn@0: #include "mwrap_check.h" dawn@0: dawn@0: /* Input Arguments */ dawn@0: #define X_IN prhs[0] dawn@0: #define N_IN prhs[1] dawn@0: dawn@0: /* Output Arguments */ dawn@0: dawn@0: static void rsmth( dawn@0: double *xp, /* matrix to sum */ dawn@0: double N, /* window size */ dawn@0: int m, /* rows */ dawn@0: int n /* columns */ dawn@0: ) dawn@0: { dawn@0: int j,k, Ni; dawn@0: double Nr, tmp, sum, *x, *xx, *bump; dawn@0: dawn@0: Ni = (int) floor(N); dawn@0: Nr = N - (double) Ni; dawn@0: dawn@0: dawn@0: if (Nr == 0.0) { dawn@0: /* N is integer: simple summation */ dawn@0: for (j=0;j