FillArrays.jl
FillArrays.jl copied to clipboard
Implement broadcast styles
There's been talk of a FillStyle before, and RectDiagonal could implement Base's StructuredMatrixStyle.
I've been working on broadcast styles for Nabla.jl so I might take a crack at them for this package in my spare time.
That would be great. It would be good to codify why FillStyle is the right solution while Base has no RangeStyle for AbstractRange. I guess the answer may be as simple that a broadcasted AbstractFill is always an AbstractFill.
Hmm, it's not though. For example, (x -> x + rand()).(Zeros(3)).
I will do a review of all existing BroadcastStyles and report back.
Following SparseMatrixCSC broadcasting, yes it is:
julia> (x -> x + rand()).(spzeros(3,3))
3×3 SparseMatrixCSC{Float64,Int64} with 9 stored entries:
[1, 1] = 0.32463
[2, 1] = 0.32463
[3, 1] = 0.32463
[1, 2] = 0.32463
[2, 2] = 0.32463
[3, 2] = 0.32463
[1, 3] = 0.32463
[2, 3] = 0.32463
[3, 3] = 0.32463
See also discussion https://github.com/JuliaArrays/FillArrays.jl/issues/29 where the current behaviour was decided on:
julia> (x -> x + rand()).(Zeros(5))
5-element Fill{Float64,1,Tuple{Base.OneTo{Int64}}}:
0.4797461797606011
0.4797461797606011
0.4797461797606011
0.4797461797606011
0.4797461797606011
Well never mind then! That makes things simple and I think your reasoning is correct.