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

[BUG] Inline matrix construction fails to promote with mixed types #1291

Closed
andrjohns opened this issue Mar 15, 2023 · 0 comments · Fixed by #1292
Closed

[BUG] Inline matrix construction fails to promote with mixed types #1291

andrjohns opened this issue Mar 15, 2023 · 0 comments · Fixed by #1292
Assignees
Labels
bug Something isn't working

Comments

@andrjohns
Copy link
Contributor

The following model fails to compile:

data {
  real y_mean;
}

parameters {
  real y;
}

transformed parameters {
  matrix[2, 2] M;
  M = [[1, 2], [3, y]];
}

model {
  y ~ normal(y_mean, 1);
}

With the error:

/Users/andrew/.cmdstan/cmdstan-2.31.0/stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/functors/AssignmentFunctors.h:24:104: error: assigning to 'double' from incompatible type 'const stan::math::var_value<double>'

Because the construction of M is transpiling to:

      stan::model::assign(M, stan::math::to_matrix(
        std::vector<Eigen::Matrix<double, 1, -1>>{
        (Eigen::Matrix<double,1,-1>(2) << 1, 2).finished(),
        (Eigen::Matrix<local_scalar_t__,1,-1>(2) << 3, y).finished()}),
        "assigning variable M");

Where the std::vector<Eigen::Matrix<double, 1, -1>> should more likely be std::vector<Eigen::Matrix<local_scalar_t__, 1, -1>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants