File tree 4 files changed +37
-1
lines changed
4 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -331,6 +331,7 @@ RUN(NAME test_builtin_divmod LABELS cpython llvm c)
331
331
RUN(NAME test_builtin_sum LABELS cpython llvm c)
332
332
RUN(NAME test_math1 LABELS cpython llvm c)
333
333
RUN(NAME test_math_02 LABELS cpython llvm)
334
+ RUN(NAME test_math_03 LABELS llvm) #1595: TODO: Test using CPython (3.11 recommended)
334
335
RUN(NAME test_pass_compare LABELS cpython llvm c)
335
336
RUN(NAME test_c_interop_01 LABELS cpython llvm c)
336
337
RUN(NAME test_c_interop_02 LABELS cpython llvm c
Original file line number Diff line number Diff line change @@ -60,7 +60,6 @@ def test_exp():
60
60
i = exp (2.34 )
61
61
assert abs (i - 10.381236562731843 ) < eps
62
62
63
-
64
63
def test_pow ():
65
64
eps : f64
66
65
eps = 1e-12
Original file line number Diff line number Diff line change
1
+ from math import (cbrt , exp2 )
2
+ from ltypes import f64
3
+
4
+ eps : f64
5
+ eps = 1e-12
6
+
7
+ def test_exp2 ():
8
+ i : f64
9
+ i = exp2 (4.3 )
10
+ assert abs (i - 19.698310613518657 ) < eps
11
+
12
+ def test_cbrt ():
13
+ eps : f64 = 1e-12
14
+ assert abs (cbrt (124.0 ) - 4.986630952238646 ) < eps
15
+ assert abs (cbrt (39.0 ) - 3.3912114430141664 ) < eps
16
+
17
+ def check ():
18
+ test_cbrt ()
19
+ test_exp2 ()
20
+
21
+ check ()
Original file line number Diff line number Diff line change @@ -465,6 +465,12 @@ def exp(x: f64) -> f64:
465
465
"""
466
466
return e ** x
467
467
468
+ def exp2 (x : f64 ) -> f64 :
469
+ """
470
+ Return `2` raised to the power `x`.
471
+ """
472
+ return f64 ((2.0 )** x )
473
+
468
474
469
475
def mod (a : i32 , b : i32 ) -> i32 :
470
476
"""
@@ -540,8 +546,17 @@ def trunc(x: f32) -> i32:
540
546
return ceil (x )
541
547
542
548
def sqrt (x : f64 ) -> f64 :
549
+ """
550
+ Returns square root of a number x
551
+ """
543
552
return x ** (1 / 2 )
544
553
554
+ def cbrt (x : f64 ) -> f64 :
555
+ """
556
+ Returns cube root of a number x
557
+ """
558
+ return x ** (1 / 3 )
559
+
545
560
@ccall
546
561
def _lfortran_dsin (x : f64 ) -> f64 :
547
562
pass
You can’t perform that action at this time.
0 commit comments