@@ -24,12 +24,12 @@ struct SizedArray{S <: Tuple, T, N, M} <: StaticArray{S, T, N}
24
24
end
25
25
end
26
26
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)
30
30
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)} ()
33
33
34
34
@generated function (:: Type{SizedArray{S,T,N,M}} )(x:: NTuple{L,Any} ) where {S,T,N,M,L}
35
35
if L != tuple_prod (S)
44
44
end
45
45
end
46
46
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)
50
50
51
51
# Overide some problematic default behaviour
52
52
@inline convert (:: Type{SA} , sa:: SizedArray ) where {SA<: SizedArray } = SA (sa. data)
53
53
@inline convert (:: Type{SA} , sa:: SA ) where {SA<: SizedArray } = sa
54
54
55
55
# 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
59
59
60
60
@inline convert (:: Type{Array} , sa:: SizedArray ) = sa. data
61
61
@inline convert (:: Type{Array{T}} , sa:: SizedArray{S,T} ) where {T,S} = sa. data
65
65
@propagate_inbounds setindex! (a:: SizedArray , v, i:: Int ) = setindex! (a. data, v, i)
66
66
67
67
SizedVector{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)
70
70
71
71
SizedMatrix{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)
74
74
75
75
if isdefined (Base, :dataids ) # v0.7-
76
76
Base. dataids (sa:: SizedArray ) = Base. dataids (sa. data)
0 commit comments