"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mpmath/tests/test_eigen_symmetric.py" between
mpmath-0.19.tar.gz and mpmath-1.0.0.tar.gz

About: mpmath is a Python library for arbitrary-precision floating-point arithmetic.

test_eigen_symmetric.py  (mpmath-0.19):test_eigen_symmetric.py  (mpmath-1.0.0)
skipping to change at line 323 skipping to change at line 323
a = [ -2.02018287, -0.958572465, 0, 0.958572465, 2.02018287] a = [ -2.02018287, -0.958572465, 0, 0.958572465, 2.02018287]
b = [ 0.01995324, 0.39361932, 0.94530872, 0.39361932, 0.01995324] b = [ 0.01995324, 0.39361932, 0.94530872, 0.39361932, 0.01995324]
run_gauss("hermite", a , b) run_gauss("hermite", a , b)
a = [ 0.41577456, 2.29428036, 6.28994508] a = [ 0.41577456, 2.29428036, 6.28994508]
b = [ 0.71109301, 0.27851773, 0.01038926] b = [ 0.71109301, 0.27851773, 0.01038926]
run_gauss("laguerre", a , b) run_gauss("laguerre", a , b)
def test_gauss_quadrature_dynamic(verbose = False): def test_gauss_quadrature_dynamic(verbose = False):
n = 5 n = 5
A = mp.randmatrix(2 * n, 1) A = mp.randmatrix(2 * n, 1)
def F(x): def F(x):
r = 0 r = 0
for i in xrange(len(A) - 1, -1, -1): for i in xrange(len(A) - 1, -1, -1):
r = r * x + A[i] r = r * x + A[i]
return r return r
def run(qtype, FW, R, alpha = 0, beta = 0): def run(qtype, FW, R, alpha = 0, beta = 0):
X, W = mp.gauss_quadrature(n, qtype, alpha = alpha, beta = beta) X, W = mp.gauss_quadrature(n, qtype, alpha = alpha, beta = beta)
a = 0 a = 0
for i in xrange(len(X)): for i in xrange(len(X)):
a += W[i] * F(X[i]) a += W[i] * F(X[i])
b = mp.quad(lambda x: FW(x) * F(x), R) b = mp.quad(lambda x: FW(x) * F(x), R)
c = mp.fabs(a - b) c = mp.fabs(a - b)
if verbose: if verbose:
print(qtype, c, a, b) print(qtype, c, a, b)
assert c < 1e-5 assert c < 1e-5
run("legendre", lambda x: 1, [-1, 1]) run("legendre", lambda x: 1, [-1, 1])
run("legendre01", lambda x: 1, [0, 1]) run("legendre01", lambda x: 1, [0, 1])
run("hermite", lambda x: mp.exp(-x*x), [-mp.inf, mp.inf]) run("hermite", lambda x: mp.exp(-x*x), [-mp.inf, mp.inf])
run("laguerre", lambda x: mp.exp(-x), [0, mp.inf]) run("laguerre", lambda x: mp.exp(-x), [0, mp.inf])
run("glaguerre", lambda x: mp.sqrt(x)*mp.exp(-x), [0, mp.inf], alpha = 1 / mp. run("glaguerre", lambda x: mp.sqrt(x)*mp.exp(-x), [0, mp.inf], alpha = 1 / m
mpf(2)) p.mpf(2))
run("chebyshev1", lambda x: 1/mp.sqrt(1-x*x), [-1, 1]) run("chebyshev1", lambda x: 1/mp.sqrt(1-x*x), [-1, 1])
run("chebyshev2", lambda x: mp.sqrt(1-x*x), [-1, 1]) run("chebyshev2", lambda x: mp.sqrt(1-x*x), [-1, 1])
run("jacobi", lambda x: (1-x)**(1/mp.mpf(3)) * (1+x)**(1/mp.mpf(5)), [-1, 1], run("jacobi", lambda x: (1-x)**(1/mp.mpf(3)) * (1+x)**(1/mp.mpf(5)), [-1, 1]
alpha = 1 / mp.mpf(3), beta = 1 / mp.mpf(5) ) , alpha = 1 / mp.mpf(3), beta = 1 / mp.mpf(5) )
 End of changes. 10 change blocks. 
17 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)