@@ -34,7 +34,7 @@ additional fields, make sure the array data appears first.
34
34
35
35
(see also `SVector`, `SMatrix`, `SArray`, `MVector`, `MMatrix`, `MArray` and `FieldVector`)
36
36
"""
37
- abstract StaticArray{T, N} <: DenseArray {T, N}
37
+ abstract StaticArray{T, N} <: AbstractArray {T, N}
38
38
39
39
typealias StaticVector{T} StaticArray{T, 1 }
40
40
typealias StaticMatrix{T} StaticArray{T, 2 }
@@ -47,21 +47,21 @@ typealias StaticMatrix{T} StaticArray{T, 2}
47
47
48
48
# Avoiding splatting penalties. Being here, implementations of StaticArray will not have to deal with these. TODO check these are necessary or not
49
49
# @inline (::Type{SA}){SA<:StaticArray}(x1) = SA((x1,)) # see convert below (lesser precedence than other constructors?)
50
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2) = SA ((x1,x2))
51
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3) = SA ((x1,x2,x3))
52
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3,x4) = SA ((x1,x2,x3,x4))
53
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3,x4,x5) = SA ((x1,x2,x3,x4,x5))
54
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3,x4,x5,x6) = SA ((x1,x2,x3,x4,x5,x6))
55
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3,x4,x5,x6,x7) = SA ((x1,x2,x3,x4,x5,x6,x7))
56
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3,x4,x5,x6,x7,x8) = SA ((x1,x2,x3,x4,x5,x6,x7,x8))
57
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3,x4,x5,x6,x7,x8,x9) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9))
58
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10))
59
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11))
60
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12))
61
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13))
62
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14))
63
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15))
64
- @inline ( :: Type {SA} ){SA <: StaticArray }(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16))
50
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2) = SA ((x1,x2))
51
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3) = SA ((x1,x2,x3))
52
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3,x4) = SA ((x1,x2,x3,x4))
53
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3,x4,x5) = SA ((x1,x2,x3,x4,x5))
54
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3,x4,x5,x6) = SA ((x1,x2,x3,x4,x5,x6))
55
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3,x4,x5,x6,x7) = SA ((x1,x2,x3,x4,x5,x6,x7))
56
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3,x4,x5,x6,x7,x8) = SA ((x1,x2,x3,x4,x5,x6,x7,x8))
57
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3,x4,x5,x6,x7,x8,x9) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9))
58
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10))
59
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11))
60
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12))
61
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13))
62
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14))
63
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15))
64
+ @inline convert {SA<:StaticArray} (:: Type{SA} , x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16) = SA ((x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16))
65
65
66
66
@inline convert {SA<:StaticArray} (:: Type{SA} , x1) = SA ((x1,))
67
67
@@ -122,33 +122,16 @@ function convert{T}(::Type{Vector}, sa::StaticVector{T})
122
122
return out
123
123
end
124
124
125
- # function convert{A<:AbstractArray}(::Type{A}, sa::StaticArray)
126
- # out = A(size(sa))
127
- # @inbounds for i = 1:length(sa)
128
- # out[i] = sa[i]
129
- # end
130
- # return out
131
- # end
132
-
133
-
134
125
# A general way of going back to a tuple, etc
135
126
@generated function convert (:: Type{Tuple} , a:: StaticArray )
136
127
n = length (a)
137
128
exprs = [:(a[$ j]) for j = 1 : n]
138
129
quote
139
130
$ (Expr (:meta , :inline ))
140
- $ (Expr (:tuple , exprs... ))
131
+ @inbounds return $ (Expr (:tuple , exprs... ))
141
132
end
142
133
end
143
134
144
- # We may want a pointer... usefull for LAPACK etc. However, some static arrays
145
- # might not store a dense representation of their matrix (they may be sparse or
146
- # some computed representation) so the fallback needs to be safe.
147
- # Custom-defined, dense, mutable StaticArrays might want to overload this default
148
- @inline function Base. unsafe_convert {T} (:: Type{Ptr{T}} , a:: StaticArray{T} )
149
- Base. unsafe_convert (Ptr{T}, Base. data_pointer_from_objref (Tuple (a)))
150
- end
151
-
152
135
@inline size (x:: StaticArray ) = size (typeof (x))
153
136
154
137
function size {SA <: StaticArray} (:: Type{SA} )
0 commit comments