@@ -48,7 +48,7 @@ int CNAME(int mode, blas_arg_t *arg, BLASLONG *range_m, BLASLONG *range_n, int (
48
48
49
49
BLASLONG width , i ;
50
50
BLASLONG n_from , n_to ;
51
- double dnum , nf , nt , di ;
51
+ double dnum , nf , nt , di , dinum ;
52
52
53
53
int num_cpu ;
54
54
int mask = 0 ;
@@ -109,7 +109,11 @@ int CNAME(int mode, blas_arg_t *arg, BLASLONG *range_m, BLASLONG *range_n, int (
109
109
if (nthreads - num_cpu > 1 ) {
110
110
111
111
di = (double )i ;
112
- width = (BLASLONG )(( sqrt (di * di + dnum ) - di + mask )/(mask + 1 )) * (mask + 1 );
112
+ dinum = di * di + dnum ;
113
+ if (dinum < 0 )
114
+ width = (BLASLONG )(( - di + mask )/(mask + 1 )) * (mask + 1 );
115
+ else
116
+ width = (BLASLONG )(( sqrt (dinum ) - di + mask )/(mask + 1 )) * (mask + 1 );
113
117
114
118
if ((width <= 0 ) || (width > n_to - i )) width = n_to - i ;
115
119
@@ -136,9 +140,7 @@ int CNAME(int mode, blas_arg_t *arg, BLASLONG *range_m, BLASLONG *range_n, int (
136
140
137
141
nf = (double )(arg -> n - n_from );
138
142
nt = (double )(arg -> n - n_to );
139
-
140
143
dnum = (nt * nt - nf * nf ) / (double )nthreads ;
141
-
142
144
num_cpu = 0 ;
143
145
144
146
range [0 ] = n_from ;
@@ -149,8 +151,11 @@ int CNAME(int mode, blas_arg_t *arg, BLASLONG *range_m, BLASLONG *range_n, int (
149
151
if (nthreads - num_cpu > 1 ) {
150
152
151
153
di = (double )(arg -> n - i );
152
- width = ((BLASLONG )((- sqrt (di * di + dnum ) + di ) + mask )/(mask + 1 )) * (mask + 1 );
153
-
154
+ dinum = di * di + dnum ;
155
+ if (dinum < 0 )
156
+ width = ((BLASLONG )(di + mask )/(mask + 1 )) * (mask + 1 );
157
+ else
158
+ width = ((BLASLONG )((- sqrt (dinum ) + di ) + mask )/(mask + 1 )) * (mask + 1 );
154
159
if ((width <= 0 ) || (width > n_to - i )) width = n_to - i ;
155
160
156
161
} else {
0 commit comments