def chebRoots(A, a=-1, b=1, ImTol=1e-6, im=False): D = np_cheb.chebcompanion(A) eigs = sp_lin.eigvals(D) if im == False: eigs = np.real(eigs[np.abs(np.imag(eigs)) < ImTol]) eigs = eigs[eigs >= -1] eigs = np.sort(eigs[eigs <= 1]) else: eigs = eigs[eigs.real >= -1] eigs = eigs[eigs.real <= 1] q = (b - a) / 2; p = (a + b) / 2 return eigs * q + p
def test_linear_root(self): assert_(cheb.chebcompanion([1, 2])[0, 0] == -.5)
def test_dimensions(self): for i in range(1, 5): coef = [0]*i + [1] assert_(cheb.chebcompanion(coef).shape == (i, i))