X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=epclust%2Fsrc%2Ffilter.cpp;fp=epclust%2Fsrc%2Ffilter.cpp;h=0000000000000000000000000000000000000000;hb=40f12a2f66d06fd77183ea02b996f5c66f90761c;hp=175000032af80c1e7ad30b1ba2d6889f2bbd56a4;hpb=a52836b23adb4bfa6722642ec6426fb7b5f39650;p=epclust.git diff --git a/epclust/src/filter.cpp b/epclust/src/filter.cpp deleted file mode 100644 index 1750000..0000000 --- a/epclust/src/filter.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include - -using namespace Rcpp; - -//' filter -//' -//' Filter [time-]series by replacing all values by the moving average of previous, current and -//' next value. Possible extensions: larger window, gaussian kernel... (but would be costly!). -//' Note: border values are unchanged. -//' -//' @param cwt Continuous wavelets transform (in columns): a matrix of size LxD -//' -//' @return The filtered CWT, in a matrix of same size (LxD) -// [[Rcpp::export]] -RcppExport SEXP filterMA(SEXP cwt_) -{ - // NOTE: C-style for better efficiency (this must be as fast as possible) - int L = INTEGER(Rf_getAttrib(cwt_, R_DimSymbol))[0], - D = INTEGER(Rf_getAttrib(cwt_, R_DimSymbol))[1]; - double *cwt = REAL(cwt_); - - SEXP fcwt_; //the filtered result - PROTECT(fcwt_ = Rf_allocMatrix(REALSXP, L, D)); - double* fcwt = REAL(fcwt_); //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--) - { - double v1 = cwt[0]; //first value - double ms = v1 + cwt[1] + cwt[2]; //moving sum at second value - for (int i=1; i