Stan development repository. The master branch contains the current release. The develop branch contains the latest stable development. See the Developer Process Wiki for details.
[x] Declare copyright holder and open-source license: see below
Summary
This exposes the method added in https://github.com/stan-dev/stanc3/pull/1305 as a direct inverse function for write_array. unconstrain_array takes in a vector of parameters on the constrained scale _in the same order that write_array produced them_ and produces a vector of parameters on the unconstrained scale in the same order that write_array and log_prob expect.
This allows us to write what we want to write in almost all cases where we are using array_var_context followed by transform_inits at the moment (standalone generated quantities, the log_prob service function, etc). This is very useful for new features like tuples, ragged arrays, etc, since it weakens the reliance on the model.get_dims() function which fundamentally assumes that parameters are rectangular.
Intended Effect
Exposes unconstrain_array to the model base class. This function is already generated by the compiler.
How to Verify
Tests are added for the function directly and the standalone generated quantities service has been updated to use this new code.
Side Effects
None
Documentation
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):
Simons Foundation
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:
Submission Checklist
./runTests.py src/test/unit
make cpplint
Summary
This exposes the method added in https://github.com/stan-dev/stanc3/pull/1305 as a direct inverse function for
write_array
.unconstrain_array
takes in a vector of parameters on the constrained scale _in the same order thatwrite_array
produced them_ and produces a vector of parameters on the unconstrained scale in the same order thatwrite_array
andlog_prob
expect.This allows us to write what we want to write in almost all cases where we are using
array_var_context
followed bytransform_inits
at the moment (standalone generated quantities, thelog_prob
service function, etc). This is very useful for new features like tuples, ragged arrays, etc, since it weakens the reliance on themodel.get_dims()
function which fundamentally assumes that parameters are rectangular.Intended Effect
Exposes
unconstrain_array
to the model base class. This function is already generated by the compiler.How to Verify
Tests are added for the function directly and the standalone generated quantities service has been updated to use this new code.
Side Effects
None
Documentation
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Simons Foundation
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: