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

xptr_eval(x, pars, xpsexp)

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.

Value

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

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

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

# Value at lower limit
xptr_eval(-1, list(), lambert_ptr)
#> [1] -1.367879

# Value at upper limit
xptr_eval(1, list(), lambert_ptr)
#> [1] 1.718282

# Value at the estimated root
xptr_eval(res$root, list(), lambert_ptr)
#> [1] 2.047917e-12