nimble
nimble copied to clipboard
compilation error with `1:1` indexing
We can't compile this, which seems like a corner case but could come up if users are trying to write code for multiple cases (i.e., 1:k
where k
might be one or something else
code <- nimbleCode({
z <- a[1:1]
})
m = nimbleModel(code, inits = list(a = rnorm(2)))
cm <- compileNimble(m)
> printErrors()
P_6_code_MID_8_nfCode.cpp: In member function ‘virtual void z_L1_UID_31::simulate(const indexedNodeInfo&) const’:
P_6_code_MID_8_nfCode.cpp:18:51: error: no match for ‘operator-’ (operand types are ‘Eigen::CwiseNullaryOp<seqClass<Eigen::Matrix<double, -1, -1>, int, int, int, useBy>, Eigen::Matrix<double, -1, -1> >’ and ‘int’)
18 | (**model_z)[0] = (**model_a)[(nimSeqByD(1,1,1,0)) - 1];
| ~~~~~~~~~~~~~~~~~~~~ ^ ~
| | |
| | int
| Eigen::CwiseNullaryOp<seqClass<Eigen::Matrix<double, -1, -1>, int, int, int, useBy>, Eigen::Matrix<double, -1, -1> >
In file included from /accounts/gen/vis/paciorek/R/x86_64-pc-linux-gnu-library/4.1/nimble/include/Eigen/Core:91,
from /accounts/gen/vis/paciorek/R/x86_64-pc-linux-gnu-library/4.1/nimble/include/Eigen/Dense:1,
from /accounts/gen/vis/paciorek/R/x86_64-pc-linux-gnu-library/4.1/nimble/include/nimble/EigenTypedefs.h:24,
from P_6_code_MID_8_nfCode.cpp:6:
/accounts/gen/vis/paciorek/R/x86_64-pc-linux-gnu-library/4.1/nimble/include/Eigen/src/Core/../plugins/CommonCwiseBinaryOps.h:19:28: note: candidate: ‘template<class OtherDerived> const Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<typename Eigen::internal::traits<T>::Scalar, typename Eigen::internal::traits<OtherDerived>::Scalar>, const Derived, const OtherDerived> Eigen::MatrixBase<Derived>::operator-(const Eigen::MatrixBase<OtherDerived>&) const [with OtherDerived = OtherDerived; Derived = Eigen::CwiseNullaryOp<seqClass<Eigen::Matrix<double, -1, -1>, int, int, int, useBy>, Eigen::Matrix<double, -1, -1> >]’
19 | EIGEN_MAKE_CWISE_BINARY_OP(operator-,difference)
| ^~~~~~~~
/accounts/gen/vis/paciorek/R/x86_64-pc-linux-gnu-library/4.1/nimble/include/Eigen/src/Core/util/Macros.h:952:4: note: in definition of macro ‘EIGEN_MAKE_CWISE_BINARY_OP’
952 | (METHOD)(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
| ^~~~~~
<snip>