[Date Index]
[Thread Index]
[Author Index]
Re: Q on SparseArray representation
*To*: mathgroup at smc.vnet.net
*Subject*: [mg113976] Re: Q on SparseArray representation
*From*: Oliver Ruebenkoenig <ruebenko at wolfram.com>
*Date*: Fri, 19 Nov 2010 06:59:13 -0500 (EST)
On Fri, 19 Nov 2010, kj wrote:
> 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?
Let me see if I can get these together again,
{{0, 1, 3, 4, 8}, {{3}, {4}, {1}, {4}, {4}, {1}, {3}, {2}}}
The first row has 1-0 entries in column 3 (i.e. 8) The second row has 3-1
entries in columns 4 and 1 (i.e. 9 and 6), the next row, 3, has 4-3
entries in column 4, ie. 2 and so on...
What the 1 stands for, I can't remember.
Hth,
Oliver
>
> TIA!
>
> ~kj
>
>
Prev by Date:
**Re: band pass or notch filtering?**
Next by Date:
**Re: transform Matrix and List elements toreplacement Rules**
Previous by thread:
**Q on SparseArray representation**
Next by thread:
**Re: Q on SparseArray representation**
| |