Merge pull request #433 from skirpichev/fix-more-defun

Fix more broken defun decorators, amend ef75979
This commit is contained in:
Fredrik Johansson
2019-02-04 11:46:56 +01:00
committed by GitHub
4 changed files with 7 additions and 5 deletions
+1
View File
@@ -3,3 +3,4 @@ class CalculusMethods(object):
def defun(f):
setattr(CalculusMethods, f.__name__, f)
return f
+1 -1
View File
@@ -117,7 +117,7 @@ def polyroots(ctx, coeffs, maxsteps=50, cleanup=True, extraprec=10,
>>> mp.dps = 60
>>> for r in polyroots([1, 0, -10, 0, 1]):
... print r
... print(r)
...
-3.14626436994197234232913506571557044551247712918732870123249
-0.317837245195782244725757617296174288373133378433432554879127
+1
View File
@@ -40,6 +40,7 @@ class Eigen(object):
def defun(f):
setattr(Eigen, f.__name__, f)
return f
def hessenberg_reduce_0(ctx, A, T):
"""
+4 -4
View File
@@ -783,16 +783,16 @@ def gauss_quadrature(ctx, n, qtype = "legendre", alpha = 0, beta = 0):
>>> A = mp.fdot([(f(x), w) for x, w in zip(X, W)])
>>> B = mp.sqrt(mp.pi) * 57 / 16
>>> C = mp.quad(lambda x: mp.exp(- x * x) * f(x), [-mp.inf, +mp.inf])
>>> print mp.chop(A-B, tol = 1e-10), mp.chop(A-C, tol = 1e-10)
0.0 0.0
>>> mp.nprint((mp.chop(A-B, tol = 1e-10), mp.chop(A-C, tol = 1e-10)))
(0.0, 0.0)
>>> f = lambda x: x**5 - 2 * x**4 + 3 * x**3 - 5 * x**2 + 7 * x - 11
>>> X, W = mp.gauss_quadrature(3, "laguerre")
>>> A = mp.fdot([(f(x), w) for x, w in zip(X, W)])
>>> B = 76
>>> C = mp.quad(lambda x: mp.exp(-x) * f(x), [0, +mp.inf])
>>> print mp.chop(A-B, tol = 1e-10), mp.chop(A-C, tol = 1e-10)
0.0 0.0
>>> mp.nprint(mp.chop(A-B, tol = 1e-10), mp.chop(A-C, tol = 1e-10))
.0
# orthogonality of the chebyshev polynomials:
>>> f = lambda x: mp.chebyt(3, x) * mp.chebyt(2, x)