Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Full support for Complex cos and acos.
  • Loading branch information
colomon committed Oct 2, 2009
1 parent c4dbb59 commit a7d2a98
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/setting/Any-num.pm
Expand Up @@ -93,7 +93,7 @@ class Any is also {
self.Num.sin($base);
}

our Num multi method cos($base = 'radians') is export {
our Num multi method cos($base = 'radians') {
self.Num.cos($base);
}

Expand Down Expand Up @@ -142,7 +142,7 @@ class Any is also {
self.Num.asin($base);
}

our Num multi method acos($base = 'radians') is export {
our Num multi method acos($base = 'radians') {
self.Num.acos($base);
}

Expand Down Expand Up @@ -204,6 +204,14 @@ multi sub asin($x, $base = 'radians') {
$x.asin($base)
}

multi sub cos($x, $base = 'radians') {
$x.cos($base)
}

multi sub acos($x, $base = 'radians') {
$x.acos($base)
}

our Num sub rand (*@args) {
die "too many arguments passed - 0 params expected" if @args;
1.rand
Expand Down
4 changes: 4 additions & 0 deletions src/setting/Complex.pm
Expand Up @@ -36,6 +36,10 @@ class Complex {
$.re.cos($base) * $.im.cosh($base) - ($.re.sin($base) * $.im.sinh($base))i;
}

multi method acos($base = 'radians') {
(pi / 2)!from-radians($base) - self.asin($base);
}

multi method log() {
Q:PIR {
$P0 = get_root_namespace ['parrot'; 'Complex' ]
Expand Down
4 changes: 2 additions & 2 deletions src/setting/Num.pm
Expand Up @@ -25,7 +25,7 @@ class Num is also {
};
}
our Num multi method acos($base = 'radians') is export {
our Num multi method acos($base = 'radians') {
my $r = Q:PIR {
$N0 = self
$N1 = acos $N0
Expand Down Expand Up @@ -166,7 +166,7 @@ class Num is also {
$r!from-radians($base)
}
our Num multi method cos($base = 'radians') is export {
our Num multi method cos($base = 'radians') {
my $x = self!to-radians($base);
Q:PIR {
$P0 = find_lex "$x"
Expand Down

0 comments on commit a7d2a98

Please sign in to comment.