summaryrefslogtreecommitdiff
path: root/src/randfuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/randfuncs.c')
-rw-r--r--src/randfuncs.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/randfuncs.c b/src/randfuncs.c
index 35b9f56..830e078 100644
--- a/src/randfuncs.c
+++ b/src/randfuncs.c
@@ -22,23 +22,25 @@ double *genfunc_hyperuniform(unsigned int L, bound_t boundary, gsl_rng *r, unsig
double *lattice = (double *)malloc(2 * (*num) * sizeof(double));
double rho = *num;
unsigned int to_gen = *num;
+ unsigned int start = 0;
if (boundary == EMBEDDED_BOUND) {
for (unsigned int i = 0; i < L / 2; i++) {
- lattice[2 * i] = 0;
- lattice[2 * i + 1] = (2. * i + 1.) / L;
-
- lattice[L / 2 + 2 * i] = 1;
- lattice[L / 2 + 2 * i + 1] = (2. * i + 1.) / L;
+ lattice[2 * i + 1] = 0;
+ lattice[2 * i] = (2. * i + 1.) / L;
+ lattice[L + 2 * i + 1] = 1;
lattice[L + 2 * i] = (2. * i + 1.) / L;
- lattice[L + 2 * i + 1] = 0;
- lattice[3 * L / 2 + 2 * i] = (2. * i + 1.) / L;
- lattice[3 * L / 2 + 2 * i + 1] = 1;
+ lattice[2 * L + 2 * i + 1] = (2. * i + 1.) / L;
+ lattice[2 * L + 2 * i] = 0;
+
+ lattice[3 * L + 2 * i + 1] = (2. * i + 1.) / L;
+ lattice[3 * L + 2 * i] = 1;
}
to_gen -= 2 * L;
+ start = 2 * L;
}
for (unsigned int i = 0; i < to_gen; i++) {
@@ -67,8 +69,8 @@ double *genfunc_hyperuniform(unsigned int L, bound_t boundary, gsl_rng *r, unsig
}
}
}
- lattice[2 * i] = x;
- lattice[2 * i + 1] = y;
+ lattice[2*start + 2 * i] = x;
+ lattice[2*start + 2 * i + 1] = y;
}
return lattice;