File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -331,6 +331,7 @@ RUN(NAME test_builtin_divmod LABELS cpython llvm c)
331331RUN (NAME test_builtin_sum LABELS cpython llvm c )
332332RUN (NAME test_math1 LABELS cpython llvm c )
333333RUN (NAME test_math_02 LABELS cpython llvm )
334+ RUN (NAME test_math_03 LABELS llvm ) #1595: TODO: Test using CPython (3.11 recommended)
334335RUN (NAME test_pass_compare LABELS cpython llvm c )
335336RUN (NAME test_c_interop_01 LABELS cpython llvm c )
336337RUN (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():
6060 i = exp (2.34 )
6161 assert abs (i - 10.381236562731843 ) < eps
6262
63-
6463def test_pow ():
6564 eps : f64
6665 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:
465465 """
466466 return e ** x
467467
468+ def exp2 (x : f64 ) -> f64 :
469+ """
470+ Return `2` raised to the power `x`.
471+ """
472+ return f64 ((2.0 )** x )
473+
468474
469475def mod (a : i32 , b : i32 ) -> i32 :
470476 """
@@ -540,8 +546,17 @@ def trunc(x: f32) -> i32:
540546 return ceil (x )
541547
542548def sqrt (x : f64 ) -> f64 :
549+ """
550+ Returns square root of a number x
551+ """
543552 return x ** (1 / 2 )
544553
554+ def cbrt (x : f64 ) -> f64 :
555+ """
556+ Returns cube root of a number x
557+ """
558+ return x ** (1 / 3 )
559+
545560@ccall
546561def _lfortran_dsin (x : f64 ) -> f64 :
547562 pass
You can’t perform that action at this time.
0 commit comments