Skip to content

Commit 40a27c6

Browse files
committed
chore: apply suggestions from review
--- 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: passed - 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 669d1be commit 40a27c6

File tree

5 files changed

+25
-22
lines changed

5 files changed

+25
-22
lines changed

lib/node_modules/@stdlib/math/base/special/cosf/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ float out = stdlib_base_cosf( 0.0f );
111111
// returns 1.0f
112112

113113
out = stdlib_base_cosf( 3.141592653589793f / 4.0f );
114-
// returns ~-0.707f
114+
// returns ~0.707f
115115
```
116116

117117
The function accepts the following arguments:

lib/node_modules/@stdlib/math/base/special/cosf/benchmark/c/benchmark.c

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

7676
/**
77-
* Generates a random number on the interval [0,1).
77+
* Generates a random number on the interval [min,max).
7878
*
79-
* @return random number
79+
* @param min minimum value (inclusive)
80+
* @param max maximum value (exclusive)
81+
* @return random number
8082
*/
81-
static float rand_float( void ) {
82-
int r = rand();
83-
return (float)r / ( (float)RAND_MAX + 1.0f );
83+
static float random_uniform( const float min, const float max ) {
84+
float v = (float)rand() / ( (float)RAND_MAX + 1.0f );
85+
return min + ( v*(max-min) );
8486
}
8587

8688
/**
@@ -96,7 +98,7 @@ static double benchmark( void ) {
9698
int i;
9799

98100
for ( i = 0; i < 100; i++ ) {
99-
x[ i ] = ( 20.0f*rand_float() ) - 10.0f;
101+
x[ i ] = random_uniform( -10.0f, 10.0f );
100102
}
101103

102104
t = tic();

lib/node_modules/@stdlib/math/base/special/cosf/benchmark/c/cephes/benchmark.c

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

8181
/**
82-
* Generates a random number on the interval [0,1).
82+
* Generates a random number on the interval [min,max).
8383
*
84-
* @return random number
84+
* @param min minimum value (inclusive)
85+
* @param max maximum value (exclusive)
86+
* @return random number
8587
*/
86-
static float rand_float( void ) {
87-
int r = rand();
88-
return (float)r / ( (float)RAND_MAX + 1.0f );
88+
static float random_uniform( const float min, const float max ) {
89+
float v = (float)rand() / ( (float)RAND_MAX + 1.0f );
90+
return min + ( v*(max-min) );
8991
}
9092

9193
/**
@@ -101,7 +103,7 @@ static double benchmark( void ) {
101103
int i;
102104

103105
for ( i = 0; i < 100; i++ ) {
104-
x[ i ] = ( 20.0f*rand_float() ) - 10.0f;
106+
x[ i ] = random_uniform( -10.0f, 10.0f );
105107
}
106108

107109
t = tic();

lib/node_modules/@stdlib/math/base/special/cosf/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 float rand_float( void ) {
83-
int r = rand();
84-
return (float)r / ( (float)RAND_MAX + 1.0f );
84+
static float random_uniform( const float min, const float max ) {
85+
float v = (float)rand() / ( (float)RAND_MAX + 1.0f );
86+
return min + ( v*(max-min) );
8587
}
8688

8789
/**
@@ -97,7 +99,7 @@ static double benchmark( void ) {
9799
int i;
98100

99101
for ( i = 0; i < 100; i++ ) {
100-
x[ i ] = ( 20.0f*rand_float() ) - 10.0f;
102+
x[ i ] = random_uniform( -10.0f, 10.0f );
101103
}
102104

103105
t = tic();

lib/node_modules/@stdlib/math/base/special/cosf/manifest.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"dependencies": [
3939
"@stdlib/math/base/napi/unary",
4040
"@stdlib/number/float32/base/to-word",
41-
"@stdlib/constants/float64/high-word-abs-mask",
4241
"@stdlib/constants/float64/half-pi",
4342
"@stdlib/constants/float32/exponent-mask",
4443
"@stdlib/math/base/special/kernel-cosf",
@@ -58,7 +57,6 @@
5857
"libpath": [],
5958
"dependencies": [
6059
"@stdlib/number/float32/base/to-word",
61-
"@stdlib/constants/float64/high-word-abs-mask",
6260
"@stdlib/constants/float64/half-pi",
6361
"@stdlib/constants/float32/exponent-mask",
6462
"@stdlib/math/base/special/kernel-cosf",
@@ -78,7 +76,6 @@
7876
"libpath": [],
7977
"dependencies": [
8078
"@stdlib/number/float32/base/to-word",
81-
"@stdlib/constants/float64/high-word-abs-mask",
8279
"@stdlib/constants/float64/half-pi",
8380
"@stdlib/constants/float32/exponent-mask",
8481
"@stdlib/math/base/special/kernel-cosf",

0 commit comments

Comments
 (0)