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

Broadcast on nested Arrays gives suboptimal type information #11119

Closed
Keno opened this issue May 3, 2015 · 2 comments
Closed

Broadcast on nested Arrays gives suboptimal type information #11119

Keno opened this issue May 3, 2015 · 2 comments

Comments

@Keno
Copy link
Member

Keno commented May 3, 2015

a = Array(Array{Float64,1},2)
a[1] = [1.;2.;3.]
a[2] = [3.;4.;5.]
broadcast(*,[2.;3.],a)

gives

2-element Array{Any,1}:
 [2.0,4.0,6.0]
 [9.0,12.0,15.0]

I would have expected an Array{Array{Float64,1},1}.

@simonster simonster changed the title Broadcast on nested Arrays gives subobtimal type information Broadcast on nested Arrays gives suboptimal type information May 5, 2015
@simonster
Copy link
Member

Right now the return type is determined using promote_eltype or by a set of ad-hoc functions in broadcast.jl. To get this right generally, it seems like we need to either (ab)use type inference or use a trick similar to map.

@stevengj
Copy link
Member

stevengj commented May 5, 2016

map(*, [2.,3.], a) gives an Array{Array{Float64,1},1}, so this is another instance that would apparently be fixed by adapting map's algorithm to broadcast (#16164). Duplicate of #4883.

@stevengj stevengj closed this as completed May 5, 2016
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

No branches or pull requests

3 participants