Skip to content

Commit

Permalink
Add Complex trig functions not currently shadowed by Parrot complex f…
Browse files Browse the repository at this point in the history
…unctions.

In particular, add Complex.cosec, Complex.cosech, Complex.acosec, Complex.cotan, Complex.cotanh, Complex.acotan, Complex.acosec, and Complex.acotanh.  Comment out implementations of Complex.sin and Complex.cos, as these are currently shadowed by Parrot functions.
  • Loading branch information
colomon committed Sep 24, 2009
1 parent 3afb78d commit 729722a
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions src/setting/Complex.pm
Expand Up @@ -103,13 +103,46 @@ multi sub infix:<**>($a, Complex $b) {
}

class Complex is also {
multi method sin($base = 'radians') {
$.re.sin($base) * $.im.cosh($base) + ($.re.cos($base) * $.im.sinh($base))i;
# multi method sin($base = 'radians') {
# $.re.sin($base) * $.im.cosh($base) + ($.re.cos($base) * $.im.sinh($base))i;
# }
#
# multi method cos($base = 'radians') {
# $.re.cos($base) * $.im.cosh($base) - ($.re.sin($base) * $.im.sinh($base))i;
# }

multi method cosec($base = 'radians') {
1.0 / self!to-radians($base).sin;
}

multi method cosech($base = 'radians') {
1.0 / self!to-radians($base).sinh;
}

multi method acosec($base = 'radians') {
(1.0 / self).asin!to-radians($base);
}

multi method cotan($base = 'radians') {
1.0 / self!to-radians($base).tan;
}
multi method cos($base = 'radians') {
$.re.cos($base) * $.im.cosh($base) - ($.re.sin($base) * $.im.sinh($base))i;

multi method cotanh($base = 'radians') {
1.0 / self!to-radians($base).tanh;
}

multi method acotan($base = 'radians') {
(1.0 / self).atan!to-radians($base);
}

multi method acosech($base = 'radians') {
(1.0 / self).asinh!to-radians($base);
}

multi method acotanh($base = 'radians') {
(1.0 / self).atanh!to-radians($base);
}

}

# vim: ft=perl6

0 comments on commit 729722a

Please sign in to comment.