Skip to content

Commit 0fd5448

Browse files
authored
Handle INCX=0
1 parent 1b85b6a commit 0fd5448

File tree

1 file changed

+69
-1
lines changed

1 file changed

+69
-1
lines changed

interface/nrm2.c

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,37 @@ FLOATRET NAME(blasint *N, FLOAT *x, blasint *INCX){
6161
#else
6262
return fabsf(x[0]);
6363
#endif
64+
#endif
65+
66+
if (incx == 0)
67+
#ifndef COMPLEX
68+
#ifdef DOUBLE
69+
return (sqrt((double)n)*fabs(x[0]));
70+
#else
71+
return (sqrt((float)n)*fabsf(x[0]));
72+
#endif
73+
#else
74+
#ifdef DOUBLE
75+
{
76+
double fr=fabs(x[0]);
77+
double fi=fabs(x[1]);
78+
double fmin=MIN(fr,fi);
79+
double fmax=MAX(fr,fi);
80+
if (fmax==0.) return(fmax);
81+
if (fmax==fmin) return(sqrt((double)n)*sqrt(2.)*fmax);
82+
return (sqrt((double)n) * fmax * sqrt (1. + (fmin/fmax)*(fmin/fmax)));
83+
}
84+
#else
85+
{
86+
float fr=fabs(x[0]);
87+
float fi=fabs(x[1]);
88+
float fmin=MIN(fr,fi);
89+
float fmax=MAX(fr,fi);
90+
if (fmax==0.) return(fmax);
91+
if (fmax==fmin) return(sqrt((float)n)*sqrt(2.)*fmax);
92+
return (sqrt((float)n) * fmax * sqrt (1. + (fmin/fmax)*(fmin/fmax)));
93+
}
94+
#endif
6495
#endif
6596

6697
if (incx < 0)
@@ -97,13 +128,50 @@ FLOAT CNAME(blasint n, FLOAT *x, blasint incx){
97128

98129
if (n <= 0) return 0.;
99130

100-
#ifndef COMPLEX
101131
if (n == 1)
132+
#ifndef COMPLEX
102133
#ifdef DOUBLE
103134
return fabs(x[0]);
104135
#else
105136
return fabsf(x[0]);
106137
#endif
138+
#else
139+
#ifdef DOUBLE
140+
return fabs(x[0]+fabs(x[1]));
141+
#else
142+
return fabsf(x[0]+fabsf(x[1]));
143+
#endif
144+
#endif
145+
146+
if (incx == 0)
147+
#ifndef COMPLEX
148+
#ifdef DOUBLE
149+
return (sqrt((double)n)*fabs(x[0]));
150+
#else
151+
return (sqrt((float)n)*fabsf(x[0]));
152+
#endif
153+
#else
154+
#ifdef DOUBLE
155+
{
156+
double fr=fabs(x[0]);
157+
double fi=fabs(x[1]);
158+
double fmin=MIN(fr,fi);
159+
double fmax=MAX(fr,fi);
160+
if (fmax==0.) return(fmax);
161+
if (fmax==fmin) return(sqrt((double)n)*sqrt(2.)*fmax);
162+
return (sqrt((double)n) * fmax * sqrt (1. + (fmin/fmax)*(fmin/fmax)));
163+
}
164+
#else
165+
{
166+
float fr=fabs(x[0]);
167+
float fi=fabs(x[1]);
168+
float fmin=MIN(fr,fi);
169+
float fmax=MAX(fr,fi);
170+
if (fmax==0.) return(fmax);
171+
if (fmax==fmin) return(sqrt((float)n)*sqrt(2.)*fmax);
172+
return (sqrt((float)n) * fmax * sqrt (1. + (fmin/fmax)*(fmin/fmax)));
173+
}
174+
#endif
107175
#endif
108176

109177
if (incx < 0)

0 commit comments

Comments
 (0)