Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Complex.roots
  • Loading branch information
moritz committed Sep 30, 2009
1 parent d9cbe43 commit 5159c42
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/setting/Complex.pm
Expand Up @@ -58,6 +58,12 @@ class Complex {
$.abs, atan2($.im, $.re);
}
multi method roots($n) {
my ($mag, $angle) = @.polar;
$mag **= 1/$n;
(^$n).map: { $mag.unpolar( ($angle + $_ * 2 * pi) / $n) };
}

multi method sqrt() {
Q:PIR {
$P0 = get_root_namespace ['parrot'; 'Complex' ]
Expand Down

1 comment on commit 5159c42

@leto
Copy link
Contributor

@leto leto commented on 5159c42 Sep 30, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet.

Please sign in to comment.