Skip to content
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

Implement broadcast styles #58

Open
iamed2 opened this issue Jan 4, 2019 · 5 comments · May be fixed by #385
Open

Implement broadcast styles #58

iamed2 opened this issue Jan 4, 2019 · 5 comments · May be fixed by #385

Comments

@iamed2
Copy link
Contributor

iamed2 commented Jan 4, 2019

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.

@dlfivefifty
Copy link
Member

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.

@iamed2
Copy link
Contributor Author

iamed2 commented Jan 4, 2019

Hmm, it's not though. For example, (x -> x + rand()).(Zeros(3)).

I will do a review of all existing BroadcastStyles and report back.

@dlfivefifty
Copy link
Member

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

@dlfivefifty
Copy link
Member

See also discussion #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

@iamed2
Copy link
Contributor Author

iamed2 commented Jan 5, 2019

Well never mind then! That makes things simple and I think your reasoning is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants