MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Re: Weird behavior of SparseArray


and thus spake Adel Elsabbagh [2005.07.02 @ 04:13]:
> But here is what I get using the same input:
> 
> In[218]:=
> cp1=SparseArray[{i_,j_}\[Rule]0,{4,2}];
> cp1[[Range[4],1]]=cp1[[Range[4],1]]+{1,1,1,1};
> Normal[cp1]
> $Version
> 
> 
> 
> Out[220]=
> {{0,0},{0,0},{0,0},{0,0}}
> 
> Out[221]=
> 5.0 for Microsoft Windows (June 11, 2003)

Looks like a bug with 5.0.0, fixed in 5.0.1;

This use of SparseArray is rather unintuitive, however.  What you shold
probably be doing is something like this:

cp1 = SparseArray[{_,1}->1,{4,2}]

Assigning a rule for every position in a sparse array defeats the
purpose of a sparse array.

> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!

That's a lot of exclaiming...
--
/*------------------------------*\
|        stephen layland         |
|    Documentation Programmer    |
| http://members.wri.com/layland |
\*------------------------------*/


  • Prev by Date: Re: Simple List manipulation question
  • Next by Date: Re: a question about the UnitStep function
  • Previous by thread: Re: Re: Weird behavior of SparseArray
  • Next by thread: a question about the UnitStep function