Max Alekseyev on Thu, 01 Sep 2022 22:39:37 +0200


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

Re: nice undocumented features of t_INTMOD


Documentation for 'forstep' must be a new addition, I did not see it in the half-a-year (or so) old version (or I was blind back then). And it's still missing in the short doc given by '?forstep'.
Anyway, it's great to see it documented.

Regards,
Max

On Thu, Sep 1, 2022 at 4:21 PM Bill Allombert <Bill.Allombert@math.u-bordeaux.fr> wrote:
On Thu, Sep 01, 2022 at 04:03:28PM -0400, Max Alekseyev wrote:
> By pure chance I've discovered the following two undocumented features,
> which I find quite useful.
> I think it is worth describing them in the documentation of forstep() and
> operation % respectively.
>
> 1) t_INTMOD can be used as a step in forstep() for iterating over integers
> in the given interval belonging to the given congruence class - like:

This one is documented:
 forstep(X = a,b,s,seq):
s must be in R^* or an intmod Mod(c,N) (restrict to the corresponding arithmetic progression)

It also works for forprimestep.

> 2) t_INTMOD can be used as x in "x % y" with an integer y. If I got it
> correctly, it results in the modulus of x being reduced to gcd(x.mod,y),
> i.e. Mod(lift(x),gcd(x.mod,y)) - like:
>
> ? Mod(13,21) % 70
> %1 = Mod(6, 7)

This is consistent with the way operations with mixed moduli are done:

? Mod(13,21) + Mod(0,70)
%1 = Mod(6,7)
? Mod(13,21) * Mod(1,70)
%2 = Mod(6,7)
etc.

Whether this is useful is debatable.

Cheers,
Bill.