R supports only a subset of types available in C++. The types which are natively
supported with xtensor-R are int (32 bit), double, complex, byte.
Using other types (such as a C++
float) in a
rtensor will fail to compile.
Below is a mapping from R to xtensor:
|R type||xtensor type|
|Integer Vector||rarray<int> or rarray<int32_t>|
|Raw Vector||rarray<Rbyte> or rarray<uint8_t>|
|Logical Vector||Not supported at the moment|
Note that, for illustration purposes,
rarray was used above. The
container works just as well.
R’s NA and NaN values¶
R encodes missing values (NAs) as special values of the underlying type.
Xtensor-r supports R’s missing values with the
rtensor_optional counterparts to
rtensor which enable
operations with missing values with the
R defining PI as macro¶
Ancient versions of
S used to define a
PI macro. This macro collides with
xtensor, as xtensor is using
PI as a variable name in the numeric constants.
If you’re encountering this issue, either reorder your headers so that the xmath header of xtensor is included before Rcpp / xtensor-r or use the following define before including xtensor-r and Rcpp:
This prevents the PI macro definition.