Upgrade to version 0.3.21
[platform/upstream/openblas.git] / utest / utest_main2.c
1 /*****************************************************************************
2 Copyright (c) 2011-2016, The OpenBLAS Project
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8
9    1. Redistributions of source code must retain the above copyright
10       notice, this list of conditions and the following disclaimer.
11
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
15       distribution.
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 
19       permission.
20
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.
31
32 **********************************************************************************/
33
34 #include <stdio.h>
35 #include <complex.h>
36
37 #define CTEST_MAIN
38 #define CTEST_SEGFAULT
39 #define CTEST_ADD_TESTS_MANUALLY
40
41 #include "openblas_utest.h"
42
43 CTEST(amax, samax){
44   blasint N=3, inc=1;
45   float te_max=0.0, tr_max=0.0;
46   float x[]={-1.1, 2.2, -3.3};
47   te_max=BLASFUNC(samax)(&N, x, &inc);
48   tr_max=3.3;
49   
50   ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS);
51 }
52
53 CTEST(amax, damax){
54   blasint N=3, inc=1;
55   double te_max=0.0, tr_max=0.0;
56   double x[]={-1.1, 2.2, -3.3};
57
58   te_max=BLASFUNC(damax)(&N, x, &inc);
59   tr_max=3.3;
60
61   ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), DOUBLE_EPS);
62 }
63
64 CTEST (drotmg,rotmg)
65 {
66         double te_d1, tr_d1;
67         double te_d2, tr_d2;
68         double te_x1, tr_x1;
69         double te_y1, tr_y1;
70         double te_param[5];
71         double tr_param[5];
72         int i=0;
73         // original test case for libGoto bug fixed by feb2014 rewrite
74         te_d1= 0.21149573940783739;
75         te_d2= 0.046892057172954082;
76         te_x1= -0.42272687517106533;
77         te_y1= 0.42211309121921659;
78
79
80         for(i=0; i<5; i++){
81           te_param[i]=tr_param[i]=0.0;
82         }
83
84         //reference values as calculated by netlib blas
85
86         tr_d1= 0.1732048;
87         tr_d2= 0.03840234;
88         tr_x1= -0.516180;
89         tr_y1= 0.422113;
90         tr_d1= 0.17320483687975;
91         tr_d2= 0.03840233915037;
92         tr_x1= -0.51618034832329;
93         tr_y1= 0.42211309121922;
94
95         tr_param[0]= 0.0;
96         tr_param[1]= 0.0;
97         tr_param[2]= 0.99854803659786; 
98         tr_param[3]= -0.22139439665872;
99         tr_param[4]= 0.0;
100
101         BLASFUNC(drotmg)(&te_d1, &te_d2, &te_x1, &te_y1, te_param);
102         ASSERT_DBL_NEAR_TOL(tr_d1, te_d1, DOUBLE_EPS);
103         ASSERT_DBL_NEAR_TOL(tr_d2, te_d2, DOUBLE_EPS);
104         ASSERT_DBL_NEAR_TOL(tr_x1, te_x1, DOUBLE_EPS);
105         ASSERT_DBL_NEAR_TOL(tr_y1, te_y1, DOUBLE_EPS);
106
107         for(i=0; i<5; i++){
108                 ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS);
109         }
110 }
111
112 CTEST (drotmg,rotmg_issue1452)
113 {
114         double te_d1, tr_d1;
115         double te_d2, tr_d2;
116         double te_x1, tr_x1;
117         double te_y1, tr_y1;
118         double te_param[5];
119         double tr_param[5];
120         int i=0;
121
122         // from issue #1452
123         te_d1 = 5.9e-8;
124         te_d2 = 5.960464e-8;
125         te_x1 = 1.0;
126         te_y1 = 150.0;
127
128         for(i=0; i<5; i++){
129           te_param[i]=tr_param[i]=0.0;
130         }
131         te_param[3]=1./4096.;
132         //reference values as calculated by gonum blas with rotmg rewritten to Hopkins' algorithm
133         tr_d1= 0.99995592822897;
134         tr_d2= 0.98981219860583;
135         tr_x1= 0.03662270484346;
136         tr_y1= 150.000000000000;
137
138         tr_param[0]= -1.0;
139         tr_param[1]= 0.00000161109346;
140         tr_param[2]= -0.00024414062500;
141         tr_param[3]= 0.00024414062500;
142         tr_param[4]= 0.00000162760417;
143
144         //OpenBLAS
145         BLASFUNC(drotmg)(&te_d1, &te_d2, &te_x1, &te_y1, te_param);
146
147         ASSERT_DBL_NEAR_TOL(tr_d1, te_d1, DOUBLE_EPS);
148         ASSERT_DBL_NEAR_TOL(tr_d2, te_d2, DOUBLE_EPS);
149         ASSERT_DBL_NEAR_TOL(tr_x1, te_x1, DOUBLE_EPS);
150         ASSERT_DBL_NEAR_TOL(tr_y1, te_y1, DOUBLE_EPS);
151
152         for(i=0; i<5; i++){
153                 ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS);
154         }
155
156 }
157
158 CTEST(drotmg, rotmg_D1eqD2_X1eqX2)
159 {
160         double te_d1, tr_d1;
161         double te_d2, tr_d2;
162         double te_x1, tr_x1;
163         double te_y1, tr_y1;
164         double te_param[5];
165         double tr_param[5];
166         int i=0;
167         te_d1= tr_d1=2.;
168         te_d2= tr_d2=2.;
169         te_x1= tr_x1=8.;
170         te_y1= tr_y1=8.;
171
172         for(i=0; i<5; i++){
173           te_param[i]=tr_param[i]=0.0;
174         }
175         
176         //reference values as calculated by netlib blas
177         tr_d1= 1.0;
178         tr_d2= 1.0;
179         tr_x1= 16.0;
180         tr_y1= 8.0;
181
182         tr_param[0]=1.0;
183         tr_param[1]=1.0;
184         tr_param[2]=0.0;
185         tr_param[3]=0.0;
186         tr_param[4]=1.0;
187
188         //OpenBLAS
189         BLASFUNC(drotmg)(&te_d1, &te_d2, &te_x1, &te_y1, te_param);
190
191         ASSERT_DBL_NEAR_TOL(tr_d1, te_d1, DOUBLE_EPS);
192         ASSERT_DBL_NEAR_TOL(tr_d2, te_d2, DOUBLE_EPS);
193         ASSERT_DBL_NEAR_TOL(tr_x1, te_x1, DOUBLE_EPS);
194         ASSERT_DBL_NEAR_TOL(tr_y1, te_y1, DOUBLE_EPS);
195
196         for(i=0; i<5; i++){
197                 ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS);
198         }
199 }
200
201 CTEST(drotmg, drotmg_D1_big_D2_big_flag_zero)
202 {
203         double te_d1, tr_d1;
204         double te_d2, tr_d2;
205         double te_x1, tr_x1;
206         double te_y1, tr_y1;
207         double te_param[5]={1.,4096.,-4096.,1.,4096.};
208         double tr_param[5]={-1.,4096.,-3584.,1792.,4096.};
209         int i=0;
210         te_d1= tr_d1=1600000000.;
211         te_d2= tr_d2=800000000.;
212         te_x1= tr_x1=8.;
213         te_y1= tr_y1=7.;
214
215         
216         //reference values as calculated by gonum 
217         tr_d1= 68.96627824858757;
218         tr_d2= 34.483139124293785;
219         tr_x1= 45312.;
220         tr_y1= 7.0;
221
222
223         //OpenBLAS
224         BLASFUNC(drotmg)(&te_d1, &te_d2, &te_x1, &te_y1, te_param);
225
226         ASSERT_DBL_NEAR_TOL(tr_d1, te_d1, DOUBLE_EPS);
227         ASSERT_DBL_NEAR_TOL(tr_d2, te_d2, DOUBLE_EPS);
228         ASSERT_DBL_NEAR_TOL(tr_x1, te_x1, DOUBLE_EPS);
229         ASSERT_DBL_NEAR_TOL(tr_y1, te_y1, DOUBLE_EPS);
230
231         for(i=0; i<5; i++){
232                 ASSERT_DBL_NEAR_TOL(tr_param[i], te_param[i], DOUBLE_EPS);
233         }
234 }
235
236 CTEST(axpy,daxpy_inc_0)
237 {
238         blasint i;
239         blasint N=8,incX=0,incY=0;
240         double a=0.25;
241         double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
242         double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
243
244         double x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
245         double y2[]={4.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
246
247         //OpenBLAS
248         BLASFUNC(daxpy)(&N,&a,x1,&incX,y1,&incY);
249
250         for(i=0; i<N; i++){
251                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], DOUBLE_EPS);
252                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
253         }
254 }
255
256 CTEST(axpy,zaxpy_inc_0)
257 {
258         blasint i;
259         blasint N=4,incX=0,incY=0;
260         double a[2]={0.25,0.5};
261         double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
262         double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
263         double x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
264         double y2[]={-3.0,9.0,6.0,8.0,2.0,4.0,6.0,8.0};
265
266         //OpenBLAS
267         BLASFUNC(zaxpy)(&N,a,x1,&incX,y1,&incY);
268
269         for(i=0; i<2*N; i++){
270                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], DOUBLE_EPS);
271                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
272         }
273 }
274
275 CTEST(axpy,saxpy_inc_0)
276 {
277         blasint i;
278         blasint N=8,incX=0,incY=0;
279         float a=0.25;
280         float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
281         float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
282         float x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
283         float y2[]={4.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
284
285         //OpenBLAS
286         BLASFUNC(saxpy)(&N,&a,x1,&incX,y1,&incY);
287
288         for(i=0; i<N; i++){
289                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], DOUBLE_EPS);
290                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
291         }
292 }
293
294 CTEST(axpy,caxpy_inc_0)
295 {
296         blasint i;
297         blasint N=4,incX=0,incY=0;
298         float a[2]={0.25,0.5};
299         float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
300         float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
301         float x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
302         float y2[]={-3.0,9.0,6.0,8.0,2.0,4.0,6.0,8.0};
303
304         //OpenBLAS
305         BLASFUNC(caxpy)(&N,a,x1,&incX,y1,&incY);
306
307         for(i=0; i<2*N; i++){
308                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], DOUBLE_EPS);
309                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
310         }
311 }
312
313 CTEST( zdotu,zdotu_n_1)
314 {
315         blasint N=1,incX=1,incY=1;
316         double x1[]={1.0,1.0};
317         double y1[]={1.0,2.0};
318         openblas_complex_double result1=openblas_make_complex_double(0.0,0.0);
319         openblas_complex_double result2=openblas_make_complex_double(-1.0,3.0);
320 #ifdef RETURN_BY_STACK
321         BLASFUNC(zdotu)(&result1,&N,x1,&incX,y1,&incY);
322 #else
323         result1=BLASFUNC(zdotu)(&N,x1,&incX,y1,&incY);
324 #endif
325         
326 #ifdef OPENBLAS_COMPLEX_STRUCT
327         ASSERT_DBL_NEAR_TOL(result2.real, result1.real, DOUBLE_EPS);
328         ASSERT_DBL_NEAR_TOL(result2.imag, result1.imag, DOUBLE_EPS);
329 #else
330         ASSERT_DBL_NEAR_TOL(creal(result2), creal(result1), DOUBLE_EPS);
331         ASSERT_DBL_NEAR_TOL(cimag(result2), cimag(result1), DOUBLE_EPS);
332 #endif
333 }
334
335 CTEST(zdotu, zdotu_offset_1)
336 {
337         blasint N=1,incX=1,incY=1;
338         double x1[]={1.0,2.0,3.0,4.0};
339         double y1[]={5.0,6.0,7.0,8.0};
340         openblas_complex_double result1=openblas_make_complex_double(0.0,0.0);
341         openblas_complex_double result2=openblas_make_complex_double(-9.0,32.0);
342 #ifdef RETURN_BY_STACK
343         BLASFUNC(zdotu)(&result1,&N,x1+1,&incX,y1+1,&incY);
344 #else
345         result1=BLASFUNC(zdotu)(&N,x1+1,&incX,y1+1,&incY);
346 #endif
347         
348 #ifdef OPENBLAS_COMPLEX_STRUCT
349         ASSERT_DBL_NEAR_TOL(result2.real, result1.real, DOUBLE_EPS);
350         ASSERT_DBL_NEAR_TOL(result2.imag, result1.imag, DOUBLE_EPS);
351 #else
352         ASSERT_DBL_NEAR_TOL(creal(result2), creal(result1), DOUBLE_EPS);
353         ASSERT_DBL_NEAR_TOL(cimag(result2), cimag(result1), DOUBLE_EPS);
354 #endif
355 }
356
357 CTEST(dsdot,dsdot_n_1)
358 {
359         float x= 0.172555164F;
360         float y= -0.0138700781F;
361         blasint incx=1;
362         blasint incy=1;
363         blasint n=1;
364
365         double res1=0.0f, res2=-0.00239335360107;
366
367         res1=BLASFUNC(dsdot)(&n, &x, &incx, &y, &incy);
368         ASSERT_DBL_NEAR_TOL(res2, res1, DOUBLE_EPS);
369
370 }
371
372 #if defined(BUILD_DOUBLE)
373 CTEST(dnrm2,dnrm2_inf)
374 {
375 #ifndef INFINITY
376 #define INFINITY HUGE_VAL
377 #endif
378         int i;
379         double x[29];
380         blasint incx=1;
381         blasint n=28;
382         double res1=0.0f, res2=INFINITY;
383
384         for (i=0;i<n;i++)x[i]=0.0f;
385         x[10]=-INFINITY;
386         res1=BLASFUNC(dnrm2)(&n, x, &incx);
387         ASSERT_DBL_NEAR_TOL(res2, res1, DOUBLE_EPS);
388
389 }
390 CTEST(dnrm2,dnrm2_tiny)
391 {
392         int i;
393         double x[29];
394         blasint incx=1;
395         blasint n=28;
396         double res1=0.0f, res2=0.0f;
397
398         for (i=0;i<n;i++)x[i]=7.457008414e-310;
399         res1=BLASFUNC(dnrm2)(&n, x, &incx);
400         ASSERT_DBL_NEAR_TOL(res2, res1, DOUBLE_EPS);
401 }
402 #endif
403
404 CTEST(rot,drot_inc_0)
405 {
406         blasint i=0;
407         blasint N=4,incX=0,incY=0;
408         double c=0.25,s=0.5;
409         double x1[]={1.0,3.0,5.0,7.0};
410         double y1[]={2.0,4.0,6.0,8.0};
411         double x2[]={-0.21484375000000,3.0,5.0,7.0};
412         double y2[]={ 0.03906250000000,4.0,6.0,8.0};
413
414
415         //OpenBLAS
416         BLASFUNC(drot)(&N,x1,&incX,y1,&incY,&c,&s);
417
418         for(i=0; i<N; i++){
419                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], DOUBLE_EPS);
420                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
421         }
422 }
423
424 CTEST(rot,zdrot_inc_0)
425 {
426         blasint i=0;
427         blasint N=4,incX=0,incY=0;
428         double c=0.25,s=0.5;
429         double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
430         double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
431         double x2[]={-0.21484375000000,-0.45703125000000 ,5.0,7.0,1.0,3.0,5.0,7.0};
432         double y2[]={ 0.03906250000000, 0.17187500000000 ,6.0,8.0,2.0,4.0,6.0,8.0};
433         
434
435         //OpenBLAS
436         BLASFUNC(zdrot)(&N,x1,&incX,y1,&incY,&c,&s);
437
438         for(i=0; i<2*N; i++){
439                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], DOUBLE_EPS);
440                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
441         }
442 }
443
444 CTEST(rot,srot_inc_0)
445 {
446         blasint i=0;
447         blasint N=4,incX=0,incY=0;
448         float c=0.25,s=0.5;
449         float x1[]={1.0,3.0,5.0,7.0};
450         float y1[]={2.0,4.0,6.0,8.0};
451         float x2[]={-0.21484375000000,3.0,5.0,7.0};
452         float y2[]={ 0.03906250000000,4.0,6.0,8.0};
453
454         //OpenBLAS
455         BLASFUNC(srot)(&N,x1,&incX,y1,&incY,&c,&s);
456
457         for(i=0; i<N; i++){
458                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], SINGLE_EPS);
459                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
460         }
461 }
462
463 CTEST(rot, csrot_inc_0)
464 {
465         blasint i=0;
466         blasint N=4,incX=0,incY=0;
467         float c=0.25,s=0.5;
468         float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
469         float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
470         float x2[]={-0.21484375000000,-0.45703125000000 ,5.0,7.0,1.0,3.0,5.0,7.0};
471         float y2[]={ 0.03906250000000, 0.17187500000000 ,6.0,8.0,2.0,4.0,6.0,8.0};
472         
473         //OpenBLAS
474         BLASFUNC(csrot)(&N,x1,&incX,y1,&incY,&c,&s);
475
476         for(i=0; i<2*N; i++){
477                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], SINGLE_EPS);
478                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
479         }
480 }
481
482 CTEST(swap,dswap_inc_0)
483 {
484         blasint i=0;
485         blasint N=4,incX=0,incY=0;
486         double x1[]={1.0,3.0,5.0,7.0};
487         double y1[]={2.0,4.0,6.0,8.0};
488         double x2[]={1.0,3.0,5.0,7.0};
489         double y2[]={2.0,4.0,6.0,8.0};
490         
491         //OpenBLAS
492         BLASFUNC(dswap)(&N,x1,&incX,y1,&incY);
493
494         for(i=0; i<N; i++){
495                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], DOUBLE_EPS);
496                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
497         }
498 }
499
500 CTEST(swap,zswap_inc_0)
501 {
502         blasint i=0;
503         blasint N=4,incX=0,incY=0;
504         double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
505         double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
506         double x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
507         double y2[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
508
509         //OpenBLAS
510         BLASFUNC(zswap)(&N,x1,&incX,y1,&incY);
511
512         for(i=0; i<2*N; i++){
513                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], DOUBLE_EPS);
514                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
515         }
516 }
517
518 CTEST(swap,sswap_inc_0)
519 {
520         blasint i=0;
521         blasint N=4,incX=0,incY=0;
522         float x1[]={1.0,3.0,5.0,7.0};
523         float y1[]={2.0,4.0,6.0,8.0};
524         float x2[]={1.0,3.0,5.0,7.0};
525         float y2[]={2.0,4.0,6.0,8.0};
526
527         //OpenBLAS
528         BLASFUNC(sswap)(&N,x1,&incX,y1,&incY);
529
530         for(i=0; i<N; i++){
531                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], SINGLE_EPS);
532                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
533         }
534 }
535
536 CTEST(swap,cswap_inc_0)
537 {
538         blasint i=0;
539         blasint N=4,incX=0,incY=0;
540         float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
541         float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
542         float x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
543         float y2[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
544
545         //OpenBLAS
546         BLASFUNC(cswap)(&N,x1,&incX,y1,&incY);
547
548         for(i=0; i<2*N; i++){
549                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], SINGLE_EPS);
550                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
551         }
552 }
553
554 CTEST(min, smin_negative){
555   blasint N=3, inc=1;
556   float te_min=0.0, tr_min=0.0;
557   float x[]={-1.1, -2.2, -3.3};
558
559   te_min=BLASFUNC(smin)(&N, x, &inc);
560   tr_min=-3.3;
561
562   ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), SINGLE_EPS);
563 }
564
565 CTEST(min, dmin_positive){
566   blasint N=3, inc=1;
567   double te_min=0.0, tr_min=0.0;
568   double x[]={1.1, 0.0, 3.3};
569
570   te_min=BLASFUNC(dmin)(&N, x, &inc);
571   tr_min=0.0;
572
573   ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), DOUBLE_EPS);
574 }
575
576 CTEST(min, smin_zero){
577   blasint N=3, inc=1;
578   float te_min=0.0, tr_min=0.0;
579   float x[]={1.1, 2.2, 0.0};
580
581   te_min=BLASFUNC(smin)(&N, x, &inc);
582   tr_min=0.0;
583
584   ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), SINGLE_EPS);
585 }
586
587 CTEST(max, smax_negative){
588   blasint N=3, inc=1;
589   float te_max=0.0, tr_max=0.0;
590   float x[]={-1.1, -2.2, -3.3};
591
592   te_max=BLASFUNC(smax)(&N, x, &inc);
593   tr_max=-1.1;
594
595   ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS);
596 }
597
598 CTEST(max, dmax_positive){
599   blasint N=3, inc=1;
600   double te_max=0.0, tr_max=0.0;
601   double x[]={1.1, 0.0, 3.3};
602
603   te_max=BLASFUNC(dmax)(&N, x, &inc);
604   tr_max=3.3;
605
606   ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), DOUBLE_EPS);
607 }
608
609 CTEST(max, smax_zero){
610   blasint N=3, inc=1;
611   float te_max=0.0, tr_max=0.0;
612   float x[]={-1.1, -2.2, 0.0};
613
614   te_max=BLASFUNC(smax)(&N, x, &inc);
615   tr_max=0.0;
616
617   ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS);
618 }
619
620 int main(int argc, const char ** argv){
621
622   CTEST_ADD (amax, samax);
623   CTEST_ADD (amax, damax);
624   CTEST_ADD (min, smin_negative); 
625   CTEST_ADD (min, dmin_positive); 
626   CTEST_ADD (min, smin_zero); 
627   CTEST_ADD (max, smax_negative); 
628   CTEST_ADD (max, dmax_positive); 
629   CTEST_ADD (max, smax_zero); 
630   CTEST_ADD (drotmg,rotmg);
631   CTEST_ADD (drotmg,rotmg_issue1452);
632   CTEST_ADD (drotmg,rotmg_D1eqD2_X1eqX2);
633   CTEST_ADD (drotmg,drotmg_D1_big_D2_big_flag_zero);
634   CTEST_ADD (axpy,daxpy_inc_0);
635   CTEST_ADD (axpy,zaxpy_inc_0);
636   CTEST_ADD (axpy,saxpy_inc_0);
637   CTEST_ADD (axpy,caxpy_inc_0);
638   CTEST_ADD (zdotu,zdotu_n_1);
639   CTEST_ADD (zdotu,zdotu_offset_1);
640   CTEST_ADD (dsdot,dsdot_n_1);
641   CTEST_ADD (dnrm2,dnrm2_inf);
642   CTEST_ADD (dnrm2,dnrm2_tiny);
643   CTEST_ADD (rot,drot_inc_0);
644   CTEST_ADD (rot,zdrot_inc_0);
645   CTEST_ADD (rot,srot_inc_0);
646   CTEST_ADD (rot,csrot_inc_0);
647   CTEST_ADD (swap,dswap_inc_0);
648   CTEST_ADD (swap,zswap_inc_0);
649   CTEST_ADD (swap,sswap_inc_0);
650   CTEST_ADD (swap,cswap_inc_0);
651
652   int num_fail=0;
653
654   num_fail=ctest_main(argc, argv);
655
656   return num_fail;
657 }