74
74
export unit
75
75
76
76
function Base. extrema (a:: AbstractVector{T} ) where T <: StaticVector
77
- reduce ((x, v)-> (min .(x[1 ], v), max .(x[2 ], v)), a)
77
+ ET = eltype (T)
78
+ reduce ((x, v)-> (min .(x[1 ], v), max .(x[2 ], v)), (T (typemax (ET)), T (typemin (ET))), a)
78
79
end
79
80
function Base. minimum (a:: AbstractVector{T} ) where T <: StaticVector
80
- reduce ((x, v)-> min .(x[1 ], v), a)
81
+ reduce ((x, v)-> min .(x[1 ], v), T ( typemax ( eltype (T))), a)
81
82
end
82
83
function Base. maximum (a:: AbstractVector{T} ) where T <: StaticVector
83
- reduce ((x, v)-> max .(x[1 ], v), a)
84
+ reduce ((x, v)-> max .(x[1 ], v), T ( typemin ( eltype (T))), a)
84
85
end
85
86
86
87
@@ -98,6 +99,15 @@ macro fixed_vector(name, parent)
98
99
new {S, T} (StaticArrays. convert_ntuple (T, x))
99
100
end
100
101
end
102
+ size_or (:: Type{$(name)} , or) = or
103
+ eltype_or (:: Type{$(name)} , or) = or
104
+ eltype_or (:: Type{$(name){S, T} where S} , or) where {T} = T
105
+ eltype_or (:: Type{$(name){S, T} where T} , or) where {S} = or
106
+ eltype_or (:: Type{$(name){S, T}} , or) where {S, T} = T
107
+
108
+ size_or (:: Type{$(name){S, T} where S} , or) where {T} = or
109
+ size_or (:: Type{$(name){S, T} where T} , or) where {S} = Size {(S,)} ()
110
+ size_or (:: Type{$(name){S, T}} , or) where {S, T} = (S,)
101
111
# Array constructor
102
112
@inline function (:: Type{$(name){S}} )(x:: AbstractVector{T} ) where {S, T}
103
113
@assert S <= length (x)
@@ -168,15 +178,7 @@ macro fixed_vector(name, parent)
168
178
StaticArrays. default_similar_type (T,s (),Val{length (S)})
169
179
end
170
180
end
171
- size_or (:: Type{$(name)} , or) = or
172
- eltype_or (:: Type{$(name)} , or) = or
173
- eltype_or (:: Type{$(name){S, T} where S} , or) where {T} = T
174
- eltype_or (:: Type{$(name){S, T} where T} , or) where {S} = or
175
- eltype_or (:: Type{$(name){S, T}} , or) where {S, T} = T
176
181
177
- size_or (:: Type{$(name){S, T} where S} , or) where {T} = or
178
- size_or (:: Type{$(name){S, T} where T} , or) where {S} = Size {(S,)} ()
179
- size_or (:: Type{$(name){S, T}} , or) where {S, T} = (S,)
180
182
end )
181
183
end
182
184
0 commit comments