On Apr 1, 2008, at 11:59 PM, Jason Grout wrote:
>
> Robert Bradshaw wrote:
>> On Apr 1, 2008, at 9:15 PM, Jason Grout wrote:
>>
>>> I'm trying to add _fast_float_ functionality to SymbolicEquation
>>> objects.  However, a perusal of the sage.ext.fast_eval.pyx file
>>> seems to
>>> indicate that the operations <, <=, ==, >=, >, and != are not
>>> supported
>>> by the fast_float machinery.  Is that correct?
>>
>> That is correct.
>>
>>> If so, how do I add
>>> these operations?  If not, then how do I construct a FastDoubleFunc
>>> object appropriately?
>>>
>>> Or, should I just use the python operators and call fast_float on
>>> each side?
>>
>> The latter is what I would do--the result of evaluating a symbolic
>> equation object is a boolean not a float so it would be kind of hard
>> to hook into this mechanism anyways (well, one could represent True
>> by one float and False by another, but I don't think that's a very
>> clean solution).
>
>
> Sorry, Robert, I didn't see your message until just now (after all the
> work was done).  If you want to veto the patch, I understand and  
> I'll do
> it the way you suggest.
>
> The use-case I had in mind called for getting 0 for false and 1 for
> true, so that is how I implemented it (e.g., contour_plot(x<y,  
> (x,-1,1),
> (y,-1,1))).
>
> Still, it was fun to muck around in the fast_float file.  You're  
> amazing!

Thanks.

I put a comment up on trac, but it boils down to

sage: f = (x == 1)
sage: g = (1 == x)
sage: bool(f+g)
True
sage: ff = f._fast_float_('x') + g._fast_float_('x')
sage: ff(0)
0.0

but I think piecewise functions would be a good way to implement the  
desired functionality.

- Robert


--~--~---------~--~----~------------~-------~--~----~
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://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to