Skip to content

Commit c9b7da9

Browse files
committed
c lint error fix
1 parent 1596184 commit c9b7da9

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

lib/node_modules/@stdlib/strided/base/zmap/benchmark/c/benchmark.length.c

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -106,29 +106,33 @@ static double complex identity( const double complex x ) {
106106
* @return elapsed time in seconds
107107
*/
108108
static double benchmark( int iterations, int len ) {
109-
double complex x[ len ];
110-
double complex y[ len ];
111-
double elapsed;
112-
double t;
113-
int i;
109+
double complex x[ len ];
110+
double complex y[ len ];
111+
double elapsed;
112+
double t;
113+
int i;
114114

115-
for ( i = 0; i < len; i++ ) {
116-
x[ i ] = ( ( rand_double()*200.0 ) - 100.0 ) + ( ( rand_double()*200.0 ) - 100.0 )*I;
117-
y[ i ] = 0.0 + 0.0*I;
118-
}
119-
t = tic();
120-
for ( i = 0; i < iterations; i++ ) {
121-
stdlib_strided_zmap( len, x, 1, y, 1, identity );
122-
if ( y[ i%len ] != y[ i%len ] ) {
123-
printf( "should not return NaN\n" );
124-
break;
125-
}
126-
}
127-
elapsed = tic() - t;
128-
if ( y[ i%len ] != y[ i%len ] ) {
129-
printf( "should not return NaN\n" );
130-
}
131-
return elapsed;
115+
for ( i = 0; i < len; i++ ) {
116+
x[ i ] = ( ( rand_double()*200.0 ) - 100.0 ) + ( ( rand_double()*200.0 ) - 100.0 )*I;
117+
y[ i ] = 0.0 + 0.0*I;
118+
}
119+
120+
t = tic();
121+
for ( i = 0; i < iterations; i++ ) {
122+
stdlib_strided_zmap( len, x, 1, y, 1, identity );
123+
124+
// Use a stable index for the check to avoid any "out of bounds" linter noise
125+
if ( y[ 0 ] != y[ 0 ] ) {
126+
printf( "should not return NaN\n" );
127+
break;
128+
}
129+
}
130+
elapsed = tic() - t;
131+
132+
if ( y[ 0 ] != y[ 0 ] ) {
133+
printf( "should not return NaN\n" );
134+
}
135+
return elapsed;
132136
}
133137

134138
/**

0 commit comments

Comments
 (0)