Skip to content

Commit

Permalink
Add $base to exp proto, and make a version of Complex.exp which takes…
Browse files Browse the repository at this point in the history
… the $base argument.
  • Loading branch information
colomon committed Apr 24, 2010
1 parent 73e8d42 commit aa51358
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/Complex.pm
Expand Up @@ -33,6 +33,10 @@ class Complex does Numeric is Cool {
Complex.new($.re.Num.exp * $.im.Num.cos, $.re.Num.exp * $.im.Num.sin);
}

multi method exp(Complex $exponent: Numeric $base) {
$base ** $exponent;
}

multi method sin($base = Radians) {
$.re.sin($base) * $.im.cosh($base) + ($.re.cos($base) * $.im.sinh($base))i;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Cool-num.pm
Expand Up @@ -168,7 +168,7 @@ augment class Cool {
proto sub abs($x) { $x.abs }
multi sub prefix:<abs>($x) { $x.abs }
proto sub sign($x) { $x.sign }
proto sub exp($exponent) { $exponent.exp }
proto sub exp($exponent, $base = e) { $exponent.exp($base) }
proto sub log($x, $base = e) { $x.log($base) }
proto sub log10($x) { $x.log10 }
proto sub cis($angle) { $angle.cis; }
Expand Down

0 comments on commit aa51358

Please sign in to comment.