From 7d8ab5a148946f94121316cc1dc5d22936e7ea57 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Tue, 3 Dec 2024 16:02:50 +0530 Subject: [PATCH 01/11] feat: add `ii_f` API in `math/base/napi/binary` PR-URL: https://github.com/stdlib-js/stdlib/pull/3315 Reviewed-by: Athan Reines --- .../@stdlib/math/base/napi/binary/README.md | 63 +++++++++++++++++++ .../include/stdlib/math/base/napi/binary.h | 47 ++++++++++++++ .../@stdlib/math/base/napi/binary/src/main.c | 62 ++++++++++++++++++ 3 files changed, 172 insertions(+) diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/README.md b/lib/node_modules/@stdlib/math/base/napi/binary/README.md index 884541964c0b..e1ff3cd3af7a 100644 --- a/lib/node_modules/@stdlib/math/base/napi/binary/README.md +++ b/lib/node_modules/@stdlib/math/base/napi/binary/README.md @@ -595,6 +595,46 @@ The function accepts the following arguments: void stdlib_math_base_napi_ll_d( napi_env env, napi_callback_info info, double (*fcn)( int64_t, int64_t ) ); ``` +#### stdlib_math_base_napi_ii_f( env, info, fcn ) + +Invokes a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. + +```c +#include +#include + +// ... + +static float fcn( const int32_t x, const int32_t y ) { + // ... +} + +// ... + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_ii_f( env, info, fcn ); +} + +// ... +``` + +The function accepts the following arguments: + +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] float (*fcn)( int32_t, int32_t )` binary function. + +```c +void stdlib_math_base_napi_ii_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t, int32_t ) ); +``` + #### STDLIB_MATH_BASE_NAPI_MODULE_DD_D( fcn ) Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning double-precision floating-point numbers. @@ -964,6 +1004,29 @@ The macro expects the following arguments: When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. +#### STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. + +```c +#include + +static float fcn( const int32_t x, const int32_t y ) { + // ... +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn ); +``` + +The macro expects the following arguments: + +- **fcn**: `float (*fcn)( int32_t, int32_t )` binary function. + +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. + diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary.h index 2d59c39c3d64..4315f1072eac 100644 --- a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary.h +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary.h @@ -616,6 +616,48 @@ }; \ NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ll_d_init ) +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. +* +* @param fcn binary function +* +* @example +* #include +* +* static float fcn( const int_32 x, const int_32 y ) { +* // ... +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn ) \ + static napi_value stdlib_math_base_napi_ii_f_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_ii_f( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_ii_f_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_ii_f_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ii_f_init ) + /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. */ @@ -688,6 +730,11 @@ napi_value stdlib_math_base_napi_cf_c( napi_env env, napi_callback_info info, st */ napi_value stdlib_math_base_napi_ll_d( napi_env env, napi_callback_info info, double (*fcn)( int64_t, int64_t ) ); +/** +* Invokes a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_ii_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t, int32_t ) ); + #ifdef __cplusplus } #endif diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/main.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/main.c index 8a308393295c..07d3b89c5f6e 100644 --- a/lib/node_modules/@stdlib/math/base/napi/binary/src/main.c +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/main.c @@ -1247,3 +1247,65 @@ napi_value stdlib_math_base_napi_ll_d( napi_env env, napi_callback_info info, do return v; } + +/** +* Invokes a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API single-precision floating-point number +*/ +napi_value stdlib_math_base_napi_ii_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t, int32_t ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + int32_t x; + status = napi_get_value_int32( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + int32_t y; + status = napi_get_value_int32( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, (double)fcn( x, y ), &v ); + assert( status == napi_ok ); + + return v; +} From 97985302871b99c45462d43479e246c4549c3991 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 3 Dec 2024 07:56:23 -0500 Subject: [PATCH 02/11] chore: minor clean-up --- ...st-index-of.js => benchmark.last_index_of.js} | 0 ...ngth.js => benchmark.last_index_of.length.js} | 0 .../array/fixed-endian-factory/lib/main.js | 10 +++------- ...st.last-index-of.js => test.last_index_of.js} | 16 ++++++++++++++++ 4 files changed, 19 insertions(+), 7 deletions(-) rename lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/{benchmark.last-index-of.js => benchmark.last_index_of.js} (100%) rename lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/{benchmark.last-index-of.length.js => benchmark.last_index_of.length.js} (100%) rename lib/node_modules/@stdlib/array/fixed-endian-factory/test/{test.last-index-of.js => test.last_index_of.js} (90%) diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.last-index-of.js b/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.last_index_of.js similarity index 100% rename from lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.last-index-of.js rename to lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.last_index_of.js diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.last-index-of.length.js b/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.last_index_of.length.js similarity index 100% rename from lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.last-index-of.length.js rename to lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.last_index_of.length.js diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js b/lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js index 9938162ff704..4004689d9c3f 100644 --- a/lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js +++ b/lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js @@ -720,7 +720,7 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli * @memberof TypedArray.prototype * @type {Function} * @param {*} searchElement - element to search for - * @param {integer} [fromIndex=this._length-1] - starting index (inclusive) + * @param {integer} fromIndex - starting index (inclusive) * @throws {TypeError} `this` must be a typed array instance * @throws {TypeError} second argument must be an integer * @returns {integer} index or -1 @@ -736,14 +736,10 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli if ( !isInteger( fromIndex ) ) { throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); } - if ( fromIndex < 0 ) { - fromIndex += this._length; - } - if ( fromIndex < 0 ) { - return -1; - } if ( fromIndex >= this._length ) { fromIndex = this._length - 1; + } else if ( fromIndex < 0 ) { + fromIndex += this._length; } } else { fromIndex = this._length - 1; diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.last-index-of.js b/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.last_index_of.js similarity index 90% rename from lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.last-index-of.js rename to lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.last_index_of.js index 8333bb8402a0..54be9b624b8d 100644 --- a/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.last-index-of.js +++ b/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.last_index_of.js @@ -204,3 +204,19 @@ tape( 'the method supports specifying a starting search index (negative)', funct t.end(); }); + +tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { + var ctor; + var arr; + var idx; + + ctor = factory( 'float64' ); + arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); + + idx = arr.lastIndexOf( 2.0, 10 ); + t.strictEqual( idx, 4, 'returns expected value' ); + + idx = arr.lastIndexOf( 5.0, 10 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); From e5d32c53f8f552fae4d672c8750619a59ce078ac Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 3 Dec 2024 08:47:23 -0500 Subject: [PATCH 03/11] chore: minor clean-up --- .../array/fixed-endian-factory/README.md | 121 ++++++++--------- .../benchmark/benchmark.join.length.js | 3 +- .../array/fixed-endian-factory/lib/main.js | 127 +++++++++--------- .../fixed-endian-factory/test/test.filter.js | 4 +- .../fixed-endian-factory/test/test.join.js | 56 ++++---- .../fixed-endian-factory/test/test.with.js | 39 +----- 6 files changed, 161 insertions(+), 189 deletions(-) diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/README.md b/lib/node_modules/@stdlib/array/fixed-endian-factory/README.md index 7ceb1b56cf40..568d0f575d6a 100644 --- a/lib/node_modules/@stdlib/array/fixed-endian-factory/README.md +++ b/lib/node_modules/@stdlib/array/fixed-endian-factory/README.md @@ -390,35 +390,35 @@ var count = context.count; // returns 3 ``` - + -#### TypedArrayFE.prototype.forEach( callbackFn\[, thisArg] ) +#### TypedArrayFE.prototype.filter( predicate\[, thisArg] ) -Invokes a function once for each array element. +Returns a new array containing the elements of an array which pass a test implemented by a predicate function. ```javascript -function log( v, i ) { - console.log( '%s: %s', i.toString(), v.toString() ); +function predicate( v ) { + return ( v % 2 === 0 ); } var Float64ArrayFE = fixedEndianFactory( 'float64' ); -var arr = new Float64ArrayFE( 'little-endian', 3 ); +var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); + +var out = arr.filter( predicate ); // returns -arr.set( 1.5, 0 ); -arr.set( 2.5, 1 ); -arr.set( 3.5, 2 ); +var len = out.length; +// returns 2 -arr.forEach( log ); -/* => - 0: 1.5 - 1: 2.5 - 2: 3.5 -*/ +var v = out.get( 0 ); +// returns 2.0 + +v = out.get( 1 ); +// return 4.0 ``` -The invoked function is provided three arguments: +The `predicate` function is provided three arguments: - **value**: current array element. - **index**: current array element index. @@ -427,59 +427,58 @@ The invoked function is provided three arguments: To set the function execution context, provide a `thisArg`. ```javascript -function fcn( v, i ) { +function predicate( v, i ) { this.count += 1; - console.log( '%s: %s', i.toString(), v.toString() ); + return ( v % 2 === 0 ); } -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', 3 ); -// returns - var context = { 'count': 0 }; -arr.set( 1.0, 0 ); -arr.set( 2.0, 1 ); -arr.set( 3.0, 2 ); +var Float64ArrayFE = fixedEndianFactory( 'float64' ); -arr.forEach( fcn, context ); +var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); + +var out = arr.filter( predicate, context ); +// returns + +var len = out.length; +// returns 2 var count = context.count; -// returns 3 +// returns 4 ``` - + -#### TypedArrayFE.prototype.filter( predicate\[, thisArg] ) +#### TypedArrayFE.prototype.forEach( callbackFn\[, thisArg] ) -Returns a new array containing the elements of an array which pass a test implemented by a predicate function. +Invokes a function once for each array element. ```javascript -function predicate( v ) { - return ( v % 2 === 0 ); +function log( v, i ) { + console.log( '%s: %s', i.toString(), v.toString() ); } var Float64ArrayFE = fixedEndianFactory( 'float64' ); -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - -var out = arr.filter( predicate ); +var arr = new Float64ArrayFE( 'little-endian', 3 ); // returns -var len = out.length; -// returns 2 - -var v = out.get( 0 ); -// returns 2.0 +arr.set( 1.5, 0 ); +arr.set( 2.5, 1 ); +arr.set( 3.5, 2 ); -v = out.get( 1 ); -// return 4.0 +arr.forEach( log ); +/* => + 0: 1.5 + 1: 2.5 + 2: 3.5 +*/ ``` -The `predicate` function is provided three arguments: +The invoked function is provided three arguments: - **value**: current array element. - **index**: current array element index. @@ -488,27 +487,28 @@ The `predicate` function is provided three arguments: To set the function execution context, provide a `thisArg`. ```javascript -function predicate( v, i ) { +function fcn( v, i ) { this.count += 1; - return ( v % 2 === 0 ); + console.log( '%s: %s', i.toString(), v.toString() ); } +var Float64ArrayFE = fixedEndianFactory( 'float64' ); + +var arr = new Float64ArrayFE( 'little-endian', 3 ); +// returns + var context = { 'count': 0 }; -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - -var out = arr.filter( predicate, context ); -// returns +arr.set( 1.0, 0 ); +arr.set( 2.0, 1 ); +arr.set( 3.0, 2 ); -var len = out.length; -// returns 2 +arr.forEach( fcn, context ); var count = context.count; -// returns 4 +// returns 3 ``` @@ -883,7 +883,7 @@ var str = arr.toString(); #### TypedArrayFE.prototype.join( \[separator] ) -Serializes the array elements into a string, with elements separated by the specified `separator`. If no `separator` is provided, a comma (`,`) is used as the default. +Returns a new string by concatenating all array elements. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); @@ -892,20 +892,17 @@ var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); var str = arr.join(); // returns '1,2,3' - -str = arr.join( ' - ' ); -// returns '1 - 2 - 3' ``` -If the provided `separator` is not a string, it is coerced to a string. +By default, the method separates serialized array elements with a comma. To use an alternative separator, provide a `separator` string. ```javascript var Float64ArrayFE = fixedEndianFactory( 'float64' ); var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); -var str = arr.join( 0 ); -// returns '10203' +var str = arr.join( ' - ' ); +// returns '1 - 2 - 3' ``` diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.join.length.js b/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.join.length.js index 683f2a3bc169..69b0e1f8051d 100644 --- a/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.join.length.js +++ b/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.join.length.js @@ -42,8 +42,7 @@ var Float64ArrayFE = factory( 'float64' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var arr; - arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); + var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); return benchmark; /** diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js b/lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js index 4004689d9c3f..b1899599583e 100644 --- a/lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js +++ b/lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js @@ -24,7 +24,6 @@ var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; var isCollection = require( '@stdlib/assert/is-collection' ); var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); var isObject = require( '@stdlib/assert/is-object' ); @@ -584,65 +583,65 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli }); /** - * Invokes a function once for each array element. + * Returns a new array containing the elements of an array which pass a test implemented by a predicate function. * - * @name forEach + * @name filter * @memberof TypedArray.prototype * @type {Function} - * @param {Function} fcn - function to invoke - * @param {*} [thisArg] - function invocation context + * @param {Function} predicate - test function + * @param {*} [thisArg] - predicate function execution context * @throws {TypeError} `this` must be a typed array instance * @throws {TypeError} first argument must be a function + * @returns {TypedArray} typed array */ - setReadOnly( TypedArray.prototype, 'forEach', function forEach( fcn, thisArg ) { + setReadOnly( TypedArray.prototype, 'filter', function filter( predicate, thisArg ) { var buf; + var out; var i; + var v; if ( !isTypedArray( this ) ) { throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); } buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - fcn.call( thisArg, buf[ GETTER ]( i*BYTES_PER_ELEMENT, this._isLE ), i, this ); + out = []; + for ( i = 0; i < this._length; i++) { + v = buf[ GETTER ]( i*BYTES_PER_ELEMENT, this._isLE ); + if ( predicate.call( thisArg, v, i, this ) ) { + out.push( v ); + } } + return new this.constructor( flag2byteOrder( this._isLE ), out ); }); /** - * Returns a new array containing the elements of an array which pass a test implemented by a predicate function. + * Invokes a function once for each array element. * - * @name filter + * @name forEach * @memberof TypedArray.prototype * @type {Function} - * @param {Function} predicate - test function - * @param {*} [thisArg] - predicate function execution context + * @param {Function} fcn - function to invoke + * @param {*} [thisArg] - function invocation context * @throws {TypeError} `this` must be a typed array instance * @throws {TypeError} first argument must be a function - * @returns {TypedArray} typed array */ - setReadOnly( TypedArray.prototype, 'filter', function filter( predicate, thisArg ) { + setReadOnly( TypedArray.prototype, 'forEach', function forEach( fcn, thisArg ) { var buf; - var out; var i; - var v; if ( !isTypedArray( this ) ) { throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + if ( !isFunction( fcn ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++) { - v = buf[ GETTER ]( i*BYTES_PER_ELEMENT, this._isLE ); - if ( predicate.call( thisArg, v, i, this ) ) { - out.push( v ); - } + for ( i = 0; i < this._length; i++ ) { + fcn.call( thisArg, buf[ GETTER ]( i*BYTES_PER_ELEMENT, this._isLE ), i, this ); } - return new this.constructor( flag2byteOrder( this._isLE ), out ); }); /** @@ -712,6 +711,43 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli return -1; }); + /** + * Returns a new string by concatenating all array elements. + * + * @private + * @name join + * @memberof TypedArray.prototype + * @type {Function} + * @param {string} [separator=','] - element separator + * @throws {TypeError} `this` must be a typed array instance + * @throws {TypeError} first argument must be a string + * @returns {string} joined string + */ + setReadOnly( TypedArray.prototype, 'join', function join( separator ) { + var out; + var buf; + var sep; + var i; + + if ( !isTypedArray( this ) ) { + throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); + } + if ( arguments.length > 0 ) { + if ( !isString( separator ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); + } + sep = separator; + } else { + sep = ','; + } + out = []; + buf = this._buffer; + for ( i = 0; i < this._length; i++ ) { + out.push( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) ); + } + return out.join( sep ); + }); + /** * Returns the index of the last occurrence of a given element. * @@ -1036,39 +1072,6 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli return out.join( ',' ); }); - /** - * Serializes the array elements into a string, with elements separated by the specified `separator`. - * - * @private - * @name join - * @memberof TypedArray.prototype - * @type {Function} - * @param {string} [separator=','] - string used to separate consecutive elements - * @throws {TypeError} `this` must be a typed array instance - * @returns {string} joined string - */ - setReadOnly( TypedArray.prototype, 'join', function join( separator ) { - var out; - var buf; - var sep; - var i; - - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( arguments.length > 0 ) { - sep = String( separator ); - } else { - sep = ','; - } - out = []; - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - out.push( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) ); - } - return out.join( sep ); - }); - /** * Returns a new typed array with the element at a provided index replaced with a provided value. * @@ -1080,7 +1083,6 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli * @throws {TypeError} `this` must be a typed array instance * @throws {TypeError} first argument must be an integer * @throws {RangeError} index argument is out-of-bounds - * @throws {TypeError} second argument must be a number * @returns {TypedArray} new typed array */ setReadOnly( TypedArray.prototype, 'with', function copyWith( index, value ) { @@ -1103,9 +1105,6 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli if ( index < 0 || index >= len ) { throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) ); } - if ( !isNumber( value ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a number. Value: `%s`.', value ) ); - } out = new this.constructor( flag2byteOrder( this._isLE ), buf.buffer ); outbuf = out._buffer; // eslint-disable-line no-underscore-dangle outbuf[ SETTER ]( index * BYTES_PER_ELEMENT, value, this._isLE ); diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.filter.js b/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.filter.js index 5f3c14ac0eb1..47cf85db100e 100644 --- a/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.filter.js +++ b/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.filter.js @@ -40,7 +40,7 @@ tape( 'the function returns a function', function test( t ) { t.end(); }); -tape( 'attached to the prototype of the returned function is an `filter` method', function test( t ) { +tape( 'attached to the prototype of the returned function is a `filter` method', function test( t ) { var ctor = factory( 'float64' ); t.strictEqual( hasOwnProp( ctor.prototype, 'filter' ), true, 'returns expected value' ); t.strictEqual( isFunction( ctor.prototype.filter ), true, 'returns expected value' ); @@ -132,7 +132,7 @@ tape( 'the method returns an empty array if operating on an empty array', functi } }); -tape( 'the method returns a new boolean array containing only those elements which satisfy a test condition', function test( t ) { +tape( 'the method returns a new typed array containing only those elements which satisfy a test condition', function test( t ) { var expected; var actual; var ctor; diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.join.js b/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.join.js index d98a86d01da9..e59fed52d2cb 100644 --- a/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.join.js +++ b/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.join.js @@ -74,6 +74,38 @@ tape( 'the method throws an error if invoked with a `this` context which is not } }); +tape( 'the method throws an error if invoked with a `separator` argument which is not a string', function test( t ) { + var values; + var ctor; + var arr; + var i; + + ctor = factory( 'float64' ); + arr = new ctor( 'little-endian', 5 ); + + values = [ + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.join( value ); + }; + } +}); + tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { var ctor; var str; @@ -141,27 +173,3 @@ tape( 'if the method is invoked without a separator argument, the method returns t.strictEqual( str, expected, 'returns expected value' ); t.end(); }); - -tape( 'the method coerces non-string separators to strings', function test( t ) { - var expected; - var ctor; - var str; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0 ] ); - - expected = '1true2true3'; - str = arr.join( true ); - t.strictEqual( str, expected, 'returns expected value' ); - - expected = '1null2null3'; - str = arr.join( null ); - t.strictEqual( str, expected, 'returns expected value' ); - - expected = '1[object Object]2[object Object]3'; - str = arr.join( {} ); - t.strictEqual( str, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.with.js b/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.with.js index 93a36b03d62e..df6fa9201321 100644 --- a/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.with.js +++ b/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.with.js @@ -21,6 +21,7 @@ // MODULES // var tape = require( 'tape' ); +var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); var factory = require( './../lib' ); @@ -142,38 +143,6 @@ tape( 'the method throws an error if provided a first argument which is not in b } }); -tape( 'the method throws an error if provided a second argument which is not a number', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( 0, value ); - }; - } -}); - tape( 'the method does not change the array length', function test( t ) { var ctor; var arr; @@ -198,7 +167,7 @@ tape( 'the method returns a new boolean array with the element at a provided ind expected = new ctor( 'little-endian', [ 0.0, 2.0, 3.0, 4.0, 5.0 ] ); actual = arr.with( 0, 0.0 ); t.strictEqual( actual instanceof ctor, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); + t.strictEqual( hasSameValues( actual, expected ), true, 'returns expected value' ); t.notEqual( actual, arr, 'returns new instance' ); t.end(); }); @@ -212,9 +181,9 @@ tape( 'the method supports negative indices', function test( t ) { ctor = factory( 'float64' ); arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); expected = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 0.0 ] ); - actual = arr.with( -5, 0.0 ); + actual = arr.with( -1, 0.0 ); t.strictEqual( actual instanceof ctor, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); + t.strictEqual( hasSameValues( actual, expected ), true, 'returns expected value' ); t.notEqual( actual, arr, 'returns new instance' ); t.end(); }); From 299517a7a1e3494b93b2368c4f135a5826f88090 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Wed, 4 Dec 2024 03:39:38 +0530 Subject: [PATCH 04/11] docs: update examples in `math/base/special/lcmf` PR-URL: https://github.com/stdlib-js/stdlib/pull/3319 Co-authored-by: Athan Reines Reviewed-by: Athan Reines Reviewed-by: Philipp Burckhardt Signed-off-by: Athan Reines --- .../@stdlib/math/base/special/lcmf/README.md | 15 +++++---------- .../math/base/special/lcmf/examples/index.js | 15 +++++---------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 9215e3bac914..516e540bb345 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -101,20 +101,15 @@ v = lcmf( 48, NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var roundf = require( '@stdlib/math/base/special/roundf' ); +var randu = require( '@stdlib/random/array/discrete-uniform' ); var lcmf = require( '@stdlib/math/base/special/lcmf' ); -var a; -var b; -var v; -var i; +var a = randu( 100, 0, 50 ); +var b = randu( 100, 0, 50 ); +var i; for ( i = 0; i < 100; i++ ) { - a = roundf( randu() * 50 ); - b = roundf( randu() * 50 ); - v = lcmf( a, b ); - console.log( 'lcmf(%d,%d) = %d', a, b, v ); + console.log( 'lcmf(%d,%d) = %d', a[ i ], b[ i ], lcmf( a[ i ], b[ i ] ) ); } ``` diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js index 762dd5382e7d..42f023a6008b 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js @@ -18,18 +18,13 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var roundf = require( '@stdlib/math/base/special/roundf' ); +var randu = require( '@stdlib/random/array/discrete-uniform' ); var lcmf = require( './../lib' ); -var a; -var b; -var v; -var i; +var a = randu( 100, 0, 50 ); +var b = randu( 100, 0, 50 ); +var i; for ( i = 0; i < 100; i++ ) { - a = roundf( randu() * 50 ); - b = roundf( randu() * 50 ); - v = lcmf( a, b ); - console.log( 'lcmf(%d,%d) = %d', a, b, v ); + console.log( 'lcmf(%d,%d) = %d', a[ i ], b[ i ], lcmf( a[ i ], b[ i ] ) ); } From 27e0f3c432b142bcef3e679670802947b9ad16ca Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Wed, 4 Dec 2024 03:44:50 +0530 Subject: [PATCH 05/11] feat: add `constants/float64/max-safe-nth-tribonacci` PR-URL: https://github.com/stdlib-js/stdlib/pull/3317 Ref: https://github.com/stdlib-js/stdlib/blob/299517a7a1e3494b93b2368c4f135a5826f88090/lib/node_modules/%40stdlib/math/base/special/tribonacci/src/main.c#L21 Co-authored-by: Athan Reines Reviewed-by: Athan Reines Signed-off-by: Gunj Joshi Signed-off-by: Athan Reines --- .../float64/max-safe-nth-tribonacci/README.md | 183 ++++++++++++++++++ .../max-safe-nth-tribonacci/docs/repl.txt | 13 ++ .../docs/types/index.d.ts | 33 ++++ .../docs/types/test.ts | 28 +++ .../max-safe-nth-tribonacci/examples/index.js | 60 ++++++ .../float64/max_safe_nth_tribonacci.h | 27 +++ .../max-safe-nth-tribonacci/lib/index.js | 49 +++++ .../max-safe-nth-tribonacci/manifest.json | 36 ++++ .../max-safe-nth-tribonacci/package.json | 73 +++++++ .../max-safe-nth-tribonacci/test/test.js | 38 ++++ 10 files changed, 540 insertions(+) create mode 100644 lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/README.md create mode 100644 lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/examples/index.js create mode 100644 lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/include/stdlib/constants/float64/max_safe_nth_tribonacci.h create mode 100644 lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/lib/index.js create mode 100644 lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/manifest.json create mode 100644 lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/package.json create mode 100644 lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/test/test.js diff --git a/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/README.md b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/README.md new file mode 100644 index 000000000000..22751c1abdd9 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/README.md @@ -0,0 +1,183 @@ + + +# FLOAT64_MAX_SAFE_NTH_TRIBONACCI + +> Maximum safe nth [Tribonacci number][tribonacci-number] when stored in [double-precision floating-point][ieee754] format. + +
+ +## Usage + + + +```javascript +var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( '@stdlib/constants/float64/max-safe-nth-tribonacci' ); +``` + +#### FLOAT64_MAX_SAFE_NTH_TRIBONACCI + +Maximum [safe][safe-integers] nth [Tribonacci number][tribonacci-number] when stored in [double-precision floating-point][ieee754] format. + + + +```javascript +var bool = ( FLOAT64_MAX_SAFE_NTH_TRIBONACCI === 63 ); +// returns true +``` + +
+ + + +
+ +## Examples + + + + + +```javascript +var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( '@stdlib/constants/float64/max-safe-nth-tribonacci' ); + +function tribonacci( n ) { + var a; + var b; + var c; + var d; + var i; + + a = 0; + b = 0; + c = 1; + if ( n === 0 ) { + return a; + } + if ( n === 1 ) { + return b; + } + if ( n === 2 ) { + return c; + } + for ( i = 3; i <= n; i++ ) { + d = a + b + c; + a = b; + b = c; + c = d; + } + return c; +} + +var v; +var i; +for ( i = 0; i < 100; i++ ) { + v = tribonacci( i ); + if ( i > FLOAT64_MAX_SAFE_NTH_TRIBONACCI ) { + console.log( 'Unsafe: %d', v ); + } else { + console.log( 'Safe: %d', v ); + } +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/constants/float64/max_safe_nth_tribonacci.h" +``` + +#### STDLIB_CONSTANT_FLOAT64_MAX_SAFE_NTH_TRIBONACCI + +Maximum [safe][safe-integers] nth [Tribonacci number][tribonacci-number] when stored in [double-precision floating-point][ieee754] format. + +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/docs/repl.txt b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/docs/repl.txt new file mode 100644 index 000000000000..8228c9706e65 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/docs/repl.txt @@ -0,0 +1,13 @@ + +{{alias}} + Maximum safe nth Tribonacci number when stored in double-precision + floating-point format. + + Examples + -------- + > {{alias}} + 63 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/docs/types/index.d.ts b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/docs/types/index.d.ts new file mode 100644 index 000000000000..bf85fb6c1bda --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/docs/types/index.d.ts @@ -0,0 +1,33 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Maximum safe nth Tribonacci number when stored in double-precision floating-point format. +* +* @example +* var max = FLOAT64_MAX_SAFE_NTH_TRIBONACCI; +* // returns 63 +*/ +declare const FLOAT64_MAX_SAFE_NTH_TRIBONACCI: number; + + +// EXPORTS // + +export = FLOAT64_MAX_SAFE_NTH_TRIBONACCI; diff --git a/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/docs/types/test.ts b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/docs/types/test.ts new file mode 100644 index 000000000000..fd1e495e6485 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/docs/types/test.ts @@ -0,0 +1,28 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( './index' ); + + +// TESTS // + +// The export is a number... +{ + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + FLOAT64_MAX_SAFE_NTH_TRIBONACCI; // $ExpectType number +} diff --git a/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/examples/index.js b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/examples/index.js new file mode 100644 index 000000000000..dcd5b4a523cd --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/examples/index.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( './../lib' ); // eslint-disable-line id-length + +function tribonacci( n ) { + var a; + var b; + var c; + var d; + var i; + + a = 0; + b = 0; + c = 1; + if ( n === 0 ) { + return a; + } + if ( n === 1 ) { + return b; + } + if ( n === 2 ) { + return c; + } + for ( i = 3; i <= n; i++ ) { + d = a + b + c; + a = b; + b = c; + c = d; + } + return c; +} + +var v; +var i; +for ( i = 0; i < 100; i++ ) { + v = tribonacci( i ); + if ( i > FLOAT64_MAX_SAFE_NTH_TRIBONACCI ) { + console.log( 'Unsafe: %d', v ); + } else { + console.log( 'Safe: %d', v ); + } +} diff --git a/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/include/stdlib/constants/float64/max_safe_nth_tribonacci.h b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/include/stdlib/constants/float64/max_safe_nth_tribonacci.h new file mode 100644 index 000000000000..1c3c96f4ce0b --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/include/stdlib/constants/float64/max_safe_nth_tribonacci.h @@ -0,0 +1,27 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_CONSTANTS_FLOAT64_MAX_SAFE_NTH_TRIBONACCI_H +#define STDLIB_CONSTANTS_FLOAT64_MAX_SAFE_NTH_TRIBONACCI_H + +/** +* Maximum safe nth Tribonacci number when stored in single-precision floating-point format. +*/ +#define STDLIB_CONSTANT_FLOAT64_MAX_SAFE_NTH_TRIBONACCI 63 + +#endif // !STDLIB_CONSTANTS_FLOAT64_MAX_SAFE_NTH_TRIBONACCI_H diff --git a/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/lib/index.js b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/lib/index.js new file mode 100644 index 000000000000..a5d25ca78d88 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/lib/index.js @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Maximum safe nth Tribonacci number when stored in double-precision floating-point format. +* +* @module @stdlib/constants/float64/max-safe-nth-tribonacci +* @type {integer} +* +* @example +* var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( '@stdlib/constants/float64/max-safe-nth-tribonacci' ); +* // returns 63 +*/ + + +// MAIN // + +/** +* Maximum safe nth Tribonacci number when stored in double-precision floating-point format. +* +* @constant +* @type {integer} +* @default 63 +* @see [Tribonacci number]{@link https://en.wikipedia.org/wiki/Tribonacci_number} +* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985} +*/ +var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = 63|0; // eslint-disable-line id-length + + +// EXPORTS // + +module.exports = FLOAT64_MAX_SAFE_NTH_TRIBONACCI; diff --git a/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/manifest.json b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/manifest.json new file mode 100644 index 000000000000..844d692f6439 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/manifest.json @@ -0,0 +1,36 @@ +{ + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [] + } + ] +} diff --git a/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/package.json b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/package.json new file mode 100644 index 000000000000..f849b0956c92 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/package.json @@ -0,0 +1,73 @@ +{ + "name": "@stdlib/constants/float64/max-safe-nth-tribonacci", + "version": "0.0.0", + "description": "Maximum safe nth Tribonacci number when stored in double-precision floating-point format.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "constant", + "const", + "max", + "maximum", + "tribonacci", + "number", + "trib", + "safe", + "integer", + "double", + "dbl", + "floating", + "point", + "floating-point", + "float", + "float64", + "f64", + "ieee754" + ] +} diff --git a/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/test/test.js b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/test/test.js new file mode 100644 index 000000000000..b386846035e9 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float64/max-safe-nth-tribonacci/test/test.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( './../lib' ); // eslint-disable-line id-length + + +// TESTS // + +tape( 'main export is a number', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof FLOAT64_MAX_SAFE_NTH_TRIBONACCI, 'number', 'main export is a number' ); + t.end(); +}); + +tape( 'the exported value is 63', function test( t ) { + t.strictEqual( FLOAT64_MAX_SAFE_NTH_TRIBONACCI, 63, 'returns expected value' ); + t.end(); +}); From cf7f7699d75907cd327fc3369d77bc8a4e064ba6 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 3 Dec 2024 21:52:18 -0500 Subject: [PATCH 06/11] build: set triggers and add and remove Needs Review label --- .github/workflows/labeler.yml | 61 ++++++++++++++++++++++++++++ .github/workflows/slash_commands.yml | 20 ++++----- 2 files changed, 71 insertions(+), 10 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 4b4e5e3d41bf..9328b08e33aa 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -22,6 +22,18 @@ name: labeler # Workflow triggers: on: pull_request_target: + types: + - opened + - synchronize + - reopened + - edited + - assigned + - unassigned + - labeled + - unlabeled + - review_requested + - review_request_removed + - ready_for_review # Workflow jobs: jobs: @@ -53,3 +65,52 @@ jobs: with: configuration-path: .github/labeler.yml repo-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }} + + # Add "Needs Review" label when PR is opened and not a draft: + - name: 'Add "Needs Review" label if PR is opened and not draft' + if: ${{ github.event.action == 'opened' && github.event.pull_request.draft == false }} + # Pin action to full length commit SHA + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }} + script: | + await github.issues.addLabels({ + 'owner': context.repo.owner, + 'repo': context.repo.repo, + 'issue_number': context.payload.pull_request.number, + 'labels': ['Needs Review'], + }) + + # Add "Needs Review" label when PR is marked ready for review: + - name: 'Add "Needs Review" label if PR is ready for review' + if: ${{ github.event.action == 'ready_for_review' }} + # Pin action to full length commit SHA + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }} + script: | + await github.issues.addLabels({ + 'owner': context.repo.owner, + 'repo': context.repo.repo, + 'issue_number': context.payload.pull_request.number, + 'labels': ['Needs Review'], + }) + + # Remove "Needs Review" label when PR is converted to draft or closed: + - name: 'Remove "Needs Review" label if PR is converted to draft or closed' + if: ${{ github.event.action == 'converted_to_draft' || github.event.action == 'closed' }} + # Pin action to full length commit SHA + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }} + script: | + try { + await github.issues.removeLabel({ + 'owner': context.repo.owner, + 'repo': context.repo.repo, + 'issue_number': context.payload.pull_request.number, + 'name': 'Needs Review', + }) + } catch ( error ) { + console.log( 'Error removing label: %s', error.message ); + } diff --git a/.github/workflows/slash_commands.yml b/.github/workflows/slash_commands.yml index b2b4e416f24b..e6dfe14e1b18 100644 --- a/.github/workflows/slash_commands.yml +++ b/.github/workflows/slash_commands.yml @@ -51,10 +51,10 @@ jobs: github-token: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }} script: | github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - labels: ['bot: In Progress'] + 'owner': context.repo.owner, + 'repo': context.repo.repo, + 'issue_number': context.issue.number, + 'labels': ['bot: In Progress'] }) # Add initial reaction to comment with slash command: @@ -254,11 +254,11 @@ jobs: script: | try { await github.rest.issues.removeLabel({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - name: 'bot: In Progress' + 'owner': context.repo.owner, + 'repo': context.repo.repo, + 'issue_number': context.issue.number, + 'name': 'bot: In Progress' }) - } catch (error) { - console.log( 'Error removing label:', error ); + } catch ( error ) { + console.log( 'Error removing label: %s', error.message ); } From 01dbe3a492eba280e93425cb3291622b4ad99e46 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 3 Dec 2024 21:59:21 -0500 Subject: [PATCH 07/11] build: add missing trigger and fix invocations --- .github/workflows/labeler.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 9328b08e33aa..5dcf9951d835 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -27,13 +27,10 @@ on: - synchronize - reopened - edited - - assigned - - unassigned - - labeled - - unlabeled - review_requested - review_request_removed - ready_for_review + - converted_to_draft # Workflow jobs: jobs: @@ -74,7 +71,7 @@ jobs: with: github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }} script: | - await github.issues.addLabels({ + await github.rest.issues.addLabels({ 'owner': context.repo.owner, 'repo': context.repo.repo, 'issue_number': context.payload.pull_request.number, @@ -89,7 +86,7 @@ jobs: with: github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }} script: | - await github.issues.addLabels({ + await github.rest.issues.addLabels({ 'owner': context.repo.owner, 'repo': context.repo.repo, 'issue_number': context.payload.pull_request.number, @@ -105,7 +102,7 @@ jobs: github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }} script: | try { - await github.issues.removeLabel({ + await github.rest.issues.removeLabel({ 'owner': context.repo.owner, 'repo': context.repo.repo, 'issue_number': context.payload.pull_request.number, From 1d10ce5163bb06f0b93f6dc0ef9697a8336054c2 Mon Sep 17 00:00:00 2001 From: Ahmed_Kashkoush <89735230+ahmad-kashkoush@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:53:48 +0200 Subject: [PATCH 08/11] feat: add `includes` method to `array/fixed-endian-factory` PR-URL: https://github.com/stdlib-js/stdlib/pull/3283 Closes: https://github.com/stdlib-js/stdlib/issues/3145 Co-authored-by: Athan Reines Co-authored-by: Muhammad Haris Reviewed-by: Athan Reines Reviewed-by: Muhammad Haris Signed-off-by: Ahmed_Kashkoush <89735230+ahmad-kashkoush@users.noreply.github.com> Signed-off-by: Athan Reines --- .../array/fixed-endian-factory/README.md | 24 ++ .../benchmark/benchmark.includes.js | 56 +++++ .../benchmark/benchmark.includes.length.js | 103 ++++++++ .../array/fixed-endian-factory/lib/main.js | 42 ++++ .../test/test.includes.js | 226 ++++++++++++++++++ 5 files changed, 451 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.includes.js create mode 100644 lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.includes.length.js create mode 100644 lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.includes.js diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/README.md b/lib/node_modules/@stdlib/array/fixed-endian-factory/README.md index 568d0f575d6a..ab659bbc55ba 100644 --- a/lib/node_modules/@stdlib/array/fixed-endian-factory/README.md +++ b/lib/node_modules/@stdlib/array/fixed-endian-factory/README.md @@ -543,6 +543,30 @@ var v = arr.get( 100 ); // returns undefined ``` + + +#### TypedArrayFE.prototype.includes( searchElement\[, fromIndex] ) + +Returns a boolean indicating whether an array includes a provided value. + +```javascript +var Float64ArrayFE = fixedEndianFactory( 'float64' ); + +var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); + +var idx = arr.includes( 2.0 ); +// returns true + +idx = arr.includes( 2.0, 2 ); +// returns true + +idx = arr.includes( 2.0, -4 ); +// returns true + +idx = arr.includes( 5.0 ); +// returns false +``` + #### TypedArrayFE.prototype.indexOf( searchElement\[, fromIndex] ) diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.includes.js b/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.includes.js new file mode 100644 index 000000000000..d1c27cc4d64a --- /dev/null +++ b/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.includes.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var factory = require( './../lib' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var Float64ArrayFE = factory( 'float64' ); + + +// MAIN // + +bench( pkg+':includes', function benchmark( b ) { + var result; + var arr; + var i; + + arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + result = arr.includes( 5.0, 0 ); + if ( typeof result !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( result ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.includes.length.js b/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.includes.length.js new file mode 100644 index 000000000000..db15d820b6e9 --- /dev/null +++ b/lib/node_modules/@stdlib/array/fixed-endian-factory/benchmark/benchmark.includes.length.js @@ -0,0 +1,103 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var zeroTo = require( '@stdlib/array/zero-to' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var factory = require( './../lib' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var Float64ArrayFE = factory( 'float64' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var result; + var v; + var i; + + v = len - 1; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + result = arr.includes( v ); + if ( typeof result !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( result ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':includes:len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js b/lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js index b1899599583e..079902a6c333 100644 --- a/lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js +++ b/lib/node_modules/@stdlib/array/fixed-endian-factory/lib/main.js @@ -669,6 +669,48 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli return this._buffer[ GETTER ]( idx*BYTES_PER_ELEMENT, this._isLE ); }); + /** + * Returns a boolean indicating whether an array includes a provided value. + * + * @private + * @name includes + * @memberof TypedArray.prototype + * @type {Function} + * @param {*} searchElement - search element + * @param {integer} [fromIndex=0] - starting index (inclusive) + * @throws {TypeError} `this` must be a typed array instance + * @throws {TypeError} second argument must be an integer + * @returns {boolean} boolean indicating whether an array includes a provided value + */ + setReadOnly( TypedArray.prototype, 'includes', function includes( searchElement, fromIndex ) { + var buf; + var i; + + if ( !isTypedArray( this ) ) { + throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); + } + if ( arguments.length > 1 ) { + if ( !isInteger( fromIndex ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + } + if ( fromIndex < 0 ) { + fromIndex += this._length; + if ( fromIndex < 0 ) { + fromIndex = 0; + } + } + } else { + fromIndex = 0; + } + buf = this._buffer; + for ( i = fromIndex; i < this._length; i++ ) { + if ( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) === searchElement ) { + return true; + } + } + return false; + }); + /** * Returns the index of the first occurrence of a given element. * diff --git a/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.includes.js b/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.includes.js new file mode 100644 index 000000000000..ff0cf5d98963 --- /dev/null +++ b/lib/node_modules/@stdlib/array/fixed-endian-factory/test/test.includes.js @@ -0,0 +1,226 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns a function', function test( t ) { + var ctor = factory( 'float64' ); + t.strictEqual( isFunction( ctor ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned function is an `includes` method', function test( t ) { + var ctor = factory( 'float64' ); + t.strictEqual( hasOwnProp( ctor.prototype, 'includes' ), true, 'returns expected value' ); + t.strictEqual( isFunction( ctor.prototype.includes ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { + var values; + var ctor; + var arr; + var i; + + ctor = factory( 'float64' ); + arr = new ctor( 'little-endian', 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.includes.call( value, 0 ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { + var values; + var ctor; + var arr; + var i; + + ctor = factory( 'float64' ); + arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.includes( 1.0, value ); + }; + } +}); + +tape( 'the method returns `false` if provided a second argument which exceeds array dimensions', function test( t ) { + var ctor; + var arr; + var v; + var i; + + ctor = factory( 'float64' ); + arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); + + for ( i = arr.length; i < arr.length+5; i++ ) { + v = arr.includes( 1.0, i ); + t.strictEqual( v, false, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the method returns `false` if operating on an empty array', function test( t ) { + var ctor; + var arr; + var v; + + ctor = factory( 'float64' ); + arr = new ctor( 'little-endian', [] ); + + v = arr.includes( 1.0 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method returns `false` if a search element is not found', function test( t ) { + var ctor; + var arr; + var v; + + ctor = factory( 'float64' ); + arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + + v = arr.includes( 10.0 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method returns `true` if an element is found', function test( t ) { + var ctor; + var arr; + var v; + + ctor = factory( 'float64' ); + arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); + + v = arr.includes( 2.0 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method supports specifying a starting search index', function test( t ) { + var ctor; + var arr; + var v; + + ctor = factory( 'float64' ); + arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); + + v = arr.includes( 2.0, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + v = arr.includes( 2.0, 2 ); + t.strictEqual( v, true, 'returns expected value' ); + + v = arr.includes( 1.0, 4 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method supports specifying a starting search index (negative)', function test( t ) { + var ctor; + var arr; + var v; + + ctor = factory( 'float64' ); + arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); + + v = arr.includes( 2.0, -3 ); + t.strictEqual( v, true, 'returns expected value' ); + + v = arr.includes( 1.0, -3 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'when provided a starting index which resolves to an index less than zero, the method searches from the first array element', function test( t ) { + var ctor; + var arr; + var v; + + ctor = factory( 'float64' ); + arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); + + v = arr.includes( 2.0, -10 ); + t.strictEqual( v, true, 'returns expected value' ); + + v = arr.includes( 1.0, -10 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); From 4bc5c7efda9452e0fb18a2cfe59bf89a4d180534 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Thu, 5 Dec 2024 01:33:55 +0530 Subject: [PATCH 09/11] refactor: use external constant in `math/base/special/tribonacci` PR-URL: https://github.com/stdlib-js/stdlib/pull/3324 Reviewed-by: Athan Reines --- .../@stdlib/math/base/special/tribonacci/lib/main.js | 8 ++------ .../math/base/special/tribonacci/manifest.json | 11 ++++++++--- .../@stdlib/math/base/special/tribonacci/src/main.c | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/tribonacci/lib/main.js b/lib/node_modules/@stdlib/math/base/special/tribonacci/lib/main.js index 1934282ef2b5..ae42aa6fce29 100644 --- a/lib/node_modules/@stdlib/math/base/special/tribonacci/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/tribonacci/lib/main.js @@ -22,14 +22,10 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isInteger = require( '@stdlib/math/base/assert/is-integer' ); +var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( '@stdlib/constants/float64/max-safe-nth-tribonacci' ); // eslint-disable-line id-length var TRIBONACCI = require( './tribonacci.json' ); -// VARIABLES // - -var MAX_TRIBONACCI = 63; - - // MAIN // /** @@ -83,7 +79,7 @@ function tribonacci( n ) { isnan( n ) || isInteger( n ) === false || n < 0 || - n > MAX_TRIBONACCI + n > FLOAT64_MAX_SAFE_NTH_TRIBONACCI ) { return NaN; } diff --git a/lib/node_modules/@stdlib/math/base/special/tribonacci/manifest.json b/lib/node_modules/@stdlib/math/base/special/tribonacci/manifest.json index 6bfc690068b2..04f64e637d30 100644 --- a/lib/node_modules/@stdlib/math/base/special/tribonacci/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/tribonacci/manifest.json @@ -36,7 +36,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/napi/unary" + "@stdlib/math/base/napi/unary", + "@stdlib/constants/float64/max-safe-nth-tribonacci" ] }, { @@ -49,7 +50,9 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/constants/float64/max-safe-nth-tribonacci" + ] }, { "task": "examples", @@ -61,7 +64,9 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/constants/float64/max-safe-nth-tribonacci" + ] } ] } diff --git a/lib/node_modules/@stdlib/math/base/special/tribonacci/src/main.c b/lib/node_modules/@stdlib/math/base/special/tribonacci/src/main.c index 7c67d18b71d6..4c40ca64d130 100644 --- a/lib/node_modules/@stdlib/math/base/special/tribonacci/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/tribonacci/src/main.c @@ -17,8 +17,8 @@ */ #include "stdlib/math/base/special/tribonacci.h" +#include "stdlib/constants/float64/max_safe_nth_tribonacci.h" -static const int32_t STDLIB_CONSTANTS_FLOAT64_MAX_SAFE_NTH_TRIBONACCI = 63; // TODO: consider making a package similar to `@stdlib/constants/float64/max-safe-nth-fibonacci` static const int64_t tribonacci_value[ 64 ] = { 0, 0, @@ -96,7 +96,7 @@ static const int64_t tribonacci_value[ 64 ] = { * // returns 0 */ double stdlib_base_tribonacci( const int32_t n ) { - if ( n < 0 || n > STDLIB_CONSTANTS_FLOAT64_MAX_SAFE_NTH_TRIBONACCI ) { + if ( n < 0 || n > STDLIB_CONSTANT_FLOAT64_MAX_SAFE_NTH_TRIBONACCI ) { return 0.0 / 0.0; // NaN } return tribonacci_value[ n ]; From fcedaac9fd61fd81a1aa6d522ed2c29b21465259 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Thu, 5 Dec 2024 01:13:19 +0500 Subject: [PATCH 10/11] fix: update the return type and remove unnecessary branches/tests in `blas/ext/base/ssumpw` PR-URL: https://github.com/stdlib-js/stdlib/pull/3321 Reviewed-by: Athan Reines --- .../@stdlib/blas/ext/base/ssumpw/README.md | 12 ++++---- .../ssumpw/benchmark/c/benchmark.length.c | 2 +- .../include/stdlib/blas/ext/base/ssumpw.h | 4 +-- .../blas/ext/base/ssumpw/lib/ndarray.js | 4 --- .../blas/ext/base/ssumpw/manifest.json | 3 -- .../@stdlib/blas/ext/base/ssumpw/src/addon.c | 4 +-- .../@stdlib/blas/ext/base/ssumpw/src/main.c | 28 ++++++++----------- .../blas/ext/base/ssumpw/test/test.ndarray.js | 12 -------- .../base/ssumpw/test/test.ndarray.native.js | 12 -------- .../blas/ext/base/ssumpw/test/test.ssumpw.js | 12 -------- .../base/ssumpw/test/test.ssumpw.native.js | 12 -------- 11 files changed, 23 insertions(+), 82 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/README.md b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/README.md index 099e037756ed..f580f76ec54d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/README.md @@ -178,8 +178,8 @@ Computes the sum of single-precision floating-point strided array elements using ```c const float x[] = { 1.0f, -2.0f, 2.0f }; -double v = stdlib_strided_ssumpw( 3, x, 1 ); -// returns 1.0 +float v = stdlib_strided_ssumpw( 3, x, 1 ); +// returns 1.0f ``` The function accepts the following arguments: @@ -189,7 +189,7 @@ The function accepts the following arguments: - **strideX**: `[in] CBLAS_INT` stride length for `X`. ```c -double stdlib_strided_ssumpw( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ); +float stdlib_strided_ssumpw( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ); ``` #### stdlib_strided_ssumpw_ndarray( N, \*X, strideX, offsetX ) @@ -199,8 +199,8 @@ Computes the sum of single-precision floating-point strided array elements using ```c const float x[] = { 1.0f, -2.0f, 2.0f }; -double v = stdlib_strided_ssumpw_ndarray( 3, x, 1, 0 ); -// returns 1.0 +float v = stdlib_strided_ssumpw_ndarray( 3, x, 1, 0 ); +// returns 1.0f ``` The function accepts the following arguments: @@ -211,7 +211,7 @@ The function accepts the following arguments: - **offsetX**: `[in] CBLAS_INT` starting index for `X`. ```c -double stdlib_strided_ssumpw_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +float stdlib_strided_ssumpw_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/c/benchmark.length.c index 43deee0705a7..7c5a68bd0348 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/c/benchmark.length.c @@ -131,7 +131,7 @@ static double benchmark1( int iterations, int len ) { static double benchmark2( int iterations, int len ) { double elapsed; float x[ len ]; - double v; + float v; double t; int i; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/include/stdlib/blas/ext/base/ssumpw.h b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/include/stdlib/blas/ext/base/ssumpw.h index 3f44488af3da..331916b57bbd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/include/stdlib/blas/ext/base/ssumpw.h +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/include/stdlib/blas/ext/base/ssumpw.h @@ -31,12 +31,12 @@ extern "C" { /** * Computes the sum of single-precision floating-point strided array elements using pairwise summation. */ -double API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ); +float API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ); /** * Computes the sum of single-precision floating-point strided array elements using pairwise summation and alternative indexing semantics. */ -double API_SUFFIX(stdlib_strided_ssumpw_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +float API_SUFFIX(stdlib_strided_ssumpw_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/lib/ndarray.js index d73d98f00de9..bdf5ce4a1324 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/lib/ndarray.js @@ -22,7 +22,6 @@ var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var floor = require( '@stdlib/math/base/special/floor' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); // VARIABLES // @@ -78,9 +77,6 @@ function ssumpw( N, x, strideX, offsetX ) { } ix = offsetX; if ( strideX === 0 ) { - if ( isnan( x[ ix ] ) ) { - return 0.0; - } return N * x[ ix ]; } if ( N < 8 ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/manifest.json index 2e4581f2d856..411d1502dfdf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/manifest.json @@ -41,7 +41,6 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float32array", "@stdlib/napi/create-double", - "@stdlib/math/base/assert/is-nanf", "@stdlib/blas/base/shared", "@stdlib/strided/base/stride2offset" ] @@ -57,7 +56,6 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/assert/is-nanf", "@stdlib/blas/base/shared", "@stdlib/strided/base/stride2offset" ] @@ -73,7 +71,6 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/assert/is-nanf", "@stdlib/blas/base/shared", "@stdlib/strided/base/stride2offset" ] diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.c index e0868a246b27..c6b31fda493a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.c @@ -37,7 +37,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 ); - STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_ssumpw)( N, X, strideX ), v ) + STDLIB_NAPI_CREATE_DOUBLE( env, (double)API_SUFFIX(stdlib_strided_ssumpw)( N, X, strideX ), v ) return v; } @@ -54,7 +54,7 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 ); - STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_ssumpw_ndarray)( N, X, strideX, offsetX ), v ) + STDLIB_NAPI_CREATE_DOUBLE( env, (double)API_SUFFIX(stdlib_strided_ssumpw_ndarray)( N, X, strideX, offsetX ), v ) return v; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/main.c index 910cc7a804d2..034fb859189f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/main.c @@ -17,7 +17,6 @@ */ #include "stdlib/blas/ext/base/ssumpw.h" -#include "stdlib/math/base/assert/is_nanf.h" #include "stdlib/blas/base/shared.h" #include "stdlib/strided/base/stride2offset.h" @@ -37,9 +36,9 @@ * @param strideX stride length * @return output value */ -double API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ) { +float API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ) { CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); - API_SUFFIX(stdlib_strided_ssumpw_ndarray)( N, X, strideX, ox ); + return API_SUFFIX(stdlib_strided_ssumpw_ndarray)( N, X, strideX, ox ); } /** @@ -59,29 +58,26 @@ double API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, con * @param offsetX starting index * @return output value */ -double API_SUFFIX(stdlib_strided_ssumpw_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { +float API_SUFFIX(stdlib_strided_ssumpw_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { CBLAS_INT ix; CBLAS_INT M; CBLAS_INT n; CBLAS_INT i; - double sum; - double s0; - double s1; - double s2; - double s3; - double s4; - double s5; - double s6; - double s7; + float sum; + float s0; + float s1; + float s2; + float s3; + float s4; + float s5; + float s6; + float s7; if ( N <= 0 ) { return 0.0f; } ix = offsetX; if ( strideX == 0 ) { - if ( stdlib_base_is_nanf( X[ ix ] ) ) { - return 0.0f; - } return N * X[ ix ]; } if ( N < 8 ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ndarray.js index 7f66952466c4..3c9f0a38d937 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ndarray.js @@ -168,18 +168,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s t.end(); }); -tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns 0.0', function test( t ) { - var x; - var v; - - x = new Float32Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); - - v = ssumpw( x.length, x, 0, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports an `offset` parameter', function test( t ) { var N; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ndarray.native.js index 32adc1f11529..1c564ae2b391 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ndarray.native.js @@ -177,18 +177,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s t.end(); }); -tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns 0.0', opts, function test( t ) { - var x; - var v; - - x = new Float32Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); - - v = ssumpw( x.length, x, 0, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports an `offset` parameter', opts, function test( t ) { var N; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ssumpw.js b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ssumpw.js index 0eb782742a30..e47d762372a3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ssumpw.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ssumpw.js @@ -168,18 +168,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s t.end(); }); -tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns 0.0', function test( t ) { - var x; - var v; - - x = new Float32Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); - - v = ssumpw( x.length, x, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports view offsets', function test( t ) { var x0; var x1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ssumpw.native.js b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ssumpw.native.js index 182dba95473b..2c55a13eeb16 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ssumpw.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ssumpw.native.js @@ -259,18 +259,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s t.end(); }); -tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns 0.0', opts, function test( t ) { - var x; - var v; - - x = new Float32Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); - - v = ssumpw( x.length, x, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports view offsets', opts, function test( t ) { var x0; var x1; From a974755c96abfbab894aa8b19a385709cbc10dfd Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Wed, 4 Dec 2024 20:24:16 -0800 Subject: [PATCH 11/11] docs: update list of contributors PR-URL: https://github.com/stdlib-js/stdlib/pull/3329 Co-authored-by: Philipp Burckhardt Reviewed-by: Philipp Burckhardt Signed-off-by: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> --- .mailmap | 24 +++++++++++++++++++++++- CONTRIBUTORS | 20 +++++++++++--------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.mailmap b/.mailmap index 9915f529e760..87614f81aa79 100644 --- a/.mailmap +++ b/.mailmap @@ -20,6 +20,11 @@ Adarsh Palaskar adarshpalaskar1 Aditya Sapra <110766802+adityacodes30@users.noreply.github.com> Aditya Sapra adityacodes30 +Ahmed Atwa NightKnight + +Ahmed Kashkoush <89735230+ahmad-kashkoush@users.noreply.github.com> +Ahmed Kashkoush Ahmed_Kashkoush + Aman Bhansali <92033532+aman-095@users.noreply.github.com> Aman Bhansali aman-095 @@ -99,10 +104,17 @@ Muhammad Haris headlessNode Naresh Jagadeesan <37257700+Infinage@users.noreply.github.com> +Nishant Shinde <97207366+nishant-s7@users.noreply.github.com> nishant-s7 + Nithin Katta <88046362+nithinkatta@users.noreply.github.com> KATTA NAGA NITHIN +# O + +Ori Miles <97595296+orimiles5@users.noreply.github.com> orimiles5 + # P +Philipp Burckhardt <1913638+Planeshifter@users.noreply.github.com> Philipp Burckhardt Planeshifter Pranav Goswami <85227306+Pranavchiku@users.noreply.github.com> @@ -117,6 +129,8 @@ Pratyush Kumar Chouhan Pratyush Priyansh <88396544+itsspriyansh@users.noreply.github.com> itsspriyansh +Priyanshu Agarwal <113460573+AgPriyanshu18@users.noreply.github.com> AgPriyanshu18 + Pushpendra Chandravanshi <56391001+Pushpendra766@users.noreply.github.com> Pushpendra Chandravanshi Pushpendra766 @@ -132,9 +146,11 @@ Rejoan Sardar <119718513+Rejoan-Sardar@users.noreply.github.com> Rejoan-Sardar Ricky Reusser Ricky Reusser <572717+rreusser@users.noreply.github.com> +Rishav <115060907+rishav2404@users.noreply.github.com> RISHAV + Robert Gislason rgizz -Rutam <138517416+performant23@users.noreply.github.com> performant23 +Rutam Kathale <138517416+performant23@users.noreply.github.com> performant23 Ryan Seal Splrk @@ -142,6 +158,8 @@ Ryan Seal Splrk Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com> the-r3aper7 +Sarthak Paandey <145528240+SarthakPaandey@users.noreply.github.com> SarthakPaandey + Shashank Shekhar Singh <123410790+Shashankss1205@users.noreply.github.com> Shashank Shekhar Singh Shashankss1205 @@ -160,6 +178,8 @@ Stephannie Jiménez Gacha Stephannie Jimenez Stephannie Jiménez Gacha Stephannie Jimenez Gacha +Suraj Kumar <125961509+kumarsuraj212003@users.noreply.github.com> Suraj kuma + # T Tudor Pagu <104032457+tudor-pagu@users.noreply.github.com> tudor-pagu @@ -184,5 +204,7 @@ Varad Gupta vr-varad # Y +Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com> yaswanth + Yernar Yergaziyev Yernar Yergaziyev <54137699+yernar707@users.noreply.github.com> diff --git a/CONTRIBUTORS b/CONTRIBUTORS index a8d0bb6ee112..1566b42c6289 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -6,7 +6,8 @@ Aayush Khanna Abhijit Raut Adarsh Palaskar Aditya Sapra -AgPriyanshu18 <113460573+AgPriyanshu18@users.noreply.github.com> +Ahmed Atwa +Ahmed Kashkoush Aleksandr <112382387+alextes90@users.noreply.github.com> Ali Salesi Aman Bhansali @@ -60,32 +61,35 @@ Momtchil Momtchev Muhammad Haris Naresh Jagadeesan Neeraj Pathak -NightKnight +Nishant Shinde <97207366+nishant-s7@users.noreply.github.com> Nithin Katta <88046362+nithinkatta@users.noreply.github.com> Nourhan Hasan <109472010+TheNourhan@users.noreply.github.com> Ognjen Jevremović Oneday12323 <107678750+Oneday12323@users.noreply.github.com> +Ori Miles <97595296+orimiles5@users.noreply.github.com> Philipp Burckhardt +Planeshifter <1913638+Planeshifter@users.noreply.github.com> Prajwal Kulkarni Pranav Goswami Praneki <97080887+PraneGIT@users.noreply.github.com> Pratik <97464067+Pratik772846@users.noreply.github.com> Pratyush Kumar Chouhan Priyansh <88396544+itsspriyansh@users.noreply.github.com> +Priyanshu Agarwal <113460573+AgPriyanshu18@users.noreply.github.com> Pushpendra Chandravanshi -RISHAV <115060907+rishav2404@users.noreply.github.com> Raunak Kumar Gupta Rejoan Sardar <119718513+Rejoan-Sardar@users.noreply.github.com> Ricky Reusser Ridam Garg <67867319+RidamGarg@users.noreply.github.com> +Rishav <115060907+rishav2404@users.noreply.github.com> Robert Gislason Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com> -Rutam <138517416+performant23@users.noreply.github.com> +Rutam Kathale <138517416+performant23@users.noreply.github.com> Ruthwik Chikoti <145591715+ruthwikchikoti@users.noreply.github.com> Ryan Seal Rylan Yang <137365285+rylany27@users.noreply.github.com> Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com> -SarthakPaandey <145528240+SarthakPaandey@users.noreply.github.com> +Sarthak Paandey <145528240+SarthakPaandey@users.noreply.github.com> Saurabh Singh Seyyed Parsa Neshaei Shashank Shekhar Singh @@ -98,7 +102,7 @@ Snehil Shah Soumajit Chatterjee <121816890+soumajit23@users.noreply.github.com> Spandan Barve Stephannie Jiménez Gacha -Suraj kumar <125961509+kumarsuraj212003@users.noreply.github.com> +Suraj Kumar <125961509+kumarsuraj212003@users.noreply.github.com> Tirtadwipa Manunggal Tudor Pagu <104032457+tudor-pagu@users.noreply.github.com> Tufailahmed Bargir <142114244+Tufailahmed-Bargir@users.noreply.github.com> @@ -109,11 +113,9 @@ Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com> Varad Gupta Vinit Pandit <106718914+MeastroZI@users.noreply.github.com> Xiaochuan Ye +Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com> Yernar Yergaziyev naveen -nishant-s7 <97207366+nishant-s7@users.noreply.github.com> olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com> -orimiles5 <97595296+orimiles5@users.noreply.github.com> rainn <88160429+AmCodesLame@users.noreply.github.com> rei2hu -yaswanth <116426380+yaswanthkosuru@users.noreply.github.com>