Skip to content

Commit

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

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

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

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

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

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

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

our Num sub rand (*@args) {
die "too many arguments passed - 0 params expected" if @args;
1.rand
Expand Down
10 changes: 9 additions & 1 deletion src/setting/Complex.pm
Expand Up @@ -45,7 +45,7 @@ class Complex {
}

multi method atan($base = 'radians') {
((log(1 - (self)i) - log(1 + (self)i))i / 2)!from-radians($base);
((log(1 - (self)i) - log(1 + (self)i))i / 2)!from-radians($base);
}

multi method sec($base = 'radians') {
Expand All @@ -64,6 +64,14 @@ class Complex {
(1 / self).asin($base);
}

multi method cotan($base = 'radians') {
self.cos($base) / self.sin($base);
}

multi method acotan($base = 'radians') {
(1 / self).atan($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 @@ -64,7 +64,7 @@ class Num is also {
asinh(1/+self)!from-radians($base)
}

our Num multi method acotan($base = 'radians') is export {
our Num multi method acotan($base = 'radians') {
my $r = Q:PIR {
$N0 = self
$N1 = 1 / $N0
Expand Down Expand Up @@ -208,7 +208,7 @@ class Num is also {
};
}
our Num multi method cotan($base = 'radians') is export {
our Num multi method cotan($base = 'radians') {
my $x = self!to-radians($base);
Q:PIR {
$P0 = find_lex "$x"
Expand Down

0 comments on commit 54c4564

Please sign in to comment.