cpp11armadillo
The idea is to pass matrices/vectors from R to C++, write pure C++/Armadillo code for the computation, and then export the result back to R with the proper data structures.
Science Score: 39.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (17.7%) to scientific vocabulary
Keywords
armadillo
cpp
cpp11
hacktoberfest
linear-algebra
rstats
Last synced: 6 months ago
·
JSON representation
Repository
The idea is to pass matrices/vectors from R to C++, write pure C++/Armadillo code for the computation, and then export the result back to R with the proper data structures.
Basic Info
- Host: GitHub
- Owner: pachadotdev
- License: apache-2.0
- Language: C++
- Default Branch: main
- Homepage: http://pacha.dev/cpp11armadillo/
- Size: 50.4 MB
Statistics
- Stars: 13
- Watchers: 1
- Forks: 1
- Open Issues: 1
- Releases: 0
Topics
armadillo
cpp
cpp11
hacktoberfest
linear-algebra
rstats
Created about 2 years ago
· Last pushed 7 months ago
Metadata Files
Readme
Changelog
Contributing
License
Code of conduct
Support
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# cpp11armadillo
[](https://github.com/pachadotdev/cpp11armadillo/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/pachadotdev/cpp11armadillo)
[](https://buymeacoffee.com/pacha)
[](https://CRAN.R-project.org/package=cpp11armadillo)
## About
The goal of cpp11armadillo is to provide a novel approach to use the [Armadillo
C++ library](https://arma.sourceforge.net/docs.html) by using the header-only
cpp11 R package and to simplify things for the end-user. It uses the Apache 2.0
license.
⚠️Important⚠️: cpp11armadillo was created to ease writing functions in your own
packages and does not offer on-the-fly compilation for code snippets.
The idea is to pass matrices/vectors from R to C++, write pure C++/Armadillo
code for the computation, and then export the result back to R with the proper
data structures.
[RcppArmadillo](https://cran.r-project.org/package=RcppArmadillo) is a
popular R package used by over 1200 CRAN packages as of 2024-12-13.
RcppArmadillo uses the GPL-3 license.
cpp11armadillo has different internals, even when the goal is the same, and it
aims to:
* Enforcing copy-on-write semantics.
* Improving the safety of using the R API from C++ code.
* Using UTF-8 strings everywhere.
* Applying newer C++11 features.
* Having a more straightforward, simpler implementation.
* Faster compilation time with lower memory requirements.
* Growing vectors more efficiently.
The design differences result in marginally higher speed for cpp11armadillo, and
the real difference for the end user is that cpp11armadillo:
* Has a smaller memory footprint.
* Uses the Apache license instead of GPL-3 (i.e., The Apache license is
permissive and allows commercial use with attribution, unlike the GPL-3,
which requires open-source redistribution.)
* Can be vendored to be used in restricted environments (i.e., servers with no
internet access or where IT restricts the installation of packages).
This is expanded in our article [cpp11armadillo: An R package to use the Armadillo C++ library](https://dx.doi.org/10.1016/j.softx.2025.102087).
If this software is useful to you, please consider donating on
[Buy Me A Coffee](https://buymeacoffee.com/pacha). All donations will
be used to continue improving cpp11armadillo.
## Getting Started
Install the released version of cpp11armadillo from CRAN:
``` r
install.packages("cpp11armadillo")
```
Or, alternatively, install the development version of cpp11armadillo from
GitHub:
``` r
remotes::install_github("pachadotdev/cpp11armadillo")
```
## Who uses cpp11armadillo?
cpp11armadillo is used by the following packages:
* [lotri](https://github.com/nlmixr2/lotri), created by Dr. Matt Fidler.
* [economiccomplexity](https://github.com/pachadotdev/economiccomplexity),
created by me.
## Examples
I have provided a package template for RStudio that also works with VS Code.
The idea of this package is to be as simple as possible, with the least amount
of setup to get you started.
From RStudio/VSCode, go to an empty directory of your choice and run:
```r
# subdir + package name
# subdir can be "." to create the package in the current directory
cpp11armadillo::pkg_template("pkgtemplate", "myownpackage")
```
Then follow the instructions from README.md in the path where the new package
is. The template contains a simple Ordinary Least Squares (OLS) example that you
can run to test the package.
The vignette expands on the OLS estimator, and the
[hansen package](https://pacha.dev/hansen/) expands on how to use cpp11armadillo
for Econometric models.
The [cpp11armadillotest](https://github.com/pachadotdev/cpp11armadillo/tree/main/cpp11armadillotest)
directory contains a package that I use to test cpp11armadillo. It includes
tests for OLS, eigenvalues, matrix decompositions (Cholesky and QR), the Capital
Asset Pricing Model (CAPM), and data consistency between R and C++. Please note
that cpp11armadillotest is a dummy package to test the C++ build with GitHub
Actions, and you do not need to install it. You can check its code to get extra
examples.
## Linear Algebra Libraries
Armadillo supports OpenBLAS, Intel MKL, and the Accelerate framework (Mac).
Install OpenBLAS on Debian-based systems with:
```bash
sudo apt-get install libopenblas-dev
```
Restart R and run the following command to verify:
```r
sessionInfo()
```
R should display something like:
```r
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0
```
Owner
- Name: Mauricio "Pachá" Vargas Sepúlveda
- Login: pachadotdev
- Kind: user
- Website: https://pacha.dev
- Repositories: 308
- Profile: https://github.com/pachadotdev
Statistician interested in applying statistical methods to address specific policy-relevant questions, particularly in international trade.
GitHub Events
Total
- Issues event: 10
- Watch event: 6
- Issue comment event: 27
- Push event: 94
- Create event: 1
Last Year
- Issues event: 10
- Watch event: 6
- Issue comment event: 27
- Push event: 94
- Create event: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 10
- Total pull requests: 0
- Average time to close issues: 19 days
- Average time to close pull requests: N/A
- Total issue authors: 6
- Total pull request authors: 0
- Average comments per issue: 3.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 8
- Pull requests: 0
- Average time to close issues: 22 days
- Average time to close pull requests: N/A
- Issue authors: 6
- Pull request authors: 0
- Average comments per issue: 3.63
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- pachadotdev (5)
- eddelbuettel (1)
- barracuda156 (1)
- fangzhou-xie (1)
- reikoch (1)
- conradsnicta (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 2,233 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 11
- Total maintainers: 1
cran.r-project.org: cpp11armadillo
An 'Armadillo' Interface
- Homepage: https://pacha.dev/cpp11armadillo/
- Documentation: http://cran.r-project.org/web/packages/cpp11armadillo/cpp11armadillo.pdf
- License: Apache License (≥ 2)
-
Latest release: 0.5.4
published 7 months ago
Rankings
Dependent packages count: 27.8%
Dependent repos count: 35.7%
Average: 49.5%
Downloads: 85.2%
Maintainers (1)
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.5.0 depends
- knitr * suggests
- rmarkdown * suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/format.yaml
actions
- actions/checkout v2 composite
.github/workflows/pr-commands.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/pr-fetch v2 composite
- r-lib/actions/pr-push v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
cpp11armadillotest/DESCRIPTION
cran
- R >= 3.5.0 depends
- knitr * suggests
- rmarkdown * suggests
- testthat >= 3.0.0 suggests