Skip to content

Commit 216b78f

Browse files
committed
fix: code 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: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: passed - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 8f8f7ae commit 216b78f

File tree

26 files changed

+76
-330
lines changed

26 files changed

+76
-330
lines changed

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

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,18 @@ limitations under the License.
2020

2121
# gammasgnf
2222

23-
> Sign of the [gamma function][@stdlib/math/base/special/gamma] for a single precision-floating point number.
23+
> Sign of the [gamma function][@stdlib/math/base/special/gamma] for a single-precision floating-point number.
2424
2525
<section class="intro">
2626

2727
The sign of the [gamma-function][@stdlib/math/base/special/gamma] is defined as
2828

29-
<!-- <equation class="equation" label="eq:gamma_sign_function" align="center" raw="\operatorname{gammasgnf} ( x ) = \begin{cases} 1 & \textrm{if}\ \Gamma > 1 \\ -1 & \textrm{if}\ \Gamma < 1 \\ 0 & \textrm{otherwise}\ \end{cases}" alt="Sign of the gamma function"> -->
29+
<!-- <equation class="equation" label="eq:gamma_sign_function" align="center" raw="\operatorname{gammasgn} ( x ) = \begin{cases} 1 & \textrm{if}\ \Gamma > 0 \\ -1 & \textrm{if}\ \Gamma < 0 \\ 0 & \textrm{otherwise}\ \end{cases}" alt="Sign of the gamma function"> -->
3030

3131
```math
32-
\mathop{\mathrm{gammasgnf}} ( x ) = \begin{cases} 1 & \textrm{if}\ \Gamma > 1 \\ -1 & \textrm{if}\ \Gamma < 1 \\ 0 & \textrm{otherwise}\ \end{cases}
32+
\mathop{\mathrm{gammasgn}} ( x ) = \begin{cases} 1 & \textrm{if}\ \Gamma > 0 \\ -1 & \textrm{if}\ \Gamma < 0 \\ 0 & \textrm{otherwise}\ \end{cases}
3333
```
3434

35-
<!-- <div class="equation" align="center" data-raw-text="\operatorname{gammasgnf} ( x ) = \begin{cases} 1 &amp; \textrm{if}\ \Gamma &gt; 1 \\ -1 &amp; \textrm{if}\ \Gamma &lt; 1 \\ 0 &amp; \textrm{otherwise}\ \end{cases}" data-equation="eq:gamma_sign_function">
36-
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@50b141156b147529227e2eb4247eda81c781dec9/lib/node_modules/@stdlib/math/base/special/gammasgnf/docs/img/equation_gamma_sign_function.svg" alt="Sign of the gamma function">
37-
<br>
38-
</div> -->
39-
4035
<!-- </equation> -->
4136

4237
The [gamma function][@stdlib/math/base/special/gamma] can be computed as the product of `gammasgn(x)` and `exp(gammaln(x))`.
@@ -55,7 +50,7 @@ var gammasgnf = require( '@stdlib/math/base/special/gammasgnf' );
5550

5651
#### gammasgnf( x )
5752

58-
Returns the sign of the [gamma function][@stdlib/math/base/special/gamma] for a single precision-floating point number.
53+
Computes the sign of the [gamma function][@stdlib/math/base/special/gamma] for a single-precision floating-point number.
5954

6055
```javascript
6156
var v = gammasgnf( 1.0 );
@@ -92,17 +87,15 @@ v = gammasgnf( NaN );
9287
<!-- eslint no-undef: "error" -->
9388

9489
```javascript
95-
var linspace = require( '@stdlib/array/base/linspace' );
90+
var logEachMap = require( '@stdlib/console/log-each-map' );
91+
var uniform = require( '@stdlib/random/array/uniform' );
9692
var gammasgnf = require( '@stdlib/math/base/special/gammasgnf' );
9793

