MyNixOS website logo
Description

An 'Eigen' Interface.

Provides function declarations and inline function definitions that facilitate communication between R and the 'Eigen' 'C++' library for linear algebra and scientific computing.

cpp11eigen

R-CMD-check codecov BuyMeACoffee CRANstatus

The goal of cpp11eigen is to provide a novel approach to use the Eigen C++ library by using the header-only cpp11 R package and to simplify things for the end-user.

The idea is to pass matrices/vectors from R to C++, write pure C++/Eigen code for the computation, and then export the result back to R with the proper data structures.

This follows from the same goals as cpp11:

  • 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.

If this software is useful to you, please consider donating on Buy Me A Coffee. All donations will be used to continue improving cpp11eigen.

Installation

You can install the development version of cpp11eigen from GitHub:

remotes::install_github("pachadotdev/cpp11eigen")

Examples

I have provided a package template for RStudio that also works with VS Code.

The idea of this package is to be naive and simple (like me).

From RStudio/VSCode create a new project and run:

cpp11eigen::pkg_template()

Then follow the instructions from the README.

The vignettes contains detailed examples that I use to test cpp11eigen, these include Ordinary Least Squares.

Linear Algebra Libraries

Eigen supports OpenBLAS, Intel MKL, and the Accelerate framework (Mac). You can install OpenBLAS on Debian-based systems with:

sudo apt-get install libopenblas-dev

You can also use other commands for your specific operating system.

To verify that R is using OpenBLAS, you can run sessionInfo() after restarting R to check the BLAS/LAPACK libraries in use:

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
Metadata

Version

0.2.0

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows