X-Git-Url: https://git.auder.net/?p=epclust.git;a=blobdiff_plain;f=epclust%2Fsrc%2Ffilter.c;h=8ece9c3f439dc7eaf2e23f3962e816fec42e829a;hp=97dbef2983fe2a4ea19a8bf30fcd16707f6e05c0;hb=282342bafdc9ff65c5df98c6e2304d63b33b9fb2;hpb=3c5a4b0880db63367a474a568e1322b3999932fe diff --git a/epclust/src/filter.c b/epclust/src/filter.c index 97dbef2..8ece9c3 100644 --- a/epclust/src/filter.c +++ b/epclust/src/filter.c @@ -12,59 +12,59 @@ // @return The filtered matrix, of same size as the input SEXP filterMA(SEXP M_, SEXP w_) { - int L = INTEGER(getAttrib(cwt_, R_DimSymbol))[0], - D = INTEGER(getAttrib(cwt_, R_DimSymbol))[1], + int L = INTEGER(getAttrib(M_, R_DimSymbol))[0], + D = INTEGER(getAttrib(M_, R_DimSymbol))[1], w = INTEGER_VALUE(w_), half_w = (w-1)/2, i, nt; //number of terms in the current sum (max: w) - double *cwt = REAL(cwt_), + double *M = REAL(M_), cs, //current sum (max: w terms) left; //leftward term in the current moving sum - SEXP fcwt_; //the filtered result - PROTECT(fcwt_ = allocMatrix(REALSXP, L, D)); - double* fcwt = REAL(fcwt_); //pointer to the encapsulated vector + SEXP fM_; //the filtered result + PROTECT(fM_ = allocMatrix(REALSXP, L, D)); + double* fM = REAL(fM_); //pointer to the encapsulated vector // NOTE: unused loop parameter: shifting at the end of the loop is more efficient for (int col=D-1; col>=0; col--) { // Initialization nt = half_w + 1; - left = cwt[0]; + left = M[0]; cs = 0.; for (i=half_w; i>=0; i--) - cs += cwt[i]; + cs += M[i]; // Left border for (i=0; i