       Re: sparsearray bug?

• To: mathgroup at smc.vnet.net
• Subject: [mg101546] Re: sparsearray bug?
• From: Bill Rowe <readnews at sbcglobal.net>
• Date: Fri, 10 Jul 2009 06:41:49 -0400 (EDT)

```On 7/8/09 at 7:11 AM, w.p.bergsma at lse.ac.uk (wpb) wrote:

>In:= SparseArray[{1}]/SparseArray[{1}]

>During evaluation of In:= Power::infy: Infinite expression 1/0
>encountered. >> During evaluation of In:= \[Infinity]::indet:
>Indeterminate expression 0 ComplexInfinity encountered. >>

>Out= SparseArray[<1>,{1},Indeterminate]

What were you expecting and why would you ever divide one sparse
array by another?

Consider for normal arrays the following:

In:= x = RandomReal[1, {2, 2}]

Out= {{0.980046, 0.324877}, {0.587326, 0.387608}}

In:= y = RandomReal[1, {2, 2}]

Out= {{0.554456, 0.960964}, {0.162428, 0.976886}}

In:= x/y

Out= {{1.76758, 0.338074}, {3.61592, 0.396779}}

Since the divide operation does an element by element divide you
should expect the same behavior when dividing a sparse array by
another sparse array. But by definition a sparse array has a
great many elements with value 0. So, an element by element
divide will inevitably mean dividing by 0.

above since SparseArray[{1}] is the one element array {1}.
Possibly the code that does the element by element divide does
not look to see that SparseArray[{1}] isn't really a sparse
array in the since there are no zero elements.

But even if this is a bug (meaning the results are different
than intended) it still leaves the question of why would you be
doing this kind of division?

```

• Prev by Date: Re: 2dFFT & image processing
• Next by Date: Re: Manipulating list
• Previous by thread: Re: sparsearray bug?
• Next by thread: Re: sparsearray bug?