library(cpp11)
x <- matrix(runif(4), nrow = 2)
cpp_function("int get_nrow(cpp11::doubles_matrix x) {
int res = x.nrow();
return(res);
}")
get_nrow(x)
#> [1] 2076180480
cpp_function("int get_ncol(cpp11::doubles_matrix x) {
int res = x.ncol();
return(res);
}")
get_ncol(x)
#> [1] 0
Created on 2020-06-16 by the reprex package (v0.3.0)
Created on 2020-06-16 by the reprex package (v0.3.0)