[Dplr-commits] r669 - in branches/redfit: R src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 29 15:52:02 CEST 2013


Author: mvkorpel
Date: 2013-08-29 15:52:02 +0200 (Thu, 29 Aug 2013)
New Revision: 669

Modified:
   branches/redfit/R/redfit.R
   branches/redfit/src/redfit.c
Log:
Added some previously missing "dplR" notes to comments added in the dplR
version of redfit.
No "dplR" in a comment means it is essentially from the original REDFIT.


Modified: branches/redfit/R/redfit.R
===================================================================
--- branches/redfit/R/redfit.R	2013-08-27 21:38:10 UTC (rev 668)
+++ branches/redfit/R/redfit.R	2013-08-29 13:52:02 UTC (rev 669)
@@ -108,7 +108,7 @@
     MIN_POINTS <- 2
     WIN_NAMES <- c("rectangular", "welch i", "hanning",
                    "triangular", "blackman-harris")
-    ## 21 is the lower limit of nsim where !anyDuplicated(c(idx80,
+    ## dplR: 21 is the lower limit of nsim where !anyDuplicated(c(idx80,
     ## idx90, idx95, idx99)) is TRUE.  (Also, none of the indices is
     ## 0.)  For more reliable results, a much greated value is
     ## recommended.
@@ -139,7 +139,7 @@
                       NSIM_LIMIT, domain = "R-dplR"),
              domain = NA)
     }
-    ## iwin can be a number or a string. iwin2 is a number %in% 0:4
+    ## dplR: iwin can be a number or a string. iwin2 is a number %in% 0:4
     if (is.numeric(iwin)) {
         if (length(iwin) != 1 || !(iwin %in% 0:4)) {
             stop("numeric 'iwin' must be 0, 1, 2, 3 or 4")
@@ -189,7 +189,7 @@
         t <- t[idx]
         x <- x[idx]
     }
-    ## The rest of the function assumes that t is age, not time
+    ## dplR: The rest of the function assumes that t is age, not time
     if (tType2 == "time") {
         t <- -rev(t)
         x <- rev(x)
@@ -368,7 +368,7 @@
     ##                     3: Parzen (Triangular)
     ##                     4: Blackman-Harris 3-Term
     winbw <- function(iwin, df, ofac) {
-        ## NOTE: bw could be defined with greated precision
+        ## dplR NOTE: bw could be defined with greated precision
         bw <- c(1.21, 1.59, 2.00, 1.78, 2.26)
         df * ofac * bw[iwin + 1]
     }
@@ -376,12 +376,12 @@
     ## and n50 overlapping segments (Harris, 1978).
     ## dplR: Computed more precise values for c50.
     getdof <- function(iwin, n50) {
-        ## Rectangular, Welch, Hanning, Triangular, Blackman-Harris
+        ## dplR: Rectangular, Welch, Hanning, Triangular, Blackman-Harris
         c50 <- c(0.5, 0.34375, 1 / 6, 0.25, 0.0955489871755)
         c2 <- 2 * c50[iwin + 1]^2
         2 * n50 / (1 + c2 - c2 / n50)
     }
-    ## Automatically adds prefix (for example "# " from REDFIT) and
+    ## dplR: Automatically adds prefix (for example "# " from REDFIT) and
     ## newline (if newline = TRUE) to output.
     precat <- function(..., newline = TRUE, sep = "") {
         cat(prefix)
@@ -589,7 +589,7 @@
 }
 
 redfitSetdim <- function(min.nseg, t, np, ofac, hifac, n50, verbose, ...) {
-    ## Formula for nseg from the original Fortran version:
+    ## dplR: Formula for nseg from the original Fortran version:
     ## Integer division (or truncation, or "floor").
     ## nseg <- (2 * np) %/% (n50 + 1)
     ## New version: rounding instead of truncation, order of operations changed.
@@ -601,14 +601,14 @@
     if (n50 == 1) {
         segskip <- 0
     } else {
-        ## (ideal, not rounded) difference between starting indices of
+        ## dplR: (ideal, not rounded) difference between starting indices of
         ## consecutive segments
         segskip <- (np - nseg) / (n50 - 1)
         if (segskip < 1) {
             stop("too many segments: overlap of more than nseg - 1 points")
         }
     }
-    ## It seems that avgdt, fnyq, etc. were somewhat off in the
+    ## dplR: It seems that avgdt, fnyq, etc. were somewhat off in the
     ## original Fortran version because it would not use all of the
     ## data (t[np]) with some combinations of np and n50.
     avgdt <- (t[np] - t[1]) / (np - 1)          # avg. sampling interval
@@ -634,7 +634,7 @@
     for (k in which(nzchar(argnames))) {
         res[[argnames[k]]] <- args[[k]]
     }
-    ## Convert integers (if any) to numeric
+    ## dplR: Convert integers (if any) to numeric
     for (k in seq_along(res)) {
         elem <- res[[k]]
         if (is.integer(elem)) {

Modified: branches/redfit/src/redfit.c
===================================================================
--- branches/redfit/src/redfit.c	2013-08-27 21:38:10 UTC (rev 668)
+++ branches/redfit/src/redfit.c	2013-08-29 13:52:02 UTC (rev 669)
@@ -35,6 +35,7 @@
 	   double *ftrx, double *ftix);
 SEXP makear1(SEXP t, SEXP np, SEXP tau);
 
+/* dplR: Find the start of a segment. */
 /* Formula from the original Fortran version:
  * If nseg is even, the overlap is exactly 50 % every time.
  * If nseg is odd, an overlap of 50 % is impossible, and the actual
@@ -58,7 +59,8 @@
     return fmax(0.0, fmin(np - nseg, round(k * segskip)));
 }
 
-/* Indices for segments of nseg points each with approximately 50 %
+/* dplR:
+ * Indices for segments of nseg points each with approximately 50 %
  * overlap for consecutive values of k. segskip is the (ideal, not
  * rounded) difference between starting points of consecutive
  * segments.  np (number of points) is used for a safety check, only.
@@ -120,7 +122,7 @@
     y_data = REAL(y);
     if (!mismatch) {
 	rdualsptr = REAL(rduals);
-	/* Copy residuals over y */
+	/* dplR: Copy residuals over y */
 	for (i = 0; i < n; i++) {
 	    y_data[i] = rdualsptr[i];
 	}



More information about the Dplr-commits mailing list