-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Basic slicing and dimension queries operators support var<Matrix> types #2507
Conversation
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
stan/math/rev/core/vari.hpp
Outdated
vari_view(S&& val, K&& adj) noexcept | ||
: val_(std::forward<S>(val)), adj_(std::forward<K>(adj)) {} |
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.
This does not seem to be in line with other changes in this PR. What is the reason for this change? I dont think we ever have views that would need forwarding.
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.
Whups, yeah this should not be changed. Was debugging something and thought this was a point of error but it's fine as it was
var_value<Eigen::VectorXd> vec_v(vec); | ||
EXPECT_MATRIX_FLOAT_EQ(stan::math::segment(vec_v, 2, 2).val(), | ||
stan::math::segment(vec, 2, 2)); | ||
} |
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.
[optional] To be consistent with the rest of math the tests for these functions should be each in a file named after the function it is testing / matching the hpp that defines the function. Otherwise they are hard to find.
Also I did not see any tests for check* function you changed. Given how minimal these changes are I would not require the tests, but they would be nice to have.
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'm fine with breaking them up into multiple functions, it's mostly that they are all very small and have nearly the same pattern so I thought it might be better just to put them in one file. Mostly so then when the jenkins is putting all the tests together into jumbo units it doesn't see 10 different files and just sees 1
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.
Actually would you mind if I left these? We do something similar in vari_test
as well and I think it's nicer for Jenkins if we keep them together
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 don't like the small files either, but breaking the pattern makes it harder to find things. If you insist I am fine with leaving this as one file.
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Summary
As title says, this adds slicing and dimension queries like
rows()
andcols()
forvar_value<Eigen>
typesTests
Tests can be run with
I put most of them in
dimensions_test
because they are all quite small and similarSide Effects
Are there any side effects that we should be aware of?
Release notes
Adds support for basic slicing and dimension queries operators support var types
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