Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

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


  • Prev by Date: RE: Mathematica newbie
  • Next by Date: Re: Problem with Position applied on 2D list?
  • Previous by thread: Re: sparsearray and its nonempty cells
  • Next by thread: Re: sparsearray and its nonempty cells