2 from timeit
import default_timer
as clock
3 from sympy
import Symbol
, Add
, Mul
, Integer
, ADD
, MUL
, POW
, INTEGER
, SYMBOL
, \
4 multinomial_coefficients
31 #t_tot1 = clock()-t_tot1
43 a
= multinomial_coefficients(4, N
)
44 b
= multinomial_coefficients(4, 2*N
)
45 t_mul
= clock() - t_mul
48 #print "a1 == a2: ", a1 == a2
49 #print "hash(a1) == hash(a2)", hash(a1) == hash(a2)
51 print "# of terms:", len(a2
.args
)
52 print "time spent doing e+e2:", t
53 print "time doing multinomial_coefficients:", t_mul
54 #print "total time1:", t_tot1
55 print "total time2:", t_tot
61 return sympy
.Add(*[csympy2sympy(x
) for x
in a
.args
])
63 return sympy
.Mul(*[csympy2sympy(x
) for x
in a
.args
])
65 return sympy
.Pow(*[csympy2sympy(x
) for x
in a
.args
])
66 elif a
.type == INTEGER
:
67 return sympy
.sympify(str(a
))
68 elif a
.type == SYMBOL
:
69 return sympy
.sympify(str(a
))
71 raise NotImplementedError("sorry")
73 #e_sympy = csympy2sympy(e)
74 #a2_sympy = doit2(e_sympy)[0]
75 #a2_csympy = csympy2sympy(a2)
76 #print "comparison with sympy:"
77 #print a2_sympy == a2_csympy