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

Method fromroots

numpy/polynomial/_polybase.py:1037–1077  ·  view source on GitHub ↗

Return series instance that has the specified roots. Returns a series representing the product ``(x - r[0])*(x - r[1])*...*(x - r[n-1])``, where ``r`` is a list of roots. Parameters ---------- roots : array_like List of roots. dom

(cls, roots, domain=[], window=None, symbol='x')

Source from the content-addressed store, hash-verified

1035
1036 @classmethod
1037 def fromroots(cls, roots, domain=[], window=None, symbol='x'):
1038 """Return series instance that has the specified roots.
1039
1040 Returns a series representing the product
1041 ``(x - r[0])*(x - r[1])*...*(x - r[n-1])``, where ``r`` is a
1042 list of roots.
1043
1044 Parameters
1045 ----------
1046 roots : array_like
1047 List of roots.
1048 domain : {[], None, array_like}, optional
1049 Domain for the resulting series. If None the domain is the
1050 interval from the smallest root to the largest. If [] the
1051 domain is the class domain. The default is [].
1052 window : {None, array_like}, optional
1053 Window for the returned series. If None the class window is
1054 used. The default is None.
1055 symbol : str, optional
1056 Symbol representing the independent variable. Default is 'x'.
1057
1058 Returns
1059 -------
1060 new_series : series
1061 Series with the specified roots.
1062
1063 """
1064 [roots] = pu.as_series([roots], trim=False)
1065 if domain is None:
1066 domain = pu.getdomain(roots)
1067 elif isinstance(domain, list) and len(domain) == 0:
1068 domain = cls.domain
1069
1070 if window is None:
1071 window = cls.window
1072
1073 deg = len(roots)
1074 off, scl = pu.mapparms(domain, window)
1075 rnew = off + scl * roots
1076 coef = cls._fromroots(rnew) / scl**deg
1077 return cls(coef, domain=domain, window=window, symbol=symbol)
1078
1079 @classmethod
1080 def identity(cls, domain=None, window=None, symbol='x'):

Callers 3

test_fromrootsFunction · 0.80
test_rootsFunction · 0.80
test_froomrootsFunction · 0.80

Calls 2

mapparmsMethod · 0.80
_fromrootsMethod · 0.80

Tested by 3

test_fromrootsFunction · 0.64
test_rootsFunction · 0.64
test_froomrootsFunction · 0.64