本文整理汇总了Python中polynomial.Polynomial.power方法的典型用法代码示例。如果您正苦于以下问题:Python Polynomial.power方法的具体用法?Python Polynomial.power怎么用?Python Polynomial.power使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类polynomial.Polynomial
的用法示例。
在下文中一共展示了Polynomial.power方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from polynomial import Polynomial [as 别名]
# 或者: from polynomial.Polynomial import power [as 别名]
def __init__(self, first=Polynomial.power(0)): self.__seq = [ first ]
def iswhole(val): return val == long(val)
示例2: __getslice__
# 需要导入模块: from polynomial import Polynomial [as 别名]
# 或者: from polynomial.Polynomial import power [as 别名]
def __getslice__(self, lo, hi, step=1):
ans = []
if step > 0:
while lo < hi:
ans.append(self[lo])
lo += step
elif step < 0:
while lo > hi:
ans.append(self[lo])
lo += step
elif lo != hi:
raise ValueError("Sequence with zero step is a very bad idea !")
return ans
z = Polynomial.power(1)
class Middle (LazySeq):
def growto(self, key, u=z,
squp = lambda p, u=z: (2 + u) * p**2,
flap = lambda p, u=z: p + p(-u)):
assert H is self # singleton class
assert key > 0
m, r = divmod(key - 1, 3)
n = m + r
assert key == n + 2 * m + 1 and (n + m) % 2 == r % 2
N, M = self[n], self[m]
head = (u + 2) * N * M
tail = head(-u) # now subtract (-1) ** (n + m) of that from head:
if r % 2: head += tail
else: head -= tail