Subject: | suggest mul1c and div1c as "root" operations |
Date: | Thu, 28 May 2009 09:19:22 +1000 |
To: | bug-Math-Polynomial [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
Are the mul1c() and div1c() functions still available? They were
slightly odd, but might be kept as "root" operations, per below.
There might even be a place for a new_from_roots($c1,...$cN) forming
(x-$c1)*(x-$c2)*...*(x-$cN), especially if it could be done more
efficiently than O(N^2) which simple successive multiplications would
take.
=item I<$q = $p-E<gt>mul_root($c)>
=item I<$q = $p-E<gt>div_root($c)>
Return C<$p> multiplied by or divided by the polynomial C<x - $c> with
given coefficient C<$c>.
C<mul_root> has the effect of incorporating C<$c> as a root, ie. a zero,
in the return. C<div_root> conversely removes a root C<$c>, or if C<$c>
is not a root then the remainder from the division is discarded, the
same as for C<div>.
=cut
sub mul_root {
my ($this, $c) = @_;
# FIXME: this can be done faster by a mul and add of the coeffs
return $this->mul ($this->new(-$c,1));
}
sub div_root {
my ($this, $c) = @_;
# FIXME: this can be done faster by a mul and sub of the coeffs
return $this->div ($this->new(-$c,1));
}