[Dplr-commits] r674 - branches/redfit/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Aug 30 21:04:52 CEST 2013


Author: mvkorpel
Date: 2013-08-30 21:04:51 +0200 (Fri, 30 Aug 2013)
New Revision: 674

Modified:
   branches/redfit/src/redfit.c
Log:
In makear1(), variable 'sigma' was removed.  Its value is now computed
as part of one statement (red_data[i] = ...).


Modified: branches/redfit/src/redfit.c
===================================================================
--- branches/redfit/src/redfit.c	2013-08-29 17:39:47 UTC (rev 673)
+++ branches/redfit/src/redfit.c	2013-08-30 19:04:51 UTC (rev 674)
@@ -85,7 +85,7 @@
     return(seg);
 }
 
-/* dplR: y <- lm.fit(x, y)[["residuals"]]
+/* dplR: y <- lmfit(x, y)[["residuals"]]
  */
 void rmtrend(SEXP x, SEXP y, SEXP lmfit) {
     SEXP tmp, lmcall, lmres, lmnames, rduals;
@@ -189,7 +189,7 @@
     /* dplR: twk_data points to the non-constant column; the constant
      * column will not be altered */
     twk_data = REAL(twk) + nseg_val;
-    
+
     PROTECT(xwk = allocVector(REALSXP, nseg_val));
     /* dplR: unused halves of ftrx and ftix were removed */
     PROTECT(ftrx = allocVector(REALSXP, nfreq_val));
@@ -276,7 +276,7 @@
     double complex work;
     size_t i, ii, iput;
     size_t idx = 0;
-    
+
     const2 = si * const1;
     const3 = (double)(const2 * sumbysqrt);
     /* initialize for zero frequency */
@@ -338,7 +338,7 @@
  * of length 'np - 1'.
  */
 SEXP makear1(SEXP difft, SEXP np, SEXP tau) {
-    double sigma, dt, tau_val, np_val;
+    double dt, tau_val, np_val;
     double *difft_data, *red_data;
     SEXP red;
     size_t i;
@@ -352,8 +352,8 @@
     red_data[0] = norm_rand();
     for (i = 1; i < np_val; i++) {
 	dt = difft_data[i - 1];
-	sigma = sqrt(1.0 - exp(-2.0 * dt / tau_val));
-	red_data[i] = exp(-dt / tau_val) * red_data[i-1] + sigma * norm_rand();
+	red_data[i] = exp(-dt / tau_val) * red_data[i-1] +
+	    sqrt(1.0 - exp(-2.0 * dt / tau_val)) * norm_rand();
     }
     PutRNGstate();
     UNPROTECT(1);



More information about the Dplr-commits mailing list