Bill Allombert on Mon, 11 May 2009 16:06:13 +0200

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: PATCH: gequal1 and gequal_1 for t_SERs

On Mon, May 11, 2009 at 10:14:50AM +0200, Jeroen Demeyer wrote:
> Bill Allombert wrote:
>> On Tue, Feb 10, 2009 at 12:09:22PM +0100, Jeroen Demeyer wrote:
>>> Hello pari-dev,
>>> It seems that gcmp1() and gcmp_1() were not implemented for t_SER 
>>> (they always returned 0).  This patch should fix that.
>>> - Implemented gcmp1() and gcmp_1() for t_SERs.
>> Well, this change the semantic of gcmp1() and gcmp_1(), but I think
>> it is in an expected way, the current behaviour being rather
>> unexpecected.
>> However I am not entirely sure the implementation is correct:
>> We should have the equivalence gcmp1(x) == gequal(x,gen_1) and this is 
>> far from obvious from the code, though that might be
>> an issue with gequal rather than with your code.
> I am opening this thread again since there haven't been any replies...
> Do you think there are any problems with this patch?  If there aren't,  

Yes, I think there are potential problems with your patch, but I also think
there are problems with gequal1 and gequal as well that need to be sorted out
before your patch can be evaluated.

Note that gequalm1 is affected in exactly the same way.
The problem is that the documentation of gequal1 only says:

\fun{int}{gequal1}{GEN x} returns 1 (true) if \kbd{x} is equal to~1, 0~(false)

Thus it imply that gequal1(x)==gequal(x,gen_1).

? install(gequal1,lG)
? a=1+0.*x;
? a==1
%2 = 1
? gequal1(a)
%3 = 0

With your patch applied, we also have 

? a=1+0.*z+O(x^4);
? a==1
%5 = 1
? gequal1(a)
%6 = 0

So either we fix the documentation and apply your patch, or we fix the code
and your patch become wrong.

I expect Karim will clarify the correct behaviour of gequal1.

> then you should commit it to SVN.

In the current SVN it is clear that gequal1() does not handle t_SER.
With your patch they are handled in a undocumented way, which might change
in the future.