aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorAlexandra Tolstikova <alexandra.tolstikova@desy.de>2015-06-17 12:49:04 +0200
committerAlexandra Tolstikova <alexandra.tolstikova@desy.de>2015-06-17 12:49:04 +0200
commit10e85f43e59949eec1c8a479b37b029d8d495c71 (patch)
treef3d57c38d6dc473bc2c85d0802dd22b462823f38 /libcrystfel
parent067842bd0480ad7f4e5680158e80c40d23d08041 (diff)
Fix fft in[N] array subscript calculation
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/asdf.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libcrystfel/src/asdf.c b/libcrystfel/src/asdf.c
index fb2f8279..da12e3c1 100644
--- a/libcrystfel/src/asdf.c
+++ b/libcrystfel/src/asdf.c
@@ -286,7 +286,7 @@ static int check_cell(struct asdf_private *dp, struct image *image,
}
-static int compare_doubles (const void *a, const void *b)
+static int compare_doubles(const void *a, const void *b)
{
const double *da = (const double *) a;
const double *db = (const double *) b;
@@ -296,7 +296,7 @@ static int compare_doubles (const void *a, const void *b)
/* Compares tvectors by length */
-static int compare_tvectors (const void *a, const void *b)
+static int compare_tvectors(const void *a, const void *b)
{
struct tvector *ta = (struct tvector *) a;
struct tvector *tb = (struct tvector *) b;
@@ -357,7 +357,7 @@ static float find_ds_fft(double *projections, int N_projections, double d_max,
memcpy(projections_sorted, projections, sizeof(double) * n);
qsort(projections_sorted, n, sizeof(double), compare_doubles);
- int i;
+ int i, k;
int N = fftw.N; // number of points in fft calculation
double *in = fftw.in;
@@ -369,8 +369,11 @@ static float find_ds_fft(double *projections, int N_projections, double d_max,
}
for ( i = 0; i < n; i++ ) {
- in[(int)((projections_sorted[i] - projections_sorted[0]) /
- (projections_sorted[n - 1] - projections_sorted[0]) * N)] ++;
+
+ k = (int)((projections_sorted[i] - projections_sorted[0]) /
+ (projections_sorted[n - 1] - projections_sorted[0]) *
+ (N - 1));
+ in[k] ++;
}
fftw_execute_dft_r2c(p, in, out);