foo <- nimbleFunction(
run = function(x = double(1), y = integer(1)) {
returnType(double(1))
return(x * (y + 1)) # This has double * (integer operation instead of logical operation)
})
cfoo <- compileNimble(foo)
foo <- nimbleFunction(
run = function(x = double(1)) {
returnType(double(1))
temp <- x > 0 # create a temporary to hold the x>0 result
return(x * temp)
})
cfoo <- compileNimble(foo)
So the problem seems to be a particular Eigen incantation that is code-generated from the first case and looks superficially valid. The code generated for the last case looks exactly like code from the first case with the exception of assigning to the temporary variable.
A user reported this problem:
Note that the following two cases work:
So the problem seems to be a particular Eigen incantation that is code-generated from the first case and looks superficially valid. The code generated for the last case looks exactly like code from the first case with the exception of assigning to the temporary variable.