[WIP] Adding complex scalars and arrays#2
Open
SteveBronder wants to merge 32 commits into
Open
Conversation
…ure/complex-types-proto
Call new deserializer backend for constrained reads
…-meta-info Cleanup some of the C++
… decls, fix error message and removed quiet_NaN for int
SteveBronder
pushed a commit
that referenced
this pull request
Apr 13, 2021
Switch to Fmt; move exit 0 to driver from lib module
Use Eigen Maps for data and transformed data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a proto of complex types in Stan! This PR just focuses on complex scalars/arrays and we can do complex vectors and matrices in a seperate PR. I built it on top of @rybern 's constraint PR since I need the
deserializerfor these to work.There's a couple issues in the generated Stan code I'll go over and one parser issue that's weird and I can't figure out.
For the mother_complex.stan test file there is one function that won't compile
Uncommenting that line gives back an error after parsing the AST of
Which seems really odd? In the signatures test it looks like it is generating the correct signature for
rep_array(complex, int)So I'm not sure where that
array[] intis coming from? It has to be somewhere in the AST/parser/lexer. I've tried looking bottom up starting at the semantic checks but I can't figure out where it thinks it's getting an array of integers from.For the generated code there's a couple small issues.
I think I need a version of
fill()for complex types so that it knows to fill up the real and imaginary part with the value we give.For code generated in data that get it's values from the context I think we need a
vals_cfor returning an std::vector. So in the belowvals_ris going to return anstd::vector<double>that can't be directly assigned.But if the context had a
vals_cit can return back anstd::vector<complex<double>and that should work for arrays as well.For things like
unconstrained_param_namesshould an complex type return one name asp_complexor two names forp_complex.real,p_complex.imag?@BobCarpenter should all of the functions in prim for scalars and arrays work with
complex? I know we don't want_lpdfetc. functions to accept complex types though I think I remember pretty much everything in prim should work with complex types. It might be good to write up a tech spec if you have the time@rokcesnovar did we ever figure out a name for accessing the real and imaginary parts of a complex type? I'm pro
reandimagor.re()and.imag(). Anything really. What if we just made them indexable so users could doThen under the hood we can just call
.real()for[1]and.imag()for[2]. Though idk if that could end up being confusing for users or not.Release notes
Adds complex scalars and arrays to the language
Copyright and Licensing
By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause): Steve Bronder