diff options
Diffstat (limited to 'src/signalProcessing/fft')
-rw-r--r-- | src/signalProcessing/fft/Makefile.am | 8 | ||||
-rw-r--r-- | src/signalProcessing/fft/Makefile.in | 28 | ||||
-rw-r--r-- | src/signalProcessing/fft/dfftma.c | 31 | ||||
-rw-r--r-- | src/signalProcessing/fft/sfftma.c | 31 | ||||
-rw-r--r-- | src/signalProcessing/fft/testMatFft.c | 103 |
5 files changed, 172 insertions, 29 deletions
diff --git a/src/signalProcessing/fft/Makefile.am b/src/signalProcessing/fft/Makefile.am index 46d75349..2c6c184c 100644 --- a/src/signalProcessing/fft/Makefile.am +++ b/src/signalProcessing/fft/Makefile.am @@ -16,6 +16,7 @@ libFft_la_CFLAGS = -I . \ -I $(top_builddir)/type \ -I $(top_builddir)/signalProcessing/includes \ -I $(top_builddir)/operations/includes \ + -I $(top_builddir)/matrixOperations/includes \ -I $(top_builddir)/auxiliaryFunctions/includes instdir = $(top_builddir)/lib @@ -35,8 +36,9 @@ SRC = zfftma.c \ fft842.c \ r2tx.c \ r4tx.c \ - r8tx.c - + r8tx.c \ + dfftma.c \ + sfftma.c #### # Checking Part @@ -45,6 +47,7 @@ SRC = zfftma.c \ check_INCLUDES = -I . \ -I $(top_builddir)/type \ -I $(top_builddir)/signalProcessing/includes \ + -I $(top_builddir)/matrixOperations/includes \ -I $(top_builddir)/operations/includes \ -I $(top_builddir)/auxiliaryFunctions/includes @@ -56,6 +59,7 @@ check_LDADD = $(top_builddir)/type/libDoubleComplex.la \ $(top_builddir)/signalProcessing/fft/libFft.la \ $(top_builddir)/operations/addition/libAddition.la \ $(top_builddir)/operations/subtraction/libSubtraction.la \ + $(top_builddir)/matrixOperations/zeros/libMatrixZeros.la \ @LIBMATH@ check_PROGRAMS = testFloatFft testDoubleFft testMatFft diff --git a/src/signalProcessing/fft/Makefile.in b/src/signalProcessing/fft/Makefile.in index 4be18b9d..4deb6077 100644 --- a/src/signalProcessing/fft/Makefile.in +++ b/src/signalProcessing/fft/Makefile.in @@ -59,7 +59,7 @@ am__objects_1 = am__objects_2 = libFft_la-zfftma.lo libFft_la-cfftma.lo \ libFft_la-dfft2.lo libFft_la-dfftbi.lo libFft_la-dfftmx.lo \ libFft_la-fft842.lo libFft_la-r2tx.lo libFft_la-r4tx.lo \ - libFft_la-r8tx.lo + libFft_la-r8tx.lo libFft_la-dfftma.lo libFft_la-sfftma.lo am_libFft_la_OBJECTS = $(am__objects_1) $(am__objects_2) libFft_la_OBJECTS = $(am_libFft_la_OBJECTS) libFft_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ @@ -73,7 +73,8 @@ am__DEPENDENCIES_1 = $(top_builddir)/type/libDoubleComplex.la \ $(top_builddir)/lib/blas/libsciblas.la \ $(top_builddir)/signalProcessing/fft/libFft.la \ $(top_builddir)/operations/addition/libAddition.la \ - $(top_builddir)/operations/subtraction/libSubtraction.la + $(top_builddir)/operations/subtraction/libSubtraction.la \ + $(top_builddir)/matrixOperations/zeros/libMatrixZeros.la testDoubleFft_DEPENDENCIES = $(am__DEPENDENCIES_1) testDoubleFft_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(testDoubleFft_CFLAGS) \ @@ -223,6 +224,7 @@ libFft_la_CFLAGS = -I . \ -I $(top_builddir)/type \ -I $(top_builddir)/signalProcessing/includes \ -I $(top_builddir)/operations/includes \ + -I $(top_builddir)/matrixOperations/includes \ -I $(top_builddir)/auxiliaryFunctions/includes instdir = $(top_builddir)/lib @@ -239,7 +241,9 @@ SRC = zfftma.c \ fft842.c \ r2tx.c \ r4tx.c \ - r8tx.c + r8tx.c \ + dfftma.c \ + sfftma.c #### @@ -248,6 +252,7 @@ SRC = zfftma.c \ check_INCLUDES = -I . \ -I $(top_builddir)/type \ -I $(top_builddir)/signalProcessing/includes \ + -I $(top_builddir)/matrixOperations/includes \ -I $(top_builddir)/operations/includes \ -I $(top_builddir)/auxiliaryFunctions/includes @@ -258,6 +263,7 @@ check_LDADD = $(top_builddir)/type/libDoubleComplex.la \ $(top_builddir)/signalProcessing/fft/libFft.la \ $(top_builddir)/operations/addition/libAddition.la \ $(top_builddir)/operations/subtraction/libSubtraction.la \ + $(top_builddir)/matrixOperations/zeros/libMatrixZeros.la \ @LIBMATH@ @@ -361,11 +367,13 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libFft_la-cfftma.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libFft_la-dfft2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libFft_la-dfftbi.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libFft_la-dfftma.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libFft_la-dfftmx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libFft_la-fft842.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libFft_la-r2tx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libFft_la-r4tx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libFft_la-r8tx.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libFft_la-sfftma.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libFft_la-zfftma.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testDoubleFft-testDoubleFft.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testFloatFft-testFloatFft.Po@am__quote@ @@ -455,6 +463,20 @@ libFft_la-r8tx.lo: r8tx.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libFft_la_CFLAGS) $(CFLAGS) -c -o libFft_la-r8tx.lo `test -f 'r8tx.c' || echo '$(srcdir)/'`r8tx.c +libFft_la-dfftma.lo: dfftma.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libFft_la_CFLAGS) $(CFLAGS) -MT libFft_la-dfftma.lo -MD -MP -MF $(DEPDIR)/libFft_la-dfftma.Tpo -c -o libFft_la-dfftma.lo `test -f 'dfftma.c' || echo '$(srcdir)/'`dfftma.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libFft_la-dfftma.Tpo $(DEPDIR)/libFft_la-dfftma.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dfftma.c' object='libFft_la-dfftma.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libFft_la_CFLAGS) $(CFLAGS) -c -o libFft_la-dfftma.lo `test -f 'dfftma.c' || echo '$(srcdir)/'`dfftma.c + +libFft_la-sfftma.lo: sfftma.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libFft_la_CFLAGS) $(CFLAGS) -MT libFft_la-sfftma.lo -MD -MP -MF $(DEPDIR)/libFft_la-sfftma.Tpo -c -o libFft_la-sfftma.lo `test -f 'sfftma.c' || echo '$(srcdir)/'`sfftma.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libFft_la-sfftma.Tpo $(DEPDIR)/libFft_la-sfftma.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sfftma.c' object='libFft_la-sfftma.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libFft_la_CFLAGS) $(CFLAGS) -c -o libFft_la-sfftma.lo `test -f 'sfftma.c' || echo '$(srcdir)/'`sfftma.c + testDoubleFft-testDoubleFft.o: testDoubleFft.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testDoubleFft_CFLAGS) $(CFLAGS) -MT testDoubleFft-testDoubleFft.o -MD -MP -MF $(DEPDIR)/testDoubleFft-testDoubleFft.Tpo -c -o testDoubleFft-testDoubleFft.o `test -f 'testDoubleFft.c' || echo '$(srcdir)/'`testDoubleFft.c @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testDoubleFft-testDoubleFft.Tpo $(DEPDIR)/testDoubleFft-testDoubleFft.Po diff --git a/src/signalProcessing/fft/dfftma.c b/src/signalProcessing/fft/dfftma.c new file mode 100644 index 00000000..f855c1b7 --- /dev/null +++ b/src/signalProcessing/fft/dfftma.c @@ -0,0 +1,31 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008 - INRIA - Arnaud Torset + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include "fft.h" +#include "zeros.h" + + +void dfftma ( double* in , int rows, int cols, double* out){ + double* ZEROS; + doubleComplex* inCpx; + doubleComplex* outCpx; + + ZEROS = malloc((uint)(rows*cols)*sizeof(double)); + outCpx = malloc((uint)(rows*cols)*sizeof(doubleComplex)); + + dzerosa(ZEROS,rows,cols); + inCpx=DoubleComplexMatrix(in,ZEROS,rows*cols); + + zfftma(inCpx,rows,cols,outCpx); + + zreala(outCpx, rows*cols, out); +} diff --git a/src/signalProcessing/fft/sfftma.c b/src/signalProcessing/fft/sfftma.c new file mode 100644 index 00000000..c60c9427 --- /dev/null +++ b/src/signalProcessing/fft/sfftma.c @@ -0,0 +1,31 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008 - INRIA - Arnaud Torset + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include "fft.h" +#include "zeros.h" + + +void sfftma ( float* in , int rows, int cols, float* out){ + float* ZEROS; + floatComplex* inCpx; + floatComplex* outCpx; + + ZEROS = malloc((uint)(rows*cols)*sizeof(float)); + outCpx = malloc((uint)(rows*cols)*sizeof(floatComplex)); + + szerosa(ZEROS,rows,cols); + inCpx=FloatComplexMatrix(in,ZEROS,rows*cols); + + cfftma(inCpx,rows,cols,outCpx); + + creala(outCpx, rows*cols, out); +} diff --git a/src/signalProcessing/fft/testMatFft.c b/src/signalProcessing/fft/testMatFft.c index ee29cf72..de626d81 100644 --- a/src/signalProcessing/fft/testMatFft.c +++ b/src/signalProcessing/fft/testMatFft.c @@ -101,8 +101,74 @@ #define RRESULT9 {45,-4.5,-4.5,-13.5,0,0,-13.5,0,0} #define IRESULT9 {0,2.598076211353316011810,- 2.598076211353316011810,7.7942286340599471472501,0,0,- 7.7942286340599471472501,0,0} - -static int testFft(void){ + +static void dfftmaTest(void){ + int i; + + double in1[]=test1; + double in2[]=test2; + double in3[]=test3; + double in4[]=test4; + double in6[]=test6; + double in9[]=test9; + + double resR1[]=RRESULT1; + double resR2[]=RRESULT2; + double resR3[]=RRESULT3; + double resR4[]=RRESULT4; + double resR6[]=RRESULT6; + double resR9[]=RRESULT9; + + double out1[12], out2[12], out3[12], out4[12], out6[12], out9[9]; + + + printf(" >>> Matrice 1*12 <<< \n"); + dfftma(in1, 1, 12, out1); + for (i=0;i<12;i++){ + if (out1[i]>1e-14) assert( (fabs(out1[i]-resR1[i]) / fabs(out1[i])) < 1e-14 ); + else assert(1); + } + + printf(" >>> Matrice 2*6 <<< \n"); + dfftma(in2, 2, 6, out2); + for (i=0;i<12;i++){ + if (out2[i]>1e-14) assert( (fabs(out2[i]-resR2[i]) / fabs(out2[i])) < 1e-14 ); + else assert(1); + } + + + printf(" >>> Matrice 3*4 <<< \n"); + dfftma(in3, 3, 4, out3); + for (i=0;i<12;i++){ + if (out3[i]>1e-14) assert( (fabs(out3[i]-resR3[i]) / fabs(out3[i])) < 1e-14 ); + else assert(1); + } + + printf(" >>> Matrice 4*3 <<< \n"); + dfftma(in4, 4, 3, out4); + for (i=0;i<12;i++){ + if (out4[i]>1e-14) assert( (fabs(out4[i]-resR4[i]) / fabs(out4[i])) < 1e-14 ); + else assert(1); + } + + printf(" >>> Matrice 6*2 <<< \n"); + dfftma(in6, 6, 2, out6); + for (i=0;i<12;i++){ + if (out6[i]>1e-16) assert( (fabs(out6[i]-resR6[i]) / fabs(out6[i])) < 1e-14 ); + else assert(1); + } + + printf(" >>> Matrice 3*3 <<< \n"); + dfftma(in9, 3, 3, out9); + for (i=0;i<9;i++){ + if (out9[i]>1e-16) assert( (fabs(out9[i]-resR9[i]) / fabs(out9[i])) < 1e-16 ); + else assert(1); + } + + +} + +static void zfftmaTest(void){ int i; double inR1[]=test1; @@ -125,7 +191,7 @@ static int testFft(void){ double resR9[]=RRESULT9; double resI9[]=IRESULT9; - doubleComplex *in1, *in2, *in3, *in4, *in6, *in9, *out1, *out2, *out3, *out4, *out6, *out9; + doubleComplex *in1, *in2, *in3, *in4, *in6, *in9, out1[12], out2[12], out3[12], out4[12], out6[12], out9[12]; in1=malloc((uint)12*sizeof(doubleComplex)); in2=malloc((uint)12*sizeof(doubleComplex)); @@ -133,13 +199,9 @@ static int testFft(void){ in4=malloc((uint)12*sizeof(doubleComplex)); in6=malloc((uint)12*sizeof(doubleComplex)); in9=malloc((uint)9*sizeof(doubleComplex)); - out1=malloc((uint)12*sizeof(doubleComplex)); - out2=malloc((uint)12*sizeof(doubleComplex)); - out3=malloc((uint)12*sizeof(doubleComplex)); - out4=malloc((uint)12*sizeof(doubleComplex)); - out6=malloc((uint)12*sizeof(doubleComplex)); - out9=malloc((uint)9*sizeof(doubleComplex)); - + + + for (i=0;i<12;i++){ in1[i]=DoubleComplex(inR1[i],0); in2[i]=DoubleComplex(inR2[i],0); @@ -212,20 +274,13 @@ static int testFft(void){ if (zimags(out9[i])>1e-15) assert( (fabs(zimags(out9[i])-resI9[i]) / fabs(zimags(out9[i]))) < 1e-15 ); else assert(1); } - - - free(in1); - free(in2); - free(in3); - free(in4); - free(in6); - free(in9); - free(out1); - free(out2); - free(out3); - free(out4); - free(out6); - free(out9); +} + + + +static int testFft(void){ + dfftmaTest(); + zfftmaTest(); return 0; } |