Skip to content

Commit

Permalink
tanh and atanh.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Aug 15, 2011
1 parent 9802d3e commit e8a10fb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/core/Complex.pm
Expand Up @@ -154,14 +154,14 @@ my class Complex is Numeric {
(self + sqrt(self * self - 1)).log;
}

# method tanh(Complex:D:) {
# -((Complex.new(0, 1) * self).tan)i;
# }
#
# method atanh(Complex:D:) {
# (((1 + self) / (1 - self)).log / 2);
# }
#
method tanh(Complex:D:) {
-((Complex.new(0, 1) * self).tan)i;
}

method atanh(Complex:D:) {
(((1 + self) / (1 - self)).log / 2);
}

# method sech(Complex:D:) {
# 1 / self.cosh;
# }
Expand Down
2 changes: 2 additions & 0 deletions src/core/Cool.pm
Expand Up @@ -21,6 +21,8 @@ my class Cool {
method asinh() { self.Numeric.asinh }
method cosh() { self.Numeric.cosh }
method acosh() { self.Numeric.acosh }
method tanh() { self.Numeric.tanh }
method atanh() { self.Numeric.atanh }

## string methods

Expand Down
4 changes: 4 additions & 0 deletions src/core/Num.pm
Expand Up @@ -154,6 +154,10 @@ my class Num {
multi method tanh(Num:D: ) {
nqp::p6box_n(pir::tanh__NN(nqp::unbox_n(self)));
}
proto method atanh(|$) {*}
multi method atanh(Num:D: ) {
((1 + self) / (1 - self)).log / 2;
}
proto method sech(|$) {*}
multi method sech(Num:D: ) {
nqp::p6box_n(pir::sech__NN(nqp::unbox_n(self)));
Expand Down
8 changes: 8 additions & 0 deletions src/core/Numeric.pm
Expand Up @@ -116,6 +116,14 @@ proto sub acosh(|$) {*}
multi sub acosh(Numeric \$x) { $x.acosh }
multi sub acosh(Cool \$x) { $x.Numeric.acosh }

proto sub tanh(|$) {*}
multi sub tanh(Numeric \$x) { $x.tanh }
multi sub tanh(Cool \$x) { $x.Numeric.tanh }

proto sub atanh(|$) {*}
multi sub atanh(Numeric \$x) { $x.atanh }
multi sub atanh(Cool \$x) { $x.Numeric.atanh }

proto sub sqrt(|$) {*}
multi sub sqrt(Numeric \$x) { $x.sqrt }
multi sub sqrt(Cool \$x) { $x.Numeric.sqrt }
Expand Down

0 comments on commit e8a10fb

Please sign in to comment.