98-
var x = linspace( -10.0, 10.0, 100, {
94+
var x = uniform( 100, -10.0, 10.0, {
9995
'dtype': 'float32'
10096
});
10197

102-
var i;
103-
for ( i = 0; i < x.length; i++ ) {
104-
console.log( 'x: %d, f(x): %f', x[ i ], gammasgnf( x[ i ] ) );
105-
}
98+
logEachMap( 'x: %0.4f, f(x): %0.4f', x, gammasgnf );
10699
```
107100

108101
</section>
@@ -137,13 +130,13 @@ for ( i = 0; i < x.length; i++ ) {
137130

138131
#### stdlib_base_gammasgnf( x )
139132

140-
Returns the sign of the [gamma-function][@stdlib/math/base/special/gamma] for a single precision-floating point number.
133+
Computes the sign of the [gamma function][@stdlib/math/base/special/gamma] for a single-precision floating-point number.
141134

142135
```c
143-
float out = stdlib_base_gammasgnf( 1.0 );
136+
float out = stdlib_base_gammasgnf( 1.0f );
144137
// returns 1.0f
145138

146-
out = stdlib_base_gammasgnf( -2.5 );
139+
out = stdlib_base_gammasgnf( -2.5f );
147140
// returns -1.0f
148141
```
149142

@@ -186,7 +179,7 @@ int main( void ) {
186179
for ( i = 0; i < 100; i++ ) {
187180
x = ( (float)rand() / (float)RAND_MAX ) * 100.0f;
188181
v = stdlib_base_gammasgnf( x );
189-
printf( "gammasgnf%f = %f\n", x, v );
182+
printf( "gammasgnf(%f) = %f\n", x, v );
190183
}
191184
}
192185
```

lib/node_modules/@stdlib/math/base/special/gammasgnf/benchmark/benchmark.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,17 @@ var gammasgnf = require( './../lib' );
3030
// MAIN //
3131

3232
bench( pkg, function benchmark( b ) {
33-
var len;
3433
var x;
3534
var y;
3635
var i;
3736

38-
len = 100;
39-
x = uniform( len, 0, 171, {
37+
x = uniform( 100, -10.0, 10.0, {
4038
'dtype': 'float32'
4139
});
4240

4341
b.tic();
4442
for ( i = 0; i < b.iterations; i++ ) {
45-
y = gammasgnf( x[ i % len ] );
43+
y = gammasgnf( x[ i%x.length ] );
4644
if ( isnanf( y ) ) {
4745
b.fail( 'should not return NaN' );
4846
}

lib/node_modules/@stdlib/math/base/special/gammasgnf/benchmark/benchmark.native.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,17 @@ var opts = {
3939
// MAIN //
4040

4141
bench( pkg+'::native', opts, function benchmark( b ) {
42-
var len;
4342
var x;
4443
var y;
4544
var i;
4645

47-
len = 100;
48-
x = uniform( len, 0, 171, {
46+
x = uniform( 100, -10.0, 10.0, {
4947
'dtype': 'float32'
5048
});
5149

5250
b.tic();
5351
for ( i = 0; i < b.iterations; i++ ) {
54-
y = gammasgnf( x[ i % len ] );
52+
y = gammasgnf( x[ i%x.length ] );
5553
if ( isnanf( y ) ) {
5654
b.fail( 'should not return NaN' );
5755
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ static double benchmark( void ) {
9797
int i;
9898

9999
for ( i = 0; i < 100; i++ ) {
100-
x[ i ] = ( 171.0f * rand_float() ) - 0.0f;
100+
x[ i ] = ( 100.0f * rand_float() ) - 50.0f;
101101
}
102102

103103
t = tic();
104104
for ( i = 0; i < ITERATIONS; i++ ) {
105-
y = stdlib_base_gammasgnf( x[ i % 100 ] );
105+
y = stdlib_base_gammasgnf( x[ i%100 ] );
106106
if ( y != y ) {
107107
printf( "should not return NaN\n" );
108108
break;

lib/node_modules/@stdlib/math/base/special/gammasgnf/benchmark/python/scipy/benchmark.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from __future__ import print_function
2222
import timeit
2323

24-
NAME = "gammasgn"
24+
NAME = "gammasgnf"
2525
REPEATS = 3
2626
ITERATIONS = 1000000
2727

@@ -72,8 +72,8 @@ def print_results(elapsed):
7272

7373
def benchmark():
7474
"""Run the benchmark and print benchmark results."""
75-
setup = "from scipy.special import gammasgn; from random import random;"
76-
stmt = "y = gammasgn(171.0*random() - 0.0)"
75+
setup = "from scipy.special import gammasgn; from random import random; import numpy as np;"
76+
stmt = "y = gammasgn(np.float32(100.0*random()))"
7777

7878
t = timeit.Timer(stmt, setup=setup)
7979

0 commit comments

Comments
 (0)