From 1267ce6cdc1984575c20093453acd1c0aca3fb08 Mon Sep 17 00:00:00 2001 From: Lovelin <100030865+lovelindhoni@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:25:19 +0530 Subject: [PATCH] refactor: update `blas/ext/base/ssumpw` to follow current project conventions Closes: https://github.com/stdlib-js/stdlib/issues/1544 PR-URL: https://github.com/stdlib-js/stdlib/pull/1673 Ref: https://github.com/stdlib-js/stdlib/issues/788 Ref: https://github.com/stdlib-js/stdlib/issues/1152 Co-authored-by: Athan Reines Reviewed-by: Athan Reines Signed-off-by: Athan Reines Signed-off-by: Lovelin <100030865+lovelindhoni@users.noreply.github.com> --- .../@stdlib/blas/ext/base/ssumpw/README.md | 30 ++--- .../ext/base/ssumpw/benchmark/benchmark.js | 19 ++- .../base/ssumpw/benchmark/benchmark.native.js | 15 +-- .../ssumpw/benchmark/benchmark.ndarray.js | 19 ++- .../benchmark/benchmark.ndarray.native.js | 15 +-- .../blas/ext/base/ssumpw/docs/repl.txt | 18 ++- .../blas/ext/base/ssumpw/examples/index.js | 15 +-- .../@stdlib/blas/ext/base/ssumpw/include.gypi | 2 +- .../@stdlib/blas/ext/base/ssumpw/lib/index.js | 6 +- .../blas/ext/base/ssumpw/lib/ndarray.js | 6 +- .../ext/base/ssumpw/lib/ndarray.native.js | 15 +-- .../blas/ext/base/ssumpw/manifest.json | 81 ++++++------ .../@stdlib/blas/ext/base/ssumpw/src/addon.c | 48 +++++++ .../blas/ext/base/ssumpw/src/addon.cpp | 117 ------------------ .../blas/ext/base/ssumpw/test/test.ndarray.js | 11 +- .../base/ssumpw/test/test.ndarray.native.js | 11 +- .../blas/ext/base/ssumpw/test/test.ssumpw.js | 18 ++- .../base/ssumpw/test/test.ssumpw.native.js | 11 +- 18 files changed, 172 insertions(+), 285 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.c delete mode 100644 lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.cpp 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 cd38c2d01ea..89ac46033fd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2020 The Stdlib Authors. +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. @@ -56,16 +56,14 @@ The function has the following parameters: - **x**: input [`Float32Array`][@stdlib/array/float32]. - **stride**: index increment for `x`. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the sum of every other element in `x`, +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of every other element in `x`, ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] ); -var N = floor( x.length / 2 ); -var v = ssumpw( N, x, 2 ); +var v = ssumpw( 4, x, 2 ); // returns 5.0 ``` @@ -75,14 +73,11 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = ssumpw( N, x1, 2 ); +var v = ssumpw( 4, x1, 2 ); // returns 5.0 ``` @@ -108,12 +103,10 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -var N = floor( x.length / 2 ); -var v = ssumpw.ndarray( N, x, 2, 1 ); +var v = ssumpw.ndarray( 4, x, 2, 1 ); // returns 5.0 ``` @@ -139,18 +132,11 @@ var v = ssumpw.ndarray( N, x, 2, 1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var ssumpw = require( '@stdlib/blas/ext/base/ssumpw' ); -var x; -var i; - -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} +var x = filledarrayBy(10, 'float32', discreteUniform(0, 100)); console.log( x ); var v = ssumpw( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.js index 5560d04682a..3d80ee7c0e6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* 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. @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var ssumpw = require( './../lib/ssumpw.js' ); +// VARIABLES // + +var rand = uniform( -100.0, 100.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var ssumpw = require( './../lib/ssumpw.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*10.0 ) - 20.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.native.js index 63976466780..75eba90307e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* 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. @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var ssumpw = tryRequire( resolve( __dirname, './../lib/ssumpw.native.js' ) ); var opts = { 'skip': ( ssumpw instanceof Error ) }; +var rand = uniform( -100.0, 100.0 ); // FUNCTIONS // @@ -48,13 +49,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*10.0 ) - 20.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.ndarray.js index 03ac333f321..2d9da5ceedc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* 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. @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var ssumpw = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -100.0, 100.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var ssumpw = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*10.0 ) - 20.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.ndarray.native.js index 7cc835edcdb..5d45da4c73c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/benchmark.ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* 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. @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var ssumpw = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( ssumpw instanceof Error ) }; +var rand = uniform( -100.0, 100.0 ); // FUNCTIONS // @@ -48,13 +49,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*10.0 ) - 20.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/docs/repl.txt index 1c5f2cf4027..124979eb58c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/docs/repl.txt @@ -3,8 +3,8 @@ Computes the sum of single-precision floating-point strided array elements using pairwise summation. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + The `N` and `stride` parameters determine which elements in the strided + array are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -36,19 +36,16 @@ // Using `N` and `stride` parameters: > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > var stride = 2; - > {{alias}}( N, x, stride ) + > {{alias}}( 3, x, 2 ) 1.0 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > stride = 2; - > {{alias}}( N, x1, stride ) + > {{alias}}( 3, x1, 2 ) -1.0 + {{alias}}.ndarray( N, x, stride, offset ) Computes the sum of single-precision floating-point strided array elements using pairwise summation and alternative indexing semantics. @@ -84,9 +81,8 @@ 1.0 // Using offset parameter: - > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1 ) + > x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); + > {{alias}}.ndarray( 3, x, 2, 1 ) -1.0 See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/examples/index.js index bfbc22ac7d7..c8c4a83414d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* 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. @@ -18,18 +18,11 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var ssumpw = require( './../lib' ); -var x; -var i; - -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} +var x = filledarrayBy( 10, 'float32', discreteUniform( -100.0, 100.0 ) ); console.log( x ); var v = ssumpw( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/include.gypi index 868c5c12e85..26476a8c265 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' +#include + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 3 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, stride, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 1 ); + + napi_value v; + napi_status status = napi_create_double( env, (double)stdlib_strided_ssumpw( N, (float *)X, stride ), &v ); + assert( status == napi_ok ); + + return v; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.cpp b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.cpp deleted file mode 100644 index 88de5819375..00000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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. -*/ - -#include "stdlib/blas/ext/base/ssumpw.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_ext_base_ssumpw { - - /** - * Computes the sum of single-precision floating-point strided array elements using pairwise summation. - * - * ## Notes - * - * - When called from JavaScript, the function expects three arguments: - * - * - `N`: number of indexed elements - * - `X`: input array - * - `stride`: stride length - */ - napi_value node_ssumpw( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 3; - napi_value argv[ 3 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 3 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 3 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - bool res; - status = napi_is_typedarray( env, argv[ 1 ], &res ); - assert( status == napi_ok ); - if ( res == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype2 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - int64_t stride; - status = napi_get_value_int64( env, argv[ 2 ], &stride ); - assert( status == napi_ok ); - - napi_typedarray_type vtype1; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 1 ], &vtype1, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype1 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(stride) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Second argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_value v; - status = napi_create_double( env, (double)stdlib_strided_ssumpw( N, (float *)X, stride ), &v ); - assert( status == napi_ok ); - - return v; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_ssumpw, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_ssumpw 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 fe76d087c67..e9c183089d5 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 @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* 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. @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var ssumpw = require( './../lib/ndarray.js' ); @@ -36,7 +35,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 4', function test( t ) { - t.strictEqual( ssumpw.length, 4, 'has expected arity' ); + t.strictEqual( ssumpw.length, 4, 'returns expected value' ); t.end(); }); @@ -118,7 +117,7 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); + N = 4; v = ssumpw( N, x, 2, 0 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -142,7 +141,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); + N = 4; v = ssumpw( N, x, -2, 6 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -184,7 +183,7 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); + N = 4; v = ssumpw( N, x, 2, 1 ); t.strictEqual( v, 5.0, 'returns expected value' ); 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 4c34bbc7f16..99493e472db 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 @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* 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. @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -45,7 +44,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 4', opts, function test( t ) { - t.strictEqual( ssumpw.length, 4, 'has expected arity' ); + t.strictEqual( ssumpw.length, 4, 'returns expected value' ); t.end(); }); @@ -127,7 +126,7 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); + N = 4; v = ssumpw( N, x, 2, 0 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -151,7 +150,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); + N = 4; v = ssumpw( N, x, -2, 6 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -193,7 +192,7 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); + N = 4; v = ssumpw( N, x, 2, 1 ); t.strictEqual( v, 5.0, 'returns expected value' ); 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 9107ad8d25d..ea6438f6a75 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 @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* 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. @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var ssumpw = require( './../lib/ssumpw.js' ); @@ -36,7 +35,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 3', function test( t ) { - t.strictEqual( ssumpw.length, 3, 'has expected arity' ); + t.strictEqual( ssumpw.length, 3, 'returns expected value' ); t.end(); }); @@ -103,9 +102,9 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; + var N; x = new Float32Array([ 1.0, // 0 @@ -118,7 +117,7 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); + N = 4; v = ssumpw( N, x, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -126,10 +125,10 @@ tape( 'the function supports a `stride` parameter', function test( t ) { }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; var i; + var N; x = new Float32Array([ 1.0, // 3 @@ -142,7 +141,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); + N = 4; v = ssumpw( N, x, -2 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -172,8 +171,8 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; + var N; x0 = new Float32Array([ 2.0, @@ -187,9 +186,8 @@ tape( 'the function supports view offsets', function test( t ) { 6.0 ]); + N = 4; x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = ssumpw( N, x1, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); 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 c83329086b5..f8c3bac2d29 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 @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* 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. @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -45,7 +44,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 3', opts, function test( t ) { - t.strictEqual( ssumpw.length, 3, 'has expected arity' ); + t.strictEqual( ssumpw.length, 3, 'returns expected value' ); t.end(); }); @@ -209,7 +208,7 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); + N = 4; v = ssumpw( N, x, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -233,7 +232,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); + N = 4; v = ssumpw( N, x, -2 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -279,7 +278,7 @@ tape( 'the function supports view offsets', opts, function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); + N = 4; v = ssumpw( N, x1, 2 ); t.strictEqual( v, 5.0, 'returns expected value' );