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

Promotion with SArray * Number #69

Closed
KristofferC opened this issue Nov 9, 2016 · 7 comments
Closed

Promotion with SArray * Number #69

KristofferC opened this issue Nov 9, 2016 · 7 comments
Labels
up for grabs Implement me, I'm yours!

Comments

@KristofferC
Copy link
Contributor

KristofferC commented Nov 9, 2016

This behavior is different between SVectors and base arrays (different resulting element type):

julia> 3.0 * rand(SVector{3, Float32})
3-element StaticArrays.SVector{3,Float64}:
 1.7314  
 0.394485
 0.566248

julia> 3.0 * rand(Float32, 3)
3-element Array{Float32,1}:
 1.5532  
 0.506801
 1.7563  

It is a bit annoying because it will promote the array when you multiply with a literal. In base they use promote_array_type it seems.

@SimonDanisch
Copy link
Member

Good catch! This should most definitely be different! I think that's what has been called preserving the container type.

@andyferris
Copy link
Member

Sigh. I wish this stuff was more obvious and intuitive (not that I disagree with the motivation, but just having a simple broadcast is quite valuable).

@andyferris andyferris added the up for grabs Implement me, I'm yours! label Nov 10, 2016
@KristofferC
Copy link
Contributor Author

I think julia master just swapped to this behavior. Way to be ahead of the curve @andyferris :)

@SimonDanisch
Copy link
Member

Awww, what? That's the most classic way for me to introduce type instabilities. Where was this decided?

@KristofferC
Copy link
Contributor Author

JuliaLang/julia#19692

@andyferris
Copy link
Member

I find this behavior much more intuitive. Type stability is always an issue.

@andyferris
Copy link
Member

I'm going to close this. I don't intent to fix this for v0.5 if it matches v0.6 anyway.

oschulz pushed a commit to oschulz/StaticArrays.jl that referenced this issue Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
up for grabs Implement me, I'm yours!
Projects
None yet
Development

No branches or pull requests

3 participants