I want to take an arbitrary 1D vector a = [k] and b = [m] and form the matrix of ordered pairs c = [2 x k x m] such that $c->(:,(i),(j)) = [ $a->(i), $b->(j) ]
. I.e. the set of all ordered pairs of the elements in a and b a.k.a the cartesian product.
Of course I could use a loop and the [glue] function to accomplish this, but that isn't in the spirit of Perl/PDL. Is there a fancy method that involves slices, dummy dimensions, and glue that gets me there?
Also, using Math::Cartesian::Product (as answered here: In Perl, how can I get the Cartesian product of multiple sets? is cheating! :3 I want straight perl/PDL and hopefully learn something in the process.
I got something that meets my criteria: