Math-Yapp
view release on metacpan or search on metacpan
lib/Math/Yapp.pm view on Meta::CPAN
elsif ( ($added =~ m/^($coef_pat)$/)
|| (ref($added) eq $class_cplx) ) # Adding real or complex const
{
# As above: If the target term is defined, add the new term.
# Otherwise, set the target term to the given value
#
if (defined($self->{coeff}[0])) {$self->{coeff}[0] += $added;}
else {$self->{coeff}[0] = $added;}
} # (Just needed to augment the constant term)
else
{ die "Operator += requires a constant or a Yapp polynomial reference";}
# Didn't die - I have a good value to return
#
return ($self); # (Ought to return something)
}
#------------------------------------------------------------------------------
# Yapp_add() - Function (and overloaded + operator) to add two polynomials.
# Parameters:
# - (Implicit) The polynomial on the left side of the + (self)
lib/Math/Yapp.pm view on Meta::CPAN
} # End loop multiplying one target term by term from multiplier
} # End loop multiplying whole polynomials
# Done multiplication: Now put it back in place
#
$self->{degree} = $new_degree; # Copy back degree of multiplied target Yapp
@{$self->{coeff}} = @builder; # and copy back array where we carried
# out the multiplication.
} # All done multiplying Yapps; product is in place
else # No more permitted possibilities
{ die "Operator *= requires a constant or a Yapp polynomial reference";}
# Afterthought: I have found that when I multiply two poly's with conjugate
# complex constant terms, the result will include coefficients like like
# (30.00+0.00i); which is a real, of course, but doesn't look that way.
# Here's the fix:
#
realify(\@{$self->{coeff}});
return $self;
}
#
( run in 0.411 second using v1.01-cache-2.11-cpan-05444aca049 )