-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Improve tests and documentation for quad_form and quad_form_sym #1698
Conversation
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.
Lots of questions and some change requests.
Thanks for updating all this and all the doc!
* Compute the quadratic form B^T A B. | ||
* | ||
* @tparam Ta type of elements in the square matrix | ||
* @tparam Ra number of rows in the square matrix, can be Eigen::Dynamic |
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.
[question]
Can these be anything other than Eigen::Dynamic
?
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.
I thought so. In reality we can't compile if we hardcode sizes because of check_square
:
In file included from test/unit/math/prim/fun/quad_form_test.cpp:1:
In file included from ./stan/math/prim.hpp:10:
In file included from ./stan/math/prim/fun.hpp:238:
./stan/math/prim/fun/quad_form.hpp:31:3: error: no matching function for call to
'check_square'
check_square("quad_form", "A", A);
^~~~~~~~~~~~
test/unit/math/prim/fun/quad_form_test.cpp:22:31: note: in instantiation of
function template specialization 'stan::math::quad_form<5, 5, 5, 5, double>'
requested here
matrix_d res2 = stan::math::quad_form(A, A);
^
./stan/math/prim/err/check_square.hpp:21:13: note: candidate template ignored:
could not match -1 against 5
inline void check_square(
^
1 error generated.
I've addressed your comments as best as I could. In |
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.
Looks good. Thanks for trying the fixes. There must be issues with multiply
if that doesn't work, but we can take those on in a separate issue.
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Summary
This started out to be a simple clean up of the
quad_form
andquad_form_sym
tests, but it turned into a rabbit hole. There were a few issues around those functions:quad_form_sym
were broken because their input was not symmetric: I now symmetrize the input matrix so that tests execute as expected (this also required fixing some tolerances)b22
was not initialized, and variableb23
was not usedquad_form
: this is because there was no fwd version of that function, which I've now addedFixes #1695.
Tests
Added and fixed as mentioned above.
Side Effects
None.
Checklist
Math issue Sort out quad_form tests #1695
Copyright holder: Marco Colombo
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