Skip to content
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

Merged
merged 2 commits into from
May 7, 2017

Conversation

rtrangucci
Copy link
Contributor

@rtrangucci rtrangucci commented May 4, 2017

Submission Checklist

  • Run unit tests: ./runTests.py test/unit
  • Run cpplint: make cpplint
  • Declare copyright holder and open-source license: see below

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:

Copy link
Contributor

@bob-carpenter bob-carpenter left a 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.
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@bob-carpenter bob-carpenter merged commit 8bbecaf into develop May 7, 2017
@syclik syclik deleted the feature/issue-359-inplace_cholesky branch October 26, 2017 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants