Skip to content

Commit

Permalink
Full support for Complex sech and asech.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Oct 3, 2009
1 parent d5b578b commit 396f318
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 @@ -126,7 +126,7 @@ class Any is also {
self.Num.tanh($base);
}

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

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

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

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

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

multi sub asech($x, $base = 'radians') {
$x.asech($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 @@ -96,6 +96,14 @@ class Complex {
(((1 + self) / (1 - self)).log / 2)!from-radians($base);
}

multi method sech($base = 'radians') {
1 / self.cosh($base);
}

multi method asech($base = 'radians') {
(1 / self).acosh($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 @@ -96,7 +96,7 @@ class Num is also {
$r!from-radians($base)
}
our Num multi method asech($base = 'radians') is export {
our Num multi method asech($base = 'radians') {
my $r = Q:PIR {
$N0 = self
$N1 = neg $N0
Expand Down Expand Up @@ -260,7 +260,7 @@ class Num is also {
}
}

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

0 comments on commit 396f318

Please sign in to comment.