Force rep_matrix to always return column-major matrices#3342
Conversation
5b68b33 to
eac52b1
Compare
Jenkins Console Log Machine informationNo LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focalCPU: G++: Clang: |
|
The main concern with this change is that it forces an evaluation of the result in all cases, when that's only needed for usage with the ternary operator. Could this be done in |
|
Alternatively the stan ternary operator could be transpiled to |
Stanc3 is already generating these evals (stan-dev/stanc3#977), the issue is that the expressions in the problematic model resolve to different types once eval’d, stemming from this function |
Ah gotcha, yeah in that case |
|
Select loses the short circuit evaluation of ?: right? |
Hmm yeah that is a big loss, never mind! |
Summary
Closes #3341. rep_matrix, when supplied with a row vector, could return a row-major matrix. This is assignable to a normal matrix, so it mostly was invisible, except in the case of it being in a ternary with a normal matrix; because the assignability goes both ways, the compiler doesn't know which one to select and errors.
Tests
Added a reduced version of the repex based on the code the compiler generated for #3341
Side Effects
None
Release notes
Fixed an issue with rep_matrix sometimes returning a row-major matrix.
Checklist
Copyright holder: Simons Foundation
The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
the basic tests are passing
./runTests.py test/unit)make test-headers)make test-math-dependencies)make doxygen)make cpplint)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested