Skip to content

Commit e197e41

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: passed - task: lint_repl_help status: na - 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: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 12053ac commit e197e41

File tree

15 files changed

+109
-113
lines changed

15 files changed

+109
-113
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ var v = bernoullif( NaN );
108108
<!-- eslint no-undef: "error" -->
109109

110110
```javascript
111+
var logEachMap = require( '@stdlib/console/log-each-map' );
112+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
111113
var bernoullif = require( '@stdlib/math/base/special/bernoullif' );
112114

113-
var v;
114-
var i;
115+
var x = discreteUniform( 100, 0, 70, {
116+
'dtype': 'int32'
117+
});
115118

116-
for ( i = 0; i < 70; i++ ) {
117-
v = bernoullif( i );
118-
console.log( v );
119-
}
119+
logEachMap( 'bernoullif(%d) = %0.4f', x, bernoullif );
120120
```
121121

122122
</section>
@@ -155,10 +155,10 @@ Compute the nth [Bernoulli number][bernoulli-number] as a single-precision float
155155

156156
```c
157157
float out = stdlib_base_bernoullif( 0 );
158-
// returns 1.0
158+
// returns 1.0f
159159

160160
out = stdlib_base_bernoullif( 1 );
161-
// returns 0.5
161+
// returns 0.5f
162162
```
163163

