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
123typedef struct dft_plan DftPlan;
124
138DAS_API DftPlan* new_DftPlan(size_t uLen, bool bForward);
139
140
155DAS_API bool del_DftPlan(DftPlan* pThis);
156
164typedef struct das_dft_t{
165
166 /* The plan, the only variable changed in the plan is the usage count */
167 DftPlan* pPlan;
168
169 /* FFTW variables */
170 void* vpIn;
171 void* vpOut;
172
173 /* Input vector length */
174 size_t uLen;
175
176 /* Input vector is real only*/
177 bool bRealOnly;
178
179 /* DFT Direction */
180 bool bForward;
181
182 /* Holder for the window function and name*/
183 char* sWindow;
184 double* pWnd;
185
186 /* Holder for the magnitude result */
187 bool bNewMag;
188 double* pMag;
189 size_t uMagLen;
190
191 /* Holder for continuous real and imaginary results */
192 bool bNewCmp[2]; /* fftw convention: 0 = reals, 1 = img */
193 double* pCmpOut[2];
194 size_t uCmpLen[2];
195
196} Das2Dft;
197
213DAS_API Das2Dft* new_Dft(DftPlan* pPlan, const char* sWindow);
214
223DAS_API void del_Dft(Das2Dft* pThis);
224
245 Das2Dft* pThis, const double* pReal, const double* pImg
246);
247
254DAS_API const double* Dft_getReal(Das2Dft* pThis, size_t* pLen);
255
263DAS_API const double* Dft_getImg(Das2Dft* pThis, size_t* pLen);
264
289DAS_API const double* Dft_getMagnitude(Das2Dft* pThis, size_t* pLen);
290
296typedef struct das_psd_t{
297
298 /* The plan, the only variable changed in the plan is the usage count */
299 DftPlan* pPlan;
300
301 /* FFTW variables */
302 void* vpIn;
303 void* vpOut;
304
305 /* Input vector information */
306 size_t uLen;
307 bool bRealOnly;
308
309 /* Center data about average first */
310 bool bCenter;
311
312 /* Holder for up conversion arrays, helps Psd_calculate_f*/
313 size_t uUpConvLen;
314 double* pUpConvReal;
315 double* pUpConvImg;
316
317 /* Holder for the window function and name */
318 char* sWindow;
319 double* pWnd;
320 double rWndSqSum;
321
322 /* Holder for the PSD result */
323 double* pMag;
324 size_t uMagLen;
325
326 /* Total Energy calculations */
327 double rPwrIn;
328 double rPwrOut;
329
330} Das2Psd;
331
351DAS_API Das2Psd* new_Psd(DftPlan* pPlan, bool bCenter, const char* sWindow);
352
361DAS_API void del_Das2Psd(Das2Psd* pThis);
362
363
384 Das2Psd* pThis, const double* pReal, const double* pImg
385);
386
393 Das2Psd* pThis, const float* pReal, const float* pImg
394);
395
448DAS_API double Psd_powerRatio(
449 const Das2Psd* pThis, double* pInput, double* pOutput
450);
451
452
478DAS_API const double* Psd_get(const Das2Psd* pThis, size_t* pLen);
479
480#ifdef __cplusplus
481}
482#endif
483
485#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:123
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:189
An amplitude preserving Discrete Fourier Transform converter.
Definition dft.h:164
A power spectral density estimator (periodogram)
Definition dft.h:296