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

Elementwise operations .* and ./ are not broadcasting for all argument types #3171

Closed
5 tasks done
toivoh opened this issue May 21, 2013 · 2 comments
Closed
5 tasks done
Labels
sparse Sparse arrays

Comments

@toivoh
Copy link
Contributor

toivoh commented May 21, 2013

I've added broadcasting methods for .* and ./ in #3100 (for StridedArray arguments), but since there are other methods lying about that do not broadcast, they do not use broadcasting in all cases yet (and also since broadcasting does not yet work for any AbstractArray arguments yet). I've created this issue to track and discuss the cases that need to be taken care of.

Methods that don't broadcast:

  • range.jl: .* and ./ between two Ranges (applies when one of the ranges is length one)
  • array.jl: .* and ./ between one Ranges and one StridedArray
  • bitarray.jl: .* between BitArray and BitArray or Array{Bool} arguments
  • sparse.jl: .* between SparseMatrixCSC arguments (fixes #8416 (and duplicated issue #9664) #10106)
  • array.jl: ./ between StridedArray arguments of (possibly complex) integer element types.

Except for the last one, these all deal with non-StridedArray arguments, and are cases where a specialized implementation will probably beat a generic AbstractArray fallback. One option would be to teach the broadcast machinery how to do code those special cases with broadcasting once and for all. Or perhaps it might be better to handle them case by case.

The last case deals purely with StridedArray arguments; the issue here is with the result type. I'm thinking that we might want to introduce quotient_type(S, T) to compute the type of x::S / y::T. (The fallback could be quotient_type(S, T) = promote_type(S, T).) Then, it should be straightforward to write a broadcasting ./ that produces the right result type.

Thoughts?

@timholy
Copy link
Member

timholy commented Feb 21, 2014

As an update, someone (@toivoh?) fixed the fifth one some time ago. For the first two, these were in principle fixed with the Cartesian transition, as broadcast now works on arbitrary AbstractArrays. However, to make them actually work I needed to delete a little more code 😄. See 9e9ab5c.

carlobaldassi added a commit that referenced this issue Mar 3, 2014
carlobaldassi added a commit that referenced this issue Mar 9, 2014
@ViralBShah
Copy link
Member

It seems that all of these work now. I am closing this - but perhaps someone can find examples that still don't work.

@ViralBShah ViralBShah removed this from the 1.0 milestone Apr 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sparse Sparse arrays
Projects
None yet
Development

No branches or pull requests

3 participants