164164
The function accepts the following arguments:
@@ -196,7 +196,7 @@ int main( void ) {
196196
int32_t i;
197197
float v;
198198
199-
for ( i = 0; i < 130; i++ ) {
199+
for ( i = 0; i < 70; i++ ) {
200200
v = stdlib_base_bernoullif( i );
201201
printf( "bernoullif(%d) = %f\n", i, v );
202202
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/array/discrete-uniform' );
24+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2525
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2626
var pkg = require( './../package.json' ).name;
2727
var bernoullif = require( './../lib' );
@@ -34,7 +34,7 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

37-
x = randu( 100, 0, 500 );
37+
x = discreteUniform( 100, 0, 100 );
3838

3939
b.tic();
4040
for ( i = 0; i < b.iterations; i++ ) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/array/discrete-uniform' );
25+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2626
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2727
var tryRequire = require( '@stdlib/utils/try-require' );
2828
var pkg = require( './../package.json' ).name;
@@ -43,7 +43,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4343
var y;
4444
var i;
4545

46-
x = randu( 100, 0, 500 );
46+
x = discreteUniform( 100, 0, 100 );
4747

4848
b.tic();
4949
for ( i = 0; i < b.iterations; i++ ) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "stdlib/math/base/special/bernoullif.h"
2020
#include <stdlib.h>
21+
#include <stdint.h>
2122
#include <stdio.h>
2223
#include <math.h>
2324
#include <time.h>
@@ -97,12 +98,12 @@ static double benchmark( void ) {
9798
int i;
9899

99100
for ( i = 0; i < 100; i++ ) {
100-
x[ i ] = ( 500.0 * rand_float() );
101+
x[ i ] = ( 500.0f * rand_float() );
101102
}
102103

103104
t = tic();
104105
for ( i = 0; i < ITERATIONS; i++ ) {
105-
y = stdlib_base_bernoullif( (int)( x[ i % 100 ] ) );
106+
y = stdlib_base_bernoullif( (int32_t)( x[ i%100 ] ) );
106107
if ( y != y ) {
107108
printf( "should not return NaN\n" );
108109
break;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ int main( void ) {
2626

2727
for ( i = 0; i < 70; i++ ) {
2828
v = stdlib_base_bernoullif( i );
29-
printf( "bernoulli(%d) = %f\n", i, v );
29+
printf( "bernoullif(%d) = %f\n", i, v );
3030
}
3131
}

lib/node_modules/@stdlib/math/base/special/bernoullif/examples/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
'use strict';
2020

21+
var logEachMap = require( '@stdlib/console/log-each-map' );
22+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2123
var bernoullif = require( './../lib' );
2224

23-
var v;
24-
var i;
25+
var x = discreteUniform( 100, 0, 70, {
26+
'dtype': 'int32'
27+
});
2528

26-
for ( i = 0; i < 70; i++ ) {
27-
v = bernoullif( i );
28-
console.log( v );
29-
}
29+
logEachMap( 'bernoullif(%d) = %0.4f', x, bernoullif );
Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
[
2-
1.00000000000000000000000000000000000000000,
3-
0.166666666666666666666666666666666666666667,
4-
-0.0333333333333333333333333333333333333333333,
5-
0.0238095238095238095238095238095238095238095,
6-
-0.0333333333333333333333333333333333333333333,
7-
0.0757575757575757575757575757575757575757576,
8-
-0.253113553113553113553113553113553113553114,
9-
1.16666666666666666666666666666666666666667,
10-
-7.09215686274509803921568627450980392156863,
11-
54.9711779448621553884711779448621553884712,
12-
-529.124242424242424242424242424242424242424,
13-
6192.12318840579710144927536231884057971014,
14-
-86580.2531135531135531135531135531135531136,
15-
1.42551716666666666666666666666666666666667e6,
16-
-2.72982310678160919540229885057471264367816e7,
17-
6.01580873900642368384303868174835916771401e8,
18-
-1.51163157670921568627450980392156862745098e10,
19-
4.29614643061166666666666666666666666666667e11,
20-
-1.37116552050883327721590879485616327721591e13,
21-
4.88332318973593166666666666666666666666667e14,
22-
-1.92965793419400681486326681448632668144863e16,
23-
8.41693047573682615000553709856035437430786e17,
24-
-4.03380718540594554130768115942028985507246e19,
25-
2.11507486380819916056014539007092198581560e21,
26-
-1.20866265222965259346027311937082525317819e23,
27-
7.50086674607696436685572007575757575757576e24,
28-
-5.03877810148106891413789303052201257861635e26,
29-
3.65287764848181233351104308429711779448622e28,
30-
-2.84987693024508822262691464329106781609195e30,
31-
2.38654274996836276446459819192192149717514e32,
32-
-2.13999492572253336658107447651910973926742e34,
33-
2.05009757234780975699217330956723102516667e36,
34-
-2.09380059113463784090951852900279701847092e38
2+
1.0,
3+
0.1666666716337204,
4+
-0.03333333507180214,
5+
0.02380952425301075,
6+
-0.03333333507180214,
7+
0.07575757801532745,
8+
-0.2531135678291321,
9+
1.1666666269302368,
10+
-7.092156887054443,
11+
54.97117614746094,
12+
-529.124267578125,
13+
6192.123046875,
14+
-86580.25,
15+
1425517.125,
16+
-27298232.0,
17+
601580864.0,
18+
-15116315648.0,
19+
429614628864.0,
20+
-13711654780928.0,
21+
488332312182784.0,
22+
-19296579391324160.0,
23+
841693056053805000.0,
24+
-40338073359287845000.0,
25+
2.1150748918604188e+21,
26+
-1.2086626472668042e+23,
27+
7.500866956719485e+24,
28+
-5.038777949942763e+26,
29+
3.652877742276384e+28,
30+
-2.849876996904201e+30,
31+
2.386542781638813e+32,
32+
-2.1399950070596233e+34,
33+
2.050097633557977e+36,
34+
-2.0938006042234345e+38
3535
]

lib/node_modules/@stdlib/math/base/special/bernoullif/lib/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// MODULES //
2222

23-
var isNonNegativeInteger = require( '@stdlib/math/base/assert/is-nonnegative-integer' );
23+
var isNonNegativeIntegerf = require( '@stdlib/math/base/assert/is-nonnegative-integerf' );
2424
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
2525
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2626
var isOdd = require( '@stdlib/math/base/assert/is-odd' );
@@ -83,7 +83,7 @@ var MAX_BERNOULLI = 64|0; // asm type annotation
8383
* // returns NaN
8484
*/
8585
function bernoullif( n ) {
86-
if ( isnanf( n ) || !isNonNegativeInteger( n ) ) {
86+
if ( isnanf( n ) || !isNonNegativeIntegerf( n ) ) {
8787
return NaN;
8888
}
8989
if ( n === 1 ) {
@@ -93,9 +93,9 @@ function bernoullif( n ) {
9393
return 0.0;
9494
}
9595
if ( n > MAX_BERNOULLI ) {
96-
return ( ( n / 2 ) & 1 ) ? PINF : NINF;
96+
return ( (n/2)&1 ) ? PINF : NINF;
9797
}
98-
return float64ToFloat32( BERNOULLIF[ n / 2 ] );
98+
return float64ToFloat32( BERNOULLIF[ n/2 ] );
9999
}
100100

101101

lib/node_modules/@stdlib/math/base/special/bernoullif/lib/native.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var addon = require( './../src/addon.node' );
2828
/**
2929
* Computes the nth Bernoulli number as a single-precision floating-point number.
3030
*
31+
* @private
3132
* @param {NonNegativeInteger} n - the Bernoulli number to compute
3233
* @returns {number} Bernoulli number
3334
*

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"libpath": [],
3838
"dependencies": [
3939
"@stdlib/math/base/napi/unary",
40-
"@stdlib/math/base/assert/is-odd",
4140
"@stdlib/constants/float32/ninf",
4241
"@stdlib/constants/float32/pinf"
4342
]
@@ -53,7 +52,6 @@
5352
"libraries": [],
5453
"libpath": [],
5554
"dependencies": [
56-
"@stdlib/math/base/assert/is-odd",
5755
"@stdlib/constants/float32/ninf",
5856
"@stdlib/constants/float32/pinf"
5957
]
@@ -69,7 +67,6 @@
6967
"libraries": [],
7068
"libpath": [],
7169
"dependencies": [
72-
"@stdlib/math/base/assert/is-odd",
7370
"@stdlib/constants/float32/ninf",
7471
"@stdlib/constants/float32/pinf"
7572
]

lib/node_modules/@stdlib/math/base/special/bernoullif/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
"stdmath",
5757
"mathematics",
5858
"math",
59-
"special functions",
6059
"special",
6160
"function",
6261
"bernoulli",

lib/node_modules/@stdlib/math/base/special/bernoullif/src/addon.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@
1919
#include "stdlib/math/base/special/bernoullif.h"
2020
#include "stdlib/math/base/napi/unary.h"
2121

22-
// cppcheck-suppress shadowFunction
2322
STDLIB_MATH_BASE_NAPI_MODULE_I_F( stdlib_base_bernoullif )

lib/node_modules/@stdlib/math/base/special/bernoullif/src/main.c

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,46 @@
1717
*/
1818

1919
#include "stdlib/math/base/special/bernoullif.h"
20-
#include "stdlib/math/base/assert/is_odd.h"
2120
#include "stdlib/constants/float32/ninf.h"
2221
#include "stdlib/constants/float32/pinf.h"
22+
#include <stdint.h>
2323

2424
static const float bernoulli_value[ 33 ] = {
25-
1.0000000000000000f,
26-
0.1666666666666666f,
27-
-0.0333333333333333f,
28-
0.0238095238095238f,
29-
-0.0333333333333333f,
30-
0.0757575757575757f,
31-
-0.2531135531135531f,
32-
1.1666666666666666f,
33-
-7.0921568627450980f,
34-
54.9711779448621553f,
35-
-529.1242424242424242f,
36-
6192.1231884057971014f,
37-
-86580.2531135531135531f,
38-
1.4255171666666666e+6f,
39-
-2.7298231067816091e+7f,
40-
6.0158087390064236e+8f,
41-
-1.5116315767092156e+10f,
42-
4.2961464306116666e+11f,
43-
-1.3711655205088332e+13f,
44-
4.8833231897359316e+14f,
45-
-1.9296579341940068e+16f,
46-
8.4169304757368261e+17f,
47-
-4.0338071854059455e+19f,
48-
2.1150748638081991e+21f,
49-
-1.2086626522296525e+23f,
50-
7.5008667460769643e+24f,
51-
-5.0387781014810689e+26f,
52-
3.6528776484818123e+28f,
53-
-2.8498769302450882e+30f,
54-
2.3865427499683627e+32f,
55-
-2.1399949257225333e+34f,
56-
2.0500975723478097e+36f,
25+
1.0f,
26+
0.1666666716337204f,
27+
-0.03333333507180214f,
28+
0.02380952425301075f,
29+
-0.03333333507180214f,
30+
0.07575757801532745f,
31+
-0.2531135678291321f,
32+
1.1666666269302368f,
33+
-7.092156887054443f,
34+
54.97117614746094f,
35+
-529.124267578125f,
36+
6192.123046875f,
37+
-86580.25f,
38+
1425517.125f,
39+
-27298232.0f,
40+
601580864.0f,
41+
-15116315648.0f,
42+
429614628864.0f,
43+
-13711654780928.0f,
44+
488332312182784.0f,
45+
-19296579391324160.0f,
46+
841693056053805000.0f,
47+
-40338073359287845000.0f,
48+
2.1150748918604188e+21f,
49+
-1.2086626472668042e+23f,
50+
7.500866956719485e+24f,
51+
-5.038777949942763e+26f,
52+
3.652877742276384e+28f,
53+
-2.849876996904201e+30f,
54+
2.386542781638813e+32f,
55+
-2.1399950070596233e+34f,
56+
2.050097633557977e+36f,
5757
-2.0938006042234345e+38f
5858
};
5959

60-
6160
static const int32_t MAX_BERNOULLI = 64;
6261

6362
/**
@@ -68,17 +67,17 @@ static const int32_t MAX_BERNOULLI = 64;
6867
*
6968
* @example
7069
* float out = stdlib_base_bernoullif( 0 );
71-
* // returns 1
70+
* // returns 1.0f
7271
*/
7372
float stdlib_base_bernoullif( const int32_t n ) {
7473
if ( n < 0 ) {
75-
return 0.0 / 0.0; // NaN
74+
return 0.0f / 0.0f; // NaN
7675
}
7776
if ( n == 1 ) {
78-
return 0.5;
77+
return 0.5f;
7978
}
80-
if ( stdlib_base_is_odd( n ) ) {
81-
return 0.0;
79+
if ( n & 1 ) {
80+
return 0.0f;
8281
}
8382
if ( n > MAX_BERNOULLI ) {
8483
return ( ( n / 2 ) & 1 ) ? STDLIB_CONSTANT_FLOAT32_PINF : STDLIB_CONSTANT_FLOAT32_NINF;

0 commit comments

Comments
 (0)