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)
| 668 | |
| 669 | |
| 670 | def _pow(mul_f, c, pow, maxpower): |
| 671 | """ |
| 672 | Helper function used to implement the ``<type>pow`` functions. |
| 673 | |
| 674 | Parameters |
| 675 | ---------- |
| 676 | mul_f : function(array_like, array_like) -> ndarray |
| 677 | The ``<type>mul`` function, such as ``polymul`` |
| 678 | c : array_like |
| 679 | 1-D array of array of series coefficients |
| 680 | pow, maxpower |
| 681 | See the ``<type>pow`` functions for more detail |
| 682 | """ |
| 683 | # c is a trimmed copy |
| 684 | [c] = as_series([c]) |
| 685 | power = int(pow) |
| 686 | if power != pow or power < 0: |
| 687 | raise ValueError("Power must be a non-negative integer.") |
| 688 | elif maxpower is not None and power > maxpower: |
| 689 | raise ValueError("Power is too large") |
| 690 | elif power == 0: |
| 691 | return np.array([1], dtype=c.dtype) |
| 692 | elif power == 1: |
| 693 | return c |
| 694 | else: |
| 695 | # This can be made more efficient by using powers of two |
| 696 | # in the usual way. |
| 697 | prd = c |
| 698 | for i in range(2, power + 1): |
| 699 | prd = mul_f(prd, c) |
| 700 | return prd |
| 701 | |
| 702 | |
| 703 | def _as_int(x, desc): |
nothing calls this directly
no test coverage detected
searching dependent graphs…