File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -602,6 +602,7 @@ RUN(NAME symbolics_01 LABELS cpython_sym c_sym)
602602RUN(NAME symbolics_02 LABELS cpython_sym c_sym)
603603RUN(NAME symbolics_03 LABELS cpython_sym c_sym)
604604RUN(NAME symbolics_04 LABELS cpython_sym c_sym)
605+ RUN(NAME symbolics_05 LABELS cpython_sym c_sym)
605606
606607RUN(NAME sizeof_01 LABELS llvm c
607608 EXTRAFILES sizeof_01b.c)
Original file line number Diff line number Diff line change 1+ from sympy import Symbol , expand , diff
2+ from lpython import S
3+
4+ def test_operations ():
5+ x : S = Symbol ('x' )
6+ y : S = Symbol ('y' )
7+ z : S = Symbol ('z' )
8+
9+ # test expand
10+ a : S = (x + y )** S (2 )
11+ b : S = (x + y + z )** S (3 )
12+ assert (a .expand () == S (2 )* x * y + x ** S (2 ) + y ** S (2 ))
13+ assert (expand (b ) == S (3 )* x * y ** S (2 ) + S (3 )* x * z ** S (2 ) + S (3 )* x ** S (2 )* y + S (3 )* x ** S (2 )* z + \
14+ S (3 )* y * z ** S (2 ) + S (3 )* y ** S (2 )* z + S (6 )* x * y * z + x ** S (3 ) + y ** S (3 ) + z ** S (3 ))
15+ print (a .expand ())
16+ print (expand (b ))
17+
18+ # test diff
19+ c : S = (x + y )** S (2 )
20+ d : S = (x + y + z )** S (3 )
21+ assert (c .diff (x ) == S (2 )* (x + y ))
22+ assert (diff (d , x ) == S (3 )* (x + y + z )** S (2 ))
23+ print (c .diff (x ))
24+ print (diff (d , x ))
25+
26+ test_operations ()
You can’t perform that action at this time.
0 commit comments