##
print join " ", @{p([1..5],[1..5])};
1 4 9 16 25
##
##
sub p{my $t=pdl+pop;$t=$t*(pdl$_)for@_;[list$t]}
##
##
A = p1'*p2;
product = crossdiags(A);
##
##
sub p{$t=pdl+pop;for(@_){
my $a=outer$t,pdl+pop;
transpose($a);
my $n=-1+nelem$t;
$t=zeroes($n*2+1);
$t->slice("$_:".($_+$n))+=$a->slice("$_,:")for 0..$n;
}
[list$t]}