[Rcpp-commits] r3173 - pkg/Rcpp/inst/examples/Fibonacci

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 17 15:36:35 CEST 2011


Author: edd
Date: 2011-08-17 15:36:35 +0200 (Wed, 17 Aug 2011)
New Revision: 3173

Modified:
   pkg/Rcpp/inst/examples/Fibonacci/fib.r
Log:
added missing call to library(compiler)


Modified: pkg/Rcpp/inst/examples/Fibonacci/fib.r
===================================================================
--- pkg/Rcpp/inst/examples/Fibonacci/fib.r	2011-08-16 01:23:41 UTC (rev 3172)
+++ pkg/Rcpp/inst/examples/Fibonacci/fib.r	2011-08-17 13:36:35 UTC (rev 3173)
@@ -30,13 +30,14 @@
 ')
 
 ## for comparison, the original (but repaired with 0/1 offsets)
-fibR <- function(seq) {
-    if (seq == 0) return(0)
-    if (seq == 1) return(1)
-    return (fibR(seq - 1) + fibR(seq - 2))
+fibR <- function(n) {
+    if (n == 0) return(0)
+    if (n == 1) return(1)
+    return (fibR(n - 1) + fibR(n - 2))
 }
 
 ## also use byte-compiled R function
+require(compiler)
 fibRC <- cmpfun(fibR)
 
 ## load rbenchmark to compare



More information about the Rcpp-commits mailing list