Skip to content

Commit 519ea6e

Browse files
committed
utest: Add utest for the {sc/dz}amax and {s/d/sc/dz}amin
1 parent 276e3eb commit 519ea6e

File tree

4 files changed

+123
-5
lines changed

4 files changed

+123
-5
lines changed

utest/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ else ()
1616
test_dnrm2.c
1717
test_swap.c
1818
test_zscal.c
19+
test_amin.c
1920
)
2021
endif ()
2122

utest/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ UTESTBIN=openblas_utest
1111

1212
include $(TOPDIR)/Makefile.system
1313

14-
OBJS=utest_main.o test_min.o test_amax.o test_ismin.o test_rotmg.o test_axpy.o test_dotu.o test_dsdot.o test_swap.o test_rot.o test_dnrm2.o test_zscal.o
14+
OBJS=utest_main.o test_min.o test_amax.o test_ismin.o test_rotmg.o test_axpy.o test_dotu.o test_dsdot.o test_swap.o test_rot.o test_dnrm2.o test_zscal.o \
15+
test_amin.o
1516
#test_rot.o test_swap.o test_axpy.o test_dotu.o test_dsdot.o test_fork.o
1617

1718
ifneq ($(NO_LAPACK), 1)

utest/test_amax.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*****************************************************************************
2-
Copyright (c) 2011-2016, The OpenBLAS Project
2+
Copyright (c) 2011-2024, The OpenBLAS Project
33
All rights reserved.
44
55
Redistribution and use in source and binary forms, with or without
@@ -13,9 +13,9 @@ modification, are permitted provided that the following conditions are
1313
notice, this list of conditions and the following disclaimer in
1414
the documentation and/or other materials provided with the
1515
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
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
1919
permission.
2020
2121
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
@@ -57,4 +57,31 @@ CTEST(amax, damax){
5757
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), DOUBLE_EPS);
5858
}
5959
#endif
60+
#ifdef BUILD_COMPLEX
61+
CTEST(amax, scamax){
62+
blasint N = 9, inc = 1;
63+
float te_max = 0.0, tr_max = 0.0;
64+
float x[] = { -1.1, 2.2, -3.3, 4.4, -5.5, 6.6, -7.7, 8.8,
65+
-9.9, 10.10, -1.1, 2.2, -3.3, 4.4, -5.5, 6.6,
66+
-7.7, 8.8 };
6067

68+
te_max = BLASFUNC(scamax)(&N, x, &inc);
69+
tr_max = 20.0;
70+
71+
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS);
72+
}
73+
#endif
74+
#ifdef BUILD_COMPLEX16
75+
CTEST(amax, dzamax){
76+
blasint N = 9, inc = 1;
77+
double te_max = 0.0, tr_max = 0.0;
78+
double x[] = { -1.1, 2.2, -3.3, 4.4, -5.5, 6.6, -7.7, 8.8,
79+
-9.9, 10.10, -1.1, 2.2, -3.3, 4.4, -5.5, 6.6,
80+
-7.7, 8.8 };
81+
82+
te_max = BLASFUNC(dzamax)(&N, x, &inc);
83+
tr_max = 20.0;
84+
85+
ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), DOUBLE_EPS);
86+
}
87+
#endif

utest/test_amin.c

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*****************************************************************************
2+
Copyright (c) 2011-2024, 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+
#ifdef BUILD_SINGLE
37+
CTEST(amin, samin){
38+
blasint N = 3, inc = 1;
39+
float te_min = 0.0, tr_min = 0.0;
40+
float x[] = { -1.1, 2.2, -3.3, 4.4, -5.5, 6.6, -7.7, 8.8,
41+
-9.9 };
42+
43+
te_min = BLASFUNC(samin)(&N, x, &inc);
44+
tr_min = 1.1;
45+
46+
ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), SINGLE_EPS);
47+
}
48+
#endif
49+
#ifdef BUILD_DOUBLE
50+
CTEST(amin, damin){
51+
blasint N = 3, inc = 1;
52+
double te_min = 0.0, tr_min = 0.0;
53+
double x[] = { -1.1, 2.2, -3.3, 4.4, -5.5, 6.6, -7.7, 8.8,
54+
-9.9 };
55+
56+
te_min = BLASFUNC(damin)(&N, x, &inc);
57+
tr_min = 1.1;
58+
59+
ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), DOUBLE_EPS);
60+
}
61+
#endif
62+
#ifdef BUILD_COMPLEX
63+
CTEST(amin, scamin){
64+
blasint N = 9, inc = 1;
65+
float te_min = 0.0, tr_min = 0.0;
66+
float x[] = { -1.1, 2.2, -3.3, 4.4, -5.5, 6.6, -7.7, 8.8,
67+
-9.9, 10.10, -1.1, 2.2, -3.3, 4.4, -5.5, 6.6,
68+
-7.7, 8.8 };
69+
70+
te_min = BLASFUNC(scamin)(&N, x, &inc);
71+
tr_min = 3.3;
72+
73+
ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), SINGLE_EPS);
74+
}
75+
#endif
76+
#ifdef BUILD_COMPLEX16
77+
CTEST(amin, dzamin){
78+
blasint N = 9, inc = 1;
79+
double te_min = 0.0, tr_min = 0.0;
80+
double x[] = { -1.1, 2.2, -3.3, 4.4, -5.5, 6.6, -7.7, 8.8,
81+
-9.9, 10.10, -1.1, 2.2, -3.3, 4.4, -5.5, 6.6,
82+
-7.7, 8.8 };
83+
84+
te_min = BLASFUNC(dzamin)(&N, x, &inc);
85+
tr_min = 3.3;
86+
87+
ASSERT_DBL_NEAR_TOL((double)(tr_min), (double)(te_min), DOUBLE_EPS);
88+
}
89+
#endif

0 commit comments

Comments
 (0)