Subject: | support for overload of unary minus |
Hi,
Math::Matrix overloads '-' using the subtract function, which doesn't handle being called when the unary minus operation is invoked, as in
$m1 = -$m2;
The attached patch supplies that behavior.
Thanks,
Diab
Subject: | Math-Matrix-0.7.patch |
diff -r Math-Matrix-0.7.orig/Matrix.pm Math-Matrix-0.7/Matrix.pm
155c155
< =head2 substract
---
> =head2 subtract
571c571,581
< $self->add($other->negative);
---
>
> # if $swap is present, $other operand isn't a Math::Matrix. in
> # general that's undefined, but, if called as
> # subtract($self,0,1)
> # we've been called as unary minus, which is defined.
> if ( @_ && $_[0] && ! ref $other && $other == 0 ) {
> $self->negative;
> }
> else {
> $self->add($other->negative);
> }