Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15979

Re: position of sequence of numbers in list

From Oliver Ruebenkoenig <ruebenko@wolfram.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: position of sequence of numbers in list
Date 2011-02-08 10:03 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iir4d4$6g6$1@smc.vnet.net> (permalink)

Show all headers | View raw


On Mon, 7 Feb 2011, Armand Tamzarian wrote:

> On Feb 6, 9:37 pm, "Mr. Wizard" <gl...@flashmail.com> wrote:
>>> I just found another way that outperforms both of our solutions on a
>>> wide range of integer arrays I tested. It turns out that one can
>>> extract the position directly from SparseArray, without using
>>> ArrayRules. It took me some time to figure it out:
>>
>>> extractPositionFromSparseArray[
>>>   HoldPattern[SparseArray[u___]]] := {u}[[4, 2, 2]]
>>
>>> positionExtr[x_List, n_] :=
>>>  Flatten@extractPositionFromSparseArray[
>>>    SparseArray[1 - Unitize[x - n]]]
>>
>>> Again, no unpacking.
>>
>>> Best,
>>> Norbert
>>
>> Oliver Ruebenkoenig recently gave an easier way to get these values
>> in the thread "Fast matrices comparison" started January 25th, 2011.
>>
>> SparseArray[{0, 1, 0, 0, 1, 0, 1, 1, 0, 0}]["NonzeroPositions"]
>>
>> SparseArray[{1}]["Properties"]
>>
>> Paul
>
> I noted in his post that this stuff is undocumented. Hard to fathom
> why this would be. Wonder if this is a V8 thing or has been there
> since SparseArray was included.
>
> Oliver, if you're reading this, what other undocumented goodies can
> you show to the group?
>
> Mike

Mike,

I filed a suggestions that the functionality used here is going to be 
documented. I can not, however, say if this will be approved and or when 
this will happen.

Please also keep in mind to use undocumented functionality very cautiously 
- there may be very good reasons that the functionality is undocumented; it 
may not have been tested as much as needed.

Concerning "goodies", let's see what computational issues come up.


Oliver

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: position of sequence of numbers in list Oliver Ruebenkoenig <ruebenko@wolfram.com> - 2011-02-08 10:03 +0000

csiph-web