1 /*****************************************************************************
2 Copyright (c) 2011-2014, The OpenBLAS Project
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
9 1. Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in
14 the documentation and/or other materials provided with the
16 3. Neither the name of the OpenBLAS project nor the names of
17 its contributors may be used to endorse or promote products
18 derived from this software without specific prior written
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
30 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 **********************************************************************************/
34 #include "openblas_utest.h"
45 // original test case for libGoto bug fixed by feb2014 rewrite
46 te_d1= 0.21149573940783739;
47 te_d2= 0.046892057172954082;
48 te_x1= -0.42272687517106533;
49 te_y1= 0.42211309121921659;
53 te_param[i]=tr_param[i]=0.0;
56 //reference values as calculated by netlib blas
62 tr_d1= 0.17320483687975;
63 tr_d2= 0.03840233915037;
64 tr_x1= -0.51618034832329;
65 tr_y1= 0.42211309121922;
69 tr_param[2]= 0.99854803659786;
70 tr_param[3]= -0.22139439665872;
73 BLASFUNC(drotmg)(&te_d1, &te_d2, &te_x1, &te_y1, te_param);
74 ASSERT_DBL_NEAR_TOL(tr_d1, te_d1, DOUBLE_EPS);
75 ASSERT_DBL_NEAR_TOL(tr_d2, te_d2, DOUBLE_EPS);
76 ASSERT_DBL_NEAR_TOL(tr_x1, te_x1, DOUBLE_EPS);
77 ASSERT_DBL_NEAR_TOL(tr_y1, te_y1, DOUBLE_EPS);
80 ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS);
84 CTEST (drotmg,rotmg_issue1452)
101 te_param[i]=tr_param[i]=0.0;
103 te_param[3]=1./4096.;
104 //reference values as calculated by gonum blas with rotmg rewritten to Hopkins' algorithm
105 tr_d1= 0.99995592822897;
106 tr_d2= 0.98981219860583;
107 tr_x1= 0.03662270484346;
108 tr_y1= 150.000000000000;
111 tr_param[1]= 0.00000161109346;
112 tr_param[2]= -0.00024414062500;
113 tr_param[3]= 0.00024414062500;
114 tr_param[4]= 0.00000162760417;
117 BLASFUNC(drotmg)(&te_d1, &te_d2, &te_x1, &te_y1, te_param);
119 ASSERT_DBL_NEAR_TOL(tr_d1, te_d1, DOUBLE_EPS);
120 ASSERT_DBL_NEAR_TOL(tr_d2, te_d2, DOUBLE_EPS);
121 ASSERT_DBL_NEAR_TOL(tr_x1, te_x1, DOUBLE_EPS);
122 ASSERT_DBL_NEAR_TOL(tr_y1, te_y1, DOUBLE_EPS);
125 ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS);
130 CTEST(drotmg, rotmg_D1eqD2_X1eqX2)
145 te_param[i]=tr_param[i]=0.0;
148 //reference values as calculated by netlib blas
161 BLASFUNC(drotmg)(&te_d1, &te_d2, &te_x1, &te_y1, te_param);
163 ASSERT_DBL_NEAR_TOL(tr_d1, te_d1, DOUBLE_EPS);
164 ASSERT_DBL_NEAR_TOL(tr_d2, te_d2, DOUBLE_EPS);
165 ASSERT_DBL_NEAR_TOL(tr_x1, te_x1, DOUBLE_EPS);
166 ASSERT_DBL_NEAR_TOL(tr_y1, te_y1, DOUBLE_EPS);
169 ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS);
173 CTEST(drotmg, drotmg_D1_big_D2_big_flag_zero)
179 double te_param[5]={1.,4096.,-4096.,1.,4096.};
180 double tr_param[5]={-1.,4096.,-3584.,1792.,4096.};
182 te_d1= tr_d1=1600000000.;
183 te_d2= tr_d2=800000000.;
188 //reference values as calculated by gonum
189 tr_d1= 68.96627824858757;
190 tr_d2= 34.483139124293785;
196 BLASFUNC(drotmg)(&te_d1, &te_d2, &te_x1, &te_y1, te_param);
198 ASSERT_DBL_NEAR_TOL(tr_d1, te_d1, DOUBLE_EPS);
199 ASSERT_DBL_NEAR_TOL(tr_d2, te_d2, DOUBLE_EPS);
200 ASSERT_DBL_NEAR_TOL(tr_x1, te_x1, DOUBLE_EPS);
201 ASSERT_DBL_NEAR_TOL(tr_y1, te_y1, DOUBLE_EPS);
204 ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS);