Stack-machine evaluator. The stack is a preallocated list of complex vectors; each VAR slot can carry a length-N input, in which case every interior node is computed elementwise via vectorised base::exp and base::log. Returns a complex vector matching the input length.
Usage
run_bytecode(bc, vars = list())Arguments
- bc
compiled bytecode object from
compile_eml().- vars
named list of variable bindings.
Details
Same semantics as eml_eval(), including principal-branch and
extended-real conventions.
See also
compile_eml() for producing the bytecode object;
eml_eval() for the slower tree-walking evaluator.
Examples
bc <- compile_eml(quote(eml(1, eml(eml(1, x), 1))))
xs <- seq(0.5, 5, length.out = 30)
Re(run_bytecode(bc, list(x = xs))) # log(xs)
#> [1] -0.69314718 -0.42285685 -0.21029541 -0.03509132 0.11394426 0.24362208
#> [7] 0.35839760 0.46134557 0.55467751 0.64003736 0.71868048 0.79158725
#> [13] 0.85953792 0.92316361 0.98298211 1.03942342 1.09284858 1.14356368
#> [19] 1.19183042 1.23787436 1.28189124 1.32405205 1.36450701 1.40338879
#> [25] 1.44081520 1.47689126 1.51171102 1.54535906 1.57791166 1.60943791
