@@ -27,17 +27,17 @@ using StaticArrays, Test
27
27
28
28
# SVector
29
29
mv = MVector {4,Int} (undef)
30
- @test (mv[SVector (1 ,2 ,3 ,4 )] = vec; (@inferred getindex (mv, SVector (4 ,3 ,2 ,1 ))):: SVector {4,Int} == SVector ((7 ,6 ,5 ,4 )))
30
+ @test (mv[SVector (1 ,2 ,3 ,4 )] = vec; (@inferred getindex (mv, SVector (4 ,3 ,2 ,1 ))):: MVector {4,Int} == MVector ((7 ,6 ,5 ,4 )))
31
31
32
32
mv = MVector {4,Int} (undef)
33
- @test (mv[SVector (1 ,2 ,3 ,4 )] = [4 , 5 , 6 , 7 ]; (@inferred getindex (mv, SVector (4 ,3 ,2 ,1 ))):: SVector {4,Int} == SVector ((7 ,6 ,5 ,4 )))
34
- @test (mv[SVector (1 ,2 ,3 ,4 )] = 2 ; (@inferred getindex (mv, SVector (4 ,3 ,2 ,1 ))):: SVector {4,Int} == SVector ((2 ,2 ,2 ,2 )))
33
+ @test (mv[SVector (1 ,2 ,3 ,4 )] = [4 , 5 , 6 , 7 ]; (@inferred getindex (mv, SVector (4 ,3 ,2 ,1 ))):: MVector {4,Int} == MVector ((7 ,6 ,5 ,4 )))
34
+ @test (mv[SVector (1 ,2 ,3 ,4 )] = 2 ; (@inferred getindex (mv, SVector (4 ,3 ,2 ,1 ))):: MVector {4,Int} == MVector ((2 ,2 ,2 ,2 )))
35
35
36
36
# Colon
37
37
mv = MVector {4,Int} (undef)
38
- @test (mv[:] = vec; (@inferred getindex (mv, :)):: SVector {4,Int} == SVector ((4 ,5 ,6 ,7 )))
39
- @test (mv[:] = [4 , 5 , 6 , 7 ]; (@inferred getindex (mv, :)):: SVector {4,Int} == SVector ((4 ,5 ,6 ,7 )))
40
- @test (mv[:] = 2 ; (@inferred getindex (mv, :)):: SVector {4,Int} == SVector ((2 ,2 ,2 ,2 )))
38
+ @test (mv[:] = vec; (@inferred getindex (mv, :)):: MVector {4,Int} == MVector ((4 ,5 ,6 ,7 )))
39
+ @test (mv[:] = [4 , 5 , 6 , 7 ]; (@inferred getindex (mv, :)):: MVector {4,Int} == MVector ((4 ,5 ,6 ,7 )))
40
+ @test (mv[:] = 2 ; (@inferred getindex (mv, :)):: MVector {4,Int} == MVector ((2 ,2 ,2 ,2 )))
41
41
42
42
@test_throws DimensionMismatch setindex! (mv, SVector (1 ,2 ,3 ), SVector (1 ,2 ,3 ,4 ))
43
43
@test_throws DimensionMismatch setindex! (mv, SVector (1 ,2 ,3 ), :)
@@ -50,11 +50,11 @@ using StaticArrays, Test
50
50
51
51
# SVector
52
52
mm = MMatrix {2,2,Int} (undef)
53
- @test (mm[SVector (1 ,2 ,3 ,4 )] = vec; (@inferred getindex (mm, SVector (4 ,3 ,2 ,1 ))):: SVector {4,Int} == SVector ((7 ,6 ,5 ,4 )))
53
+ @test (mm[SVector (1 ,2 ,3 ,4 )] = vec; (@inferred getindex (mm, SVector (4 ,3 ,2 ,1 ))):: MVector {4,Int} == MVector ((7 ,6 ,5 ,4 )))
54
54
55
55
# Colon
56
56
mm = MMatrix {2,2,Int} (undef)
57
- @test (mm[:] = vec; (@inferred getindex (mm, :)):: SVector {4,Int} == SVector ((4 ,5 ,6 ,7 )))
57
+ @test (mm[:] = vec; (@inferred getindex (mm, :)):: MVector {4,Int} == MVector ((4 ,5 ,6 ,7 )))
58
58
end
59
59
60
60
@testset " Linear getindex()/setindex!() with a SVector on an Array" begin
@@ -93,16 +93,16 @@ using StaticArrays, Test
93
93
sm = @MMatrix [1 3 ; 2 4 ]
94
94
95
95
# Tuple, scalar
96
- @test (mm = MMatrix {2,2,Int} (undef); mm[SVector (2 ,1 ),SVector (2 ,1 )] = sm[SVector (2 ,1 ),SVector (2 ,1 )]; (@inferred getindex (mm, SVector (2 ,1 ), SVector (2 ,1 ))):: SMatrix == @SMatrix [4 2 ; 3 1 ])
97
- @test (mm = MMatrix {2,2,Int} (undef); mm[1 ,SVector (1 ,2 )] = sm[1 ,SVector (1 ,2 )]; (@inferred getindex (mm, 1 , SVector (1 ,2 ))):: SVector == @SVector [1 ,3 ])
98
- @test (mm = MMatrix {2,2,Int} (undef); mm[SVector (1 ,2 ),1 ] = sm[SVector (1 ,2 ),1 ]; (@inferred getindex (mm, SVector (1 ,2 ), 1 )):: SVector == @SVector [1 ,2 ])
96
+ @test (mm = MMatrix {2,2,Int} (undef); mm[SVector (2 ,1 ),SVector (2 ,1 )] = sm[SVector (2 ,1 ),SVector (2 ,1 )]; (@inferred getindex (mm, SVector (2 ,1 ), SVector (2 ,1 ))):: MMatrix == @MMatrix [4 2 ; 3 1 ])
97
+ @test (mm = MMatrix {2,2,Int} (undef); mm[1 ,SVector (1 ,2 )] = sm[1 ,SVector (1 ,2 )]; (@inferred getindex (mm, 1 , SVector (1 ,2 ))):: MVector == @MVector [1 ,3 ])
98
+ @test (mm = MMatrix {2,2,Int} (undef); mm[SVector (1 ,2 ),1 ] = sm[SVector (1 ,2 ),1 ]; (@inferred getindex (mm, SVector (1 ,2 ), 1 )):: MVector == @MVector [1 ,2 ])
99
99
100
100
# Colon
101
- @test (mm = MMatrix {2,2,Int} (undef); mm[:,:] = sm[:,:]; (@inferred getindex (mm, :, :)):: SMatrix == @MMatrix [1 3 ; 2 4 ])
102
- @test (mm = MMatrix {2,2,Int} (undef); mm[SVector (2 ,1 ),:] = sm[SVector (2 ,1 ),:]; (@inferred getindex (mm, SVector (2 ,1 ), :)):: SMatrix == @SMatrix [2 4 ; 1 3 ])
103
- @test (mm = MMatrix {2,2,Int} (undef); mm[:,SVector (2 ,1 )] = sm[:,SVector (2 ,1 )]; (@inferred getindex (mm, :, SVector (2 ,1 ))):: SMatrix == @SMatrix [3 1 ; 4 2 ])
104
- @test (mm = MMatrix {2,2,Int} (undef); mm[1 ,:] = sm[1 ,:]; (@inferred getindex (mm, 1 , :)):: SVector == @SVector [1 ,3 ])
105
- @test (mm = MMatrix {2,2,Int} (undef); mm[:,1 ] = sm[:,1 ]; (@inferred getindex (mm, :, 1 )):: SVector == @SVector [1 ,2 ])
101
+ @test (mm = MMatrix {2,2,Int} (undef); mm[:,:] = sm[:,:]; (@inferred getindex (mm, :, :)):: MMatrix == @MMatrix [1 3 ; 2 4 ])
102
+ @test (mm = MMatrix {2,2,Int} (undef); mm[SVector (2 ,1 ),:] = sm[SVector (2 ,1 ),:]; (@inferred getindex (mm, SVector (2 ,1 ), :)):: MMatrix == @MMatrix [2 4 ; 1 3 ])
103
+ @test (mm = MMatrix {2,2,Int} (undef); mm[:,SVector (2 ,1 )] = sm[:,SVector (2 ,1 )]; (@inferred getindex (mm, :, SVector (2 ,1 ))):: MMatrix == @MMatrix [3 1 ; 4 2 ])
104
+ @test (mm = MMatrix {2,2,Int} (undef); mm[1 ,:] = sm[1 ,:]; (@inferred getindex (mm, 1 , :)):: MVector == @MVector [1 ,3 ])
105
+ @test (mm = MMatrix {2,2,Int} (undef); mm[:,1 ] = sm[:,1 ]; (@inferred getindex (mm, :, 1 )):: MVector == @MVector [1 ,2 ])
106
106
end
107
107
108
108
@testset " 3D scalar indexing" begin
0 commit comments