-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
I can't tell if this is expected behavior of eye() or not. Is there a column major option for it?
I dont really see anything here about row/column major, so I honestly have no idea
https://github.com/QuantStack/xtensor/blob/master/include/xtensor/xbuilder.hpp#L305
// [[Rcpp::depends(xtensorrr)]]
// [[Rcpp::plugins(cpp14)]]
#include <xtensor-r/rarray.hpp>
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
SEXP rray_eye_cpp(const std::vector<std::size_t> shape, int k = 0) {
xt::rarray<int> res = xt::eye<int>(shape, k);
return res;
}Rcpp::sourceCpp("~/Desktop/test.cpp")
# looks good
rray_eye_cpp(c(2, 2))
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 0 1
rray_eye_cpp(c(2, 2, 2))
#> , , 1
#>
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 1 0
#>
#> , , 2
#>
#> [,1] [,2]
#> [1,] 0 1
#> [2,] 0 1
# I think I would have expected
array(c(1,0,0,1,1,0,0,1), c(2,2,2))
#> , , 1
#>
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 0 1
#>
#> , , 2
#>
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 0 1Created on 2019-01-09 by the reprex package (v0.2.1.9000)
Metadata
Metadata
Assignees
Labels
No labels