s + t def test_sub(): """subtraction of complexes, 64x""" for s in numbers: for t in numbers: s - t def test_mul(): """multiplication of complexes, 64x""" for s in numbers: for t in numbers: s * t def test_div(): """division of complexes, 64x""" for s in numbers: for t in numbers: s / t def test_pow(): """complex integer power, 64x""" for s in numbers: for t in intnumbers: s ** t if __name__=='__main__': from func_timeit import run_tests run_tests([test_add, test_sub, test_mul, test_div, test_pow])
n -= 1 def test_sum4(): """ sum(x**i/i,i=1..4), 100x """ n = 100 while n: s = 0 i = 4 while i: s += x**i/i i -= 1 n -= 1 def test_inplace_sum4(): """ Add(x**i/i,i=1..4), 100x """ n = 100 while n: Add(*[x**i/i for i in xrange(1,5)]) n -= 1 if __name__=='__main__': from func_timeit import run_tests run_tests([test_sum, test_inplace_sum, test_sum40, test_inplace_sum40, test_sum4, test_inplace_sum4, test_negsum ])
"""division of small fractions and integers, 64x""" for s in numbers: for t in numbers: s / t def test_pow(): """powers of small fractions and integers, 64x""" for s in numbers: for t in numbers: s ** t def test_mixed_symbolic(): """Mixed arithmetic with symbols and small integers / fractions""" a+x; a+x+b; a+x+x+x; a+x+b+x+c; a+x+x+b+x+c; b+x; b+x+c; b+x+x+x; b+x+c+x+d; b+x+x+c+x+d; c+x; c+x+b; c+x+x+x; c+x+d+x+e; c+x+x+d+x+e; d+x; d+x+c; d+x+x+x; d+x+e+x+f; d+x+x+e+x+f; a*x a*x*a a*x + b*x a*x - b*x a*x + b*x - a*x - b*x a*x**2 + a*x + b*x**2 - a*x**2 - b*x**2 x/a + x/b + x/c x/e + x/f + x/g if __name__=='__main__': from func_timeit import run_tests run_tests([test_compare, test_equality, test_add, test_sub, test_mul, test_div, test_pow, test_mixed_symbolic])
def test_compare_ne1(): """ not not (s1 == s2), s1 = expand((x+y+z)**10), s2 = expand((x+y+w)**10), 20x """ n = 20 while n: not not (s1 == s2) n -= 1 def test_compare_ne2(): """ not not (s1 == 1), s1 = expand((x+y+z)**10), 20x """ n = 20 while n: not not (s1 == 1) n -= 1 def test_compare_is(): """ not not (s1 is s1), s1 = expand((x+y+z)**10), 20x """ n = 20 while n: not not (s1 is s1) n -= 1 if __name__=='__main__': from func_timeit import run_tests run_tests([test_hash, test_compare_eq1, test_compare_eq2, test_compare_eq3, test_compare_ne1, test_compare_ne2, test_compare_is])
quad8.expand() def test_high_3(): """Expand large (1+x+y+z+a+b+c)**3""" high3.expand() def test_mixed_1(): """Expand small mixed products, 8x""" mixed1.expand(); mixed1.expand(); mixed1.expand() mixed2.expand(); mixed2.expand(); mixed3.expand() mixed4.expand() mixed5.expand() def test_mixed_2(): """Expand large mixed product""" mixed6.expand() def test_nested(): """Expand deeply nested expression""" nested.expand() if __name__=='__main__': from func_timeit import run_tests run_tests([ test_bin_1, test_bin_2, test_bin_3, test_quad_1, test_quad_2, test_mixed_1, test_mixed_2, test_nested, test_high_3 ])
while i: ff = ff.integrate(x) i -= 1 def test_integrate_defined1(f1=f1): """ f.integrate((x,2,3)), 100x, f=4*x**3+sin(y)**2*x**2+x+1 """ i = 100 while i: f = f1.integrate((x, 2, 3)) i -= 1 def test_integrate_defined2(f1=f1): """ r=f.integrate(x); r.subs(x,3)-r.subs(x,2), 100x, f=4*x**3+sin(y)**2*x**2+x+1 """ i = 100 while i: f = f1.integrate(x) f = f.subs(x, 3) - f.subs(x, 2) i -= 1 if __name__ == '__main__': from func_timeit import run_tests run_tests([ test_diff1, test_diff2, test_integrate, test_integrate_defined1, test_integrate_defined2 ])
""" n = 101 while n: n -= 1 Mul(x,n,y) def test_Mul2(): """ x*i*y, i=0..100 """ n = 101 while n: n -= 1 x * n * y def test_Div2(): """ x/i/y, i=0..100 """ n = 101 while n: n -= 1 x / n / y if __name__=='__main__': from func_timeit import run_tests run_tests([test_Add, test_Add2, test_Sub2, test_Mul, test_Mul2, test_Div2, test_directadd5])
from sympycore import Symbol, Number x,y,z = map(Symbol,'xyz') e1 = ((x+2*y+3*z)**50).expand() e2 = ((x+2*y+3*z)**2).expand() #print len(e1.data)/len(e2.data) -> 221 def test_long(): """str(e), e = expand((x+2*y+3*z)**50)""" str(e1) def test_short(): """str(e), e = expand((x+2*y+3*z)**2), 221x""" n = 221 while n: n -= 1 str(e2) if __name__=='__main__': from func_timeit import run_tests run_tests([test_long, test_short])
cos(n*pi/6) e = 2 + 3*I def test_complex_power(): """ evaluate (2+3*I)**1000, 10x """ n = 10 while n: n -= 1 e ** 1000 re = 2 + 3*I/4 def test_rat_complex_power(): """ evaluate (2+3/4*I)**1000, 1x """ re ** 1000 def test_inverse_complex(): """ evaluate 1/(2+3/4*I), 100x """ n = 100 while n: n -= 1 1/re if __name__=='__main__': from func_timeit import run_tests run_tests([test_sin, test_cos, test_complex_power, test_rat_complex_power, test_inverse_complex])
def test_neg(): """Negate a 15x20 random dense matrix.""" -a def test_add(): """Add two 15x20 random dense matricies.""" a + b def test_sub(): """Substract two 15x20 random dense matricies.""" a - b def test_mul_coeff(): """Multiply 15x20 random dense matrix with a number.""" a * 3 def test_div_coeff(): """Divide 15x20 random dense matrix with a number.""" a / 3 def test_add_sparse(): """Add two 15x20 random sparse int matricies.""" c + d if __name__=='__main__': from func_timeit import run_tests run_tests([test_neg, test_add, test_sub, test_mul_coeff, test_div_coeff, test_add_sparse])
from sympycore import Symbol, Number x, y, z = map(Symbol, 'xyz') e1 = ((x + 2 * y + 3 * z)**50).expand() e2 = ((x + 2 * y + 3 * z)**2).expand() #print len(e1.data)/len(e2.data) -> 221 def test_long(): """str(e), e = expand((x+2*y+3*z)**50)""" str(e1) def test_short(): """str(e), e = expand((x+2*y+3*z)**2), 221x""" n = 221 while n: n -= 1 str(e2) if __name__ == '__main__': from func_timeit import run_tests run_tests([test_long, test_short])
""" f = f.integrate(), 100x, f=4*x**3+sin(y)**2*x**2+x+1 """ i = 100 ff = f1 while i: ff = ff.integrate(x) i -= 1 def test_integrate_defined1(f1=f1): """ f.integrate((x,2,3)), 100x, f=4*x**3+sin(y)**2*x**2+x+1 """ i = 100 while i: f = f1.integrate((x, 2, 3)) i -= 1 def test_integrate_defined2(f1=f1): """ r=f.integrate(x); r.subs(x,3)-r.subs(x,2), 100x, f=4*x**3+sin(y)**2*x**2+x+1 """ i = 100 while i: f = f1.integrate(x) f = f.subs(x, 3) - f.subs(x, 2) i -= 1 if __name__=='__main__': from func_timeit import run_tests run_tests([test_diff1, test_diff2, test_integrate, test_integrate_defined1, test_integrate_defined2 ])