README.md

Xtensor.R

Travis Appveyor CRAN status Documentation Join the Gitter Chat

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

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

From conda-forge

Xtensor.R is available on conda-forge, it can be installed with conda, mamba, and rhumba.

mamba install r-xtensor -c conda-forge

From CRAN

Xtensor.R is available on CRAN (The Comprehensive R Archive Network).

install.packages("xtensor")

From the GitHub repository

Xtensor.R can be installed from GitHub directly using devtools

devtools::install_github("QuantStack/Xtensor.R", ref="package")

Documentation

To get started with using Xtensor.R, check out the documentation at

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

Dependencies

xtensor-r depends on the xtensor and Rcpp libraries

| Xtensor.R | xtensor-r | xtensor | Rcpp | |--------------|-------------|-----------|----------| | master | ^0.13.0 | ^0.23.0 | ^1.0 | | 0.13.2 | ^0.13.0 | ^0.23.0 | ^1.0 | | 0.13.1 | ^0.13.0 | ^0.23.0 | ^1.0 | | 0.13.0 | ^0.13.0 | ^0.23.0 | ^1.0 | | 0.12.1 | ^0.12.1 | ^0.21.4 | ^1.0 | | 0.12.0 | ^0.12.0 | ^0.21.2 | ^1.0 | | 0.11.1 | ^0.11.1 | ^0.20.8 | ^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 |

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.



Try the xtensor package in your browser

Any scripts or data that you put into this service are public.

xtensor documentation built on March 1, 2021, 5:06 p.m.