Re: sparsearray and its nonempty cells
- To: mathgroup at smc.vnet.net
- Subject: [mg72621] Re: sparsearray and its nonempty cells
- From: Bill Rowe <readnewsciv at sbcglobal.net>
- Date: Fri, 12 Jan 2007 06:09:50 -0500 (EST)
On 1/11/07 at 3:20 AM, Arkadiusz.Majka at gmail.com wrote:
>I bulit the following sparse array
>Mysparse=SparseArray[i_ /; 2 â?¤ i â?¤ 11 :> 0.8, 20]
>in order to find out all nonempty cells in this array I call (I want
>to avoid Normal)
>Mysparse/. SparseArray[_, _, _, x_] :> x[[2, 2]]
>and I get
>{{8}, {11}, {3}, {7}, {2}, {6}, {10}, {9}, {5}, {4}}
>This is of course correct, but why it is not sorted????
>How can I build Mysparse to get sorted list of nonempty cells?
Use ArrayRules
In[5]:=
Most[First/@ArrayRules[Mysparse]]
Out[5]=
{{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}}
--
To reply via email subtract one hundred and four