Modified:
/trunk/sympycore/calculus/algebra.py
/trunk/sympycore/heads/polynomial.py
/trunk/sympycore/polynomials/algebra.py
=======================================
--- /trunk/sympycore/calculus/algebra.py Mon Sep 19 13:56:01 2011
+++ /trunk/sympycore/calculus/algebra.py Wed Sep 21 15:28:27 2011
@@ -8,7 +8,7 @@
from ..core import classes, defined_functions
from ..utils import TERMS, str_PRODUCT, SYMBOL, NUMBER
-from ..heads import APPLY, CALLABLE, TERM_COEFF
+from ..heads import APPLY, CALLABLE, TERM_COEFF, TERM_COEFF_DICT
from ..heads import BASE_EXP_DICT as FACTORS
from ..basealgebra import Algebra, Verbatim
from ..ring import CommutativeRing
@@ -209,6 +209,11 @@
term, coeff = data
coeff = coeff * float_one
return cls(head, (term, coeff))
+ if head is TERM_COEFF_DICT:
+ new_data = {}
+ for term, coeff in data.iteritems():
+ new_data[term] = coeff * float_one
+ return cls(head, new_data)
return target
return head.walk(evalf, type(self), data, self)
=======================================
--- /trunk/sympycore/heads/polynomial.py Tue Sep 20 15:09:34 2011
+++ /trunk/sympycore/heads/polynomial.py Wed Sep 21 15:28:27 2011
@@ -76,13 +76,12 @@
for exp, coeff in data.iteritems():
if order > exp[index]:
continue
- new_exp = type(exp)(*exp.pair)
+ new_exp = exp.copy()
new_exp[index] -= order
- n = exp[index]-1
- new_coeff = coeff * (exp[index]-1)
- for o in range(order-1):
- n *= exp[index]-1
- new_data[new_exp] = coeff * n
+ new_coeff = coeff
+ for i in range(order):
+ new_coeff = new_coeff * (exp[index] - i)
+ new_data[new_exp] = new_coeff
return cls(new_data)
def expand(self, cls, expr):
=======================================
--- /trunk/sympycore/polynomials/algebra.py Mon Sep 19 13:56:01 2011
+++ /trunk/sympycore/polynomials/algebra.py Wed Sep 21 15:28:27 2011
@@ -472,6 +472,15 @@
d[exps.add(index,-1)] = coeff * e
return type(self)(head, d)
+ def variable_diff(self, variable, order=1):
+ try:
+ index = list(self.variables).index(variable)
+ except ValueError:
+ index = None
+ if index is not None:
+ return self.head.diff_index(type(self), self.data, self,
index, order=order)
+ raise NotImplementedError(`self.variables, variable, index`)
+
def variable_integrate(self, variable, *bounds):
""" Return integral over variable.