Weird behavior of SparseArray
- To: mathgroup at smc.vnet.net
- Subject: [mg58387] Weird behavior of SparseArray
- From: Adel Elsabbagh <aelsabbagh at gmail.com>
- Date: Thu, 30 Jun 2005 04:37:22 -0400 (EDT)
- Reply-to: Adel Elsabbagh <aelsabbagh at gmail.com>
- Sender: owner-wri-mathgroup at wolfram.com
Dear all I don't understand what is going on with SparseArray If I write this: cp1 = SparseArray[{i_, j_} -> 0, {4, 2}]; cp1[[Range[4], 1]] = cp1[[Range[4], 1]] + {1, 1, 1, 1}; cp1 // MatrixForm I get cp1 with all entries equal to zero However, if use Table instead of SparseArray I get the right answer. More surprisingly, if I write this: cp1 = SparseArray[{i_, j_} -> 0, {4, 2}]; cp1[[Range[4], 1]] = cp1[[Range[4], 1]] + {1, 1, 1, 1}; cp1 // MatrixForm cp1[[Range[4], 1]] = cp1[[Range[4], 1]] + {1, 1, 1, 1}; cp1 // MatrixForm I get ones in the first column!! Any explanation? -- Adel