2007/7/30, Martin Albrecht <[EMAIL PROTECTED]>: > > Hi Didier, > > I hope you don't mind that I have some remarks about your patches
Not at all! I am just poking my way through the multivariate code and any input from someone more knowledgeable than me would be greatly appreciated. > > The R.random_element method on the other hand seems to be specialized for > MPolynomial_polydict only, i.e. you'd loose the speed advantage of > MPolynomial_libsingular by constructing an MPolynomial_polydict in any case. Is there a way to construct a multivariate polynomial from a dictionary? That's what I was shooting for, but I'm getting it doesn't always work. Example: Base ring is RR: {{{ sage: # Works fine sage: from sage.rings.polynomial.polydict import PolyDict sage: R.<x,y,z> = MPolynomialRing(RR,3,order='grevlex') sage: D= PolyDict( {(1, 1, 1): 1, (0, 0, 1): 1/2, (0, 1, 0): 9, (0, 1, 1): -3/8, (0, 0, 0): 3/4}) sage: R(D) x*y*z - 3/8*y*z + 9*y + 1/2*z + 3/4 }}} Base ring is QQ (this fails): {{{ sage: R.<x,y,z> = MPolynomialRing(QQ,3,order='grevlex') sage: R(D) --------------------------------------------------------------------------- <type 'exceptions.TypeError'> Traceback (most recent call last) /home/dfdeshom/custom/sage/devel/sage-multi-random/<ipython console> in <module>() /home/dfdeshom/custom/sage/devel/sage-multi-random/multi_polynomial_libsingular.pyx in multi_polynomial_libsingular.MPolynomialRing_libsingular.__call__() /home/dfdeshom/custom/sage/local/lib/python2.5/site-packages/sage/rings/rational_field.py in __call__(self, x, base) 172 if isinstance(x, sage.rings.rational.Rational): 173 return x --> 174 return sage.rings.rational.Rational(x, base) 175 176 def construction(self): /home/dfdeshom/custom/sage/devel/sage-multi-random/rational.pyx in rational.Rational.__init__() /home/dfdeshom/custom/sage/devel/sage-multi-random/rational.pyx in rational.Rational.__set_value() <type 'exceptions.TypeError'>: Unable to coerce PolyDict with representation {(0, 0, 0): 3/4, (0, 1, 1): -3/8, (0, 1, 0): 9, (1, 1, 1): 1, (0, 0, 1): 1/2} (<type 'sage.rings.polynomial.polydict.PolyDict'>) to Rational }}} Is this a bug, or am I not using this correctly? didier --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---