Re: equality of t_INTMODs
Max Alekseyev <[email protected]>
| Newsgroups | gmane.comp.mathematics.pari.user |
|---|---|
| Message-ID | <CAJkPp5NZg0bvoxQfVuWkPqCryUTFJHYB_gTLS+V4k-TdDw3mqQ@mail.gmail.com> |
Hi Karim, On "===" vs "==", what are other notable cases when the two give different results? Do I understand correctly, that internally functions in PARI/GP, such as setsearch(), rely on "===" rather than "=="? As for "==" for t_INTMODs, it looks like it's better understood as non-disjointness of the corresponding residue classes. What is confusing though is that such non-disjointness is denoted by equality. Maybe, it's affected by my (default) view of t_INTMOD as a residue class, but in reality it's a more relaxed thing. Regards, Max On Fri, Jan 24, 2025 at 11:23 AM Karim Belabas < [email protected]> wrote: > Hi Max, > > we recommend using > > a === b (is identical to) > > rather than the much more liberal and more costly > > a == b (is equal to; in the sense of "there is a natural map sending a > to the domain of b or sending b to the domain of a, such that > the > comparison makes sense and equality holds") > > Cheers, > > K.B. > > * Max Alekseyev [2025-01-24 17:11]: > > Hi Karim, > > > > After the fix we have > > > > ? Mod(14,20) == Mod(39,55) > > %1 = 1 > > > > I understand why, but nevertheless it looks very confusing. > > > > Regards, > > Max > > > > > > On Fri, Jan 24, 2025 at 10:58 AM Karim Belabas < > > [email protected]> wrote: > > > > > Hi Max, > > > > > > * Max Alekseyev [2025-01-24 16:12]: > > > > In view of a recently discovered issue in Sage ( > > > > https://github.com/sagemath/sage/issues/39372), I'd like to check > how > > > the > > > > following two (in)equalities co-exist in PARI/GP. Do they violate any > > > > design conventions and/or represent a notable exception to those? > > > > > > > > ? Mod(14,20) == Mod(39,55) > > > > %1 = 0 > > > > ? Mod(14,20) - Mod(39,55) == 0 > > > > %2 = 1 > > > > > > They do violate the design convention (x == y iff x - y == 0; > > > use the === operator for proper equality without implicit coercion). > > > > > > t_POLMOD had the same issue. Both issues are now fixed in 'master'. > > > > > > Cheers, > > > > > > K.B. > > > -- > > > Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique > > > Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77 > > > http://www.math.u-bordeaux.fr/~kbelabas/ > > > > > K.B. > -- > Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique > Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77 > http://www.math.u-bordeaux.fr/~kbelabas/ >