File tree 2 files changed +35
-1
lines changed
2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -905,7 +905,9 @@ for (type, N_expr) in [
905
905
else
906
906
unpacked = unpack_voa (bc, i)
907
907
arr_type = StaticArraysCore. similar_type (dest[:, i])
908
- dest[:, i] = if length (unpacked) == 1
908
+ dest[:, i] = if length (unpacked) == 1 && length (dest[:, i]) == 1
909
+ arr_type (unpacked[1 ])
910
+ elseif length (unpacked) == 1
909
911
fill (copy (unpacked), arr_type)
910
912
else
911
913
arr_type (unpacked[j] for j in eachindex (unpacked))
Original file line number Diff line number Diff line change @@ -82,3 +82,35 @@ b = recursivecopy(a)
82
82
@test a[1 ] == b[1 ]
83
83
a[1 ] *= 2
84
84
@test a[1 ] != b[1 ]
85
+
86
+ # Broadcasting when SVector{N} where N = 1
87
+ a = [SVector (0.0 ) for _ in 1 : 2 ]
88
+ a_voa = VectorOfArray (a)
89
+ b_voa = copy (a_voa)
90
+ a_voa[1 ] = SVector (1.0 )
91
+ a_voa[2 ] = SVector (1.0 )
92
+ @. b_voa = a_voa
93
+ @test b_voa[1 ] == a_voa[1 ]
94
+ @test b_voa[2 ] == a_voa[2 ]
95
+
96
+ a = [SVector (0.0 ) for _ in 1 : 2 ]
97
+ a_voa = VectorOfArray (a)
98
+ a_voa .= 1.0
99
+ @test a_voa[1 ] == SVector (1.0 )
100
+ @test a_voa[2 ] == SVector (1.0 )
101
+
102
+ # Broadcasting when SVector{N} where N > 1
103
+ a = [SVector (0.0 , 0.0 ) for _ in 1 : 2 ]
104
+ a_voa = VectorOfArray (a)
105
+ b_voa = copy (a_voa)
106
+ a_voa[1 ] = SVector (1.0 , 1.0 )
107
+ a_voa[2 ] = SVector (1.0 , 1.0 )
108
+ @. b_voa = a_voa
109
+ @test b_voa[1 ] == a_voa[1 ]
110
+ @test b_voa[2 ] == a_voa[2 ]
111
+
112
+ a = [SVector (0.0 , 0.0 ) for _ in 1 : 2 ]
113
+ a_voa = VectorOfArray (a)
114
+ a_voa .= 1.0
115
+ @test a_voa[1 ] == SVector (1.0 , 1.0 )
116
+ @test a_voa[2 ] == SVector (1.0 , 1.0 )
You can’t perform that action at this time.
0 commit comments