-
Notifications
You must be signed in to change notification settings - Fork 152
SA type aliases for constructors with precise eltype #656
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
Conversation
This gives a way to construct an `SVector` and `SMatrix` with a precise eltype, but without typing a verbose type name. I think this fixes #24 to the extent that it can be fixed. Also add some quickstart docs for `SA` and the new type aliases.
I do have mixed feelings about the way it "looks". Also contrast with Do any other community members have some opinions on this? |
The other interesting case is |
The But I think the existing alternative is better because it really emphasizes the julia> const SAf64 = SA_F64
SA{Float64}
julia> SA_F64[1,2,3]
3-element SArray{Tuple{3},Float64,1,3} with indices SOneTo(3):
1.0
2.0
3.0
julia> SAf64[1,2,3]
3-element SArray{Tuple{3},Float64,1,3} with indices SOneTo(3):
1.0
2.0
3.0
|
Does anyone have better ideas for naming or should we just merge this? I'd like to have something equivalent to it to go with Any further thoughts @andyferris; do you buy my argument or remain unconvinced? :-) |
Well, unless anyone's inclined to paint this bikeshed a different color, I think I'll merge this tomorrow or so. |
In the name of forward progress I went ahead and merged this; I think/hope these names are a good tradeoff! |
Hi all, Is a decrease in performance from using julia> using StaticArrays, BenchmarkTools
julia> f(x) = @SArray[1,2,x]
julia> g(x) = SA[1,2,x]
julia> @code_llvm f(3)
# short stuff
julia> @code_llvm g(3)
# long stuff
julia> @btime f(3)
0.023 ns (0 allocations: 0 bytes)
3-element SArray{Tuple{3},Int64,1,3} with indices SOneTo(3):
1
2
3
julia> @btime g(3)
249.480 ns (2 allocations: 64 bytes)
3-element SArray{Tuple{3},Int64,1,3} with indices SOneTo(3):
1
2
3
julia> versioninfo()
Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
JULIA_EDITOR = "/usr/share/code/code"
julia> import Pkg; Pkg.status("StaticArrays")
Status `~/.julia/environments/v1.2/Project.toml`
[90137ffa] StaticArrays v0.11.0 #master (https://github.com/JuliaArrays/StaticArrays.jl.git) |
Yikes no! Looks like I made a mistake of leaving in some spurious |
By the way @cdsousa, thank you very much for reporting this problem. These kind of performance problems are hard to detect without proper benchmarking, and proper benchmarking is hard without dedicated hardware... instead we rely heavily on |
@c42f, it is fixed indeed! And thank you very much for all the awesome work. |
Phew :-) You had me worried for a minute there (I did check this originally, but if I was mistaken it would nix the whole idea of having |
The discussion at #655 has stimulated what I feel is finally a reasonable solution to constructing small static arrays with precise eltype without too much typing:
I don't love the underscore there, but
SAF64
looks very confusing. Other than that, I think the naming here is consistent with the precedent set byBase.ComplexF64
.Better naming options welcome!
I believe this (along with #633) finally fixes #24 to the extent that we can have a solution to that.