Skip to content
R package for xtensor-r
Branch: master
Clone or download
Latest commit 4b68a26 Apr 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
inst/include Add roptional.hpp to xtensor.h Apr 17, 2019
man Fixes to please cran (#5) Dec 26, 2018
src
tests Add a simple roundtrip test for optional rarrays and rtensors Apr 17, 2019
tools
.Rbuildignore
.appveyor.yml A bit of cleanup in Xtensor.R CI Mar 29, 2019
.gitignore
.travis.yml
DESCRIPTION Release 0.11.0 Apr 18, 2019
LICENSE
NAMESPACE
README.md Release 0.11.0 Apr 18, 2019
Xtensor.R.Rproj
configure
configure.win

README.md

Xtensor.R

Travis Appveyor Documentation Join the Gitter Chat

R bindings for the xtensor C++ multi-dimensional array library.

  • xtensor is a C++ library for multi-dimensional arrays enabling numpy-style broadcasting and lazy computing.

  • xtensor-r enables inplace use of R arrays in C++ with all the benefits from xtensor

xtensor-r can be used either to author C++ extensions for R with Rcpp, or applications that embed the R interpreter with RInside.

Example

#include <numeric>                    // Standard library import for std::accumulate
#define STRICT_R_HEADERS              // Otherwise a PI macro is defined in R
#include "xtensor/xmath.hpp"          // xtensor import for the C++ universal functions
#include "xtensor-r/rarray.hpp"       // R bindings

#include <Rcpp.h>

using namespace Rcpp;

// [[Rcpp::plugins(cpp14)]]

// [[Rcpp::export]]
double sum_of_sines(xt::rarray<double>& m)
{
    auto sines = xt::sin(m);  // sines does not actually hold values.
    return std::accumulate(sines.cbegin(), sines.cend(), 0.0);
}
v <- matrix(0:14, nrow=3, ncol=5)
s <- sum_of_sines(v)
s

# prints 1.2853996391883833

Installation

xtensor-r has been packaged for CRAN (The Comprehensive R Archive Network). It can be installed

install.packages("xtensor")

or from the repository using devtools:

devtools::install_github("QuantStack/xtensor-r", ref="package")

Installation from Sources

xtensor-r is primarily a C++ library that can be installed classically using cmake in any installation prefix. For example, on unix systems

cmake -D CMAKE_INSTALL_PREFIX=/prefix/path/ .
make
make install

A tarball for the R package archive network (CRAN) can be generated.

mkdir build
cd build
cmake -D CMAKE_INSTALL_PREFIX=/prefix/path/ ..
make
make cran

The generated tarball vendors the headers of the core xtensor library. It can be installed with

install.packages('xtensor_0.9.0-0.tar.gz')

The package can be tested with a simple function call.

library('xtensor')
xtensor::rcpp_hello_xtensor(4:12)

Documentation

To get started with using xtensor-r, check out the full documentation

http://xtensor-r.readthedocs.io/

Dependencies on xtensor and Rcpp

xtensor-r depends on the xtensor and Rcpp libraries

Xtensor.R xtensor-r xtensor Rcpp
master ^0.11.0 ^0.20.4 ^1.0
0.11.0 ^0.11.0 ^0.20.4 ^1.0
0.10.1 ^0.10.0 ^0.19.4 ^1.0
0.10.0 ^0.10.0 ^0.19.4 ^1.0
0.9.0 ^0.9.0 ^0.19.0 ^1.0
  • Core xtensor headers are vendored in the CRAN package.
  • When using the conda, or debian package managers, xtensor-r has a dependency on xtensor.

License

We use a shared copyright model that enables all contributors to maintain the copyright on their contributions.

This software is licensed under the BSD-3-Clause license. See the LICENSE file for details.

You can’t perform that action at this time.