Upgrade to version 0.3.21
[platform/upstream/openblas.git] / utest / test_min.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 "openblas_utest.h"
35 #ifdef BUILD_SINGLE
36 CTEST(min, smin_negative){
37   blasint N=3, inc=1;
38   float te_min=0.0, tr_min=0.0;
39   float x[]={-1.1, -2.2, -3.3};
40
41   te_min=BLASFUNC(smin)(&N, x, &inc);
42   tr_min=-3.3;
43
44   ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), SINGLE_EPS);
45 }
46 #endif
47
48 #ifdef BUILD_DOUBLE
49 CTEST(min, dmin_positive){
50   blasint N=3, inc=1;
51   double te_min=0.0, tr_min=0.0;
52   double x[]={1.1, 0.0, 3.3};
53
54   te_min=BLASFUNC(dmin)(&N, x, &inc);
55   tr_min=0.0;
56
57   ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), DOUBLE_EPS);
58 }
59 #endif
60
61 #ifdef BUILD_SINGLE
62 CTEST(min, smin_zero){
63   blasint N=3, inc=1;
64   float te_min=0.0, tr_min=0.0;
65   float x[]={1.1, 2.2, 0.0};
66
67   te_min=BLASFUNC(smin)(&N, x, &inc);
68   tr_min=0.0;
69
70   ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), SINGLE_EPS);
71 }
72
73 CTEST(max, smax_negative){
74   blasint N=3, inc=1;
75   float te_max=0.0, tr_max=0.0;
76   float x[]={-1.1, -2.2, -3.3};
77
78   te_max=BLASFUNC(smax)(&N, x, &inc);
79   tr_max=-1.1;
80
81   ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS);
82 }
83 #endif
84
85 #ifdef BUILD_DOUBLE
86 CTEST(max, dmax_positive){
87   blasint N=3, inc=1;
88   double te_max=0.0, tr_max=0.0;
89   double x[]={1.1, 0.0, 3.3};
90
91   te_max=BLASFUNC(dmax)(&N, x, &inc);
92   tr_max=3.3;
93
94   ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), DOUBLE_EPS);
95 }
96 #endif
97 #ifdef BUILD_SINGLE
98 CTEST(max, smax_zero){
99   blasint N=3, inc=1;
100   float te_max=0.0, tr_max=0.0;
101   float x[]={-1.1, -2.2, 0.0};
102
103   te_max=BLASFUNC(smax)(&N, x, &inc);
104   tr_max=0.0;
105
106   ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS);
107 }
108 #endif
109