Mark,
You can also do this very quickly without PDL at all, if you don't actually
need piddles:
print(split( / */,sprintf("%0*b",4,$_)),"\n") for (0..15);
If you're looking for the Grey codes (your example was almost there, but not
quite), then you can just replace $_ with (( $_>>1 ) ^ $_ ). Now it's getting
a bit opaque, but will still do the job.
On Jan 5, 2013, at 4:50 PM, Craig DeForest wrote:
> Does it have to be Grey code? If you only care about all permutations, try:
>
> $a= pdl(short,2)**xvals(short,$width);
> $b= yvals (short,1,$height);
> $c= ($b/$a)&pdl(short,1);
>
> (mobile)
>
>
> On Jan 5, 2013, at 4:25 PM, MARK BAKER <[email protected]> wrote:
>
>>
>>
>>
>>
>> Hello all
>>
>> I have been trying to make a matrix that starts out with all zeros
>> and then cycles threw all combinations of a binay numbers for instance
>>
>>
>> if I had a matrix
>> [ 0 0 0 0]
>>
>> then I would like it to cycle very fast to go threw all combinations
>> like this
>>
>> [ 0 0 0 0 ]
>> [ 0 0 0 1 ]
>> [ 0 0 1 1 ]
>> [ 0 0 1 0 ]
>> [ 0 1 1 0 ]
>> [ 0 1 0 0 ]
>> [ 0 1 0 1 ]
>> [ 0 1 1 1 ]
>> [ 1 1 1 1 ]
>> [ 1 1 1 0 ]
>> [ 1 1 0 0 ]
>> [ 1 1 0 1 ]
>> [ 1 0 0 1 ]
>> [ 1 0 1 1 ]
>> [ 1 0 1 0 ]
>>
>>
>> I know I can do this
>>
>> $k = zeros(4);
>> p $h->(3).=1;
>> p $h->(2).=1;
>> p $h->(3).=0;
>> p $h->(1).=1;
>> p $h->(2).=0;
>> p $h->(3).=1;
>> p $h->(2).=1;
>> p $h->(0).=1;
>> p $h->(3).=0;
>> p $h->(2).=0;
>> p $h->(3).=1;
>> p $h->(1).=0;
>> p $h->(2).=1;
>> p $h->(3).=0;
>>
>> is there a faster way to do this that anyone might know of ???
>>
>> Thanks for your advice ..
>>
>>
>>
>>
>> -Mark R Baker
>>
>>
>> _______________________________________________
>> Perldl mailing list
>> [email protected]
>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl