From f1c46cd7aed96dafc8b6fd7ea2a45927062b9fcd Mon Sep 17 00:00:00 2001 From: Shivam <11shivam00@gmail.com> Date: Mon, 25 Mar 2024 00:10:54 +0530 Subject: [PATCH] refactor: update `blas/ext/base/sasumpw` to follow current project conventions PR-URL: #1969 Closes: #1515 --------- Signed-off-by: Philipp Burckhardt Co-authored-by: Philipp Burckhardt Reviewed-by: Philipp Burckhardt --- .../@stdlib/blas/ext/base/sasumpw/README.md | 28 ++--- .../ext/base/sasumpw/benchmark/benchmark.js | 17 ++- .../sasumpw/benchmark/benchmark.native.js | 14 +-- .../sasumpw/benchmark/benchmark.ndarray.js | 17 ++- .../benchmark/benchmark.ndarray.native.js | 14 +-- .../blas/ext/base/sasumpw/docs/repl.txt | 16 +-- .../blas/ext/base/sasumpw/examples/index.js | 13 +- .../blas/ext/base/sasumpw/include.gypi | 2 +- .../blas/ext/base/sasumpw/lib/index.js | 4 +- .../blas/ext/base/sasumpw/lib/ndarray.js | 4 +- .../ext/base/sasumpw/lib/ndarray.native.js | 13 +- .../blas/ext/base/sasumpw/manifest.json | 112 +++++++++++------ .../@stdlib/blas/ext/base/sasumpw/src/addon.c | 49 ++++++++ .../blas/ext/base/sasumpw/src/addon.cpp | 117 ------------------ .../ext/base/sasumpw/test/test.ndarray.js | 15 +-- .../base/sasumpw/test/test.ndarray.native.js | 15 +-- .../ext/base/sasumpw/test/test.sasumpw.js | 15 +-- .../base/sasumpw/test/test.sasumpw.native.js | 15 +-- 18 files changed, 189 insertions(+), 291 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/sasumpw/src/addon.c delete mode 100644 lib/node_modules/@stdlib/blas/ext/base/sasumpw/src/addon.cpp diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/README.md b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/README.md index 0aa3e1666ff..71d4acba54e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/README.md @@ -71,16 +71,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 absolute values 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 absolute values 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 = sasumpw( N, x, 2 ); +var v = sasumpw( 4, x, 2 ); // returns 9.0 ``` @@ -90,14 +88,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 = sasumpw( N, x1, 2 ); +var v = sasumpw( 4, x1, 2 ); // returns 9.0 ``` @@ -123,12 +118,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 = sasumpw.ndarray( N, x, 2, 1 ); +var v = sasumpw.ndarray( 4, x, 2, 1 ); // returns 9.0 ``` @@ -154,18 +147,11 @@ var v = sasumpw.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 sasumpw = require( '@stdlib/blas/ext/base/sasumpw' ); -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 = sasumpw( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.js index 0b82e9bd15b..6a6fd9c6a57 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.js @@ -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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var sasumpw = require( './../lib/sasumpw.js' ); +// VARIABLES // + +var rand = uniform( -100.0, 100.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var sasumpw = require( './../lib/sasumpw.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()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.native.js index 4ea42da6425..3c378c2ac2f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.native.js @@ -22,10 +22,11 @@ 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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); 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 +37,7 @@ var sasumpw = tryRequire( resolve( __dirname, './../lib/sasumpw.native.js' ) ); var opts = { 'skip': ( sasumpw instanceof Error ) }; +var rand = uniform( -100.0, 100.0 ); // FUNCTIONS // @@ -48,13 +50,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()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.ndarray.js index 51516eaf303..a8a5f2a6257 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.ndarray.js @@ -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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var sasumpw = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -100.0, 100.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var sasumpw = 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()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.ndarray.native.js index c044f20aece..37276b0feba 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/benchmark/benchmark.ndarray.native.js @@ -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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); 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; @@ -37,6 +37,8 @@ var opts = { 'skip': ( sasumpw instanceof Error ) }; +var rand = uniform( -100.0, 100.0 ); + // FUNCTIONS // @@ -48,13 +50,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()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/docs/repl.txt index e6741df256a..1774f5a709d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/docs/repl.txt @@ -3,8 +3,8 @@ Computes the sum of absolute values (L1 norm) 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 ) 5.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 ) 5.0 + {{alias}}.ndarray( N, x, stride, offset ) Computes the sum of absolute values (L1 norm) of single-precision floating- point strided array elements using pairwise summation and alternative @@ -86,8 +83,7 @@ // 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 ) + > {{alias}}.ndarray( 3, x, 2, 1 ) 5.0 See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/examples/index.js index 64c0c04b5f5..776816d6ddd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/examples/index.js @@ -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 sasumpw = 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 = sasumpw( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/include.gypi index 868c5c12e85..26476a8c265 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/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, stdlib_strided_sasumpw( N, X, stride ), &v ); + assert( status == napi_ok ); + + return v; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/src/addon.cpp b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/src/addon.cpp deleted file mode 100644 index 05160d6ea35..00000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/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/sasumpw.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_ext_base_sasumpw { - - /** - * Computes the sum of absolute values (L1 norm) 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_sasumpw( 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_sasumpw( 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_sasumpw, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_sasumpw diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.js index 3fc4b492b80..4ba34cb8d02 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); @@ -37,7 +36,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 4', function test( t ) { - t.strictEqual( sasumpw.length, 4, 'has expected arity' ); + t.strictEqual( sasumpw.length, 4, 'returns expected value' ); t.end(); }); @@ -104,7 +103,6 @@ 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; @@ -119,15 +117,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = sasumpw( N, x, 2, 0 ); + v = sasumpw( 4, x, 2, 0 ); t.strictEqual( v, 9.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; var i; @@ -143,8 +139,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = sasumpw( N, x, -2, 6 ); + v = sasumpw( 4, x, -2, 6 ); t.strictEqual( v, 9.0, 'returns expected value' ); @@ -171,7 +166,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -185,9 +179,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = sasumpw( N, x, 2, 1 ); + v = sasumpw( 4, x, 2, 1 ); t.strictEqual( v, 9.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.native.js index 8f317e5c50a..4b7824262ed 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.ndarray.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); @@ -46,7 +45,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( sasumpw.length, 4, 'has expected arity' ); + t.strictEqual( sasumpw.length, 4, 'returns expected value' ); t.end(); }); @@ -113,7 +112,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -128,15 +126,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = sasumpw( N, x, 2, 0 ); + v = sasumpw( 4, x, 2, 0 ); t.strictEqual( v, 9.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; var i; @@ -152,8 +148,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = sasumpw( N, x, -2, 6 ); + v = sasumpw( 4, x, -2, 6 ); t.strictEqual( v, 9.0, 'returns expected value' ); @@ -180,7 +175,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', opts, function test( t ) { - var N; var x; var v; @@ -194,9 +188,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = sasumpw( N, x, 2, 1 ); + v = sasumpw( 4, x, 2, 1 ); t.strictEqual( v, 9.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.js index eb2a48e4583..b4edbf624a8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); @@ -37,7 +36,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 3', function test( t ) { - t.strictEqual( sasumpw.length, 3, 'has expected arity' ); + t.strictEqual( sasumpw.length, 3, 'returns expected value' ); t.end(); }); @@ -104,7 +103,6 @@ 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; @@ -119,15 +117,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = sasumpw( N, x, 2 ); + v = sasumpw( 4, x, 2 ); t.strictEqual( v, 9.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; var i; @@ -143,8 +139,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = sasumpw( N, x, -2 ); + v = sasumpw( 4, x, -2 ); t.strictEqual( v, 9.0, 'returns expected value' ); @@ -173,7 +168,6 @@ 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; x0 = new Float32Array([ @@ -189,9 +183,8 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = sasumpw( N, x1, 2 ); + v = sasumpw( 4, x1, 2 ); t.strictEqual( v, 9.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.native.js b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.native.js index 4ba8d59194f..241143d176c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sasumpw/test/test.sasumpw.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); @@ -46,7 +45,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( sasumpw.length, 3, 'has expected arity' ); + t.strictEqual( sasumpw.length, 3, 'returns expected value' ); t.end(); }); @@ -195,7 +194,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -210,15 +208,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = sasumpw( N, x, 2 ); + v = sasumpw( 4, x, 2 ); t.strictEqual( v, 9.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; var i; @@ -234,8 +230,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = sasumpw( N, x, -2 ); + v = sasumpw( 4, x, -2 ); t.strictEqual( v, 9.0, 'returns expected value' ); @@ -264,7 +259,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', opts, function test( t ) { var x0; var x1; - var N; var v; x0 = new Float32Array([ @@ -280,9 +274,8 @@ 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); - v = sasumpw( N, x1, 2 ); + v = sasumpw( 4, x1, 2 ); t.strictEqual( v, 9.0, 'returns expected value' ); t.end();