What does Tuple{3} mean in StaticArrays?

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}, where Size = Tuple{S1, S2, ...} is a tuple of Ints. 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 and SMatrix are defined is to make it easier to define the types without the extra tuple characters (compare SVector{3} to SArray{Tuple{3}}).

The numbers are Value-Types.

1 Like