From 471832e39f62f2e67f5fd78e2dd0b8b14b7f05ec Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 3 Mar 2018 18:38:41 +0100 Subject: [PATCH] Update rotmg tests in utest_main2.c --- utest/utest_main2.c | 162 +++++++++++++++++++++++++++----------------- 1 file changed, 100 insertions(+), 62 deletions(-) diff --git a/utest/utest_main2.c b/utest/utest_main2.c index bcaa43ec0..e394f2da2 100644 --- a/utest/utest_main2.c +++ b/utest/utest_main2.c @@ -50,14 +50,15 @@ CTEST(amax, samax){ ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS); } -CTEST (drotmg,rotmg){ +CTEST (drotmg,rotmg) +{ double te_d1, tr_d1; double te_d2, tr_d2; double te_x1, tr_x1; double te_y1, tr_y1; double te_param[5]; double tr_param[5]; - blasint i=0; + int i=0; // original test case for libGoto bug fixed by feb2014 rewrite te_d1= 0.21149573940783739; te_d2= 0.046892057172954082; @@ -87,26 +88,27 @@ CTEST (drotmg,rotmg){ tr_param[4]= 0.0; BLASFUNC(drotmg)(&te_d1, &te_d2, &te_x1, &te_y1, te_param); - ASSERT_DBL_NEAR_TOL(te_d1, tr_d1, DOUBLE_EPS); - ASSERT_DBL_NEAR_TOL(te_d2, tr_d2, DOUBLE_EPS); - ASSERT_DBL_NEAR_TOL(te_x1, tr_x1, DOUBLE_EPS); - ASSERT_DBL_NEAR_TOL(te_y1, tr_y1, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_d1, te_d1, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_d2, te_d2, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_x1, te_x1, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_y1, te_y1, DOUBLE_EPS); for(i=0; i<5; i++){ - ASSERT_DBL_NEAR_TOL(te_param[i], tr_param[i], DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS); } } -CTEST (drotmg,rotmg_issue1452){ +CTEST (drotmg,rotmg_issue1452) +{ double te_d1, tr_d1; double te_d2, tr_d2; double te_x1, tr_x1; double te_y1, tr_y1; double te_param[5]; double tr_param[5]; - blasint i=0; + int i=0; - // from issue #1452, buggy version returned 0.000244 for param[3] + // from issue #1452 te_d1 = 5.9e-8; te_d2 = 5.960464e-8; te_x1 = 1.0; @@ -115,8 +117,8 @@ CTEST (drotmg,rotmg_issue1452){ for(i=0; i<5; i++){ te_param[i]=tr_param[i]=0.0; } - - //reference values as calulated by netlib blas + te_param[3]=1./4096.; + //reference values as calulated by gonum blas with rotmg rewritten to Hopkins' algorithm tr_d1= 0.99995592822897; tr_d2= 0.98981219860583; tr_x1= 0.03662270484346; @@ -125,31 +127,32 @@ CTEST (drotmg,rotmg_issue1452){ tr_param[0]= -1.0; tr_param[1]= 0.00000161109346; tr_param[2]= -0.00024414062500; - tr_param[3]= 1.0; + tr_param[3]= 0.00024414062500; tr_param[4]= 0.00000162760417; //OpenBLAS BLASFUNC(drotmg)(&te_d1, &te_d2, &te_x1, &te_y1, te_param); - ASSERT_DBL_NEAR_TOL(te_d1, tr_d1, DOUBLE_EPS); - ASSERT_DBL_NEAR_TOL(te_d2, tr_d2, DOUBLE_EPS); - ASSERT_DBL_NEAR_TOL(te_x1, tr_x1, DOUBLE_EPS); - ASSERT_DBL_NEAR_TOL(te_y1, tr_y1, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_d1, te_d1, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_d2, te_d2, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_x1, te_x1, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_y1, te_y1, DOUBLE_EPS); for(i=0; i<5; i++){ - ASSERT_DBL_NEAR_TOL(te_param[i], tr_param[i], DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS); } } -CTEST(drotmg, rotmg_D1eqD2_X1eqX2){ +CTEST(drotmg, rotmg_D1eqD2_X1eqX2) +{ double te_d1, tr_d1; double te_d2, tr_d2; double te_x1, tr_x1; double te_y1, tr_y1; double te_param[5]; double tr_param[5]; - blasint i=0; + int i=0; te_d1= tr_d1=2.; te_d2= tr_d2=2.; te_x1= tr_x1=8.; @@ -174,13 +177,48 @@ CTEST(drotmg, rotmg_D1eqD2_X1eqX2){ //OpenBLAS BLASFUNC(drotmg)(&te_d1, &te_d2, &te_x1, &te_y1, te_param); - ASSERT_DBL_NEAR_TOL(te_d1, tr_d1, DOUBLE_EPS); - ASSERT_DBL_NEAR_TOL(te_d2, tr_d2, DOUBLE_EPS); - ASSERT_DBL_NEAR_TOL(te_x1, tr_x1, DOUBLE_EPS); - ASSERT_DBL_NEAR_TOL(te_y1, tr_y1, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_d1, te_d1, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_d2, te_d2, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_x1, te_x1, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_y1, te_y1, DOUBLE_EPS); for(i=0; i<5; i++){ - ASSERT_DBL_NEAR_TOL(te_param[i], tr_param[i], DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS); + } +} + +CTEST(drotmg, drotmg_D1_big_D2_big_flag_zero) +{ + double te_d1, tr_d1; + double te_d2, tr_d2; + double te_x1, tr_x1; + double te_y1, tr_y1; + double te_param[5]={1.,4096.,-4096.,1.,4096.}; + double tr_param[5]={-1.,4096.,-3584.,1792.,4096.}; + int i=0; + te_d1= tr_d1=1600000000.; + te_d2= tr_d2=800000000.; + te_x1= tr_x1=8.; + te_y1= tr_y1=7.; + + + //reference values as calulated by gonum + tr_d1= 68.96627824858757; + tr_d2= 34.483139124293785; + tr_x1= 45312.; + tr_y1= 7.0; + + + //OpenBLAS + BLASFUNC(drotmg)(&te_d1, &te_d2, &te_x1, &te_y1, te_param); + + ASSERT_DBL_NEAR_TOL(tr_d1, te_d1, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_d2, te_d2, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_x1, te_x1, DOUBLE_EPS); + ASSERT_DBL_NEAR_TOL(tr_y1, te_y1, DOUBLE_EPS); + + for(i=0; i<5; i++){ + ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS); } } @@ -199,8 +237,8 @@ CTEST(axpy,daxpy_inc_0) BLASFUNC(daxpy)(&N,&a,x1,&incX,y1,&incY); for(i=0; i