fibonacci {rcpptimer} | R Documentation |
Simple rcpptimer example
Description
Time the computation of Fibonacci numbers
Usage
fibonacci(n)
Arguments
n |
vector giving integers for which to compute the Fibonacci sum |
Details
The function being timed is the following:
int fib(int n) { return ((n <= 1) ? n : fib(n - 1) + fib(n - 2)); }
Runtime for computations less than n = 15
is nearly unmeasurable.
Value
vector of integers giving the Fibonacci sum for each element in
n
Examples
fibonacci(n = rep(10*(1:4), 10))
# this function creates a global environment variable "times"
times
[Package rcpptimer version 1.1.0 Index]