This is the initial release of {anvil}, which is a functional composable code transformation framework for R, similar to JAX in Python.
It let's you run numerical programs extremely fast without having to touch lower-level languages like C++ and supports execution on CPUs as well as GPUs.
In a nutshell, you can write ordinary R programs, jit() them, and also easily obtain gradient()s of scalar-valued functions.
You can learn how to do this in our getting started vignette.
One restriction of {anvil} is that it only works with operations where the output shape is known at compile time.
Another restriction is that programs have to be re-compiled for new input types (shape + data type).
These restrictions exist because we are building upon the https://openxla.org/ compiler developed by Google which operates under these assumptions. This means, the package cannot be applied to arbitrary problems and is best used for expressing numerical algorithms such as MCMC samplers or fitting models via gradient-based methods.
However, if it is applicable to your problem, the code will run very fast due to the compilation.
While the package is in an early stage, we already support 70 different primitive operations, including control-flow primitives for conditionals and loops, as well as many common mathematical operations.
Because the package is written almost entirely in R, it is also easy to extend purely in R.
The first release is only on GitHub and r-universe, because the package is still experimental.
Later, we will also distribute our releases via CRAN.
Learn more about it on our website: https://r-xla.github.io/anvil/