@@ -56,7 +56,7 @@ Datum fft_agg_finalfn(PG_FUNCTION_ARGS)
56
56
ndims = ARR_NDIM (input );
57
57
dims = ARR_DIMS (input );
58
58
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); */
60
60
61
61
Assert (ndims == 1 );
62
62
Assert (eltype == FLOAT4OID );
@@ -75,26 +75,29 @@ Datum fft_agg_finalfn(PG_FUNCTION_ARGS)
75
75
cx_out = palloc0 (* dims * sizeof (kiss_fft_cpx ));
76
76
77
77
/* 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
+ }
80
82
81
83
if ((cfg = kiss_fft_alloc (* dims , 0 , 0 , 0 )) == NULL )
82
84
elog (ERROR , "kiss_fft_alloc() failed" );
83
85
84
86
kiss_fft (cfg , cx_in , cx_out );
85
87
86
88
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 ) ;
88
90
/*
89
91
printf("%23.15e %23.15e\n", freq / (double)n * (double)i,
90
92
(cx_out[i].r * cx_out[i].r + cx_out[i].i * cx_out[i].i) / (double)n);
91
93
*/
94
+ /* elog(INFO, "data %d %f", i, (double)(data[i])); */
92
95
}
93
96
94
97
/*
95
98
elog(INFO, "odata: %p dims: %d otype: %d olen: %d obyval: %d align: %d",
96
99
data, *dims, eltype, typlen, typbyval, typalign);
97
- */
100
+ */
98
101
99
102
result = construct_array ((void * )data , * dims , eltype , typlen , typbyval , typalign );
100
103
0 commit comments