> This RFC proposes that operators in a list context should be applied
> element-wise to the elements of their arguments:
>
> @d = @b * @c; # Returns (2,8,18)
>
> If the lists are not of equal length, an error is raised.
I've been watching this RFC for a while. I would hesitate to change the
default behavior of * and other operators in so radical a sense,
especially since it would create unexpected error conditions. I think
these operations should remain scalar.
However, we need a means to do what you're after, definitely. I would
recommend you check out RFC 200, just posted, which proposes massive tie
changes that would allow for integrated data, function, and operator
overloading. From the RFC:
tie My::Matrix @a; # tie @a to $obj
@c = @a + @b; # @c = $obj->ADD(@b);
$a[0] = 4; # $obj->STORE(0, 4);
@d = @a * @b; # @d = $obj->MUL(@b);
The idea would be operator and data overloading is completely integrated
with tie, based on the concept of polymorphic objects. As such, you
could create native PDL classes that would allow @a * @b to do what you
want.
Otherwise, you have to decide if @a * @b should be element-wise, a
cross-product, a vector, or ??? I just think it's a can of worms that's
going to result in a set of arbitrary decisions, which in the the end
makes less sense than having these contexts remain scalar by default.
-Nate