File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -1568,12 +1568,35 @@ public double count(double value) {
1568
1568
@ GenerateNodeFactory
1569
1569
public abstract static class AsinhNode extends MathDoubleUnaryBuiltinNode {
1570
1570
1571
+ private static final double LN_2 = 6.93147180559945286227e-01 ;
1572
+ private static final double TWO_POW_P28 = 0x1.0p28 ;
1573
+ private static final double TWO_POW_M28 = 0x1.0p-28 ;
1574
+
1571
1575
@ Override
1576
+ @ TruffleBoundary
1572
1577
public double count (double value ) {
1573
- if (Double .isInfinite (value )) {
1578
+ double absx = Math .abs (value );
1579
+
1580
+ if (Double .isNaN (value ) || Double .isInfinite (value )) {
1581
+ return value + value ;
1582
+ }
1583
+ if (absx < TWO_POW_M28 ) {
1574
1584
return value ;
1575
1585
}
1576
- return Math .log (value + Math .sqrt (value * value + 1.0 ));
1586
+ double w ;
1587
+ if (absx > TWO_POW_P28 ) {
1588
+ w = Math .log (absx ) + LN_2 ;
1589
+ } else if (absx > 2.0 ) {
1590
+ w = Math .log (2.0 * absx + 1.0 / (Math .sqrt (value * value + 1.0 ) + absx ));
1591
+ } else {
1592
+ double t = value * value ;
1593
+ w = Math .log1p (absx + t / (1.0 + Math .sqrt (1.0 + t )));
1594
+ }
1595
+ return Math .copySign (w , value );
1596
+ }
1597
+
1598
+ public static AsinhNode create () {
1599
+ return MathModuleBuiltinsFactory .AsinhNodeFactory .create ();
1577
1600
}
1578
1601
}
1579
1602
You can’t perform that action at this time.
0 commit comments