summaryrefslogtreecommitdiff
path: root/src/randfuncs.c
diff options
context:
space:
mode:
authorpants <jaron@kent-dobias.com>2016-08-31 14:04:55 -0400
committerpants <jaron@kent-dobias.com>2016-08-31 14:04:55 -0400
commit7ff906b9cd27a44472b40e78e5d595ea41df1482 (patch)
treed6b3b5a930847dd52f308d34f07058928631633c /src/randfuncs.c
parent0f6782c9e5a9171d69d8e62dff33a558ba542d58 (diff)
downloadfuse_networks-7ff906b9cd27a44472b40e78e5d595ea41df1482.tar.gz
fuse_networks-7ff906b9cd27a44472b40e78e5d595ea41df1482.tar.bz2
fuse_networks-7ff906b9cd27a44472b40e78e5d595ea41df1482.zip
can generate voronoi networks with regular boundaries
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;