Skip to content

Commit f534efd

Browse files
authored
Merge pull request #99 from JuliaGeometry/sd/fix_conversion
fix conversion
2 parents fa636fc + d661964 commit f534efd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/fixed_arrays.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
function unit(::Type{T}, i::Integer) where {T<:StaticVector}
2+
function unit(::Type{T}, i::Integer) where {T <: StaticVector}
33
tup = ntuple(Val(length(T))) do j
44
return ifelse(i == j, 1, 0)
55
end
@@ -38,21 +38,21 @@ macro fixed_vector(name, parent)
3838

3939
function $(name){S,T1}(x::AbstractVector{T2}) where {S,T1,T2}
4040
@assert S <= length(x)
41-
return $(name){S,T1}(ntuple(i -> T1(x[i]), Val(S)))
41+
return $(name){S,T1}(ntuple(i -> convert(T1, x[i]), Val(S)))
4242
end
4343

4444
function $(name){S,T}(x) where {S,T}
45-
return $(name){S,T}(ntuple(i -> T(x), Val(S)))
45+
return $(name){S,T}(ntuple(i -> convert(T, x), Val(S)))
4646
end
4747

4848
$(name){S}(x::T) where {S,T} = $(name){S,T}(ntuple(i -> x, Val(S)))
4949
$(name){1,T}(x::T) where {T} = $(name){1,T}((x,))
5050
$(name)(x::NTuple{S}) where {S} = $(name){S}(x)
51-
function $(name)(x::T) where {S,T<:Tuple{Vararg{Any,S}}}
51+
function $(name)(x::T) where {S,T <: Tuple{Vararg{Any,S}}}
5252
return $(name){S,StaticArrays.promote_tuple_eltype(T)}(x)
5353
end
5454

55-
function $(name){S}(x::T) where {S,T<:Tuple}
55+
function $(name){S}(x::T) where {S,T <: Tuple}
5656
return $(name){S,StaticArrays.promote_tuple_eltype(T)}(x)
5757
end
5858
$(name){S,T}(x::StaticVector) where {S,T} = $(name){S,T}(Tuple(x))
@@ -71,7 +71,7 @@ macro fixed_vector(name, parent)
7171
end
7272
end
7373

74-
@generated function (::Type{SV})(x::StaticVector) where {SV<:$(name)}
74+
@generated function (::Type{SV})(x::StaticVector) where {SV <: $(name)}
7575
len = size_or(SV, size(x))[1]
7676
return if length(x) == len
7777
:(SV(Tuple(x)))
@@ -99,7 +99,7 @@ macro fixed_vector(name, parent)
9999
end
100100

101101
@generated function StaticArrays.similar_type(::Type{SV}, ::Type{T},
102-
s::Size{S}) where {SV<:$(name),T,S}
102+
s::Size{S}) where {SV <: $(name),T,S}
103103
return if length(S) === 1
104104
$(name){S[1],T}
105105
else
@@ -108,7 +108,7 @@ macro fixed_vector(name, parent)
108108
end
109109

110110
Base.:(*)(a::$name, b::$name) = a .* b
111-
function Base.broadcasted(f, a::AbstractArray{T}, b::$name) where {T<:$name}
111+
function Base.broadcasted(f, a::AbstractArray{T}, b::$name) where {T <: $name}
112112
return Base.broadcasted(f, a, (b,))
113113
end
114114
end
@@ -123,9 +123,9 @@ const Mat = SMatrix
123123
const VecTypes{N,T} = Union{StaticVector{N,T},NTuple{N,T}}
124124
const Vecf0{N} = Vec{N,Float32}
125125
const Pointf0{N} = Point{N,Float32}
126-
Base.isnan(p::Union{AbstractPoint, Vec}) = any(x -> isnan(x), p)
126+
Base.isnan(p::Union{AbstractPoint,Vec}) = any(x -> isnan(x), p)
127127

128-
#Create constes like Mat4f0, Point2, Point2f0
128+
# Create constes like Mat4f0, Point2, Point2f0
129129
for i in 1:4
130130
for T in [:Point, :Vec]
131131
name = Symbol("$T$i")

0 commit comments

Comments
 (0)