odin_build | R Documentation |
Build an odin model generator from its intermediate representation, as generated by odin_parse. This function is for advanced use.
odin_build(x, options = NULL)
x |
An odin ir (json) object or output from odin_validate. |
options |
Options to pass to the build stage (see odin_options |
In applications that want to inspect the intermediate
representation rather before compiling, rather than directly using
odin, use either odin_parse or
odin_validate and then pass the result to
odin::odin_build
.
The return value of this function includes information about how long the compilation took, if it was successful, etc, in the same style as odin_validate:
Logical, indicating if compilation was successful
Time taken to compile the model, as a
proc_time
object, as returned by proc.time.
Any output produced when compiling the model (only present if compiling to C, and if the cache was not hit.
The model itself, as an odin_generator
object,
as returned by odin.
The intermediate representation.
Any error thrown during compilation
odin_parse, which creates intermediate representations used by this function.
# Parse a model of exponential decay
ir <- odin::odin_parse({
deriv(y) <- -0.5 * y
initial(y) <- 1
})
# Compile the model:
options <- odin::odin_options(target = "r")
res <- odin::odin_build(ir, options)
# All results:
res
# The model:
mod <- res$model$new()
mod$run(0:10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.