[Gridflow-dev] feature request: [#shuffle]
Claude Heiland-Allen
claudiusmaximus at goto10.org
Wed Jan 11 21:28:40 EST 2006
Hi all,
Mathieu Bouchard wrote:
> On Wed, 11 Jan 2006, Claude Heiland-Allen wrote:
>
>>I'm working on something, and would find it really handy to have a
>>[#shuffle] object that would take an input grid's 'vectors' and swap
>>them with each other to give a random permutation.
After heading down a completely wrong direction, I've managed to get it
working the way I want it to (which maybe is slightly different to the
way I specified in my original mail):
"( 3 4 5 # ... )" -> [#shuffle 0] => shuffle in blocks of ( 4 5 # ... )
"( 3 4 5 # ... )" -> [#shuffle 1] => shuffle in blocks of ( 5 # ... )
"( 3 4 5 # ... )" -> [#shuffle 2] => shuffle in blocks of ( 1 # ... )
Two points:
1. this error message when feeding Dim[0] to [#reverse] can be ignored,
but it is annoying:
error: ArgumentError: [#reverse]: factor=0 should be >= 1
base/grid.c.fcs:149:in `void GridInlet::set_factor(int)'
[#reverse]
2. I got into a horrible place with [fork] and undefined behaviour, so I
used an abstraction wrapping it with [#store] and [#finished] - you
might not want to feed huge grids into [#shuffle] for this reason.
> [42 # 1000000000}
> |
You missed a [# rand] here.
> [#grade] generates a uniformly random permutation of numbers 0..N-1
> |
> [#outer ignore (0)] add dimension to please #store
> |
> [#store (42 # ...)]
> |
> random permutation of 42 values
Ok, I got what I wanted to do working with this method. Statistics and
probability were never my strong points.
>>inlet 0 method grid (grid(d0 d1 d2 ... dN) grid)
>
> the convention is that the last dimension is labeled d(N-1) so that the
> number of dimensions is N instead of N+1.
Ok, that's much more sensible :-)
> do you need it to be faster than the one using [#grade] above?
I don't know yet...
Claude
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: #fork_safe.pd
Url: http://ns.artengine.ca/pipermail/gridflow-dev/attachments/20060112/ad614f6b/fork_safe.cc
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: #reverse-test.pd
Url: http://ns.artengine.ca/pipermail/gridflow-dev/attachments/20060112/ad614f6b/reverse-test.cc
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: #shuffle-help.pd
Url: http://ns.artengine.ca/pipermail/gridflow-dev/attachments/20060112/ad614f6b/shuffle-help.cc
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: #shuffle.pd
Url: http://ns.artengine.ca/pipermail/gridflow-dev/attachments/20060112/ad614f6b/shuffle.cc
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: #wrap_dimension-help.pd
Url: http://ns.artengine.ca/pipermail/gridflow-dev/attachments/20060112/ad614f6b/wrap_dimension-help.cc
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: #wrap_dimension.pd
Url: http://ns.artengine.ca/pipermail/gridflow-dev/attachments/20060112/ad614f6b/wrap_dimension.cc
More information about the Gridflow-dev
mailing list