Feat(Compute): Start add MO to create MOpolynomial

This commit is contained in:
2018-11-13 11:40:21 +01:00
parent eff3ccf9f5
commit 051d79cb9b
3 changed files with 18 additions and 10 deletions

View File

@@ -114,15 +114,21 @@ class MOMonomial(MO):
self._power = _power
if self._power == 1:
_tree = Tree("*",
self._coefficient,
self._variable
)
if self._coefficient == 1:
_tree = self._variable
else:
_tree = Tree("*",
self._coefficient,
self._variable
)
else:
_tree = Tree("*",
self._coefficient,
MOstrPower(self._variable, self._power)
)
if self._coefficient == 1:
_tree = MOstrPower(self._variable, self._power)
else:
_tree = Tree("*",
self._coefficient,
MOstrPower(self._variable, self._power)
)
MO.__init__(self, _tree)

View File

@@ -33,6 +33,8 @@ class MOpolynomial(MO):
<MOpolynomial 3x^2 + 2x + 1>
>>> MOpolynomial('x', {0: 1, 3: 4})
<MOpolynomial 4x^3 + 1>
>>> MOpolynomial('x', {0: 1, 3: 1})
<MOpolynomial x^3 + 1>
"""