From c768529c18d237ab75ffaef4f65651cf23dafc6e Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 12 Mar 2026 02:17:38 +0500 Subject: [PATCH 1/8] feat: add blas/ext/base/scopy-within --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../blas/ext/base/scopy-within/README.md | 303 ++++++++++++++++++ .../base/scopy-within/benchmark/benchmark.js | 103 ++++++ .../benchmark/benchmark.native.js | 108 +++++++ .../benchmark/benchmark.ndarray.js | 103 ++++++ .../benchmark/benchmark.ndarray.native.js | 108 +++++++ .../base/scopy-within/benchmark/c/Makefile | 146 +++++++++ .../benchmark/c/benchmark.length.c | 197 ++++++++++++ .../blas/ext/base/scopy-within/binding.gyp | 170 ++++++++++ .../blas/ext/base/scopy-within/docs/repl.txt | 110 +++++++ .../base/scopy-within/docs/types/index.d.ts | 101 ++++++ .../ext/base/scopy-within/docs/types/test.ts | 242 ++++++++++++++ .../ext/base/scopy-within/examples/c/Makefile | 146 +++++++++ .../base/scopy-within/examples/c/example.c | 39 +++ .../ext/base/scopy-within/examples/index.js | 35 ++ .../blas/ext/base/scopy-within/include.gypi | 53 +++ .../stdlib/blas/ext/base/scopy_within.h | 45 +++ .../blas/ext/base/scopy-within/lib/index.js | 68 ++++ .../blas/ext/base/scopy-within/lib/main.js | 35 ++ .../blas/ext/base/scopy-within/lib/native.js | 35 ++ .../blas/ext/base/scopy-within/lib/ndarray.js | 106 ++++++ .../base/scopy-within/lib/ndarray.native.js | 57 ++++ .../ext/base/scopy-within/lib/scopy_within.js | 55 ++++ .../scopy-within/lib/scopy_within.native.js | 56 ++++ .../blas/ext/base/scopy-within/manifest.json | 110 +++++++ .../blas/ext/base/scopy-within/package.json | 74 +++++ .../blas/ext/base/scopy-within/src/Makefile | 70 ++++ .../blas/ext/base/scopy-within/src/addon.c | 66 ++++ .../blas/ext/base/scopy-within/src/main.c | 114 +++++++ .../blas/ext/base/scopy-within/test/test.js | 82 +++++ .../base/scopy-within/test/test.ndarray.js | 199 ++++++++++++ .../scopy-within/test/test.ndarray.native.js | 210 ++++++++++++ .../scopy-within/test/test.scopy_within.js | 184 +++++++++++ .../test/test.scopy_within.native.js | 188 +++++++++++ 33 files changed, 3718 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/include/stdlib/blas/ext/base/scopy_within.h create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md new file mode 100644 index 000000000000..754f12df5e93 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md @@ -0,0 +1,303 @@ + + +# scopyWithin + +> Perform an in-place copy of elements within a single-precision floating-point array. + +
+ +## Usage + +```javascript +var scopyWithin = require( '@stdlib/blas/ext/base/scopy-within' ); +``` + +#### scopyWithin( N, target, start, end, x, strideX ) + +Performs an in-place copy of elements within a single-precision floating-point array. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +scopyWithin( x.length, 3, 1, 4, x, 1 ); +// x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **target**: target index. +- **start**: source start index. +- **end**: source end index. +- **x**: input [`Float32Array`][@stdlib/array/float32]. +- **strideX**: stride length. + +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to copy every other element: + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var x = new Float32Array( [ 1.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0 ] ); + +scopyWithin( 3, 0, 1, 6, x, 2 ); +// x => [ 3.0, 0.0, 5.0, 0.0, 7.0, 0.0, 7.0, 0.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +// Initial array... +var x0 = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +// Create an offset view... +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +// Copy within the view... +scopyWithin( 3, 0, 2, 5, x1, 1 ); +// x0 => [ 1.0, 4.0, 5.0, 6.0, 5.0, 6.0, 7.0, 8.0 ] +``` + +#### scopyWithin.ndarray( N, target, start, end, x, strideX, offsetX ) + +Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +scopyWithin.ndarray( x.length, 3, 1, 4, x, 1, 0 ); +// x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `x`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to copy elements starting from the second element: + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +scopyWithin.ndarray( 3, 2, 0, 3, x, 1, 2 ); +// x => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0, 8.0 ] +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions return the strided array unchanged. +- If `target >= N`, both functions return the strided array unchanged. +- Both functions **mutate** the provided input strided array. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var scopyWithin = require( '@stdlib/blas/ext/base/scopy-within' ); + +var x = discreteUniform( 10, 0, 500, { + 'dtype': 'float32' +}); +console.log( x ); + +// Copy the first 3 elements to positions 5, 6, 7: +scopyWithin( 10, 5, 0, 3, x, 1 ); +console.log( x ); + +// Copy every other element starting from the second element: +scopyWithin( 5, 0, 1, 9, x, 1 ); +console.log( x ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/ext/base/scopy_within.h" +``` + +#### stdlib_strided_scopy_within( N, target, start, end, \*x, strideX ) + +Performs an in-place copy of elements within a single-precision floating-point array. + +```c +float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; + +stdlib_strided_scopy_within( 6, 3, 1, 4, x, 1 ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **target**: `[in] CBLAS_INT` target index. +- **start**: `[in] CBLAS_INT` source start index. +- **end**: `[in] CBLAS_INT` source end index. +- **x**: `[inout] float*` input array. +- **strideX**: `[in] CBLAS_INT` stride length. + +```c +void stdlib_strided_scopy_within( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *x, const CBLAS_INT strideX ); +``` + + + +### stdlib_strided_scopy_within_ndarray( N, target, start, end, \*x, strideX, offsetX ) + + + +Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. + +```c +float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; + +stdlib_strided_scopy_within_ndarray( 4, 2, 0, 2, x, 1, 1 ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **target**: `[in] CBLAS_INT` target index. +- **start**: `[in] CBLAS_INT` source start index. +- **end**: `[in] CBLAS_INT` source end index. +- **x**: `[inout] float*` input array. +- **strideX**: `[in] CBLAS_INT` stride length. +- **offsetX**: `[in] CBLAS_INT` starting index. + +```c +void stdlib_strided_scopy_within_ndarray( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/ext/base/scopy_within.h" +#include + +int main( void ) { + // Create a strided array: + float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + + // Specify the number of elements to copy: + const int N = 8; + + // Specify a stride: + const int strideX = 1; + + // Copy elements starting from index 1 to index 4: + stdlib_strided_scopy_within( N, 4, 1, 4, x, strideX ); + + // Print the result: + for ( int i = 0; i < 8; i++ ) { + printf( "x[ %i ] = %f\n", i, x[ i ] ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js new file mode 100644 index 000000000000..a287df1c14e5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js @@ -0,0 +1,103 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var scopyWithin = require( './../lib/scopy_within.js' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = scopyWithin( len, 0, 0, len-1, x, 1 ); + if ( isnanf( y[ i%y.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( x[ i%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.native.js new file mode 100644 index 000000000000..d8523c859fd8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.native.js @@ -0,0 +1,108 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var scopyWithin = tryRequire( resolve( __dirname, './../lib/scopy_within.native.js' ) ); +var opts = { + 'skip': ( scopyWithin instanceof Error ) +}; +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = scopyWithin( len, 0, 0, len-1, x, 1 ); + if ( isnanf( y[ i%y.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( x[ i%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s::native:len=%d', pkg, len ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..b8b26d7e203c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js @@ -0,0 +1,103 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var scopyWithin = require( './../lib/ndarray.js' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = scopyWithin( len, 0, 0, len-1, x, 1, 0 ); + if ( isnanf( y[ i%y.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( x[ i%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:ndarray:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..f39b63bd9f11 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,108 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var scopyWithin = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( scopyWithin instanceof Error ) +}; +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = scopyWithin( len, 0, 0, len-1, x, 1, 0 ); + if ( isnanf( y[ i%y.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( x[ i%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s::native:ndarray:len=%d', pkg, len ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/Makefile new file mode 100644 index 000000000000..0756dc7da20a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..a6b672fce1c7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c @@ -0,0 +1,197 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/ext/base/scopy_within.h" +#include "stdlib/blas/base/shared.h" +#include +#include +#include +#include +#include + +#define NAME "scopy_within" +#define ITERATIONS 10000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmark results. +* +* @param prefix comment prefix +* @param elapsed elapsed time in seconds +*/ +static void print_results( const char* prefix, double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( "# %s\n", prefix ); + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random float on the interval [-100,100). +* +* @return random float +*/ +static float rand_float( void ) { + int r = rand(); + return -100.0f + (r/(float)RAND_MAX)*200.0f; +} + +/** +* Run a benchmark which tests `stdlib_strided_scopy_within`. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark1( int iterations, int len ) { + double elapsed; + float x[ len ]; + double t; + int i; + + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_float()*200.0f ) - 100.0f; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + API_SUFFIX(stdlib_strided_scopy_within)( len, 0, 0, len-1, x, 1 ); + if ( x[ 0 ] != x[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( x[ 0 ] != x[ 0 ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Run a benchmark which tests `stdlib_strided_scopy_within_ndarray`. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int len ) { + double elapsed; + float x[ len ]; + double t; + int i; + + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_float()*200.0f ) - 100.0f; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + API_SUFFIX(stdlib_strided_scopy_within_ndarray)( len, 0, 0, len-1, x, 1, 0 ); + if ( x[ 0 ] != x[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( x[ 0 ] != x[ 0 ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int len; + int i; + int j; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + + // Run benchmarks: + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + iter = ITERATIONS / pow( 10, i-1 ); + if ( iter < 1 ) { + iter = 1; + } + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::native::%s:len=%d\n", NAME, len ); + elapsed = benchmark1( iter, len ); + print_results( "scopy_within:len", elapsed ); + printf( "ok %d benchmark finished\n", count ); + + count += 1; + printf( "# c::native::%s:ndarray:len=%d\n", NAME, len ); + elapsed = benchmark2( iter, len ); + print_results( "scopy_within_ndarray:len", elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); + + return 0; +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/binding.gyp b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt new file mode 100644 index 000000000000..9b36ba4e4fdb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt @@ -0,0 +1,110 @@ +{{alias}}( N, target, start, end, x, strideX ) + Performs an in-place copy of elements within a single-precision + floating-point strided array. + + The `N` and stride parameters determine which elements in the strided array + are accessed at runtime. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N <= 0`, the function returns the strided array unchanged. + + If `target >= N`, the function returns the strided array unchanged. + + Parameters + ---------- + N: integer + Number of indexed elements. + + target: integer + Target index. + + start: integer + Source start index. + + end: integer + Source end index. + + x: Float32Array + Input array. + + strideX: integer + Stride length. + + Returns + ------- + x: Float32Array + Input array. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}( 3, 2, 1, 2, x, 1 ) + [ 1.0, 2.0, 2.0, 4.0, 5.0, 6.0 ] + + // Using `N` and stride parameters: + > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > {{alias}}( 3, 0, 1, 6, x, 2 ) + [ 3.0, 2.0, 5.0, 4.0, 7.0, 6.0, 7.0, 8.0 ] + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( 2, 0, 2, 5, x1, 1 ) + [ 4.0, 5.0, 4.0, 5.0, 6.0 ] + > x0 + [ 1.0, 4.0, 5.0, 4.0, 5.0, 6.0 ] + + +{{alias}}.ndarray( N, target, start, end, x, strideX, offsetX ) + Performs an in-place copy of elements within a single-precision + floating-point strided array using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameter supports indexing semantics based on a + starting index. + + Parameters + ---------- + N: integer + Number of indexed elements. + + target: integer + Target index. + + start: integer + Source start index. + + end: integer + Source end index. + + x: Float32Array + Input array. + + strideX: integer + Stride length. + + offsetX: integer + Starting index. + + Returns + ------- + x: Float32Array + Input array. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}.ndarray( 4, 2, 0, 2, x, 1, 1 ) + [ 1.0, 2.0, 3.0, 2.0, 3.0, 6.0 ] + + // Using an index offset: + > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}.ndarray( 4, 3, 0, 1, x, 1, 2 ) + [ 1.0, 2.0, 3.0, 4.0, 5.0, 3.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/index.d.ts new file mode 100644 index 000000000000..35266fd60ea7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/index.d.ts @@ -0,0 +1,101 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Interface describing `scopyWithin`. +*/ +interface Routine { + /** + * Performs an in-place copy of elements within a single-precision floating-point array. + * + * @param N - number of indexed elements + * @param target - target index + * @param start - source start index + * @param end - source end index + * @param x - input array + * @param strideX - stride length + * @returns input array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * scopyWithin( x.length, 3, 1, 4, x, 1 ); + * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] + */ + ( N: number, target: number, start: number, end: number, x: Float32Array, strideX: number ): Float32Array; + + /** + * Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param target - target index + * @param start - source start index + * @param end - source end index + * @param x - input array + * @param strideX - stride length + * @param offsetX - starting index + * @returns input array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * scopyWithin.ndarray( x.length, 3, 1, 4, x, 1, 0 ); + * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] + */ + ndarray( N: number, target: number, start: number, end: number, x: Float32Array, strideX: number, offsetX: number ): Float32Array; +} + +/** +* Performs an in-place copy of elements within a single-precision floating-point array. +* +* @param N - number of indexed elements +* @param target - target index +* @param start - source start index +* @param end - source end index +* @param x - input array +* @param strideX - stride length +* @returns input array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* scopyWithin( x.length, 3, 1, 4, x, 1 ); +* // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* scopyWithin.ndarray( x.length, 3, 1, 4, x, 1, 0 ); +* // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] +*/ +declare var scopyWithin: Routine; + + +// EXPORTS // + +export = scopyWithin; diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/test.ts new file mode 100644 index 000000000000..e79bb8471c52 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/test.ts @@ -0,0 +1,242 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import scopyWithin = require( './index' ); + + +// TESTS // + +// The function returns a Float32Array... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin( 3, 3, 1, 2, x, 1 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin( '3', 3, 1, 2, x, 1 ); // $ExpectError + scopyWithin( true, 3, 1, 2, x, 1 ); // $ExpectError + scopyWithin( false, 3, 1, 2, x, 1 ); // $ExpectError + scopyWithin( null, 3, 1, 2, x, 1 ); // $ExpectError + scopyWithin( undefined, 3, 1, 2, x, 1 ); // $ExpectError + scopyWithin( [], 3, 1, 2, x, 1 ); // $ExpectError + scopyWithin( {}, 3, 1, 2, x, 1 ); // $ExpectError + scopyWithin( ( x: number ): number => x, 3, 1, 2, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin( 3, '3', 1, 2, x, 1 ); // $ExpectError + scopyWithin( 3, true, 1, 2, x, 1 ); // $ExpectError + scopyWithin( 3, false, 1, 2, x, 1 ); // $ExpectError + scopyWithin( 3, null, 1, 2, x, 1 ); // $ExpectError + scopyWithin( 3, undefined, 1, 2, x, 1 ); // $ExpectError + scopyWithin( 3, [], 1, 2, x, 1 ); // $ExpectError + scopyWithin( 3, {}, 1, 2, x, 1 ); // $ExpectError + scopyWithin( 3, ( x: number ): number => x, 1, 2, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin( 3, 3, '1', 2, x, 1 ); // $ExpectError + scopyWithin( 3, 3, true, 2, x, 1 ); // $ExpectError + scopyWithin( 3, 3, false, 2, x, 1 ); // $ExpectError + scopyWithin( 3, 3, null, 2, x, 1 ); // $ExpectError + scopyWithin( 3, 3, undefined, 2, x, 1 ); // $ExpectError + scopyWithin( 3, 3, [], 2, x, 1 ); // $ExpectError + scopyWithin( 3, 3, {}, 2, x, 1 ); // $ExpectError + scopyWithin( 3, 3, ( x: number ): number => x, 2, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin( 3, 3, 1, '2', x, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, true, x, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, false, x, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, null, x, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, undefined, x, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, [], x, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, {}, x, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, ( x: number ): number => x, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float32Array... +{ + scopyWithin( 3, 3, 1, 2, '3', 1 ); // $ExpectError + scopyWithin( 3, 3, 1, 2, 3, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, 2, true, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, 2, false, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, 2, null, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, 2, undefined, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, 2, [], 1 ); // $ExpectError + scopyWithin( 3, 3, 1, 2, {}, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, 2, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin( 3, 3, 1, 2, x, '4' ); // $ExpectError + scopyWithin( 3, 3, 1, 2, x, true ); // $ExpectError + scopyWithin( 3, 3, 1, 2, x, false ); // $ExpectError + scopyWithin( 3, 3, 1, 2, x, null ); // $ExpectError + scopyWithin( 3, 3, 1, 2, x, [] ); // $ExpectError + scopyWithin( 3, 3, 1, 2, x, {} ); // $ExpectError + scopyWithin( 3, 3, 1, 2, x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin(); // $ExpectError + scopyWithin( 3 ); // $ExpectError + scopyWithin( 3, 3 ); // $ExpectError + scopyWithin( 3, 3, 1 ); // $ExpectError + scopyWithin( 3, 3, 1, 2 ); // $ExpectError + scopyWithin( 3, 3, 1, 2, x ); // $ExpectError + scopyWithin( 3, 3, 1, 2, x, 1, {} ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float32Array... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin.ndarray( 3, 3, 1, 2, x, 1, 1 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin.ndarray( '2', 3, 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( true, 3, 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( false, 3, 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( null, 3, 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( undefined, 3, 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( [], 2, 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( {}, 2, 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( ( x: number ): number => x, 2, 1, 2, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin.ndarray( 2, '2', 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, true, 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, false, 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, null, 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, undefined, 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, [], 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, {}, 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, ( x: number ): number => x, 1, 2, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin.ndarray( 2, 2, '1', 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, true, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, false, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, null, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, undefined, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, [], 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, {}, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, ( x: number ): number => x, 2, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin.ndarray( 2, 2, 1, '2', x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, true, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, false, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, null, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, undefined, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, [], x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, {}, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, ( x: number ): number => x, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Float32Array... +{ + scopyWithin.ndarray( 2, 2, 1, 2, '5', 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, 5, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, true, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, false, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, null, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, undefined, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, [], 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, {}, 1, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin.ndarray( 2, 2, 1, 2, x, '1', 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, true, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, false, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, null, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, undefined, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, [], 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, {}, 0 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin.ndarray( 2, 2, 1, 2, x, 1, '0' ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, 1, true ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, 1, false ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, 1, null ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, 1, undefined ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, 1, [] ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, 1, {} ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided insufficient arguments... +{ + const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + scopyWithin.ndarray(); // $ExpectError + scopyWithin.ndarray( 2 ); // $ExpectError + scopyWithin.ndarray( 2, 2 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, 1 ); // $ExpectError + scopyWithin.ndarray( 2, 2, 1, 2, x, 1, 0, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/example.c new file mode 100644 index 000000000000..2635366efe0f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/example.c @@ -0,0 +1,39 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/ext/base/scopy_within.h" +#include + +int main( void ) { + // Create a strided array: + float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + + // Specify the number of elements to copy: + const int N = 8; + + // Specify a stride: + const int strideX = 1; + + // Copy elements starting from index 1 to index 4: + stdlib_strided_scopy_within( N, 4, 1, 4, x, strideX ); + + // Print the result: + for ( int i = 0; i < 8; i++ ) { + printf( "x[ %i ] = %f\n", i, x[ i ] ); + } +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/index.js new file mode 100644 index 000000000000..60a9df2ccb59 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/index.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var scopyWithin = require( './../lib' ); + +var x = discreteUniform( 10, 0, 500, { + 'dtype': 'float32' +}); +console.log( x ); + +// Copy the first 3 elements to positions 5, 6, 7: +scopyWithin( 10, 5, 0, 3, x, 1 ); +console.log( x ); + +// Copy elements starting from index 1 to position 0: +scopyWithin( 5, 0, 1, 9, x, 1 ); +console.log( x ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var scopyWithin = require( '@stdlib/blas/ext/base/scopy-within' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* scopyWithin.ndarray( x.length, 3, 1, 4, x, 1, 0 ); +* // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var scopyWithin; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + scopyWithin = main; +} else { + scopyWithin = tmp; +} + + +// EXPORTS // + +module.exports = scopyWithin; + +// exports: { "ndarray": "scopyWithin.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/main.js new file mode 100644 index 000000000000..7cb992d450f0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var scopyWithin = require( './scopy_within.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( scopyWithin, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = scopyWithin; diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/native.js new file mode 100644 index 000000000000..65ecf73fd672 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/native.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var scopyWithin = require( './scopy_within.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( scopyWithin, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = scopyWithin; diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js new file mode 100644 index 000000000000..d04abb3f4b00 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var min = require( '@stdlib/math/base/special/min' ); +var max = require( '@stdlib/math/base/special/max' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var Float32Array = require( '@stdlib/array/float32' ); +var scopy = require( '@stdlib/blas/base/scopy' ).ndarray; + + +// MAIN // + +/** +* Performs an in-place copy of elements within a single-precision floating-point array. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {integer} target - target index +* @param {integer} start - source start index +* @param {integer} end - source end index +* @param {Float32Array} x - input array +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index +* @returns {Float32Array} input array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* scopyWithin( x.length, 3, 1, 4, x, 1, 0 ); +* // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] +*/ +function scopyWithin( N, target, start, end, x, strideX, offsetX ) { + var flg; + var tei; + var sei; + var tsi; + var ssi; + var tmp; + var cl; + + if ( N <= 0 ) { + return x; + } + if ( target >= N ) { + return x; + } + + flg = false; + + // Resolve copy length: + cl = min( abs( end - start ), N ); + if ( cl <= 0 ) { + return x; + } + + // Calculate source and target indices: + ssi = offsetX + ( start * strideX ); + sei = ssi + ( ( cl - 1 ) * strideX ); + tsi = offsetX + ( target * strideX ); + tei = tsi + ( ( cl - 1 ) * strideX ); + + // Check if source and target regions overlap: + if ( + !( max( ssi, sei ) < min( tsi, tei ) || + max( tsi, tei ) < min( ssi, sei ) ) + ) { + flg = true; + } + + if ( flg ) { + // Create a temporary copy of source elements: + tmp = new Float32Array( cl ); + scopy( cl, x, strideX, ssi, tmp, 1, 0 ); + + // Copy from temporary array to target position: + scopy( cl, tmp, 1, 0, x, strideX, tsi ); + } else { + scopy( cl, x, strideX, ssi, x, strideX, tsi ); + } + return x; +} + + +// EXPORTS // + +module.exports = scopyWithin; diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js new file mode 100644 index 000000000000..6c8411bf4c3c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Performs an in-place copy of elements within a single-precision floating-point array. +* +* @private +* @param {PositiveInteger} N - number of indexed elements +* @param {integer} target - target index +* @param {integer} start - source start index +* @param {integer} end - source end index +* @param {Float32Array} x - input array +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index +* @returns {Float32Array} input array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* scopyWithin( 6, 3, 1, 4, x, 1, 0 ); +* // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] +*/ +function scopyWithin( N, target, start, end, x, strideX, offsetX ) { + addon.ndarray( N, target, start, end, x, strideX, offsetX ); + return x; +} + + +// EXPORTS // + +module.exports = scopyWithin; diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js new file mode 100644 index 000000000000..550e7dce5898 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Performs an in-place copy of elements within a single-precision floating-point array. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {integer} target - target index +* @param {integer} start - source start index +* @param {integer} end - source end index +* @param {Float32Array} x - input array +* @param {integer} strideX - stride length +* @returns {Float32Array} input array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* scopyWithin( x.length, 3, 1, 4, x, 1 ); +* // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] +*/ +function scopyWithin( N, target, start, end, x, strideX ) { + return ndarray( N, target, start, end, x, strideX, stride2offset( N, strideX ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = scopyWithin; diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js new file mode 100644 index 000000000000..f9d90540e667 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Performs an in-place copy of elements within a single-precision floating-point array. +* +* @private +* @param {PositiveInteger} N - number of indexed elements +* @param {integer} target - target index +* @param {integer} start - source start index +* @param {integer} end - source end index +* @param {Float32Array} x - input array +* @param {integer} strideX - stride length +* @returns {Float32Array} input array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* scopyWithin( 6, 3, 1, 4, x, 1 ); +* // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] +*/ +function scopyWithin( N, target, start, end, x, strideX ) { + addon( N, target, start, end, x, strideX ); + return x; +} + + +// EXPORTS // + +module.exports = scopyWithin; diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/manifest.json new file mode 100644 index 000000000000..a4180fb5e2f5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/manifest.json @@ -0,0 +1,110 @@ +{ + "options": { + "task": "build", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/scopy", + "@stdlib/strided/base/stride2offset", + "@stdlib/math/base/special/max", + "@stdlib/math/base/special/min", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array" + ] + }, + { + "task": "benchmark", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/scopy", + "@stdlib/strided/base/stride2offset", + "@stdlib/math/base/special/max", + "@stdlib/math/base/special/min" + ] + }, + { + "task": "examples", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/scopy", + "@stdlib/strided/base/stride2offset", + "@stdlib/math/base/special/max", + "@stdlib/math/base/special/min" + ] + }, + { + "task": "build", + "wasm": true, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/scopy", + "@stdlib/strided/base/stride2offset", + "@stdlib/math/base/special/max", + "@stdlib/math/base/special/min" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/package.json b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/package.json new file mode 100644 index 000000000000..7b97911b4835 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/blas/ext/base/scopy-within", + "version": "0.0.0", + "description": "Perform an in-place copy of elements within a single-precision floating-point array.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "browser": "./lib/main.js", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "extended", + "copy", + "copywithin", + "within", + "move", + "strided", + "array", + "ndarray", + "float32", + "float", + "float32array" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/Makefile b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/addon.c new file mode 100644 index 000000000000..403ae8c5a901 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/addon.c @@ -0,0 +1,66 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/ext/base/scopy_within.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_float32array.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @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, 6 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, target, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, start, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, end, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, x, N, strideX, argv, 4 ); + API_SUFFIX(stdlib_strided_scopy_within)( N, target, start, end, x, strideX ); + return NULL; +} + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 7 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, target, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, start, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, end, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, x, N, strideX, argv, 4 ); + API_SUFFIX(stdlib_strided_scopy_within_ndarray)( N, target, start, end, x, strideX, offsetX ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c new file mode 100644 index 000000000000..b901e35ded6e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c @@ -0,0 +1,114 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/ext/base/scopy_within.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/scopy.h" +#include "stdlib/strided/base/stride2offset.h" +#include "stdlib/math/base/special/max.h" +#include "stdlib/math/base/special/min.h" +#include +#include + +/** +* Performs an in-place copy of elements within a single-precision floating-point array. +* +* @param N number of indexed elements +* @param target target index +* @param start source start index +* @param end source end index +* @param x input array +* @param strideX stride length +*/ +void API_SUFFIX(stdlib_strided_scopy_within)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *x, const CBLAS_INT strideX ) { + CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + API_SUFFIX(stdlib_strided_scopy_within_ndarray)( N, target, start, end, x, strideX, ox ); +} + +/** +* Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. +* +* @param N number of indexed elements +* @param target target index +* @param start source start index +* @param end source end index +* @param x input array +* @param strideX stride length +* @param offsetX starting index +*/ +void API_SUFFIX(stdlib_strided_scopy_within_ndarray)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + CBLAS_INT ssi; + CBLAS_INT sei; + CBLAS_INT tsi; + CBLAS_INT tei; + CBLAS_INT cl; + float *tmp; + bool flg; + + if ( N <= 0 ) { + return; + } + if ( target >= N ) { + return; + } + + flg = false; + + // Resolve copy length: + cl = end - start; + if ( cl < 0 ) { + cl = -cl; + } + if ( cl > N ) { + cl = N; + } + if ( cl <= 0 ) { + return; + } + + // Calculate source and target indices: + ssi = offsetX + ( start * strideX ); + sei = ssi + ( ( cl - 1 ) * strideX ); + tsi = offsetX + ( target * strideX ); + tei = tsi + ( ( cl - 1 ) * strideX ); + + // Check if source and target regions overlap: + if ( + !( stdlib_base_max( ssi, sei ) < stdlib_base_min( tsi, tei ) || + stdlib_base_max( tsi, tei ) < stdlib_base_min( ssi, sei ) ) + ) { + flg = true; + } + + if ( flg ) { + // Create a temporary copy of source elements: + tmp = (float *)malloc( cl * sizeof(float) ); + if ( tmp == NULL ) { + return; + } + c_scopy_ndarray( cl, x, strideX, ssi, tmp, 1, 0 ); + + // Copy from temporary array to target position: + c_scopy_ndarray( cl, tmp, 1, 0, x, strideX, tsi ); + + // Clean up memory: + free( tmp ); + } else { + c_scopy_ndarray( cl, x, strideX, ssi, x, strideX, tsi ); + } +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.js new file mode 100644 index 000000000000..833c88cb99e5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var isBrowser = require( '@stdlib/assert/is-browser' ); +var scopyWithin = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': isBrowser +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof scopyWithin, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof scopyWithin.ndarray, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var scopyWithin = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( scopyWithin, mock, 'returns expected value' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', function test( t ) { + var scopyWithin; + var main; + + main = require( './../lib/main.js' ); + + scopyWithin = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( scopyWithin, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot resolve module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js new file mode 100644 index 000000000000..859f0f87cbb9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js @@ -0,0 +1,199 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var scopyWithin = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof scopyWithin, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( scopyWithin.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies values within the provided single-precision floating-point strided array', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ); + + actual = scopyWithin( 6, 3, 1, 4, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 6, 0, 3, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 4, 5, 0, 3, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 3.0 ] ); + + actual = scopyWithin( 3, 2, 0, 3, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing an offset parameter', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 2.0, 3.0 ] ); + + actual = scopyWithin( 4, 3, 0, 2, x, 1, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing a stride parameter', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 3.0, 2.0, 5.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + actual = scopyWithin( 2, 0, 1, 4, x, 2, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing negative strides', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 3, 0, 1, 3, x, -1, 2 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); + + actual = scopyWithin( 4, 0, 2, 4, x, -1, 3 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a reversed source range (start > end)', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 4.0, 5.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 0, 3, 1, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the strided array unchanged if `start` equals `end`', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 0, 2, 2, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a stride of zero', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 1, 0, 2, x, 0, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the strided array unchanged if `N` is less than or equal to `0`', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 0, 3, 1, 4, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + actual = scopyWithin( -1, 3, 1, 4, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js new file mode 100644 index 000000000000..9f5038a61d85 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js @@ -0,0 +1,210 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var isBrowser = require( '@stdlib/assert/is-browser' ); +var isError = require( '@stdlib/assert/is-error' ); +var Float32Array = require( '@stdlib/array/float32' ); + + +// VARIABLES // + +var scopyWithin = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( isBrowser || isError( scopyWithin ) ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof scopyWithin, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', opts, function test( t ) { + t.strictEqual( scopyWithin.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies values within the provided single-precision floating-point strided array', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ); + + actual = scopyWithin( 6, 3, 1, 4, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 6, 0, 3, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 4, 5, 0, 3, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 3.0 ] ); + + actual = scopyWithin( 3, 2, 0, 3, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing an offset parameter', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 2.0, 3.0 ] ); + + actual = scopyWithin( 4, 3, 0, 2, x, 1, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing a stride parameter', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 3.0, 2.0, 5.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + actual = scopyWithin( 2, 0, 1, 4, x, 2, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing negative strides', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 3, 0, 1, 3, x, -1, 2 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); + + actual = scopyWithin( 4, 0, 2, 4, x, -1, 3 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a reversed source range (start > end)', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 4.0, 5.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 0, 3, 1, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the strided array unchanged if `start` equals `end`', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 0, 2, 2, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a stride of zero', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 1, 0, 2, x, 0, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the strided array unchanged if `N` is less than or equal to `0`', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 0, 3, 1, 4, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + actual = scopyWithin( -1, 3, 1, 4, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js new file mode 100644 index 000000000000..b278417c8fb0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js @@ -0,0 +1,184 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var scopyWithin = require( './../lib/scopy_within.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof scopyWithin, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( scopyWithin.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies values within the provided single-precision floating-point strided array', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ); + + actual = scopyWithin( 6, 3, 1, 4, x, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 6, 0, 3, x, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 4, 5, 0, 3, x, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 3.0 ] ); + + actual = scopyWithin( 3, 2, 0, 3, x, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a stride parameter', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 3.0, 2.0, 5.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + actual = scopyWithin( 2, 0, 1, 4, x, 2 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing negative strides', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 3, 0, 1, 3, x, -1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); + + actual = scopyWithin( 4, 0, 2, 4, x, -1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a reversed source range (start > end)', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 4.0, 5.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 0, 3, 1, x, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the strided array unchanged if `start` equals `end`', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 0, 2, 2, x, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a stride of zero', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 1, 0, 2, x, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the strided array unchanged if `N` is less than or equal to `0`', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 0, 3, 1, 4, x, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + actual = scopyWithin( -1, 3, 1, 4, x, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js new file mode 100644 index 000000000000..57705788fa84 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js @@ -0,0 +1,188 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var isBrowser = require( '@stdlib/assert/is-browser' ); +var isError = require( '@stdlib/assert/is-error' ); +var Float32Array = require( '@stdlib/array/float32' ); + + +// VARIABLES // + +var scopyWithin = tryRequire( resolve( __dirname, './../lib/scopy_within.native.js' ) ); +var opts = { + 'skip': ( isBrowser || isError( scopyWithin ) ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof scopyWithin, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', opts, function test( t ) { + t.strictEqual( scopyWithin.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies values within the provided single-precision floating-point strided array', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ); + + actual = scopyWithin( 6, 3, 1, 4, x, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 6, 0, 3, x, 1 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + actual = scopyWithin( 6, 10, 0, 3, x, 1 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 3.0 ] ); + + actual = scopyWithin( 3, 2, 0, 3, x, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a stride parameter', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 3.0, 2.0, 5.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + actual = scopyWithin( 2, 0, 1, 4, x, 2 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing negative strides', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 3, 0, 1, 3, x, -1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); + + actual = scopyWithin( 4, 0, 2, 4, x, -1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a reversed source range (start > end)', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 4.0, 5.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 0, 3, 1, x, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the strided array unchanged if `start` equals `end`', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 0, 2, 2, x, 1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a stride of zero', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 1, 0, 2, x, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the strided array unchanged if `N` is less than or equal to `0`', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 0, 3, 1, 4, x, 1 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + actual = scopyWithin( -1, 3, 1, 4, x, 1 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); From cae28a079d331ca20681632f22d2437fc3dd1cdf Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 12 Mar 2026 02:27:54 +0500 Subject: [PATCH 2/8] refactor: update binding file --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/ext/base/scopy-within/binding.gyp | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/binding.gyp b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/binding.gyp index 0d6508a12e99..60dce9d0b31a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/binding.gyp +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/binding.gyp @@ -29,6 +29,39 @@ # Target name should match the add-on export name: 'addon_target_name%': 'addon', + # Fortran compiler (to override -Dfortran_compiler=): + 'fortran_compiler%': 'gfortran', + + # Fortran compiler flags: + 'fflags': [ + # Specify the Fortran standard to which a program is expected to conform: + '-std=f95', + + # Indicate that the layout is free-form source code: + '-ffree-form', + + # Aggressive optimization: + '-O3', + + # Enable commonly used warning options: + '-Wall', + + # Warn if source code contains problematic language features: + '-Wextra', + + # Warn if a procedure is called without an explicit interface: + '-Wimplicit-interface', + + # Do not transform names of entities specified in Fortran source files by appending underscores (i.e., don't mangle names, thus allowing easier usage in C wrappers): + '-fno-underscoring', + + # Warn if source code contains Fortran 95 extensions and C-language constructs: + '-pedantic', + + # Compile but do not link (output is an object file): + '-c', + ], + # Set variables based on the host OS: 'conditions': [ [ @@ -128,6 +161,68 @@ }, ], # end condition (OS!="win") ], # end conditions + + # Define custom build actions for particular inputs: + 'rules': [ + { + # Define a rule for processing Fortran files: + 'extension': 'f', + + # Define the pathnames to be used as inputs when performing processing: + 'inputs': [ + # Full path of the current input: + '<(RULE_INPUT_PATH)' + ], + + # Define the outputs produced during processing: + 'outputs': [ + # Store an output object file in a directory for placing intermediate results (only accessible within a single target): + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).<(obj)' + ], + + # Define the rule for compiling Fortran based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + + # Rule to compile Fortran on Windows: + { + 'rule_name': 'compile_fortran_windows', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Windows...', + + 'process_outputs_as_sources': 0, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + }, + + # Rule to compile Fortran on non-Windows: + { + 'rule_name': 'compile_fortran_linux', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Linux...', + + 'process_outputs_as_sources': 1, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '-fPIC', # generate platform-independent code + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + } + ], # end condition (OS=="win") + ], # end conditions + }, # end rule (extension=="f") + ], # end rules }, # end target <(addon_target_name) # Target to copy a generated add-on to a standard location: From f2a1137f32bb5f22100d6e758bc40303c48e0a3e Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 12 Mar 2026 03:14:57 +0500 Subject: [PATCH 3/8] fix: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/scopy-within/README.md | 2 +- .../blas/ext/base/scopy-within/benchmark/benchmark.js | 2 +- .../ext/base/scopy-within/benchmark/benchmark.native.js | 2 +- .../ext/base/scopy-within/benchmark/benchmark.ndarray.js | 2 +- .../scopy-within/benchmark/benchmark.ndarray.native.js | 2 +- .../ext/base/scopy-within/benchmark/c/benchmark.length.c | 8 ++++++-- .../@stdlib/blas/ext/base/scopy-within/docs/repl.txt | 4 ++-- .../@stdlib/blas/ext/base/scopy-within/docs/types/test.ts | 1 + .../blas/ext/base/scopy-within/test/test.ndarray.js | 3 +++ .../ext/base/scopy-within/test/test.ndarray.native.js | 3 +++ .../blas/ext/base/scopy-within/test/test.scopy_within.js | 3 +++ 11 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md index 754f12df5e93..524603568593 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md @@ -142,7 +142,7 @@ console.log( x ); scopyWithin( 10, 5, 0, 3, x, 1 ); console.log( x ); -// Copy every other element starting from the second element: +// Copy elements starting from source index 1 to target index 0: scopyWithin( 5, 0, 1, 9, x, 1 ); console.log( x ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js index a287df1c14e5..c4238659bc78 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js @@ -61,7 +61,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = scopyWithin( len, 0, 0, len-1, x, 1 ); + y = scopyWithin( len, 0, 0, len - 1, x, 1 ); if ( isnanf( y[ i%y.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.native.js index d8523c859fd8..5b901672702d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.native.js @@ -66,7 +66,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = scopyWithin( len, 0, 0, len-1, x, 1 ); + y = scopyWithin( len, 0, 0, len - 1, x, 1 ); if ( isnanf( y[ i%y.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js index b8b26d7e203c..1bd7392162a8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js @@ -61,7 +61,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = scopyWithin( len, 0, 0, len-1, x, 1, 0 ); + y = scopyWithin( len, 0, 0, len - 1, x, 1, 0 ); if ( isnanf( y[ i%y.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.native.js index f39b63bd9f11..fdb76317ece6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.native.js @@ -66,7 +66,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = scopyWithin( len, 0, 0, len-1, x, 1, 0 ); + y = scopyWithin( len, 0, 0, len - 1, x, 1, 0 ); if ( isnanf( y[ i%y.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c index a6b672fce1c7..ae8ade51aa48 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c @@ -98,10 +98,11 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int len ) { double elapsed; - float x[ len ]; + float *x; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*200.0f ) - 100.0f; } @@ -118,6 +119,7 @@ static double benchmark1( int iterations, int len ) { if ( x[ 0 ] != x[ 0 ] ) { printf( "should not return NaN\n" ); } + free( x ); return elapsed; } @@ -130,10 +132,11 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { double elapsed; - float x[ len ]; + float *x; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*200.0f ) - 100.0f; } @@ -150,6 +153,7 @@ static double benchmark2( int iterations, int len ) { if ( x[ 0 ] != x[ 0 ] ) { printf( "should not return NaN\n" ); } + free( x ); return elapsed; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt index 9b36ba4e4fdb..911672fd3439 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( N, target, start, end, x, strideX ) Performs an in-place copy of elements within a single-precision - floating-point strided array. + floating-point array. The `N` and stride parameters determine which elements in the strided array are accessed at runtime. @@ -60,7 +60,7 @@ {{alias}}.ndarray( N, target, start, end, x, strideX, offsetX ) Performs an in-place copy of elements within a single-precision - floating-point strided array using alternative indexing semantics. + floating-point array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/test.ts index e79bb8471c52..759d72d0c5ab 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/test.ts @@ -105,6 +105,7 @@ import scopyWithin = require( './index' ); scopyWithin( 3, 3, 1, 2, x, true ); // $ExpectError scopyWithin( 3, 3, 1, 2, x, false ); // $ExpectError scopyWithin( 3, 3, 1, 2, x, null ); // $ExpectError + scopyWithin( 3, 3, 1, 2, x, undefined ); // $ExpectError scopyWithin( 3, 3, 1, 2, x, [] ); // $ExpectError scopyWithin( 3, 3, 1, 2, x, {} ); // $ExpectError scopyWithin( 3, 3, 1, 2, x, ( x: number ): number => x ); // $ExpectError diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js index 859f0f87cbb9..21cbc78f7958 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js @@ -55,7 +55,10 @@ tape( 'the function copies values within the provided single-precision floating- expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); actual = scopyWithin( 6, 6, 0, 3, x, 1, 0 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + actual = scopyWithin( 6, 10, 0, 3, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js index 9f5038a61d85..a7265264bc3b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js @@ -66,7 +66,10 @@ tape( 'the function copies values within the provided single-precision floating- expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); actual = scopyWithin( 6, 6, 0, 3, x, 1, 0 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + actual = scopyWithin( 6, 10, 0, 3, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js index b278417c8fb0..fe8460bf389f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js @@ -55,7 +55,10 @@ tape( 'the function copies values within the provided single-precision floating- expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); actual = scopyWithin( 6, 6, 0, 3, x, 1 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + actual = scopyWithin( 6, 10, 0, 3, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); From bea7ac7ff4de8a8b990c972ba562bd6fd14f98e8 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 22 Jul 2026 20:59:03 +0500 Subject: [PATCH 4/8] fix: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/ext/base/scopy-within/README.md | 31 +++-- .../benchmark/c/benchmark.length.c | 4 +- .../blas/ext/base/scopy-within/docs/repl.txt | 22 ++-- .../ext/base/scopy-within/examples/index.js | 4 - .../stdlib/blas/ext/base/scopy_within.h | 4 +- .../blas/ext/base/scopy-within/lib/ndarray.js | 50 +++------ .../base/scopy-within/lib/ndarray.native.js | 8 +- .../ext/base/scopy-within/lib/scopy_within.js | 6 +- .../scopy-within/lib/scopy_within.native.js | 8 +- .../blas/ext/base/scopy-within/manifest.json | 14 +-- .../blas/ext/base/scopy-within/src/addon.c | 8 +- .../blas/ext/base/scopy-within/src/main.c | 67 ++++------- .../base/scopy-within/test/test.ndarray.js | 106 +++++++++++------- .../scopy-within/test/test.ndarray.native.js | 106 +++++++++++------- .../scopy-within/test/test.scopy_within.js | 98 +++++++++------- .../test/test.scopy_within.native.js | 92 ++++++++++----- 16 files changed, 326 insertions(+), 302 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md index 524603568593..f55c41cda5fa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md @@ -60,7 +60,7 @@ var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0 ] ); scopyWithin( 3, 0, 1, 6, x, 2 ); -// x => [ 3.0, 0.0, 5.0, 0.0, 7.0, 0.0, 7.0, 0.0 ] +// x => [ 3.0, 0.0, 5.0, 0.0, 5.0, 0.0, 7.0, 0.0 ] ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -75,8 +75,8 @@ var x0 = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element // Copy within the view... -scopyWithin( 3, 0, 2, 5, x1, 1 ); -// x0 => [ 1.0, 4.0, 5.0, 6.0, 5.0, 6.0, 7.0, 8.0 ] +scopyWithin( 6, 0, 3, 6, x1, 1 ); +// x0 => [ 1.0, 5.0, 6.0, 7.0, 5.0, 6.0, 7.0, 8.0 ] ``` #### scopyWithin.ndarray( N, target, start, end, x, strideX, offsetX ) @@ -96,15 +96,15 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to copy elements starting from the second element: +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to copy elements starting from the third element: ```javascript var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -scopyWithin.ndarray( 3, 2, 0, 3, x, 1, 2 ); -// x => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0, 8.0 ] +scopyWithin.ndarray( 4, 2, 0, 2, x, 1, 2 ); +// x => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 7.0, 8.0 ] ``` @@ -117,6 +117,7 @@ scopyWithin.ndarray( 3, 2, 0, 3, x, 1, 2 ); - If `N <= 0`, both functions return the strided array unchanged. - If `target >= N`, both functions return the strided array unchanged. +- If `start >= end`, both functions return the strided array unchanged. - Both functions **mutate** the provided input strided array. @@ -141,10 +142,6 @@ console.log( x ); // Copy the first 3 elements to positions 5, 6, 7: scopyWithin( 10, 5, 0, 3, x, 1 ); console.log( x ); - -// Copy elements starting from source index 1 to target index 0: -scopyWithin( 5, 0, 1, 9, x, 1 ); -console.log( x ); ``` @@ -177,7 +174,7 @@ console.log( x ); #include "stdlib/blas/ext/base/scopy_within.h" ``` -#### stdlib_strided_scopy_within( N, target, start, end, \*x, strideX ) +#### stdlib_strided_scopy_within( N, target, start, end, \*X, strideX ) Performs an in-place copy of elements within a single-precision floating-point array. @@ -193,16 +190,16 @@ The function accepts the following arguments: - **target**: `[in] CBLAS_INT` target index. - **start**: `[in] CBLAS_INT` source start index. - **end**: `[in] CBLAS_INT` source end index. -- **x**: `[inout] float*` input array. +- **X**: `[inout] float*` input array. - **strideX**: `[in] CBLAS_INT` stride length. ```c -void stdlib_strided_scopy_within( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *x, const CBLAS_INT strideX ); +void stdlib_strided_scopy_within( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX ); ``` -### stdlib_strided_scopy_within_ndarray( N, target, start, end, \*x, strideX, offsetX ) +### stdlib_strided_scopy_within_ndarray( N, target, start, end, \*X, strideX, offsetX ) @@ -220,12 +217,12 @@ The function accepts the following arguments: - **target**: `[in] CBLAS_INT` target index. - **start**: `[in] CBLAS_INT` source start index. - **end**: `[in] CBLAS_INT` source end index. -- **x**: `[inout] float*` input array. +- **X**: `[inout] float*` input array. - **strideX**: `[in] CBLAS_INT` stride length. - **offsetX**: `[in] CBLAS_INT` starting index. ```c -void stdlib_strided_scopy_within_ndarray( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +void stdlib_strided_scopy_within_ndarray( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); ``` @@ -265,7 +262,7 @@ int main( void ) { // Print the result: for ( int i = 0; i < 8; i++ ) { - printf( "x[ %i ] = %f\n", i, x[ i ] ); + printf( "x[ %i ] = %lf\n", i, x[ i ] ); } } ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c index ae8ade51aa48..b6e8a7016089 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c @@ -109,7 +109,7 @@ static double benchmark1( int iterations, int len ) { t = tic(); for ( i = 0; i < iterations; i++ ) { // cppcheck-suppress uninitvar - API_SUFFIX(stdlib_strided_scopy_within)( len, 0, 0, len-1, x, 1 ); + API_SUFFIX(stdlib_strided_scopy_within)( len, 0, 0, len - 1, x, 1 ); if ( x[ 0 ] != x[ 0 ] ) { printf( "should not return NaN\n" ); break; @@ -143,7 +143,7 @@ static double benchmark2( int iterations, int len ) { t = tic(); for ( i = 0; i < iterations; i++ ) { // cppcheck-suppress uninitvar - API_SUFFIX(stdlib_strided_scopy_within_ndarray)( len, 0, 0, len-1, x, 1, 0 ); + API_SUFFIX(stdlib_strided_scopy_within_ndarray)( len, 0, 0, len - 1, x, 1, 0 ); if ( x[ 0 ] != x[ 0 ] ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt index 911672fd3439..376736ab5b11 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( N, target, start, end, x, strideX ) - Performs an in-place copy of elements within a single-precision - floating-point array. + Performs an in-place copy of elements within a single-precision floating- + point array. The `N` and stride parameters determine which elements in the strided array are accessed at runtime. @@ -12,6 +12,8 @@ If `target >= N`, the function returns the strided array unchanged. + If `start >= end`, the function returns the strided array unchanged. + Parameters ---------- N: integer @@ -41,26 +43,26 @@ -------- // Standard Usage: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > {{alias}}( 3, 2, 1, 2, x, 1 ) - [ 1.0, 2.0, 2.0, 4.0, 5.0, 6.0 ] + > {{alias}}( 6, 3, 1, 4, x, 1 ) + [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] // Using `N` and stride parameters: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); > {{alias}}( 3, 0, 1, 6, x, 2 ) - [ 3.0, 2.0, 5.0, 4.0, 7.0, 6.0, 7.0, 8.0 ] + [ 3.0, 2.0, 5.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] // Using view offsets: > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > {{alias}}( 2, 0, 2, 5, x1, 1 ) + > {{alias}}( 4, 0, 2, 4, x1, 1 ) [ 4.0, 5.0, 4.0, 5.0, 6.0 ] > x0 [ 1.0, 4.0, 5.0, 4.0, 5.0, 6.0 ] {{alias}}.ndarray( N, target, start, end, x, strideX, offsetX ) - Performs an in-place copy of elements within a single-precision - floating-point array using alternative indexing semantics. + Performs an in-place copy of elements within a single-precision floating- + point array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a @@ -103,8 +105,8 @@ // Using an index offset: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > {{alias}}.ndarray( 4, 3, 0, 1, x, 1, 2 ) - [ 1.0, 2.0, 3.0, 4.0, 5.0, 3.0 ] + > {{alias}}.ndarray( 3, 1, 0, 2, x, 1, 2 ) + [ 1.0, 2.0, 3.0, 3.0, 4.0, 6.0 ] See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/index.js index 60a9df2ccb59..020c93ee9acb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/index.js @@ -29,7 +29,3 @@ console.log( x ); // Copy the first 3 elements to positions 5, 6, 7: scopyWithin( 10, 5, 0, 3, x, 1 ); console.log( x ); - -// Copy elements starting from index 1 to position 0: -scopyWithin( 5, 0, 1, 9, x, 1 ); -console.log( x ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include/stdlib/blas/ext/base/scopy_within.h b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include/stdlib/blas/ext/base/scopy_within.h index 572371073435..d7b12eea0f28 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include/stdlib/blas/ext/base/scopy_within.h +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include/stdlib/blas/ext/base/scopy_within.h @@ -31,12 +31,12 @@ extern "C" { /** * Performs an in-place copy of elements within a single-precision floating-point array. */ -void API_SUFFIX(stdlib_strided_scopy_within)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *x, const CBLAS_INT strideX ); +void API_SUFFIX(stdlib_strided_scopy_within)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX ); /** * Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. */ -void API_SUFFIX(stdlib_strided_scopy_within_ndarray)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +void API_SUFFIX(stdlib_strided_scopy_within_ndarray)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js index d04abb3f4b00..f6585197dcf9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js @@ -21,8 +21,6 @@ // MODULES // var min = require( '@stdlib/math/base/special/min' ); -var max = require( '@stdlib/math/base/special/max' ); -var abs = require( '@stdlib/math/base/special/abs' ); var Float32Array = require( '@stdlib/array/float32' ); var scopy = require( '@stdlib/blas/base/scopy' ).ndarray; @@ -33,9 +31,9 @@ var scopy = require( '@stdlib/blas/base/scopy' ).ndarray; * Performs an in-place copy of elements within a single-precision floating-point array. * * @param {PositiveInteger} N - number of indexed elements -* @param {integer} target - target index -* @param {integer} start - source start index -* @param {integer} end - source end index +* @param {NonNegativeInteger} target - target index +* @param {NonNegativeInteger} start - source start index +* @param {NonNegativeInteger} end - source end index * @param {Float32Array} x - input array * @param {integer} strideX - stride length * @param {NonNegativeInteger} offsetX - starting index @@ -50,53 +48,31 @@ var scopy = require( '@stdlib/blas/base/scopy' ).ndarray; * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] */ function scopyWithin( N, target, start, end, x, strideX, offsetX ) { - var flg; - var tei; - var sei; - var tsi; - var ssi; var tmp; + var ssi; + var tsi; var cl; - if ( N <= 0 ) { + if ( N <= 0 || strideX === 0 || target >= N ) { return x; } - if ( target >= N ) { - return x; - } - - flg = false; - - // Resolve copy length: - cl = min( abs( end - start ), N ); + // Resolve the number of elements to copy: + cl = min( min( end, N ) - start, N - target ); if ( cl <= 0 ) { return x; } - - // Calculate source and target indices: + // Resolve the starting source and target indices... ssi = offsetX + ( start * strideX ); - sei = ssi + ( ( cl - 1 ) * strideX ); tsi = offsetX + ( target * strideX ); - tei = tsi + ( ( cl - 1 ) * strideX ); - - // Check if source and target regions overlap: - if ( - !( max( ssi, sei ) < min( tsi, tei ) || - max( tsi, tei ) < min( ssi, sei ) ) - ) { - flg = true; - } - if ( flg ) { - // Create a temporary copy of source elements: + // When the source and target index ranges overlap, copying directly could overwrite source elements before they are read, and, thus, we first copy the source elements to a temporary array: + if ( start < target + cl && target < start + cl ) { tmp = new Float32Array( cl ); scopy( cl, x, strideX, ssi, tmp, 1, 0 ); - - // Copy from temporary array to target position: scopy( cl, tmp, 1, 0, x, strideX, tsi ); - } else { - scopy( cl, x, strideX, ssi, x, strideX, tsi ); + return x; } + scopy( cl, x, strideX, ssi, x, strideX, tsi ); return x; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js index 6c8411bf4c3c..0ca5b76dae8d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js @@ -30,9 +30,9 @@ var addon = require( './../src/addon.node' ); * * @private * @param {PositiveInteger} N - number of indexed elements -* @param {integer} target - target index -* @param {integer} start - source start index -* @param {integer} end - source end index +* @param {NonNegativeInteger} target - target index +* @param {NonNegativeInteger} start - source start index +* @param {NonNegativeInteger} end - source end index * @param {Float32Array} x - input array * @param {integer} strideX - stride length * @param {NonNegativeInteger} offsetX - starting index @@ -43,7 +43,7 @@ var addon = require( './../src/addon.node' ); * * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * -* scopyWithin( 6, 3, 1, 4, x, 1, 0 ); +* scopyWithin( x.length, 3, 1, 4, x, 1, 0 ); * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] */ function scopyWithin( N, target, start, end, x, strideX, offsetX ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js index 550e7dce5898..4a5b603114bf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js @@ -30,9 +30,9 @@ var ndarray = require( './ndarray.js' ); * Performs an in-place copy of elements within a single-precision floating-point array. * * @param {PositiveInteger} N - number of indexed elements -* @param {integer} target - target index -* @param {integer} start - source start index -* @param {integer} end - source end index +* @param {NonNegativeInteger} target - target index +* @param {NonNegativeInteger} start - source start index +* @param {NonNegativeInteger} end - source end index * @param {Float32Array} x - input array * @param {integer} strideX - stride length * @returns {Float32Array} input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js index f9d90540e667..887e8ded9fbf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js @@ -30,9 +30,9 @@ var addon = require( './../src/addon.node' ); * * @private * @param {PositiveInteger} N - number of indexed elements -* @param {integer} target - target index -* @param {integer} start - source start index -* @param {integer} end - source end index +* @param {NonNegativeInteger} target - target index +* @param {NonNegativeInteger} start - source start index +* @param {NonNegativeInteger} end - source end index * @param {Float32Array} x - input array * @param {integer} strideX - stride length * @returns {Float32Array} input array @@ -42,7 +42,7 @@ var addon = require( './../src/addon.node' ); * * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * -* scopyWithin( 6, 3, 1, 4, x, 1 ); +* scopyWithin( x.length, 3, 1, 4, x, 1 ); * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] */ function scopyWithin( N, target, start, end, x, strideX ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/manifest.json index a4180fb5e2f5..90035b091ecb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/manifest.json @@ -41,8 +41,6 @@ "@stdlib/blas/base/shared", "@stdlib/blas/base/scopy", "@stdlib/strided/base/stride2offset", - "@stdlib/math/base/special/max", - "@stdlib/math/base/special/min", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -63,9 +61,7 @@ "dependencies": [ "@stdlib/blas/base/shared", "@stdlib/blas/base/scopy", - "@stdlib/strided/base/stride2offset", - "@stdlib/math/base/special/max", - "@stdlib/math/base/special/min" + "@stdlib/strided/base/stride2offset" ] }, { @@ -82,9 +78,7 @@ "dependencies": [ "@stdlib/blas/base/shared", "@stdlib/blas/base/scopy", - "@stdlib/strided/base/stride2offset", - "@stdlib/math/base/special/max", - "@stdlib/math/base/special/min" + "@stdlib/strided/base/stride2offset" ] }, { @@ -101,9 +95,7 @@ "dependencies": [ "@stdlib/blas/base/shared", "@stdlib/blas/base/scopy", - "@stdlib/strided/base/stride2offset", - "@stdlib/math/base/special/max", - "@stdlib/math/base/special/min" + "@stdlib/strided/base/stride2offset" ] } ] diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/addon.c index 403ae8c5a901..3c942040d768 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/addon.c @@ -38,8 +38,8 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, start, argv, 2 ); STDLIB_NAPI_ARGV_INT64( env, end, argv, 3 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, x, N, strideX, argv, 4 ); - API_SUFFIX(stdlib_strided_scopy_within)( N, target, start, end, x, strideX ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 4 ); + API_SUFFIX(stdlib_strided_scopy_within)( N, target, start, end, X, strideX ); return NULL; } @@ -58,8 +58,8 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, end, argv, 3 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 6 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, x, N, strideX, argv, 4 ); - API_SUFFIX(stdlib_strided_scopy_within_ndarray)( N, target, start, end, x, strideX, offsetX ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 4 ); + API_SUFFIX(stdlib_strided_scopy_within_ndarray)( N, target, start, end, X, strideX, offsetX ); return NULL; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c index b901e35ded6e..65e12364fe4a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c @@ -20,9 +20,6 @@ #include "stdlib/blas/base/shared.h" #include "stdlib/blas/base/scopy.h" #include "stdlib/strided/base/stride2offset.h" -#include "stdlib/math/base/special/max.h" -#include "stdlib/math/base/special/min.h" -#include #include /** @@ -32,12 +29,12 @@ * @param target target index * @param start source start index * @param end source end index -* @param x input array +* @param X input array * @param strideX stride length */ -void API_SUFFIX(stdlib_strided_scopy_within)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *x, const CBLAS_INT strideX ) { +void API_SUFFIX(stdlib_strided_scopy_within)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX ) { CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); - API_SUFFIX(stdlib_strided_scopy_within_ndarray)( N, target, start, end, x, strideX, ox ); + API_SUFFIX(stdlib_strided_scopy_within_ndarray)( N, target, start, end, X, strideX, ox ); } /** @@ -47,68 +44,42 @@ void API_SUFFIX(stdlib_strided_scopy_within)( const CBLAS_INT N, const CBLAS_INT * @param target target index * @param start source start index * @param end source end index -* @param x input array +* @param X input array * @param strideX stride length * @param offsetX starting index */ -void API_SUFFIX(stdlib_strided_scopy_within_ndarray)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { +void API_SUFFIX(stdlib_strided_scopy_within_ndarray)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { CBLAS_INT ssi; - CBLAS_INT sei; CBLAS_INT tsi; - CBLAS_INT tei; CBLAS_INT cl; float *tmp; - bool flg; - if ( N <= 0 ) { + if ( N <= 0 || strideX == 0 || target >= N ) { return; } - if ( target >= N ) { - return; - } - - flg = false; - - // Resolve copy length: - cl = end - start; - if ( cl < 0 ) { - cl = -cl; - } - if ( cl > N ) { - cl = N; + // Resolve the number of elements to copy: + cl = ( ( end < N ) ? end : N ) - start; + if ( cl > N - target ) { + cl = N - target; } if ( cl <= 0 ) { return; } - - // Calculate source and target indices: + // Resolve the starting source and target indices... ssi = offsetX + ( start * strideX ); - sei = ssi + ( ( cl - 1 ) * strideX ); tsi = offsetX + ( target * strideX ); - tei = tsi + ( ( cl - 1 ) * strideX ); - // Check if source and target regions overlap: - if ( - !( stdlib_base_max( ssi, sei ) < stdlib_base_min( tsi, tei ) || - stdlib_base_max( tsi, tei ) < stdlib_base_min( ssi, sei ) ) - ) { - flg = true; - } - - if ( flg ) { - // Create a temporary copy of source elements: - tmp = (float *)malloc( cl * sizeof(float) ); + // When the source and target index ranges overlap, copying directly could overwrite source elements before they are read, and, thus, we first copy the source elements to a temporary array: + if ( start < target + cl && target < start + cl ) { + tmp = (float *)malloc( cl * sizeof( float ) ); if ( tmp == NULL ) { return; } - c_scopy_ndarray( cl, x, strideX, ssi, tmp, 1, 0 ); - - // Copy from temporary array to target position: - c_scopy_ndarray( cl, tmp, 1, 0, x, strideX, tsi ); - - // Clean up memory: + API_SUFFIX(c_scopy_ndarray)( cl, X, strideX, ssi, tmp, 1, 0 ); + API_SUFFIX(c_scopy_ndarray)( cl, tmp, 1, 0, X, strideX, tsi ); free( tmp ); - } else { - c_scopy_ndarray( cl, x, strideX, ssi, x, strideX, tsi ); + return; } + API_SUFFIX(c_scopy_ndarray)( cl, X, strideX, ssi, X, strideX, tsi ); + return; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js index 21cbc78f7958..e957b2332079 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js @@ -52,20 +52,9 @@ tape( 'the function copies values within the provided single-precision floating- t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 6, 6, 0, 3, x, 1, 0 ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - actual = scopyWithin( 6, 10, 0, 3, x, 1, 0 ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - actual = scopyWithin( 4, 5, 0, 3, x, 1, 0 ); + actual = scopyWithin( 6, 3, 0, 3, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -73,7 +62,7 @@ tape( 'the function copies values within the provided single-precision floating- x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 3, 2, 0, 3, x, 1, 0 ); + actual = scopyWithin( 5, 2, 0, 5, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -81,106 +70,128 @@ tape( 'the function copies values within the provided single-precision floating- t.end(); }); -tape( 'the function supports providing an offset parameter', function test( t ) { +tape( 'if provided `target` parameter is greater than or equal to the `N` parameter, the function returns the strided array unchanged', function test( t ) { var expected; var actual; var x; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 2.0, 3.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 6, 0, 3, x, 1, 0 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( 4, 3, 0, 2, x, 1, 1 ); + actual = scopyWithin( 6, 10, 0, 3, x, 1, 0 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + actual = scopyWithin( 4, 5, 0, 3, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function supports providing a stride parameter', function test( t ) { +tape( 'if provided `N` parameter is less than or equal to `0`, the function returns the strided array unchanged', function test( t ) { var expected; var actual; var x; - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - expected = new Float32Array( [ 3.0, 2.0, 5.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 2, 0, 1, 4, x, 2, 0 ); + actual = scopyWithin( 0, 3, 1, 4, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); + + actual = scopyWithin( -1, 3, 1, 4, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function supports providing negative strides', function test( t ) { +tape( 'if provided `start` parameter is greater than or equal to the `end` parameter, the function returns the strided array unchanged', function test( t ) { var expected; var actual; var x; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 3, 0, 1, 3, x, -1, 2 ); + actual = scopyWithin( 6, 0, 3, 1, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 4, 0, 2, 4, x, -1, 3 ); + actual = scopyWithin( 6, 0, 2, 2, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - t.end(); }); -tape( 'the function supports a reversed source range (start > end)', function test( t ) { +tape( 'if provided `end` parameter is greater than the number of indexed elements, the function copies elements up to the last indexed element', function test( t ) { var expected; var actual; var x; - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 4.0, 5.0, 3.0, 4.0, 5.0, 6.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + expected = new Float32Array( [ 3.0, 4.0, 5.0, 4.0, 5.0 ] ); - actual = scopyWithin( 6, 0, 3, 1, x, 1, 0 ); + actual = scopyWithin( 5, 0, 2, 10, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns the strided array unchanged if `start` equals `end`', function test( t ) { +tape( 'the function supports providing a stride parameter', function test( t ) { var expected; var actual; var x; - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 5.0, 2.0, 7.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - actual = scopyWithin( 6, 0, 2, 2, x, 1, 0 ); + actual = scopyWithin( 4, 0, 2, 4, x, 2, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports a stride of zero', function test( t ) { +tape( 'the function supports providing negative strides', function test( t ) { var expected; var actual; var x; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 1, 0, 2, x, 0, 0 ); + actual = scopyWithin( 3, 0, 1, 3, x, -1, 2 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); + + actual = scopyWithin( 4, 0, 2, 4, x, -1, 3 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function returns the strided array unchanged if `N` is less than or equal to `0`', function test( t ) { +tape( 'the function supports a stride of zero', function test( t ) { var expected; var actual; var x; @@ -188,15 +199,24 @@ tape( 'the function returns the strided array unchanged if `N` is less than or e x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 0, 3, 1, 4, x, 1, 0 ); + actual = scopyWithin( 6, 1, 0, 2, x, 0, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); - actual = scopyWithin( -1, 3, 1, 4, x, 1, 0 ); +tape( 'the function supports providing an offset parameter', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 6.0 ] ); + + actual = scopyWithin( 4, 2, 0, 2, x, 1, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js index a7265264bc3b..262a74ae83c7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js @@ -63,20 +63,9 @@ tape( 'the function copies values within the provided single-precision floating- t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 6, 6, 0, 3, x, 1, 0 ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - actual = scopyWithin( 6, 10, 0, 3, x, 1, 0 ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - actual = scopyWithin( 4, 5, 0, 3, x, 1, 0 ); + actual = scopyWithin( 6, 3, 0, 3, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -84,7 +73,7 @@ tape( 'the function copies values within the provided single-precision floating- x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 3, 2, 0, 3, x, 1, 0 ); + actual = scopyWithin( 5, 2, 0, 5, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -92,106 +81,128 @@ tape( 'the function copies values within the provided single-precision floating- t.end(); }); -tape( 'the function supports providing an offset parameter', opts, function test( t ) { +tape( 'if provided `target` parameter is greater than or equal to the `N` parameter, the function returns the strided array unchanged', opts, function test( t ) { var expected; var actual; var x; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 2.0, 3.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 6, 0, 3, x, 1, 0 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( 4, 3, 0, 2, x, 1, 1 ); + actual = scopyWithin( 6, 10, 0, 3, x, 1, 0 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + actual = scopyWithin( 4, 5, 0, 3, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function supports providing a stride parameter', opts, function test( t ) { +tape( 'if provided `N` parameter is less than or equal to `0`, the function returns the strided array unchanged', opts, function test( t ) { var expected; var actual; var x; - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - expected = new Float32Array( [ 3.0, 2.0, 5.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 2, 0, 1, 4, x, 2, 0 ); + actual = scopyWithin( 0, 3, 1, 4, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); + + actual = scopyWithin( -1, 3, 1, 4, x, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function supports providing negative strides', opts, function test( t ) { +tape( 'if provided `start` parameter is greater than or equal to the `end` parameter, the function returns the strided array unchanged', opts, function test( t ) { var expected; var actual; var x; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 3, 0, 1, 3, x, -1, 2 ); + actual = scopyWithin( 6, 0, 3, 1, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 4, 0, 2, 4, x, -1, 3 ); + actual = scopyWithin( 6, 0, 2, 2, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - t.end(); }); -tape( 'the function supports a reversed source range (start > end)', opts, function test( t ) { +tape( 'if provided `end` parameter is greater than the number of indexed elements, the function copies elements up to the last indexed element', opts, function test( t ) { var expected; var actual; var x; - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 4.0, 5.0, 3.0, 4.0, 5.0, 6.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + expected = new Float32Array( [ 3.0, 4.0, 5.0, 4.0, 5.0 ] ); - actual = scopyWithin( 6, 0, 3, 1, x, 1, 0 ); + actual = scopyWithin( 5, 0, 2, 10, x, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns the strided array unchanged if `start` equals `end`', opts, function test( t ) { +tape( 'the function supports providing a stride parameter', opts, function test( t ) { var expected; var actual; var x; - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 5.0, 2.0, 7.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - actual = scopyWithin( 6, 0, 2, 2, x, 1, 0 ); + actual = scopyWithin( 4, 0, 2, 4, x, 2, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports a stride of zero', opts, function test( t ) { +tape( 'the function supports providing negative strides', opts, function test( t ) { var expected; var actual; var x; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 1, 0, 2, x, 0, 0 ); + actual = scopyWithin( 3, 0, 1, 3, x, -1, 2 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); + + actual = scopyWithin( 4, 0, 2, 4, x, -1, 3 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function returns the strided array unchanged if `N` is less than or equal to `0`', opts, function test( t ) { +tape( 'the function supports a stride of zero', opts, function test( t ) { var expected; var actual; var x; @@ -199,15 +210,24 @@ tape( 'the function returns the strided array unchanged if `N` is less than or e x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 0, 3, 1, 4, x, 1, 0 ); + actual = scopyWithin( 6, 1, 0, 2, x, 0, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); - actual = scopyWithin( -1, 3, 1, 4, x, 1, 0 ); +tape( 'the function supports providing an offset parameter', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 6.0 ] ); + + actual = scopyWithin( 4, 2, 0, 2, x, 1, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js index fe8460bf389f..721054c0c246 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js @@ -52,20 +52,9 @@ tape( 'the function copies values within the provided single-precision floating- t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - actual = scopyWithin( 6, 6, 0, 3, x, 1 ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - actual = scopyWithin( 6, 10, 0, 3, x, 1 ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 4, 5, 0, 3, x, 1 ); + actual = scopyWithin( 6, 3, 0, 3, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -73,7 +62,7 @@ tape( 'the function copies values within the provided single-precision floating- x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 3, 2, 0, 3, x, 1 ); + actual = scopyWithin( 5, 2, 0, 5, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -81,38 +70,43 @@ tape( 'the function copies values within the provided single-precision floating- t.end(); }); -tape( 'the function supports providing a stride parameter', function test( t ) { +tape( 'if provided `target` parameter is greater than or equal to the `N` parameter, the function returns the strided array unchanged', function test( t ) { var expected; var actual; var x; - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - expected = new Float32Array( [ 3.0, 2.0, 5.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 6, 0, 3, x, 1 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( 2, 0, 1, 4, x, 2 ); + actual = scopyWithin( 6, 10, 0, 3, x, 1 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + actual = scopyWithin( 4, 5, 0, 3, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function supports providing negative strides', function test( t ) { +tape( 'if provided `N` parameter is less than or equal to `0`, the function returns the strided array unchanged', function test( t ) { var expected; var actual; var x; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 3, 0, 1, 3, x, -1 ); + actual = scopyWithin( 0, 3, 1, 4, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); - - actual = scopyWithin( 4, 0, 2, 4, x, -1 ); + actual = scopyWithin( -1, 3, 1, 4, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -120,68 +114,94 @@ tape( 'the function supports providing negative strides', function test( t ) { t.end(); }); -tape( 'the function supports a reversed source range (start > end)', function test( t ) { +tape( 'if provided `start` parameter is greater than or equal to the `end` parameter, the function returns the strided array unchanged', function test( t ) { var expected; var actual; var x; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 4.0, 5.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); actual = scopyWithin( 6, 0, 3, 1, x, 1 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 0, 2, 2, x, 1 ); + t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns the strided array unchanged if `start` equals `end`', function test( t ) { +tape( 'if provided `end` parameter is greater than the number of indexed elements, the function copies elements up to the last indexed element', function test( t ) { var expected; var actual; var x; - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + expected = new Float32Array( [ 3.0, 4.0, 5.0, 4.0, 5.0 ] ); - actual = scopyWithin( 6, 0, 2, 2, x, 1 ); + actual = scopyWithin( 5, 0, 2, 10, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports a stride of zero', function test( t ) { +tape( 'the function supports providing a stride parameter', function test( t ) { var expected; var actual; var x; - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 5.0, 2.0, 7.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - actual = scopyWithin( 6, 1, 0, 2, x, 0 ); + actual = scopyWithin( 4, 0, 2, 4, x, 2 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns the strided array unchanged if `N` is less than or equal to `0`', function test( t ) { +tape( 'the function supports providing negative strides', function test( t ) { var expected; var actual; var x; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 0, 3, 1, 4, x, 1 ); + actual = scopyWithin( 3, 0, 1, 3, x, -1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( -1, 3, 1, 4, x, 1 ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); + + actual = scopyWithin( 4, 0, 2, 4, x, -1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); + +tape( 'the function supports a stride of zero', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 1, 0, 2, x, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js index 57705788fa84..0cd369336a20 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js @@ -63,20 +63,17 @@ tape( 'the function copies values within the provided single-precision floating- t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 6, 6, 0, 3, x, 1 ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); + actual = scopyWithin( 6, 3, 0, 3, x, 1 ); - actual = scopyWithin( 6, 10, 0, 3, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 3, 2, 0, 3, x, 1 ); + actual = scopyWithin( 5, 2, 0, 5, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -84,38 +81,43 @@ tape( 'the function copies values within the provided single-precision floating- t.end(); }); -tape( 'the function supports providing a stride parameter', opts, function test( t ) { +tape( 'if provided `target` parameter is greater than or equal to the `N` parameter, the function returns the strided array unchanged', opts, function test( t ) { var expected; var actual; var x; - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - expected = new Float32Array( [ 3.0, 2.0, 5.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 2, 0, 1, 4, x, 2 ); + actual = scopyWithin( 6, 6, 0, 3, x, 1 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + actual = scopyWithin( 6, 10, 0, 3, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); + + actual = scopyWithin( 4, 5, 0, 3, x, 1 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function supports providing negative strides', opts, function test( t ) { +tape( 'if provided `N` parameter is less than or equal to `0`, the function returns the strided array unchanged', opts, function test( t ) { var expected; var actual; var x; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 3, 0, 1, 3, x, -1 ); + actual = scopyWithin( 0, 3, 1, 4, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); - - actual = scopyWithin( 4, 0, 2, 4, x, -1 ); + actual = scopyWithin( -1, 3, 1, 4, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -123,66 +125,94 @@ tape( 'the function supports providing negative strides', opts, function test( t t.end(); }); -tape( 'the function supports a reversed source range (start > end)', opts, function test( t ) { +tape( 'if provided `start` parameter is greater than or equal to the `end` parameter, the function returns the strided array unchanged', opts, function test( t ) { var expected; var actual; var x; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 4.0, 5.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); actual = scopyWithin( 6, 0, 3, 1, x, 1 ); + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 0, 2, 2, x, 1 ); + t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns the strided array unchanged if `start` equals `end`', opts, function test( t ) { +tape( 'if provided `end` parameter is greater than the number of indexed elements, the function copies elements up to the last indexed element', opts, function test( t ) { var expected; var actual; var x; - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + expected = new Float32Array( [ 3.0, 4.0, 5.0, 4.0, 5.0 ] ); - actual = scopyWithin( 6, 0, 2, 2, x, 1 ); + actual = scopyWithin( 5, 0, 2, 10, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports a stride of zero', opts, function test( t ) { +tape( 'the function supports providing a stride parameter', opts, function test( t ) { var expected; var actual; var x; - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 5.0, 2.0, 7.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - actual = scopyWithin( 6, 1, 0, 2, x, 0 ); + actual = scopyWithin( 4, 0, 2, 4, x, 2 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns the strided array unchanged if `N` is less than or equal to `0`', opts, function test( t ) { +tape( 'the function supports providing negative strides', opts, function test( t ) { var expected; var actual; var x; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 3, 0, 1, 3, x, -1 ); - actual = scopyWithin( 0, 3, 1, 4, x, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( -1, 3, 1, 4, x, 1 ); + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); + + actual = scopyWithin( 4, 0, 2, 4, x, -1 ); + t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); + +tape( 'the function supports a stride of zero', opts, function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 6, 1, 0, 2, x, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); From 43bbeb3cfaeefcf91f311d2b5e0f4bd2a042b05a Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 2 Aug 2026 15:43:03 +0500 Subject: [PATCH 5/8] fix: cleanup --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../blas/ext/base/scopy-within/README.md | 87 ++-- .../base/scopy-within/benchmark/benchmark.js | 9 +- .../benchmark/benchmark.native.js | 9 +- .../benchmark/benchmark.ndarray.js | 9 +- .../benchmark/benchmark.ndarray.native.js | 9 +- .../benchmark/c/benchmark.length.c | 18 +- .../blas/ext/base/scopy-within/docs/repl.txt | 61 ++- .../base/scopy-within/docs/types/index.d.ts | 61 ++- .../ext/base/scopy-within/docs/types/test.ts | 391 +++++++++++------- .../base/scopy-within/examples/c/example.c | 8 +- .../ext/base/scopy-within/examples/index.js | 5 +- .../stdlib/blas/ext/base/scopy_within.h | 4 +- .../blas/ext/base/scopy-within/lib/index.js | 6 +- .../blas/ext/base/scopy-within/lib/ndarray.js | 33 +- .../base/scopy-within/lib/ndarray.native.js | 18 +- .../ext/base/scopy-within/lib/scopy_within.js | 21 +- .../scopy-within/lib/scopy_within.native.js | 15 +- .../blas/ext/base/scopy-within/src/addon.c | 13 +- .../blas/ext/base/scopy-within/src/main.c | 43 +- .../base/scopy-within/test/test.ndarray.js | 115 +++++- .../scopy-within/test/test.ndarray.native.js | 115 +++++- .../scopy-within/test/test.scopy_within.js | 124 +++++- .../test/test.scopy_within.native.js | 124 +++++- 23 files changed, 924 insertions(+), 374 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md index f55c41cda5fa..51a4ae2f8539 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md @@ -30,7 +30,7 @@ limitations under the License. var scopyWithin = require( '@stdlib/blas/ext/base/scopy-within' ); ``` -#### scopyWithin( N, target, start, end, x, strideX ) +#### scopyWithin( N, target, start, end, x, strideX, workspace, strideW ) Performs an in-place copy of elements within a single-precision floating-point array. @@ -38,8 +38,9 @@ Performs an in-place copy of elements within a single-precision floating-point a var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var w = new Float32Array( x.length ); -scopyWithin( x.length, 3, 1, 4, x, 1 ); +scopyWithin( x.length, 3, 1, 4, x, 1, w, 1 ); // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ``` @@ -47,10 +48,12 @@ The function has the following parameters: - **N**: number of indexed elements. - **target**: target index. -- **start**: source start index. -- **end**: source end index. +- **start**: source start index (inclusive). +- **end**: source end index (exclusive). - **x**: input [`Float32Array`][@stdlib/array/float32]. -- **strideX**: stride length. +- **strideX**: stride length for `x`. +- **workspace**: workspace [`Float32Array`][@stdlib/array/float32]. Must have at least `N` indexed elements. +- **strideW**: stride length for `workspace`. The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to copy every other element: @@ -58,8 +61,9 @@ The `N` and stride parameters determine which elements in the strided array are var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0 ] ); +var w = new Float32Array( 3 ); -scopyWithin( 3, 0, 1, 6, x, 2 ); +scopyWithin( 3, 0, 1, 6, x, 2, w, 1 ); // x => [ 3.0, 0.0, 5.0, 0.0, 5.0, 0.0, 7.0, 0.0 ] ``` @@ -74,12 +78,17 @@ var x0 = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); // Create an offset view... var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +// Create a workspace array... +var w = new Float32Array( 6 ); + // Copy within the view... -scopyWithin( 6, 0, 3, 6, x1, 1 ); +scopyWithin( 6, 0, 3, 6, x1, 1, w, 1 ); // x0 => [ 1.0, 5.0, 6.0, 7.0, 5.0, 6.0, 7.0, 8.0 ] ``` -#### scopyWithin.ndarray( N, target, start, end, x, strideX, offsetX ) + + +#### scopyWithin.ndarray( N, target, start, end, x, strideX, offsetX, workspace, strideW, offsetW ) Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. @@ -87,23 +96,26 @@ Performs an in-place copy of elements within a single-precision floating-point a var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var w = new Float32Array( x.length ); -scopyWithin.ndarray( x.length, 3, 1, 4, x, 1, 0 ); +scopyWithin.ndarray( x.length, 3, 1, 4, x, 1, 0, w, 1, 0 ); // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ``` The function has the following additional parameters: - **offsetX**: starting index for `x`. +- **offsetW**: starting index for `workspace`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to copy elements starting from the third element: +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 elements starting from the third element: ```javascript var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var w = new Float32Array( 4 ); -scopyWithin.ndarray( 4, 2, 0, 2, x, 1, 2 ); +scopyWithin.ndarray( 4, 2, 0, 2, x, 1, 2, w, 1, 0 ); // x => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 7.0, 8.0 ] ``` @@ -118,6 +130,7 @@ scopyWithin.ndarray( 4, 2, 0, 2, x, 1, 2 ); - If `N <= 0`, both functions return the strided array unchanged. - If `target >= N`, both functions return the strided array unchanged. - If `start >= end`, both functions return the strided array unchanged. +- If the `start` and `target` index ranges do not overlap, the `workspace` array is unused and thus ignored. - Both functions **mutate** the provided input strided array. @@ -132,6 +145,7 @@ scopyWithin.ndarray( 4, 2, 0, 2, x, 1, 2 ); ```javascript var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var zeros = require( '@stdlib/array/zeros' ); var scopyWithin = require( '@stdlib/blas/ext/base/scopy-within' ); var x = discreteUniform( 10, 0, 500, { @@ -139,8 +153,10 @@ var x = discreteUniform( 10, 0, 500, { }); console.log( x ); +var w = zeros( 10, 'float32' ); + // Copy the first 3 elements to positions 5, 6, 7: -scopyWithin( 10, 5, 0, 3, x, 1 ); +scopyWithin( 10, 5, 0, 3, x, 1, w, 1 ); console.log( x ); ``` @@ -174,55 +190,58 @@ console.log( x ); #include "stdlib/blas/ext/base/scopy_within.h" ``` -#### stdlib_strided_scopy_within( N, target, start, end, \*X, strideX ) +#### stdlib_strided_scopy_within( N, target, start, end, \*X, strideX, \*W, strideW ) Performs an in-place copy of elements within a single-precision floating-point array. ```c float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; +float w[ 6 ]; -stdlib_strided_scopy_within( 6, 3, 1, 4, x, 1 ); +stdlib_strided_scopy_within( 6, 3, 1, 4, x, 1, w, 1 ); ``` The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. - **target**: `[in] CBLAS_INT` target index. -- **start**: `[in] CBLAS_INT` source start index. -- **end**: `[in] CBLAS_INT` source end index. +- **start**: `[in] CBLAS_INT` source start index (inclusive). +- **end**: `[in] CBLAS_INT` source end index (exclusive). - **X**: `[inout] float*` input array. -- **strideX**: `[in] CBLAS_INT` stride length. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **W**: `[out] float*` workspace array. Must have at least `N` indexed elements. +- **strideW**: `[in] CBLAS_INT` stride length for `W`. ```c -void stdlib_strided_scopy_within( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX ); +void stdlib_strided_scopy_within( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, float *W, const CBLAS_INT strideW ); ``` - - -### stdlib_strided_scopy_within_ndarray( N, target, start, end, \*X, strideX, offsetX ) - - +#### stdlib_strided_scopy_within_ndarray( N, target, start, end, \*X, strideX, offsetX, \*W, strideW, offsetW ) Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. ```c float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; +float w[ 6 ]; -stdlib_strided_scopy_within_ndarray( 4, 2, 0, 2, x, 1, 1 ); +stdlib_strided_scopy_within_ndarray( 4, 2, 0, 2, x, 1, 1, w, 1, 0 ); ``` The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. - **target**: `[in] CBLAS_INT` target index. -- **start**: `[in] CBLAS_INT` source start index. -- **end**: `[in] CBLAS_INT` source end index. +- **start**: `[in] CBLAS_INT` source start index (inclusive). +- **end**: `[in] CBLAS_INT` source end index (exclusive). - **X**: `[inout] float*` input array. -- **strideX**: `[in] CBLAS_INT` stride length. -- **offsetX**: `[in] CBLAS_INT` starting index. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **W**: `[out] float*` workspace array. Must have at least `N` indexed elements. +- **strideW**: `[in] CBLAS_INT` stride length for `W`. +- **offsetW**: `[in] CBLAS_INT` starting index for `W`. ```c -void stdlib_strided_scopy_within_ndarray( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +void stdlib_strided_scopy_within_ndarray( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *W, const CBLAS_INT strideW, const CBLAS_INT offsetW ); ``` @@ -251,18 +270,22 @@ int main( void ) { // Create a strided array: float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + // Create a workspace array: + float w[ 8 ]; + // Specify the number of elements to copy: const int N = 8; - // Specify a stride: + // Specify strides: const int strideX = 1; + const int strideW = 1; // Copy elements starting from index 1 to index 4: - stdlib_strided_scopy_within( N, 4, 1, 4, x, strideX ); + stdlib_strided_scopy_within( N, 4, 1, 4, x, strideX, w, strideW ); // Print the result: for ( int i = 0; i < 8; i++ ) { - printf( "x[ %i ] = %lf\n", i, x[ i ] ); + printf( "x[ %i ] = %f\n", i, x[ i ] ); } } ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js index c4238659bc78..04a721eff298 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); +var zeros = require( '@stdlib/array/zeros' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -46,7 +47,11 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = uniform( len, -10.0, 10.0, options ); + var x; + var w; + + x = uniform( len, -10.0, 10.0, options ); + w = zeros( len, options.dtype ); return benchmark; /** @@ -61,7 +66,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = scopyWithin( len, 0, 0, len - 1, x, 1 ); + y = scopyWithin( len, 0, 0, len - 1, x, 1, w, 1 ); if ( isnanf( y[ i%y.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.native.js index 5b901672702d..9c335ac3153f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.native.js @@ -23,6 +23,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); +var zeros = require( '@stdlib/array/zeros' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -51,7 +52,11 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = uniform( len, -10.0, 10.0, options ); + var x; + var w; + + x = uniform( len, -10.0, 10.0, options ); + w = zeros( len, options.dtype ); return benchmark; /** @@ -66,7 +71,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = scopyWithin( len, 0, 0, len - 1, x, 1 ); + y = scopyWithin( len, 0, 0, len - 1, x, 1, w, 1 ); if ( isnanf( y[ i%y.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js index 1bd7392162a8..7fbce424daa4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); +var zeros = require( '@stdlib/array/zeros' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -46,7 +47,11 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = uniform( len, -10.0, 10.0, options ); + var x; + var w; + + x = uniform( len, -10.0, 10.0, options ); + w = zeros( len, options.dtype ); return benchmark; /** @@ -61,7 +66,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = scopyWithin( len, 0, 0, len - 1, x, 1, 0 ); + y = scopyWithin( len, 0, 0, len - 1, x, 1, 0, w, 1, 0 ); if ( isnanf( y[ i%y.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.native.js index fdb76317ece6..d2abc45b81a6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.native.js @@ -23,6 +23,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); +var zeros = require( '@stdlib/array/zeros' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -51,7 +52,11 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = uniform( len, -10.0, 10.0, options ); + var x; + var w; + + x = uniform( len, -10.0, 10.0, options ); + w = zeros( len, options.dtype ); return benchmark; /** @@ -66,7 +71,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = scopyWithin( len, 0, 0, len - 1, x, 1, 0 ); + y = scopyWithin( len, 0, 0, len - 1, x, 1, 0, w, 1, 0 ); if ( isnanf( y[ i%y.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c index b6e8a7016089..0d25c10503dc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c @@ -99,17 +99,19 @@ static float rand_float( void ) { static double benchmark1( int iterations, int len ) { double elapsed; float *x; + float *w; double t; int i; x = (float *)malloc( len * sizeof( float ) ); + w = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*200.0f ) - 100.0f; + w[ i ] = 0.0f; } t = tic(); for ( i = 0; i < iterations; i++ ) { - // cppcheck-suppress uninitvar - API_SUFFIX(stdlib_strided_scopy_within)( len, 0, 0, len - 1, x, 1 ); + API_SUFFIX(stdlib_strided_scopy_within)( len, 0, 0, len - 1, x, 1, w, 1 ); if ( x[ 0 ] != x[ 0 ] ) { printf( "should not return NaN\n" ); break; @@ -120,6 +122,7 @@ static double benchmark1( int iterations, int len ) { printf( "should not return NaN\n" ); } free( x ); + free( w ); return elapsed; } @@ -133,17 +136,19 @@ static double benchmark1( int iterations, int len ) { static double benchmark2( int iterations, int len ) { double elapsed; float *x; + float *w; double t; int i; x = (float *)malloc( len * sizeof( float ) ); + w = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*200.0f ) - 100.0f; + w[ i ] = 0.0f; } t = tic(); for ( i = 0; i < iterations; i++ ) { - // cppcheck-suppress uninitvar - API_SUFFIX(stdlib_strided_scopy_within_ndarray)( len, 0, 0, len - 1, x, 1, 0 ); + API_SUFFIX(stdlib_strided_scopy_within_ndarray)( len, 0, 0, len - 1, x, 1, 0, w, 1, 0 ); if ( x[ 0 ] != x[ 0 ] ) { printf( "should not return NaN\n" ); break; @@ -154,6 +159,7 @@ static double benchmark2( int iterations, int len ) { printf( "should not return NaN\n" ); } free( x ); + free( w ); return elapsed; } @@ -183,13 +189,13 @@ int main( void ) { } for ( j = 0; j < REPEATS; j++ ) { count += 1; - printf( "# c::native::%s:len=%d\n", NAME, len ); + printf( "# c::%s:len=%d\n", NAME, len ); elapsed = benchmark1( iter, len ); print_results( "scopy_within:len", elapsed ); printf( "ok %d benchmark finished\n", count ); count += 1; - printf( "# c::native::%s:ndarray:len=%d\n", NAME, len ); + printf( "# c::%s:ndarray:len=%d\n", NAME, len ); elapsed = benchmark2( iter, len ); print_results( "scopy_within_ndarray:len", elapsed ); printf( "ok %d benchmark finished\n", count ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt index 376736ab5b11..07dd89eb717c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt @@ -1,12 +1,13 @@ -{{alias}}( N, target, start, end, x, strideX ) + +{{alias}}( N, target, start, end, x, strideX, w, strideW ) Performs an in-place copy of elements within a single-precision floating- point array. The `N` and stride parameters determine which elements in the strided array are accessed at runtime. - Indexing is relative to the first index. To introduce an offset, use typed - array views. + Indexing is relative to the first index. To introduce an offset, use a typed + array view. If `N <= 0`, the function returns the strided array unchanged. @@ -14,6 +15,9 @@ If `start >= end`, the function returns the strided array unchanged. + If the `start` and `target` index ranges do not overlap, the `workspace` + array is unused and thus ignored. + Parameters ---------- N: integer @@ -23,16 +27,22 @@ Target index. start: integer - Source start index. + Source start index (inclusive). end: integer - Source end index. + Source end index (exclusive). x: Float32Array Input array. strideX: integer - Stride length. + Stride length for `x`. + + w: Float32Array + Workspace array. Must have at least `N` indexed elements. + + strideW: integer + Stride length for `w`. Returns ------- @@ -43,30 +53,33 @@ -------- // Standard Usage: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > {{alias}}( 6, 3, 1, 4, x, 1 ) + > var w = new {{alias:@stdlib/array/float32}}( 6 ); + > {{alias}}( 6, 3, 1, 4, x, 1, w, 1 ) [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] // Using `N` and stride parameters: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - > {{alias}}( 3, 0, 1, 6, x, 2 ) + > w = new {{alias:@stdlib/array/float32}}( 3 ); + > {{alias}}( 3, 0, 1, 6, x, 2, w, 1 ) [ 3.0, 2.0, 5.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] // Using view offsets: > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > {{alias}}( 4, 0, 2, 4, x1, 1 ) + > var w0 = new {{alias:@stdlib/array/float32}}( 4 ); + > {{alias}}( 4, 0, 2, 4, x1, 1, w0, 1 ) [ 4.0, 5.0, 4.0, 5.0, 6.0 ] > x0 [ 1.0, 4.0, 5.0, 4.0, 5.0, 6.0 ] -{{alias}}.ndarray( N, target, start, end, x, strideX, offsetX ) +{{alias}}.ndarray( N, target, start, end, x,strideX,offsetX, w,strideW,offsetW ) Performs an in-place copy of elements within a single-precision floating- point array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying - buffer, the offset parameter supports indexing semantics based on a - starting index. + buffer, the offset parameters support indexing semantics based on starting + indices. Parameters ---------- @@ -77,19 +90,28 @@ Target index. start: integer - Source start index. + Source start index (inclusive). end: integer - Source end index. + Source end index (exclusive). x: Float32Array Input array. strideX: integer - Stride length. + Stride length for `x`. offsetX: integer - Starting index. + Starting index for `x`. + + w: Float32Array + Workspace array. Must have at least `N` indexed elements. + + strideW: integer + Stride length for `w`. + + offsetW: integer + Starting index for `w`. Returns ------- @@ -100,13 +122,16 @@ -------- // Standard Usage: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > {{alias}}.ndarray( 4, 2, 0, 2, x, 1, 1 ) + > var w = new {{alias:@stdlib/array/float32}}( 4 ); + > {{alias}}.ndarray( 4, 2, 0, 2, x, 1, 1, w, 1, 0 ) [ 1.0, 2.0, 3.0, 2.0, 3.0, 6.0 ] // Using an index offset: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > {{alias}}.ndarray( 3, 1, 0, 2, x, 1, 2 ) + > w = new {{alias:@stdlib/array/float32}}( 3 ); + > {{alias}}.ndarray( 3, 1, 0, 2, x, 1, 2, w, 1, 0 ) [ 1.0, 2.0, 3.0, 3.0, 4.0, 6.0 ] See Also -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/index.d.ts index 35266fd60ea7..bf589dab9f79 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/index.d.ts @@ -25,72 +25,95 @@ interface Routine { /** * Performs an in-place copy of elements within a single-precision floating-point array. * + * ## Notes + * + * - If the `start` and `target` index ranges do not overlap, the `workspace` array is unused and thus ignored. + * * @param N - number of indexed elements * @param target - target index - * @param start - source start index - * @param end - source end index + * @param start - source start index (inclusive) + * @param end - source end index (exclusive) * @param x - input array - * @param strideX - stride length - * @returns input array + * @param strideX - stride length for `x` + * @param workspace - workspace array + * @param strideW - stride length for `workspace` + * @returns `x` * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var w = new Float32Array( x.length ); * - * scopyWithin( x.length, 3, 1, 4, x, 1 ); + * scopyWithin( x.length, 3, 1, 4, x, 1, w, 1 ); * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] */ - ( N: number, target: number, start: number, end: number, x: Float32Array, strideX: number ): Float32Array; + ( N: number, target: number, start: number, end: number, x: Float32Array, strideX: number, workspace: Float32Array, strideW: number ): Float32Array; /** * Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. * + * ## Notes + * + * - If the `start` and `target` index ranges do not overlap, the `workspace` array is unused and thus ignored. + * * @param N - number of indexed elements * @param target - target index - * @param start - source start index - * @param end - source end index + * @param start - source start index (inclusive) + * @param end - source end index (exclusive) * @param x - input array - * @param strideX - stride length - * @param offsetX - starting index - * @returns input array + * @param strideX - stride length for `x` + * @param offsetX - starting index for `x` + * @param workspace - workspace array + * @param strideW - stride length for `workspace` + * @param offsetW - starting index for `workspace` + * @returns `x` * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var w = new Float32Array( x.length ); * - * scopyWithin.ndarray( x.length, 3, 1, 4, x, 1, 0 ); + * scopyWithin.ndarray( x.length, 3, 1, 4, x, 1, 0, w, 1, 0 ); * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] */ - ndarray( N: number, target: number, start: number, end: number, x: Float32Array, strideX: number, offsetX: number ): Float32Array; + ndarray( N: number, target: number, start: number, end: number, x: Float32Array, strideX: number, offsetX: number, workspace: Float32Array, strideW: number, offsetW: number ): Float32Array; } /** * Performs an in-place copy of elements within a single-precision floating-point array. * +* ## Notes +* +* - If the `start` and `target` index ranges do not overlap, the `workspace` array is unused and thus ignored. +* * @param N - number of indexed elements * @param target - target index -* @param start - source start index -* @param end - source end index +* @param start - source start index (inclusive) +* @param end - source end index (exclusive) * @param x - input array -* @param strideX - stride length -* @returns input array +* @param strideX - stride length for `x` +* @param workspace - workspace array +* @param strideW - stride length for `workspace` +* @returns `x` * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var w = new Float32Array( x.length ); * -* scopyWithin( x.length, 3, 1, 4, x, 1 ); +* scopyWithin( x.length, 3, 1, 4, x, 1, w, 1 ); * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var w = new Float32Array( x.length ); * -* scopyWithin.ndarray( x.length, 3, 1, 4, x, 1, 0 ); +* scopyWithin.ndarray( x.length, 3, 1, 4, x, 1, 0, w, 1, 0 ); * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] */ declare var scopyWithin: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/test.ts index 759d72d0c5ab..ef9ced3184aa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/test.ts @@ -23,221 +23,322 @@ import scopyWithin = require( './index' ); // The function returns a Float32Array... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); - scopyWithin( 3, 3, 1, 2, x, 1 ); // $ExpectType Float32Array + scopyWithin( x.length, 3, 1, 4, x, 1, w, 1 ); // $ExpectType Float32Array } // The compiler throws an error if the function is provided a first argument which is not a number... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - scopyWithin( '3', 3, 1, 2, x, 1 ); // $ExpectError - scopyWithin( true, 3, 1, 2, x, 1 ); // $ExpectError - scopyWithin( false, 3, 1, 2, x, 1 ); // $ExpectError - scopyWithin( null, 3, 1, 2, x, 1 ); // $ExpectError - scopyWithin( undefined, 3, 1, 2, x, 1 ); // $ExpectError - scopyWithin( [], 3, 1, 2, x, 1 ); // $ExpectError - scopyWithin( {}, 3, 1, 2, x, 1 ); // $ExpectError - scopyWithin( ( x: number ): number => x, 3, 1, 2, x, 1 ); // $ExpectError + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin( '3', 3, 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( true, 3, 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( false, 3, 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( null, 3, 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( undefined, 3, 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( [], 3, 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( {}, 3, 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( ( x: number ): number => x, 3, 1, 2, x, 1, w, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - scopyWithin( 3, '3', 1, 2, x, 1 ); // $ExpectError - scopyWithin( 3, true, 1, 2, x, 1 ); // $ExpectError - scopyWithin( 3, false, 1, 2, x, 1 ); // $ExpectError - scopyWithin( 3, null, 1, 2, x, 1 ); // $ExpectError - scopyWithin( 3, undefined, 1, 2, x, 1 ); // $ExpectError - scopyWithin( 3, [], 1, 2, x, 1 ); // $ExpectError - scopyWithin( 3, {}, 1, 2, x, 1 ); // $ExpectError - scopyWithin( 3, ( x: number ): number => x, 1, 2, x, 1 ); // $ExpectError + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin( x.length, '3', 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, true, 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, false, 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, null, 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, undefined, 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, [], 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, {}, 1, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, ( x: number ): number => x, 1, 2, x, 1, w, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - scopyWithin( 3, 3, '1', 2, x, 1 ); // $ExpectError - scopyWithin( 3, 3, true, 2, x, 1 ); // $ExpectError - scopyWithin( 3, 3, false, 2, x, 1 ); // $ExpectError - scopyWithin( 3, 3, null, 2, x, 1 ); // $ExpectError - scopyWithin( 3, 3, undefined, 2, x, 1 ); // $ExpectError - scopyWithin( 3, 3, [], 2, x, 1 ); // $ExpectError - scopyWithin( 3, 3, {}, 2, x, 1 ); // $ExpectError - scopyWithin( 3, 3, ( x: number ): number => x, 2, x, 1 ); // $ExpectError + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin( x.length, 3, '1', 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, true, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, false, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, null, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, undefined, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, [], 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, {}, 2, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, ( x: number ): number => x, 2, x, 1, w, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - scopyWithin( 3, 3, 1, '2', x, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, true, x, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, false, x, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, null, x, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, undefined, x, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, [], x, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, {}, x, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, ( x: number ): number => x, x, 1 ); // $ExpectError + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin( x.length, 3, 1, '2', x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, true, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, false, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, null, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, undefined, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, [], x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, {}, x, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, ( x: number ): number => x, x, 1, w, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a Float32Array... { - scopyWithin( 3, 3, 1, 2, '3', 1 ); // $ExpectError - scopyWithin( 3, 3, 1, 2, 3, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, 2, true, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, 2, false, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, 2, null, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, 2, undefined, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, 2, [], 1 ); // $ExpectError - scopyWithin( 3, 3, 1, 2, {}, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, 2, ( x: number ): number => x, 1 ); // $ExpectError + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin( x.length, 3, 1, 2, '5', 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, 5, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, true, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, false, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, null, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, undefined, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, [], 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, {}, 1, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, ( x: number ): number => x, 1, w, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a sixth argument which is not a number... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin( x.length, 3, 1, 2, x, '4', w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, true, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, false, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, null, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, undefined, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, [], w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, {}, w, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, ( x: number ): number => x, w, 1 ); // $ExpectError +} - scopyWithin( 3, 3, 1, 2, x, '4' ); // $ExpectError - scopyWithin( 3, 3, 1, 2, x, true ); // $ExpectError - scopyWithin( 3, 3, 1, 2, x, false ); // $ExpectError - scopyWithin( 3, 3, 1, 2, x, null ); // $ExpectError - scopyWithin( 3, 3, 1, 2, x, undefined ); // $ExpectError - scopyWithin( 3, 3, 1, 2, x, [] ); // $ExpectError - scopyWithin( 3, 3, 1, 2, x, {} ); // $ExpectError - scopyWithin( 3, 3, 1, 2, x, ( x: number ): number => x ); // $ExpectError +// The compiler throws an error if the function is provided a seventh argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + + scopyWithin( x.length, 3, 1, 2, x, 1, '5', 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, 5, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, true, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, false, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, null, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, undefined, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, [], 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, {}, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin( x.length, 3, 1, 2, x, 1, w, '1' ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, w, true ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, w, false ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, w, null ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, w, undefined ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, w, [] ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, w, {} ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, w, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided insufficient arguments... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); scopyWithin(); // $ExpectError - scopyWithin( 3 ); // $ExpectError - scopyWithin( 3, 3 ); // $ExpectError - scopyWithin( 3, 3, 1 ); // $ExpectError - scopyWithin( 3, 3, 1, 2 ); // $ExpectError - scopyWithin( 3, 3, 1, 2, x ); // $ExpectError - scopyWithin( 3, 3, 1, 2, x, 1, {} ); // $ExpectError + scopyWithin( x.length ); // $ExpectError + scopyWithin( x.length, 3 ); // $ExpectError + scopyWithin( x.length, 3, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1 ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, w ); // $ExpectError + scopyWithin( x.length, 3, 1, 2, x, 1, w, 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a Float32Array... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); - scopyWithin.ndarray( 3, 3, 1, 2, x, 1, 1 ); // $ExpectType Float32Array + scopyWithin.ndarray( x.length, 3, 1, 4, x, 1, 0, w, 1, 0 ); // $ExpectType Float32Array } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - scopyWithin.ndarray( '2', 3, 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( true, 3, 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( false, 3, 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( null, 3, 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( undefined, 3, 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( [], 2, 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( {}, 2, 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( ( x: number ): number => x, 2, 1, 2, x, 1, 0 ); // $ExpectError + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin.ndarray( '2', 3, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( true, 3, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( false, 3, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( null, 3, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( undefined, 3, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( [], 3, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( {}, 3, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( ( x: number ): number => x, 3, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - scopyWithin.ndarray( 2, '2', 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, true, 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, false, 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, null, 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, undefined, 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, [], 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, {}, 1, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, ( x: number ): number => x, 1, 2, x, 1, 0 ); // $ExpectError + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin.ndarray( x.length, '3', 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, true, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, false, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, null, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, undefined, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, [], 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, {}, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, ( x: number ): number => x, 1, 2, x, 1, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - scopyWithin.ndarray( 2, 2, '1', 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, true, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, false, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, null, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, undefined, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, [], 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, {}, 2, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, ( x: number ): number => x, 2, x, 1, 0 ); // $ExpectError + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin.ndarray( x.length, 3, '1', 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, true, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, false, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, null, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, undefined, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, [], 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, {}, 2, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, ( x: number ): number => x, 2, x, 1, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - scopyWithin.ndarray( 2, 2, 1, '2', x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, true, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, false, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, null, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, undefined, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, [], x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, {}, x, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, ( x: number ): number => x, x, 1, 0 ); // $ExpectError + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin.ndarray( x.length, 3, 1, '2', x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, true, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, false, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, null, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, undefined, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, [], x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, {}, x, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, ( x: number ): number => x, x, 1, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Float32Array... { - scopyWithin.ndarray( 2, 2, 1, 2, '5', 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, 5, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, true, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, false, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, null, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, undefined, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, [], 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, {}, 1, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, ( x: number ): number => x, 1, 0 ); // $ExpectError + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin.ndarray( x.length, 3, 1, 2, '5', 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, 5, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, true, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, false, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, null, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, undefined, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, [], 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, {}, 1, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, ( x: number ): number => x, 1, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - scopyWithin.ndarray( 2, 2, 1, 2, x, '1', 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, true, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, false, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, null, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, undefined, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, [], 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, {}, 0 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, ( x: number ): number => x, 0 ); // $ExpectError + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin.ndarray( x.length, 3, 1, 2, x, '4', 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, true, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, false, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, null, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, undefined, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, [], 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, {}, 0, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, ( x: number ): number => x, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, '0', w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, true, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, false, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, null, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, undefined, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, [], w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, {}, w, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, ( x: number ): number => x, w, 1, 0 ); // $ExpectError +} - scopyWithin.ndarray( 2, 2, 1, 2, x, 1, '0' ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, 1, true ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, 1, false ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, 1, null ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, 1, undefined ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, 1, [] ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, 1, {} ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, 1, ( x: number ): number => x ); // $ExpectError +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, '5', 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, 5, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, true, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, false, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, null, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, undefined, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, [], 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, {}, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, '1', 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, true, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, false, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, null, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, undefined, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, [], 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, {}, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); + + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, 1, '0' ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, 1, true ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, 1, false ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, 1, null ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, 1, undefined ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, 1, [] ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, 1, {} ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided insufficient arguments... { - const x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const x = new Float32Array( 10 ); + const w = new Float32Array( 10 ); scopyWithin.ndarray(); // $ExpectError - scopyWithin.ndarray( 2 ); // $ExpectError - scopyWithin.ndarray( 2, 2 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, 1 ); // $ExpectError - scopyWithin.ndarray( 2, 2, 1, 2, x, 1, 0, {} ); // $ExpectError + scopyWithin.ndarray( x.length ); // $ExpectError + scopyWithin.ndarray( x.length, 3 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, 1 ); // $ExpectError + scopyWithin.ndarray( x.length, 3, 1, 2, x, 1, 0, w, 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/example.c index 2635366efe0f..fba89e774e75 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/example.c @@ -23,14 +23,18 @@ int main( void ) { // Create a strided array: float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + // Create a workspace array: + float w[ 8 ]; + // Specify the number of elements to copy: const int N = 8; - // Specify a stride: + // Specify strides: const int strideX = 1; + const int strideW = 1; // Copy elements starting from index 1 to index 4: - stdlib_strided_scopy_within( N, 4, 1, 4, x, strideX ); + stdlib_strided_scopy_within( N, 4, 1, 4, x, strideX, w, strideW ); // Print the result: for ( int i = 0; i < 8; i++ ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/index.js index 020c93ee9acb..a1f9998efb3c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/index.js @@ -19,6 +19,7 @@ 'use strict'; var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var zeros = require( '@stdlib/array/zeros' ); var scopyWithin = require( './../lib' ); var x = discreteUniform( 10, 0, 500, { @@ -26,6 +27,8 @@ var x = discreteUniform( 10, 0, 500, { }); console.log( x ); +var w = zeros( 10, 'float32' ); + // Copy the first 3 elements to positions 5, 6, 7: -scopyWithin( 10, 5, 0, 3, x, 1 ); +scopyWithin( 10, 5, 0, 3, x, 1, w, 1 ); console.log( x ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include/stdlib/blas/ext/base/scopy_within.h b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include/stdlib/blas/ext/base/scopy_within.h index d7b12eea0f28..a4273578816c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include/stdlib/blas/ext/base/scopy_within.h +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include/stdlib/blas/ext/base/scopy_within.h @@ -31,12 +31,12 @@ extern "C" { /** * Performs an in-place copy of elements within a single-precision floating-point array. */ -void API_SUFFIX(stdlib_strided_scopy_within)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX ); +void API_SUFFIX(stdlib_strided_scopy_within)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, float *W, const CBLAS_INT strideW ); /** * Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. */ -void API_SUFFIX(stdlib_strided_scopy_within_ndarray)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +void API_SUFFIX(stdlib_strided_scopy_within_ndarray)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *W, const CBLAS_INT strideW, const CBLAS_INT offsetW ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/index.js index c651ef48c7e1..a7833fbe6bea 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/index.js @@ -28,8 +28,9 @@ * var scopyWithin = require( '@stdlib/blas/ext/base/scopy-within' ); * * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var w = new Float32Array( x.length ); * -* scopyWithin( x.length, 3, 1, 4, x, 1 ); +* scopyWithin( x.length, 3, 1, 4, x, 1, w, 1 ); * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] * * @example @@ -37,8 +38,9 @@ * var scopyWithin = require( '@stdlib/blas/ext/base/scopy-within' ); * * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var w = new Float32Array( x.length ); * -* scopyWithin.ndarray( x.length, 3, 1, 4, x, 1, 0 ); +* scopyWithin.ndarray( x.length, 3, 1, 4, x, 1, 0, w, 1, 0 ); * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] */ diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js index f6585197dcf9..dd4c6109d9f8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js @@ -20,8 +20,7 @@ // MODULES // -var min = require( '@stdlib/math/base/special/min' ); -var Float32Array = require( '@stdlib/array/float32' ); +var min = require( '@stdlib/math/base/special/fast/min' ); var scopy = require( '@stdlib/blas/base/scopy' ).ndarray; @@ -30,25 +29,32 @@ var scopy = require( '@stdlib/blas/base/scopy' ).ndarray; /** * Performs an in-place copy of elements within a single-precision floating-point array. * +* ## Notes +* +* - If the `start` and `target` index ranges do not overlap, the `workspace` array is unused and thus ignored. +* * @param {PositiveInteger} N - number of indexed elements * @param {NonNegativeInteger} target - target index -* @param {NonNegativeInteger} start - source start index -* @param {NonNegativeInteger} end - source end index +* @param {NonNegativeInteger} start - source start index (inclusive) +* @param {NonNegativeInteger} end - source end index (exclusive) * @param {Float32Array} x - input array -* @param {integer} strideX - stride length -* @param {NonNegativeInteger} offsetX - starting index +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float32Array} workspace - workspace array +* @param {integer} strideW - stride length for `workspace` +* @param {NonNegativeInteger} offsetW - starting index for `workspace` * @returns {Float32Array} input array * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var w = new Float32Array( x.length ); * -* scopyWithin( x.length, 3, 1, 4, x, 1, 0 ); +* scopyWithin( x.length, 3, 1, 4, x, 1, 0, w, 1, 0 ); * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] */ -function scopyWithin( N, target, start, end, x, strideX, offsetX ) { - var tmp; +function scopyWithin( N, target, start, end, x, strideX, offsetX, workspace, strideW, offsetW ) { // eslint-disable-line max-len var ssi; var tsi; var cl; @@ -65,11 +71,10 @@ function scopyWithin( N, target, start, end, x, strideX, offsetX ) { ssi = offsetX + ( start * strideX ); tsi = offsetX + ( target * strideX ); - // When the source and target index ranges overlap, copying directly could overwrite source elements before they are read, and, thus, we first copy the source elements to a temporary array: - if ( start < target + cl && target < start + cl ) { - tmp = new Float32Array( cl ); - scopy( cl, x, strideX, ssi, tmp, 1, 0 ); - scopy( cl, tmp, 1, 0, x, strideX, tsi ); + // When the source and target index ranges overlap, copying directly could overwrite source elements before they are read, and, thus, we first copy the source elements to a workspace array: + if ( start < target+cl && target < start+cl ) { + scopy( cl, x, strideX, ssi, workspace, strideW, offsetW ); + scopy( cl, workspace, strideW, offsetW, x, strideX, tsi ); return x; } scopy( cl, x, strideX, ssi, x, strideX, tsi ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js index 0ca5b76dae8d..eedad918b20a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js @@ -31,23 +31,27 @@ var addon = require( './../src/addon.node' ); * @private * @param {PositiveInteger} N - number of indexed elements * @param {NonNegativeInteger} target - target index -* @param {NonNegativeInteger} start - source start index -* @param {NonNegativeInteger} end - source end index +* @param {NonNegativeInteger} start - source start index (inclusive) +* @param {NonNegativeInteger} end - source end index (exclusive) * @param {Float32Array} x - input array -* @param {integer} strideX - stride length -* @param {NonNegativeInteger} offsetX - starting index +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float32Array} workspace - workspace array +* @param {integer} strideW - stride length for `workspace` +* @param {NonNegativeInteger} offsetW - starting index for `workspace` * @returns {Float32Array} input array * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var w = new Float32Array( x.length ); * -* scopyWithin( x.length, 3, 1, 4, x, 1, 0 ); +* scopyWithin( x.length, 3, 1, 4, x, 1, 0, w, 1, 0 ); * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] */ -function scopyWithin( N, target, start, end, x, strideX, offsetX ) { - addon.ndarray( N, target, start, end, x, strideX, offsetX ); +function scopyWithin( N, target, start, end, x, strideX, offsetX, workspace, strideW, offsetW ) { // eslint-disable-line max-len + addon.ndarray( N, target, start, end, x, strideX, offsetX, workspace, strideW, offsetW ); // eslint-disable-line max-len return x; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js index 4a5b603114bf..ca7e2f7629fb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js @@ -29,24 +29,33 @@ var ndarray = require( './ndarray.js' ); /** * Performs an in-place copy of elements within a single-precision floating-point array. * +* ## Notes +* +* - If the `start` and `target` index ranges do not overlap, the `workspace` array is unused and thus ignored. +* * @param {PositiveInteger} N - number of indexed elements * @param {NonNegativeInteger} target - target index -* @param {NonNegativeInteger} start - source start index -* @param {NonNegativeInteger} end - source end index +* @param {NonNegativeInteger} start - source start index (inclusive) +* @param {NonNegativeInteger} end - source end index (exclusive) * @param {Float32Array} x - input array -* @param {integer} strideX - stride length +* @param {integer} strideX - stride length for `x` +* @param {Float32Array} workspace - workspace array +* @param {integer} strideW - stride length for `workspace` * @returns {Float32Array} input array * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var w = new Float32Array( x.length ); * -* scopyWithin( x.length, 3, 1, 4, x, 1 ); +* scopyWithin( x.length, 3, 1, 4, x, 1, w, 1 ); * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] */ -function scopyWithin( N, target, start, end, x, strideX ) { - return ndarray( N, target, start, end, x, strideX, stride2offset( N, strideX ) ); // eslint-disable-line max-len +function scopyWithin( N, target, start, end, x, strideX, workspace, strideW ) { + var ox = stride2offset( N, strideX ); + var ow = stride2offset( N, strideW ); + return ndarray( N, target, start, end, x, strideX, ox, workspace, strideW, ow ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js index 887e8ded9fbf..69958e880b56 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js @@ -31,22 +31,25 @@ var addon = require( './../src/addon.node' ); * @private * @param {PositiveInteger} N - number of indexed elements * @param {NonNegativeInteger} target - target index -* @param {NonNegativeInteger} start - source start index -* @param {NonNegativeInteger} end - source end index +* @param {NonNegativeInteger} start - source start index (inclusive) +* @param {NonNegativeInteger} end - source end index (exclusive) * @param {Float32Array} x - input array -* @param {integer} strideX - stride length +* @param {integer} strideX - stride length for `x` +* @param {Float32Array} workspace - workspace array +* @param {integer} strideW - stride length for `workspace` * @returns {Float32Array} input array * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var w = new Float32Array( x.length ); * -* scopyWithin( x.length, 3, 1, 4, x, 1 ); +* scopyWithin( x.length, 3, 1, 4, x, 1, w, 1 ); * // x => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] */ -function scopyWithin( N, target, start, end, x, strideX ) { - addon( N, target, start, end, x, strideX ); +function scopyWithin( N, target, start, end, x, strideX, workspace, strideW ) { + addon( N, target, start, end, x, strideX, workspace, strideW ); return x; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/addon.c index 3c942040d768..3ec389b43412 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/addon.c @@ -32,14 +32,16 @@ * @return Node-API value */ static napi_value addon( napi_env env, napi_callback_info info ) { - STDLIB_NAPI_ARGV( env, info, argv, argc, 6 ); + STDLIB_NAPI_ARGV( env, info, argv, argc, 8 ); STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); STDLIB_NAPI_ARGV_INT64( env, target, argv, 1 ); STDLIB_NAPI_ARGV_INT64( env, start, argv, 2 ); STDLIB_NAPI_ARGV_INT64( env, end, argv, 3 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, strideW, argv, 7 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 4 ); - API_SUFFIX(stdlib_strided_scopy_within)( N, target, start, end, X, strideX ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, W, N, strideW, argv, 6 ); + API_SUFFIX(stdlib_strided_scopy_within)( N, target, start, end, X, strideX, W, strideW ); return NULL; } @@ -51,15 +53,18 @@ static napi_value addon( napi_env env, napi_callback_info info ) { * @return Node-API value */ static napi_value addon_method( napi_env env, napi_callback_info info ) { - STDLIB_NAPI_ARGV( env, info, argv, argc, 7 ); + STDLIB_NAPI_ARGV( env, info, argv, argc, 10 ); STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); STDLIB_NAPI_ARGV_INT64( env, target, argv, 1 ); STDLIB_NAPI_ARGV_INT64( env, start, argv, 2 ); STDLIB_NAPI_ARGV_INT64( env, end, argv, 3 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 6 ); + STDLIB_NAPI_ARGV_INT64( env, strideW, argv, 8 ); + STDLIB_NAPI_ARGV_INT64( env, offsetW, argv, 9 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 4 ); - API_SUFFIX(stdlib_strided_scopy_within_ndarray)( N, target, start, end, X, strideX, offsetX ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, W, N, strideW, argv, 7 ); + API_SUFFIX(stdlib_strided_scopy_within_ndarray)( N, target, start, end, X, strideX, offsetX, W, strideW, offsetW ); return NULL; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c index 65e12364fe4a..ff35a771cecc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c @@ -20,21 +20,23 @@ #include "stdlib/blas/base/shared.h" #include "stdlib/blas/base/scopy.h" #include "stdlib/strided/base/stride2offset.h" -#include /** * Performs an in-place copy of elements within a single-precision floating-point array. * * @param N number of indexed elements * @param target target index -* @param start source start index -* @param end source end index +* @param start source start index (inclusive) +* @param end source end index (exclusive) * @param X input array -* @param strideX stride length +* @param strideX stride length for `X` +* @param W workspace array +* @param strideW stride length for `W` */ -void API_SUFFIX(stdlib_strided_scopy_within)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX ) { - CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); - API_SUFFIX(stdlib_strided_scopy_within_ndarray)( N, target, start, end, X, strideX, ox ); +void API_SUFFIX(stdlib_strided_scopy_within)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, float *W, const CBLAS_INT strideW ) { + const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + const CBLAS_INT ow = stdlib_strided_stride2offset( N, strideW ); + API_SUFFIX(stdlib_strided_scopy_within_ndarray)( N, target, start, end, X, strideX, ox, W, strideW, ow ); } /** @@ -42,22 +44,24 @@ void API_SUFFIX(stdlib_strided_scopy_within)( const CBLAS_INT N, const CBLAS_INT * * @param N number of indexed elements * @param target target index -* @param start source start index -* @param end source end index +* @param start source start index (inclusive) +* @param end source end index (exclusive) * @param X input array -* @param strideX stride length -* @param offsetX starting index +* @param strideX stride length for `X` +* @param offsetX starting index for `X` +* @param W workspace array +* @param strideW stride length for `W` +* @param offsetW starting index for `W` */ -void API_SUFFIX(stdlib_strided_scopy_within_ndarray)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { +void API_SUFFIX(stdlib_strided_scopy_within_ndarray)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *W, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { CBLAS_INT ssi; CBLAS_INT tsi; CBLAS_INT cl; - float *tmp; if ( N <= 0 || strideX == 0 || target >= N ) { return; } - // Resolve the number of elements to copy: + // Resolve the number of elements to copy (note: intentionally avoid `stdlib_base_min`, which operates on double-precision floating-point numbers)... cl = ( ( end < N ) ? end : N ) - start; if ( cl > N - target ) { cl = N - target; @@ -69,15 +73,10 @@ void API_SUFFIX(stdlib_strided_scopy_within_ndarray)( const CBLAS_INT N, const C ssi = offsetX + ( start * strideX ); tsi = offsetX + ( target * strideX ); - // When the source and target index ranges overlap, copying directly could overwrite source elements before they are read, and, thus, we first copy the source elements to a temporary array: + // When the source and target index ranges overlap, copying directly could overwrite source elements before they are read, and, thus, we first copy the source elements to a workspace array: if ( start < target + cl && target < start + cl ) { - tmp = (float *)malloc( cl * sizeof( float ) ); - if ( tmp == NULL ) { - return; - } - API_SUFFIX(c_scopy_ndarray)( cl, X, strideX, ssi, tmp, 1, 0 ); - API_SUFFIX(c_scopy_ndarray)( cl, tmp, 1, 0, X, strideX, tsi ); - free( tmp ); + API_SUFFIX(c_scopy_ndarray)( cl, X, strideX, ssi, W, strideW, offsetW ); + API_SUFFIX(c_scopy_ndarray)( cl, W, strideW, offsetW, X, strideX, tsi ); return; } API_SUFFIX(c_scopy_ndarray)( cl, X, strideX, ssi, X, strideX, tsi ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js index e957b2332079..f67fa7b58046 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.js @@ -33,8 +33,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 7', function test( t ) { - t.strictEqual( scopyWithin.length, 7, 'returns expected value' ); +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( scopyWithin.length, 10, 'returns expected value' ); t.end(); }); @@ -42,27 +42,31 @@ tape( 'the function copies values within the provided single-precision floating- var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ); - actual = scopyWithin( 6, 3, 1, 4, x, 1, 0 ); + actual = scopyWithin( 6, 3, 1, 4, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 6, 3, 0, 3, x, 1, 0 ); + actual = scopyWithin( 6, 3, 0, 3, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + w = new Float32Array( 5 ); expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 5, 2, 0, 5, x, 1, 0 ); + actual = scopyWithin( 5, 2, 0, 5, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -74,19 +78,21 @@ tape( 'if provided `target` parameter is greater than or equal to the `N` parame var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 6, 0, 3, x, 1, 0 ); + actual = scopyWithin( 6, 6, 0, 3, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( 6, 10, 0, 3, x, 1, 0 ); + actual = scopyWithin( 6, 10, 0, 3, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( 4, 5, 0, 3, x, 1, 0 ); + actual = scopyWithin( 4, 5, 0, 3, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -97,16 +103,18 @@ tape( 'if provided `N` parameter is less than or equal to `0`, the function retu var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 0, 3, 1, 4, x, 1, 0 ); + actual = scopyWithin( 0, 3, 1, 4, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( -1, 3, 1, 4, x, 1, 0 ); + actual = scopyWithin( -1, 3, 1, 4, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -118,19 +126,22 @@ tape( 'if provided `start` parameter is greater than or equal to the `end` param var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 0, 3, 1, x, 1, 0 ); + actual = scopyWithin( 6, 0, 3, 1, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 0, 2, 2, x, 1, 0 ); + actual = scopyWithin( 6, 0, 2, 2, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -141,49 +152,56 @@ tape( 'if provided `end` parameter is greater than the number of indexed element var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + w = new Float32Array( 5 ); expected = new Float32Array( [ 3.0, 4.0, 5.0, 4.0, 5.0 ] ); - actual = scopyWithin( 5, 0, 2, 10, x, 1, 0 ); + actual = scopyWithin( 5, 0, 2, 10, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports providing a stride parameter', function test( t ) { +tape( 'the function supports providing an `x` stride parameter', function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + w = new Float32Array( 4 ); expected = new Float32Array( [ 5.0, 2.0, 7.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - actual = scopyWithin( 4, 0, 2, 4, x, 2, 0 ); + actual = scopyWithin( 4, 0, 2, 4, x, 2, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports providing negative strides', function test( t ) { +tape( 'the function supports providing an `x` negative stride parameter', function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 3 ); expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 3, 0, 1, 3, x, -1, 2 ); + actual = scopyWithin( 3, 0, 1, 3, x, -1, 2, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + w = new Float32Array( 4 ); expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); - actual = scopyWithin( 4, 0, 2, 4, x, -1, 3 ); + actual = scopyWithin( 4, 0, 2, 4, x, -1, 3, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -195,26 +213,81 @@ tape( 'the function supports a stride of zero', function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 1, 0, 2, x, 0, 0 ); + actual = scopyWithin( 6, 1, 0, 2, x, 0, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports providing an offset parameter', function test( t ) { +tape( 'the function supports providing an `x` offset parameter', function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 4 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 6.0 ] ); - actual = scopyWithin( 4, 2, 0, 2, x, 1, 1 ); + actual = scopyWithin( 4, 2, 0, 2, x, 1, 1, w, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing a `workspace` stride parameter', function test( t ) { + var expected; + var actual; + var x; + var w; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 5 ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 3, 1, 0, 2, x, 1, 0, w, 2, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing a `workspace` negative stride parameter', function test( t ) { + var expected; + var actual; + var x; + var w; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ); + + actual = scopyWithin( 6, 3, 1, 4, x, 1, 0, w, -1, 5 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing a `workspace` offset parameter', function test( t ) { + var expected; + var actual; + var x; + var w; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 5 ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 3, 1, 0, 2, x, 1, 0, w, 1, 2 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js index 262a74ae83c7..7536f6f12b97 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js @@ -44,8 +44,8 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); -tape( 'the function has an arity of 7', opts, function test( t ) { - t.strictEqual( scopyWithin.length, 7, 'returns expected value' ); +tape( 'the function has an arity of 10', opts, function test( t ) { + t.strictEqual( scopyWithin.length, 10, 'returns expected value' ); t.end(); }); @@ -53,27 +53,31 @@ tape( 'the function copies values within the provided single-precision floating- var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ); - actual = scopyWithin( 6, 3, 1, 4, x, 1, 0 ); + actual = scopyWithin( 6, 3, 1, 4, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 6, 3, 0, 3, x, 1, 0 ); + actual = scopyWithin( 6, 3, 0, 3, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + w = new Float32Array( 5 ); expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 5, 2, 0, 5, x, 1, 0 ); + actual = scopyWithin( 5, 2, 0, 5, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -85,19 +89,21 @@ tape( 'if provided `target` parameter is greater than or equal to the `N` parame var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 6, 0, 3, x, 1, 0 ); + actual = scopyWithin( 6, 6, 0, 3, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( 6, 10, 0, 3, x, 1, 0 ); + actual = scopyWithin( 6, 10, 0, 3, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( 4, 5, 0, 3, x, 1, 0 ); + actual = scopyWithin( 4, 5, 0, 3, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -108,16 +114,18 @@ tape( 'if provided `N` parameter is less than or equal to `0`, the function retu var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 0, 3, 1, 4, x, 1, 0 ); + actual = scopyWithin( 0, 3, 1, 4, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( -1, 3, 1, 4, x, 1, 0 ); + actual = scopyWithin( -1, 3, 1, 4, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -129,19 +137,22 @@ tape( 'if provided `start` parameter is greater than or equal to the `end` param var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 0, 3, 1, x, 1, 0 ); + actual = scopyWithin( 6, 0, 3, 1, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 0, 2, 2, x, 1, 0 ); + actual = scopyWithin( 6, 0, 2, 2, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -152,49 +163,56 @@ tape( 'if provided `end` parameter is greater than the number of indexed element var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + w = new Float32Array( 5 ); expected = new Float32Array( [ 3.0, 4.0, 5.0, 4.0, 5.0 ] ); - actual = scopyWithin( 5, 0, 2, 10, x, 1, 0 ); + actual = scopyWithin( 5, 0, 2, 10, x, 1, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports providing a stride parameter', opts, function test( t ) { +tape( 'the function supports providing an `x` stride parameter', opts, function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + w = new Float32Array( 4 ); expected = new Float32Array( [ 5.0, 2.0, 7.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - actual = scopyWithin( 4, 0, 2, 4, x, 2, 0 ); + actual = scopyWithin( 4, 0, 2, 4, x, 2, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports providing negative strides', opts, function test( t ) { +tape( 'the function supports providing an `x` negative stride parameter', opts, function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 3 ); expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 3, 0, 1, 3, x, -1, 2 ); + actual = scopyWithin( 3, 0, 1, 3, x, -1, 2, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + w = new Float32Array( 4 ); expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); - actual = scopyWithin( 4, 0, 2, 4, x, -1, 3 ); + actual = scopyWithin( 4, 0, 2, 4, x, -1, 3, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -206,26 +224,81 @@ tape( 'the function supports a stride of zero', opts, function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 1, 0, 2, x, 0, 0 ); + actual = scopyWithin( 6, 1, 0, 2, x, 0, 0, w, 1, 0 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports providing an offset parameter', opts, function test( t ) { +tape( 'the function supports providing an `x` offset parameter', opts, function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 4 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 6.0 ] ); - actual = scopyWithin( 4, 2, 0, 2, x, 1, 1 ); + actual = scopyWithin( 4, 2, 0, 2, x, 1, 1, w, 1, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing a `workspace` stride parameter', opts, function test( t ) { + var expected; + var actual; + var x; + var w; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 5 ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 3, 1, 0, 2, x, 1, 0, w, 2, 0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing a `workspace` negative stride parameter', opts, function test( t ) { + var expected; + var actual; + var x; + var w; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ); + + actual = scopyWithin( 6, 3, 1, 4, x, 1, 0, w, -1, 5 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing a `workspace` offset parameter', opts, function test( t ) { + var expected; + var actual; + var x; + var w; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 5 ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 3, 1, 0, 2, x, 1, 0, w, 1, 2 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js index 721054c0c246..43a8e7344d6e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.js @@ -33,8 +33,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 6', function test( t ) { - t.strictEqual( scopyWithin.length, 6, 'returns expected value' ); +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( scopyWithin.length, 8, 'returns expected value' ); t.end(); }); @@ -42,27 +42,31 @@ tape( 'the function copies values within the provided single-precision floating- var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ); - actual = scopyWithin( 6, 3, 1, 4, x, 1 ); + actual = scopyWithin( 6, 3, 1, 4, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 6, 3, 0, 3, x, 1 ); + actual = scopyWithin( 6, 3, 0, 3, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + w = new Float32Array( 5 ); expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 5, 2, 0, 5, x, 1 ); + actual = scopyWithin( 5, 2, 0, 5, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -74,19 +78,21 @@ tape( 'if provided `target` parameter is greater than or equal to the `N` parame var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 6, 0, 3, x, 1 ); + actual = scopyWithin( 6, 6, 0, 3, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( 6, 10, 0, 3, x, 1 ); + actual = scopyWithin( 6, 10, 0, 3, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( 4, 5, 0, 3, x, 1 ); + actual = scopyWithin( 4, 5, 0, 3, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -97,16 +103,18 @@ tape( 'if provided `N` parameter is less than or equal to `0`, the function retu var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 0, 3, 1, 4, x, 1 ); + actual = scopyWithin( 0, 3, 1, 4, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( -1, 3, 1, 4, x, 1 ); + actual = scopyWithin( -1, 3, 1, 4, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -118,19 +126,22 @@ tape( 'if provided `start` parameter is greater than or equal to the `end` param var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 0, 3, 1, x, 1 ); + actual = scopyWithin( 6, 0, 3, 1, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 0, 2, 2, x, 1 ); + actual = scopyWithin( 6, 0, 2, 2, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -141,49 +152,56 @@ tape( 'if provided `end` parameter is greater than the number of indexed element var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + w = new Float32Array( 5 ); expected = new Float32Array( [ 3.0, 4.0, 5.0, 4.0, 5.0 ] ); - actual = scopyWithin( 5, 0, 2, 10, x, 1 ); + actual = scopyWithin( 5, 0, 2, 10, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports providing a stride parameter', function test( t ) { +tape( 'the function supports providing an `x` stride parameter', function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + w = new Float32Array( 4 ); expected = new Float32Array( [ 5.0, 2.0, 7.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - actual = scopyWithin( 4, 0, 2, 4, x, 2 ); + actual = scopyWithin( 4, 0, 2, 4, x, 2, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports providing negative strides', function test( t ) { +tape( 'the function supports providing an `x` negative stride parameter', function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 3 ); expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 3, 0, 1, 3, x, -1 ); + actual = scopyWithin( 3, 0, 1, 3, x, -1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + w = new Float32Array( 4 ); expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); - actual = scopyWithin( 4, 0, 2, 4, x, -1 ); + actual = scopyWithin( 4, 0, 2, 4, x, -1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -195,13 +213,81 @@ tape( 'the function supports a stride of zero', function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 1, 0, 2, x, 0 ); + actual = scopyWithin( 6, 1, 0, 2, x, 0, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); + +tape( 'the function supports providing a `workspace` stride parameter', function test( t ) { + var expected; + var actual; + var x; + var w; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 5 ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 3, 1, 0, 2, x, 1, w, 2 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing a `workspace` negative stride parameter', function test( t ) { + var expected; + var actual; + var x; + var w; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ); + + actual = scopyWithin( 6, 3, 1, 4, x, 1, w, -1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var expected; + var x0; + var x1; + var w; + + // Initial array... + x0 = new Float32Array([ + 1.0, + 2.0, // 0 + 3.0, // 1 + 4.0, // 2 + 5.0, // 3 + 6.0, // 4 + 7.0, // 5 + 8.0 + ]); + + // Create offset view... + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + + // Create a workspace array... + w = new Float32Array( 6 ); + + scopyWithin( 6, 0, 3, 6, x1, 1, w, 1 ); + + expected = new Float32Array( [ 1.0, 5.0, 6.0, 7.0, 5.0, 6.0, 7.0, 8.0 ] ); + + t.deepEqual( x0, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js index 0cd369336a20..e6ee2d0e97ba 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js @@ -44,8 +44,8 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); -tape( 'the function has an arity of 6', opts, function test( t ) { - t.strictEqual( scopyWithin.length, 6, 'returns expected value' ); +tape( 'the function has an arity of 8', opts, function test( t ) { + t.strictEqual( scopyWithin.length, 8, 'returns expected value' ); t.end(); }); @@ -53,27 +53,31 @@ tape( 'the function copies values within the provided single-precision floating- var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ); - actual = scopyWithin( 6, 3, 1, 4, x, 1 ); + actual = scopyWithin( 6, 3, 1, 4, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 6, 3, 0, 3, x, 1 ); + actual = scopyWithin( 6, 3, 0, 3, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + w = new Float32Array( 5 ); expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 3.0 ] ); - actual = scopyWithin( 5, 2, 0, 5, x, 1 ); + actual = scopyWithin( 5, 2, 0, 5, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -85,19 +89,21 @@ tape( 'if provided `target` parameter is greater than or equal to the `N` parame var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 6, 0, 3, x, 1 ); + actual = scopyWithin( 6, 6, 0, 3, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( 6, 10, 0, 3, x, 1 ); + actual = scopyWithin( 6, 10, 0, 3, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( 4, 5, 0, 3, x, 1 ); + actual = scopyWithin( 4, 5, 0, 3, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -108,16 +114,18 @@ tape( 'if provided `N` parameter is less than or equal to `0`, the function retu var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 0, 3, 1, 4, x, 1 ); + actual = scopyWithin( 0, 3, 1, 4, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); - actual = scopyWithin( -1, 3, 1, 4, x, 1 ); + actual = scopyWithin( -1, 3, 1, 4, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -129,19 +137,22 @@ tape( 'if provided `start` parameter is greater than or equal to the `end` param var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 0, 3, 1, x, 1 ); + actual = scopyWithin( 6, 0, 3, 1, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 0, 2, 2, x, 1 ); + actual = scopyWithin( 6, 0, 2, 2, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -152,49 +163,56 @@ tape( 'if provided `end` parameter is greater than the number of indexed element var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + w = new Float32Array( 5 ); expected = new Float32Array( [ 3.0, 4.0, 5.0, 4.0, 5.0 ] ); - actual = scopyWithin( 5, 0, 2, 10, x, 1 ); + actual = scopyWithin( 5, 0, 2, 10, x, 1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports providing a stride parameter', opts, function test( t ) { +tape( 'the function supports providing an `x` stride parameter', opts, function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + w = new Float32Array( 4 ); expected = new Float32Array( [ 5.0, 2.0, 7.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - actual = scopyWithin( 4, 0, 2, 4, x, 2 ); + actual = scopyWithin( 4, 0, 2, 4, x, 2, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports providing negative strides', opts, function test( t ) { +tape( 'the function supports providing an `x` negative stride parameter', opts, function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 3 ); expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 3, 0, 1, 3, x, -1 ); + actual = scopyWithin( 3, 0, 1, 3, x, -1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + w = new Float32Array( 4 ); expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0 ] ); - actual = scopyWithin( 4, 0, 2, 4, x, -1 ); + actual = scopyWithin( 4, 0, 2, 4, x, -1, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); @@ -206,13 +224,81 @@ tape( 'the function supports a stride of zero', opts, function test( t ) { var expected; var actual; var x; + var w; x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = scopyWithin( 6, 1, 0, 2, x, 0 ); + actual = scopyWithin( 6, 1, 0, 2, x, 0, w, 1 ); t.strictEqual( actual, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); t.end(); }); + +tape( 'the function supports providing a `workspace` stride parameter', opts, function test( t ) { + var expected; + var actual; + var x; + var w; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 5 ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + + actual = scopyWithin( 3, 1, 0, 2, x, 1, w, 2 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing a `workspace` negative stride parameter', opts, function test( t ) { + var expected; + var actual; + var x; + var w; + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + w = new Float32Array( 6 ); + expected = new Float32Array( [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ] ); + + actual = scopyWithin( 6, 3, 1, 4, x, 1, w, -1 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var expected; + var x0; + var x1; + var w; + + // Initial array... + x0 = new Float32Array([ + 1.0, + 2.0, // 0 + 3.0, // 1 + 4.0, // 2 + 5.0, // 3 + 6.0, // 4 + 7.0, // 5 + 8.0 + ]); + + // Create offset view... + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + + // Create a workspace array... + w = new Float32Array( 6 ); + + scopyWithin( 6, 0, 3, 6, x1, 1, w, 1 ); + + expected = new Float32Array( [ 1.0, 5.0, 6.0, 7.0, 5.0, 6.0, 7.0, 8.0 ] ); + + t.deepEqual( x0, expected, 'returns expected value' ); + t.end(); +}); From 383f0f94e8dc9b41fe34cdb440ccaea310dd5cfc Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 2 Aug 2026 21:56:39 +0500 Subject: [PATCH 6/8] fix: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../blas/ext/base/scopy-within/README.md | 14 +++--- .../base/scopy-within/benchmark/benchmark.js | 2 +- .../benchmark/benchmark.ndarray.js | 2 +- .../benchmark/c/benchmark.length.c | 45 ++++++++----------- .../blas/ext/base/scopy-within/docs/repl.txt | 4 +- .../base/scopy-within/docs/types/index.d.ts | 6 +-- .../base/scopy-within/examples/c/example.c | 4 +- .../stdlib/blas/ext/base/scopy_within.h | 4 +- .../blas/ext/base/scopy-within/lib/index.js | 2 +- .../blas/ext/base/scopy-within/lib/ndarray.js | 2 +- .../base/scopy-within/lib/ndarray.native.js | 2 +- .../ext/base/scopy-within/lib/scopy_within.js | 2 +- .../scopy-within/lib/scopy_within.native.js | 2 +- .../blas/ext/base/scopy-within/package.json | 2 +- .../blas/ext/base/scopy-within/src/main.c | 4 +- .../blas/ext/base/scopy-within/test/test.js | 8 ++-- .../scopy-within/test/test.ndarray.native.js | 6 +-- .../test/test.scopy_within.native.js | 6 +-- 18 files changed, 53 insertions(+), 64 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md index 51a4ae2f8539..4cf9f4cc1fe7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md @@ -20,7 +20,7 @@ limitations under the License. # scopyWithin -> Perform an in-place copy of elements within a single-precision floating-point array. +> Perform an in-place copy of elements within a single-precision floating-point strided array.
@@ -32,7 +32,7 @@ var scopyWithin = require( '@stdlib/blas/ext/base/scopy-within' ); #### scopyWithin( N, target, start, end, x, strideX, workspace, strideW ) -Performs an in-place copy of elements within a single-precision floating-point array. +Performs an in-place copy of elements within a single-precision floating-point strided array. ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -90,7 +90,7 @@ scopyWithin( 6, 0, 3, 6, x1, 1, w, 1 ); #### scopyWithin.ndarray( N, target, start, end, x, strideX, offsetX, workspace, strideW, offsetW ) -Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. +Performs an in-place copy of elements within a single-precision floating-point strided array using alternative indexing semantics. ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -192,7 +192,7 @@ console.log( x ); #### stdlib_strided_scopy_within( N, target, start, end, \*X, strideX, \*W, strideW ) -Performs an in-place copy of elements within a single-precision floating-point array. +Performs an in-place copy of elements within a single-precision floating-point strided array. ```c float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; @@ -218,7 +218,7 @@ void stdlib_strided_scopy_within( const CBLAS_INT N, const CBLAS_INT target, con #### stdlib_strided_scopy_within_ndarray( N, target, start, end, \*X, strideX, offsetX, \*W, strideW, offsetW ) -Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. +Performs an in-place copy of elements within a single-precision floating-point strided array using alternative indexing semantics. ```c float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; @@ -273,14 +273,14 @@ int main( void ) { // Create a workspace array: float w[ 8 ]; - // Specify the number of elements to copy: + // Specify the number of indexed elements: const int N = 8; // Specify strides: const int strideX = 1; const int strideW = 1; - // Copy elements starting from index 1 to index 4: + // Copy elements: stdlib_strided_scopy_within( N, 4, 1, 4, x, strideX, w, strideW ); // Print the result: diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js index 04a721eff298..448a1c193e65 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.js @@ -26,8 +26,8 @@ var zeros = require( '@stdlib/array/zeros' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); -var scopyWithin = require( './../lib/scopy_within.js' ); var pkg = require( './../package.json' ).name; +var scopyWithin = require( './../lib/scopy_within.js' ); // VARIABLES // diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js index 7fbce424daa4..4d6d1fdd7d57 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/benchmark.ndarray.js @@ -26,8 +26,8 @@ var zeros = require( '@stdlib/array/zeros' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); -var scopyWithin = require( './../lib/ndarray.js' ); var pkg = require( './../package.json' ).name; +var scopyWithin = require( './../lib/ndarray.js' ); // VARIABLES // diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c index 0d25c10503dc..799b910f2bcf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/benchmark/c/benchmark.length.c @@ -40,8 +40,8 @@ static void print_version( void ) { /** * Prints the TAP summary. * -* @param total total number of tests -* @param passing total number of passing tests +* @param total total number of tests +* @param passing total number of passing tests */ static void print_summary( int total, int passing ) { printf( "#\n" ); @@ -53,16 +53,15 @@ static void print_summary( int total, int passing ) { } /** -* Prints benchmark results. +* Prints benchmarks results. * -* @param prefix comment prefix -* @param elapsed elapsed time in seconds +* @param iterations number of iterations +* @param elapsed elapsed time in seconds */ -static void print_results( const char* prefix, double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( "# %s\n", prefix ); +static void print_results( int iterations, double elapsed ) { + double rate = (double)iterations / elapsed; printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); + printf( " iterations: %d\n", iterations ); printf( " elapsed: %0.9f\n", elapsed ); printf( " rate: %0.9f\n", rate ); printf( " ...\n" ); @@ -80,21 +79,21 @@ static double tic( void ) { } /** -* Generates a random float on the interval [-100,100). +* Generates a random number on the interval [0,1). * -* @return random float +* @return random number */ static float rand_float( void ) { int r = rand(); - return -100.0f + (r/(float)RAND_MAX)*200.0f; + return (float)r / ( (float)RAND_MAX + 1.0f ); } /** -* Run a benchmark which tests `stdlib_strided_scopy_within`. +* Runs a benchmark. * * @param iterations number of iterations * @param len array length -* @return elapsed time in seconds +* @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { double elapsed; @@ -127,11 +126,11 @@ static double benchmark1( int iterations, int len ) { } /** -* Run a benchmark which tests `stdlib_strided_scopy_within_ndarray`. +* Runs a benchmark. * * @param iterations number of iterations * @param len array length -* @return elapsed time in seconds +* @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { double elapsed; @@ -179,29 +178,23 @@ int main( void ) { print_version(); count = 0; - - // Run benchmarks: for ( i = MIN; i <= MAX; i++ ) { len = pow( 10, i ); iter = ITERATIONS / pow( 10, i-1 ); - if ( iter < 1 ) { - iter = 1; - } for ( j = 0; j < REPEATS; j++ ) { count += 1; printf( "# c::%s:len=%d\n", NAME, len ); elapsed = benchmark1( iter, len ); - print_results( "scopy_within:len", elapsed ); + print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); - + } + for ( j = 0; j < REPEATS; j++ ) { count += 1; printf( "# c::%s:ndarray:len=%d\n", NAME, len ); elapsed = benchmark2( iter, len ); - print_results( "scopy_within_ndarray:len", elapsed ); + print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } } print_summary( count, count ); - - return 0; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt index 07dd89eb717c..a060ec2dd046 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( N, target, start, end, x, strideX, w, strideW ) Performs an in-place copy of elements within a single-precision floating- - point array. + point strided array. The `N` and stride parameters determine which elements in the strided array are accessed at runtime. @@ -75,7 +75,7 @@ {{alias}}.ndarray( N, target, start, end, x,strideX,offsetX, w,strideW,offsetW ) Performs an in-place copy of elements within a single-precision floating- - point array using alternative indexing semantics. + point strided array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/index.d.ts index bf589dab9f79..e736654ce79f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/docs/types/index.d.ts @@ -23,7 +23,7 @@ */ interface Routine { /** - * Performs an in-place copy of elements within a single-precision floating-point array. + * Performs an in-place copy of elements within a single-precision floating-point strided array. * * ## Notes * @@ -51,7 +51,7 @@ interface Routine { ( N: number, target: number, start: number, end: number, x: Float32Array, strideX: number, workspace: Float32Array, strideW: number ): Float32Array; /** - * Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. + * Performs an in-place copy of elements within a single-precision floating-point strided array using alternative indexing semantics. * * ## Notes * @@ -82,7 +82,7 @@ interface Routine { } /** -* Performs an in-place copy of elements within a single-precision floating-point array. +* Performs an in-place copy of elements within a single-precision floating-point strided array. * * ## Notes * diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/example.c index fba89e774e75..b7337125a18d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/examples/c/example.c @@ -26,14 +26,14 @@ int main( void ) { // Create a workspace array: float w[ 8 ]; - // Specify the number of elements to copy: + // Specify the number of indexed elements: const int N = 8; // Specify strides: const int strideX = 1; const int strideW = 1; - // Copy elements starting from index 1 to index 4: + // Copy elements: stdlib_strided_scopy_within( N, 4, 1, 4, x, strideX, w, strideW ); // Print the result: diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include/stdlib/blas/ext/base/scopy_within.h b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include/stdlib/blas/ext/base/scopy_within.h index a4273578816c..d17d60dcfe90 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include/stdlib/blas/ext/base/scopy_within.h +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/include/stdlib/blas/ext/base/scopy_within.h @@ -29,12 +29,12 @@ extern "C" { #endif /** -* Performs an in-place copy of elements within a single-precision floating-point array. +* Performs an in-place copy of elements within a single-precision floating-point strided array. */ void API_SUFFIX(stdlib_strided_scopy_within)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, float *W, const CBLAS_INT strideW ); /** -* Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. +* Performs an in-place copy of elements within a single-precision floating-point strided array using alternative indexing semantics. */ void API_SUFFIX(stdlib_strided_scopy_within_ndarray)( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *W, const CBLAS_INT strideW, const CBLAS_INT offsetW ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/index.js index a7833fbe6bea..2f5f15a1018e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Perform an in-place copy of elements within a single-precision floating-point array. +* Perform an in-place copy of elements within a single-precision floating-point strided array. * * @module @stdlib/blas/ext/base/scopy-within * diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js index dd4c6109d9f8..e6c4a058b4da 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.js @@ -27,7 +27,7 @@ var scopy = require( '@stdlib/blas/base/scopy' ).ndarray; // MAIN // /** -* Performs an in-place copy of elements within a single-precision floating-point array. +* Performs an in-place copy of elements within a single-precision floating-point strided array. * * ## Notes * diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js index eedad918b20a..1d171e1c7451 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Performs an in-place copy of elements within a single-precision floating-point array. +* Performs an in-place copy of elements within a single-precision floating-point strided array. * * @private * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js index ca7e2f7629fb..a19eb67a2700 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.js @@ -27,7 +27,7 @@ var ndarray = require( './ndarray.js' ); // MAIN // /** -* Performs an in-place copy of elements within a single-precision floating-point array. +* Performs an in-place copy of elements within a single-precision floating-point strided array. * * ## Notes * diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js index 69958e880b56..302c150d6b7b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Performs an in-place copy of elements within a single-precision floating-point array. +* Performs an in-place copy of elements within a single-precision floating-point strided array. * * @private * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/package.json b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/package.json index 7b97911b4835..a1571551ce5c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/ext/base/scopy-within", "version": "0.0.0", - "description": "Perform an in-place copy of elements within a single-precision floating-point array.", + "description": "Perform an in-place copy of elements within a single-precision floating-point strided array.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c index ff35a771cecc..73d3d37b1efb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c @@ -22,7 +22,7 @@ #include "stdlib/strided/base/stride2offset.h" /** -* Performs an in-place copy of elements within a single-precision floating-point array. +* Performs an in-place copy of elements within a single-precision floating-point strided array. * * @param N number of indexed elements * @param target target index @@ -40,7 +40,7 @@ void API_SUFFIX(stdlib_strided_scopy_within)( const CBLAS_INT N, const CBLAS_INT } /** -* Performs an in-place copy of elements within a single-precision floating-point array using alternative indexing semantics. +* Performs an in-place copy of elements within a single-precision floating-point strided array using alternative indexing semantics. * * @param N number of indexed elements * @param target target index diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.js index 833c88cb99e5..9cd01771319f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.js @@ -22,14 +22,14 @@ var tape = require( 'tape' ); var proxyquire = require( 'proxyquire' ); -var isBrowser = require( '@stdlib/assert/is-browser' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); var scopyWithin = require( './../lib' ); // VARIABLES // var opts = { - 'skip': isBrowser + 'skip': IS_BROWSER }; @@ -63,7 +63,7 @@ tape( 'if a native implementation is available, the main export is the native im } }); -tape( 'if a native implementation is not available, the main export is a JavaScript implementation', function test( t ) { +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { var scopyWithin; var main; @@ -77,6 +77,6 @@ tape( 'if a native implementation is not available, the main export is a JavaScr t.end(); function tryRequire() { - return new Error( 'Cannot resolve module' ); + return new Error( 'Cannot find module' ); } }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js index 7536f6f12b97..f5e26de51a00 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.ndarray.native.js @@ -22,17 +22,15 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var tryRequire = require( '@stdlib/utils/try-require' ); -var isBrowser = require( '@stdlib/assert/is-browser' ); -var isError = require( '@stdlib/assert/is-error' ); var Float32Array = require( '@stdlib/array/float32' ); +var tryRequire = require( '@stdlib/utils/try-require' ); // VARIABLES // var scopyWithin = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { - 'skip': ( isBrowser || isError( scopyWithin ) ) + 'skip': ( scopyWithin instanceof Error ) }; diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js index e6ee2d0e97ba..003039479e81 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/test/test.scopy_within.native.js @@ -22,17 +22,15 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var tryRequire = require( '@stdlib/utils/try-require' ); -var isBrowser = require( '@stdlib/assert/is-browser' ); -var isError = require( '@stdlib/assert/is-error' ); var Float32Array = require( '@stdlib/array/float32' ); +var tryRequire = require( '@stdlib/utils/try-require' ); // VARIABLES // var scopyWithin = tryRequire( resolve( __dirname, './../lib/scopy_within.native.js' ) ); var opts = { - 'skip': ( isBrowser || isError( scopyWithin ) ) + 'skip': ( scopyWithin instanceof Error ) }; From c26bc4690756da64745db7ccec9d55dcb03acb03 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 2 Aug 2026 23:37:20 -0700 Subject: [PATCH 7/8] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js | 1 - .../blas/ext/base/scopy-within/lib/scopy_within.native.js | 1 - lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js index 1d171e1c7451..d4bd488490f3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/ndarray.native.js @@ -28,7 +28,6 @@ var addon = require( './../src/addon.node' ); /** * Performs an in-place copy of elements within a single-precision floating-point strided array. * -* @private * @param {PositiveInteger} N - number of indexed elements * @param {NonNegativeInteger} target - target index * @param {NonNegativeInteger} start - source start index (inclusive) diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js index 302c150d6b7b..7a4e322ab619 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/lib/scopy_within.native.js @@ -28,7 +28,6 @@ var addon = require( './../src/addon.node' ); /** * Performs an in-place copy of elements within a single-precision floating-point strided array. * -* @private * @param {PositiveInteger} N - number of indexed elements * @param {NonNegativeInteger} target - target index * @param {NonNegativeInteger} start - source start index (inclusive) diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c index 73d3d37b1efb..99bea8394d2b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/src/main.c @@ -61,7 +61,7 @@ void API_SUFFIX(stdlib_strided_scopy_within_ndarray)( const CBLAS_INT N, const C if ( N <= 0 || strideX == 0 || target >= N ) { return; } - // Resolve the number of elements to copy (note: intentionally avoid `stdlib_base_min`, which operates on double-precision floating-point numbers)... + // Resolve the number of elements to copy... cl = ( ( end < N ) ? end : N ) - start; if ( cl > N - target ) { cl = N - target; From 5837b07b50e9189b114ddf7a9d8d9c3242a5011f Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 3 Aug 2026 00:00:40 -0700 Subject: [PATCH 8/8] style: enable lint rule Signed-off-by: Athan --- .../@stdlib/blas/ext/base/scopy-within/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md index 4cf9f4cc1fe7..5f9f8148d611 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/scopy-within/README.md @@ -90,6 +90,8 @@ scopyWithin( 6, 0, 3, 6, x1, 1, w, 1 ); #### scopyWithin.ndarray( N, target, start, end, x, strideX, offsetX, workspace, strideW, offsetW ) + + Performs an in-place copy of elements within a single-precision floating-point strided array using alternative indexing semantics. ```javascript @@ -190,8 +192,12 @@ console.log( x ); #include "stdlib/blas/ext/base/scopy_within.h" ``` + + #### stdlib_strided_scopy_within( N, target, start, end, \*X, strideX, \*W, strideW ) + + Performs an in-place copy of elements within a single-precision floating-point strided array. ```c @@ -216,8 +222,12 @@ The function accepts the following arguments: void stdlib_strided_scopy_within( const CBLAS_INT N, const CBLAS_INT target, const CBLAS_INT start, const CBLAS_INT end, float *X, const CBLAS_INT strideX, float *W, const CBLAS_INT strideW ); ``` + + #### stdlib_strided_scopy_within_ndarray( N, target, start, end, \*X, strideX, offsetX, \*W, strideW, offsetW ) + + Performs an in-place copy of elements within a single-precision floating-point strided array using alternative indexing semantics. ```c