libdspl-2.0
Digital Signal Processing Algorithm Library
fft.c
1/*
2* Copyright (c) 2015-2022 Sergey Bakhurin
3* Digital Signal Processing Library [http://dsplib.org]
4*
5* This file is part of libdspl-2.0.
6*
7* is free software: you can redistribute it and/or modify
8* it under the terms of the GNU Lesser General Public License as published by
9* the Free Software Foundation, either version 3 of the License, or
10* (at your option) any later version.
11*
12* DSPL is distributed in the hope that it will be useful,
13* but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15* GNU General Public License for more details.
16*
17* You should have received a copy of the GNU Lesser General Public License
18* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#include <stdlib.h>
22#include <stdio.h>
23#include <string.h>
24#include <float.h>
25
26#include "dspl.h"
27#include "dft.h"
28
29
30#ifdef DOXYGEN_ENGLISH
100#endif
101#ifdef DOXYGEN_RUSSIAN
172#endif
173int DSPL_API fft(double* x, int n, fft_t* pfft, complex_t* y)
174{
175 int err;
176
177 if(!x || !pfft || !y)
178 return ERROR_PTR;
179 if(n<1)
180 return ERROR_SIZE;
181
182
183 err = fft_create(pfft, n);
184 if(err != RES_OK)
185 return err;
186
187 re2cmplx(x, n, pfft->t1);
188
189 return fft_krn(pfft->t1, y, pfft, n, 0);
190}
int DSPL_API fft_create(fft_t *pfft, int n)
Function creates and fill fft_t structure.
Definition: fft_create.c:161
int DSPL_API fft(double *x, int n, fft_t *pfft, complex_t *y)
Fast Fourier transform for the real vector.
Definition: fft.c:173
#define RES_OK
The function completed correctly. No errors.
Definition: dspl.h:558
#define ERROR_PTR
Pointer error. This error means that one of the required pointers (memory to be allocated for) is tra...
Definition: dspl.h:610
#define ERROR_SIZE
Error array size. This error occurs when in addition to the pointer the wrong input is passed to the ...
Definition: dspl.h:618
int DSPL_API re2cmplx(double *x, int n, complex_t *y)
Convert real array to the complex array.
Definition: re2cmplx.c:120
double complex_t[2]
Complex data type.
Definition: dspl.h:86
Fast Fourier Transform Object Data Structure.
Definition: dspl.h:278
complex_t * t1
Definition: dspl.h:281