We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
reshape
1 parent 22a05ef commit e30448bCopy full SHA for e30448b
Project.toml
@@ -1,6 +1,6 @@
1
name = "StaticArrays"
2
uuid = "90137ffa-7385-5640-81b9-e52037218182"
3
-version = "1.2.9"
+version = "1.2.10"
4
5
[deps]
6
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
src/abstractarray.jl
@@ -186,6 +186,7 @@ homogenize_shape(shape::Tuple{Vararg{HeterogeneousShape}}) = map(last, shape)
186
@inline reshape(a::SArray, s::Size) = similar_type(a, s)(Tuple(a))
187
@inline reshape(a::AbstractArray, s::Size) = __reshape(a, ((typeof(s).parameters...)...,), s)
188
@inline reshape(a::SArray, s::Tuple{SOneTo,Vararg{SOneTo}}) = reshape(a, homogenize_shape(s))
189
+@inline reshape(a::AbstractArray, s::Tuple{SOneTo,Vararg{SOneTo}}) = reshape(a, homogenize_shape(s))
190
@inline function reshape(a::StaticArray, s::Tuple{SOneTo,Vararg{SOneTo}})
191
return __reshape(a, map(u -> last(u), s), homogenize_shape(s))
192
end
test/abstractarray.jl
@@ -109,7 +109,10 @@ using StaticArrays, Test, LinearAlgebra
109
@test @inferred(reshape(SVector(1,2,3,4), axes(SMatrix{2,2}(1,2,3,4)))) === SMatrix{2,2}(1,2,3,4)
110
@test @inferred(reshape(SVector(1,2,3,4), Size(2,2))) === SMatrix{2,2}(1,2,3,4)
111
@test @inferred(reshape([1,2,3,4], Size(2,2)))::SizedArray{Tuple{2,2},Int,2,1} == [1 3; 2 4]
112
+ @test @inferred(reshape([1,2,3,4], axes(SMatrix{2,2}(1,2,3,4))))::SizedArray{Tuple{2,2},Int,2,1} == [1 3; 2 4]
113
+ @test @inferred(reshape([1 2 3 4], axes(SMatrix{2,2}(1,2,3,4))))::SizedArray{Tuple{2,2},Int,2,2} == [1 3; 2 4]
114
@test_throws DimensionMismatch reshape([1 2; 3 4], Size(2,2,2))
115
+ @test_throws DimensionMismatch reshape([1 2 3], axes(SMatrix{2,2}(1,2,3,4)))
116
117
@test @inferred(vec(SMatrix{2, 2}([1 2; 3 4])))::SVector{4,Int} == [1, 3, 2, 4]
118
0 commit comments