diff --git a/lib/node_modules/@stdlib/blas/base/scopy/README.md b/lib/node_modules/@stdlib/blas/base/scopy/README.md index 8277c35a1fd8..b8e4fbcdab89 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/README.md +++ b/lib/node_modules/@stdlib/blas/base/scopy/README.md @@ -2,7 +2,7 @@ @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,18 +52,15 @@ The function has the following parameters: - **y**: destination [`Float32Array`][mdn-float32array]. - **strideY**: index increment for `y`. -The `N` and `stride` parameters determine how values from `x` are copied into `y`. For example, to copy in reverse order every other value in `x` into the first `N` elements of `y`, +The `N` and stride parameters determine how values from `x` are copied into `y`. For example, to copy in reverse order every other value in `x` into the first `N` elements of `y`, ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var y = new Float32Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -var N = floor( x.length / 2 ); - -scopy( N, x, -2, y, 1 ); +scopy( 3, x, -2, y, 1 ); // y => [ 5.0, 3.0, 1.0, 10.0, 11.0, 12.0 ] ``` @@ -73,7 +70,6 @@ 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' ); // Initial arrays... var x0 = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); @@ -83,10 +79,8 @@ var y0 = new Float32Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // start at 4th element -var N = floor( x0.length / 2 ); - // Copy in reverse order every other value from `x1` into `y1`... -scopy( N, x1, -2, y1, 1 ); +scopy( 3, x1, -2, y1, 1 ); // y0 => [ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ] ``` @@ -109,18 +103,15 @@ 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 copy every other value in `x` starting from the second value into 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 copy every other value in `x` starting from the second value into the last `N` elements in `y` where `x[i] = y[n]`, `x[i+2] = y[n-1]`,..., ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var y = new Float32Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -var N = floor( x.length / 2 ); - -scopy.ndarray( N, x, 2, 1, y, -1, y.length-1 ); +scopy.ndarray( 3, x, 2, 1, y, -1, y.length-1 ); // y => [ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ] ``` @@ -146,22 +137,14 @@ scopy.ndarray( N, 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 Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var scopy = require( '@stdlib/blas/base/scopy' ); -var x; -var y; -var i; - -x = new Float32Array( 10 ); -y = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*500.0 ); - y[ i ] = -1.0; -} +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 500 ) ); console.log( x ); + +var y = filledarrayBy( x.length, 'float32', discreteUniform( 0, 255 ) ); console.log( y ); // Copy elements from `x` into `y` starting from the end of `y`: diff --git a/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.js index a9320b98c148..3230fbfde93a 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @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. @@ -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 scopy = require( './../lib/scopy.js' ); +// VARIABLES // + +var rand = uniform( -10000.0, 10000.0 ); + + // FUNCTIONS // /** @@ -39,15 +44,8 @@ var scopy = require( './../lib/scopy.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20000.0 ) - 10000.0; - } + var x = filledarrayBy( len, 'float32', rand ); + var y = filledarrayBy( len, 'float32', rand ); return benchmark; /** diff --git a/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.native.js index 53685fbd18ed..f43fa5ef161f 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @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. @@ -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 scopy = tryRequire( resolve( __dirname, './../lib/scopy.native.js' ) ); var opts = { 'skip': ( scopy 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 Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20000.0 ) - 10000.0; - } + var x = filledarrayBy( len, 'float32', rand ); + var y = filledarrayBy( len, 'float32', rand ); return benchmark; /** diff --git a/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.ndarray.js index f1ea8622b005..aa041ae15c27 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @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. @@ -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 scopy = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -10000.0, 10000.0 ); + + // FUNCTIONS // /** @@ -39,15 +44,8 @@ var scopy = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20000.0 ) - 10000.0; - } + var x = filledarrayBy( len, 'float32', rand ); + var y = filledarrayBy( len, 'float32', rand ); return benchmark; /** diff --git a/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.ndarray.native.js index 1638d6384c22..b7dbd0929937 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/scopy/benchmark/benchmark.ndarray.native.js @@ -1,7 +1,7 @@ /** * @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. @@ -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 scopy = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( scopy instanceof Error ) }; +var randu = 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 Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20000.0 ) - 10000.0; - } + var x = filledarrayBy( len, 'float32', randu ); + var y = filledarrayBy( len, 'float32', randu ); return benchmark; /** diff --git a/lib/node_modules/@stdlib/blas/base/scopy/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/scopy/docs/repl.txt index 90d2338fedfe..7f82450b71d3 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/scopy/docs/repl.txt @@ -2,7 +2,7 @@ {{alias}}( N, x, strideX, y, strideY ) Copies values from `x` into `y`. - The `N` and `stride` parameters determine how values from `x` are copied + The `N` and stride parameters determine how values from `x` are copied into `y`. Indexing is relative to the first index. To introduce an offset, use typed @@ -22,7 +22,7 @@ Index increment for `x`. y: Float32Array - Destination array. + Output array. strideY: integer Index increment for `y`. @@ -30,7 +30,7 @@ Returns ------- y: Float32Array - Input array `y`. + Output array. Examples -------- @@ -43,8 +43,7 @@ // Advanced indexing: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float32}}( [ 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/float32}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var y1 = new {{alias:@stdlib/array/float32}}( 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 ] @@ -81,7 +79,7 @@ Starting index for `x`. y: Float32Array - Destination array. + Output array. strideY: integer Index increment for `y`. @@ -92,7 +90,7 @@ Returns ------- y: Float32Array - Input array `y`. + Output array. Examples -------- @@ -105,8 +103,7 @@ // Advanced indexing: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float32}}( [ 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/scopy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/scopy/docs/types/index.d.ts index 56d97de082f8..de176e664c64 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/scopy/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,12 +25,12 @@ interface Routine { /** * Copies values from `x` into `y`. * - * @param N - number of values to copy + * @param N - number of values * @param x - input array * @param strideX - `x` stride length - * @param y - destination array + * @param y - output array * @param strideY - `y` stride length - * @returns `y` + * @returns output array * * @example * var Float32Array = require( `@stdlib/array/float32` ); @@ -46,14 +46,14 @@ interface Routine { /** * Copies values from `x` into `y` using alternative indexing semantics. * - * @param N - number of values to copy + * @param N - number of values * @param x - input array * @param strideX - `x` stride length * @param offsetX - starting index for `x` - * @param y - destination array + * @param y - output array * @param strideY - `y` stride length * @param offsetY - starting index for `y` - * @returns `y` + * @returns output array * * @example * var Float32Array = require( `@stdlib/array/float32` ); @@ -70,12 +70,12 @@ interface Routine { /** * Copies values from `x` into `y`. * -* @param N - number of values to copy +* @param N - number of values * @param x - input array * @param strideX - `x` stride length -* @param y - destination array +* @param y - output array * @param strideY - `y` stride length -* @returns `y` +* @returns output array * * @example * var Float32Array = require( `@stdlib/array/float32` ); diff --git a/lib/node_modules/@stdlib/blas/base/scopy/examples/index.js b/lib/node_modules/@stdlib/blas/base/scopy/examples/index.js index 6484e3eb9800..f2b8f5d121bd 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/scopy/examples/index.js @@ -1,7 +1,7 @@ /** * @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. @@ -18,22 +18,14 @@ '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 scopy = require( './../lib' ); -var x; -var y; -var i; - -x = new Float32Array( 10 ); -y = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*500.0 ); - y[ i ] = -1.0; -} +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 500 ) ); console.log( x ); + +var y = filledarrayBy( x.length, 'float32', discreteUniform( 0, 255 ) ); console.log( y ); // Copy elements from `x` into `y` starting from the end of `y`: diff --git a/lib/node_modules/@stdlib/blas/base/scopy/include.gypi b/lib/node_modules/@stdlib/blas/base/scopy/include.gypi index 22e6289c74db..f8b01bfb52cb 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/include.gypi +++ b/lib/node_modules/@stdlib/blas/base/scopy/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', ' + +/** +* 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_FLOAT32ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 3 ); + c_scopy( N, (float *)X, strideX, (float *)Y, strideY ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/base/scopy/src/addon.cpp b/lib/node_modules/@stdlib/blas/base/scopy/src/addon.cpp deleted file mode 100644 index 58fb9bd6a47c..000000000000 --- a/lib/node_modules/@stdlib/blas/base/scopy/src/addon.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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/scopy.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_base_scopy { - - /** - * Copies values from one single-precision floating-point vector to another single-precision floating-point vector. - * - * ## 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_scopy( 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 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; - } - - 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 Float32Array." ); - 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_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." ); - 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_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a Float32Array." ); - 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_scopy( N, (float *)X, strideX, (float *)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_scopy, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_base_scopy diff --git a/lib/node_modules/@stdlib/blas/base/scopy/src/scopy.c b/lib/node_modules/@stdlib/blas/base/scopy/src/scopy.c index c440118ce8a7..8e257597caa2 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/src/scopy.c +++ b/lib/node_modules/@stdlib/blas/base/scopy/src/scopy.c @@ -1,7 +1,7 @@ /** * @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. @@ -21,10 +21,10 @@ /** * Copies values from `X` into `Y`. * -* @param N number of elements to copy +* @param N number of elements * @param X input array * @param strideX X stride length -* @param Y destination array +* @param Y output array * @param strideY Y stride length */ void c_scopy( const int N, const float *X, const int strideX, float *Y, const int strideY ) { diff --git a/lib/node_modules/@stdlib/blas/base/scopy/src/scopy.f b/lib/node_modules/@stdlib/blas/base/scopy/src/scopy.f index 2f49fdd254dc..1b91c76e014e 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/src/scopy.f +++ b/lib/node_modules/@stdlib/blas/base/scopy/src/scopy.f @@ -47,10 +47,10 @@ ! > ! > * We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support. ! -! @param {integer} N - number of values to copy +! @param {integer} N - number of values ! @param {Array} sx - input array ! @param {integer} strideX - `sx` stride length -! @param {Array} sy - destination array +! @param {Array} sy - output array ! @param {integer} strideY - `sy` stride length !< subroutine scopy( N, sx, strideX, sy, strideY ) @@ -113,4 +113,4 @@ subroutine scopy( N, sx, strideX, sy, strideY ) end do end if return -end subroutine scopy \ No newline at end of file +end subroutine scopy diff --git a/lib/node_modules/@stdlib/blas/base/scopy/src/scopy_cblas.c b/lib/node_modules/@stdlib/blas/base/scopy/src/scopy_cblas.c index 4a5853605661..400a4fc901fb 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/src/scopy_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/scopy/src/scopy_cblas.c @@ -1,7 +1,7 @@ /** * @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. @@ -22,10 +22,10 @@ /** * Copies values from `X` into `Y`. * -* @param N number of elements to copy +* @param N number of elements * @param X input array * @param strideX X stride length -* @param Y destination array +* @param Y output array * @param strideY Y stride length */ void c_scopy( const int N, const float *X, const int strideX, float *Y, const int strideY ) { diff --git a/lib/node_modules/@stdlib/blas/base/scopy/src/scopy_f.c b/lib/node_modules/@stdlib/blas/base/scopy/src/scopy_f.c index a87237b745e6..dc7fd91254c7 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/src/scopy_f.c +++ b/lib/node_modules/@stdlib/blas/base/scopy/src/scopy_f.c @@ -24,10 +24,10 @@ * * Arguments are passed by reference to a Fortran subroutine implementing `scopy`. * -* @param N number of elements to copy +* @param N number of elements * @param X input array * @param strideX X stride length -* @param Y destination array +* @param Y output array * @param strideY Y stride length */ void c_scopy( const int N, const float *X, const int strideX, float *Y, const int strideY ) { diff --git a/lib/node_modules/@stdlib/blas/base/scopy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/scopy/test/test.ndarray.js index 4db432dde924..881436827366 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/scopy/test/test.ndarray.js @@ -1,7 +1,7 @@ /** * @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. @@ -44,7 +44,7 @@ tape( 'the function copies elements from `x` into `y`', function test( t ) { scopy( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, x, 'deep equal' ); + t.deepEqual( y, x, 'returns expected value' ); t.notEqual( y, x, 'different references' ); t.end(); @@ -76,7 +76,7 @@ tape( 'the function supports an `x` stride', function test( t ) { expected = new Float32Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -106,7 +106,7 @@ tape( 'the function supports an `x` offset', function test( t ) { expected = new Float32Array( [ 3.0, 4.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -136,7 +136,7 @@ tape( 'the function supports a `y` stride', function test( t ) { expected = new Float32Array( [ 1.0, 7.0, 2.0, 9.0, 3.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -166,11 +166,11 @@ tape( 'the function supports a `y` offset', function test( t ) { expected = new Float32Array( [ 6.0, 7.0, 1.0, 2.0, 3.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns a reference to the destination array', function test( t ) { +tape( 'the function returns a reference to the output array', function test( t ) { var out; var x; var y; @@ -184,7 +184,7 @@ tape( 'the function returns a reference to the destination array', function test t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the output array unchanged', function test( t ) { var expected; var x; var y; @@ -195,10 +195,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu expected = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); scopy( -1, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); scopy( 0, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -229,7 +229,7 @@ tape( 'the function supports negative strides', function test( t ) { expected = new Float32Array( [ 6.0, 1.0, 3.0, 5.0, 10.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -261,7 +261,7 @@ tape( 'the function supports complex access patterns', function test( t ) { expected = new Float32Array( [ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -279,7 +279,7 @@ tape( 'if both strides are equal to `1`, the function efficiently copies element scopy( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, x, 'deep equal' ); + t.deepEqual( y, x, 'returns expected value' ); t.notEqual( y, x, 'different references' ); x = new Float32Array( 120 ); @@ -291,7 +291,7 @@ tape( 'if both strides are equal to `1`, the function efficiently copies element scopy( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, x, 'deep equal' ); + t.deepEqual( y, x, 'returns expected value' ); t.notEqual( y, x, 'different references' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/base/scopy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/scopy/test/test.ndarray.native.js index 44b2751b62d6..fa74408623e1 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/scopy/test/test.ndarray.native.js @@ -1,7 +1,7 @@ /** * @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. @@ -53,7 +53,7 @@ tape( 'the function copies elements from `x` into `y`', opts, function test( t ) scopy( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, x, 'deep equal' ); + t.deepEqual( y, x, 'returns expected value' ); t.notEqual( y, x, 'different references' ); t.end(); @@ -85,7 +85,7 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { expected = new Float32Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -115,7 +115,7 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { expected = new Float32Array( [ 3.0, 4.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -145,7 +145,7 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { expected = new Float32Array( [ 1.0, 7.0, 2.0, 9.0, 3.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -175,11 +175,11 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { expected = new Float32Array( [ 6.0, 7.0, 1.0, 2.0, 3.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns a reference to the destination array', opts, function test( t ) { +tape( 'the function returns a reference to the output array', opts, function test( t ) { var out; var x; var y; @@ -193,7 +193,7 @@ tape( 'the function returns a reference to the destination array', opts, functio t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', opts, function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the output array unchanged', opts, function test( t ) { var expected; var x; var y; @@ -204,10 +204,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu expected = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); scopy( -1, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); scopy( 0, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -238,7 +238,7 @@ tape( 'the function supports negative strides', opts, function test( t ) { expected = new Float32Array( [ 6.0, 1.0, 3.0, 5.0, 10.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -270,7 +270,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) expected = new Float32Array( [ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -288,7 +288,7 @@ tape( 'if both strides are equal to `1`, the function efficiently copies element scopy( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, x, 'deep equal' ); + t.deepEqual( y, x, 'returns expected value' ); t.notEqual( y, x, 'different references' ); x = new Float32Array( 120 ); @@ -300,7 +300,7 @@ tape( 'if both strides are equal to `1`, the function efficiently copies element scopy( x.length, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, x, 'deep equal' ); + t.deepEqual( y, x, 'returns expected value' ); t.notEqual( y, x, 'different references' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/base/scopy/test/test.scopy.js b/lib/node_modules/@stdlib/blas/base/scopy/test/test.scopy.js index a73ba270ebda..f0157bb45189 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/test/test.scopy.js +++ b/lib/node_modules/@stdlib/blas/base/scopy/test/test.scopy.js @@ -1,7 +1,7 @@ /** * @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. @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var Float32Array = require( '@stdlib/array/float32' ); var scopy = require( './../lib/scopy.js' ); @@ -45,7 +44,7 @@ tape( 'the function copies elements from `x` into `y`', function test( t ) { scopy( x.length, x, 1, y, 1 ); - t.deepEqual( y, x, 'deep equal' ); + t.deepEqual( y, x, 'returns expected value' ); t.notEqual( y, x, 'different references' ); t.end(); @@ -77,7 +76,7 @@ tape( 'the function supports an `x` stride', function test( t ) { expected = new Float32Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -107,11 +106,11 @@ tape( 'the function supports a `y` stride', function test( t ) { expected = new Float32Array( [ 1, 7, 2, 9, 3 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns a reference to the destination array', function test( t ) { +tape( 'the function returns a reference to the output array', function test( t ) { var out; var x; var y; @@ -125,7 +124,7 @@ tape( 'the function returns a reference to the destination array', function test t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the output array unchanged', function test( t ) { var expected; var x; var y; @@ -170,7 +169,7 @@ tape( 'the function supports negative strides', function test( t ) { expected = new Float32Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -202,7 +201,7 @@ tape( 'the function supports complex access patterns', function test( t ) { expected = new Float32Array( [ 5.0, 3.0, 1.0, 10.0, 11.0, 12.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -236,12 +235,12 @@ tape( 'the function supports view offsets', function test( t ) { x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); + N = 3; scopy( N, x1, -2, y1, 1 ); expected = new Float32Array( [ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ] ); - t.deepEqual( y0, expected, 'deep equal' ); + t.deepEqual( y0, expected, 'returns expected value' ); t.end(); }); @@ -259,7 +258,7 @@ tape( 'if both strides are equal to `1`, the function efficiently copies element scopy( x.length, x, 1, y, 1 ); - t.deepEqual( y, x, 'deep equal' ); + t.deepEqual( y, x, 'returns expected value' ); t.notEqual( y, x, 'different references' ); x = new Float32Array( 120 ); @@ -271,7 +270,7 @@ tape( 'if both strides are equal to `1`, the function efficiently copies element scopy( x.length, x, 1, y, 1 ); - t.deepEqual( y, x, 'deep equal' ); + t.deepEqual( y, x, 'returns expected value' ); t.notEqual( y, x, 'different references' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/base/scopy/test/test.scopy.native.js b/lib/node_modules/@stdlib/blas/base/scopy/test/test.scopy.native.js index feefa0ef93a9..039e35b05f63 100644 --- a/lib/node_modules/@stdlib/blas/base/scopy/test/test.scopy.native.js +++ b/lib/node_modules/@stdlib/blas/base/scopy/test/test.scopy.native.js @@ -1,7 +1,7 @@ /** * @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. @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -54,7 +53,7 @@ tape( 'the function copies elements from `x` into `y`', opts, function test( t ) scopy( x.length, x, 1, y, 1 ); - t.deepEqual( y, x, 'deep equal' ); + t.deepEqual( y, x, 'returns expected value' ); t.notEqual( y, x, 'different references' ); t.end(); @@ -86,7 +85,7 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { expected = new Float32Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -116,11 +115,11 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { expected = new Float32Array( [ 1, 7, 2, 9, 3 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns a reference to the destination array', opts, function test( t ) { +tape( 'the function returns a reference to the output array', opts, function test( t ) { var out; var x; var y; @@ -134,7 +133,7 @@ tape( 'the function returns a reference to the destination array', opts, functio t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', opts, function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the output array unchanged', opts, function test( t ) { var expected; var x; var y; @@ -179,7 +178,7 @@ tape( 'the function supports negative strides', opts, function test( t ) { expected = new Float32Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -211,7 +210,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) expected = new Float32Array( [ 5.0, 3.0, 1.0, 10.0, 11.0, 12.0 ] ); - t.deepEqual( y, expected, 'deep equal' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -245,12 +244,12 @@ tape( 'the function supports view offsets', opts, function test( t ) { x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); + N = 3; scopy( N, x1, -2, y1, 1 ); expected = new Float32Array( [ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ] ); - t.deepEqual( y0, expected, 'deep equal' ); + t.deepEqual( y0, expected, 'returns expected value' ); t.end(); }); @@ -268,7 +267,7 @@ tape( 'if both strides are equal to `1`, the function efficiently copies element scopy( x.length, x, 1, y, 1 ); - t.deepEqual( y, x, 'deep equal' ); + t.deepEqual( y, x, 'returns expected value' ); t.notEqual( y, x, 'different references' ); x = new Float32Array( 120 ); @@ -280,7 +279,7 @@ tape( 'if both strides are equal to `1`, the function efficiently copies element scopy( x.length, x, 1, y, 1 ); - t.deepEqual( y, x, 'deep equal' ); + t.deepEqual( y, x, 'returns expected value' ); t.notEqual( y, x, 'different references' ); t.end();