summaryrefslogtreecommitdiff
path: root/src/signalProcessing/fft
diff options
context:
space:
mode:
authorsimon2008-10-16 08:25:30 +0000
committersimon2008-10-16 08:25:30 +0000
commit729eae8902d25105fee50f683503a5832b0912a2 (patch)
tree235770a8069c68f2fea687e3fac8cd5967b94d08 /src/signalProcessing/fft
parentee7b836277930e7fd36179e7da2300652895c510 (diff)
downloadscilab2c-729eae8902d25105fee50f683503a5832b0912a2.tar.gz
scilab2c-729eae8902d25105fee50f683503a5832b0912a2.tar.bz2
scilab2c-729eae8902d25105fee50f683503a5832b0912a2.zip
a convenient code to see the segfault on the 6th test
Diffstat (limited to 'src/signalProcessing/fft')
-rw-r--r--src/signalProcessing/fft/dfftmx.c40
-rw-r--r--src/signalProcessing/fft/testDoubleFft.c123
2 files changed, 120 insertions, 43 deletions
diff --git a/src/signalProcessing/fft/dfftmx.c b/src/signalProcessing/fft/dfftmx.c
index 16514578..cf739e03 100644
--- a/src/signalProcessing/fft/dfftmx.c
+++ b/src/signalProcessing/fft/dfftmx.c
@@ -98,7 +98,7 @@ int dfftmx ( double* _pdblA , double* _pdblB , int _iNtot, int _iN, int _iNspan,
{
int retVal = 0 ;
-
+ int iii = 0 ;
a = _pdblA ;
b = _pdblB ;
@@ -123,14 +123,8 @@ int dfftmx ( double* _pdblA , double* _pdblB , int _iNtot, int _iN, int _iNspan,
s72 = sin (rad/0.6250);
s120= sqrt(0.750);
- int iii = 0 ;
- fprintf (stderr , "\n\n" );
- for ( iii = 0 ; iii < 3 ; iii++)
- {
-
- fprintf (stderr , "\t\t %d tot : %f \t %f\n" , iii ,a[iii], b[iii]);
- }
+ fprintf (stderr , "\n\n" );
fprintf (stderr , "preliminary\n" );
preliminaryWork () ;
@@ -229,14 +223,16 @@ void preliminaryWork (void)
int factorTransform (void)
{
- int retVal = 42 ;
-
+ int retVal = 42;
dr = 8 * jc/kspan ;
cd = 2 * pow ( sin(0.5*dr*rad) , 2 );
sd = sin(dr*rad) ;
kk = 1 ;
i++ ;
+
+
+
fprintf (stderr , "avant switch i %d ,nfac[i-1] %d\n" , i , nfac[i-1]);
switch ( nfac[i-1] )
{
@@ -285,7 +281,7 @@ switch ( nfac[i-1] )
k = nfac[i-1] ;
kspnn = kspan ;
kspan = kspan / k ;
- fprintf (stderr , "\t\t k %d\n" , k);
+ fprintf (stderr , "\t\t k %d kspan \n" , k , kspan);
fprintf (stderr , "\t\t nfac[i-1] %d jf %d\n" , nfac[i-1] , jf ) ;
if ( nfac[i-1] != jf)
{
@@ -892,7 +888,7 @@ do
int mulByRotationFactor (void )
{
-
+ int ktemp = 0 ;
if ( i != m )
{
@@ -908,17 +904,21 @@ int mulByRotationFactor (void )
/*320 */
do
{
+ printf ( "\t 320 \n" ) ;
c1 = c2 ;
s2 = s1 ;
kk += kspan ;
do
{
+ printf ( "\t 330 \n" ) ;
ak = a[kk-1] ;
a[kk-1] = c2*ak - s2*b[kk-1] ;
b[kk-1] = s2*ak + c2*b[kk-1] ;
kk += kspnn ;
+ ktemp = kk ;
+
if ( kk > nt )
{
@@ -926,14 +926,18 @@ int mulByRotationFactor (void )
s2 = s1*c2 + s1*c1 ;
c2 = c1*c2 - ak ;
kk += (kspan - nt ) ;
+
+
}
- }while ( kk <= kspnn ) ;
+ }while (ktemp <= nt || ( kk <= kspnn && ktemp > nt )) ;
kk += ( jc - kspnn );
+ printf ( "\t avant goto310/340 , kk %d , mm %d , kspan %d \n" , kk , mm , kspan ) ;
if ( kk <= mm )
{
+ printf ( "\t 310 \n" ) ;
/* 310*/
c2 = c1 - ( cd*c1 + sd*s1 ) ;
s1 += (sd*c1 - cd*s1 ) ;
@@ -952,22 +956,26 @@ int mulByRotationFactor (void )
{
if ( kk <= kspan )
{
+ printf ( "\t 340 \n" ) ;
s1 = dr*rad * (kk-1)/jc ;
c2 = cos (s1) ;
s1 = sin (s1) ;
mm = min ( kspan , mm + klim );
}
}
- }while ( kk <= kspnn || kk <= kspan ) ;
+
+ }while ( kk <= mm ||( kk <= kspan && kk > nn ) ) ;
kk += (jc + inc -kspan );
+ printf ( "je boucle 2 \n" ) ;
}while ( kk <= jc+jc);
- return 1 ; /* goto40 */
+ printf ("\tje prends le goto40\n" ) ;
+ return 0 ; /* goto40 */
}
- return 0 ; /* goto350*/
+ return 1 ; /* goto350*/
}
diff --git a/src/signalProcessing/fft/testDoubleFft.c b/src/signalProcessing/fft/testDoubleFft.c
index 9bb41ce4..c872c689 100644
--- a/src/signalProcessing/fft/testDoubleFft.c
+++ b/src/signalProcessing/fft/testDoubleFft.c
@@ -1,6 +1,6 @@
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2006-2008 - INRIA - Bruno JOFRET
+ * 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
@@ -60,11 +60,18 @@
#define ZIMAG_IN8 { 0.21460078610107303, 0.31264199689030647, 0.36163610080257058, 0.2922266637906432,\
0.56642488157376647, 0.48264719732105732, 0.33217189135029912, 0.59350947011262178}
+#define ZREAL_IN9 { 0.23122371966019273, 0.21646326314657927, 0.88338878145441413, 0.65251349471509457,\
+ 0.30760907428339124, 0.93296162132173777, 0.21460078610107303, 0.31264199689030647,\
+ 0.43685875833034515}
+#define ZIMAG_IN9 { 0.26931248093023896, 0.63257448654621840, 0.40519540151581168, 0.91847078315913677,\
+ 0.28064980218186975, 0.12800584640353918, 0.77831285959109664, 0.21190304495394230,\
+ 0.68568959552794695}
+
+
#define ZREAL_IN16 {0.23122371966019273, 0.21646326314657927, 0.88338878145441413, 0.65251349471509457,\
0.30760907428339124, 0.93296162132173777, 0.21460078610107303, 0.31264199689030647,\
0.36163610080257058, 0.2922266637906432 , 0.56642488157376647, 0.48264719732105732,\
0.33217189135029912, 0.59350947011262178, 0.50153415976092219, 0.43685875833034515}
-
#define ZIMAG_IN16 {0.26931248093023896, 0.63257448654621840, 0.40519540151581168, 0.91847078315913677,\
0.04373343335464597, 0.48185089323669672, 0.26395560009405017, 0.41481037065386772,\
0.28064980218186975, 0.12800584640353918, 0.77831285959109664, 0.21190304495394230,\
@@ -116,6 +123,13 @@
#define ZIMAG_RESULT8 { 3.15585898794233799, 0.62132445165622818, 0.35205427557229996, 0.28289917172258683,\
-0.20619166828691959,-1.17220193335521805,-0.17761892452836037,-1.13931807191437073 }
+#define ZREAL_RESULT9 { 4.18826149590313435,-0.33012457237426968,-0.46815050871925312,-0.52782532864173848,\
+ 0.14402327100125287, 0.48673726656350014,-0.36542216583231485,-0.05675799381585508,\
+ -0.98972798714272159}
+#define ZIMAG_RESULT9 { 4.31011430080980062,-0.43185186999958014,-0.61788469590268758, 2.02080753944191294,\
+ -1.82700213292318292,-0.72130831941965079,-0.43263346921029644,-0.61611460931125561,\
+ 0.73968558488709069 }
+
#define ZREAL_RESULT16 { 7.31841186061501503, 0.57213963313411265,-0.54757095809921363,-0.48628670926159856,\
-1.24745626002550125,-0.60260425121772254,-0.09566750389725764, 1.12013387649474438,\
-0.52123307064175606,-0.4866536676629296 , 1.98659065302356819,-0.8626986211125984 ,\
@@ -249,6 +263,53 @@ static void zfftmaTest3 (void )
}
+
+static void zfftmaTest4 (void )
+{
+ int i = 0 ;
+
+ double tRealIn [] = ZREAL_IN4;
+ double tImagIn [] = ZIMAG_IN4 ;
+
+
+
+ double tRealResult [] = ZREAL_RESULT4 ;
+ double tImagResult [] = ZIMAG_RESULT4 ;
+
+
+
+ doubleComplex* out = (doubleComplex*) malloc ( sizeof(doubleComplex) * (unsigned int) (ROW*COLS4));
+ doubleComplex* in = DoubleComplexMatrix ( tRealIn , tImagIn , ROW*COLS4 );
+ doubleComplex* Result = DoubleComplexMatrix ( tRealResult , tImagResult ,ROW*COLS4) ;
+
+
+ zfftma ( in , ROW , COLS4 , out ) ;
+
+ /* if we don't add that test assert failed if result = 0 'cause then we have |(out - 0)|/|out| = 1*/
+ for ( i = 0 ; i < (ROW*COLS4 ) ; i++ )
+ {
+ printf ( "\t\t %d out : %e\t %e\t * i result : %e\t %e\t * i assert : : %e\t %e\t * i \n" ,
+ i ,zreals(out[i]) , zimags(out[i]), zreals (Result[i]) , zimags (Result[i]),
+ fabs( zreals(out[i]) - zreals (Result[i]) ) / fabs (zreals (out[i])) ,
+ fabs( zimags(out[i]) - zimags (Result[i]) ) / fabs (zimags (out[i])));
+
+ if ( zreals(out[i]) < 1e-14 && zreals (Result[i]) < 1e-18 )
+ assert ( 1 ) ;
+ else
+ assert ( fabs( zreals(out[i]) - zreals (Result[i]) ) / fabs (zreals (out[i])) < 1e-12 );
+
+
+ if ( zimags(out[i]) < 1e-14 && zimags (Result[i]) < 1e-18 )
+ assert ( 1 ) ;
+ else
+ assert ( fabs( zimags(out[i]) - zimags (Result[i]) ) / fabs (zimags (out[i])) < 1e-12 ) ;
+
+ }
+
+
+}
+
+
static void zfftmaTest5 (void )
{
int i = 0 ;
@@ -407,29 +468,31 @@ static void zfftmaTest7 (void )
}
-static void zfftmaTest4 (void )
+
+
+static void zfftmaTest8 (void )
{
int i = 0 ;
- double tRealIn [] = ZREAL_IN4;
- double tImagIn [] = ZIMAG_IN4 ;
+ double tRealIn [] = ZREAL_IN8;
+ double tImagIn [] = ZIMAG_IN8 ;
- double tRealResult [] = ZREAL_RESULT4 ;
- double tImagResult [] = ZIMAG_RESULT4 ;
+ double tRealResult [] = ZREAL_RESULT8 ;
+ double tImagResult [] = ZIMAG_RESULT8 ;
- doubleComplex* out = (doubleComplex*) malloc ( sizeof(doubleComplex) * (unsigned int) (ROW*COLS4));
- doubleComplex* in = DoubleComplexMatrix ( tRealIn , tImagIn , ROW*COLS4 );
- doubleComplex* Result = DoubleComplexMatrix ( tRealResult , tImagResult ,ROW*COLS4) ;
+ doubleComplex* out = (doubleComplex*) malloc ( sizeof(doubleComplex) * (unsigned int) (ROW*COLS8));
+ doubleComplex* in = DoubleComplexMatrix ( tRealIn , tImagIn , ROW*COLS8 );
+ doubleComplex* Result = DoubleComplexMatrix ( tRealResult , tImagResult ,ROW*COLS8) ;
- zfftma ( in , ROW , COLS4 , out ) ;
+ zfftma ( in , ROW , COLS8 , out ) ;
/* if we don't add that test assert failed if result = 0 'cause then we have |(out - 0)|/|out| = 1*/
- for ( i = 0 ; i < (ROW*COLS4 ) ; i++ )
+ for ( i = 0 ; i < (ROW*COLS8 ) ; i++ )
{
printf ( "\t\t %d out : %e\t %e\t * i result : %e\t %e\t * i assert : : %e\t %e\t * i \n" ,
i ,zreals(out[i]) , zimags(out[i]), zreals (Result[i]) , zimags (Result[i]),
@@ -452,36 +515,35 @@ static void zfftmaTest4 (void )
}
-
-static void zfftmaTest8 (void )
+static void zfftmaTest9 (void )
{
int i = 0 ;
- double tRealIn [] = ZREAL_IN8;
- double tImagIn [] = ZIMAG_IN8 ;
+ double tRealIn [] = ZREAL_IN9;
+ double tImagIn [] = ZIMAG_IN9 ;
- double tRealResult [] = ZREAL_RESULT8 ;
- double tImagResult [] = ZIMAG_RESULT8 ;
+ double tRealResult [] = ZREAL_RESULT9 ;
+ double tImagResult [] = ZIMAG_RESULT9 ;
- doubleComplex* out = (doubleComplex*) malloc ( sizeof(doubleComplex) * (unsigned int) (ROW*COLS8));
- doubleComplex* in = DoubleComplexMatrix ( tRealIn , tImagIn , ROW*COLS8 );
- doubleComplex* Result = DoubleComplexMatrix ( tRealResult , tImagResult ,ROW*COLS8) ;
+ doubleComplex* out = (doubleComplex*) malloc ( sizeof(doubleComplex) * (unsigned int) (ROW*COLS9));
+ doubleComplex* in = DoubleComplexMatrix ( tRealIn , tImagIn , ROW*COLS9 );
+ doubleComplex* Result = DoubleComplexMatrix ( tRealResult , tImagResult ,ROW*COLS9) ;
- zfftma ( in , ROW , COLS8 , out ) ;
+ zfftma ( in , ROW , COLS9 , out ) ;
/* if we don't add that test assert failed if result = 0 'cause then we have |(out - 0)|/|out| = 1*/
- for ( i = 0 ; i < (ROW*COLS8 ) ; i++ )
+ for ( i = 0 ; i < (ROW*COLS9 ) ; i++ )
{
printf ( "\t\t %d out : %e\t %e\t * i result : %e\t %e\t * i assert : : %e\t %e\t * i \n" ,
i ,zreals(out[i]) , zimags(out[i]), zreals (Result[i]) , zimags (Result[i]),
fabs( zreals(out[i]) - zreals (Result[i]) ) / fabs (zreals (out[i])) ,
fabs( zimags(out[i]) - zimags (Result[i]) ) / fabs (zimags (out[i])));
-
+/*
if ( zreals(out[i]) < 1e-14 && zreals (Result[i]) < 1e-18 )
assert ( 1 ) ;
else
@@ -492,7 +554,7 @@ static void zfftmaTest8 (void )
assert ( 1 ) ;
else
assert ( fabs( zimags(out[i]) - zimags (Result[i]) ) / fabs (zimags (out[i])) < 1e-12 ) ;
-
+*/
}
@@ -626,14 +688,21 @@ static int testFft(void) {
printf("\t>>>> Vector 7 Double Complex Tests\n");
zfftmaTest7();
-/*
printf("\t>>>> Vector 8 Double Complex Tests\n");
zfftmaTest8();
+ printf("\t>>>> Vector 9 Double Complex Tests\n");
+ zfftmaTest9();
+
printf("\t>>>> Vector 16 Double Complex Tests\n");
zfftmaTest16();
printf("\t>>>> Vector 32 Double Complex Tests\n");
zfftmaTest32();
-*/
+
+
+
+ printf("\t>>>> Vector 6 Double Complex Tests\n");
+ zfftmaTest6();
+
return 0;
}