MCPcopy Index your code
hub / github.com/numpy/numpy / _pow

Function _pow

numpy/polynomial/polyutils.py:670–700  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

668
669
670def _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
703def _as_int(x, desc):

Callers

nothing calls this directly

Calls 1

as_seriesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…