[sympycore] r1214 committed - Impl evalf for PolynomialRing

2 views
Skip to first unread message

codesite...@google.com

unread,
Sep 22, 2011, 5:33:51 PM9/22/11
to sympycor...@googlegroups.com
Revision: 1214
Author: pearu.peterson
Date: Thu Sep 22 14:33:14 2011
Log: Impl evalf for PolynomialRing
http://code.google.com/p/sympycore/source/detail?r=1214

Modified:
/trunk/sympycore/heads/polynomial.py
/trunk/sympycore/ring/algebra.py

=======================================
--- /trunk/sympycore/heads/polynomial.py Wed Sep 21 15:28:27 2011
+++ /trunk/sympycore/heads/polynomial.py Thu Sep 22 14:33:14 2011
@@ -93,6 +93,16 @@
new_data[exp] = coeff
return cls(new_data)

+ def evalf(self, cls, expr, n):
+ new_data = {}
+ for exp, coeff in expr.data.iteritems():
+ if isinstance(coeff, Expr):
+ new_data[exp] = coeff.evalf(n)
+ else:
+ new_data[exp] = coeff
+ return cls(new_data)
+
+
class DensepolyHead(Head):
"""
DensepolyHead is a head for dense polynomials represented
=======================================
--- /trunk/sympycore/ring/algebra.py Mon Dec 7 23:34:24 2009
+++ /trunk/sympycore/ring/algebra.py Thu Sep 22 14:33:14 2011
@@ -133,6 +133,9 @@
def expand(self):
return self.head.expand(type(self), self)

+ def evalf(self, n=None):
+ return self.head.evalf(type(self), self, n)
+
class CommutativeRing(Ring):

def __mul__(self, other):

Reply all
Reply to author
Forward
0 new messages