Skip to content

Commit

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

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

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

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

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

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

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

our Num sub rand (*@args) {
die "too many arguments passed - 0 params expected" if @args;
1.rand
Expand Down
8 changes: 8 additions & 0 deletions src/setting/Complex.pm
Expand Up @@ -80,6 +80,14 @@ class Complex {
(self + sqrt(1 + self * self)).log!from-radians($base);
}

multi method cosh($base = 'radians') {
(1i * self).cos($base);
}

multi method acosh($base = 'radians') {
(self + sqrt(self * self - 1)).log!from-radians($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 @@ -34,7 +34,7 @@ class Num is also {
$r!from-radians($base)
}

our Num multi method acosh($base = 'radians') is export {
our Num multi method acosh($base = 'radians') {
my $r = Q:PIR {
$N0 = self
$N1 = $N0 * $N0
Expand Down Expand Up @@ -176,7 +176,7 @@ class Num is also {
};
}

our Num multi method cosh($base = 'radians') is export {
our Num multi method cosh($base = 'radians') {
my $x = self!to-radians($base);
Q:PIR {
$P0 = find_lex "$x"
Expand Down

0 comments on commit fc29434

Please sign in to comment.