本文整理匯總了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