Skip to content

Error compiling rep_matrix inside of offset_multiplier_constrain #3146

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

Open
SteveBronder opened this issue Feb 13, 2025 · 0 comments · May be fixed by #3147
Open

Error compiling rep_matrix inside of offset_multiplier_constrain #3146

SteveBronder opened this issue Feb 13, 2025 · 0 comments · May be fixed by #3147

Comments

@SteveBronder
Copy link
Collaborator

Compiling the following Stan code gives an error about bad return deduction

parameters {
  vector<lower=0>[5] sigma_gamma_n;
  matrix<multiplier=rep_matrix(sigma_gamma_n', 10)>[10, 5] z_gamma_n;
}

The error log is below which traces down into multiply_log about an inconsistent deduction for the return type. I think just adding constexpr if in this statement would fix this. Though I'd look to look at why the return types are just slightly different. That looks like a bug in type deduction

stan/lib/stan_math/stan/math/rev/fun/multiply_log.hpp:214:29: error: inconsistent deduction for auto return type: ‘stan::math::var_value<Eigen::Matrix<double, -1, -1, 1, -1, -1>, void>’ and then ‘stan::math::var_value<Eigen::Matrix<double, -1, -1> >’
  214 |     return make_callback_var(
      |            ~~~~~~~~~~~~~~~~~^
  215 |         multiply_log(arena_a.val(), arena_b),
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  216 |         [arena_a, arena_b](const auto& res) mutable {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  217 |           arena_a.adj()
      |           ~~~~~~~~~~~~~      
  218 |               += (res.adj().array() * arena_b.val().array().log()).sum();

https://gist.github.com/SteveBronder/5ba8b98ce92e7d1965fcce5a9fc091a2

@SteveBronder SteveBronder changed the title Error compiling Error compiling rep_matrix inside of offset_multiplier_constrain Feb 13, 2025
@SteveBronder SteveBronder linked a pull request Feb 13, 2025 that will close this issue
4 tasks
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

Successfully merging a pull request may close this issue.

1 participant