From 7ff906b9cd27a44472b40e78e5d595ea41df1482 Mon Sep 17 00:00:00 2001 From: pants Date: Wed, 31 Aug 2016 14:04:55 -0400 Subject: can generate voronoi networks with regular boundaries --- src/randfuncs.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/randfuncs.c') 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; -- cgit v1.2.3-70-g09d2