-
-
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
added hcat/vcat/hvcat methods for UniformScaling #19305
Conversation
I like it, but of course, this leads to wanting |
@StefanKarpinski, you can get a zeros object just by |
PS. I would have used |
If UniformScaling were generalized to have a base value and a diagonal value, then we could make things like |
Great. I think this will be really useful. |
…n the docs of the former
Matrices full of constants just aren't that useful in linear algebra, so I doubt it is worth it. (This is similar to the discussion in #14963 about whether we should implement "sparse" matrices with a nonzero "default" value.) |
I dunno, I've written a lot of code concatenating |
Getting
on Linux, which seems unrelated. Is there a problem with Travis? |
General low-rank updates would be useful, but they vastly complicate the implementation; low-rank matrices are really their own data structure (e.g. for BFGS updates). Adding a constant everywhere is just a very special case of a rank-1 update, and in my opinion is not worth the trouble (every single sparse-matrix routine everywhere would have to be updated, and unexpectedly so — people writing "sparse" code would not expect this definition of "sparse"), and SuiteSparse would be a hassle. In any case, this seems like something to be discussed in its own issue. |
Restarting CI now that #19132 is closed. |
Yay, CI passes again. Okay to merge, since it seems that supporting this functionality is uncontroversial? |
should have run nanosoldier here, make sure this doesn't slow down other concatenation cases |
How could it? The new code is only called when you have a |
it's called on a union, and a similar change with sparse matrices caused a big regression several months ago |
I'm not sure if you two noticed 832ab88#commitcomment-19855129. |
Thanks @andreasnoack. Also, @tkelman, in this case it is defined for |
does look like this caused a stack overflow in ImageFiltering.jl's tests http://pkg.julialang.org/logs/ImageFiltering_0.6.log |
Ah, looks like we need an |
A similar example that overflows (via a dispatch loop) is |
* added hcat/vcat/hvcat methods for UniformScaling * NEWS for 19305 * unified speye and sparse(I) code, and added a note about the latter in the docs of the former
It is nice to be able to construct matrices with identity components using
I
, where the size of the identity is inferred from the other pieces of the matrix. e.g. with this PR you can now do:For sparse matrices, it concatenates a sparse identity efficiently. I also added a
sparse(I, m,n)
constructor since this seemed generally useful.This change is technically breaking because
hcat(I, I)
now throws an error (because it can't figure out the size of the resulting matrix), whereas before it returned a1×2 Array{UniformScaling{Int64},2}
. I doubt this will affect many people.