|
| 1 | +/***************************************************************************** |
| 2 | +Copyright (c) 2020, 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 | +#define ELEMENTS 50 |
| 37 | +#define INCREMENT 2 |
| 38 | + |
| 39 | +CTEST(ismin, positive_step_2){ |
| 40 | + blasint i; |
| 41 | + blasint N = ELEMENTS, inc = INCREMENT; |
| 42 | + float x[ELEMENTS * INCREMENT]; |
| 43 | + for (i = 0; i < N * inc; i ++) { |
| 44 | + x[i] = i + 1000; |
| 45 | + } |
| 46 | + |
| 47 | + x[8 * inc] = 0; |
| 48 | + blasint index = BLASFUNC(ismin)(&N, x, &inc); |
| 49 | + ASSERT_EQUAL(9, index); |
| 50 | +} |
| 51 | + |
| 52 | +CTEST(ismin, negative_step_2){ |
| 53 | + blasint i; |
| 54 | + blasint N = ELEMENTS, inc = INCREMENT; |
| 55 | + float x[ELEMENTS * INCREMENT]; |
| 56 | + for (i = 0; i < N * inc; i ++) { |
| 57 | + x[i] = - i - 1000; |
| 58 | + } |
| 59 | + |
| 60 | + x[8 * inc] = -123456.0f; |
| 61 | + blasint index = BLASFUNC(ismin)(&N, x, &inc); |
| 62 | + ASSERT_EQUAL(9, index); |
| 63 | +} |
| 64 | + |
| 65 | +CTEST(ismax, positive_step_2){ |
| 66 | + blasint i; |
| 67 | + blasint N = ELEMENTS, inc = INCREMENT; |
| 68 | + float x[ELEMENTS * INCREMENT]; |
| 69 | + for (i = 0; i < N * inc; i ++) { |
| 70 | + x[i] = i + 1000; |
| 71 | + } |
| 72 | + |
| 73 | + x[8 * inc] = 123456.0f; |
| 74 | + blasint index = BLASFUNC(ismax)(&N, x, &inc); |
| 75 | + ASSERT_EQUAL(9, index); |
| 76 | +} |
| 77 | + |
| 78 | +CTEST(ismax, negative_step_2){ |
| 79 | + blasint i; |
| 80 | + blasint N = ELEMENTS, inc = INCREMENT; |
| 81 | + float x[ELEMENTS * INCREMENT]; |
| 82 | + for (i = 0; i < N * inc; i ++) { |
| 83 | + x[i] = - i - 1000; |
| 84 | + } |
| 85 | + |
| 86 | + x[8 * inc] = 0; |
| 87 | + blasint index = BLASFUNC(ismax)(&N, x, &inc); |
| 88 | + ASSERT_EQUAL(9, index); |
| 89 | +} |
0 commit comments