Return the scaled companion matrix of c. The basis polynomials are scaled so that the companion matrix is symmetric when `c` is a Chebyshev basis polynomial. This provides better eigenvalue estimates than the unscaled case and for basis polynomials the eigenvalues are guaranteed to
(c)
| 1672 | |
| 1673 | |
| 1674 | def chebcompanion(c): |
| 1675 | """Return the scaled companion matrix of c. |
| 1676 | |
| 1677 | The basis polynomials are scaled so that the companion matrix is |
| 1678 | symmetric when `c` is a Chebyshev basis polynomial. This provides |
| 1679 | better eigenvalue estimates than the unscaled case and for basis |
| 1680 | polynomials the eigenvalues are guaranteed to be real if |
| 1681 | `numpy.linalg.eigvalsh` is used to obtain them. |
| 1682 | |
| 1683 | Parameters |
| 1684 | ---------- |
| 1685 | c : array_like |
| 1686 | 1-D array of Chebyshev series coefficients ordered from low to high |
| 1687 | degree. |
| 1688 | |
| 1689 | Returns |
| 1690 | ------- |
| 1691 | mat : ndarray |
| 1692 | Scaled companion matrix of dimensions (deg, deg). |
| 1693 | |
| 1694 | Notes |
| 1695 | ----- |
| 1696 | |
| 1697 | .. versionadded:: 1.7.0 |
| 1698 | |
| 1699 | """ |
| 1700 | # c is a trimmed copy |
| 1701 | [c] = pu.as_series([c]) |
| 1702 | if len(c) < 2: |
| 1703 | raise ValueError('Series must have maximum degree of at least 1.') |
| 1704 | if len(c) == 2: |
| 1705 | return np.array([[-c[0]/c[1]]]) |
| 1706 | |
| 1707 | n = len(c) - 1 |
| 1708 | mat = np.zeros((n, n), dtype=c.dtype) |
| 1709 | scl = np.array([1.] + [np.sqrt(.5)]*(n-1)) |
| 1710 | top = mat.reshape(-1)[1::n+1] |
| 1711 | bot = mat.reshape(-1)[n::n+1] |
| 1712 | top[0] = np.sqrt(.5) |
| 1713 | top[1:] = 1/2 |
| 1714 | bot[...] = top |
| 1715 | mat[:, -1] -= (c[:-1]/c[-1])*(scl/scl[-1])*.5 |
| 1716 | return mat |
| 1717 | |
| 1718 | |
| 1719 | def chebroots(c): |