An Implementation Error in SampleC Function
Hello, we found an implementation error in your code. We (Yichen Gong, Shiduo Zhang and Yang Yu) are members of a lattice research team in Tsinghua University.
In SampleC function, this code *a = *a - (static_cast<double>((*z)[k - 1])) * c;
is wrong, the correct code should be *a = *a + (static_cast<double>((*z)[k - 1])) * c;
. You can test the distribution of SampleC's output is not a spherical Gaussian distribution.
In GM18, the pseudocode describing SampleD which is SampleC in your implementation has a clerical error about this line. c = c - z_k-1 * d should be -c = -c - z_k-1 * d and then c = c + z_k-1 * d because SampleD returns a sample whose distribution's center is -c while SampleD's input is c.
Edited by Yichen