MathGroup Archive 2007

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

Search the Archive

Re: sparsearray and its nonempty cells


Are you sure Mysparse is defined well?
This is what I got:

In[1]:=
Quit

In[1]:=
Mysparse = SparseArray[i_ /; 2 = i = 11 :> 0.8, 20]
Set::nosym : i_ /; 2 does not contain a symbol to which to attach a
rule.
Out[1]=
SparseArray[]

As regards your question the simplest way is the use of Sort.

In[3]:=
Sort[{{8}, {11}, {3}, {7}, {2}, {6}, {10}, {9}, {5}, {4}}]

Out[3]=
{{2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}}

Regards
Dimitris


Arkadiusz.Ma... at gmail.com wrote:
> Hi,
>
> 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?
> 
> Arek


  • Prev by Date: Writing 16 Bit Image in Dicom Format
  • Next by Date: Possible to Create 16 Bit Dicom Images in Mathematica 5.2??
  • Previous by thread: Re: sparsearray and its nonempty cells
  • Next by thread: Re: sparsearray and its nonempty cells