XTOS / OPEN SOURCE REAL-TIME SYSTEMOPEN SOURCE · VERSION 0.9.0 · BUILD FROM SOURCE
libxtos-signalxtos_signal_fft_power

xtos_signal_fft_power

Computes one-sided squared-magnitude power for an unnormalized DFT, bins 0 through n/2.

On this page

Declaration

c
#include <xtos/signal.h>

int xtos_signal_fft_power(const double *input,
                          size_t n,
                          double *power,
                          size_t power_count);

Parameters

ParameterTypeDescription
inputconst double *Non-NULL input with at least n doubles; the implementation does not check NaN/Inf.
nsize_tA nonzero power of two determining the FFT length.
powerdouble *Non-NULL caller-allocated output with at least n/2+1 entries.
power_countsize_tOutput capacity in double elements, at least n/2+1.

Return value

Returns 0 on success and -1 on failure. power[0..n/2] is written; extra capacity is untouched.

Errors

errnoCondition
EINVALA pointer is NULL, n is not a nonzero power of two, or output capacity is too small.
ENOMEMAllocation of either internal n-element temporary array failed.

Notes

  • The implementation calloc-allocates two n-element arrays and frees them before return; the caller still owns power.
  • Power is Re(X)^2+Im(X)^2 with no n or n^2 normalization, window, mean removal, or automatic factor of 2; NaN/Inf are not checked.

Example

Source

This reference describes headers and implementation at OpenXTOS commit dd313955ad57542bcd2af8827157d1bbd0cf5e83.