summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortorset2008-12-19 15:26:36 +0000
committertorset2008-12-19 15:26:36 +0000
commit92a94f77a9d6a31d2423e85f74547eca45d89425 (patch)
tree1e27f8c0cc39af5958e0e2aa6d8f75306c7a6974
parent7bcc74849a84b87464ca6cc48cdbde8206a3a602 (diff)
downloadscilab2c-92a94f77a9d6a31d2423e85f74547eca45d89425.tar.gz
scilab2c-92a94f77a9d6a31d2423e85f74547eca45d89425.tar.bz2
scilab2c-92a94f77a9d6a31d2423e85f74547eca45d89425.zip
debug ifft and add new tests
-rw-r--r--src/signalProcessing/ifft/Makefile.am9
-rw-r--r--src/signalProcessing/ifft/Makefile.in37
-rw-r--r--src/signalProcessing/ifft/difftmx.c501
-rw-r--r--src/signalProcessing/ifft/testMatIfft.c224
-rw-r--r--src/signalProcessing/ifft/zifftma.c264
5 files changed, 590 insertions, 445 deletions
diff --git a/src/signalProcessing/ifft/Makefile.am b/src/signalProcessing/ifft/Makefile.am
index 5aaefe21..1ffce071 100644
--- a/src/signalProcessing/ifft/Makefile.am
+++ b/src/signalProcessing/ifft/Makefile.am
@@ -58,9 +58,9 @@ check_LDADD = $(top_builddir)/type/libDoubleComplex.la \
$(top_builddir)/operations/subtraction/libSubtraction.la \
@LIBMATH@
-check_PROGRAMS = testFloatIfft testDoubleIfft
+check_PROGRAMS = testFloatIfft testDoubleIfft testMatIfft
-TESTS = testFloatIfft testDoubleIfft
+TESTS = testFloatIfft testDoubleIfft testMatIfft
#
# -*- Fftine Tests -*-
@@ -72,3 +72,8 @@ testFloatIfft_LDADD = $(check_LDADD)
testDoubleIfft_SOURCES = testDoubleIfft.c
testDoubleIfft_CFLAGS = $(check_INCLUDES)
testDoubleIfft_LDADD = $(check_LDADD)
+
+
+testMatIfft_SOURCES = testMatIfft.c
+testMatIfft_CFLAGS = $(check_INCLUDES)
+testMatIfft_LDADD = $(check_LDADD)
diff --git a/src/signalProcessing/ifft/Makefile.in b/src/signalProcessing/ifft/Makefile.in
index ddad4b31..09124b34 100644
--- a/src/signalProcessing/ifft/Makefile.in
+++ b/src/signalProcessing/ifft/Makefile.in
@@ -32,8 +32,10 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-check_PROGRAMS = testFloatIfft$(EXEEXT) testDoubleIfft$(EXEEXT)
-TESTS = testFloatIfft$(EXEEXT) testDoubleIfft$(EXEEXT)
+check_PROGRAMS = testFloatIfft$(EXEEXT) testDoubleIfft$(EXEEXT) \
+ testMatIfft$(EXEEXT)
+TESTS = testFloatIfft$(EXEEXT) testDoubleIfft$(EXEEXT) \
+ testMatIfft$(EXEEXT)
subdir = signalProcessing/ifft
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -82,6 +84,12 @@ testFloatIfft_DEPENDENCIES = $(am__DEPENDENCIES_1)
testFloatIfft_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(testFloatIfft_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+am_testMatIfft_OBJECTS = testMatIfft-testMatIfft.$(OBJEXT)
+testMatIfft_OBJECTS = $(am_testMatIfft_OBJECTS)
+testMatIfft_DEPENDENCIES = $(am__DEPENDENCIES_1)
+testMatIfft_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(testMatIfft_CFLAGS) \
+ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/includes
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
am__depfiles_maybe = depfiles
@@ -95,9 +103,9 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(libIfft_la_SOURCES) $(testDoubleIfft_SOURCES) \
- $(testFloatIfft_SOURCES)
+ $(testFloatIfft_SOURCES) $(testMatIfft_SOURCES)
DIST_SOURCES = $(libIfft_la_SOURCES) $(testDoubleIfft_SOURCES) \
- $(testFloatIfft_SOURCES)
+ $(testFloatIfft_SOURCES) $(testMatIfft_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -262,6 +270,9 @@ testFloatIfft_LDADD = $(check_LDADD)
testDoubleIfft_SOURCES = testDoubleIfft.c
testDoubleIfft_CFLAGS = $(check_INCLUDES)
testDoubleIfft_LDADD = $(check_LDADD)
+testMatIfft_SOURCES = testMatIfft.c
+testMatIfft_CFLAGS = $(check_INCLUDES)
+testMatIfft_LDADD = $(check_LDADD)
all: all-am
.SUFFIXES:
@@ -337,6 +348,9 @@ testDoubleIfft$(EXEEXT): $(testDoubleIfft_OBJECTS) $(testDoubleIfft_DEPENDENCIES
testFloatIfft$(EXEEXT): $(testFloatIfft_OBJECTS) $(testFloatIfft_DEPENDENCIES)
@rm -f testFloatIfft$(EXEEXT)
$(testFloatIfft_LINK) $(testFloatIfft_OBJECTS) $(testFloatIfft_LDADD) $(LIBS)
+testMatIfft$(EXEEXT): $(testMatIfft_OBJECTS) $(testMatIfft_DEPENDENCIES)
+ @rm -f testMatIfft$(EXEEXT)
+ $(testMatIfft_LINK) $(testMatIfft_OBJECTS) $(testMatIfft_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -355,6 +369,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libIfft_la-zifftma.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testDoubleIfft-testDoubleIfft.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testFloatIfft-testFloatIfft.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testMatIfft-testMatIfft.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -468,6 +483,20 @@ testFloatIfft-testFloatIfft.obj: testFloatIfft.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testFloatIfft_CFLAGS) $(CFLAGS) -c -o testFloatIfft-testFloatIfft.obj `if test -f 'testFloatIfft.c'; then $(CYGPATH_W) 'testFloatIfft.c'; else $(CYGPATH_W) '$(srcdir)/testFloatIfft.c'; fi`
+testMatIfft-testMatIfft.o: testMatIfft.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testMatIfft_CFLAGS) $(CFLAGS) -MT testMatIfft-testMatIfft.o -MD -MP -MF $(DEPDIR)/testMatIfft-testMatIfft.Tpo -c -o testMatIfft-testMatIfft.o `test -f 'testMatIfft.c' || echo '$(srcdir)/'`testMatIfft.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testMatIfft-testMatIfft.Tpo $(DEPDIR)/testMatIfft-testMatIfft.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testMatIfft.c' object='testMatIfft-testMatIfft.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testMatIfft_CFLAGS) $(CFLAGS) -c -o testMatIfft-testMatIfft.o `test -f 'testMatIfft.c' || echo '$(srcdir)/'`testMatIfft.c
+
+testMatIfft-testMatIfft.obj: testMatIfft.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testMatIfft_CFLAGS) $(CFLAGS) -MT testMatIfft-testMatIfft.obj -MD -MP -MF $(DEPDIR)/testMatIfft-testMatIfft.Tpo -c -o testMatIfft-testMatIfft.obj `if test -f 'testMatIfft.c'; then $(CYGPATH_W) 'testMatIfft.c'; else $(CYGPATH_W) '$(srcdir)/testMatIfft.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/testMatIfft-testMatIfft.Tpo $(DEPDIR)/testMatIfft-testMatIfft.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testMatIfft.c' object='testMatIfft-testMatIfft.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testMatIfft_CFLAGS) $(CFLAGS) -c -o testMatIfft-testMatIfft.obj `if test -f 'testMatIfft.c'; then $(CYGPATH_W) 'testMatIfft.c'; else $(CYGPATH_W) '$(srcdir)/testMatIfft.c'; fi`
+
mostlyclean-libtool:
-rm -f *.lo
diff --git a/src/signalProcessing/ifft/difftmx.c b/src/signalProcessing/ifft/difftmx.c
index 1466fe8b..e1ec428d 100644
--- a/src/signalProcessing/ifft/difftmx.c
+++ b/src/signalProcessing/ifft/difftmx.c
@@ -216,25 +216,22 @@ void preliminaryWork (void)
/*40*/
+/* this function is call as many time as dfftbi has determined factor for the size of the input vector
+ each time we call a transform function for each kind of factor , we begin by the smallest
+ factor are stored in nfac
+ */
+
int factorTransform (void)
{
int retVal = 42;
- int jjjj = 0 ;
-
dr = 8 * (double)jc/(double)kspan ;
-
cd = 2 * sin(0.5*dr*rad)*sin(0.5*dr*rad);
sd = sin(dr*rad) ;
-
kk = 1 ;
i++ ;
- for ( jjjj = 0 ; jjjj < 10 ; jjjj ++ )
- {
-
- }
@@ -243,13 +240,9 @@ switch ( nfac[i-1] )
case 2 :
/*transform for factor of 2 (including rotation factor)*/
- retVal = pre_fOf2Trans( ) ;
- if ( retVal == 0 )
- {
-
- factorOf2Transform ( ) ;
+ retVal = pre_fOf2Trans() ;
+ if ( retVal == 0 ) factorOf2Transform () ;
- }
break ;
case 4 :
@@ -257,26 +250,20 @@ switch ( nfac[i-1] )
kspnn = kspan ;
kspan = kspan >> 2 ; /*kspan /= 4 */
-
- retVal = factorOf4Transform ( ) ;
+ retVal = factorOf4Transform () ;
break ;
case 3 :
-
+ /*transform for factor of 3 */
k = nfac[i-1] ;
kspnn = kspan ;
kspan = kspan / k ;
-
-
+
factorOf3Transform ( ) ;
- for ( jjjj = 0 ; jjjj < 9 ; jjjj ++ )
- {
-
- }
break ;
case 5 :
-
+ /*transform for factor of 5 */
k = nfac[i-1] ;
kspnn = kspan ;
kspan = kspan / k ;
@@ -290,110 +277,70 @@ switch ( nfac[i-1] )
kspnn = kspan ;
kspan = kspan / k ;
-
- if ( nfac[i-1] != jf)
- {
-
- preFOtherTransform ( ) ;
- }
-
+ if ( nfac[i-1] != jf) preFOtherTransform ( ) ;
+
factorOfOtherTransform ( ) ;
break ;
}
- for ( jjjj = 0 ; jjjj < 15; jjjj ++ )
- {
-
- }
if ( retVal == 42 )
{
-
-
- if ( i != m)
- {
-
- retVal = mulByRotationFactor ( ) ;
- }
- else
- retVal = 1 ;
+ if ( i != m) retVal = mulByRotationFactor ( ) ;
+ else retVal = 1 ;
}
-
- if ( retVal == 1 )
- return 1 ; /*goto permute */
- else
- return 0 ; /*goto factor_transform => once again*/
-
-
+ if ( retVal == 1 ) return 1 ; /*goto permute */
+ else return 0 ; /*goto factor_transform => once again*/
}
-
+/* permutation for square factor of n */
void permute_stage1 (void)
{
int retVal = 1 ;
-
- pre_sqFactor2NormlOrder ( ) ;
+ pre_sqFactor2NormlOrder () ;
if ( n == ntot )
/*permutation for single-variate transform (optional code)*/
while ( retVal == 1)
{
-
- single_sqFactor2NormlOrder ( ) ;
+ single_sqFactor2NormlOrder () ;
retVal = post_sqFactor2NormlOrder () ;
}
else
/*permutation for multivariate transform*/
- while ( retVal == 1)
- {
-
- retVal = multi_sqFactor2NormlOrder ( );
- }
-
+ while ( retVal == 1) retVal = multi_sqFactor2NormlOrder ();
}
void permute_stage2 (void)
{
-
-
- kspnn = np[kt] ;
-
-
- /*permutation for square-free facotrs of n */
-
- nonSqFactor2NormOrder ( ) ;
-
- /*determine the permutation cycles of length greater than 1*/
-
- detPermutCycles ( );
-
-
-
- j = k3 + 1;
- nt -= kspnn ;
- i = nt - inc + 1 ;
- while ( nt >= 0 )
- {
-
-
-
- reorderMatrix ( ) ;
- j = k3 + 1 ;
- nt -= kspnn ;
- i = nt - inc + 1 ;
-
+ kspnn = np[kt] ;
+
+ /*permutation for square-free facotrs of n */
+ nonSqFactor2NormOrder () ;
+
+ /*determine the permutation cycles of length greater than 1*/
+ detPermutCycles ();
+
+ j = k3 + 1;
+ nt -= kspnn ;
+ i = nt - inc + 1 ;
+ while ( nt >= 0 )
+ {
+ reorderMatrix ( ) ;
+
+ j = k3 + 1 ;
+ nt -= kspnn ;
+ i = nt - inc + 1 ;
}
-
-
}
-/** **************************************
+/*****************************************
Sous-Sous-Fonctions
******************************************/
@@ -403,45 +350,30 @@ Sous-Sous-Fonctions
int pre_fOf2Trans (void)
{
- int ktemp = 0 ;
+ kspan /= 2;
+ k1 = kspan + 2 ;
+ /*50*/
+ do{
+ do{
+ k2 = kk + kspan ;
+ ak = a[k2-1] ;
+ bk = b[k2-1] ;
- kspan /= 2;
- k1 = kspan + 2 ;
-/*50*/
- do
- {
+ a[k2-1] = a[kk-1] - ak;
+ b[k2-1] = b[kk-1] - bk;
- k2 = kk + kspan ;
- ak = a[k2-1] ;
- bk = b[k2-1] ;
+ a[kk-1] = a[kk-1] + ak;
+ b[kk-1] = b[kk-1] + bk;
- a[k2-1] = a[kk-1] - ak;
- b[k2-1] = b[kk-1] - bk;
+ kk = k2 + kspan ;
+ }while (kk <= nn);
- a[kk-1] = a[kk-1] + ak;
- b[kk-1] = b[kk-1] + bk;
-
- kk = k2 + kspan ;
- ktemp = kk ;
-
- if ( kk > nn )
- {
- kk -= nn ;
- }
- }while (ktemp <= nn ||( kk <= jc && ktemp <= nn));
-
-
-
-
-
-
- if ( kk > kspan )
- return 1 ; /*goto350*/
- else
-
- return 0 ;/*goto60*/
+ kk -= nn ;
+ }while (kk <= jc);
+ if ( kk > kspan ) return 1 ; /*goto350*/
+ else return 0 ; /*goto60*/
}
@@ -450,88 +382,73 @@ int pre_fOf2Trans (void)
int factorOf2Transform (void)
{
-int ktemp = 0 ;
-
-
-
-
-
-do /*60*/
- {
- c1 = 1 - cd ;
- s1 = sd ;
- mm = min( k1/2 , klim);
-
- do/* do 80 */
- {
- do
- {
- k2 = kk + kspan;
-
- ak = a[kk-1] - a[k2-1];
- bk = b[kk-1] - b[k2-1];
-
- a[kk-1] = a[kk-1] + a[k2-1];
- b[kk-1] = b[kk-1] + b[k2-1];
-
- a[k2-1] = c1*ak - s1*bk;
- b[k2-1] = s1*ak + c1*bk;
-
-
- kk = k2 + kspan;
- ktemp = kk ;
- if (kk >= nt)
- {
- k2 = kk - nt;
- c1 = -c1;
- kk = k1 - k2;
-
- }
-
- }while ( ktemp < nt || (kk > k2 && ( ktemp >= nt)) );
-
- kk += jc;
-
- if ( kk <= mm ) /* 70 */
- {
-
- ak = c1 - ( cd*c1+sd*s1) ;
- s1 += (sd*c1-cd*s1) ;
- /*c the following three statements compensate for truncation
- c error. if rounded arithmetic is used, substitute
- c c1=ak*/
- c1 = 0.5/(ak*ak+s1*s1) + 0.5 ;
- s1 *= c1 ;
- c1 *= ak ;
- }
- else
- {
- if ( kk < k2 ) /*90*/
- {
-
- s1 = dr*rad*((double)(kk-1)/(double)jc);
- c1 = cos(s1) ;
- s1 = sin(s1) ;
- mm = min(k1/2,mm+klim);
- }
- }
-
- }while ( kk <= mm || ( kk > mm && kk < k2 ));
-
- k1 += (inc+inc) ;
- kk = (k1-kspan)/2 + jc;
-
- } while ( kk <= jc*2 );
-
-
- return 0 ; /*goto40*/
+ do /*60*/ {/*while ( kk <= jc*2 )*/
+ c1 = 1 - cd ;
+ s1 = sd ;
+ mm = min( k1/2 , klim);
+
+ do/* do 80 */ {/*while ( kk <= mm || ( kk > mm && kk < k2 ))*/
+ do {/*while(kk > k2) */
+ do { /*while ( kk < nt )*/
+ k2 = kk + kspan;
+
+ ak = a[kk-1] - a[k2-1];
+ bk = b[kk-1] - b[k2-1];
+
+ a[kk-1] = a[kk-1] + a[k2-1];
+ b[kk-1] = b[kk-1] + b[k2-1];
+
+ a[k2-1] = c1*ak - s1*bk;
+ b[k2-1] = s1*ak + c1*bk;
+
+ kk = k2 + kspan;
+ }while ( kk < nt );
+
+ k2 = kk - nt;
+ c1 = -c1;
+ kk = k1 - k2;
+
+
+ }while (kk > k2);
+
+ kk += jc;
+
+ if ( kk <= mm ) /* 70 */
+ {
+ ak = c1 - ( cd*c1+sd*s1) ;
+ s1 += (sd*c1-cd*s1) ;
+ /*c the following three statements compensate for truncation
+ c error. if rounded arithmetic is used, substitute
+ c c1=ak*/
+ c1 = 0.5/(ak*ak+s1*s1) + 0.5 ;
+ s1 *= c1 ;
+ c1 *= ak ;
+ }
+ else {
+ if ( kk < k2 ) /*90*/ {
+ s1 = dr*rad*((double)(kk-1)/(double)jc);
+ c1 = cos(s1) ;
+ s1 = sin(s1) ;
+ mm = min(k1/2,mm+klim);
+ }
+ }
+
+ } while ( kk <= mm || ( kk > mm && kk < k2 ));
+
+ k1 += (inc+inc) ;
+ kk = (k1-kspan)/2 + jc;
+
+ } while ( kk <= jc*2 );
+
+
+ return 0 ; /*goto40*/
}
+/* this one is just an optimisation of the factor of 2 transform , we compute more things each turn */
int factorOf4Transform (void)
{
-
int return_value = 0 ;
/*120*/
@@ -561,11 +478,12 @@ int factorOf4Transform (void)
}
+/*this function and the following are just here for conveniance , they just do fourier transformation for factor of 4
+ but as the code was a bit long in factorof4transform , we've created two sub-functions */
+
void f4t_150 (void)
{
- int sign = 1 ;
-
do{
k1 = kk + kspan ;
k2 = k1 + kspan ;
@@ -589,17 +507,11 @@ void f4t_150 (void)
b[kk-1] = bkp + bjp ;
bjp = bkp - bjp ;
- if ( isn < 0 )
- sign = 1 ;
- else
- sign = -1 ;
-
-
- akp = akm +(sign * bjm );
- akm = akm -(sign * bjm );
+ akp = akm - bjm ;
+ akm = akm + bjm ;
- bkp = bkm +(sign * ajm) ;
- bkm = bkm -(sign * ajm) ;
+ bkp = bkm + ajm ;
+ bkm = bkm - ajm ;
if ( s1 == 0 )/*190*/
{
@@ -624,14 +536,14 @@ void f4t_150 (void)
a[k2-1] = bjp*c2 + ajp*s2 ;
a[k3-1] = bkm*c3 + akm*s3 ;
}
- }while ( kk < nt ) ;
+ kk=k3+kspan;
+ }while ( kk <= nt ) ;
}
int f4t_170 (void)
{
-
kk += ( jc - nt ) ;
if ( kk <= mm )
@@ -647,12 +559,13 @@ int f4t_170 (void)
c1 = 0.5/(c2*c2+s1*s1) + 0.5 ;
s1 *= c1 ;
- c2 *= c1 ;
+ c1 *= c2 ;
/*140*/
c2 = c1*c1 - s1*s1 ;
s2 = c1*s1*2 ;
+ c3 = c2*c1 - s2*s1 ;
s3 = c2*s1 + s2*c1 ;
@@ -664,7 +577,7 @@ int f4t_170 (void)
if ( kk <= kspan )
{
s1 = dr*rad * (kk-1)/jc ;
- c2 = cos (s1) ;
+ c1 = cos (s1) ;
s1 = sin (s1) ;
mm = min ( kspan , mm + klim );
@@ -672,6 +585,7 @@ int f4t_170 (void)
c2 = c1*c1 - s1*s1 ;
s2 = c1*s1*2 ;
+ c3 = c2*c1 - s2*s1 ;
s3 = c2*s1 + s2*c1 ;
return 0 ;
@@ -686,120 +600,108 @@ int f4t_170 (void)
void factorOf3Transform (void)
{
-int ktemp = 0 ;
-do
- {
+ do{
+ do{
+ k1 = kk + kspan ;
+ k2 = k1 + kspan ;
- k1 = kk + kspan ;
- k2 = k1 + kspan ;
+ ak = a[kk-1] ;
+ bk = b[kk-1] ;
- ak = a[kk-1] ;
- bk = b[kk-1] ;
+ aj = a[k1-1] + a[k2-1] ;
+ bj = b[k1-1] + b[k2-1] ;
- aj = a[k1-1] + a[k2-1] ;
- bj = b[k1-1] + b[k2-1] ;
+ a[kk-1] = ak + aj ;
+ b[kk-1] = bk + bj ;
- a[kk-1] = ak + aj ;
- b[kk-1] = bk + bj ;
+ ak = -0.5*aj + ak ;
+ bk = -0.5*bj + bk ;
- ak = -0.5*aj + ak ;
- bk = -0.5*bj + bk ;
+ aj = (a[k1-1] - a[k2-1])*s120 ;
+ bj = (b[k1-1] - b[k2-1])*s120 ;
- aj = (a[k1-1] - a[k2-1])*s120 ;
- bj = (b[k1-1] - b[k2-1])*s120 ;
+ a[k1-1] = ak - bj ;
+ b[k1-1] = bk + aj ;
+ a[k2-1] = ak + bj ;
+ b[k2-1] = bk - aj ;
- a[k1-1] = ak - bj ;
- b[k1-1] = bk + aj ;
- a[k2-1] = ak + bj ;
- b[k2-1] = bk - aj ;
-
- kk = k2 + kspan ;
- ktemp = kk ;
-
-
-
- if ( kk >= nn )
- kk -= nn ;
-
- }while ( ktemp < nn || (kk <= kspan && ( ktemp >= nn)) );
+ kk = k2 + kspan ;
+ } while (kk < nn);
+
+ kk -= nn ;
+ }while (kk <= kspan);
}
void factorOf5Transform (void)
{
- int ktemp ;
+ c2 = c72*c72 - s72 *s72 ;
+ s2 = 2 * c72*s72;
- c2 = c72*c72 - s72 *s72 ;
- s2 = 2 * c72*s72;
+ do{
+ do{
+ k1 = kk + kspan ;
+ k2 = k1 + kspan ;
+ k3 = k2 + kspan ;
+ k4 = k3 + kspan ;
- do
- {
- k1 = kk + kspan ;
- k2 = k1 + kspan ;
- k3 = k2 + kspan ;
- k4 = k3 + kspan ;
-
-
-
- akp = a[k1-1] + a[k4-1] ;
- akm = a[k1-1] - a[k4-1] ;
-
- bkp = b[k1-1] + b[k4-1] ;
- bkm = b[k1-1] - b[k4-1] ;
-
- ajp = a[k2-1] + a[k3-1] ;
- ajm = a[k2-1] - a[k3-1] ;
-
- bjp = b[k2-1] + b[k3-1] ;
- bjm = b[k2-1] - b[k3-1] ;
-
- aa = a[kk-1] ;
- bb = b[kk-1] ;
- a[kk-1] = aa + akp + ajp;
- b[kk-1] = bb + bkp + bjp;
- ak = akp*c72 + ajp*c2 + aa ;
- bk = bkp*c72 + bjp*c2 + bb ;
+ akp = a[k1-1] + a[k4-1] ;
+ akm = a[k1-1] - a[k4-1] ;
- aj = akm*s72 + ajm*s2 ;
- bj = bkm*s72 + bjm*s2 ;
+ bkp = b[k1-1] + b[k4-1] ;
+ bkm = b[k1-1] - b[k4-1] ;
- a[k1-1] = ak - bj ;
- a[k4-1] = ak + bj ;
- b[k1-1] = bk + aj ;
- b[k4-1] = bk - aj ;
+ ajp = a[k2-1] + a[k3-1] ;
+ ajm = a[k2-1] - a[k3-1] ;
- ak = akp*c2 + ajp*c72 + aa ;
- bk = bkp*c2 + bjp*c72 + bb ;
+ bjp = b[k2-1] + b[k3-1] ;
+ bjm = b[k2-1] - b[k3-1] ;
- aj = akm*s2 - ajm*s72 ;
+ aa = a[kk-1] ;
+ bb = b[kk-1] ;
- bj = bkm*s2 - bjm*s72 ;
+ a[kk-1] = aa + akp + ajp;
+ b[kk-1] = bb + bkp + bjp;
- a[k2-1] = ak - bj ;
- a[k3-1] = ak + bj ;
- b[k2-1] = bk + aj ;
- b[k3-1] = bk - aj ;
+ ak = akp*c72 + ajp*c2 + aa ;
+ bk = bkp*c72 + bjp*c2 + bb ;
- kk = k4 + kspan;
- ktemp = kk ;
+ aj = akm*s72 + ajm*s2 ;
+ bj = bkm*s72 + bjm*s2 ;
+ a[k1-1] = ak - bj ;
+ a[k4-1] = ak + bj ;
+ b[k1-1] = bk + aj ;
+ b[k4-1] = bk - aj ;
- if ( kk >= nn )
- kk -= nn ;
+ ak = akp*c2 + ajp*c72 + aa ;
+ bk = bkp*c2 + bjp*c72 + bb ;
+ aj = akm*s2 - ajm*s72 ;
- }while (ktemp < nn || ( kk <= kspan && ktemp >= nn));
+ bj = bkm*s2 - bjm*s72 ;
+ a[k2-1] = ak - bj ;
+ a[k3-1] = ak + bj ;
+ b[k2-1] = bk + aj ;
+ b[k3-1] = bk - aj ;
+ kk = k4 + kspan;
+ }while (kk < nn);
+ kk -= nn ;
+ }while (kk <= kspan);
}
+/* this function is the general case of non factor of 2 factor , the factorof3transform and factorof5trandform are just
+special case of this one */
+
void preFOtherTransform (void)
{
-
+printf("0.k=%d \n",k);
jf = k ;
s1 = (rad*8)/k ;
@@ -852,7 +754,6 @@ do
bt[j-1] = b[k1-1] + b[k2-1] ;
bk = bt[j-1] + bk ;
-
j++ ;
wt[j-1] = a[k1-1] - a[k2-1] ;
@@ -885,11 +786,9 @@ do
ak += ( wt[k-1] * ck[jj-1] ) ;
bk += ( bt[k-1] * ck[jj-1] ) ;
-
k++ ;
aj += (wt[k-1] * sk[jj-1]) ;
bj += (bt[k-1] * sk[jj-1]) ;
-
jj += j ;
if ( jj > jf )
@@ -1219,7 +1118,7 @@ void nonSqFactor2NormOrder (void)
return ;
}
-
+/* here we determine how many permutation cycles we need to do */
void detPermutCycles (void)
{
diff --git a/src/signalProcessing/ifft/testMatIfft.c b/src/signalProcessing/ifft/testMatIfft.c
new file mode 100644
index 00000000..5973f1fe
--- /dev/null
+++ b/src/signalProcessing/ifft/testMatIfft.c
@@ -0,0 +1,224 @@
+
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 <malloc.h>
+#include <assert.h>
+#include <stdio.h>
+#include <math.h>
+#include "ifft.h"
+
+#define test1 {0.2113249000000000099586,0.3303270999999999846253,0.8497451999999999783242,0.0683740000000000042180,\
+ 0.7560438999999999909463,0.6653810999999999475918,0.6857309999999999794440,0.5608486000000000304411,\
+ 0.0002211000000000000075,0.6283917999999999448590,0.8782164999999999555058,0.6623569000000000261963}
+
+#define test2 {0.2113249000000000099586,0.6857309999999999794440,\
+ 0.3303270999999999846253,0.5608486000000000304411,\
+ 0.8497451999999999783242,0.0002211000000000000075,\
+ 0.0683740000000000042180,0.6283917999999999448590,\
+ 0.7560438999999999909463,0.8782164999999999555058,\
+ 0.6653810999999999475918,0.6623569000000000261963}
+
+#define test3 {0.2113249000000000099586,0.7560438999999999909463,0.0002211000000000000075,\
+ 0.3303270999999999846253,0.6653810999999999475918,0.6283917999999999448590,\
+ 0.8497451999999999783242,0.6857309999999999794440,0.8782164999999999555058,\
+ 0.0683740000000000042180,0.5608486000000000304411,0.6623569000000000261963}
+
+#define test4 {0.2113249000000000099586,0.0683740000000000042180,0.6857309999999999794440,0.6283917999999999448590,\
+ 0.3303270999999999846253,0.7560438999999999909463,0.5608486000000000304411,0.8782164999999999555058,\
+ 0.8497451999999999783242,0.6653810999999999475918,0.0002211000000000000075,0.6623569000000000261963}
+
+#define test6 {0.2113249000000000099586,0.8497451999999999783242,0.7560438999999999909463,0.6857309999999999794440,0.0002211000000000000075,0.8782164999999999555058,\
+ 0.3303270999999999846253,0.0683740000000000042180,0.6653810999999999475918,0.5608486000000000304411,0.6283917999999999448590,0.6623569000000000261963}
+
+#define test9 {1,2,3,4,5,6,7,8,9}
+
+#define RRESULT1 {0.5247468416666665191883,-0.0159011882620516131759,0.0056361333333333485385,\
+-0.1205085666666666222024,-0.0631457083333333279995,0.0178082299287182777014,\
+0.0388002583333332817794,0.0178082299287182777014,-0.0631457083333333279995,\
+-0.1205085666666666222024,0.0056361333333333485385,-0.0159011882620516131759}
+
+#define IRESULT1 {0,0.0036551311266069114181,0.0881077213977346646034,-0.0277100416666666432564,\
+-0.0250953810419741324411,0.1086392772067264061997,0,-0.1086392772067264061997,\
+0.0250953810419741324411,0.0277100416666666432564,-0.0881077213977346646034,\
+-0.0036551311266069114181}
+
+#define RRESULT2 {0.5247468416666666302106,-0.0445474749999999961037,\
+0.0056361333333333554774,-0.0326510583333333367917,\
+-0.0631457083333333279995,-0.1070292499999999646931,\
+0.0388002583333333234128,0.0867050416666666767807,\
+-0.0631457083333333279995,-0.1070292499999999646931,\
+0.0056361333333333554774,-0.0326510583333333367917}
+
+#define IRESULT2 {0,0,\
+0.0881077213977346646034,-0.0532714598190739199723,\
+-0.0250953810419741081550,0.0869808780098438039108,\
+0,0,\
+0.0250953810419741081550,-0.0869808780098438039108,\
+-0.0881077213977346646034,0.0532714598190739199723}
+
+#define RRESULT3 {0.5247468416666665191883,-0.0799020208333333092909,-0.0799020208333333092909,\
+-0.1205085666666666222024,-0.0295434574969313107351,-0.0095530508364020244594,\
+0.0388002583333332817794,0.0633959958333333295499,0.0633959958333333295499,\
+-0.1205085666666666222024,-0.0095530508364020244594,-0.0295434574969313107351}
+
+#define IRESULT3 {0,-0.0359991099727139385323,0.0359991099727139385323,\
+-0.0277100416666666432564,-0.0873273732016361936559,0.0495491398683028591576,\
+0,-0.0453116254771752935415,0.0453116254771752935415,\
+0.0277100416666666432564,-0.0495491398683028591576,0.0873273732016361936559}
+
+#define RRESULT4 {0.5247468416666666302106,0.0120497083333333254718,-0.0850471916666666466478,\
+ 0.0120497083333333254718,\
+-0.0631457083333333279995,-0.0562903158939566938823,0.0675598583333333335688,\
+ -0.0743609174393766170219,\
+-0.0631457083333333279995,-0.0743609174393766170219,0.0675598583333333335688,\
+ -0.0562903158939566938823}
+
+#define IRESULT4 {0,0.0565971833333333285143,0,-0.0565971833333333285143,\
+-0.0250953810419741081550,0.1196492105704671793376,0.0191473164961883796087,\
+ 0.0362419439038005331000,\
+0.0250953810419741081550,-0.0362419439038005331000,-0.0191473164961883796087,\
+ -0.1196492105704671793376}
+
+#define RRESULT6 {0.5247468416666666302106,-0.0417166874999999950924,-0.0388444708333333249550,\
+ -0.0927985249999999928239,-0.0388444708333333249550,-0.0417166874999999950924,\
+0.0388002583333333372906,0.0436237291666666596179,-0.0186651041666666545060,\
+ -0.1482186083333333070922,-0.0186651041666666545060,0.0436237291666666596179}
+
+#define IRESULT6 {0,-0.0122945224279474088491,0.1021380474100006957583,0,-0.1021380474100006957583,\
+ 0.0122945224279474088491,\
+0,-0.0926896236521720928714,0.0110650550297080874085,0,-0.0110650550297080874085,\
+ 0.0926896236521720928714}
+
+#define RRESULT9 {5,-0.5000000000000002220446,-0.5000000000000002220446,\
+ -1.4999999999999997779554,- 0.0000000000000000286185, 0.0000000000000001396408,\
+ -1.4999999999999997779554,0.0000000000000001396408,- 0.0000000000000000286185}
+
+#define IRESULT9 {0,- 0.2886751345948128100183,0.2886751345948128100183,\
+ - 0.8660254037844383745437,- 0.0000000000000000138778,0.0000000000000000138778,\
+ + 0.8660254037844383745437,- 0.0000000000000000138778,+ 0.0000000000000000138778}
+
+
+static int testIfft(void){
+ int i;
+
+ double inR1[]=test1;
+ double inR2[]=test2;
+ double inR3[]=test3;
+ double inR4[]=test4;
+ double inR6[]=test6;
+ double inR9[]=test9;
+
+ double resR1[]=RRESULT1;
+ double resI1[]=IRESULT1;
+ double resR2[]=RRESULT2;
+ double resI2[]=IRESULT2;
+ double resR3[]=RRESULT3;
+ double resI3[]=IRESULT3;
+ double resR4[]=RRESULT4;
+ double resI4[]=IRESULT4;
+ double resR6[]=RRESULT6;
+ double resI6[]=IRESULT6;
+ double resR9[]=RRESULT9;
+ double resI9[]=IRESULT9;
+
+ doubleComplex *in1, *in2, *in3, *in4, *in6, *in9, *out1, *out2, *out3, *out4, *out6, *out9;
+
+ in1=malloc((uint)12*sizeof(doubleComplex));
+ in2=malloc((uint)12*sizeof(doubleComplex));
+ in3=malloc((uint)12*sizeof(doubleComplex));
+ 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);
+ in3[i]=DoubleComplex(inR3[i],0);
+ in4[i]=DoubleComplex(inR4[i],0);
+ in6[i]=DoubleComplex(inR6[i],0);
+ }
+ for (i=0;i<9;i++){
+ in9[i]=DoubleComplex(inR9[i],0);
+
+ }
+
+
+ zifftma(in1, 1, 12, out1);
+ zifftma(in2, 2, 6, out2);
+ zifftma(in3, 3, 4, out3);
+ zifftma(in4, 4, 3, out4);
+ zifftma(in6, 6, 2, out6);
+ zifftma(in9, 3, 3, out9);
+
+ /* !!!!!!!!!!!!!!!!!!!!!!!
+ for the imaginary part, the assert is out + res instead of out - res
+ cause I export the transposate of the result matrix and the transposate change the sign
+ of the imaginary part.
+ And instead of change all the define, I only change the sign of the assert.*/
+ for (i=0;i<12;i++){
+ if (zreals(out1[i])>1e-16) assert( (fabs(zreals(out1[i])-resR1[i]) / fabs(zreals(out1[i]))) < 1e-14 );
+ else assert(1);
+ if (zimags(out1[i])>1e-16) assert( (fabs(zimags(out1[i])+resI1[i]) / fabs(zimags(out1[i]))) < 1e-14 );
+ else assert(1);
+ }
+
+ for (i=0;i<12;i++){
+ if (zreals(out2[i])>1e-16) assert( (fabs(zreals(out2[i])-resR2[i]) / fabs(zreals(out2[i]))) < 1e-14 );
+ else assert(1);
+ if (zimags(out2[i])>1e-16) assert( (fabs(zimags(out2[i])+resI2[i]) / fabs(zimags(out2[i]))) < 1e-14 );
+ else assert(1);
+ }
+
+ for (i=0;i<12;i++){
+ if (zreals(out3[i])>1e-16) assert( (fabs(zreals(out3[i])-resR3[i]) / fabs(zreals(out3[i]))) < 1e-14 );
+ else assert(1);
+ if (zimags(out3[i])>1e-16) assert( (fabs(zimags(out3[i])+resI3[i]) / fabs(zimags(out3[i]))) < 1e-14 );
+ else assert(1);
+ }
+
+ for (i=0;i<12;i++){
+ if (zreals(out4[i])>1e-16) assert( (fabs(zreals(out4[i])-resR4[i]) / fabs(zreals(out4[i]))) < 1e-14 );
+ else assert(1);
+ if (zimags(out4[i])>1e-16) assert( (fabs(zimags(out4[i])+resI4[i]) / fabs(zimags(out4[i]))) < 1e-14 );
+ else assert(1);
+ }
+
+ for (i=0;i<12;i++){
+ if (zreals(out6[i])>1e-16) assert( (fabs(zreals(out6[i])-resR6[i]) / fabs(zreals(out6[i]))) < 1e-14 );
+ else assert(1);
+ if (zimags(out6[i])>1e-16) assert( (fabs(zimags(out6[i])+resI6[i]) / fabs(zimags(out6[i]))) < 1e-14 );
+ else assert(1);
+ }
+
+ for (i=0;i<9;i++){
+ printf("i : %d out : %f - res : %f - reste : %f\n",i,zimags(out9[i]),resI9[i],fabs(zimags(out9[i])-resI9[i]) / fabs(zimags(out9[i])));
+ if (zreals(out9[i])>1e-16) assert( (fabs(zreals(out9[i])-resR9[i]) / fabs(zreals(out9[i]))) < 1e-16 );
+ else assert(1);
+
+ if (zimags(out9[i])>1e-15) assert( (fabs(zimags(out9[i])-resI9[i]) / fabs(zimags(out9[i]))) < 1e-15 );
+ else assert(1);
+ }
+ return 0;
+}
+
+
+int main(void) {
+ printf(">>> Ifft Matrices Double Tests <<<");
+ assert(testIfft() == 0);
+ return 0;
+}
diff --git a/src/signalProcessing/ifft/zifftma.c b/src/signalProcessing/ifft/zifftma.c
index 9d103fd1..8968b359 100644
--- a/src/signalProcessing/ifft/zifftma.c
+++ b/src/signalProcessing/ifft/zifftma.c
@@ -18,144 +18,132 @@
void zifftma ( doubleComplex* in , int rows, int cols, doubleComplex* out)
{
-int choosenAlgo = DFFT2 ;
-
-int size = rows*cols ;
-int sizeTemp = 0;
-/*
-int sizeWorkSpace = size *2;
-*/
-int rowsTemp = 0 ;
-int colsTemp = 0 ;
-
-int ierr = 0 ;
-int isn = 1;
-int i = 0;
-
-
-double* realIn = (double*) malloc ( sizeof (double) * (unsigned int) size );
-double* imagIn = (double*) malloc ( sizeof (double) * (unsigned int) size );
-
-
-doubleComplex* inTemp = (doubleComplex*) malloc ( sizeof (doubleComplex) * (unsigned int) size );
-
-/*
-double* workSpace = (double*) malloc ( sizeof (double) * (unsigned int) sizeWorkSpace );
-*/
-
-
-zimaga ( in , size , imagIn) ;
-zreala ( in , size , realIn) ;
-
-if ( rows == 1 || cols == 1 )
-{
- printf ( "it'a vector \n" ) ;
-
- sizeTemp = (int) pow ( 2 , (int ) (log( size + 0.5 ) /log ( 2 ))) ;
- printf ("pow %e , temp %d \n" , pow ( 2 , (int )(log( size +0.5 ) /log ( 2 ))), sizeTemp);
-
- if ( size == sizeTemp )
- {
- if ( size <= pow ( 2 , 15 ))
- {
- printf ( "we call ifft842 \n" ) ;
- ifft842 ( in , size , 1 );
- choosenAlgo = IFFT842 ;
- }
- else
- {
- printf ( "we call dfft2 \n" ) ;
- difft2 ( realIn , imagIn , 1 , size , 1 , isn , ierr /*, workSpace , sizeWorkSpace*/ );
- }
-
-
- }
- else
- {
- printf ( "we call dfft2 2\n" ) ;
- difft2 ( realIn , imagIn , 1 , size , 1 , isn , ierr /*, workSpace , sizeWorkSpace */);
- }
-
-}
-
-else
-{
- printf ( "it'a matrix \n" ) ;
- rowsTemp = (int) pow ( 2 , log( rows + 0.5) /log ( 2 )) ;
- colsTemp = (int) pow ( 2 , log( cols + 0.5) /log ( 2 )) ;
-
- if ( cols == colsTemp)
- {
- if ( cols <= pow ( 2 , 15 ))
- {
- for ( i = 0 ; i < rows ; i++ )
- {
- ifft842 ( &in[ cols*i] , cols , 1);
- choosenAlgo = IFFT842 ;
- }
- }
- else
- {
- difft2 ( realIn, imagIn ,rows , cols , 1 , isn , ierr/* ,workSpace , sizeWorkSpace */);
- }
- }
- else
- {
- difft2 ( realIn, imagIn ,rows , cols , 1 , isn , ierr/* ,workSpace , sizeWorkSpace*/ );
- }
-
- /*second call*/
-
- if ( 2*rows <= 0 /* sizeWorkSpace*/ )
- {
- if ( rowsTemp == rows )
- {
- if ( rows <= pow ( 2 ,15) )
- {
- /*compute the fft on each line of the matrix */
- for (i = 0 ; i < cols ; i++ )
- {
- C2F(zcopy) ( rows, in + i, cols, inTemp , 1 );
-
- ifft842( inTemp , rows , 1);
- choosenAlgo = IFFT842 ;
- C2F(zcopy) ( rows, inTemp , cols, in + i, 1 );
-
- }
- }
- else
- {
- difft2 ( realIn, imagIn, 1, rows, cols, isn, ierr/*, workSpace, sizeWorkSpace*/);
- }
- }
- else
- {
- difft2 ( realIn, imagIn, 1, rows, cols, isn, ierr/*, workSpace, sizeWorkSpace*/);
- }
- }
- else
- {
- difft2 ( realIn, imagIn, 1, rows, cols, isn, ierr/*, workSpace, sizeWorkSpace*/);
- }
-}
-
-
-
-if ( choosenAlgo == IFFT842 )
- {
- for ( i = 0 ; i < size ; i++)
- {
- out[i] = DoubleComplex ( zreals(in[i]) , zimags(in[i]) );
- }
- }
-else
- {
- for ( i = 0 ; i < size ; i++)
- {
- out[i] = DoubleComplex ( realIn[i] , imagIn[i] );
- }
-
- }
+ int choosenAlgo = DFFT2 ;
+
+ int size = rows*cols ;
+ int sizeTemp = 0;
+
+ int rowsTemp = 0 ;
+ int colsTemp = 0 ;
+
+ int ierr = 0 ;
+ int isn = 1;
+ int i = 0;
+
+
+ double* realIn = (double*) malloc ( sizeof (double) * (unsigned int) size );
+ double* imagIn = (double*) malloc ( sizeof (double) * (unsigned int) size );
+
+
+ doubleComplex* inTemp = (doubleComplex*) malloc ( sizeof (doubleComplex) * (unsigned int) size );
+
+
+
+ zimaga ( in , size , imagIn) ;
+ zreala ( in , size , realIn) ;
+
+ if ( rows == 1 || cols == 1 )
+ {
+ printf ( "it'a vector \n" ) ;
+
+ sizeTemp = (int) pow ( 2 , (int ) (log( size + 0.5 ) /log ( 2 ))) ;
+ printf ("pow %e , temp %d \n" , pow ( 2 , (int )(log( size +0.5 ) /log ( 2 ))), sizeTemp);
+
+ if ( size == sizeTemp )
+ {
+ if ( size <= pow ( 2 , 15 ))
+ {
+ printf ( "we call ifft842 \n" ) ;
+ ifft842 ( in , size , 1 );
+ choosenAlgo = IFFT842 ;
+ }
+ else
+ {
+ printf ( "we call dfft2 \n" ) ;
+ difft2 ( realIn , imagIn , 1 , size , 1 , isn , ierr);
+ }
+
+
+ }
+ else
+ {
+ printf ( "we call dfft2 2\n" ) ;
+ difft2 ( realIn , imagIn , 1 , size , 1 , isn , ierr);
+ }
+
+ }
+
+ else
+ {
+ printf ( "it'a matrix \n" ) ;
+ rowsTemp = (int) pow ( 2 ,(int) log( rows + 0.5) /log ( 2 )) ;
+ colsTemp = (int) pow ( 2 ,(int) log( cols + 0.5) /log ( 2 )) ;
+
+ if ( rows == rowsTemp)
+ {
+ if ( rows <= pow ( 2 , 15 ))
+ {
+ for ( i = 0 ; i < cols ; i++ )
+ {
+ ifft842 ( &in[ rows*i] , rows , 1);
+ choosenAlgo = IFFT842 ;
+ }
+ }
+ else
+ {
+ difft2 ( realIn, imagIn ,cols , rows , 1 , isn , ierr);
+ }
+ }
+ else
+ {
+ difft2 ( realIn, imagIn ,cols , rows , 1 , isn , ierr);
+ }
+
+ /*second call*/
+ if ( colsTemp == cols )
+ {
+ if ( cols <= pow ( 2 ,15) )
+ {
+ /*compute the fft on each line of the matrix */
+ for (i = 0 ; i < rows ; i++ )
+ {
+ C2F(zcopy) ( cols, in + i, rows, inTemp , 1 );
+
+ ifft842( inTemp , cols , 1);
+ choosenAlgo = IFFT842 ;
+ C2F(zcopy) ( cols, inTemp , 1, in + i, rows);
+
+ }
+ }
+ else
+ {
+ difft2 ( realIn, imagIn, 1, cols, rows, isn, ierr);
+ }
+ }
+ else
+ {
+ difft2 ( realIn, imagIn, 1, cols, rows, isn, ierr);
+ }
+
+ }
+
+
+
+ if ( choosenAlgo == IFFT842 )
+ {
+ for ( i = 0 ; i < size ; i++)
+ {
+ out[i] = DoubleComplex ( zreals(in[i]) , zimags(in[i]) );
+ }
+ }
+ else
+ {
+ for ( i = 0 ; i < size ; i++)
+ {
+ out[i] = DoubleComplex ( realIn[i] , imagIn[i] );
+ }
+
+ }
}