Raise a Chebyshev series to a power. Returns the Chebyshev series `c` raised to the power `pow`. The argument `c` is a sequence of coefficients ordered from low to high. i.e., [1,2,3] is the series ``T_0 + 2*T_1 + 3*T_2.`` Parameters ---------- c : array_like 1-D a
(c, pow, maxpower=16)
| 813 | |
| 814 | |
| 815 | def chebpow(c, pow, maxpower=16): |
| 816 | """Raise a Chebyshev series to a power. |
| 817 | |
| 818 | Returns the Chebyshev series `c` raised to the power `pow`. The |
| 819 | argument `c` is a sequence of coefficients ordered from low to high. |
| 820 | i.e., [1,2,3] is the series ``T_0 + 2*T_1 + 3*T_2.`` |
| 821 | |
| 822 | Parameters |
| 823 | ---------- |
| 824 | c : array_like |
| 825 | 1-D array of Chebyshev series coefficients ordered from low to |
| 826 | high. |
| 827 | pow : integer |
| 828 | Power to which the series will be raised |
| 829 | maxpower : integer, optional |
| 830 | Maximum power allowed. This is mainly to limit growth of the series |
| 831 | to unmanageable size. Default is 16 |
| 832 | |
| 833 | Returns |
| 834 | ------- |
| 835 | coef : ndarray |
| 836 | Chebyshev series of power. |
| 837 | |
| 838 | See Also |
| 839 | -------- |
| 840 | chebadd, chebsub, chebmulx, chebmul, chebdiv |
| 841 | |
| 842 | Examples |
| 843 | -------- |
| 844 | >>> from numpy.polynomial import chebyshev as C |
| 845 | >>> C.chebpow([1, 2, 3, 4], 2) |
| 846 | array([15.5, 22. , 16. , ..., 12.5, 12. , 8. ]) |
| 847 | |
| 848 | """ |
| 849 | # note: this is more efficient than `pu._pow(chebmul, c1, c2)`, as it |
| 850 | # avoids converting between z and c series repeatedly |
| 851 | |
| 852 | # c is a trimmed copy |
| 853 | [c] = pu.as_series([c]) |
| 854 | power = int(pow) |
| 855 | if power != pow or power < 0: |
| 856 | raise ValueError("Power must be a non-negative integer.") |
| 857 | elif maxpower is not None and power > maxpower: |
| 858 | raise ValueError("Power is too large") |
| 859 | elif power == 0: |
| 860 | return np.array([1], dtype=c.dtype) |
| 861 | elif power == 1: |
| 862 | return c |
| 863 | else: |
| 864 | # This can be made more efficient by using powers of two |
| 865 | # in the usual way. |
| 866 | zs = _cseries_to_zseries(c) |
| 867 | prd = zs |
| 868 | for i in range(2, power + 1): |
| 869 | prd = np.convolve(prd, zs) |
| 870 | return _zseries_to_cseries(prd) |
| 871 | |
| 872 |
nothing calls this directly
no test coverage detected
searching dependent graphs…