Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Q on SparseArray representation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113952] Q on SparseArray representation
  • From: kj <no.email at please.post>
  • Date: Fri, 19 Nov 2010 05:08:44 -0500 (EST)

In[1]:= SparseArray[RandomInteger[{1, 4}, {10, 2}] ->
                    RandomInteger[{1, 9}, 10]]
Out[1]= SparseArray[<8>, {4, 4}]

In[2]:= InputForm[%]
Out[2]= SparseArray[Automatic, {4, 4}, 0,
                    {1, {{0, 1, 3, 4, 8}, {{3}, {4}, {1}, {4}, {4}, {1}, {3},
                     {2}}}, {8, 9, 6, 2, 4, 7, 1, 4}}]

I find this canonical form intriguing, and would like to understand
it.  The first three terms of the SparseArray arguments list (namely
Automatic, {4, 4}, and 0) are easy to rationalize.  But I'm stumped
by the last term, namely:


{1, {{0, 1, 3, 4, 8}, {{3}, {4}, {1}, {4}, {4}, {1}, {3}, {2}}},
{8, 9, 6, 2, 4, 7, 1, 4}}

In fact, this term is not 100% opaque.  Its last element, namely

{8, 9, 6, 2, 4, 7, 1, 4}

consists of the non-zero elements of the array, although they appear
in an order whose relation to their oder in the array I cannot
figure out:

/         \
| 0 0 8 0 |
| 6 0 0 9 |
| 0 0 0 2 |
| 7 4 1 4 |
\         /

Similarly, its element at position {2, 2}, namely

{{3}, {4}, {1}, {4}, {4}, {1}, {3}, {2}}

contains the numbers of the columns of the entries listed in the
last element.  Thus we see that 8 appears in column 3, 9 in column
4, 6 in column 1, etc.

It's the remaining two items that I cannot figure out at all.
These are the members at positions {1} and {2, 1}.  The former is
simply the number 1.  What does this mean?  The latter is the list
{0, 1, 3, 4, 8}.  All I can say about this list is that in all
cases of SparseArray I've examined, its firts element is always 0,
and its length is 1 more than the number of rows in the SparseArray.
Does anyone know what this list of numbers represents?

TIA!

~kj


  • Prev by Date: NMinimize -DifferentialEvolution
  • Next by Date: Mathematica 8 and Alpha integration....
  • Previous by thread: Re: NMinimize -DifferentialEvolution
  • Next by thread: Re: Q on SparseArray representation