Skip to content

Commit 1bdb7c8

Browse files
committed
refactor: refactoring benchmark and example
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 5a9f9f8 commit 1bdb7c8

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/c/native/benchmark.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ static double benchmark( void ) {
9393
double elapsed;
9494
float x1[ 100 ];
9595
float x2[ 100 ];
96-
float out[ 2 ];
96+
float min;
97+
float max;
9798
double t;
9899
int i;
99100

@@ -104,14 +105,14 @@ static double benchmark( void ) {
104105

105106
t = tic();
106107
for ( i = 0; i < ITERATIONS; i++ ) {
107-
stdlib_base_minmaxf( x1[ i % 100 ], x2[ i % 100 ], out );
108-
if ( out[ 0 ] != out[ 0 ] || out[ 1 ] != out[ 1 ] ) {
108+
stdlib_base_minmaxf( x1[ i % 100 ], x2[ i % 100 ], &min , &max );
109+
if ( min != min || max != max ) {
109110
printf( "should not return NaN\n" );
110111
break;
111112
}
112113
}
113114
elapsed = tic() - t;
114-
if ( out[ 0 ] != out[ 0 ] || out[ 1 ] != out[ 1 ] ) {
115+
if ( min != min || max != max ) {
115116
printf( "should not return NaN\n" );
116117
}
117118
return elapsed;

lib/node_modules/@stdlib/math/base/special/minmaxf/examples/c/example.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ int main(void) {
2323
const float x1[] = { 1.0, 0.45, -0.89, 0.0 / 0.0, -0.78, -0.22, 0.66, 0.11, -0.55, 0.0 };
2424
const float x2[] = { -0.22, 0.66, 0.0, -0.55, 0.33, 1.0, 0.0 / 0.0, 0.11, 0.45, -0.78 };
2525

26-
float out[ 2 ] = { 0.0, 0.0 };
26+
float min;
27+
float max;
2728
int i;
2829

2930
for ( i = 0; i < 10; i++ ) {
30-
stdlib_base_minmaxf( x1[i], x2[i], out);
31-
printf( "x1[ %d ]: %f, x2[ %d ]: %f, minmaxf( x1[ %d ], x2[ %d ] ): ( %f, %f )\n", i, x1[ i ], i, x2[ i ], i, i, out[ 0 ], out[ 1 ] );
31+
stdlib_base_minmaxf( x1[i], x2[i], &min, &max);
32+
printf( "x1[ %d ]: %f, x2[ %d ]: %f, minmaxf( x1[ %d ], x2[ %d ] ): ( %f, %f )\n", i, x1[ i ], i, x2[ i ], i, i, min, max );
3233
}
3334
}

0 commit comments

Comments
 (0)