Skip to content

Commit

Permalink
Add log with $base functions.
Browse files Browse the repository at this point in the history
Kodi++ for providing initial implementation.
  • Loading branch information
colomon committed Jan 5, 2010
1 parent db84bc0 commit 3867ffd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
13 changes: 11 additions & 2 deletions src/setting/Any-num.pm
Expand Up @@ -79,6 +79,14 @@ class Any is also {
$.Num.log();
}
multi method log($base) {
$.Num.log($base);
}
multi method log10() {
$.Num.log10();
}
our multi method !from-radians($base) {
given $base {
when /:i ^d/ { self * 180/pi } # Convert to degrees.
Expand Down Expand Up @@ -193,8 +201,9 @@ class Any is also {

multi sub abs($x) { $x.abs() }
multi sub exp($x) { $x.Num.exp() }
multi sub log($x) { $x.Num.log() }
multi sub log10($x) { $x.Num.log10 }
multi sub log($x) { $x.log() }
multi sub log($x, $base) { $x.log($base) }
multi sub log10($x) { $x.log10 }

# jnthn says that we should have both the multi sub declaration and the proto.

Expand Down
12 changes: 4 additions & 8 deletions src/setting/Complex.pm
Expand Up @@ -147,6 +147,10 @@ class Complex {
}
}
multi method log($base) {
$.log / $base.log;
}
multi method log10() {
$.log / 10.log;
}
Expand Down Expand Up @@ -300,14 +304,6 @@ multi sub infix:<**>($a, Complex $b) {
($a.log * $b).exp;
}

multi sub log(Complex $x) {
$x.log()
}

multi sub log10(Complex $x) {
$x.log10;
}

multi sub sign(Complex $x) { $x.sign }

multi sub sqrt(Complex $x) {
Expand Down
4 changes: 4 additions & 0 deletions src/setting/Num.pm
Expand Up @@ -238,6 +238,10 @@ class Num is also {
}
}

multi method log($base) {
$.log / $base.log;
}

our method log10 {
Q:PIR {
$N0 = self
Expand Down

0 comments on commit 3867ffd

Please sign in to comment.