das2C
das core C utilities (v3)
Loading...
Searching...
No Matches
dft.h
Go to the documentation of this file.
1/* Copyright (C) 2015-2017 Chris Piker <chris-piker@uiowa.edu>
2 *
3 * This file is part of das2C, the Core Das2 C Library.
4 *
5 * Das2C is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License version 2.1 as published
7 * by the Free Software Foundation.
8 *
9 * Das2C is distributed in the hope that it will be useful, but WITHOUT ANY
10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * version 2.1 along with das2C; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18
107#ifndef _das_dft_h_
108#define _das_dft_h_
109
110#ifdef __cplusplus
111extern "C" {
112#endif
113
114#include <das3/defs.h>
115
116
121/* Called from das_init */
122bool dft_init(const char* sProgName);
123
126typedef struct dft_plan DftPlan;
127
141DAS_API DftPlan* new_DftPlan(size_t uLen, bool bForward);
142
143
158DAS_API bool del_DftPlan(DftPlan* pThis);
159
167typedef struct das_dft_t{
168
169 /* The plan, the only variable changed in the plan is the usage count */
170 DftPlan* pPlan;
171
172 /* FFTW variables */
173 void* vpIn;
174 void* vpOut;
175
176 /* Input vector length */
177 size_t uLen;
178
179 /* Input vector is real only*/
180 bool bRealOnly;
181
182 /* DFT Direction */
183 bool bForward;
184
185 /* Holder for the window function and name*/
186 char* sWindow;
187 double* pWnd;
188
189 /* Holder for the magnitude result */
190 bool bNewMag;
191 double* pMag;
192 size_t uMagLen;
193
194 /* Holder for continuous real and imaginary results */
195 bool bNewCmp[2]; /* fftw convention: 0 = reals, 1 = img */
196 double* pCmpOut[2];
197 size_t uCmpLen[2];
198
199} Das2Dft;
200
216DAS_API Das2Dft* new_Dft(DftPlan* pPlan, const char* sWindow);
217
226DAS_API void del_Dft(Das2Dft* pThis);
227
248 Das2Dft* pThis, const double* pReal, const double* pImg
249);
250
257DAS_API const double* Dft_getReal(Das2Dft* pThis, size_t* pLen);
258
266DAS_API const double* Dft_getImg(Das2Dft* pThis, size_t* pLen);
267
292DAS_API const double* Dft_getMagnitude(Das2Dft* pThis, size_t* pLen);
293
299typedef struct das_psd_t{
300
301 /* The plan, the only variable changed in the plan is the usage count */
302 DftPlan* pPlan;
303
304 /* FFTW variables */
305 void* vpIn;
306 void* vpOut;
307
308 /* Input vector information */
309 size_t uLen;
310 bool bRealOnly;
311
312 /* Center data about average first */
313 bool bCenter;
314
315 /* Holder for up conversion arrays, helps Psd_calculate_f*/
316 size_t uUpConvLen;
317 double* pUpConvReal;
318 double* pUpConvImg;
319
320 /* Holder for the window function and name */
321 char* sWindow;
322 double* pWnd;
323 double rWndSqSum;
324
325 /* Holder for the PSD result */
326 double* pMag;
327 size_t uMagLen;
328
329 /* Total Energy calculations */
330 double rPwrIn;
331 double rPwrOut;
332
333} Das2Psd;
334
354DAS_API Das2Psd* new_Psd(DftPlan* pPlan, bool bCenter, const char* sWindow);
355
364DAS_API void del_Das2Psd(Das2Psd* pThis);
365
366
387 Das2Psd* pThis, const double* pReal, const double* pImg
388);
389
396 Das2Psd* pThis, const float* pReal, const float* pImg
397);
398
451DAS_API double Psd_powerRatio(
452 const Das2Psd* pThis, double* pInput, double* pOutput
453);
454
455
481DAS_API const double* Psd_get(const Das2Psd* pThis, size_t* pLen);
482
483#ifdef __cplusplus
484}
485#endif
486
488#endif
Minimal definitions for das2 utilities that can safely be run without calling das_init().
DAS_API Das2Dft * new_Dft(DftPlan *pPlan, const char *sWindow)
Create a new DFT calculator.
DAS_API void del_Das2Psd(Das2Psd *pThis)
Free a Power Spectral Density calculator.
DAS_API DasErrCode Psd_calculate(Das2Psd *pThis, const double *pReal, const double *pImg)
Calculate a Power Spectral Density (periodogram)
DAS_API DasErrCode Dft_calculate(Das2Dft *pThis, const double *pReal, const double *pImg)
Calculate a discrete Fourier transform.
DAS_API const double * Dft_getReal(Das2Dft *pThis, size_t *pLen)
Return the real component after a calculation.
DAS_API const double * Dft_getMagnitude(Das2Dft *pThis, size_t *pLen)
Get the amplitude magnitude vector from a calculation.
DAS_API const double * Psd_get(const Das2Psd *pThis, size_t *pLen)
Get the amplitude magnitude vector from a calculation.
DAS_API double Psd_powerRatio(const Das2Psd *pThis, double *pInput, double *pOutput)
Provide a comparison of the input power and the output power.
struct dft_plan DftPlan
An structure containing a set of global planning data for DFTs to be preformed.
Definition dft.h:126
DAS_API void del_Dft(Das2Dft *pThis)
Free a DFT (Discrete Fourier Transform) calculator.
DAS_API Das2Psd * new_Psd(DftPlan *pPlan, bool bCenter, const char *sWindow)
Create a new Power Spectral Density Calculator.
DAS_API const double * Dft_getImg(Das2Dft *pThis, size_t *pLen)
Return the imaginary component after a calculation.
DAS_API DasErrCode Psd_calculate_f(Das2Psd *pThis, const float *pReal, const float *pImg)
The floating point array input analog of Psd_calaculate()
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition defs.h:184
An amplitude preserving Discrete Fourier Transform converter.
Definition dft.h:167
A power spectral density estimator (periodogram)
Definition dft.h:299