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

Add full(F::Factorization) for various kinds of factorization #9290

Merged
merged 2 commits into from
Apr 13, 2015
Merged

Add full(F::Factorization) for various kinds of factorization #9290

merged 2 commits into from
Apr 13, 2015

Conversation

davidavdav
Copy link
Contributor

This PR generalizes full(::Cholesky) to various other factorizations: CholeskyPivoted, QR, QRCompactWY, QRPivoted, Eigen, Hessenberg, Schur, SVD, LDLt, and LU. The idea is that A = full(F::Factorization) is the opposite of F = factorize(A). I implemented the reconstruction for all factorizations, apart from bkfact---somehow the .ipiv encoding is too hard to understand for me, see http://www.nag.com/numeric/FL/nagdoc_fl22/pdf/F07/f07mdf.pdf , section 5.5.

The patch includes code, tests and a line of documention.

@@ -108,6 +108,7 @@ convert{T}(::Type{Factorization{T}}, C::CholeskyPivoted) = convert(CholeskyPivot

full{T,S}(C::Cholesky{T,S,:U}) = C[:U]'C[:U]
full{T,S}(C::Cholesky{T,S,:L}) = C[:L]*C[:L]'
full{T}(F::CholeskyPivoted{T}) = (ip=invperm(F[:p]); (F[:L] * F[:U])[ip,ip])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type parameter is not necessary here. The type parameters are only included in the definitions for the usual Cholesky in order to be able specify :U and :L.

@andreasnoack
Copy link
Member

Thanks for that. Please see the comments in the code.

Include changes suggested by Andreas Noack
@davidavdav
Copy link
Contributor Author

OK, adapted and squashed the PR. I am sorry that squashing outdates the diffs on github.

## Can we determine the source/result is Real? This is not stored in the type Eigen
full(F::Eigen) = F.vectors * Diagonal(F.values) / F.vectors

full(F::Hessenberg) = (fq = full(F[:Q]); fq * F[:H] * fq')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't construct the full Q here. It is expensive. Use something like q = full(F[:Q]); (q * F[:H]) * q'. The parentheses will avoid the bug I try to fix in #9170.

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 get the parentheses, but I don't really understand your remark about not reconstructing the full Q. Do you mean LAPACK.orghr! is too expensive? Should I try to not extract the first row/column of Q?

@ViralBShah ViralBShah added the linear algebra Linear algebra label Dec 13, 2014
@andreasnoack
Copy link
Member

@davidavdav I'm going through old issues and can see that this one fell under the radar. If you rebase then I'll merge.

@ViralBShah
Copy link
Member

I have this almost rebased.

@ViralBShah ViralBShah merged commit a253e70 into JuliaLang:master Apr 13, 2015
@davidavdav davidavdav deleted the factfull branch April 13, 2015 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants