Closed paciorek closed 3 months ago
We can also get compilation errors in related cases where the LHS is an array (seems fine if it is a matrix):
nf <- nimbleFunction(
run=function(b0 = double()) {
x <- array(0,c(3,2,4))
x[1:3,1:2,1:4] <- b0
returnType(double(3))
return(x)
})
cnf <- compileNimble(nf)
using C++ compiler: ‘g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
P_55_rcFun_R_GlobalEnv24.cpp: In function ‘NimArr<3, double> rcFun_R_GlobalEnv24(double)’:
P_55_rcFun_R_GlobalEnv24.cpp:20:13: error: no match for ‘operator=’ (operand types are ‘NimArr<3, double>’ and ‘double’)
20 | Interm_44 = ARG1_b0_;
| ^~~~~~~~
In file included from /accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-22.04/4.3/nimble/include/nimble/RcppNimbleUtils.h:25,
from /accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-22.04/4.3/nimble/include/nimble/NamedObjects.h:28,
from /accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-22.04/4.3/nimble/include/nimble/EigenTypedefs.h:26,
from P_55_rcFun_R_GlobalEnv24.cpp:8:
/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-22.04/4.3/nimble/include/nimble/NimArr.h:625:17: note: candidate: ‘NimArr<3, T>& NimArr<3, T>::operator=(const NimArr<3, T>&) [with T = double]’
625 | NimArr<3, T> &operator=(const NimArr<3, T> &other) {
| ^~~~~~~~
/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-22.04/4.3/nimble/include/nimble/NimArr.h:625:47: note: no known conversion for argument 1 from ‘double’ to ‘const NimArr<3, double>&’
625 | NimArr<3, T> &operator=(const NimArr<3, T> &other) {
| ~~~~~~~~~~~~~~~~~~~~^~~~~
We don't assign scalar into array.
These should all give compile-time or run-time errors, so the one that seems wrong is the one with
p[1:3,1:2,i] <- B.0[i] + B.1[i] *project[1:3]
which does not appear to generate an error.
Issue 1: this fails if
project
is a vector (but is fine if it is a 3x2 matrix)Issue #2: if the
lag
part of the summation is left out we get a run-time size error:On the other hand, both of these subsets of the summation are fine:
So there seems to be some interaction between arrays, recycling, and what is being added together that fails in some situations but not all.