Construct DoubleVisitor object from Basic or VecBasic and use it to numerically evaluate symbolic expressions.

DoubleVisitor(
  exprs,
  args,
  perform_cse = TRUE,
  llvm_opt_level = if (symengine_have_component("llvm")) 3L else -1L
)

visitor_call(visitor, input, do_transpose = FALSE)

Arguments

exprs

A Basic object or a VecBasic object to be evaluated.

args

A VecBasic object indicating order of input arguments. Can be missing.

perform_cse

Boolean.

llvm_opt_level

Integer. If negative, it will return a LambdaDoubleVisitor, otherwise it will return a LLVMDoubleVisitor with the specified optimization level.

visitor

A DoubleVisitor object.

input

A numeric matrix. Each row is input value for one argument.

do_transpose

Boolean. Matters when exprs is a VecBasic. If true, output will have each column for one symbolic expression, otherwise each row for one symbolic expression.

Value

DoubleVisitor returns a callable LambdaDoubleVisitor or

LLVMDoubleVisitor. visitor_call returns a numeric vector or matrix.

Details

DoubleVisitor constructs the visitor and visitor itself is callable. visitor_call is the low level function to call the visitor with input.

See also

Examples

a <- S("a")
b <- S("b")
c <- S("c")
vec <- c(log(a), log(a)/log(b) + c)
func <- DoubleVisitor(vec, args = c(a, b, c))
args(func)
#> function (a, b, c) 
#> NULL

## Use closure
func(a = 1:10, b = 10:1, c = 1.43)
#>            [,1]     [,2]
#>  [1,] 0.0000000 1.430000
#>  [2,] 0.6931472 1.745465
#>  [3,] 1.0986123 1.958321
#>  [4,] 1.3862944 2.142414
#>  [5,] 1.6094379 2.328244
#>  [6,] 1.7917595 2.543283
#>  [7,] 1.9459101 2.833677
#>  [8,] 2.0794415 3.322789
#>  [9,] 2.1972246 4.599925
#> [10,] 2.3025851      Inf

## Use visitor_call
input <- rbind(a = 1:10, b = 10:1, c = 1.43)
visitor_call(func, input, do_transpose = TRUE)
#>            [,1]     [,2]
#>  [1,] 0.0000000 1.430000
#>  [2,] 0.6931472 1.745465
#>  [3,] 1.0986123 1.958321
#>  [4,] 1.3862944 2.142414
#>  [5,] 1.6094379 2.328244
#>  [6,] 1.7917595 2.543283
#>  [7,] 1.9459101 2.833677
#>  [8,] 2.0794415 3.322789
#>  [9,] 2.1972246 4.599925
#> [10,] 2.3025851      Inf