Home | Develop | Download | Contact
 Todo Estructuras de Datos Funciones Variables 'typedefs' Grupos Páginas
testprograma1.c
1 /*
2  * testprograma1.c
3  *
4  * Copyright 2011 Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  *
21  */
22 
30 #include <config.h>
31 #include <stdlib.h>
32 #include <pds/pdsft.h>
33 #include <pds/pdsvector.h>
34 #include <pds/pdscvector.h>
35 
36 #include "extras.h"
37 
38 int main(int argc, char** argv)
39 {
40 
41  PdsFft *FFT=NULL;
42  PdsGoertzel *FT=NULL;
43 
44  PdsVector *Vin=NULL;
45  PdsCVector *Vout=NULL;
46  PdsCVector *V=NULL;
47 
48  PdsComplex X;
49  int i,N=32,k=10;
50 
51  FILE *fd=NULL;
52 
53  FFT=pds_fft_new(&N);
54  FT=pds_goertzel_new(k,N);
55  Vin=pds_vector_new(N);
56  Vout=pds_cvector_new(N);
57  V=pds_cvector_new(N);
58 
59  for(i=0;i<N/4;i++) Vin->V[i]=1.0;
60 
61  pds_fft_evaluate_real(FFT,Vout,Vin);
62  pds_goertzel_evaluate_real(FT,&X,Vin);
63  pds_ifft_evaluate_complex((PdsIFft*)FFT,V,Vout);
64 
65  fd=fopen("datos.dat","w");
66  pds_vector_fprintf(Vin,fd);
67  pds_cvector_fprintf(Vout,fd);
68  pds_cvector_fprintf(V,fd);
69  fclose(fd);
70 
71  printf("Vout[%d]=%e %ei\n",k,Vout->V[k].Real,Vout->V[k].Imag);
72  printf(" X[%d]=%e %ei\n",k,X.Real,X.Imag);
73 
74  pds_octplot_cvector_in_png(Vout,"n","Vout[n]","graficaVout.m","graficaVout.png");
75  pds_octplot_cvector_in_png(V,"n","V[n]","graficaV.m","graficaV.png");
76 
77  pds_cvector_free(V);
78  pds_cvector_free(Vout);
79  pds_vector_free(Vin);
81  pds_fft_free(FFT);
82 
83  return EXIT_SUCCESS;
84 }
85 
void pds_goertzel_free(PdsGoertzel *FT)
Libera una estructura de tipo puntero PdsGoertzel.
Estructura tipo PdsIFft. Esta estructura genera una Inversa de la Transformada Rápida de Fourier de N...
Definition: pdsifft.h:86
PdsGoertzel * pds_goertzel_new(PdsFtNatural k, PdsFtNatural N)
Crea una estructura de tipo PdsGoertzel, para generar una FT de N puntos. Si N no es potencia de 2...
int pds_fft_evaluate_real(const PdsFft *FFT, PdsCVector *Out, const PdsVector *In)
Evalua la transformada rapida de fourier a un vetor real. El tamanho del vector Out debe ser igual qu...
int pds_goertzel_evaluate_real(const PdsGoertzel *FT, PdsComplex *X, const PdsVector *In)
Evalúa la transformada de fourier X[k] a un vector real. El tamaño del vector In debe ser igual o men...
PdsFft * pds_fft_new(PdsFtNatural *N)
Crea una estructura de tipo PdsFft, para generar una FFT de N puntos. Si N no es potencia de 2...
int pds_ifft_evaluate_complex(const PdsIFft *IFFT, PdsCVector *Out, const PdsCVector *In)
Evalua la inversa de la transformada rápida de fourier a un vetor complejo. El tamaño del vector Out ...
Estructura tipo PdsGoertzel. Esta estructura genera una Transformada de Fourier de N puntos aplicando...
Definition: pdsgoertzel.h:95
void pds_fft_free(PdsFft *FFT)
Libera una estructura de tipo puntero PdsFft.
Estructura tipo PdsFft. Esta estructura genera una Transformada Rápida de Fourier de N puntos...
Definition: pdsfft.h:84

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed