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

Reply via email to