American Citizen on Tue, 25 Mar 2025 01:09:01 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: question on trying to use quadratic residues to eliminate needless checks |
Bill:
I am trying to develop the C++ code following your suggestion.
for k = 7, we have N = 2042040Pick k a small integer as large as possible so that the computation does not use too much memory (try k=7). Take N = 4*vecprod(primes(k)).
Compute a bit array B so that B[i]==1 iff i is a square modulo N.
Ah, I have not used bit arrays before in C++, are you talking about std::bitset ?
Compute the array of r
2 mod N using C arithmetic for all r.
I assume 0 <= r <= N ?? and this is obviously integer array.
Would std::vector<long> suffice?
I am puzzled. I am trying to avoid the costly r^2 + s^2 operation, reducing the sum mod N. Or is that unavoidable?Compute i = r2 + s 2 mod N using C arithmetic and check whether B[i]==1. If yes do the full check.
This strategy reduces the number of full tests by a factor 1/2^(k+1).
But am I still facing the (r^2+s^2) mod N cost?
Randall