Add tuple overload and cleanup code for promote_scalar #2706
Conversation
…plate argument being a tuple of scalars to promote each element to
…th into feature/promote_scalar_tuple
|
Just to check, does this do the right thing if it is called with a std::vector of tuples? E.g, given a Work like it does when the vector contains non-tuples (element wise?) |
|
No it did not, good catch! But I just put in an update that fixes that with a test for it as well |
|
I mentioned this in the a tuple The kind of recursive logic needed to get all that right usually generalizes to even deeper nesting |
|
I'll double check but looking at the test I believe I cover all of those |
|
@SteveBronder is this ready for review? I have been tagged for this a few weeks ago - just want to make sure. |
rok-cesnovar
left a comment
There was a problem hiding this comment.
This looks good to me. I went ahead and merge recent develop in as the branch was pretty old at this point. Merge away assuming the tests now pass.
Summary
This adds an overload to
promote_scalarfor the compiler that allows the input to be a set of tuples and the promotion type to be a tuple of scalar types. So for the compiler impl of tuples we will be able to generate code such asThis also cleanups the code for
promote_scalara little bit. Instead of having to do some roundabouts using a static struct method for doing actually the promotions we called frompromote_scalarwe just have explicit free functions for the particular cases we need that can be called from one another.Tests
Tests are added for testing promotions of tuples with various inner types and scalar types. A test is also added for the new type trait
is_tuple<>which just detects if a template is a tuple or not.Side Effects
Nope
Release notes
Add tuple overload and cleanup code for promote_scalar
Checklist
Math issue #
Copyright holder: Steve Bronder
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