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

Function _fromroots

numpy/polynomial/polyutils.py:443–470  ·  view source on GitHub ↗

Helper function used to implement the `` fromroots`` functions. Parameters ---------- line_f : function(float, float) -> ndarray The `` line`` function, such as ``polyline`` mul_f : function(array_like, array_like) -> ndarray The `` mul`` function

(line_f, mul_f, roots)

Source from the content-addressed store, hash-verified

441
442
443def _fromroots(line_f, mul_f, roots):
444 """
445 Helper function used to implement the ``<type>fromroots`` functions.
446
447 Parameters
448 ----------
449 line_f : function(float, float) -> ndarray
450 The ``<type>line`` function, such as ``polyline``
451 mul_f : function(array_like, array_like) -> ndarray
452 The ``<type>mul`` function, such as ``polymul``
453 roots
454 See the ``<type>fromroots`` functions for more detail
455 """
456 if len(roots) == 0:
457 return np.ones(1)
458 else:
459 [roots] = as_series([roots], trim=False)
460 roots.sort()
461 p = [line_f(-r, 1) for r in roots]
462 n = len(p)
463 while n > 1:
464 m, r = divmod(n, 2)
465 tmp = [mul_f(p[i], p[i + m]) for i in range(m)]
466 if r:
467 tmp[0] = mul_f(tmp[0], p[-1])
468 p = tmp
469 n = m
470 return p[0]
471
472
473def _valnd(val_f, c, *args):

Callers

nothing calls this directly

Calls 2

as_seriesFunction · 0.85
sortMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…