@@ -24,12 +24,12 @@ struct SizedArray{S <: Tuple, T, N, M} <: StaticArray{S, T, N}
2424 end
2525end
2626
27- @inline ( :: Type{ SizedArray{S,T,N}} ) (a:: Array{T,M} ) where {S,T,N,M} = SizedArray {S,T,N,M} (a)
28- @inline ( :: Type{ SizedArray{S,T}} ) (a:: Array{T,M} ) where {S,T,M} = SizedArray {S,T,tuple_length(S),M} (a)
29- @inline ( :: Type{ SizedArray{S}} ) (a:: Array{T,M} ) where {S,T,M} = SizedArray {S,T,tuple_length(S),M} (a)
27+ @inline SizedArray {S,T,N} (a:: Array{T,M} ) where {S,T,N,M} = SizedArray {S,T,N,M} (a)
28+ @inline SizedArray {S,T} (a:: Array{T,M} ) where {S,T,M} = SizedArray {S,T,tuple_length(S),M} (a)
29+ @inline SizedArray {S} (a:: Array{T,M} ) where {S,T,M} = SizedArray {S,T,tuple_length(S),M} (a)
3030
31- @inline ( :: Type{ SizedArray{S,T,N}} ) () where {S,T,N} = SizedArray {S,T,N,N} ()
32- @inline ( :: Type{ SizedArray{S,T}} ) () where {S,T} = SizedArray {S,T,tuple_length(S),tuple_length(S)} ()
31+ @inline SizedArray {S,T,N} () where {S,T,N} = SizedArray {S,T,N,N} ()
32+ @inline SizedArray {S,T} () where {S,T} = SizedArray {S,T,tuple_length(S),tuple_length(S)} ()
3333
3434@generated function (:: Type{SizedArray{S,T,N,M}} )(x:: NTuple{L,Any} ) where {S,T,N,M,L}
3535 if L != tuple_prod (S)
4444 end
4545end
4646
47- @inline ( :: Type{ SizedArray{S,T,N}} ) (x:: Tuple ) where {S,T,N} = SizedArray {S,T,N,N} (x)
48- @inline ( :: Type{ SizedArray{S,T}} ) (x:: Tuple ) where {S,T} = SizedArray {S,T,tuple_length(S),tuple_length(S)} (x)
49- @inline ( :: Type{ SizedArray{S}} ) (x:: NTuple{L,T} ) where {S,T,L} = SizedArray {S,T,tuple_length(S),tuple_length(S)} (x)
47+ @inline SizedArray {S,T,N} (x:: Tuple ) where {S,T,N} = SizedArray {S,T,N,N} (x)
48+ @inline SizedArray {S,T} (x:: Tuple ) where {S,T} = SizedArray {S,T,tuple_length(S),tuple_length(S)} (x)
49+ @inline SizedArray {S} (x:: NTuple{L,T} ) where {S,T,L} = SizedArray {S,T,tuple_length(S),tuple_length(S)} (x)
5050
5151# Overide some problematic default behaviour
5252@inline convert (:: Type{SA} , sa:: SizedArray ) where {SA<: SizedArray } = SA (sa. data)
5353@inline convert (:: Type{SA} , sa:: SA ) where {SA<: SizedArray } = sa
5454
5555# Back to Array (unfortunately need both convert and construct to overide other methods)
56- @inline ( :: Type{ Array} ) (sa:: SizedArray ) = sa. data
57- @inline ( :: Type{ Array{T}} ) (sa:: SizedArray{S,T} ) where {T,S} = sa. data
58- @inline ( :: Type{ Array{T,N}} ) (sa:: SizedArray{S,T,N} ) where {T,S,N} = sa. data
56+ @inline Array (sa:: SizedArray ) = sa. data
57+ @inline Array {T} (sa:: SizedArray{S,T} ) where {T,S} = sa. data
58+ @inline Array {T,N} (sa:: SizedArray{S,T,N} ) where {T,S,N} = sa. data
5959
6060@inline convert (:: Type{Array} , sa:: SizedArray ) = sa. data
6161@inline convert (:: Type{Array{T}} , sa:: SizedArray{S,T} ) where {T,S} = sa. data
6565@propagate_inbounds setindex! (a:: SizedArray , v, i:: Int ) = setindex! (a. data, v, i)
6666
6767SizedVector{S,T,M} = SizedArray{Tuple{S},T,1 ,M}
68- @inline ( :: Type{ SizedVector{S}} ) (a:: Array{T,M} ) where {S,T,M} = SizedArray {Tuple{S},T,1,M} (a)
69- @inline ( :: Type{ SizedVector{S}} ) (x:: NTuple{L,T} ) where {S,T,L} = SizedArray {Tuple{S},T,1,1} (x)
68+ @inline SizedVector {S} (a:: Array{T,M} ) where {S,T,M} = SizedArray {Tuple{S},T,1,M} (a)
69+ @inline SizedVector {S} (x:: NTuple{L,T} ) where {S,T,L} = SizedArray {Tuple{S},T,1,1} (x)
7070
7171SizedMatrix{S1,S2,T,M} = SizedArray{Tuple{S1,S2},T,2 ,M}
72- @inline ( :: Type{ SizedMatrix{S1,S2}} ) (a:: Array{T,M} ) where {S1,S2,T,M} = SizedArray {Tuple{S1,S2},T,2,M} (a)
73- @inline ( :: Type{ SizedMatrix{S1,S2}} ) (x:: NTuple{L,T} ) where {S1,S2,T,L} = SizedArray {Tuple{S1,S2},T,2,2} (x)
72+ @inline SizedMatrix {S1,S2} (a:: Array{T,M} ) where {S1,S2,T,M} = SizedArray {Tuple{S1,S2},T,2,M} (a)
73+ @inline SizedMatrix {S1,S2} (x:: NTuple{L,T} ) where {S1,S2,T,L} = SizedArray {Tuple{S1,S2},T,2,2} (x)
7474
7575if isdefined (Base, :dataids ) # v0.7-
7676 Base. dataids (sa:: SizedArray ) = Base. dataids (sa. data)
0 commit comments