MCPcopy Create free account
hub / github.com/numpy/numpy / fromroots

Method fromroots

numpy/polynomial/_polybase.py:1048–1088  ·  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

1046
1047 @classmethod
1048 def fromroots(cls, roots, domain=[], window=None, symbol='x'):
1049 """Return series instance that has the specified roots.
1050
1051 Returns a series representing the product
1052 ``(x - r[0])*(x - r[1])*...*(x - r[n-1])``, where ``r`` is a
1053 list of roots.
1054
1055 Parameters
1056 ----------
1057 roots : array_like
1058 List of roots.
1059 domain : {[], None, array_like}, optional
1060 Domain for the resulting series. If None the domain is the
1061 interval from the smallest root to the largest. If [] the
1062 domain is the class domain. The default is [].
1063 window : {None, array_like}, optional
1064 Window for the returned series. If None the class window is
1065 used. The default is None.
1066 symbol : str, optional
1067 Symbol representing the independent variable. Default is 'x'.
1068
1069 Returns
1070 -------
1071 new_series : series
1072 Series with the specified roots.
1073
1074 """
1075 [roots] = pu.as_series([roots], trim=False)
1076 if domain is None:
1077 domain = pu.getdomain(roots)
1078 elif type(domain) is list and len(domain) == 0:
1079 domain = cls.domain
1080
1081 if window is None:
1082 window = cls.window
1083
1084 deg = len(roots)
1085 off, scl = pu.mapparms(domain, window)
1086 rnew = off + scl*roots
1087 coef = cls._fromroots(rnew) / scl**deg
1088 return cls(coef, domain=domain, window=window, symbol=symbol)
1089
1090 @classmethod
1091 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