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

Broadcasting rules for Diagonal AbstractFill

Open jishnub opened this issue 2 years ago • 2 comments

Define broadcasting rules so that structure-preserving operations involving a Diagonal AbstractFill do not allocate.

After this PR

julia> D = Diagonal(Fill(2,3))
3×3 Diagonal{Int64, Fill{Int64, 1, Tuple{Base.OneTo{Int64}}}}:
 2  ⋅  ⋅
 ⋅  2  ⋅
 ⋅  ⋅  2

julia> D .+ D
3×3 Diagonal{Int64, Fill{Int64, 1, Tuple{Base.OneTo{Int64}}}}:
 4  ⋅  ⋅
 ⋅  4  ⋅
 ⋅  ⋅  4

julia> D .* 2
3×3 Diagonal{Int64, Fill{Int64, 1, Tuple{Base.OneTo{Int64}}}}:
 4  ⋅  ⋅
 ⋅  4  ⋅
 ⋅  ⋅  4

julia> D .^ 2
3×3 Diagonal{Int64, Fill{Int64, 1, Tuple{Base.OneTo{Int64}}}}:
 4  ⋅  ⋅
 ⋅  4  ⋅
 ⋅  ⋅  4

jishnub avatar Oct 14 '21 20:10 jishnub

Codecov Report

Merging #165 (bb36731) into master (aeb0aef) will increase coverage by 0.06%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #165      +/-   ##
==========================================
+ Coverage   96.22%   96.29%   +0.06%     
==========================================
  Files           4        4              
  Lines         636      647      +11     
==========================================
+ Hits          612      623      +11     
  Misses         24       24              
Impacted Files Coverage Δ
src/FillArrays.jl 94.76% <100.00%> (ø)
src/fillbroadcast.jl 97.74% <100.00%> (+0.20%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update aeb0aef...bb36731. Read the comment docs.

codecov[bot] avatar Oct 14 '21 20:10 codecov[bot]

Please add tests for non-structure preserving like D .+ 1

dlfivefifty avatar Oct 23 '21 18:10 dlfivefifty

@jishnub do we want to finish this?

dlfivefifty avatar Mar 29 '23 19:03 dlfivefifty

Perhaps this needs a re-think. I'll see if this can be done in LinearAlgebra. Closing this for now. It's not breaking, so if needed, it can be opened again post 1.0

jishnub avatar Mar 30 '23 06:03 jishnub