diff --git a/lib/node_modules/@stdlib/math/base/special/bernoulli/README.md b/lib/node_modules/@stdlib/math/base/special/bernoulli/README.md index d5d27336a71d..de040abc59f8 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoulli/README.md +++ b/lib/node_modules/@stdlib/math/base/special/bernoulli/README.md @@ -154,19 +154,19 @@ for ( i = 0; i < 280; i++ ) { Computes the nth [Bernoulli number][bernoulli-number]. ```c -double out = stdlib_base_bernoulli( 0 ); +double out = stdlib_base_bernoulli( 0.0 ); // returns 1.0 -out = stdlib_base_bernoulli( 1 ); +out = stdlib_base_bernoulli( 1.0 ); // returns 0.5 ``` The function accepts the following arguments: -- **n**: `[in] int32_t` input value. +- **n**: `[in] double` input value. ```c -double stdlib_base_bernoulli( const int32_t n ); +double stdlib_base_bernoulli( const double n ); ``` @@ -190,15 +190,14 @@ double stdlib_base_bernoulli( const int32_t n ); ```c #include "stdlib/math/base/special/bernoulli.h" #include -#include int main( void ) { - int32_t i; + double i; double v; - for ( i = 0; i < 130; i++ ) { + for ( i = 0.0; i < 130.0; i++ ) { v = stdlib_base_bernoulli( i ); - printf( "bernoulli(%d) = %lf\n", i, v ); + printf( "bernoulli(%lf) = %lf\n", i, v ); } } ``` diff --git a/lib/node_modules/@stdlib/math/base/special/bernoulli/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/bernoulli/benchmark/c/native/benchmark.c index 075794f585dc..0795faea4d39 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoulli/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/bernoulli/benchmark/c/native/benchmark.c @@ -102,7 +102,7 @@ static double benchmark( void ) { t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - y = stdlib_base_bernoulli( (int)( x[ i % 100 ] ) ); + y = stdlib_base_bernoulli( ( x[ i % 100 ] ) ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/bernoulli/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/bernoulli/examples/c/example.c index b821857724aa..14ce8acdb19d 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoulli/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/bernoulli/examples/c/example.c @@ -18,14 +18,13 @@ #include "stdlib/math/base/special/bernoulli.h" #include -#include int main( void ) { - int32_t i; + double i; double v; - for ( i = 0; i < 130; i++ ) { + for ( i = 0.0; i < 130.0; i++ ) { v = stdlib_base_bernoulli( i ); - printf( "bernoulli(%d) = %lf\n", i, v ); + printf( "bernoulli(%lf) = %lf\n", i, v ); } } diff --git a/lib/node_modules/@stdlib/math/base/special/bernoulli/include/stdlib/math/base/special/bernoulli.h b/lib/node_modules/@stdlib/math/base/special/bernoulli/include/stdlib/math/base/special/bernoulli.h index 09f82e2d76c8..28c1bd908267 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoulli/include/stdlib/math/base/special/bernoulli.h +++ b/lib/node_modules/@stdlib/math/base/special/bernoulli/include/stdlib/math/base/special/bernoulli.h @@ -19,8 +19,6 @@ #ifndef STDLIB_MATH_BASE_SPECIAL_BERNOULLI_H #define STDLIB_MATH_BASE_SPECIAL_BERNOULLI_H -#include - /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. */ @@ -31,7 +29,7 @@ extern "C" { /** * Computes the nth Bernoulli number. */ -double stdlib_base_bernoulli( const int32_t n ); +double stdlib_base_bernoulli( const double n ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/math/base/special/bernoulli/lib/main.js b/lib/node_modules/@stdlib/math/base/special/bernoulli/lib/main.js index cbcacc455004..0b4b75025e75 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoulli/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/bernoulli/lib/main.js @@ -92,7 +92,7 @@ function bernoulli( n ) { return 0.0; } if ( n > MAX_BERNOULLI ) { - return ( (n/2)&1 ) ? PINF : NINF; + return ( isOdd( n/2.0 ) ) ? PINF : NINF; } return BERNOULLI[ n/2 ]; } diff --git a/lib/node_modules/@stdlib/math/base/special/bernoulli/manifest.json b/lib/node_modules/@stdlib/math/base/special/bernoulli/manifest.json index b63457894ac8..e8352697c730 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoulli/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/bernoulli/manifest.json @@ -39,7 +39,8 @@ "@stdlib/math/base/napi/unary", "@stdlib/math/base/assert/is-odd", "@stdlib/constants/float64/ninf", - "@stdlib/constants/float64/pinf" + "@stdlib/constants/float64/pinf", + "@stdlib/math/base/assert/is-nonnegative-integer" ] }, { @@ -55,7 +56,8 @@ "dependencies": [ "@stdlib/math/base/assert/is-odd", "@stdlib/constants/float64/ninf", - "@stdlib/constants/float64/pinf" + "@stdlib/constants/float64/pinf", + "@stdlib/math/base/assert/is-nonnegative-integer" ] }, { @@ -71,7 +73,8 @@ "dependencies": [ "@stdlib/math/base/assert/is-odd", "@stdlib/constants/float64/ninf", - "@stdlib/constants/float64/pinf" + "@stdlib/constants/float64/pinf", + "@stdlib/math/base/assert/is-nonnegative-integer" ] } ] diff --git a/lib/node_modules/@stdlib/math/base/special/bernoulli/src/addon.c b/lib/node_modules/@stdlib/math/base/special/bernoulli/src/addon.c index adb2808de128..2ee9d8e56b8f 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoulli/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/bernoulli/src/addon.c @@ -19,4 +19,4 @@ #include "stdlib/math/base/special/bernoulli.h" #include "stdlib/math/base/napi/unary.h" -STDLIB_MATH_BASE_NAPI_MODULE_I_D( stdlib_base_bernoulli ) +STDLIB_MATH_BASE_NAPI_MODULE_D_D( stdlib_base_bernoulli ) diff --git a/lib/node_modules/@stdlib/math/base/special/bernoulli/src/main.c b/lib/node_modules/@stdlib/math/base/special/bernoulli/src/main.c index 20ba5b75601f..b1eb3203f5bd 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoulli/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/bernoulli/src/main.c @@ -16,10 +16,13 @@ * limitations under the License. */ +#include "stdlib/math/base/assert/is_nonnegative_integer.h" #include "stdlib/math/base/assert/is_odd.h" #include "stdlib/constants/float64/ninf.h" #include "stdlib/constants/float64/pinf.h" #include "stdlib/math/base/special/bernoulli.h" +#include +#include static const double bernoulli_value[ 130 ] = { 1.00000000000000000000000000000000000000000, @@ -164,21 +167,21 @@ int32_t MAX_BERNOULLI = 258; * @return output value * * @example -* double out = stdlib_base_bernoulli( 0 ); -* // returns 1 +* double out = stdlib_base_bernoulli( 0.0 ); +* // returns 1.0 */ -double stdlib_base_bernoulli( const int32_t n ) { - if ( n < 0 ) { +double stdlib_base_bernoulli( const double n ) { + if ( !stdlib_base_is_nonnegative_integer( n ) ) { return 0.0 / 0.0; // NaN } - if ( n == 1 ) { + if ( n == 1.0 ) { return 0.5; } if ( stdlib_base_is_odd( n ) ) { return 0.0; } if ( n > MAX_BERNOULLI ) { - return ( ( n / 2 ) & 1 ) ? STDLIB_CONSTANT_FLOAT64_PINF : STDLIB_CONSTANT_FLOAT64_NINF; + return ( stdlib_base_is_odd( n/2.0 ) ) ? STDLIB_CONSTANT_FLOAT64_PINF : STDLIB_CONSTANT_FLOAT64_NINF; } - return bernoulli_value[ n / 2 ]; + return bernoulli_value[ (size_t)( n / 2.0 ) ]; }