Dear list
I am trying to create a simple Rcpp function that creates a three-dimensional
array based on the values of a four-dimensional array. The arrays are declared
as NumericVectors with a dim attribute represent the number of levels of each
dimension. Here is a sample of the code:
NumericVector sumby4(NumericVector X) {
Dimension dim = X.attr("dim");
if(dim.size() != 4) return NULL;
NumericVector ret = NumericVector::create(dim[0],dim[1],dim[2]);
for(int i = 0; i < dim[0]; i++) {
for(int j = 0; j < dim[1]; j++) {
for(int k = 0; k < dim[2]; k++) {
ret(i,j,k) = NA_REAL;
…
When I attempt to compile the package in which this function resides, I get the
error message associated with the “ret(I,j,k) = NA_REAL” line:
No match for call to Rcpp::NumericVector Rcpp::Vector<14
Rcpp::PreserveStorage>})(int&, int&, int&)
I take from this message that the NumericVector ret cannot be indexed by three
values, even though it has been dimensioned as a 3D array. What am I doing
wrong here?
Barth
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel