2var poly ok for results but bad with explain
This commit is contained in:
parent
a564708a31
commit
f62f572fb3
@ -292,7 +292,8 @@ class AbstractPolynom(Explicable):
|
|||||||
"""
|
"""
|
||||||
if (isNumber(other) and not isPolynom(other)) or \
|
if (isNumber(other) and not isPolynom(other)) or \
|
||||||
(isPolynom(other) and self._letter != other._letter):
|
(isPolynom(other) and self._letter != other._letter):
|
||||||
ans = self.__class__([other], letter=self._letter)
|
#ans = self.__class__([other], letter=self._letter)
|
||||||
|
ans = AbstractPolynom([other], letter=self._letter)
|
||||||
ans.steal_history(other)
|
ans.steal_history(other)
|
||||||
return ans
|
return ans
|
||||||
elif isPolynom(other):
|
elif isPolynom(other):
|
||||||
@ -326,6 +327,23 @@ class AbstractPolynom(Explicable):
|
|||||||
6 x^{ 2 } + 12 x + 3
|
6 x^{ 2 } + 12 x + 3
|
||||||
>>> Q.steps
|
>>> Q.steps
|
||||||
[< Step [6, 'x', 2, ^, *, 3, 'x', *, +, 4, 'x', *, +, 5, 'x', *, +, 1, +, 2, +]>, < Step [6, 'x', 2, ^, *, 3, 4, +, 5, +, 'x', *, +, 1, 2, +, +]>, < Step [6, 'x', 2, ^, *, 7, 5, +, 'x', *, +, 3, +]>, < Step [6, 'x', 2, ^, *, 12, 'x', *, +, 3, +]>]
|
[< Step [6, 'x', 2, ^, *, 3, 'x', *, +, 4, 'x', *, +, 5, 'x', *, +, 1, +, 2, +]>, < Step [6, 'x', 2, ^, *, 3, 4, +, 5, +, 'x', *, +, 1, 2, +, +]>, < Step [6, 'x', 2, ^, *, 7, 5, +, 'x', *, +, 3, +]>, < Step [6, 'x', 2, ^, *, 12, 'x', *, +, 3, +]>]
|
||||||
|
>>> P = AbstractPolynom([1,2])
|
||||||
|
>>> Q = AbstractPolynom([P,3], 'y')
|
||||||
|
>>> Q
|
||||||
|
< AbstractPolynom y [< AbstractPolynom x [1, 2]>, 3]>
|
||||||
|
>>> Q = Q.reduce()
|
||||||
|
>>> for i in Q.explain():
|
||||||
|
... print(i)
|
||||||
|
3 y + 2 x + 1
|
||||||
|
>>> P = AbstractPolynom([1,2])
|
||||||
|
>>> Q = AbstractPolynom([[P,1],3], 'y')
|
||||||
|
>>> Q
|
||||||
|
< AbstractPolynom y [[< AbstractPolynom x [1, 2]>, 1], 3]>
|
||||||
|
>>> Q = Q.reduce()
|
||||||
|
>>> for i in Q.explain():
|
||||||
|
... print(i)
|
||||||
|
3 y + 2 x + 1 + 1
|
||||||
|
3 y + 2 x + 2
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO: Il manque le ini_step |jeu. mars 10 12:39:40 EAT 2016
|
# TODO: Il manque le ini_step |jeu. mars 10 12:39:40 EAT 2016
|
||||||
@ -426,6 +444,16 @@ class AbstractPolynom(Explicable):
|
|||||||
3 x^{ 2 } + 7 x + 5
|
3 x^{ 2 } + 7 x + 5
|
||||||
>>> R.steps
|
>>> R.steps
|
||||||
[< Step [3, 'x', 2, ^, *, 2, 'x', *, +, 1, +, 5, 'x', *, 4, +, +]>, < Step [3, 'x', 2, ^, *, 2, 'x', *, +, 5, 'x', *, +, 1, +, 4, +]>, < Step [3, 'x', 2, ^, *, 2, 5, +, 'x', *, +, 1, 4, +, +]>, < Step [3, 'x', 2, ^, *, 7, 'x', *, +, 5, +]>]
|
[< Step [3, 'x', 2, ^, *, 2, 'x', *, +, 1, +, 5, 'x', *, 4, +, +]>, < Step [3, 'x', 2, ^, *, 2, 'x', *, +, 5, 'x', *, +, 1, +, 4, +]>, < Step [3, 'x', 2, ^, *, 2, 5, +, 'x', *, +, 1, 4, +, +]>, < Step [3, 'x', 2, ^, *, 7, 'x', *, +, 5, +]>]
|
||||||
|
>>> Q = AbstractPolynom([4,5], letter = 'y')
|
||||||
|
>>> R = P+Q
|
||||||
|
>>> R
|
||||||
|
< AbstractPolynom x [< AbstractPolynom y [5, 5]>, 2, 3]>
|
||||||
|
>>> for i in R.explain():
|
||||||
|
... print(i)
|
||||||
|
3 x^{ 2 } + 2 x + 1 + 5 y + 4
|
||||||
|
3 x^{ 2 } + 2 x + 5 y + 1 + 4
|
||||||
|
3 x^{ 2 } + 2 x + 5 y + 5
|
||||||
|
|
||||||
"""
|
"""
|
||||||
o_poly = self.conv2poly(other)
|
o_poly = self.conv2poly(other)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user