Commit 6e8f9a1
authored
Currently, the following works unexpectedly:
```julia
julia> A = Symmetric(fill([1 2; 3 4], 3, 3))
3×3 Symmetric{AbstractMatrix, Matrix{Matrix{Int64}}}:
[1 2; 2 4] [1 2; 3 4] [1 2; 3 4]
[1 3; 2 4] [1 2; 2 4] [1 2; 3 4]
[1 3; 2 4] [1 3; 2 4] [1 2; 2 4]
julia> A[1,1] = [1 2; 3 4]
2×2 Matrix{Int64}:
1 2
3 4
julia> A[1,1]
2×2 Symmetric{Int64, Matrix{Int64}}:
1 2
2 4
```
After this PR, the `setindex!` throws an error if the exact value cannot
be used:
```julia
julia> A[1,1] = [1 2; 3 4]
ERROR: ArgumentError: cannot set a diagonal element of a symmetric matrix to an asymmetric value
```
1 parent 5d3d02a commit 6e8f9a1
2 files changed
+14
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
269 | 270 | | |
270 | 271 | | |
271 | 272 | | |
| |||
276 | 277 | | |
277 | 278 | | |
278 | 279 | | |
279 | | - | |
280 | | - | |
| 280 | + | |
| 281 | + | |
281 | 282 | | |
282 | 283 | | |
283 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1180 | 1180 | | |
1181 | 1181 | | |
1182 | 1182 | | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
1183 | 1194 | | |
0 commit comments