|
| 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 | + |
| 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 | + |
| 47 | +CTEST(min, dmin_positive){ |
| 48 | + blasint N=3, inc=1; |
| 49 | + double te_min=0.0, tr_min=0.0; |
| 50 | + double x[]={1.1, 0.0, 3.3}; |
| 51 | + |
| 52 | + te_min=BLASFUNC(dmin)(&N, x, &inc); |
| 53 | + tr_min=0.0; |
| 54 | + |
| 55 | + ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), DOUBLE_EPS); |
| 56 | +} |
| 57 | + |
| 58 | +CTEST(min, smin_zero){ |
| 59 | + blasint N=3, inc=1; |
| 60 | + float te_min=0.0, tr_min=0.0; |
| 61 | + float x[]={1.1, 2.2, 0.0}; |
| 62 | + |
| 63 | + te_min=BLASFUNC(smin)(&N, x, &inc); |
| 64 | + tr_min=0.0; |
| 65 | + |
| 66 | + ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), SINGLE_EPS); |
| 67 | +} |
| 68 | + |
| 69 | +CTEST(max, smax_negative){ |
| 70 | + blasint N=3, inc=1; |
| 71 | + float te_max=0.0, tr_max=0.0; |
| 72 | + float x[]={-1.1, -2.2, -3.3}; |
| 73 | + |
| 74 | + te_max=BLASFUNC(smax)(&N, x, &inc); |
| 75 | + tr_max=-1.1; |
| 76 | + |
| 77 | + ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS); |
| 78 | +} |
| 79 | + |
| 80 | +CTEST(max, dmax_positive){ |
| 81 | + blasint N=3, inc=1; |
| 82 | + double te_max=0.0, tr_max=0.0; |
| 83 | + double x[]={1.1, 0.0, 3.3}; |
| 84 | + |
| 85 | + te_max=BLASFUNC(dmax)(&N, x, &inc); |
| 86 | + tr_max=3.3; |
| 87 | + |
| 88 | + ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), DOUBLE_EPS); |
| 89 | +} |
| 90 | + |
| 91 | +CTEST(max, smax_zero){ |
| 92 | + blasint N=3, inc=1; |
| 93 | + float te_max=0.0, tr_max=0.0; |
| 94 | + float x[]={-1.1, -2.2, 0.0}; |
| 95 | + |
| 96 | + te_max=BLASFUNC(smax)(&N, x, &inc); |
| 97 | + tr_max=0.0; |
| 98 | + |
| 99 | + ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS); |
| 100 | +} |
0 commit comments