fibonacci_omp {rcpptimer}R Documentation

Simple rcpptimer example using OpenMP

Description

Time the multithreaded computation of Fibonacci numbers

Usage

fibonacci_omp(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_omp(n = rep(10*(1:4), 10))
# this function creates a global environment variable "times"
times


[Package rcpptimer version 1.1.0 Index]