Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ problem with casting in special case of non-scalar component-wise operators involving logical operation #1388

Open
perrydv opened this issue Jan 9, 2024 · 0 comments
Assignees

Comments

@perrydv
Copy link
Contributor

perrydv commented Jan 9, 2024

A user reported this problem:

foo <- nimbleFunction(
  run = function(x = double(1)) {
    returnType(double(1))
    return(x * ( x > 0 ))
  })
cfoo <- compileNimble(foo) # Fails

Note that the following two cases work:

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.

@perrydv perrydv self-assigned this Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant