Skip to content

use of c() on LHS gives C++ compilation error #215

Description

@paciorek

I have not dug into this (and I'll note that x[1:3] <- c(2,3,5) is fine).

nf <- nFunction(
    fun = function(x = 'numericVector') {
        x[c(2,3,5)] <- rep(1,3)
        return(x)
        returnType('numericVector')
    }
)
cnf <- nCompile(nf)

generated C++:

    Eigen::Tensor<double, 1>  nFun_17 ( Eigen::Tensor<double, 1> x )  {
RESET_EIGEN_ERRORS
IVEC_(0,nC(createTensor<double, 1>(2.0, 1), createTensor<double, 1>(3.0, 1), createTensor<double, 1>(5.0, 1)),x,true) = (repTimes(Eigen::Make_Length1_Tensor(1.0), 3.0)).eval();
return(x);
}

This might be the key compiler error output:

/system/linux/lib/R-24.04/4.6.0/x86_64/site-library/RcppEigen/include/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h:34:40: error: no type named ‘Dimensions’ in ‘class Eigen::TensorIndexByVecOp<0, Eigen::Tensor<double, 1>, Eigen::Tensor<double, 1>, true>’
   34 |   typedef typename Derived::Dimensions Dimensions;
      |                                        ^~~~~~~~~~
/system/linux/lib/R-24.04/4.6.0/x86_64/site-library/RcppEigen/include/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h:46:35: error: ‘IsAligned’ is not a member of ‘Eigen::TensorIndexByVecOp<0, Eigen::Tensor<double, 1>, Eigen::Tensor<double, 1>, true>’
   46 |     IsAligned          = Derived::IsAligned,
      |                                   ^~~~~~~~~
/system/linux/lib/R-24.04/4.6.0/x86_64/site-library/RcppEigen/include/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h:50:35: error: ‘Layout’ is not a member of ‘Eigen::TensorIndexByVecOp<0, Eigen::Tensor<double, 1>, Eigen::Tensor<double, 1>, true>’
   50 |     Layout             = Derived::Layout,
      |                                   ^~~~~~

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions