libdas2
das2 core C utilities
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 libdas2, the Core Das2 C Library.
4  *
5  * Libdas2 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  * Libdas2 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 libdas2; 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
111 extern "C" {
112 #endif
113 
114 
119 /* Called from das_init */
120 bool dft_init(const char* sProgName);
121 
124 typedef struct dft_plan DftPlan;
125 
139 DftPlan* new_DftPlan(size_t uLen, bool bForward);
140 
141 
156 bool del_DftPlan(DftPlan* pThis);
157 
165 typedef struct das_dft_t{
166 
167  /* The plan, the only varible changed in the plan is the usage count */
168  DftPlan* pPlan;
169 
170  /* FFTW variables */
171  void* vpIn;
172  void* vpOut;
173 
174  /* Input vector length */
175  size_t uLen;
176 
177  /* Input vector is real only*/
178  bool bRealOnly;
179 
180  /* DFT Direction */
181  bool bForward;
182 
183  /* Holder for the window function and name*/
184  char* sWindow;
185  double* pWnd;
186 
187  /* Holder for the magnitude result */
188  bool bNewMag;
189  double* pMag;
190  size_t uMagLen;
191 
192  /* Holder for continuous real and imaginary results */
193  bool bNewCmp[2]; /* fftw convention: 0 = reals, 1 = img */
194  double* pCmpOut[2];
195  size_t uCmpLen[2];
196 
197 } Das2Dft;
198 
214 Das2Dft* new_Dft(DftPlan* pPlan, const char* sWindow);
215 
224 void del_Dft(Das2Dft* pThis);
225 
246  Das2Dft* pThis, const double* pReal, const double* pImg
247 );
248 
255 const double* Dft_getReal(Das2Dft* pThis, size_t* pLen);
256 
264 const double* Dft_getImg(Das2Dft* pThis, size_t* pLen);
265 
290 const double* Dft_getMagnitude(Das2Dft* pThis, size_t* pLen);
291 
297 typedef struct das_psd_t{
298 
299  /* The plan, the only varible changed in the plan is the usage count */
300  DftPlan* pPlan;
301 
302  /* FFTW variables */
303  void* vpIn;
304  void* vpOut;
305 
306  /* Input vector information */
307  size_t uLen;
308  bool bRealOnly;
309 
310  /* Center data about average first */
311  bool bCenter;
312 
313  /* Holder for up conversion arrays, helps Psd_calculate_f*/
314  size_t uUpConvLen;
315  double* pUpConvReal;
316  double* pUpConvImg;
317 
318  /* Holder for the window function and name */
319  char* sWindow;
320  double* pWnd;
321  double rWndSqSum;
322 
323  /* Holder for the PSD result */
324  double* pMag;
325  size_t uMagLen;
326 
327  /* Total Energy calculations */
328  double rPwrIn;
329  double rPwrOut;
330 
331 } Das2Psd;
332 
352 Das2Psd* new_Psd(DftPlan* pPlan, bool bCenter, const char* sWindow);
353 
362 void del_Das2Psd(Das2Psd* pThis);
363 
364 
385  Das2Psd* pThis, const double* pReal, const double* pImg
386 );
387 
394  Das2Psd* pThis, const float* pReal, const float* pImg
395 );
396 
449 double Psd_powerRatio(const Das2Psd* pThis, double* pInput, double* pOutput);
450 
451 
477 const double* Psd_get(const Das2Psd* pThis, size_t* pLen);
478 
479 #ifdef __cplusplus
480 }
481 #endif
482 
484 #endif
const double * Psd_get(const Das2Psd *pThis, size_t *pLen)
Get the amplitude magnitude vector from a calculation.
void del_Das2Psd(Das2Psd *pThis)
Free a Power Spectral Density calculator.
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition: util.h:117
void del_Dft(Das2Dft *pThis)
Free a DFT (Discrete Fourier Transform) calculator.
Das2Psd * new_Psd(DftPlan *pPlan, bool bCenter, const char *sWindow)
Create a new Power Spectral Density Calculator.
const double * Dft_getReal(Das2Dft *pThis, size_t *pLen)
Return the real component after a calculation.
An amplitude preserving Discrete Fourier Transform converter.
Definition: dft.h:165
DasErrCode Psd_calculate(Das2Psd *pThis, const double *pReal, const double *pImg)
Calculate a Power Spectral Density (periodogram)
A power spectral density estimator (periodogram)
Definition: dft.h:297
DasErrCode Psd_calculate_f(Das2Psd *pThis, const float *pReal, const float *pImg)
The floating point array input analog of Psd_calaculate()
DasErrCode Dft_calculate(Das2Dft *pThis, const double *pReal, const double *pImg)
Calculate a discrete Fourier transform.
double Psd_powerRatio(const Das2Psd *pThis, double *pInput, double *pOutput)
Provide a comparison of the input power and the output power.
Das2Dft * new_Dft(DftPlan *pPlan, const char *sWindow)
Create a new DFT calculator.
struct dft_plan DftPlan
An structure containing a set of global planning data for DFTs to be preformed.
Definition: dft.h:124
const double * Dft_getMagnitude(Das2Dft *pThis, size_t *pLen)
Get the amplitude magnitude vector from a calculation.
const double * Dft_getImg(Das2Dft *pThis, size_t *pLen)
Return the imaginary component after a calculation.