-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
WIP: Refactors QR and Cholesky factorization codes #4621
Conversation
@@ -384,6 +409,7 @@ end | |||
(\)(A::QRPivoted, B::StridedMatrix) = (\)(A, B, sqrt(eps(typeof(real(B[1])))))[1] | |||
(\)(A::QRPivoted, B::StridedVector) = (\)(A, reshape(B, length(B), 1))[:] | |||
|
|||
<<<<<<< HEAD |
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 doesn't look like it should be here.
You are probably planning on it anyways, but we need to update the docs too. |
Is this going into 0.2? Seems like a big change post-rc! |
A bit big - but better to go in now rather than later. Also, the pivoted routines are not widely used, so hopefully the impact will be small. |
cc: @ViralBShah, @dmbates, @IainNZ – please review. |
It is a typo in the issue description. The pivoted versions of cholesky are deprecated. |
if nr == 0 return zeros(0, nrhs), 0 end | ||
ar = abs(A.hh[1]) | ||
if ar == 0 return zeros(nr, nrhs), 0 end | ||
if ar < eps(typeof(ar)) return zeros(nr, nrhs), 0 end |
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 think you are right here. If the matrix is scaled such that all the elements are small this criterion could make it look as a rank zero matrix. The old criterion is taken from the LAPACK source.
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 admit I didn't think through this one carefully. I see the issue with the new line, but returning zeros only if the householder reflector is exactly zero doesn't seem right either. I'll revert this for now, but this should be reviewed.
I think it would be better if this was a named parameter so that we would have to do |
(I don't think it makes sense for this to go into 0.2 at this stage. It's not a bug fix, and probably few people are using pivoted QR so it's not an essential feature, and we are still arguing over the interface.) |
Agreed |
Agree - this should be 0.3. |
@ViralBShah I agree that a named argument is more sensible. Are named arguments compatible with varargs? There are a bunch of methods like cholfact!(A::StridedMatrix, uplo::Symbol=:U, pivoted::Bool=false, args...) (and similarly for QR) that take a variable number of arguments but don't seem to do anything with them. Can we just get rid of these particular methods? Why were they there in the first place? |
- Deprecates qrp, qrpfact and qrpfact! - Adds trailing pivoted::Bool option to qr, qrfact and qrpfact! - Reorganizes QR factorizations section so that methods common to QR, QRPackedQ, QRPivoted, QRPivotedQ are grouped together. - Remove improperly cleaned up blob from merge - Replace methods defining default parameters with methods with default parameter values - Rename QRPivoted.jpvt to QRPivoted.pivots
Revert A.hh[1] < eps to A.hh[1] == 0 testing for (\)(QRPivoted)
bump. We should merge this once the linalg refactor is completed. |
@andreasnoackjensen Could you comment on @jiahao 's question above? It seems like we could get rid of the variable number of arguments. |
The varargs serve a purpose for most of the factorizations, e.g.
converts non-float matrices to float matrices wether or not |
@jiahao Do you think we can merge this now? I think this requires updates to the docs too, but otherwise seems largely ready. |
Let me review it given the recent linalg cleanup. |
I think we should get this merged before it becomes too stale! |
@jiahao I have some time today, and can take this up. Do you have any commits you haven't pushed? |
- Deprecates qrp, qrpfact and qrpfact! - Adds trailing pivoted::Bool option to qr, qrfact and qrpfact! - Reorganizes QR factorizations section so that methods common to QR, QRPackedQ, QRPivoted, QRPivotedQ are grouped together. - Remove improperly cleaned up blob from merge - Replace methods defining default parameters with methods with default parameter values - Rename QRPivoted.jpvt to QRPivoted.pivots
Revert A.hh[1] < eps to A.hh[1] == 0 testing for (\)(QRPivoted)
I took at a deep look at this today. I rebased this branch to master which took quite some effort, and the tests are not passing still. Considering the effort to make @jiahao @andreasnoackjensen What do you guys think? |
@ViralBShah can you push the rebased branch? Part of the overall issue, which I haven't been too clear on, is whether it is desirable for methods that return When working on this branch I also found it difficult to make changes to the factorization code, since it relies quite heavily on methods with varargs that break whenever I try to change them. I know for sure that I wasn't willing to merge this branch because of this fragility. Perhaps the entire factorization codebase could use cleaning up. However, I don't think I can do that alone. |
That was what I took away as well, that we need a general codebase cleanup here. I am willing to join that effort. |
… cjh/nopivot-default Conflicts: base/linalg/factorization.jl
For example, I added a wrapper to |
This merge is getting too screwy, and the tests are failing too. I am not sure if I should push what I have. I say, we brainstorm what we want this to look like, answering various API questions, and then just start from the latest master. |
Ok, I have pushed what I had, in any case, since this branch would otherwise be unusable anyways. Some stuff is failiing, which I have to track down. |
…iplication. Update tests.
I have fixed the last issues that made this pr fail the tests. There were only few problems. Some of them were related to promotion which is generally quite annoying and make you wish that conversions should be explicit. What is your end 2013 opinion on Regarding cleanup, I think that we should consider to split lapack.jl into more files. It is huge and the splitting would force us decide on a structure for the wrappers. Should it be by matrix or problem type? |
I feel that I feel that lapack.jl in general contains only wrappers, and having a large monolithic file is ok, but the rest of the stuff could use a better structure. I don't have well-formed opinion on how to refactor though. |
@andreasnoackjensen Thanks for fixing this PR. Nice to see it all green. |
@andreasnoackjensen Should we merge this for now, and then do a separate PR for the cleanup and making What is your view on making it a named argument? |
I think named arguments are better and will try to update this pull request soon. |
Subsumed by #5330. |
The primary goal of this refactor is to subsume the pivoted QR and Cholesky factorizations into the functions that previously only computed the ordinary (non-pivoted) factorizations
qrp
,qrpfact
,qrpfact
,cholpfact
,cholpfact!
pivoted::Bool
argument toqr
,qrfact
,qrpfact!
,cholfact
, andcholfact!
QR
,QRPackedQ
,QRPivoted
,QRPivotedQ
are grouped together.