https://github.com/ltla/runtimelinksviar
Proof of concept for run-time linking of C++ libraries via R
https://github.com/ltla/runtimelinksviar
Last synced: about 1 year ago
JSON representation
Proof of concept for run-time linking of C++ libraries via R
- Host: GitHub
- URL: https://github.com/ltla/runtimelinksviar
- Owner: LTLA
- Created: 2018-08-14T13:41:56.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-14T13:51:56.000Z (almost 8 years ago)
- Last Synced: 2025-02-10T12:29:32.432Z (over 1 year ago)
- Language: C++
- Size: 1.95 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Proof of concept for run-time linking
The idea is to be able to link C++ code from different packages at run-time.
To demonstrate, install **packA** and **packB** in any order, and then run the following code in an R session:
```{r}
library(packB)
.Call("runner", 1, 2, PACKAGE="packB")
```
The `runner` C++ function (in **packB**) will first attach **packA** to the current section;
use R's `R_getCCallable` mechanism to search for a C function in the shared library of **packA**;
and finally, execute that C function and return a result (in this case, addition of the two supplied scalars).
This strategy provides more options for the **beachmat** API, in that we no longer need to define the universe of all matrix representations at compile time.
The aim is to allow downstream packages implementing their own matrix representations to also implement their own C++ routines that can be exploited by **beachmat**.
This is more efficient than relying on block realization via R for arbitrary matrices.