Rmpfr (version 0.7-2)

sapplyMpfr: Apply a Function over a "mpfr" Vector

Description

Users may be disappointed to note that sapply() or vapply() typically do not work with "mpfr" numbers.

This is a simple (but strong) approach to work around the problem, based on lapply().

Note that this is not yet as flexible as sapply() for atomic vectors.

Usage

sapplyMpfr(X, FUN, …)

Arguments

X

a vector, possibly of class "'>mpfr".

FUN

a function returning an "'>mpfr" number. (TODO: A function returning a vector of mpfr numbers or even "'>mpfrArray").

further arguments passed to lapply, typically further arguments to FUN.

Value

an "'>mpfr" vector, typically of the same length as X.

Examples

Run this code
# NOT RUN {
## The function is simply defined as
function (X, FUN, ...)
  new("mpfr", unlist(lapply(X, FUN, ...), recursive = FALSE))

if(require("Bessel")) # here X, is simple
  bImp <- sapplyMpfr(0:4, function(k)
                     besselI.nuAsym(mpfr(1.31e9, 128), 10, expon.scaled=TRUE, k.max=k))
# }

Run the code above in your browser using DataCamp Workspace