-
-
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: Linear Algebra bikeshedding #2212
Conversation
Relevant comments are in #2062.
- use lud and lud! methods for the decomposition - allocate umf_conf and umf_info and use them throughout - preserve the pointers to the symbolic and numeric factorizations in the UmfpackLU object. Also keep around the decremented index/pointer vectors.
…and qrpd. Update docs for qr.
Conflicts: base/deprecated.jl test/Makefile
Oh, never mind. It's in a pull request. Carry on. |
Here's a link to the previous |
What is the rationale for removing the matlab-compatible versions? (Alternatively: was this discussed further?) I'm quite happy with the solution found at the end of the thread linked by @nolta, i.e. the current situation. |
What I do not like about the current situation is that we have all these great names that matlab uses (lu, qr, etc.) but they actually force you into computing in inefficient ways. I am proposing that we have defaults that are good and do the right thing in julia - i.e. all the linear algebra routines return |
With this pull request, what you get is this, which is often all you really want to do with these factorizations:
But one can always get the factors and do other things:
|
So we're just going to have the same argument again? |
In general, we have recently, as a community, been taking decisions that favour sane behaviour over matlab compatibility. I think that this is a case where being matlab compatible actually hurts, especially since we do not have |
Having the Matlab-compatible versions and the *d and *d! versions is an awful lot of multiplicity here. Inflating the number of functions in the language by some non-negligible fraction is a lot of bending over backwards to maintain the Matlab-compatible and inferior interface. |
I guess inferior's in the eye of the beholder. I use |
What do you do with the result of |
Since |
Sample from a multivariate Gaussian distribution. |
I like the idea of having |
We can also overload a few more methods for |
Needing cholfactor might be a sign of this change not being ideal. Perhaps we should give this particular change some more time? Can Gaussian sampling be done easily with and/or more efficiently with the factorization object? |
For the record, what I use most often is |
There is already @carlobaldassi I think it would be a good idea to have a |
I support getting rid of the matlab compatibility. Factorization objects are a much more sane default. |
@nolta As @andreasnoackjensen pointed out, sampling from a multivariate normal can be done with julia> using Distributions
julia> mvn = MultivariateNormal([1.,2,3], diagm([4.,5,6]))
MultivariateNormal distribution
Mean:
[1.0, 2.0, 3.0]
Covchol: CholeskyDense{Float64}(3x3 Float64 Array:
2.0 0.0 0.0
0.0 2.23607 0.0
0.0 0.0 2.44949,'U')
Mean:
[1.0, 2.0, 3.0]
Variance:
3x3 Float64 Array:
4.0 0.0 0.0
0.0 5.0 0.0
0.0 0.0 6.0
julia> srand(12321)
julia> rand(mvn)
3-element Float64 Array:
2.34813
4.22277
1.4347
julia> srand(12321)
julia> rand(mvn, 3, 20)
3x20 Float64 Array:
2.34813 0.491271 3.73474 -1.58803 2.15756 6.94249 2.16482 -3.25563 … 1.34691 -1.97108 0.192781 2.69105 1.23021 3.86129 -1.64641 1.4843 -0.778525
4.22277 1.74714 4.80336 4.99726 2.07695 -0.790902 1.7337 -1.32994 6.00423 2.7134 4.6624 2.69176 1.08644 4.08717 3.14195 3.62224 -3.74896
1.4347 -0.0141233 -1.76968 3.15905 1.85379 2.03352 1.69304 0.195228 3.5728 2.00291 4.46716 4.52372 2.83042 3.09832 7.28602 3.83717 6.57325
|
@carlobaldassi I think that adding a logdet method for CholeskyDense (and the soon-to-be CholeskySparse) type is the way to go. It would also be worthwhile adding The approach in |
I'm not sure I understand. Are you objecting to "shipping" the current state of master or something else? |
What I am saying is that the current state of I would want to hear what others have to say. |
Just a note - I have cherry-picked all the commits by @dmbates. The blas stuff is in master, whereas the suitesparse stuff is now on the |
I suppose it's ok for |
What I am proposing is to leave the matlab style routines as they are for now as part of Base - so chol, cholp, lu, qr, qrp, etc. can stay as they are. The *d versions: chold, cholpd, lud, qrd, qrpd would move to say, a |
Doesn't that make it difficult to change lu, chol, etc. to return factorization objects in the future? |
Honestly, I think this is a terrible idea. If a change this drastic was going to happen, it should have been done days ago. We now have an API stability deadline in one day and there is no way a change this disruptive is going to happen without breaking things. If the factorization stuff wasn't ready, it shouldn't have been in master – we are already shipping it. Trying to pull this out of base now is making a massive, disruptive change with no deprecation path with a single day to get it right. Not a good idea. |
Is there really that much to fix in order to get I propose:
|
It seems to me that "getting this right" is not super crucial now that we've arrived at the realization that we're not going to get this right before 0.1; since we know we're going to break people's code with 0.2 when we change all of this the main goal is not to break their code with 0.1 also with no benefit. So for tomorrow, I would suggest we tread lightly with only minimally disruptive changes that are unambiguously a good thing. |
I also think it would too drastic to remove the factorizations. Just for the perspective in this, the discussion started from the annoyance of writing I think @mlubin's suggestions are reasonable. In particular @dmbates's idea of using However, I think we should reconsider if it is useful to restrict factorizations to be the same thing as the original matrix: the LinearOperator view. What is the gain? If this association is dropped you wouldn't be surprised by the behaviour of |
|
I agree that |
But then |
About
Then the entire set of requested factors would be known immediately upon extraction, and without extending the iterator protocol. Also, it is quite clear what is happening even if the type of factorization object being operated upon cannot be seen from the code, unlike Still, I'm unclear on the details of factorizations where you only want to compute some of the factors. This seems to presuppose some kind of lazy evaluation, which would require the factorization object to keep a copy of the source matrix inside, unless the set of needed factors is given in advance. The most efficient algorithm to compute a given subset of factors would probably also need to know this set in advance, not incrementally. On the other hand, a factorization object with some factors unavailable will be crippled, e.g. cannot implement To compute a subset of factors, maybe it would be better not to (visibly) construct a factorization object, but to use something like
(and you could perhaps specify either
|
@toivoh This is not lazy evaluation. The idea is that you use the LAPACK routines for factorization, which often compute a compact form. If you want the actual matrices that represent the factors, you may have to do some more work, when forming the actual matrices. However, if you only want to use the factorization to say, solve a system, then you may not need the actual matrices. |
Given the need for minimally invasive changes, I am still pushing for renaming the *d routines to *fact routines. It is absolutely impossible to figure out what the |
Sounds reasonable to me. |
I am also not sure whether for 0.1, we should retain the current behaviour of |
If it's too much intermediate churn to remove that behavior given that we haven't decided how to expose the functionality, I would at least not present it as a good thing to do in the documentation. |
Minimal invasive changes to the Factorization objects for 0.1. All existing functionality is retained, with only a few renamings for clarity. Replaces the *d routines with *fact routines: lud ->lufact chold -> cholfact cholpd-> cholpfact qrd ->qrfact qrpd -> qrpfact Replaces * and Ac_mul_B on QRDense objects: qmulQR performs Q*A qTmulQR performs Q'*A Updates to exports, documentation, tests, and deprecations. This is a self-contained commit that can be reverted if necessary close #2062
I am closing this pull request, and we can resume this discussion after 0.1. I am actually fine with the current state, if we can retain the commit above. If everyone hates it, it can be reverted - but it does not change any functionality and only renames a few things for clarity and consistency. I am pushing it in since 0.1 will most likely be tagged when I am not awake. |
@timholy The horrible behaviour is already there for matrices. Inherited from Matlab: julia> A=randn(5,2);b=randn(5);
julia> b-A*(A\b)
5-element Float64 Array:
-0.418845
1.15814
-0.986439
0.719669
0.531056 Horrible, but convenient. |
Fair enough, but that's only because |
May I propose we disconnect two issues
|
Does anyone use |
Now that we have an svd factorization type I think |
Basically includes:
[edit: The suitesparse stuff is now cherry-picked on the
db/suitesparse
branch/]