Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
cosh and acosh.
  • Loading branch information
colomon committed Aug 15, 2011
1 parent 89a2cda commit 9802d3e
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 @@ -146,14 +146,14 @@ my class Complex is Numeric {
(self + sqrt(1 + self * self)).log;
}

# method cosh(Complex:D:) {
# (Complex.new(0, 1) * self).cos;
# }
#
# method acosh(Complex:D:) {
# ($x + sqrt(self * self - 1)).log;
# }
#
method cosh(Complex:D:) {
(Complex.new(0, 1) * self).cos;
}

method acosh(Complex:D:) {
(self + sqrt(self * self - 1)).log;
}

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

## string methods

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

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

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

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

0 comments on commit 9802d3e

Please sign in to comment.