Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
sinh and asinh.
  • Loading branch information
colomon committed Aug 15, 2011
1 parent 9e8adcc commit 4ace1ce
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/core/Complex.pm
Expand Up @@ -138,14 +138,14 @@ my class Complex is Numeric {
(1 / self).atan;
}

# method sinh(Complex:D:) {
# -((Complex.new(0, 1) * self).sin)i;
# }
#
# method asinh(Complex:D:) {
# (self + sqrt(1 + self * self)).log;
# }
#
method sinh(Complex:D:) {
-((Complex.new(0, 1) * self).sin)i;
}

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

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

## string methods

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

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

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

proto sub sqrt(|$) {*}
multi sub sqrt(Numeric \$x) { $x.sqrt }
multi sub sqrt(Cool \$x) { $x.Numeric.sqrt }
Expand Down
3 changes: 3 additions & 0 deletions src/core/Real.pm
Expand Up @@ -17,8 +17,11 @@ my class Real {
method cotan() { self.Bridge.cotan }
method acotan() { self.Bridge.acotan }
method sinh() { self.Bridge.sinh }
method asinh() { self.Bridge.asinh }
method cosh() { self.Bridge.cosh }
method acosh() { self.Bridge.acosh }
method tanh() { self.Bridge.tanh }
method atanh() { self.Bridge.atanh }
proto method atan2(|$) {*}
multi method atan2(Real $x = 1e0) { self.Bridge.atan2($x.Bridge) }
multi method atan2(Cool $x = 1e0) { self.Bridge.atan2($x.Numeric.Bridge) }
Expand Down

0 comments on commit 4ace1ce

Please sign in to comment.