Skip to content

Commit 7a4bc2e

Browse files
committed
Address comments (rename, ref. SizedArray).
1 parent c8e2fa7 commit 7a4bc2e

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

src/StaticArrays.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,20 @@ const StaticVector{N, T} = StaticArray{Tuple{N}, T, 1}
7878
const StaticMatrix{N, M, T} = StaticArray{Tuple{N, M}, T, 2}
7979
const StaticVecOrMat{T} = Union{StaticVector{<:Any, T}, StaticMatrix{<:Any, <:Any, T}}
8080

81-
# Being a member of StaticallySizedMatrix, StaticallySizedVecOrMat, or StaticallySizedArray implies that Size(A)
82-
# returns a static Size instance. The converse may not be true.
83-
const StaticallySizedMatrix{T} = Union{
81+
# Being a member of StaticMatrixLike, StaticVecOrMatLike, or StaticArrayLike implies that Size(A)
82+
# returns a static Size instance (none of the dimensions are Dynamic). The converse may not be true.
83+
# These are akin to aliases like StridedArray and in similarly bad taste, but the current approach
84+
# in Base necessitates their existence.
85+
const StaticMatrixLike{T} = Union{
8486
StaticMatrix{<:Any, <:Any, T},
8587
Transpose{T, <:StaticVecOrMat{T}},
8688
Adjoint{T, <:StaticVecOrMat{T}},
8789
Symmetric{T, <:StaticMatrix{T}},
8890
Hermitian{T, <:StaticMatrix{T}},
8991
Diagonal{T, <:StaticVector{<:Any, T}}
9092
}
91-
const StaticallySizedVecOrMat{T} = Union{StaticVector{<:Any, T}, StaticallySizedMatrix{T}}
92-
const StaticallySizedArray{T} = Union{StaticallySizedVecOrMat{T}, StaticArray{<:Any, T}}
93+
const StaticVecOrMatLike{T} = Union{StaticVector{<:Any, T}, StaticMatrixLike{T}}
94+
const StaticArrayLike{T} = Union{StaticVecOrMatLike{T}, StaticArray{<:Any, T}}
9395

9496
const AbstractScalar{T} = AbstractArray{T, 0} # not exported, but useful none-the-less
9597
const StaticArrayNoEltype{S, N, T} = StaticArray{S, T, N}

src/abstractarray.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
length(a::SA) where {SA <: StaticallySizedArray} = length(SA)
2-
length(a::Type{SA}) where {SA <: StaticallySizedArray} = prod(Size(SA))
1+
length(a::SA) where {SA <: StaticArrayLike} = length(SA)
2+
length(a::Type{SA}) where {SA <: StaticArrayLike} = prod(Size(SA))
33

4-
@pure size(::Type{SA}) where {SA <: StaticallySizedArray} = get(Size(SA))
5-
@inline function size(t::Type{<:StaticallySizedArray}, d::Int)
4+
@pure size(::Type{SA}) where {SA <: StaticArrayLike} = get(Size(SA))
5+
@inline function size(t::Type{<:StaticArrayLike}, d::Int)
66
S = size(t)
77
d > length(S) ? 1 : S[d]
88
end
9-
@inline size(a::StaticallySizedArray) = size(typeof(a))
10-
@inline size(a::StaticallySizedArray, d::Int) = size(typeof(a), d)
9+
@inline size(a::StaticArrayLike) = size(typeof(a))
10+
@inline size(a::StaticArrayLike, d::Int) = size(typeof(a), d)
1111

1212
Base.axes(s::StaticArray) = _axes(Size(s))
1313
@pure function _axes(::Size{sizes}) where {sizes}

src/convert.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ end
2525
return SA(unroll_tuple(a, Length(SA)))
2626
end
2727

28-
length_val(a::T) where {T <: StaticallySizedArray} = length_val(Size(T))
29-
length_val(a::Type{T}) where {T<:StaticallySizedArray} = length_val(Size(T))
28+
length_val(a::T) where {T <: StaticArrayLike} = length_val(Size(T))
29+
length_val(a::Type{T}) where {T<:StaticArrayLike} = length_val(Size(T))
3030

3131
@generated function unroll_tuple(a::AbstractArray, ::Length{L}) where {L}
3232
exprs = [:(a[$j]) for j = 1:L]

src/linalg.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ end
8888
end
8989
end
9090

91-
@inline vcat(a::StaticallySizedVecOrMat) = a
92-
@inline vcat(a::StaticallySizedVecOrMat, b::StaticallySizedVecOrMat) = _vcat(Size(a), Size(b), a, b)
93-
@inline vcat(a::StaticallySizedVecOrMat, b::StaticallySizedVecOrMat, c::StaticallySizedVecOrMat...) = vcat(vcat(a,b), vcat(c...))
91+
@inline vcat(a::StaticVecOrMatLike) = a
92+
@inline vcat(a::StaticVecOrMatLike, b::StaticVecOrMatLike) = _vcat(Size(a), Size(b), a, b)
93+
@inline vcat(a::StaticVecOrMatLike, b::StaticVecOrMatLike, c::StaticVecOrMatLike...) = vcat(vcat(a,b), vcat(c...))
9494

95-
@generated function _vcat(::Size{Sa}, ::Size{Sb}, a::StaticallySizedVecOrMat, b::StaticallySizedVecOrMat) where {Sa, Sb}
95+
@generated function _vcat(::Size{Sa}, ::Size{Sb}, a::StaticVecOrMatLike, b::StaticVecOrMatLike) where {Sa, Sb}
9696
if Size(Sa)[2] != Size(Sb)[2]
9797
throw(DimensionMismatch("Tried to vcat arrays of size $Sa and $Sb"))
9898
end
@@ -116,11 +116,11 @@ end
116116
end
117117

118118
@inline hcat(a::StaticVector) = similar_type(a, Size(Size(a)[1],1))(a)
119-
@inline hcat(a::StaticallySizedMatrix) = a
120-
@inline hcat(a::StaticallySizedVecOrMat, b::StaticallySizedVecOrMat) = _hcat(Size(a), Size(b), a, b)
121-
@inline hcat(a::StaticallySizedVecOrMat, b::StaticallySizedVecOrMat, c::StaticallySizedVecOrMat...) = hcat(hcat(a,b), hcat(c...))
119+
@inline hcat(a::StaticMatrixLike) = a
120+
@inline hcat(a::StaticVecOrMatLike, b::StaticVecOrMatLike) = _hcat(Size(a), Size(b), a, b)
121+
@inline hcat(a::StaticVecOrMatLike, b::StaticVecOrMatLike, c::StaticVecOrMatLike...) = hcat(hcat(a,b), hcat(c...))
122122

123-
@generated function _hcat(::Size{Sa}, ::Size{Sb}, a::StaticallySizedVecOrMat, b::StaticallySizedVecOrMat) where {Sa, Sb}
123+
@generated function _hcat(::Size{Sa}, ::Size{Sb}, a::StaticVecOrMatLike, b::StaticVecOrMatLike) where {Sa, Sb}
124124
if Sa[1] != Sb[1]
125125
throw(DimensionMismatch("Tried to hcat arrays of size $Sa and $Sb"))
126126
end

src/util.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,5 @@ TrivialView(a::AbstractArray{T,N}) where {T,N} = TrivialView{typeof(a),T,N}(a)
9090
# certain algorithms where the number of elements of the output is a lot larger
9191
# than the input.
9292
# """
93-
@inline drop_sdims(a::StaticallySizedArray) = TrivialView(a)
93+
@inline drop_sdims(a::StaticArrayLike) = TrivialView(a)
9494
@inline drop_sdims(a) = a

0 commit comments

Comments
 (0)