FillArrays.jl icon indicating copy to clipboard operation
FillArrays.jl copied to clipboard

More efficient methods for Eye, Fill, Diagonal, etc.

Open jlapeyre opened this issue 6 years ago • 6 comments

I have collected several such methods here: https://github.com/jlapeyre/IdentityMatrix.jl.

All the methods included show significantly reduced benchmark times. (I have not posted the times yet) Despite the name of the module there are methods for types other than Eye. For instance an efficient method for kron(::AbstractMatrix, ::Diagonal) is almost as fast as one specialized for Eye.

Most of this stuff could be made into PRs to FillArrays.jl and LinearAlgebra.

I don't want to go much further before checking if there are other plans underway.

Also, there is some redundancy of methods with UniformScaling, which might be fixed with some refactoring or traits or the like.

jlapeyre avatar Dec 01 '18 13:12 jlapeyre

Cool! A PR would certainly be welcomed.

dlfivefifty avatar Dec 01 '18 13:12 dlfivefifty

Great. A practical question. This could be bunch of small PRs, all to the same file. Should I make a branch for each feature from master, or a branch for feature B from the branch from feature A, or ... ?

jlapeyre avatar Dec 01 '18 15:12 jlapeyre

It shouldn't matter either way because I'll "squash and merge", so whatever is easiest for you.

dlfivefifty avatar Dec 01 '18 15:12 dlfivefifty

Ok, I'll give it shot.

jlapeyre avatar Dec 01 '18 15:12 jlapeyre

@jlapeyre, any updates on this?

ararslan avatar Jan 03 '19 22:01 ararslan

Yes. So, some of the work mentioned above I have done. Here are the relevant PRs that have been merged to FillArrays.

Some of the inefficiencies are better addressed elsewhere. This PR to LinearAlgebra has been merged: https://github.com/JuliaLang/julia/pull/30232. The corresponding PR for FillArrays has been merged. But, the improvement over julia#30232 (at least for what I tested) is very slight. One could argue its not worth the code complexity.

These PRs to LinearAlgebra still need some work: https://github.com/JuliaLang/julia/pull/30236, https://github.com/JuliaLang/julia/pull/30235

I also found that keeping track of which method is being called was a headache. So I wrote this: https://github.com/jlapeyre/MethodInSrc.jl. I'd like to apply it to other modules or base/stdlib to see if it turns up muddled tests.

There are other possible PRs that I did not yet make, for various reasons. At this point, mainly lack of time. I also made earlier, unrelated PRs that are languishing and need attention.

jlapeyre avatar Jan 04 '19 00:01 jlapeyre