mirror of
https://github.com/0xPARC/plonkathon.git
synced 2026-01-08 21:28:02 -05:00
Merge pull request #5 from franklynwang/main
support add/sub scalar for monomial representation
This commit is contained in:
29
poly.py
29
poly.py
@@ -31,10 +31,16 @@ class Polynomial:
|
||||
)
|
||||
else:
|
||||
assert isinstance(other, Scalar)
|
||||
return Polynomial(
|
||||
[x + other for x in self.values],
|
||||
self.basis,
|
||||
)
|
||||
if self.basis == Basis.LAGRANGE:
|
||||
return Polynomial(
|
||||
[x + other for x in self.values],
|
||||
self.basis,
|
||||
)
|
||||
else:
|
||||
return Polynomial(
|
||||
[self.values[0] + other] + self.values[1:],
|
||||
self.basis
|
||||
)
|
||||
|
||||
def __sub__(self, other):
|
||||
if isinstance(other, Polynomial):
|
||||
@@ -47,10 +53,17 @@ class Polynomial:
|
||||
)
|
||||
else:
|
||||
assert isinstance(other, Scalar)
|
||||
return Polynomial(
|
||||
[x - other for x in self.values],
|
||||
self.basis,
|
||||
)
|
||||
if self.basis == Basis.LAGRANGE:
|
||||
return Polynomial(
|
||||
[x - other for x in self.values],
|
||||
self.basis,
|
||||
)
|
||||
else:
|
||||
return Polynomial(
|
||||
[self.values[0] - other] + self.values[1:],
|
||||
self.basis
|
||||
)
|
||||
|
||||
|
||||
def __mul__(self, other):
|
||||
if isinstance(other, Polynomial):
|
||||
|
||||
Reference in New Issue
Block a user