Native Chan–He collision counting #
This fixed native program first decodes signed Euclidean residue keys, then builds a
histogram and counts ordered collisions. Register setup between the two loops is charged.
For injective input arrays its counter is exactly the existing Chan–He coll.
Main definitions #
Count.program: the composed native residue/histogram program.Count.memory: the complete output memory, including the residue scratch array.
Main results #
Count.exec: execution in at most34n + 5M + 18native instructions.Count.exec_coll: the counter equals the existing mathematical collision count.Count.memory_before: cells below the two workspace blocks retain their contents.
References #
Residue routine registers occupy the first sixteen registers.
Histogram registers occupy registers sixteen through twenty-six.
Encoded integer input base.
Residue scratch base.
Number of input values.
Encoded positive modulus.
Histogram destination base.
Output collision count, an ordinary unsigned word.
Histogram input base register.
Histogram output base register.
Histogram length register.
Histogram modulus register.
Histogram constant register, also used to decode the encoded modulus.
Set up the histogram parameters, explicitly decoding the positive modulus.
A single finite native program, independent of input length, modulus and word width.
Complete native collision counting, including residue computation, clearing the histogram and register setup. Input, scratch and histogram blocks occur in that order and are disjoint. The final halt is excluded. Fit hypotheses are local; a caller must derive them from its input and width contract.
For an injective integer array, the composed program returns exactly the collision count used by the existing Chan–He prime searches.