Permalink
Browse files

Add log1p.

  • Loading branch information...
1 parent 664c87c commit 15c5b2620648629705d2e0f648bdfa51b2ed9079 @colomon colomon committed Oct 13, 2012
Showing with 21 additions and 0 deletions.
  1. +19 −0 lib/Builtins.cs
  2. +2 −0 lib/CORE.setting
View
19 lib/Builtins.cs
@@ -1069,6 +1069,25 @@ public partial class Builtins {
}
}
+ static readonly Func<Constants,Variable,Variable> log1p_d = log1p;
+ [ImplicitConsts] public static Variable log1p(Constants c, Variable a1) {
+ P6any o1 = a1.Fetch();
+ int r1;
+ if (!o1.mo.is_any)
+ return HandleSpecial1(c, a1,o1, log1p_d);
+ P6any n1 = GetNumber(a1, o1, out r1);
+
+// if (r1 == NR_COMPLEX) {
+// Complex v1 = PromoteToComplex(r1, n1);
+// return MakeComplex(Math.Exp(v1.re) * Math.Cos(v1.im),
+// Math.Exp(v1.re) * Math.Sin(v1.im));
+// }
+ {
+ double v1 = PromoteToFloat(r1, n1);
+ return MakeFloat(SpecialMathFunctions.SpecialFunctions.LogOnePlusX(v1));
+ }
+ }
+
static readonly Func<Constants,Variable,Variable,Variable> atan2_d = atan2;
[ImplicitConsts] public static Variable atan2(Constants c, Variable a1, Variable a2) {
P6any o1 = a1.Fetch();
View
2 lib/CORE.setting
@@ -494,6 +494,7 @@ my class Cool {
method gamma() { Q:CgOp { (gamma {self}) } }
method lgamma() { Q:CgOp { (lgamma {self}) } }
method expm1() { Q:CgOp { (expm1 {self}) } }
+ method log1p() { Q:CgOp { (log1p {self}) } }
method split($matcher, $limit?, :$all?) {
my $matchrx = (($matcher ~~ Regex) ?? $matcher !! /$matcher/);
@@ -3867,6 +3868,7 @@ sub hypot($a, $b) is pure {
sub gamma($x) is pure { $x.gamma }
sub lgamma($x) is pure { $x.lgamma }
sub expm1($x) is pure { $x.expm1 }
+sub log1p($x) is pure { $x.log1p }
sub expmod($exp, $power, $mod) is pure { Q:CgOp { (expmod {$exp.Int} {$power.Int} {$mod.Int}) } }
sub is-prime($candidate, $tries = 100) {

0 comments on commit 15c5b26

Please sign in to comment.