I've made the change to compare by type and value instead of just value. It 
is a small change, so if one of you who is more familiar with this code 
could take a quick look that would be appreciated. #16051

I had debated whether to add a more convoluted (parent, value), which would 
then switch to (type,value) if there was no parent. But thought that the 
simpler (type,value) is probably sufficient.



On Tuesday, April 1, 2014 12:52:27 PM UTC-4, Ben Hutz wrote:
>
> Adjusting the constant cache sounds like a much more appealing solution to 
> our particular problem, as we are having trouble with more than just 
> powerseries rings with fast_callable. Some of which, as you say, you may 
> not want to convert "1" to 1.
>
> On Tuesday, April 1, 2014 11:58:37 AM UTC-4, Nils Bruin wrote:
>>
>> On Tuesday, April 1, 2014 7:27:26 AM UTC-7, Ben Hutz wrote:
>>>
>>> Actually, it seems that _coerce_map_from works just fine allowing you to 
>>> send an integer into the power series ring. What is broken is recognizing 
>>> that the powerseries element is an integer even though T(1)==1 returns true.
>>>
>> That's true exactly because 1 coerces into T and is equal to 1 there.  We 
>> also have
>>   sage: T.<t>=QQ[[]]
>>   sage: 1+O(t^-1)==1
>>   True
>> and I don't think we;d want Integer(1+O(t^-1)) to succeed.
>>  
>> I'm afraid that the design of fast_callable, with constant folding by 
>> equality regardless of type, is just not powerful enough to handle more 
>> complicated domains than the simple real calculus-type functions it was 
>> originally designed for. If we're finding an integer exponent somewhere 
>> which happens to compare equal to some other type already stored, we should 
>> really NOT be folding that to the more complicated object. That's bound to 
>> slow down the power, either by having to recognize each time that the 
>> constant can be viewed as an integer and converting it to one, or by now 
>> having to evaluate a full (analytic?) exponentiation, rather than the 
>> repeated squaring and multiply one could do with a guaranteed integer 
>> exponent.
>>  
>> Allowing power series to be converted back into integers is really just 
>> hiding the real problem: fast_callable should take type/parent into account 
>> when folding constants. So probably the constant cache should be keyed by 
>> (parent(constant),constant) tuples. That would at least make 
>> (Power Series Ring in t over Rational Field,1)
>> and
>> (Integer Ring,1)
>> distinct.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to