Feat(Compute): Add polynoms with polynoms

This commit is contained in:
2018-11-13 16:19:02 +01:00
parent f6f6741398
commit b23d83b9da
2 changed files with 446 additions and 28 deletions

View File

@@ -53,16 +53,16 @@ class MOpolynomial(MO):
raise TypeError("Coefs needs to be a dictionnary or a list")
self._coefs = _coefs
monomials = []
monomials = {}
for deg, coef in self._coefs.items():
if deg == 0:
monomials.append(coef)
monomials[deg] = coef
else:
monomials.append(
MOMonomial(coef, self._variable, deg)
)
monomials[deg] = MOMonomial(coef, self._variable, deg)
tree = Tree.from_list("+", monomials[::-1])
self._monomials = monomials
tree = Tree.from_list("+", list(self._monomials.values())[::-1])
MO.__init__(self, tree)
@property
@@ -77,6 +77,10 @@ class MOpolynomial(MO):
def coefficients(self):
return self._coefs
@property
def monomials(self):
return self._monomials
# -----------------------------
# Reglages pour 'vim'