-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
adds testing suite for nested binary var matrix functions #2502
adds testing suite for nested binary var matrix functions #2502
Conversation
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.14.6 BuildVersion: 18G8022CPU: G++: Clang: |
Great! I'll have a look on the weekend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review (finally)! The testing all looks very comprehensive, so no issues there. Just a couple of suggestions for simplifying the apply_scalar_binary
overloads
* Note: The return expresssion needs to be evaluated, otherwise the captured | ||
* function and scalar fall out of scope. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can also cut this comment since unaryExpr
doesn't get called for varmat
types
…-binary-funcs1-varmat
…add is_container_or_var_matrix
…4.1 (tags/RELEASE_600/final)
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
template <typename T1, typename T2, typename F, | ||
require_std_vector_vt<std::is_integral, T1>* = nullptr, | ||
require_var_matrix_t<T2>* = nullptr> | ||
inline auto apply_scalar_binary(const T1& x, const T2& y, const F& f) { | ||
check_matching_sizes("Binary function", "x", x, "y", y); | ||
return f(x, y); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template <typename T1, typename T2, typename F, | |
require_std_vector_vt<std::is_integral, T1>* = nullptr, | |
require_var_matrix_t<T2>* = nullptr> | |
inline auto apply_scalar_binary(const T1& x, const T2& y, const F& f) { | |
check_matching_sizes("Binary function", "x", x, "y", y); | |
return f(x, y); | |
} | |
template <typename T1, typename T2, typename F, | |
require_any_std_vector_vt<std::is_integral, T1, T2>* = nullptr, | |
require_any_var_matrix_t<T1, T2>* = nullptr> | |
inline auto apply_scalar_binary(const T1& x, const T2& y, const F& f) { | |
check_matching_sizes("Binary function", "x", x, "y", y); | |
return f(x, y); | |
} |
Then you don't need the separate overloads
…-binary-funcs1-varmat
…4.1 (tags/RELEASE_600/final)
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good!
Summary
So @andrjohns in #2461 you were totally correct that I wasn't handling nested array structures correctly for var matrix. This fixes that by
apply_scalar_binary()
for handlingvar_value<Matrix>
typesas_array_or_scalar()
that makes a 2d array fromstd::vector<std::vector<Scalar>>
typesWith the overload for
as_array_or_scalar()
this was actually pretty darn easy!Tests
@andrjohns can you check
expect_ad_vectorized_matvar
to make sure I'm catching all the specializations I need? I was a bit confused and wasn't totally sure if I caught them all. You can run the functions changed in the PR withSide Effects
Nope
Release notes
Adds nested vectorized functions for the new matrix type.
Checklist
Math issue How to add static matrix? #1805
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