Hi all, I’ve just released StaticArrays Release 0.12.0. I’d like to reach version 1.0 soon so we’ve been doing some cleanup in the last few months and working on a few long standing problems.
One is the issue of conveniently and unambiguously constructing short static arrays from their components. Base is privileged to have the Vector and Matrix literal syntaxes like [1,2,3] and [1 2; 3 4], but it’s hard to have something quite as nice in a package. We have the macros like @SMatrix but there’s a lot of them, they’re verbose and annoyingly non-extensible.
In version 0.12.0 we now have the special “SArray constructor” type SA:
julia> v = SA[1,2,3]
3-element SArray{Tuple{3},Int64,1,3} with indices SOneTo(3):
1
2
3
julia> m = SA[1.0 2.0
3.0 4.0]
2×2 SArray{Tuple{2,2},Float64,2,4} with indices SOneTo(2)×SOneTo(2):
1.0 2.0
3.0 4.0
This lets you construct SVector and SMatrix with almost the same syntax as Base. If you want a particular element type, there’s also the type aliases SA_F64 and SA_F32 for Float64 and Float32 eltypes, and you can specify your own eltypes with SA{T}. For example:
SA[1, 2, 3] isa SVector{3,Int}
SA_F64[1, 2, 3] isa SVector{3,Float64}
SA_F32[1, 2, 3] isa SVector{3,Float32}
SA[1 2; 3 4] isa SMatrix{2,2,Int}
SA_F64[1 2; 3 4] isa SMatrix{2,2,Float64}
SA{UInt8}[1,2] isa SVector{2,UInt8}
This doesn’t entirely solve the problem of creating other types of static array but it’s possible to use conversion; for example MMatrix(SA[1 2; 3 4]).
There’s also a lot of other fixes in this release thanks to many people (thanks especially to @mateuszbaran for jumping in and cheerfully fixing various long standing issues!). Another notable change is the generalization of FieldVector to arbitrary dimensional FieldArrays thanks to @CFBaptista.