Skip to content

Commit

Permalink
be smarter about NaN/Inf in roots()
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Lenz committed Sep 30, 2009
1 parent 65af3ca commit 3566baf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/setting/Complex.pm
Expand Up @@ -62,7 +62,9 @@ class Complex {
multi method roots($n is copy) {
my ($mag, $angle) = @.polar;
return NaN if $n < 1;
return NaN if $n < 1;
return self if $n == 1;
return NaN if $!re|$!im ~~ Inf|NaN|-Inf;
$n = $n.Int;
$mag **= 1/$n;
(^$n).map: { $mag.unpolar( ($angle + $_ * 2 * pi) / $n) };
Expand Down

0 comments on commit 3566baf

Please sign in to comment.