-
-
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
Updates LLT to inplace decomposition per eigen 3.3 doc #549
Conversation
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.
More questions than requested changes!
@@ -233,8 +233,6 @@ namespace stan { | |||
* Internally calls llt rather than using cholesky_decompose in order to | |||
* use selfadjointView<Lower> optimization. |
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.
Is this doc broken now? You've removed the selfadjointView<Lower>
bit of the code.
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.
Fixed the doc. Thanks for the review.
@@ -246,10 +244,8 @@ namespace stan { | |||
check_symmetric("cholesky_decompose", "A", A); | |||
|
|||
Eigen::Matrix<double, -1, -1> L_A(value_of_rec(A)); | |||
Eigen::LLT<Eigen::MatrixXd> L_factor | |||
= L_A.selfadjointView<Eigen::Lower>().llt(); | |||
Eigen::LLT<Eigen::Ref<Eigen::MatrixXd> > L_factor(L_A); |
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.
Is there a reason we're no longer using a selfadjointView of L_A
? Have the input requirements changed now that we use all of it?
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.
Good question! I'm not sure if I can do a Ref to a triangular view of a matrix. I'll see if I can figure it out.
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 used the selfadjointViewEigen::Lower() to cut down on the copy when L_factor was instantiated, but I'm fairly certain that LLT defaults to a lower triangular view. In any case, the inplace decomposition obviates the need for any selfadjointView() instantiation here. I've added an explicit Eigen::Lower template argument, but that's the default for the class.
Submission Checklist
./runTests.py test/unit
make cpplint
Summary:
Inplace LLT saves memory and one copy. Addresses #359
Intended Effect:
Reduction in memory, reduction in copies.
How to Verify:
./runTests.py test/unit/math/rev/mat/fun/cholesky_decompose_test.cp
Side Effects:
None
Documentation:
None
Reviewer Suggestions:
@bob-carpenter
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):
Rob Trangucci
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: