Skip to content

Commit e8a1cd8

Browse files
committed
Casting error (Datum *) fixed.
1 parent dc6530a commit e8a1cd8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/kissfft.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Datum fft_agg_finalfn(PG_FUNCTION_ARGS)
5656
ndims = ARR_NDIM(input);
5757
dims = ARR_DIMS(input);
5858
eltype = ARR_ELEMTYPE(input);
59-
/* elog(INFO, "input dim: %d hasnull: %d elemtype: %d", ndims, *dims, eltype); */
59+
/* elog(INFO, "input ndims: %d dims: %d elemtype: %d", ndims, *dims, eltype); */
6060

6161
Assert(ndims == 1);
6262
Assert(eltype == FLOAT4OID);
@@ -75,26 +75,29 @@ Datum fft_agg_finalfn(PG_FUNCTION_ARGS)
7575
cx_out = palloc0(*dims * sizeof(kiss_fft_cpx));
7676

7777
/* apply scale */
78-
for (i=0; i<*dims; i++)
79-
cx_in[i].r = DatumGetFloat4(data[i]);
78+
for (i=0; i<*dims; i++) {
79+
cx_in[i].r = DatumGetFloat4(data[i]);
80+
/* elog(INFO, "%d %f %f", i, DatumGetFloat4(data[i]), cx_in[i].i); */
81+
}
8082

8183
if ((cfg = kiss_fft_alloc(*dims, 0, 0, 0)) == NULL)
8284
elog(ERROR, "kiss_fft_alloc() failed");
8385

8486
kiss_fft(cfg, cx_in, cx_out);
8587

8688
for (i=0; i<*dims; i++) {
87-
data[i] = (cx_out[i].r * cx_out[i].r + cx_out[i].i * cx_out[i].i) / (double)*dims;
89+
((float *)data)[i] = (cx_out[i].r * cx_out[i].r + cx_out[i].i * cx_out[i].i) / ((double)*dims);
8890
/*
8991
printf("%23.15e %23.15e\n", freq / (double)n * (double)i,
9092
(cx_out[i].r * cx_out[i].r + cx_out[i].i * cx_out[i].i) / (double)n);
9193
*/
94+
/* elog(INFO, "data %d %f", i, (double)(data[i])); */
9295
}
9396

9497
/*
9598
elog(INFO, "odata: %p dims: %d otype: %d olen: %d obyval: %d align: %d",
9699
data, *dims, eltype, typlen, typbyval, typalign);
97-
*/
100+
*/
98101

99102
result = construct_array((void *)data, *dims, eltype, typlen, typbyval, typalign);
100103

0 commit comments

Comments
 (0)