Skip to content

Commit

Permalink
Full support for Complex sinh and asinh.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Oct 2, 2009
1 parent 54c4564 commit 16a2810
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 @@ -114,7 +114,7 @@ class Any is also {
self.Num.cotan($base);
}

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

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

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

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

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

multi sub asinh($x, $base = 'radians') {
$x.asinh($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 @@ -72,6 +72,14 @@ class Complex {
(1 / self).atan($base);
}

multi method sinh($base = 'radians') {
-((1i * self).sin($base))i;
}

multi method asinh($base = 'radians') {
(self + sqrt(1 + self * self)).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 @@ -120,7 +120,7 @@ class Num is also {
$r!from-radians($base)
}
our Num multi method asinh($base = 'radians') is export {
our Num multi method asinh($base = 'radians') {
my $r = Q:PIR {
$N0 = self
$N1 = $N0 * $N0
Expand Down Expand Up @@ -280,7 +280,7 @@ class Num is also {
}
}

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

0 comments on commit 16a2810

Please sign in to comment.