Skip to content

Commit

Permalink
Provide Any.sin, Any.cos, Complex.sin, and Complex.cos.
Browse files Browse the repository at this point in the history
Passing a $base works on the Any versions, but fails mysteriously on the Complex versions.
  • Loading branch information
colomon committed Sep 6, 2009
1 parent 6e2104a commit 09b9540
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/setting/Any-num.pm
Expand Up @@ -64,6 +64,16 @@ class Any is also {
default { die "Unable to convert to base: $base" }
}
}

our Num multi method sin($base = 'radians') is export {
self.Num!to-radians($base).sin; # seems awkward, but the obvious way of doing
# this is tripping up on some wierd Rakudo-bug
}

our Num multi method cos($base = 'radians') is export {
self.Num!to-radians($base).cos; # seems awkward, but the obvious way of doing
# this is tripping up on some wierd Rakudo-bug
}
}

our Num sub rand (*@args) {
Expand Down
8 changes: 4 additions & 4 deletions src/setting/Complex.pm
Expand Up @@ -103,12 +103,12 @@ multi sub infix:<**>($a, Complex $b) {
}

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

method cos($base = 'radians') {
$.re.cos($base) * $.im.cosh($base) - 1i * $.re.sin($base) * $.im.sinh($base);
multi method cos($base = 'radians') {
$.re.cos($base) * $.im.cosh($base) - ($.re.sin($base) * $.im.sinh($base))i;
}
}

Expand Down

0 comments on commit 09b9540

Please sign in to comment.