Alessandro Baretta <alex@baretta.com> writes:
> If I have to write the code myself, I would need to create a
> database function calling code from a C module. Such code
> would have to operate on real and complex float arrays. I
> understand how I could use a pl/pgsql function to create a
> new table where each signal is stored as a (signal_id,
> double array) tuple, but how am I supposed to pass such
> arrays to a C function? How are postgres arrays actually
> implemented in memory? In short, I need someone to get me
> started on writing an FFTW binding for pgsql, in none is
> already available.
You're intending to store each complete signal as a big array in one
row? That could get a bit ugly if the signals are very large (many
megabytes). But if you want to do it that way, I think the coding
would be pretty straightforward. See src/backend/utils/adt/float.c
for some examples of C functions that process arrays of floats ---
the "FLOAT AGGREGATE OPERATORS" section is relevant.
src/include/utils/array.h is relevant reading as well.
regards, tom lane