Make Pow able not to sympify.
[sympyx.git] / t.py
blob28a072133ae90a3ca403abb36dd2e9d6153264c7
1 #!/usr/bin/env python
2 from timeit import default_timer as clock
3 from sympy import Symbol, Add, Mul, Integer, multinomial_coefficients
5 N = 10
7 x = Symbol("x")
8 y = Symbol("y")
9 z = Symbol("z")
11 def doit1(e):
12 f = e*(e+1)
13 f = f.expand()
14 return f
16 e = (x+y+z+1)**N
18 t_tot = clock()
19 a2 = doit1(e)
20 t_tot = clock()-t_tot
22 print "done"
24 t_mul = clock()
25 a= multinomial_coefficients(4, N)
26 b= multinomial_coefficients(4, 2*N)
27 a.items()
28 b.items()
29 t_mul = clock() - t_mul
30 print e
31 print "# of terms:", len(a2.args)
32 print "time doing multinomial_coefficients:", t_mul
33 print "total time2:", t_tot
35 #from sympy import ADD, MUL, POW, INTEGER, SYMBOL
37 #def csympy2sympy(a):
38 # import sympy
39 # if a.type == ADD:
40 # return sympy.Add(*[csympy2sympy(x) for x in a.args])
41 # elif a.type == MUL:
42 # return sympy.Mul(*[csympy2sympy(x) for x in a.args])
43 # elif a.type == POW:
44 # return sympy.Pow(*[csympy2sympy(x) for x in a.args])
45 # elif a.type == INTEGER:
46 # return sympy.sympify(str(a))
47 # elif a.type == SYMBOL:
48 # return sympy.sympify(str(a))
49 # print a
50 # raise NotImplementedError("sorry")
52 #e_sympy = csympy2sympy(e)
53 #a2_sympy = doit2(e_sympy)[0]
54 #a2_csympy = csympy2sympy(a2)
55 #print "comparison with sympy:"
56 #print a2_sympy == a2_csympy