Re: Weird behavior of SparseArray
- To: mathgroup at smc.vnet.net
- Subject: [mg58400] Re: Weird behavior of SparseArray
- From: dh <dh at metrohm.ch>
- Date: Thu, 30 Jun 2005 06:16:02 -0400 (EDT)
- References: <da0bek$fjr$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
$Version
5.1 for Microsoft Windows (October 25, 2004)
Hi Adel,
in this version it seems to work o.k.
On the other hand, I saw problems with sparse matrixes in numeric
routines, but I did not report them.
sincerely, Daniel
Adel Elsabbagh wrote:
> 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?
>