[sage-devel] Re: Hashing elements from the same ring

2013-08-30 Thread Stefan
On Thursday, August 29, 2013 12:54:02 PM UTC-4, Nils Bruin wrote: > > On Thursday, August 29, 2013 8:52:02 AM UTC-7, Simon King wrote: >> >> Hi Stefan, >> >> On 2013-08-29, Stefan wrote: >> > Actually, this is not quite true. reduce() is, by default, called >> > automatically for elements of

[sage-devel] Re: Hashing elements from the same ring

2013-08-29 Thread Nils Bruin
On Thursday, August 29, 2013 8:52:02 AM UTC-7, Simon King wrote: > > Hi Stefan, > > On 2013-08-29, Stefan > wrote: > > Actually, this is not quite true. reduce() is, by default, called > > automatically for elements of exact rings at creation time. It will > > correctly get rid of common factor

[sage-devel] Re: Hashing elements from the same ring

2013-08-29 Thread Simon King
Hi Stefan, On 2013-08-29, Stefan wrote: > Actually, this is not quite true. reduce() is, by default, called > automatically for elements of exact rings at creation time. It will > correctly get rid of common factors, but it does not normalize the leading > coefficients: Bad. But of course, it

[sage-devel] Re: Hashing elements from the same ring

2013-08-29 Thread Stefan
> > But there is also a generically implemented method .reduce() for > fraction field elements (so, not necessarily needed to implement it in > subclasses). Of course, it is expensive and it may fail (if > the gcd is not defined). But *if* it works, then fraction f1 is equal to > fraction f2 i

Re: [sage-devel] Re: Hashing elements from the same ring

2013-08-29 Thread Vincent Delecroix
Hello, The following is I guess for the symbolic ring and is what we want sage: cmp((x+1)^2, x^2 + 2*x + 1) 1 while the following is in a polynomial ring and is also what we want sage: cmp((c+1)^2, c^2 + 2*c+1) 0 The only issue is about hashing and not == vs cmp, right ? Note that there are oth

[sage-devel] Re: Hashing elements from the same ring

2013-08-29 Thread John H Palmieri
On Thursday, August 29, 2013 2:08:49 AM UTC-7, Simon King wrote: > > Hi Robert, hi Stefan, > > > > If I am not mistaken, containment in sets and dicts relies on cmp and > not on ==. Hence, in this case, I think the hash is not to blame. > Indeed, comparing using == works: sage: H5. = Frac

[sage-devel] Re: Hashing elements from the same ring

2013-08-29 Thread Simon King
Hi Robert, hi Stefan, On 2013-08-28, Robert Bradshaw wrote: > What could perhaps be added is some kind of a normalization routine > (to be implemented by subclasses) that is called before performing a > hash. This might be quite expensive. Sorry, I intended to answer yesterday evening along the