In StaticArrays example, there is this line:
similar_type(m3) == SArray{Tuple{3,3},Int64,2,9}
What is Tuple{3,3}
? I thought Tuple, as a parameterized concrete type constructor, can’t take values, only types.
The explanation from API · StaticArrays.jl is not very illuminating:
SArray
A container with arbitrarily many dimensions is defined as
struct SArray{Size,T,N,L} <: StaticArray{Size,T,N}
, whereSize = Tuple{S1, S2, ...}
is a tuple ofInt
s. You can easily construct one with the@SArray
macro, supporting all the features of@SVector
and@SMatrix
(but with arbitrary dimension).The main reason
SVector
andSMatrix
are defined is to make it easier to define the types without the extra tuple characters (compareSVector{3}
toSArray{Tuple{3}}
).