From b6e46215ca8ac67ca42ce96db292007620821a23 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 17 Jan 2023 10:40:34 +0530 Subject: [PATCH 01/10] refactor readme --- .../@stdlib/blas/base/dswap/README.md | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dswap/README.md b/lib/node_modules/@stdlib/blas/base/dswap/README.md index 72840072e8b9..36f0a31fdc45 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/README.md +++ b/lib/node_modules/@stdlib/blas/base/dswap/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2020 The Stdlib Authors. +Copyright (c) 2023 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. @@ -53,7 +53,7 @@ The function has the following parameters: - **y**: second input [`Float64Array`][mdn-float64array]. - **strideY**: index increment for `y`. -The `N` and `stride` parameters determine how values from `x` and `y` are accessed at runtime. For example, to swap in reverse order every other value in `x` with the first `N` elements of `y`, +The `N` and stride parameters determine how values from `x` and `y` are accessed at runtime. For example, to swap in reverse order every other value in `x` with the first `N` elements of `y`, ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -107,7 +107,7 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. - **offsetY**: starting index for `y`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offsetX` and `offsetY` parameters support indexing semantics based on starting indices. For example, to swap every other value in `x` starting from the second value with the last `N` elements in `y` where `x[i] = y[n]`, `x[i+2] = y[n-1]`,..., +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the offset parameters support indexing semantics based on starting indices. For example, to swap every other value in `x` starting from the second value with the last `N` elements in `y` where `x[i] = y[n]`, `x[i+2] = y[n-1]`,..., ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -142,22 +142,14 @@ dswap.ndarray( 3, x, 2, 1, y, -1, y.length-1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var dswap = require( '@stdlib/blas/base/dswap' ); -var x; -var y; -var i; - -x = new Float64Array( 10 ); -y = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*500.0 ); - y[ i ] = round( randu()*255.0 ); -} +var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 500 ) ); console.log( x ); + +var y = filledarrayBy( x.length, 'float64', discreteUniform( 0, 255 ) ); console.log( y ); // Swap elements in `x` and `y` starting from the end of `y`: From ca2c127c245f2287d58df93c4cdfeec1a41f9235 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 17 Jan 2023 10:46:33 +0530 Subject: [PATCH 02/10] refactor src/ --- .../@stdlib/blas/base/dswap/src/addon.c | 47 ++++++ .../@stdlib/blas/base/dswap/src/addon.cpp | 151 ------------------ 2 files changed, 47 insertions(+), 151 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/dswap/src/addon.c delete mode 100644 lib/node_modules/@stdlib/blas/base/dswap/src/addon.cpp diff --git a/lib/node_modules/@stdlib/blas/base/dswap/src/addon.c b/lib/node_modules/@stdlib/blas/base/dswap/src/addon.c new file mode 100644 index 000000000000..0488de495bc0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dswap/src/addon.c @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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/base/dswap.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_double.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_float64array.h" +#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, 5 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 4 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 3 ); + c_dswap( N, (double *)X, strideX, (double *)Y, strideY ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/base/dswap/src/addon.cpp b/lib/node_modules/@stdlib/blas/base/dswap/src/addon.cpp deleted file mode 100644 index c633b2176719..000000000000 --- a/lib/node_modules/@stdlib/blas/base/dswap/src/addon.cpp +++ /dev/null @@ -1,151 +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/base/dswap.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_base_dswap { - - /** - * Interchanges two double-precision floating-point vectors. - * - * ## Notes - * - * - When called from JavaScript, the function expects five arguments: - * - * - `N`: number of indexed elements - * - `X`: input array - * - `strideX`: `X` stride length - * - `Y`: destination array - * - `strideY`: `Y` stride length - */ - napi_value node_dswap( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 5; - napi_value argv[ 5 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 5 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 5 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 res1; - status = napi_is_typedarray( env, argv[ 1 ], &res1 ); - assert( status == napi_ok ); - if ( res1 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float64Array." ); - 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; - } - - bool res3; - status = napi_is_typedarray( env, argv[ 3 ], &res3 ); - assert( status == napi_ok ); - if ( res3 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a Float64Array." ); - return nullptr; - } - - napi_valuetype vtype4; - status = napi_typeof( env, argv[ 4 ], &vtype4 ); - assert( status == napi_ok ); - if ( vtype4 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fifth 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 strideX; - status = napi_get_value_int64( env, argv[ 2 ], &strideX ); - assert( status == napi_ok ); - - int64_t strideY; - status = napi_get_value_int64( env, argv[ 4 ], &strideY ); - 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_float64_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float64Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideX) >= (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_typedarray_type vtype3; - size_t ylen; - void *Y; - status = napi_get_typedarray_info( env, argv[ 3 ], &vtype3, &ylen, &Y, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype3 != napi_float64_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a Float64Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideY) >= (int64_t)ylen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Fourth argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - c_dswap( N, (double *)X, strideX, (double *)Y, strideY ); - - return nullptr; - } - - 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_dswap, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_base_dswap From c2f56eba8a2eb7283f4a7adbb2e1c545e34f1623 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 17 Jan 2023 10:47:59 +0530 Subject: [PATCH 03/10] update include.gypi --- lib/node_modules/@stdlib/blas/base/dswap/include.gypi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dswap/include.gypi b/lib/node_modules/@stdlib/blas/base/dswap/include.gypi index 22e6289c74db..f8b01bfb52cb 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/include.gypi +++ b/lib/node_modules/@stdlib/blas/base/dswap/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2018 The Stdlib Authors. +# Copyright (c) 2023 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. @@ -52,7 +52,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' Date: Tue, 17 Jan 2023 10:50:39 +0530 Subject: [PATCH 04/10] update manifest.json --- .../@stdlib/blas/base/dswap/manifest.json | 48 ++++++++++++++++--- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dswap/manifest.json b/lib/node_modules/@stdlib/blas/base/dswap/manifest.json index 77efcac83cc0..eab36453f899 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dswap/manifest.json @@ -38,7 +38,13 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] }, { "os": "linux", @@ -54,7 +60,13 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] }, { "os": "mac", @@ -68,7 +80,13 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] }, { "os": "mac", @@ -83,7 +101,13 @@ "-lblas" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] }, { "os": "mac", @@ -99,7 +123,13 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] }, { "os": "win", @@ -112,7 +142,13 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] } ] } From 17273cc431aeb51a2ce8b756d783b644cb556b16 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 17 Jan 2023 10:51:38 +0530 Subject: [PATCH 05/10] update package.json --- lib/node_modules/@stdlib/blas/base/dswap/package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dswap/package.json b/lib/node_modules/@stdlib/blas/base/dswap/package.json index a7d9096b737a..e5f3b330ddcb 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/package.json +++ b/lib/node_modules/@stdlib/blas/base/dswap/package.json @@ -73,5 +73,7 @@ "float64array", "typed array" ], - "__stdlib__": {} + "__stdlib__": { + "wasm": false + } } From d5ca7f399f2464fa76d4c0cc63db207d2400f1b7 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 17 Jan 2023 15:41:47 +0530 Subject: [PATCH 06/10] refactor lib --- .../blas/base/dswap/lib/ndarray.native.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dswap/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dswap/lib/ndarray.native.js index 3bcf7bc09ff2..e846fb5dd79a 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/lib/ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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. @@ -20,7 +20,8 @@ // MODULES // -var Float64Array = require( '@stdlib/array/float64' ); +var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); +var offsetView = require( '@stdlib/strided/base/offset-view' ); var addon = require( './dswap.native.js' ); @@ -51,14 +52,13 @@ var addon = require( './dswap.native.js' ); function dswap( N, x, strideX, offsetX, y, strideY, offsetY ) { var viewX; var viewY; - if ( strideX < 0 ) { - offsetX += (N-1) * strideX; - } - if ( strideY < 0 ) { - offsetY += (N-1) * strideY; - } - viewX = new Float64Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offsetX), x.length-offsetX ); // eslint-disable-line max-len - viewY = new Float64Array( y.buffer, y.byteOffset+(y.BYTES_PER_ELEMENT*offsetY), y.length-offsetY ); // eslint-disable-line max-len + + offsetX = minViewBufferIndex( N, strideX, offsetX ); + offsetY = minViewBufferIndex( N, strideY, offsetY ); + + viewX = offsetView( x, offsetX ); + viewY = offsetView( y, offsetY ); + addon( N, viewX, strideX, viewY, strideY ); return y; } From d44d3d8d0064751f2e6cb2b0b6fa91263c29f760 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 17 Jan 2023 15:49:15 +0530 Subject: [PATCH 07/10] refactor benchmarks --- .../blas/base/dswap/benchmark/benchmark.js | 22 +++++++++---------- .../base/dswap/benchmark/benchmark.native.js | 18 +++++---------- .../base/dswap/benchmark/benchmark.ndarray.js | 22 +++++++++---------- .../benchmark/benchmark.ndarray.native.js | 18 +++++---------- .../@stdlib/blas/base/dswap/examples/index.js | 20 +++++------------ 5 files changed, 38 insertions(+), 62 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.js index 053836f19eb7..cedb75b7f848 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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 Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var dswap = require( './../lib/dswap.js' ); +// VARIABLES // + +var rand = uniform( -10000.0, 10000.0 ); + + // FUNCTIONS // /** @@ -39,15 +44,8 @@ var dswap = require( './../lib/dswap.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float64Array( len ); - y = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20000.0 ) - 10000.0; - } + var x = filledarrayBy( len, 'float64', rand ); + var y = filledarrayBy( len, 'float64', rand ); return benchmark; /** diff --git a/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.native.js index 018b566d92fd..464aeacdf50b 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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 Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var dswap = tryRequire( resolve( __dirname, './../lib/dswap.native.js' ) ); var opts = { 'skip': ( dswap instanceof Error ) }; +var rand = uniform( -10000.0, 10000.0 ); // FUNCTIONS // @@ -48,15 +49,8 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float64Array( len ); - y = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20000.0 ) - 10000.0; - } + var x = filledarrayBy( len, 'float64', rand ); + var y = filledarrayBy( len, 'float64', rand ); return benchmark; /** diff --git a/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.ndarray.js index 833a5558880a..199659eb67bb 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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 Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var dswap = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -10000.0, 10000.0 ); + + // FUNCTIONS // /** @@ -39,15 +44,8 @@ var dswap = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float64Array( len ); - y = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20000.0 ) - 10000.0; - } + var x = filledarrayBy( len, 'float64', rand ); + var y = filledarrayBy( len, 'float64', rand ); return benchmark; /** diff --git a/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.ndarray.native.js index 24c498b2a74e..78bc9861acf7 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/benchmark/benchmark.ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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 Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var dswap = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( dswap instanceof Error ) }; +var rand = uniform( -10000.0, 10000.0 ); // FUNCTIONS // @@ -48,15 +49,8 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float64Array( len ); - y = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20000.0 ) - 10000.0; - } + var x = filledarrayBy( len, 'float64', rand ); + var y = filledarrayBy( len, 'float64', rand ); return benchmark; /** diff --git a/lib/node_modules/@stdlib/blas/base/dswap/examples/index.js b/lib/node_modules/@stdlib/blas/base/dswap/examples/index.js index eb7aed132637..d024a85fb7d0 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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,22 +18,14 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var dswap = require( './../lib' ); -var x; -var y; -var i; - -x = new Float64Array( 10 ); -y = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*500.0 ); - y[ i ] = round( randu()*255.0 ); -} +var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 500 ) ); console.log( x ); + +var y = filledarrayBy( x.length, 'float64', discreteUniform( 0, 255 ) ); console.log( y ); // Swap elements in `x` and `y` starting from the end of `y`: From 154a7fa67d4adc7aae8ebe6ac0433f6a5aa9d2aa Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 17 Jan 2023 15:54:49 +0530 Subject: [PATCH 08/10] refactor tests --- .../blas/base/dswap/test/test.dswap.js | 41 +++++++++--------- .../blas/base/dswap/test/test.dswap.native.js | 41 +++++++++--------- .../blas/base/dswap/test/test.ndarray.js | 42 +++++++++---------- .../base/dswap/test/test.ndarray.native.js | 42 +++++++++---------- 4 files changed, 82 insertions(+), 84 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dswap/test/test.dswap.js b/lib/node_modules/@stdlib/blas/base/dswap/test/test.dswap.js index 9f988d3a31df..c9bd1ae13de3 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/test/test.dswap.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/test/test.dswap.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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 Float64Array = require( '@stdlib/array/float64' ); var dcopy = require( '@stdlib/blas/base/dcopy' ); var dswap = require( './../lib/dswap.js' ); @@ -57,10 +56,10 @@ tape( 'the function interchanges vectors `x` and `y`', function test( t ) { dswap( x.length, x, 1, y, 1 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); @@ -74,10 +73,10 @@ tape( 'the function interchanges vectors `x` and `y`', function test( t ) { dswap( x.length, x, 1, y, 1 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); t.end(); @@ -111,8 +110,8 @@ tape( 'the function supports an `x` stride', function test( t ) { xe = new Float64Array( [ 6.0, 2.0, 7.0, 4.0, 8.0 ] ); ye = new Float64Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -144,8 +143,8 @@ tape( 'the function supports a `y` stride', function test( t ) { xe = new Float64Array( [ 6.0, 8.0, 10.0, 4.0, 5.0 ] ); ye = new Float64Array( [ 1.0, 7.0, 2.0, 9.0, 3.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -217,8 +216,8 @@ tape( 'the function supports negative strides', function test( t ) { xe = new Float64Array( [ 6.0, 2.0, 7.0, 4.0, 8.0 ] ); ye = new Float64Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -252,8 +251,8 @@ tape( 'the function supports complex access patterns', function test( t ) { xe = new Float64Array( [ 9.0, 2.0, 8.0, 4.0, 7.0, 6.0 ] ); ye = new Float64Array( [ 5.0, 3.0, 1.0, 10.0, 11.0, 12.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -288,15 +287,15 @@ tape( 'the function supports view offsets', function test( t ) { x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); + N = 3; dswap( N, x1, -2, y1, 1 ); xe = new Float64Array( [ 1.0, 12.0, 3.0, 11.0, 5.0, 10.0 ] ); ye = new Float64Array( [ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ] ); - t.deepEqual( x0, xe, 'deep equal' ); - t.deepEqual( y0, ye, 'deep equal' ); + t.deepEqual( x0, xe, 'returns expected value' ); + t.deepEqual( y0, ye, 'returns expected value' ); t.end(); }); @@ -321,10 +320,10 @@ tape( 'if both strides are equal to `1`, the function efficiently swaps elements dswap( x.length, x, 1, y, 1 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); x = new Float64Array( 120 ); @@ -341,10 +340,10 @@ tape( 'if both strides are equal to `1`, the function efficiently swaps elements dswap( x.length, x, 1, y, 1 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/base/dswap/test/test.dswap.native.js b/lib/node_modules/@stdlib/blas/base/dswap/test/test.dswap.native.js index 5908f99d2482..22c475f3e813 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/test/test.dswap.native.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/test/test.dswap.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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 Float64Array = require( '@stdlib/array/float64' ); var dcopy = require( '@stdlib/blas/base/dcopy' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -66,10 +65,10 @@ tape( 'the function interchanges vectors `x` and `y`', opts, function test( t ) dswap( x.length, x, 1, y, 1 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); @@ -83,10 +82,10 @@ tape( 'the function interchanges vectors `x` and `y`', opts, function test( t ) dswap( x.length, x, 1, y, 1 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); t.end(); @@ -120,8 +119,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { xe = new Float64Array( [ 6.0, 2.0, 7.0, 4.0, 8.0 ] ); ye = new Float64Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -153,8 +152,8 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { xe = new Float64Array( [ 6.0, 8.0, 10.0, 4.0, 5.0 ] ); ye = new Float64Array( [ 1.0, 7.0, 2.0, 9.0, 3.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -226,8 +225,8 @@ tape( 'the function supports negative strides', opts, function test( t ) { xe = new Float64Array( [ 6.0, 2.0, 7.0, 4.0, 8.0 ] ); ye = new Float64Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -261,8 +260,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) xe = new Float64Array( [ 9.0, 2.0, 8.0, 4.0, 7.0, 6.0 ] ); ye = new Float64Array( [ 5.0, 3.0, 1.0, 10.0, 11.0, 12.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -297,15 +296,15 @@ tape( 'the function supports view offsets', opts, function test( t ) { x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); + N = 3; dswap( N, x1, -2, y1, 1 ); xe = new Float64Array( [ 1.0, 12.0, 3.0, 11.0, 5.0, 10.0 ] ); ye = new Float64Array( [ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ] ); - t.deepEqual( x0, xe, 'deep equal' ); - t.deepEqual( y0, ye, 'deep equal' ); + t.deepEqual( x0, xe, 'returns expected value' ); + t.deepEqual( y0, ye, 'returns expected value' ); t.end(); }); @@ -330,10 +329,10 @@ tape( 'if both strides are equal to `1`, the function efficiently swaps elements dswap( x.length, x, 1, y, 1 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); x = new Float64Array( 120 ); @@ -350,10 +349,10 @@ tape( 'if both strides are equal to `1`, the function efficiently swaps elements dswap( x.length, x, 1, y, 1 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/base/dswap/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dswap/test/test.ndarray.js index 43676e4a5087..1cd523415611 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/test/test.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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,10 +56,10 @@ tape( 'the function interchanges vectors `x` and `y`', function test( t ) { dswap( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); @@ -73,10 +73,10 @@ tape( 'the function interchanges vectors `x` and `y`', function test( t ) { dswap( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); t.end(); @@ -110,8 +110,8 @@ tape( 'the function supports an `x` stride', function test( t ) { xe = new Float64Array( [ 6.0, 2.0, 7.0, 4.0, 8.0 ] ); ye = new Float64Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -143,8 +143,8 @@ tape( 'the function supports an `x` offset', function test( t ) { xe = new Float64Array( [ 1.0, 2.0, 6.0, 7.0, 8.0 ] ); ye = new Float64Array( [ 3.0, 4.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -176,8 +176,8 @@ tape( 'the function supports a `y` stride', function test( t ) { xe = new Float64Array( [ 6.0, 8.0, 10.0, 4.0, 5.0 ] ); ye = new Float64Array( [ 1.0, 7.0, 2.0, 9.0, 3.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -209,8 +209,8 @@ tape( 'the function supports a `y` offset', function test( t ) { xe = new Float64Array( [ 8.0, 9.0, 10.0, 4.0, 5.0 ] ); ye = new Float64Array( [ 6.0, 7.0, 1.0, 2.0, 3.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -282,8 +282,8 @@ tape( 'the function supports negative strides', function test( t ) { xe = new Float64Array( [ 7.0, 2.0, 8.0, 4.0, 9.0 ] ); ye = new Float64Array( [ 6.0, 1.0, 3.0, 5.0, 10.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -317,8 +317,8 @@ tape( 'the function supports complex access patterns', function test( t ) { xe = new Float64Array( [ 1.0, 12.0, 3.0, 11.0, 5.0, 10.0 ] ); ye = new Float64Array( [ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -343,10 +343,10 @@ tape( 'if both strides are equal to `1`, the function efficiently swaps elements dswap( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); x = new Float64Array( 120 ); @@ -363,10 +363,10 @@ tape( 'if both strides are equal to `1`, the function efficiently swaps elements dswap( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/base/dswap/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dswap/test/test.ndarray.native.js index 7db01a0f96e3..7d4778ce382d 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/test/test.ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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. @@ -65,10 +65,10 @@ tape( 'the function interchanges vectors `x` and `y`', opts, function test( t ) dswap( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); @@ -82,10 +82,10 @@ tape( 'the function interchanges vectors `x` and `y`', opts, function test( t ) dswap( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); t.end(); @@ -119,8 +119,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { xe = new Float64Array( [ 6.0, 2.0, 7.0, 4.0, 8.0 ] ); ye = new Float64Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -152,8 +152,8 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { xe = new Float64Array( [ 1.0, 2.0, 6.0, 7.0, 8.0 ] ); ye = new Float64Array( [ 3.0, 4.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -185,8 +185,8 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { xe = new Float64Array( [ 6.0, 8.0, 10.0, 4.0, 5.0 ] ); ye = new Float64Array( [ 1.0, 7.0, 2.0, 9.0, 3.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -218,8 +218,8 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { xe = new Float64Array( [ 8.0, 9.0, 10.0, 4.0, 5.0 ] ); ye = new Float64Array( [ 6.0, 7.0, 1.0, 2.0, 3.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -291,8 +291,8 @@ tape( 'the function supports negative strides', opts, function test( t ) { xe = new Float64Array( [ 7.0, 2.0, 8.0, 4.0, 9.0 ] ); ye = new Float64Array( [ 6.0, 1.0, 3.0, 5.0, 10.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -326,8 +326,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) xe = new Float64Array( [ 1.0, 12.0, 3.0, 11.0, 5.0, 10.0 ] ); ye = new Float64Array( [ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ] ); - t.deepEqual( x, xe, 'deep equal' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); t.end(); }); @@ -352,10 +352,10 @@ tape( 'if both strides are equal to `1`, the function efficiently swaps elements dswap( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); x = new Float64Array( 120 ); @@ -372,10 +372,10 @@ tape( 'if both strides are equal to `1`, the function efficiently swaps elements dswap( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( x, xe, 'deep equal' ); + t.deepEqual( x, xe, 'returns expected value' ); t.notEqual( x, xe, 'different references' ); - t.deepEqual( y, ye, 'deep equal' ); + t.deepEqual( y, ye, 'returns expected value' ); t.notEqual( y, ye, 'different references' ); t.end(); From ec065a987f2040f2b2fa8025c455ca5508493dc9 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 17 Jan 2023 15:58:07 +0530 Subject: [PATCH 09/10] update docs --- .../@stdlib/blas/base/dswap/docs/repl.txt | 21 ++++++++----------- .../blas/base/dswap/docs/types/index.d.ts | 6 +++--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dswap/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dswap/docs/repl.txt index ebd7b1504957..ebc2f4c9ac4a 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/dswap/docs/repl.txt @@ -2,7 +2,7 @@ {{alias}}( N, x, strideX, y, strideY ) Interchanges two double-precision floating-point vectors. - The `N` and `stride` parameters determine how values from `x` are swapped + The `N` and stride parameters determine how values from `x` are swapped with values from `y`. Indexing is relative to the first index. To introduce an offset, use typed @@ -13,7 +13,7 @@ Parameters ---------- N: integer - Number of values to swap. + Number of values. x: Float64Array First input array. @@ -30,7 +30,7 @@ Returns ------- y: Float64Array - Input array `y`. + Second input array. Examples -------- @@ -43,8 +43,7 @@ // Advanced indexing: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float64}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}( N, x, -2, y, 1 ) + > {{alias}}( 3, x, -2, y, 1 ) [ 5.0, 3.0, 1.0, 10.0, 11.0, 12.0 ] // Using typed array views: @@ -52,8 +51,7 @@ > var y0 = new {{alias:@stdlib/array/float64}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > {{alias}}( N, x1, -2, y1, 1 ) + > {{alias}}( 3, x1, -2, y1, 1 ) [ 6.0, 4.0, 2.0 ] > y0 [ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ] @@ -64,13 +62,13 @@ indexing semantics. While typed array views mandate a view offset based on the underlying - buffer, the `offset` parameters support indexing semantics based on starting + buffer, the offset parameters support indexing semantics based on starting indices. Parameters ---------- N: integer - Number of values to swap. + Number of values. x: Float64Array First input array. @@ -93,7 +91,7 @@ Returns ------- y: Float64Array - Input array `y`. + Second input array. Examples -------- @@ -106,8 +104,7 @@ // Advanced indexing: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float64}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1, y, -1, y.length-1 ) + > {{alias}}.ndarray( 3, x, 2, 1, y, -1, y.length-1 ) [ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ] See Also diff --git a/lib/node_modules/@stdlib/blas/base/dswap/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dswap/docs/types/index.d.ts index 8755fb6e3095..494327e47a47 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/dswap/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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. @@ -25,7 +25,7 @@ interface Routine { /** * Interchanges two double-precision floating-point vectors. * - * @param N - number of values to swap + * @param N - number of values * @param x - first input array * @param strideX - `x` stride length * @param y - second input array @@ -47,7 +47,7 @@ interface Routine { /** * Interchanges two double-precision floating-point vectors using alternative indexing semantics. * - * @param N - number of values to swap + * @param N - number of values * @param x - first input array * @param strideX - `x` stride length * @param offsetX - starting index for `x` From 8e9c1704f94aa50a25e9f90eb295a998952e1a0d Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 18 Jan 2023 00:12:25 +0530 Subject: [PATCH 10/10] remove to swap and unnecessary dependencies --- lib/node_modules/@stdlib/blas/base/dswap/lib/dswap.js | 4 ++-- .../@stdlib/blas/base/dswap/lib/dswap.native.js | 4 ++-- lib/node_modules/@stdlib/blas/base/dswap/lib/ndarray.js | 4 ++-- .../@stdlib/blas/base/dswap/lib/ndarray.native.js | 2 +- lib/node_modules/@stdlib/blas/base/dswap/manifest.json | 6 ------ lib/node_modules/@stdlib/blas/base/dswap/src/addon.c | 1 - lib/node_modules/@stdlib/blas/base/dswap/src/dswap_cblas.c | 4 ++-- 7 files changed, 9 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dswap/lib/dswap.js b/lib/node_modules/@stdlib/blas/base/dswap/lib/dswap.js index a418d228d832..ad891ba601a6 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/lib/dswap.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/lib/dswap.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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. @@ -28,7 +28,7 @@ var M = 3; /** * Interchanges two double-precision floating-point vectors. * -* @param {PositiveInteger} N - number of values to swap +* @param {PositiveInteger} N - number of values * @param {Float64Array} x - first input array * @param {integer} strideX - `x` stride length * @param {Float64Array} y - second input array diff --git a/lib/node_modules/@stdlib/blas/base/dswap/lib/dswap.native.js b/lib/node_modules/@stdlib/blas/base/dswap/lib/dswap.native.js index 378b4c33ac22..fed09615141e 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/lib/dswap.native.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/lib/dswap.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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. @@ -28,7 +28,7 @@ var addon = require( './../src/addon.node' ); /** * Interchanges two double-precision floating-point vectors. * -* @param {PositiveInteger} N - number of values to swap +* @param {PositiveInteger} N - number of values * @param {Float64Array} x - first input array * @param {integer} strideX - `x` stride length * @param {Float64Array} y - second input array diff --git a/lib/node_modules/@stdlib/blas/base/dswap/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dswap/lib/ndarray.js index d57e384b8660..e19f9556d0cc 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/lib/ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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. @@ -28,7 +28,7 @@ var M = 3; /** * Interchanges two double-precision floating-point vectors. * -* @param {PositiveInteger} N - number of values to swap +* @param {PositiveInteger} N - number of values * @param {Float64Array} x - first input array * @param {integer} strideX - `x` stride length * @param {NonNegativeInteger} offsetX - starting `x` index diff --git a/lib/node_modules/@stdlib/blas/base/dswap/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dswap/lib/ndarray.native.js index e846fb5dd79a..232b306fcaa4 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dswap/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './dswap.native.js' ); /** * Interchanges two double-precision floating-point vectors. * -* @param {PositiveInteger} N - number of values to swap +* @param {PositiveInteger} N - number of values * @param {Float64Array} x - first input array * @param {integer} strideX - `x` stride length * @param {NonNegativeInteger} offsetX - starting `x` index diff --git a/lib/node_modules/@stdlib/blas/base/dswap/manifest.json b/lib/node_modules/@stdlib/blas/base/dswap/manifest.json index eab36453f899..dcaafd461711 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dswap/manifest.json @@ -41,7 +41,6 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float64array" ] @@ -63,7 +62,6 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float64array" ] @@ -83,7 +81,6 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float64array" ] @@ -104,7 +101,6 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float64array" ] @@ -126,7 +122,6 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float64array" ] @@ -145,7 +140,6 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float64array" ] diff --git a/lib/node_modules/@stdlib/blas/base/dswap/src/addon.c b/lib/node_modules/@stdlib/blas/base/dswap/src/addon.c index 0488de495bc0..cd4e61ca04ff 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/dswap/src/addon.c @@ -20,7 +20,6 @@ #include "stdlib/blas/base/dswap.h" #include "stdlib/napi/export.h" #include "stdlib/napi/argv.h" -#include "stdlib/napi/argv_double.h" #include "stdlib/napi/argv_int64.h" #include "stdlib/napi/argv_strided_float64array.h" #include diff --git a/lib/node_modules/@stdlib/blas/base/dswap/src/dswap_cblas.c b/lib/node_modules/@stdlib/blas/base/dswap/src/dswap_cblas.c index a554cabdfedb..cb53c04b39ff 100644 --- a/lib/node_modules/@stdlib/blas/base/dswap/src/dswap_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/dswap/src/dswap_cblas.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 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,7 @@ /** * Interchanges two double-precision floating-point vectors. * -* @param N number of elements to swap +* @param N number of elements * @param X first input array * @param strideX X stride length * @param Y second input array