summaryrefslogtreecommitdiff
path: root/src/matrixOperations/division/testMatrixRDivision.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/matrixOperations/division/testMatrixRDivision.c')
-rw-r--r--src/matrixOperations/division/testMatrixRDivision.c156
1 files changed, 144 insertions, 12 deletions
diff --git a/src/matrixOperations/division/testMatrixRDivision.c b/src/matrixOperations/division/testMatrixRDivision.c
index bc211664..659aca0e 100644
--- a/src/matrixOperations/division/testMatrixRDivision.c
+++ b/src/matrixOperations/division/testMatrixRDivision.c
@@ -19,13 +19,17 @@
#define LINES2 1
#define COLUMNS 2
+#define ZLINES1 13
+#define ZLINES2 7
+#define ZCOLUMNS 10
+
+
-/*
static void sdivaTest ( void )
{
int i = 0 ;
-
+/*
float in1[] =
{0.51323400903493166f,0.6807207581587136f,0.54669387824833393f,0.24904179340228438f,
0.95017496403306723f,0.91187966475263238f,0.78931419923901558f,0.30985609395429492f,
@@ -202,13 +206,21 @@ float result[] =
-0.07318875604760167f,0.49681103126620946f,0.16658812117729807f,0.19247716660649325f,
0.17479922937365650f,0.20305642078183334f,-0.11893261285117168f,0.52167729786941019f,
-0.26590601210923126f,-0.17052720242327102f};
-
-float out[(COLUMNS)*(LINES2)] ;
+ */
+
+ /*float in1[] = { 4.0f , 3.0f , 8.0f , 9.0f } ;
+ float in2[] = { 1.0f , 3.0f , 2.0f , 4.0f } ;
+ float result[] = { 4.0f , 7.5f , 0.0f ,-1.5f };
+float out[(COLUMNS)*(LINES2)] ;*/
- printf("\n>rentre dans fonction \n");
- srdiva ( in1 , LINES1 , COLUMNS , in2 , LINES2 , COLUMNS , out ) ;
+ float in1[] = { 1.0f ,3.0f ,2.0f ,4.0f } ;
+ float in2[] = { 1.0f , 2.0f } ;
+ float result[] = { 1.0f , 2.2f };
+ float out [(COLUMNS)*(LINES2)] ;
+
+ srdiva ( in1 , LINES1 , COLUMNS , in2 , LINES2 , COLUMNS , out) ;
printf("\n\n\t>>>>>debut assert\n");
- for ( i = 0 ; i < LINES2 *COLUMNS ; i++ )
+ for ( i = 0 ; i < 4 ; i++ )
{
printf ( "\n %d out : %e result : %e\n" , i , out[i] , result[i] ) ;
assert ( fabs ( out[i] - result[i] ) / fabs( out[i]) < 1e-6 ) ;
@@ -219,8 +231,6 @@ float out[(COLUMNS)*(LINES2)] ;
-*/
-
@@ -239,10 +249,10 @@ static void drdivaTest ( void )
double out [(COLUMNS)*(LINES2)] ;
drdiva ( in1 , LINES1 , COLUMNS , in2 , LINES2 , COLUMNS , out) ;
- printf("\n\n\t>>>>>debut assert\n");
for ( i = 0 ; i < LINES2 *COLUMNS ; i++ )
{
- printf ( "\n %d out : %e result : %e assert : %e \n" , i , out[i] , result[i] , fabs ( out[i] - result[i] ) / fabs( out[i]) ) ;
+ printf ( "*\t\t %d out : %e result : %e assert : %e \n" ,
+ i , out[i] , result[i] , fabs ( out[i] - result[i] ) / fabs( out[i]) ) ;
assert ( fabs ( out[i] - result[i] ) / fabs( out[i]) < 1e-15 ) ;
}
@@ -251,12 +261,134 @@ static void drdivaTest ( void )
+
+static void zrdivaTest ( void ){
+ int i = 0 ;
+
+ double tin1 [] =
+ {0.69949407549574971,0.25834653992205858,0.61552664963528514,0.19030105322599411,
+ 0.46075769001618028,0.52200102340430021,0.70538004627451301,0.88748936913907528,
+ 0.18582182424142957,0.09225247148424387,0.37796644819900393,0.93693156912922859,
+ 0.19805216649547219,
+0.47020285483449697,0.37788185989484191,0.36296494491398335,0.27933338703587651,
+ 0.67214426863938570,0.69089507637545466,0.5104757994413376,0.06106034899130464,
+ 0.93353842478245497,0.14489983161911368,0.57212112657725811,0.54598869429901242,
+ 0.05166801903396845,
+0.50110132200643420,0.92609716579318047,0.85469480464234948,0.58570997323840857,
+ 0.8791871047578752,0.25320483185350895,0.7903951373882592,0.63298055250197649,
+ 0.86023237137123942,0.90196201950311661,0.31587493652477860,0.40010235738009214,
+ 0.11108959605917335,
+0.47051278315484524,0.53627631859853864,0.28784319106489420,0.87401255918666720,
+ 0.07408339157700539,0.28149573365226388,0.70837680157274008,0.16526474570855498,
+ 0.26673525758087635,0.88194080116227269,0.35371549893170595,0.02646211860701442,
+ 0.08616474270820618,
+0.23139652097597718,0.13406464736908674,0.67240026732906699,0.19029983691871166,
+ 0.73075085924938321,0.50484903249889612,0.87911593122407794,0.55444371327757835,
+ 0.2063297093845904,0.40116110350936651,0.45593289798125625,0.69771515764296055,
+ 0.39659122796729207,
+0.49838109035044909,0.14524227706715465,0.90753587335348129,0.10092954570427537,
+ 0.01771899592131376,0.79376714816316962,0.43091466091573238,0.58433785336092114,
+ 0.79542846325784922,0.13906158460304141,0.10127847269177437,0.331680862698704,
+ 0.83444251772016287,
+0.05499405181035399,0.36960034258663654,0.74532664241269231,0.05718118418008089,
+ 0.59996518073603511,0.20857419073581696,0.87988782906904817,0.47828097920864820,
+ 0.71160991629585624,0.85858650319278240,0.80782221304252744,0.51599627826362848,
+ 0.89173404080793262,
+0.88423488661646843,0.70964269945397973,0.66102255787700415,0.72523507243022323,
+ 0.51014349795877934,0.28248664410784841,0.22149151284247637,0.57675753859803081,
+ 0.70482534915208817,0.56079456442967057,0.36288804840296507,0.30883262446150184,
+ 0.98134148679673672,
+0.74284822540357709,0.16163914743810892,0.36525219632312655,0.38350704684853554,
+ 0.11691810050979257,0.89112461265176535,0.06342720007523894,0.62639418430626392,
+ 0.68077020766213536,0.25885968375951052,0.43948043463751674,0.85988187789916992,
+ 0.54828232014551759,
+0.81359952967613935,0.48982370039448142,0.02400260977447033,0.73691955255344510,
+ 0.24111561570316553,0.15296932263299823,0.26483592018485069,0.42981932172551751,
+ 0.76739394571632147,0.87532604997977614,0.37969883717596531,0.30623568268492818,
+ 0.38800517935305834}
+;
+ double tin2[] =
+ {0.10472932783886790,0.76038318127393723,0.03409303957596421,0.14239662420004606,
+ 0.55545594682916999,0.80318974517285824,0.51839923160150647,
+0.15185610298067331,0.58847306622192264,0.25450934842228889,0.99926799396052957,
+ 0.63989769574254751,0.55067161237820983,0.46070076711475849,
+0.59330079378560185,0.65381935704499483,0.41683405218645930,0.99101553857326508,
+ 0.37207804108038545,0.70618240814656019,0.57808654149994254,
+0.60231964103877544,0.57150967465713620,0.05496290419250727,0.12058544857427478,
+ 0.01436204835772514,0.02579512307420373,0.84112487640231848,
+0.43818825250491500,0.46434015966951847,0.41974264057353139,0.80236544925719500,
+ 0.52285881666466594,0.50951210409402847,0.45319801801815629,
+0.78178183268755674,0.77655703714117408,0.04660592041909695,0.51133266882970929,
+ 0.75021018926054239,0.68836286617442966,0.01677561178803444,
+0.93454108992591500,0.56098637636750937,0.22058471059426665,0.76485407538712025,
+ 0.48169769765809178,0.15587856341153383,0.24760220525786281,
+0.5216529071331024,0.08052303874865174,0.44094172399491072,0.89119336148723960,
+ 0.97805908136069775,0.45880937622860074,0.55104400310665369,
+0.09609609050676227,0.41967850551009178,0.75025565037503839,0.72181495930999517,
+ 0.28955410188063979,0.39077644981443882,0.66866181464865804,
+0.48776568192988634,0.46859717695042491,0.35626485198736191,0.34423254663124681,
+ 0.42533078324049711,0.55880581727251410,0.33048649691045284};
+
+ double tresult [] =
+{0.09451169317317064,0.75015055776907902,0.36496074775718695,0.68454978838459446,
+ 0.13580235186649750,-0.73350613524989861,0.36833823393043919,0.27427787570717332,
+ 0.17435767433670571,1.27922130237729870,-0.15718152608891298,-0.66812523122285583,
+ 0.43535989166783623,
+-0.17216817930992268,-1.11920478787033972,0.09365729285784405,-0.91168598672719281,
+ -0.5256902016286176,1.47418373212534837,0.32785551967187748,0.09665910045214705,
+ 0.38963814934750451,-0.74599090807052515,0.77435560834796702,1.17862196275483577,
+ 0.41913747422722752,
+0.65168405083167491,-0.79778304970274549,-0.36689764540805470,-0.07037790812871010,
+ -0.90964747913660449,0.87009086524746737,-0.86086796711204328,0.69420170666117553,
+ 0.39900228216491013,0.01839542030829135,0.34079166496122038,0.94979559344928910,
+ 1.29342689865858507,
+-0.64010890644433138,0.43942520236508265,0.36871562427022309,-0.23543430717113373,
+ 0.9837594524525952,-0.15541789413277388,0.51832027142464965,-0.49730447418173146,
+ 0.37785363034287500,0.05031307256758123,0.14529056591993289,-0.19261761155662854,
+ -0.65165849136819898,
+0.56992829732488970,-0.67626872453203313,0.08987541550832115,-0.27809079516465274,
+ -0.52685742082861620,0.87085948155471882,-0.36015598439076552,0.24628281709439132,
+ 0.16018284982540432,-0.78765458348414275,0.4868803314915888,0.67004786693098373,
+ 1.38638653773561149,
+0.49065638508775172,1.15002211885645633,0.31098171282535453,0.772677804931936,
+ 0.77563266454559698,-0.93158860042668212,0.20092451587523308,0.56834988643083173,
+ -0.03774794264631696,0.70322729924980754,-0.84660509947179974,-0.48910607201144141,
+ -0.91999377725600595,
+0.57044463605090034,0.85729374705550832,0.03549271915962299,1.08806327983132478,
+ 0.40323683962485551,-0.27978276073461661,0.45277262688908537,0.06218152458345420,
+ -0.2153422115217984,0.68840508909853904,0.09945644614561956,-0.17861252621808085,
+ -0.44037299008464365}
+;
+
+ doubleComplex* in1 ;
+ doubleComplex* in2 ;
+ doubleComplex out[ZLINES2*ZLINES1] ;
+ doubleComplex Result[ZLINES1*ZLINES2] ;
+
+ in1 = DoubleComplexMatrix ( tin1 , tin1 , ZLINES1*ZCOLUMNS );
+ in2 = DoubleComplexMatrix ( tin2 , tin2 , ZLINES2*ZCOLUMNS );
+
+ zrdiva ( in1 , ZLINES1 , ZCOLUMNS , in2 , ZLINES2 , ZCOLUMNS , out) ;
+
+ for ( i = 0 ; i < ZLINES2*ZCOLUMNS ; i++ )
+ {
+ Result[i] = DoubleComplex ( tresult[i] , 0 ) ;
+
+ assert ( fabs( zreals(out[i]) - zreals (Result[i]) ) / fabs (zreals (out[i])) < 1e-17 );
+ assert ( fabs( zimags(out[i]) - zimags (Result[i]) ) / fabs (zimags (out[i])) < 1e-17 ) ;
+
+ }
+}
+
static int testRDiva (void) {
printf("\n>>>> Right Tests\n");
- /*sdivaTest();*/
+ printf("\n\t>>>> Float real Tests\n");
+ sdivaTest();
printf("\n\t>>>> Double real Tests\n");
drdivaTest();
+ printf("\n\t>>>> Double complex Tests\n");
+ zrdivaTest();
return 0;
}