Bug introduced in 5.2 and fixed in 10.1.0
Not sure if this is known behavior or not, but the following two lines produce an instant kernel crash (I'm using Mathematica 10.0.1 Windows 64-bit):
A = SparseArray[{}, {3, 3}];
A[[1, {1, 1}]] += 1
This is just a minor modification of the following lines:
A = SparseArray[{}, {3, 3}];
A[[1, {1, 2}]] += 1
which are designed to increment entries {1,1}
and {1,2}
of A
by one. I would have expected the crash-inducing example to increment the {1,1}
entry by two. Instead, I get screams of death.
Any clues as to what is going on here?
This slight variation produces a more apparent crash in 7.0.1:
A = SparseArray[{}, {3, 3}];
A[[1, {1, 2, 3, 1, 1}]] += 1
A[[k, list]] += 1
wherek
is a positive integer andlist
is a list increments all entries with indices $(k,m)\mid m\in\text{list}$ by one. This is a convenient one-line syntax for a multiple update within the $k$th row of a sparse matrix. Unfortunately, for some reason wheneverlist
has a repeated element the kernel crashes. Of course, one possible workaround would be to simply construct aDo
loop and iterate the sparse row update over the elements oflist
, but the aforementioned syntax makes things easier. $\endgroup$ – DumpsterDoofus Jan 15 '15 at 14:06