Skip to content

Commit c6f30fd

Browse files
check for zero inc
1 parent 5e9ead0 commit c6f30fd

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

interface/max.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646

4747
#ifdef USE_ABS
4848

49+
#if defined(DOUBLE)
50+
#define ABS fabs
51+
#else
52+
#define ABS fabsf
53+
#endif
54+
4955
#ifndef USE_MIN
5056

5157
/* ABS & MAX */
@@ -92,6 +98,8 @@
9298

9399
#else
94100

101+
#define ABS
102+
95103
#ifndef USE_MIN
96104

97105
/* MAX */
@@ -130,6 +138,12 @@ FLOATRET NAME(blasint *N, FLOAT *x, blasint *INCX){
130138

131139
if (n <= 0) return 0;
132140

141+
#ifndef COMPLEX
142+
if (incx == 0) return (ABS(*x));
143+
#else
144+
if (incx == 0) return (ABS(*x) + ABS(*(x+1)));
145+
#endif
146+
133147
IDEBUG_START;
134148

135149
FUNCTION_PROFILE_START();
@@ -158,6 +172,12 @@ FLOAT CNAME(blasint n, FLOAT *x, blasint incx){
158172

159173
if (n <= 0) return 0;
160174

175+
#ifndef COMPLEX
176+
if (incx == 0) return (ABS(*x));
177+
#else
178+
if (incx == 0) return (ABS(*x) + ABS(*(x+1)));
179+
#endif
180+
161181
IDEBUG_START;
162182

163183
FUNCTION_PROFILE_START();

0 commit comments

Comments
 (0)