Bill Allombert on Thu, 12 Sep 2024 18:08:58 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Mass-calculation of 1/k mod p with a fixed k and prime p
|
- To: pari-dev@pari.math.u-bordeaux.fr
- Subject: Re: Mass-calculation of 1/k mod p with a fixed k and prime p
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Thu, 12 Sep 2024 18:08:54 +0200
- Delivery-date: Thu, 12 Sep 2024 18:08:58 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=math.u-bordeaux.fr; s=2022; t=1726157335; bh=ezH9y+x5uANJ4CEUtx/lOyRkLpyLFbzeiLqO3NKbOyk=; h=Date:From:To:Subject:References:In-Reply-To:From; b=SeDpR5oaAPmds1y2hTL/P0C464pJN0JLIvyvca1cLJ17h8sUancYiPAwrQlLfTpQ7 JdcptKCNVGXkS0R6OsPJWZX/nLBsXMu3L4lgG3XAP+GtsQZnt4He0lZ0imnHXo5TiS UVcW1Kmz0H7Wf866uhuOQuovGkjL6gACkvomYE/scaapu+xcgBzkIlmfksU3ZUIKlh ZOz9Kbdyo47wAopPlT0oBr7C9M5wDOUsBrJ2r9EGr0k8hiyJ5wGomJaqxRjHFHEDst jHHA3M55g8qKKIiJIzR0CF8siXyycIAuLHbOkn0jHkRwdQIoQaBObJ76X8XbNw5Un2 vXn3cfTZbVR0yCJT3WNFAotEPnpR93yHYxU7WrMvxbvaFq9MMLk2DVe5Be7aZ7V0pb l+jErYuzR+a6N44S2JzkLB1b+Celr5rxXUjl5l6SDSPWpzQaVoSQA2d3Z9E+KATS5Q ee6J0gmXO2Mth3Z+qqH7iHLTZsyHonc2CHjXq3tgnZ0bu6jBEJ+KmD2smBvh7Iw4Vv kKP1eJZ1zg23vafRMNTLhQXVS0Ztm8cWUEcgMUhFtioDrlbfxGF7w78HTpRYB0Rj0t ivs4/di/eOg609JiqpPoBkMkbqp2Y2tNL89/yCdHg+k+SYE6u7DRlonutDZ9sm0mY/ dZum+Zb5/htLlGvEYukG3Fgw=
- In-reply-to: <ZuL-ef7_kFmR5nwm@debian.attlocal.net>
- Mail-followup-to: pari-dev@pari.math.u-bordeaux.fr
- References: <ZuL-ef7_kFmR5nwm@debian.attlocal.net>
On Thu, Sep 12, 2024 at 07:45:13AM -0700, Ilya Zakharevich wrote:
> I think about a cheap way to implement forprimestep() — without current
> pessimizations. To do this, it seems that given k, I need to find 1/k
> mod p for all “small” p mutually prime with k. (Say, the list of p ≤
> pMAX<10¹¹ is already pre-calculated. Already covering the case when k
> pMAX < 2⁶⁴ may be quite useful.)
>
> Is there a way to do it quickly (possibly pre-calculating suitable
> data depending on k)?
>
> ⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜
>
> So far I can only see the following (silly) way: if k is “small”,
> pre-calculate 1/l mod k for every l mod k; store in array INV[l].
> Then looping through p, it is cheap to find p mod k, hence r ≔ 1/p mod k.
> Hence rp ≡ 1 mod k, say rp - 1 = sk. So 1/k ≡ -s mod p, and all one
> needs to find is p-(rp-1)/k.
In the same spirit, there is an algorithm by Peter Montgomery to compute
1/p mod k for all p that does not require k to be small and is implemented
in Flv_inv and FpV_inv.
Cheers,
Bill.