Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance the speed of whitenoise; #33

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
better detection of compressed.
rainwoodman committed May 25, 2018
commit 343168a4eaa3f19c887715a03169ce7e822875b9
39 changes: 27 additions & 12 deletions pmesh/_whitenoise_generics.h
Original file line number Diff line number Diff line change
@@ -40,18 +40,33 @@ mkname(_generic_fill)(PMeshWhiteNoiseGenerator * self, void * delta_k, int seed)

int signs[3];

printf("size = %td Nmesh = %td\n", self->size[2], self->Nmesh[2]);
if (self->size[2] == self->Nmesh[2] / 2 + 1 && self->start[2] == 0) {
/* only half of the fourier space is requested, ignore the conjugates */
signs[0] = 1;
signs[1] = 0;
signs[2] = 0;
} else {
/* full fourier space field is requested */
/* do negative then positive. ordering is import to makesure the positive overwrites nyquist. */
signs[0] = -1;
signs[1] = 1;
signs[2] = 0;
{
int compressed = 1;
ptrdiff_t iabs[3] = {self->start[0], self->start[1], 0};

/* if no negative k modes are requested, do not work with negative sign;
* this saves half of the computing time. */

for(k = self->Nmesh[2] / 2 + 1; k < self->Nmesh[2]; k ++) {
iabs[2] = k;
if (mkname(_has_mode)(self, iabs)) {
compressed = 0;
break;
}
}
printf("compressed = %d\n", compressed);
if (compressed) {
/* only half of the fourier space is requested, ignore the conjugates */
signs[0] = 1;
signs[1] = 0;
signs[2] = 0;
} else {
/* full fourier space field is requested */
/* do negative then positive. ordering is import to makesure the positive overwrites nyquist. */
signs[0] = -1;
signs[1] = 1;
signs[2] = 0;
}
}

gsl_rng * rng = gsl_rng_alloc(gsl_rng_ranlxd1);