InSuk Joung wrote:
> Hi Users,
> I am wondering if there is a function that make a permutation piddle.
>
> For example,
>
> $a = sequence(2);
> $b = sequence(3);
>
> Using the two piddles above, I want to create
>
> [
> [ 0, 0 ],
> [ 0, 1 ],
> [ 0, 2 ],
> [ 1, 0 ],
> [ 1, 1 ],
> [ 1, 2 ],
> ]
>
> Any suggestion would be appreciated!
>
It's OK to use a for-loop sometimes! That's probably the easiest. But
since you asked:
$n = $a->nelem * $b->nelem;
use PDL::Transform;
$ap = $a->dummy(0)->map(t_identity,[1,$n],{method=>'s'});
$bp = $b->range(0,$n,'p')->dummy(0) ;
$p = append($ap,$bp);
cheers,
Derek
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl