Skip to content

Commit 8b654d1

Browse files
committed
bench: use random_uniform
--- 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: na - task: lint_c_benchmarks status: passed - 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 ---
1 parent dc928f8 commit 8b654d1

File tree

1 file changed

+8
-6
lines changed
  • lib/node_modules/@stdlib/math/base/special/kernel-sincos/benchmark/c/native

1 file changed

+8
-6
lines changed

lib/node_modules/@stdlib/math/base/special/kernel-sincos/benchmark/c/native/benchmark.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ static double tic( void ) {
7575
}
7676

7777
/**
78-
* Generates a random number on the interval [0,1).
78+
* Generates a random number on the interval [min,max).
7979
*
80-
* @return random number
80+
* @param min minimum value (inclusive)
81+
* @param max maximum value (exclusive)
82+
* @return random number
8183
*/
82-
static double rand_double( void ) {
83-
int r = rand();
84-
return (double)r / ( (double)RAND_MAX + 1.0 );
84+
static double random_uniform( const double min, const double max ) {
85+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
86+
return min + ( v*(max-min) );
8587
}
8688

8789
/**
@@ -98,7 +100,7 @@ static double benchmark( void ) {
98100
int i;
99101

100102
for ( i = 0; i < 100; i++ ) {
101-
x[ i ] = ( ( rand_double()*2.0 ) - 1.0 ) * 0.7853981633974483;
103+
x[ i ] = random_uniform( -0.7853981633974483, 0.7853981633974483 );
102104
}
103105

104106
t = tic();

0 commit comments

Comments
 (0)