Learn R Programming

itp (version 1.2.2)

xptr_eval: Call a C++ function using an external pointer

Description

This function is used in plot.itp to plot a function and the root estimated by itp.

Usage

xptr_eval(x, pars, xpsexp)

Value

A numeric scalar: the value of the C++ function evaluated at the input values x and pars.

Arguments

x

The main argument of the function.

pars

A list of additional arguments to the function. This may be an empty list.

xpsexp

An external pointer to a C++ function.

Details

See the Passing user-supplied C++ functions article in the Rcpp Gallery for information.

See Also

xptr_create for creating an external pointer to a C++ function.

Examples

Run this code
lambert_ptr <- xptr_create("lambert")
res <- itp(lambert_ptr, c(-1, 1))

# Value at lower limit
xptr_eval(-1, list(), lambert_ptr)

# Value at upper limit
xptr_eval(1, list(), lambert_ptr)

# Value at the estimated root
xptr_eval(res$root, list(), lambert_ptr)

Run the code above in your browser using DataLab