diff --git a/lib/node_modules/@stdlib/math/base/special/bernoullif/README.md b/lib/node_modules/@stdlib/math/base/special/bernoullif/README.md index 4791711ef06f..6528deb8470d 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoullif/README.md +++ b/lib/node_modules/@stdlib/math/base/special/bernoullif/README.md @@ -156,19 +156,19 @@ logEachMap( 'bernoullif(%d) = %0.4f', x, bernoullif ); Computes the nth [Bernoulli number][bernoulli-number] as a single-precision floating-point number. ```c -float out = stdlib_base_bernoullif( 0 ); +float out = stdlib_base_bernoullif( 0.0f ); // returns 1.0f -out = stdlib_base_bernoullif( 1 ); +out = stdlib_base_bernoullif( 1.0f ); // returns 0.5f ``` The function accepts the following arguments: -- **n**: `[in] int32_t` input value. +- **n**: `[in] float` input value. ```c -float stdlib_base_bernoullif( const int32_t n ); +float stdlib_base_bernoullif( const float n ); ``` @@ -192,15 +192,14 @@ float stdlib_base_bernoullif( const int32_t n ); ```c #include "stdlib/math/base/special/bernoullif.h" #include -#include int main( void ) { - int32_t i; + float i; float v; - for ( i = 0; i < 70; i++ ) { + for ( i = 0.0f; i < 70.0f; i++ ) { v = stdlib_base_bernoullif( i ); - printf( "bernoullif(%d) = %f\n", i, v ); + printf( "bernoullif(%f) = %f\n", i, v ); } } ``` diff --git a/lib/node_modules/@stdlib/math/base/special/bernoullif/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/bernoullif/benchmark/c/native/benchmark.c index ccc644bc354d..d7ae6982d331 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoullif/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/bernoullif/benchmark/c/native/benchmark.c @@ -18,7 +18,6 @@ #include "stdlib/math/base/special/bernoullif.h" #include -#include #include #include #include @@ -103,7 +102,7 @@ static double benchmark( void ) { t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - y = stdlib_base_bernoullif( (int32_t)( x[ i%100 ] ) ); + y = stdlib_base_bernoullif( ( x[ i%100 ] ) ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/bernoullif/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/bernoullif/examples/c/example.c index dd088db88bce..2f7c1e9c7e08 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoullif/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/bernoullif/examples/c/example.c @@ -18,14 +18,13 @@ #include "stdlib/math/base/special/bernoullif.h" #include -#include int main( void ) { - int32_t i; + float i; float v; - for ( i = 0; i < 70; i++ ) { + for ( i = 0.0f; i < 70.0f; i++ ) { v = stdlib_base_bernoullif( i ); - printf( "bernoullif(%d) = %f\n", i, v ); + printf( "bernoullif(%f) = %f\n", i, v ); } } diff --git a/lib/node_modules/@stdlib/math/base/special/bernoullif/include/stdlib/math/base/special/bernoullif.h b/lib/node_modules/@stdlib/math/base/special/bernoullif/include/stdlib/math/base/special/bernoullif.h index d91a06908c7e..87b87c910942 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoullif/include/stdlib/math/base/special/bernoullif.h +++ b/lib/node_modules/@stdlib/math/base/special/bernoullif/include/stdlib/math/base/special/bernoullif.h @@ -19,8 +19,6 @@ #ifndef STDLIB_MATH_BASE_SPECIAL_BERNOULLIF_H #define STDLIB_MATH_BASE_SPECIAL_BERNOULLIF_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 as a single-precision floating-point number. */ -float stdlib_base_bernoullif( const int32_t n ); +float stdlib_base_bernoullif( const float n ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/math/base/special/bernoullif/lib/main.js b/lib/node_modules/@stdlib/math/base/special/bernoullif/lib/main.js index aa3d8dad5ee4..136adc68c2cd 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoullif/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/bernoullif/lib/main.js @@ -23,7 +23,7 @@ var isNonNegativeIntegerf = require( '@stdlib/math/base/assert/is-nonnegative-integerf' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var isOdd = require( '@stdlib/math/base/assert/is-odd' ); +var isOddf = require( '@stdlib/math/base/assert/is-oddf' ); var NINF = require( '@stdlib/constants/float32/ninf' ); var PINF = require( '@stdlib/constants/float32/pinf' ); var BERNOULLIF = require( './bernoullif.json' ); @@ -89,11 +89,11 @@ function bernoullif( n ) { if ( n === 1 ) { return 0.5; } - if ( isOdd( n ) ) { + if ( isOddf( n ) ) { return 0.0; } if ( n > MAX_BERNOULLI ) { - return ( (n/2)&1 ) ? PINF : NINF; + return ( isOddf( n/2.0 ) ) ? PINF : NINF; } return float64ToFloat32( BERNOULLIF[ n/2 ] ); } diff --git a/lib/node_modules/@stdlib/math/base/special/bernoullif/manifest.json b/lib/node_modules/@stdlib/math/base/special/bernoullif/manifest.json index dfd6c1402483..728bd21fab18 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoullif/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/bernoullif/manifest.json @@ -38,7 +38,9 @@ "dependencies": [ "@stdlib/math/base/napi/unary", "@stdlib/constants/float32/ninf", - "@stdlib/constants/float32/pinf" + "@stdlib/constants/float32/pinf", + "@stdlib/math/base/assert/is-nonnegative-integerf", + "@stdlib/math/base/assert/is-oddf" ] }, { @@ -53,7 +55,9 @@ "libpath": [], "dependencies": [ "@stdlib/constants/float32/ninf", - "@stdlib/constants/float32/pinf" + "@stdlib/constants/float32/pinf", + "@stdlib/math/base/assert/is-nonnegative-integerf", + "@stdlib/math/base/assert/is-oddf" ] }, { @@ -68,7 +72,9 @@ "libpath": [], "dependencies": [ "@stdlib/constants/float32/ninf", - "@stdlib/constants/float32/pinf" + "@stdlib/constants/float32/pinf", + "@stdlib/math/base/assert/is-nonnegative-integerf", + "@stdlib/math/base/assert/is-oddf" ] } ] diff --git a/lib/node_modules/@stdlib/math/base/special/bernoullif/src/addon.c b/lib/node_modules/@stdlib/math/base/special/bernoullif/src/addon.c index b3fbf2264ddd..340d04fbd5e5 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoullif/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/bernoullif/src/addon.c @@ -19,4 +19,4 @@ #include "stdlib/math/base/special/bernoullif.h" #include "stdlib/math/base/napi/unary.h" -STDLIB_MATH_BASE_NAPI_MODULE_I_F( stdlib_base_bernoullif ) +STDLIB_MATH_BASE_NAPI_MODULE_F_F( stdlib_base_bernoullif ) diff --git a/lib/node_modules/@stdlib/math/base/special/bernoullif/src/main.c b/lib/node_modules/@stdlib/math/base/special/bernoullif/src/main.c index 37807ea16ad9..616a5c5785ed 100644 --- a/lib/node_modules/@stdlib/math/base/special/bernoullif/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/bernoullif/src/main.c @@ -16,10 +16,13 @@ * limitations under the License. */ +#include "stdlib/math/base/assert/is_nonnegative_integerf.h" +#include "stdlib/math/base/assert/is_oddf.h" #include "stdlib/math/base/special/bernoullif.h" #include "stdlib/constants/float32/ninf.h" #include "stdlib/constants/float32/pinf.h" #include +#include static const float bernoulli_value[ 33 ] = { 1.0f, @@ -66,21 +69,21 @@ static const int32_t MAX_BERNOULLI = 64; * @return output value * * @example -* float out = stdlib_base_bernoullif( 0 ); +* float out = stdlib_base_bernoullif( 0.0f ); * // returns 1.0f */ -float stdlib_base_bernoullif( const int32_t n ) { - if ( n < 0 ) { +float stdlib_base_bernoullif( const float n ) { + if ( !stdlib_base_is_nonnegative_integerf( n ) ) { return 0.0f / 0.0f; // NaN } - if ( n == 1 ) { + if ( n == 1.0f ) { return 0.5f; } - if ( n & 1 ) { + if ( stdlib_base_is_oddf( n ) ) { return 0.0f; } if ( n > MAX_BERNOULLI ) { - return ( ( n / 2 ) & 1 ) ? STDLIB_CONSTANT_FLOAT32_PINF : STDLIB_CONSTANT_FLOAT32_NINF; + return ( stdlib_base_is_oddf( n/2.0f ) ) ? STDLIB_CONSTANT_FLOAT32_PINF : STDLIB_CONSTANT_FLOAT32_NINF; } - return bernoulli_value[ n / 2 ]; + return bernoulli_value[ (size_t)( n / 2.0f ) ]; }