summaryrefslogtreecommitdiff
path: root/math/sqrtModCipolla.cpp
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 01:24:14 +0100
committerGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 01:24:14 +0100
commit98567ec798aa8ca2cfbcb85c774dd470f30e30d4 (patch)
tree5113d5cc24d1ad5f93810b6442ce584a36950dc8 /math/sqrtModCipolla.cpp
parentad3856a6b766087df0036de0b556f4700a6498c9 (diff)
parent8d11c6c8213f46f0fa19826917c255edd5d43cb1 (diff)
mzuenni tests
Diffstat (limited to 'math/sqrtModCipolla.cpp')
-rw-r--r--math/sqrtModCipolla.cpp13
1 files changed, 0 insertions, 13 deletions
diff --git a/math/sqrtModCipolla.cpp b/math/sqrtModCipolla.cpp
deleted file mode 100644
index 12bc590..0000000
--- a/math/sqrtModCipolla.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-bool isSquare(ll x, ll p){
- return powMod(x, p/2, p) != p-1;
-}
-
-// Teste vorher, ob sqrt(n) mod p existiert!
-ll sqrtMod(ll n, ll p){
- if(n == 0) return 0;
- ll r0 = 1, r1 = 0, b0 = 1, b1 = 1, w;
- while(isSquare(w=(b0*b0-n+p)%p, p)) b0 = rng()%p;
- for(ll e = (p+1)/2; e; e /= 2, tie(b0, b1) = pair((b0*b0 + b1*b1%p*w)%p, 2*b0*b1%p))
- if(e & 1) tie(r0, r1) = pair((r0*b0 + r1*b1%p*w)%p, (r0*b1 + b0*r1)%p);
- return r0;
-}