Helper function used to implement the `` pow`` functions. Parameters ---------- mul_f : function(array_like, array_like) -> ndarray The `` mul`` function, such as ``polymul`` c : array_like 1-D array of array of series coefficients pow, maxpower
(mul_f, c, pow, maxpower)
| 685 | |
| 686 | |
| 687 | def _pow(mul_f, c, pow, maxpower): |
| 688 | """ |
| 689 | Helper function used to implement the ``<type>pow`` functions. |
| 690 | |
| 691 | Parameters |
| 692 | ---------- |
| 693 | mul_f : function(array_like, array_like) -> ndarray |
| 694 | The ``<type>mul`` function, such as ``polymul`` |
| 695 | c : array_like |
| 696 | 1-D array of array of series coefficients |
| 697 | pow, maxpower |
| 698 | See the ``<type>pow`` functions for more detail |
| 699 | """ |
| 700 | # c is a trimmed copy |
| 701 | [c] = as_series([c]) |
| 702 | power = int(pow) |
| 703 | if power != pow or power < 0: |
| 704 | raise ValueError("Power must be a non-negative integer.") |
| 705 | elif maxpower is not None and power > maxpower: |
| 706 | raise ValueError("Power is too large") |
| 707 | elif power == 0: |
| 708 | return np.array([1], dtype=c.dtype) |
| 709 | elif power == 1: |
| 710 | return c |
| 711 | else: |
| 712 | # This can be made more efficient by using powers of two |
| 713 | # in the usual way. |
| 714 | prd = c |
| 715 | for i in range(2, power + 1): |
| 716 | prd = mul_f(prd, c) |
| 717 | return prd |
| 718 | |
| 719 | |
| 720 | def _deprecate_as_int(x, desc): |
nothing calls this directly
no test coverage detected