Emmanuel ROYER on Thu, 28 Mar 2024 11:40:27 +0100


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

Array of the multiplicities of a highly non injective function


Dear Pari-users and developers!

Suppose we have a symmetrical function f from [1,K]x[1,K] with values in [1,q] where the integer K is significantly greater than the integer q.

I want to construct a vector V (of size q) such that each V[a] contains the number of pairs (i,j) such that a = f(i,j).

I have two questions
1) Is there a more efficient way of doing what I want than the code below?
2) Can we imagine parallelizing, for example, the loop on i ?

K = 30;
q = 7;
f(i,j) = 1+lift(Mod(i^2+j^2+i*j,q));
V = vector(q,h,0);
for(i=1,K,V[f(i,i)] += 1;for(j=1,i-1,V[f(i,j)] += 2));
V

Comments
- You have to imagine K much larger
- I have fixed f in the example but I want to be able to do something for any other choice respecting the assumptions (essentially, symmetry).  


Emmanuel Royer
Professeur à l'Université Clermont Auvergne
https://royer.perso.math.cnrs.fr
----
Institut CNRS-Pauli
IRL2842
CNRS & Wolfgang Pauli Institut