Subject: | allow blessed constants in overloads (patch) |
Date: | Tue, 07 Apr 2009 07:36:45 +1000 |
To: | bug-Math-Polynomial [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
It'd be good if Math::Polynomial allowed multiply etc by a constant
which is not a plain number but instead some class like Math::BigRat.
For example,
use Math::Polynomial;
use Math::BigRat;
$p1 = Math::Polynomial->new (Math::BigRat->new('1/6'), 0);
$p1 *= Math::BigRat->new('1/8');
print "$p1\n";
which currently gets an error
Not an ARRAY reference at /usr/share/perl5/Math/Polynomial.pm line 345.
where it'd be good to print
(1/48 0)
I think all it might need is for the overload funcs to check
isa('Math::Polynomial') instead of assuming any ref() is a poly, perhaps
per below (including swapping a multiply in interpolate() to hit the
poly multiply instead of anything the coeff might have).
Message body is not shown because sender requested not to inline it.