Feat(Compute): Start add MO to create MOpolynomial
This commit is contained in:
parent
eff3ccf9f5
commit
051d79cb9b
@ -114,10 +114,16 @@ class MOMonomial(MO):
|
|||||||
self._power = _power
|
self._power = _power
|
||||||
|
|
||||||
if self._power == 1:
|
if self._power == 1:
|
||||||
|
if self._coefficient == 1:
|
||||||
|
_tree = self._variable
|
||||||
|
else:
|
||||||
_tree = Tree("*",
|
_tree = Tree("*",
|
||||||
self._coefficient,
|
self._coefficient,
|
||||||
self._variable
|
self._variable
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
if self._coefficient == 1:
|
||||||
|
_tree = MOstrPower(self._variable, self._power)
|
||||||
else:
|
else:
|
||||||
_tree = Tree("*",
|
_tree = Tree("*",
|
||||||
self._coefficient,
|
self._coefficient,
|
||||||
|
@ -33,6 +33,8 @@ class MOpolynomial(MO):
|
|||||||
<MOpolynomial 3x^2 + 2x + 1>
|
<MOpolynomial 3x^2 + 2x + 1>
|
||||||
>>> MOpolynomial('x', {0: 1, 3: 4})
|
>>> MOpolynomial('x', {0: 1, 3: 4})
|
||||||
<MOpolynomial 4x^3 + 1>
|
<MOpolynomial 4x^3 + 1>
|
||||||
|
>>> MOpolynomial('x', {0: 1, 3: 1})
|
||||||
|
<MOpolynomial x^3 + 1>
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -11,7 +11,7 @@ Computing with MO
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from .exceptions import TypingError
|
from .exceptions import TypingError
|
||||||
# from .add import add
|
from .add import add
|
||||||
# from .minus import minus
|
# from .minus import minus
|
||||||
# from .multiply import multiply
|
# from .multiply import multiply
|
||||||
from .divide import divide
|
from .divide import divide
|
||||||
@ -27,7 +27,7 @@ from tabulate import tabulate
|
|||||||
MOS = [ MOnumber, MOstr, MOFraction, MOstrPower, MOMonomial ]
|
MOS = [ MOnumber, MOstr, MOFraction, MOstrPower, MOMonomial ]
|
||||||
|
|
||||||
OPERATIONS = {
|
OPERATIONS = {
|
||||||
# "+": add,
|
"+": add,
|
||||||
# "-": minus,
|
# "-": minus,
|
||||||
# "*": multiply,
|
# "*": multiply,
|
||||||
"/": divide,
|
"/": divide,
|
||||||
|
Loading…
Reference in New Issue
Block a user