diff --git a/lib/node_modules/@stdlib/blas/tools/copy-factory/README.md b/lib/node_modules/@stdlib/blas/tools/copy-factory/README.md
new file mode 100644
index 000000000000..9cfcdd7439cd
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/tools/copy-factory/README.md
@@ -0,0 +1,187 @@
+
+
+# factory
+
+> Return a function which interchanges two vectors.
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var factory = require( '@stdlib/blas/tools/swap-factory' );
+```
+
+#### factory( base, dtype )
+
+Returns a function which interchanges two vectors.
+
+```javascript
+var dswap = require( '@stdlib/blas/base/dswap' ).ndarray;
+
+var swap = factory( dswap, 'float64' );
+```
+
+The function has the following parameters:
+
+- **base**: "base" function which interchanges two vectors. Must have an `ndarray` function signature (i.e., must support index offsets).
+- **dtype**: array data type. The function assumes that the data type of all provided arrays is the same.
+
+#### swap( x, y\[, dim] )
+
+Interchanges two vectors.
+
+```javascript
+var Float64Array = require( '@stdlib/array/float64' );
+var array = require( '@stdlib/ndarray/array' );
+var dswap = require( '@stdlib/blas/base/dswap' ).ndarray;
+
+var swap = factory( dswap, 'float64' );
+
+var x = array( new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ) );
+var y = array( new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ) );
+
+swap( x, y );
+
+var xbuf = x.data;
+// returns [ 2.0, 6.0, -1.0, -4.0, 8.0 ]
+
+var ybuf = y.data;
+// returns [ 4.0, 2.0, -3.0, 5.0, -1.0 ]
+```
+
+The returned function has the following parameters:
+
+- **x**: a non-zero-dimensional [`ndarray`][@stdlib/ndarray/ctor]. Must have the same shape as `y`.
+- **y**: a non-zero-dimensional [`ndarray`][@stdlib/ndarray/ctor]. Must have the same shape as `x`.
+- **dim**: dimension along which to interchange vectors. Must be a negative integer. Negative indices are resolved relative to the last array dimension, with the last dimension corresponding to `-1`. Default: `-1`.
+
+For multi-dimensional input [`ndarrays`][@stdlib/ndarray/ctor], the function performs batched computation, such that the function interchanges each pair of vectors in `x` and `y` according to the specified dimension index.
+
+```javascript
+var Float64Array = require( '@stdlib/array/float64' );
+var array = require( '@stdlib/ndarray/array' );
+var dswap = require( '@stdlib/blas/base/dswap' ).ndarray;
+
+var swap = factory( dswap, 'float64' );
+
+var opts = {
+ 'shape': [ 2, 3 ]
+};
+var x = array( new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 3.0 ] ), opts );
+var y = array( new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 2.0 ] ), opts );
+
+var v1 = x.get( 0, 0 );
+// returns 4.0
+
+var v2 = y.get( 0, 0 );
+// returns 2.0
+
+swap( x, y );
+
+v1 = x.get( 0, 0 );
+// returns 2.0
+
+v2 = y.get( 0, 0 );
+// returns 4.0
+```
+
+
+
+
+
+
+
+## Notes
+
+For the returned function,
+
+- Both input [`ndarrays`][@stdlib/ndarray/ctor] must have the same shape.
+- Negative indices are resolved relative to the last [`ndarray`][@stdlib/ndarray/ctor] dimension, with the last dimension corresponding to `-1`.
+- For multi-dimensional [`ndarrays`][@stdlib/ndarray/ctor], batched computation effectively means swapping all of `x` with all of `y`; however, the choice of `dim` will significantly affect performance. For best performance, specify a `dim` which best aligns with the [memory layout][@stdlib/ndarray/orders] of provided [`ndarrays`][@stdlib/ndarray/ctor].
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var array = require( '@stdlib/ndarray/array' );
+var dswap = require( '@stdlib/blas/base/dswap' ).ndarray;
+var factory = require( '@stdlib/blas/tools/swap-factory' );
+
+var swap = factory( dswap, 'float64' );
+
+var opts = {
+ 'dtype': 'float64'
+};
+
+var x = array( discreteUniform( 10, 0, 100, opts ), {
+ 'shape': [ 5, 2 ]
+});
+console.log( ndarray2array( x ) );
+
+var y = array( discreteUniform( 10, 0, 10, opts ), {
+ 'shape': x.shape
+});
+console.log( ndarray2array( y ) );
+
+swap( x, y );
+console.log( ndarray2array( x ) );
+console.log( ndarray2array( y ) );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/ctor
+
+[@stdlib/ndarray/orders]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/orders
+
+
+
+
diff --git a/lib/node_modules/@stdlib/blas/tools/copy-factory/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/tools/copy-factory/benchmark/benchmark.js
new file mode 100644
index 000000000000..3adc01c0223c
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/tools/copy-factory/benchmark/benchmark.js
@@ -0,0 +1,100 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* 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 isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var uniform = require( '@stdlib/random/array/uniform' );
+var array = require( '@stdlib/ndarray/array' );
+var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray;
+var pkg = require( './../package.json' ).name;
+var factory = require( './../lib' );
+
+
+// VARIABLES //
+
+var opts = {
+ 'dtype': 'float64'
+};
+var copy = factory( dcopy, opts.dtype );
+
+
+// FUNCTIONS //
+
+/**
+* Creates a benchmark function.
+*
+* @private
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( len ) {
+ var x = array( uniform( len, -100.0, 100.0, opts ) );
+ var y = array( uniform( len, -100.0, 100.0, opts ) );
+ return benchmark;
+
+ function benchmark( b ) {
+ var d;
+ var i;
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ d = copy( x, y );
+ if ( isnan( d.data[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( d.data[ i%len ] ) ) {
+ 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( pkg+':len='+len, f );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/tools/copy-factory/benchmark/benchmark.stacks.js b/lib/node_modules/@stdlib/blas/tools/copy-factory/benchmark/benchmark.stacks.js
new file mode 100644
index 000000000000..6426d916f9a5
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/tools/copy-factory/benchmark/benchmark.stacks.js
@@ -0,0 +1,124 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* 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 isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var uniform = require( '@stdlib/random/array/uniform' );
+var numel = require( '@stdlib/ndarray/base/numel' );
+var array = require( '@stdlib/ndarray/array' );
+var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray;
+var pkg = require( './../package.json' ).name;
+var factory = require( './../lib' );
+
+
+// VARIABLES //
+
+var opts = {
+ 'dtype': 'float64'
+};
+var copy = factory( dcopy, opts.dtype );
+
+
+// FUNCTIONS //
+
+/**
+* Creates a benchmark function.
+*
+* @private
+* @param {PositiveIntegerArray} shape - array shape
+* @returns {Function} benchmark function
+*/
+function createBenchmark( shape ) {
+ var x;
+ var y;
+ var N;
+ var o;
+
+ N = numel( shape );
+ o = {
+ 'shape': shape
+ };
+ x = array( uniform( N, -100.0, 100.0, opts ), o );
+ y = array( uniform( N, -100.0, 100.0, opts ), o );
+
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var d;
+ var i;
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ d = copy( x, y );
+ if ( isnan( d.data[ i%N ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( d.data[ i%N ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var shape;
+ var min;
+ var max;
+ var N;
+ var f;
+ var i;
+
+ min = 1; // 10^min
+ max = 6; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ N = pow( 10, i );
+
+ shape = [ 2, N/2 ];
+ f = createBenchmark( shape );
+ bench( pkg+'::stacks:size='+N+',ndims='+shape.length+',shape=('+shape.join( ',' )+')', f );
+
+ shape = [ N/2, 2 ];
+ f = createBenchmark( shape );
+ bench( pkg+'::stacks:size='+N+',ndims='+shape.length+',shape=('+shape.join( ',' )+')', f );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/tools/copy-factory/docs/repl.txt b/lib/node_modules/@stdlib/blas/tools/copy-factory/docs/repl.txt
new file mode 100644
index 000000000000..af9418719bce
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/tools/copy-factory/docs/repl.txt
@@ -0,0 +1,66 @@
+
+{{alias}}( base, dtype )
+ Returns a function which copies values from one vector to another.
+
+ Parameters
+ ----------
+ base: Function
+ Base function which copies values from one vector to another. Must have
+ an ndarray signature (i.e., must support index offsets).
+
+ dtype: any
+ Array data type. The function assumes that the data type of all provided
+ arrays is the same.
+
+ Returns
+ -------
+ fcn: Function
+ Function which copies values from one vector to another.
+
+ Examples
+ --------
+ > var fcn = {{alias}}( {{alias:@stdlib/blas/base/dcopy}}, 'float64' )
+
+
+
+fcn( x, y[, dim] )
+ Copies values from `x` into `y`.
+
+ For multi-dimensional input arrays, the function performs batched
+ computation, such that the function copies each pair of vectors from `x`
+ into `y` according to the specified dimension index.
+
+ Both input and output arrays must have the same shape.
+
+ Parameters
+ ----------
+ x: ndarray
+ Input array. Must have at least one dimension and must have the
+ same shape as the output array.
+
+ y: ndarray
+ Output array. Must have at least one dimension and must have the
+ same shape as the input array.
+
+ dim: integer (optional)
+ Dimension index along which to copy vectors. Must be a negative
+ integer. Negative indices are resolved relative to the last array
+ dimension, with the last dimension corresponding to `-1`. Default: -1.
+
+ Returns
+ -------
+ y: ndarray
+ Output array `y`.
+
+ Examples
+ --------
+ > var fcn = {{alias}}( {{alias:@stdlib/blas/base/dcopy}}.ndarray, 'float64' );
+ > var x = {{alias:@stdlib/ndarray/array}}( new {{alias:@stdlib/array/float64}}( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ) );
+ > var y = {{alias:@stdlib/ndarray/array}}( new {{alias:@stdlib/array/float64}}( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ) );
+ > fcn( x, y );
+ > y.data
+ [ 4.0, 2.0, -3.0, 5.0, -1.0 ]
+
+ See Also
+ --------
+
diff --git a/lib/node_modules/@stdlib/blas/tools/copy-factory/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/tools/copy-factory/docs/types/index.d.ts
new file mode 100644
index 000000000000..ae02001c4abe
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/tools/copy-factory/docs/types/index.d.ts
@@ -0,0 +1,86 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* 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
+
+///
+
+import { ndarray } from '@stdlib/types/ndarray';
+import { Collection, AccessorArrayLike } from '@stdlib/types/array';
+
+/**
+* "Base" function which copies values from one vector into other.
+*
+* @param N - number of indexed elements
+* @param x - input array
+* @param strideX - `x` stride length
+* @param offsetX - starting index for `x`
+* @param y - output array
+* @param strideY - `y` stride length
+* @param offsetY - starting index for `y`
+* @returns `y`
+*/
+type BaseFunction = ( N: number, x: T, strideX: number, offsetX: number, y: T, strideY: number, offsetY: number ) => T;
+
+/**
+* Copies values from `x` into `y`.
+*
+* ## Notes
+*
+* - For multi-dimensional input arrays, the function performs batched computation, such that the function copies each pair of vectors from `x` into `y` according to the specified dimension index.
+* - Both input and output arrays must have the same shape.
+* - Negative indices are resolved relative to the last array dimension, with the last dimension corresponding to `-1`.
+*
+* @param x - input array
+* @param y - output array
+* @param dim - dimension along which to interchange vectors (default: -1)
+* @throws first argument must be a non-zero-dimensional ndarray
+* @throws second argument must be a non-zero-dimensional ndarray
+* @throws input and output arrays must have the same shape
+* @returns `y`
+*/
+type CopyFunction = ( x: ndarray, y: ndarray, dim?: number ) => ndarray;
+
+/**
+* Returns a function which copies values from one vector into another.
+*
+* @param base - "base" function which copies values from one vector into another
+* @param dtype - array data type
+* @returns function wrapper
+*
+* @example
+* var Float64Array = require( '@stdlib/array/float64' );
+* var array = require( '@stdlib/ndarray/array' );
+* var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray;
+*
+* var copy = factory( dcopy, 'float64' );
+*
+* var x = array( new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ) );
+* var y = array( new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ) );
+*
+* copy( x, y );
+*
+* var ybuf = y.data;
+* // returns [ 4.0, 2.0, -3.0, 5.0, -1.0 ]
+*/
+declare function factory>( base: BaseFunction, dtype: any ): CopyFunction;
+
+
+// EXPORTS //
+
+export = factory;
diff --git a/lib/node_modules/@stdlib/blas/tools/copy-factory/docs/types/test.ts b/lib/node_modules/@stdlib/blas/tools/copy-factory/docs/types/test.ts
new file mode 100644
index 000000000000..fd2bc215921c
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/tools/copy-factory/docs/types/test.ts
@@ -0,0 +1,133 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* 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.
+*/
+
+/* eslint-disable @typescript-eslint/unbound-method */
+
+import dcopy = require( '@stdlib/blas/base/dcopy' );
+import zeros = require( '@stdlib/ndarray/zeros' );
+import factory = require( './index' );
+
+
+// TESTS //
+
+// The function returns a function...
+{
+ factory( dcopy.ndarray, 'float64' ); // $ExpectType CopyFunction
+}
+
+// The compiler throws an error if the function is provided a first argument which is not a valid function...
+{
+ factory( 10, 'float64' ); // $ExpectError
+ factory( '10', 'float64' ); // $ExpectError
+ factory( true, 'float64' ); // $ExpectError
+ factory( false, 'float64' ); // $ExpectError
+ factory( null, 'float64' ); // $ExpectError
+ factory( undefined, 'float64' ); // $ExpectError
+ factory( {}, 'float64' ); // $ExpectError
+ factory( [], 'float64' ); // $ExpectError
+ factory( ( x: number ): number => x, 'float64' ); // $ExpectError
+}
+
+// The function returns a function which returns an ndarray...
+{
+ const copy = factory( dcopy.ndarray, 'float64' );
+
+ copy( zeros( [ 10 ], { 'dtype': 'float64' } ), zeros( [ 10 ], { 'dtype': 'float64' } ) ); // $ExpectType ndarray
+}
+
+// The compiler throws an error if the returned function is provided a first argument which is not an ndarray...
+{
+ const copy = factory( dcopy.ndarray, 'float64' );
+
+ const y = zeros( [ 10 ], { 'dtype': 'float64' } );
+
+ copy( 10, y ); // $ExpectError
+ copy( '10', y ); // $ExpectError
+ copy( true, y ); // $ExpectError
+ copy( false, y ); // $ExpectError
+ copy( null, y ); // $ExpectError
+ copy( undefined, y ); // $ExpectError
+ copy( {}, y ); // $ExpectError
+ copy( [], y ); // $ExpectError
+ copy( ( x: number ): number => x, y ); // $ExpectError
+
+ copy( 10, y, -1 ); // $ExpectError
+ copy( '10', y, -1 ); // $ExpectError
+ copy( true, y, -1 ); // $ExpectError
+ copy( false, y, -1 ); // $ExpectError
+ copy( null, y, -1 ); // $ExpectError
+ copy( undefined, y, -1 ); // $ExpectError
+ copy( {}, y, -1 ); // $ExpectError
+ copy( [], y, -1 ); // $ExpectError
+ copy( ( x: number ): number => x, y, -1 ); // $ExpectError
+}
+
+// The compiler throws an error if the returned function is provided a second argument which is not an ndarray...
+{
+ const copy = factory( dcopy.ndarray, 'float64' );
+
+ const x = zeros( [ 10 ], { 'dtype': 'float64' } );
+
+ copy( x, 10 ); // $ExpectError
+ copy( x, '10' ); // $ExpectError
+ copy( x, true ); // $ExpectError
+ copy( x, false ); // $ExpectError
+ copy( x, null ); // $ExpectError
+ copy( x, undefined ); // $ExpectError
+ copy( x, {} ); // $ExpectError
+ copy( x, [] ); // $ExpectError
+ copy( x, ( x: number ): number => x ); // $ExpectError
+
+ copy( x, 10, -1 ); // $ExpectError
+ copy( x, '10', -1 ); // $ExpectError
+ copy( x, true, -1 ); // $ExpectError
+ copy( x, false, -1 ); // $ExpectError
+ copy( x, null, -1 ); // $ExpectError
+ copy( x, undefined, -1 ); // $ExpectError
+ copy( x, {}, -1 ); // $ExpectError
+ copy( x, [], -1 ); // $ExpectError
+ copy( x, ( x: number ): number => x, -1 ); // $ExpectError
+}
+
+// The compiler throws an error if the returned function is provided a third argument which is not a number...
+{
+ const copy = factory( dcopy.ndarray, 'float64' );
+
+ const x = zeros( [ 10 ], { 'dtype': 'float64' } );
+ const y = zeros( [ 10 ], { 'dtype': 'float64' } );
+
+ copy( x, y, '10' ); // $ExpectError
+ copy( x, y, true ); // $ExpectError
+ copy( x, y, false ); // $ExpectError
+ copy( x, y, null ); // $ExpectError
+ copy( x, y, {} ); // $ExpectError
+ copy( x, y, [] ); // $ExpectError
+ copy( x, y, ( x: number ): number => x ); // $ExpectError
+}
+
+// The compiler throws an error if the returned function is provided an unsupported number of arguments...
+{
+ const copy = factory( dcopy.ndarray, 'float64' );
+
+ const x = zeros( [ 10 ], { 'dtype': 'float64' } );
+ const y = zeros( [ 10 ], { 'dtype': 'float64' } );
+
+ copy(); // $ExpectError
+ copy( x ); // $ExpectError
+ copy( x, y, -1, {} ); // $ExpectError
+}
diff --git a/lib/node_modules/@stdlib/blas/tools/copy-factory/examples/index.js b/lib/node_modules/@stdlib/blas/tools/copy-factory/examples/index.js
new file mode 100644
index 000000000000..ae0b89f588bf
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/tools/copy-factory/examples/index.js
@@ -0,0 +1,44 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* 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 ndarray2array = require( '@stdlib/ndarray/to-array' );
+var array = require( '@stdlib/ndarray/array' );
+var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray;
+var factory = require( './../lib' );
+
+var copy = factory( dcopy, 'float64' );
+
+var opts = {
+ 'dtype': 'float64'
+};
+
+var x = array( discreteUniform( 10, 0, 100, opts ), {
+ 'shape': [ 5, 2 ]
+});
+console.log( ndarray2array( x ) );
+
+var y = array( discreteUniform( 10, 0, 10, opts ), {
+ 'shape': x.shape
+});
+console.log( ndarray2array( y ) );
+
+copy( x, y );
+console.log( ndarray2array( y ) );
diff --git a/lib/node_modules/@stdlib/blas/tools/copy-factory/lib/index.js b/lib/node_modules/@stdlib/blas/tools/copy-factory/lib/index.js
new file mode 100644
index 000000000000..ad2bad64cf78
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/tools/copy-factory/lib/index.js
@@ -0,0 +1,50 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* 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';
+
+/**
+* Return a function which copies values from one vector into another.
+*
+* @module @stdlib/blas/tools/copy-factory
+*
+* @example
+* var Float64Array = require( '@stdlib/array/float64' );
+* var array = require( '@stdlib/ndarray/array' );
+* var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray;
+* var factory = require( '@stdlib/blas/tools/copy-factory' );
+*
+* var copy = factory( dcopy, 'float64' );
+*
+* var x = array( new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ) );
+* var y = array( new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ) );
+*
+* copy( x, y );
+*
+* var ybuf = y.data;
+* // returns [ 4.0, 2.0, -3.0, 5.0, -1.0 ]
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/lib/node_modules/@stdlib/blas/tools/copy-factory/lib/main.js b/lib/node_modules/@stdlib/blas/tools/copy-factory/lib/main.js
new file mode 100644
index 000000000000..6eb2be3883d4
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/tools/copy-factory/lib/main.js
@@ -0,0 +1,192 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* 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 isFunction = require( '@stdlib/assert/is-function' );
+var isndarrayLikeWithDataType = require( '@stdlib/assert/is-ndarray-like-with-data-type' );
+var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
+var isNegativeInteger = require( '@stdlib/assert/is-negative-integer' ).isPrimitive;
+var isDataType = require( '@stdlib/ndarray/base/assert/is-data-type' );
+var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' );
+var min = require( '@stdlib/math/base/special/fast/min' );
+var maybeBroadcastArray = require( '@stdlib/ndarray/base/maybe-broadcast-array' );
+var without = require( '@stdlib/array/base/without' );
+var ndarraylike2ndarray = require( '@stdlib/ndarray/base/ndarraylike2ndarray' );
+var normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' );
+var nditerStacks = require( '@stdlib/ndarray/iter/stacks' );
+var numel = require( '@stdlib/ndarray/base/numel' );
+var format = require( '@stdlib/string/format' );
+
+
+// MAIN //
+
+/**
+* Returns a function which interchanges two vectors.
+*
+* @param {Function} base - "base" function which interchanges two vectors
+* @param {(String|null)} dtype - array data type
+* @throws {TypeError} first argument must be a function
+* @throws {TypeError} second argument must be a data type
+* @returns {Function} function wrapper
+*
+* @example
+* var Float64Array = require( '@stdlib/array/float64' );
+* var array = require( '@stdlib/ndarray/array' );
+* var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray;
+*
+* var copy = factory( dcopy, 'float64' );
+*
+* var x = array( new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ) );
+* var y = array( new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ) );
+*
+* copy( x, y );
+*
+* var ybuf = y.data;
+* // returns [ 4.0, 2.0, -3.0, 5.0, -1.0 ]
+*/
+function factory( base, dtype ) {
+ var isValid;
+ if ( !isFunction( base ) ) {
+ throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', base ) );
+ }
+ if ( !isDataType( dtype ) && dtype !== null ) {
+ throw new TypeError( format( 'invalid argument. Second argument must be a data type. Value: `%s`.', dtype ) );
+ }
+ isValid = ( dtype ) ? isValidWrapper : isndarrayLike;
+ return copy;
+
+ /**
+ * Tests if an input value is an ndarray-like object having a specified data type.
+ *
+ * @private
+ * @param {*} value - value to test
+ * @returns {boolean} boolean indicating if an input value is an ndarray-like object having a specified data type
+ */
+ function isValidWrapper( value ) {
+ return isndarrayLikeWithDataType( value, dtype );
+ }
+
+ /**
+ * Copies values from one vector into another.
+ *
+ * @private
+ * @param {ndarrayLike} x - input array
+ * @param {ndarrayLike} y - output array
+ * @param {NegativeInteger} [dim] - dimension along which to copy elements
+ * @throws {TypeError} first argument must be an ndarray
+ * @throws {TypeError} first argument must have at least one dimension
+ * @throws {TypeError} second argument must be an ndarray
+ * @throws {TypeError} second argument must have at least one dimension
+ * @throws {RangeError} third argument is out-of-bounds
+ * @throws {Error} cannot write to read-only array
+ * @returns {ndarrayLike} `y`
+ */
+ function copy( x, y ) {
+ var dim;
+ var xsh;
+ var ysh;
+ var xit;
+ var yit;
+ var xc;
+ var yc;
+ var vx;
+ var vy;
+ var dm;
+ var S;
+ var N;
+ var i;
+ if ( !isValid( x ) ) {
+ throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object having a supported data type. Value: `%s`.', x ) );
+ }
+ if ( !isValid( y ) ) {
+ throw new TypeError( format( 'invalid argument. Second argument must be an ndarray-like object having a supported data type. Value: `%s`.', y ) );
+ }
+ if ( isReadOnly( y ) ) {
+ throw new Error( 'invalid argument. Cannot write to read-only array.' );
+ }
+ // Convert the input arrays to "base" ndarrays:
+ xc = ndarraylike2ndarray( x );
+ yc = ndarraylike2ndarray( y );
+
+ // Resolve the input array shapes:
+ xsh = xc.shape;
+ ysh = yc.shape;
+
+ // Validate that we've been provided non-zero-dimensional arrays...
+ if ( xsh.length < 1 ) {
+ throw new TypeError( format( 'invalid argument. First argument must have at least one dimension.' ) );
+ }
+ if ( ysh.length < 1 ) {
+ throw new TypeError( format( 'invalid argument. Second argument must have at least one dimension.' ) );
+ }
+ // Validate that the dimension argument is a negative integer...
+ if ( arguments.length > 2 ) {
+ dim = arguments[ 2 ];
+ if ( !isNegativeInteger( dim ) ) {
+ throw new TypeError( format( 'invalid argument. Third argument must be a negative integer. Value: `%s`.', dim ) );
+ }
+ } else {
+ dim = -1;
+ }
+ // Validate that a provided dimension index is within bounds...
+ dm = min( xsh.length, ysh.length ) - 1;
+ dim = normalizeIndex( dim, dm );
+ if ( dim === -1 ) {
+ throw new RangeError( format( 'invalid argument. Third argument must be a value on the interval: [%d,%d]. Value: `%d`.', -dm, -1, arguments[ 2 ] ) );
+ }
+ // Validate that the contracted dimension size is the same for both input arrays...
+ S = xsh[ dim ];
+ if ( ysh[ dim ] !== S ) {
+ throw new RangeError( format( 'invalid argument. The size of the contracted dimension must be the same for both input ndarrays. Dim(%s,%d) = %d. Dim(%s,%d) = %d.', 'x', dim, S, 'y', dim, ysh[ dim ] ) );
+ }
+ // Broadcast `x` to the shape of `y` if necessary
+ try {
+ xc = maybeBroadcastArray( xc, ysh );
+ } catch ( err ) { // eslint-disable-line no-unused-vars
+ throw new Error( format( 'invalid arguments. Input ndarrays must be broadcast compatible. Shape(%s) = (%s). Shape(%s) = (%s).', 'x', xsh.join( ',' ), 'y', ysh.join( ',' ) ) );
+ }
+ // Resolve the number of stacks:
+ N = numel( without( xc.shape, dim ) );
+
+ // If we are only provided one-dimensional input arrays, we can skip iterating over stacks...
+ if ( xsh.length === 1 ) {
+ base( S, xc.data, xc.strides[0], xc.offset, yc.data, yc.strides[0], yc.offset ); // eslint-disable-line max-len
+ return y;
+ }
+
+ // Create iterators for iterating over stacks of vectors:
+ xit = nditerStacks( xc, [ dim ] );
+ yit = nditerStacks( yc, [ dim ] );
+
+ // Copy values from one vector into another...
+ for ( i = 0; i < N; i++ ) {
+ vx = xit.next().value;
+ vy = yit.next().value;
+ base( S, vx.data, vx.strides[0], vx.offset, vy.data, vy.strides[0], vy.offset ); // eslint-disable-line max-len
+ }
+ return y;
+ }
+}
+
+
+// EXPORTS //
+
+module.exports = factory;
diff --git a/lib/node_modules/@stdlib/blas/tools/copy-factory/package.json b/lib/node_modules/@stdlib/blas/tools/copy-factory/package.json
new file mode 100644
index 000000000000..3107508e7bfa
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/tools/copy-factory/package.json
@@ -0,0 +1,72 @@
+{
+ "name": "@stdlib/blas/tools/copy-factory",
+ "version": "0.0.0",
+ "description": "Return a function which copies values from one vector into another.",
+ "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",
+ "directories": {
+ "benchmark": "./benchmark",
+ "doc": "./docs",
+ "example": "./examples",
+ "lib": "./lib",
+ "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",
+ "level 1",
+ "linear",
+ "algebra",
+ "subroutines",
+ "copy",
+ "vector",
+ "array",
+ "ndarray",
+ "factory",
+ "tool",
+ "tools",
+ "utilities",
+ "utils"
+ ]
+}
diff --git a/lib/node_modules/@stdlib/blas/tools/copy-factory/test/test.js b/lib/node_modules/@stdlib/blas/tools/copy-factory/test/test.js
new file mode 100644
index 000000000000..6698482977a7
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/tools/copy-factory/test/test.js
@@ -0,0 +1,790 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2024 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* 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 Float64Array = require( '@stdlib/array/float64' );
+var Int16Array = require( '@stdlib/array/int16' );
+var array = require( '@stdlib/ndarray/array' );
+var zeros = require( '@stdlib/ndarray/zeros' );
+var ndarray = require( '@stdlib/ndarray/ctor' );
+var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray;
+var factory = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof factory, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function throws an error if provided a first argument which is not a function', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ factory( value, 'float64' );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an invalid second argument', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ factory( dcopy, value );
+ };
+ }
+});
+
+tape( 'the function returns a function', function test( t ) {
+ t.strictEqual( typeof factory( dcopy, 'float64' ), 'function', 'returns expected value' );
+ t.end();
+});
+
+tape( 'the returned function has an arity of 2', function test( t ) {
+ var copy = factory( dcopy, 'float64' );
+ t.strictEqual( copy.length, 2, 'has expected arity' );
+ t.end();
+});
+
+tape( 'the returned function throws an error if provided a first argument which is not a non-zero-dimensional ndarray having a supported data type', function test( t ) {
+ var values;
+ var copy;
+ var i;
+
+ copy = factory( dcopy, 'float64' );
+
+ values = [
+ 5,
+ '5',
+ true,
+ false,
+ null,
+ void 0,
+ {},
+ function noop() {},
+ zeros( [], {
+ 'dtype': 'float64'
+ }),
+ array( new Int16Array( 10 ) )
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ var y = array( new Float64Array( 10 ) );
+
+ return function badValue() {
+ copy( value, y );
+ };
+ }
+});
+
+tape( 'the returned function throws an error if provided a first argument which is not a non-zero-dimensional ndarray having a supported data type (dimension)', function test( t ) {
+ var values;
+ var copy;
+ var i;
+
+ copy = factory( dcopy, 'float64' );
+
+ values = [
+ 5,
+ '5',
+ true,
+ false,
+ null,
+ void 0,
+ {},
+ function noop() {},
+ zeros( [], {
+ 'dtype': 'float64'
+ }),
+ array( new Int16Array( 10 ) )
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ var y = array( new Float64Array( 10 ) );
+
+ return function badValue() {
+ copy( value, y, -1 );
+ };
+ }
+});
+
+tape( 'the returned function throws an error if provided a second argument which is not a non-zero-dimensional ndarray having a supported data type', function test( t ) {
+ var values;
+ var copy;
+ var i;
+
+ copy = factory( dcopy, 'float64' );
+
+ values = [
+ 5,
+ '5',
+ true,
+ false,
+ null,
+ void 0,
+ {},
+ function noop() {},
+ zeros( [], {
+ 'dtype': 'float64'
+ }),
+ array( new Int16Array( 10 ) )
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ var x = array( new Float64Array( 10 ) );
+
+ return function badValue() {
+ copy( x, value );
+ };
+ }
+});
+
+tape( 'the returned function throws an error if provided a second argument which is not a non-zero-dimensional ndarray having a supported data type (dimension)', function test( t ) {
+ var values;
+ var copy;
+ var i;
+
+ copy = factory( dcopy, 'float64' );
+
+ values = [
+ 5,
+ '5',
+ true,
+ false,
+ null,
+ void 0,
+ {},
+ function noop() {},
+ zeros( [], {
+ 'dtype': 'float64'
+ }),
+ array( new Int16Array( 10 ) )
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ var x = array( new Float64Array( 10 ) );
+
+ return function badValue() {
+ copy( x, value, -1 );
+ };
+ }
+});
+
+tape( 'the returned function throws an error if provided a second argument which is a read-only ndarray', function test( t ) {
+ var values;
+ var opts;
+ var copy;
+ var i;
+
+ copy = factory( dcopy, 'float64' );
+
+ opts = {
+ 'readonly': true
+ };
+
+ values = [
+ array( new Float64Array( 10 ), opts ),
+ array( new Float64Array( 5 ), opts )
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ var x = array( new Float64Array( value.length ) );
+
+ return function badValue() {
+ copy( x, value );
+ };
+ }
+});
+
+tape( 'the returned function throws an error if provided a third argument which is not a negative integer (vectors)', function test( t ) {
+ var values;
+ var copy;
+ var i;
+
+ copy = factory( dcopy, 'float64' );
+
+ values = [
+ '5',
+ 0,
+ 5,
+ NaN,
+ -3.14,
+ true,
+ false,
+ null,
+ void 0,
+ {},
+ [],
+ function noop() {}
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ var x = array( new Float64Array( 10 ) );
+ var y = array( new Float64Array( 10 ) );
+
+ return function badValue() {
+ copy( x, y, value );
+ };
+ }
+});
+
+tape( 'the returned function throws an error if provided a third argument which is not a negative integer (multi-dimensional arrays)', function test( t ) {
+ var values;
+ var copy;
+ var i;
+
+ copy = factory( dcopy, 'float64' );
+
+ values = [
+ '5',
+ 0,
+ 5,
+ NaN,
+ -3.14,
+ true,
+ false,
+ null,
+ void 0,
+ {},
+ [],
+ function noop() {}
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ var opts = {
+ 'shape': [ 2, 5 ]
+ };
+ var x = array( new Float64Array( 10 ), opts );
+ var y = array( new Float64Array( 10 ), opts );
+
+ return function badValue() {
+ copy( x, y, value );
+ };
+ }
+});
+
+tape( 'the returned function throws an error if provided a third argument which is out-of-bounds (vectors)', function test( t ) {
+ var values;
+ var copy;
+ var i;
+
+ copy = factory( dcopy, 'float64' );
+
+ values = [
+ -2,
+ -3,
+ -4,
+ -5
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ var x = array( new Float64Array( 10 ) );
+ var y = array( new Float64Array( 10 ) );
+
+ return function badValue() {
+ copy( x, y, value );
+ };
+ }
+});
+
+tape( 'the returned function throws an error if provided a third argument which is out-of-bounds (multi-dimensional arrays)', function test( t ) {
+ var values;
+ var copy;
+ var i;
+
+ copy = factory( dcopy, 'float64' );
+
+ values = [
+ -3,
+ -4,
+ -5,
+ -10
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ var opts = {
+ 'shape': [ 2, 5 ]
+ };
+ var x = array( new Float64Array( 10 ), opts );
+ var y = array( new Float64Array( 10 ), opts );
+
+ return function badValue() {
+ copy( x, y, value );
+ };
+ }
+});
+
+tape( 'the returned function throws an error if provided arrays having different shapes (vectors)', function test( t ) {
+ var copy = factory( dcopy, 'float64' );
+
+ t.throws( badValue, Error, 'throws an error' );
+ t.end();
+
+ function badValue() {
+ var x = array( new Float64Array( 10 ) );
+ var y = array( new Float64Array( 100 ) );
+ copy( x, y );
+ }
+});
+
+tape( 'the returned function throws an error if provided arrays having different shapes (multi-dimensional)', function test( t ) {
+ var copy = factory( dcopy, 'float64' );
+
+ t.throws( badValue, Error, 'throws an error' );
+ t.end();
+
+ function badValue() {
+ var x = array( new Float64Array( 100 ), {
+ 'shape': [ 25, 4 ]
+ });
+ var y = array( new Float64Array( 100 ), {
+ 'shape': [ 50, 2 ]
+ });
+ copy( x, y, -1 );
+ }
+});
+
+tape( 'the returned function copies values from `x` into `y`', function test( t ) {
+ var copy;
+ var ye;
+ var x;
+ var y;
+
+ copy = factory( dcopy, 'float64' );
+
+ x = new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] );
+ y = new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 8.0, 2.0, -3.0 ] );
+
+ ye = new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] );
+
+ x = array( x );
+ y = array( y );
+
+ copy( x, y );
+
+ t.deepEqual( y.data, ye, 'returns expected value' );
+ t.notEqual( y.data, ye, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the returned function supports operating on stacks of vectors (default)', function test( t ) {
+ var copy;
+ var opts;
+ var ye;
+ var x;
+ var y;
+
+ copy = factory( dcopy, 'float64' );
+
+ x = new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] );
+ y = new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 8.0, 2.0, -3.0 ] );
+
+ ye = new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] );
+
+ opts = {
+ 'shape': [ 4, 2 ]
+ };
+ x = array( x, opts );
+ y = array( y, opts );
+
+ copy( x, y );
+
+ t.deepEqual( y.data, ye, 'returns expected value' );
+ t.notEqual( y.data, ye, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the returned function supports operating on stacks of vectors (dim=-1)', function test( t ) {
+ var copy;
+ var opts;
+ var ye;
+ var x;
+ var y;
+
+ copy = factory( dcopy, 'float64' );
+
+ x = new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] );
+ y = new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 8.0, 2.0, -3.0 ] );
+
+ ye = new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] );
+
+ opts = {
+ 'shape': [ 4, 2 ]
+ };
+ x = array( x, opts );
+ y = array( y, opts );
+
+ copy( x, y, -1 );
+
+ t.deepEqual( y.data, ye, 'returns expected value' );
+ t.notEqual( y.data, ye, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the returned function supports operating on stacks of vectors (dim=-2)', function test( t ) {
+ var copy;
+ var opts;
+ var ye;
+ var x;
+ var y;
+
+ copy = factory( dcopy, 'float64' );
+
+ x = new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] );
+ y = new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 8.0, 2.0, -3.0 ] );
+
+ ye = new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] );
+
+ opts = {
+ 'shape': [ 4, 2 ]
+ };
+ x = array( x, opts );
+ y = array( y, opts );
+
+ copy( x, y, -2 );
+
+ t.deepEqual( y.data, ye, 'returns expected value' );
+ t.notEqual( y.data, ye, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the returned function supports a strided vector for the first argument', function test( t ) {
+ var copy;
+ var ye;
+ var x;
+ var y;
+
+ copy = factory( dcopy, 'float64' );
+
+ x = new Float64Array([
+ 1.0, // 0
+ 2.0,
+ 3.0, // 1
+ 4.0,
+ 5.0 // 2
+ ]);
+ y = new Float64Array([
+ 6.0, // 0
+ 7.0, // 1
+ 8.0 // 2
+ ]);
+
+ ye = new Float64Array( [ 1.0, 3.0, 5.0 ] );
+
+ x = ndarray( 'float64', x, [ 3 ], [ 2 ], 0, 'row-major' );
+ y = ndarray( 'float64', y, [ 3 ], [ 1 ], 0, 'row-major' );
+
+ copy( x, y );
+
+ t.deepEqual( y.data, ye, 'returns expected value' );
+ t.notEqual( y.data, ye, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the returned function supports a strided vector for the second argument', function test( t ) {
+ var copy;
+ var ye;
+ var x;
+ var y;
+
+ copy = factory( dcopy, 'float64' );
+
+ x = new Float64Array([
+ 1.0, // 0
+ 2.0, // 1
+ 3.0 // 2
+ ]);
+ y = new Float64Array([
+ 6.0, // 0
+ 7.0,
+ 8.0, // 1
+ 9.0,
+ 10.0 // 2
+ ]);
+
+ ye = new Float64Array( [ 1.0, 7.0, 2.0, 9.0, 3.0 ] );
+
+ x = ndarray( 'float64', x, [ 3 ], [ 1 ], 0, 'row-major' );
+ y = ndarray( 'float64', y, [ 3 ], [ 2 ], 0, 'row-major' );
+
+ copy( x, y );
+
+ t.deepEqual( y.data, ye, 'returns expected value' );
+ t.notEqual( y.data, ye, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the returned function supports negative strides', function test( t ) {
+ var copy;
+ var ye;
+ var x;
+ var y;
+
+ copy = factory( dcopy, 'float64' );
+
+ x = new Float64Array([
+ 1.0, // 2
+ 2.0,
+ 3.0, // 1
+ 4.0,
+ 5.0 // 0
+ ]);
+ y = new Float64Array([
+ 6.0, // 2
+ 7.0, // 1
+ 8.0 // 0
+ ]);
+
+ ye = new Float64Array( [ 1.0, 3.0, 5.0 ] );
+
+ x = ndarray( 'float64', x, [ 3 ], [ -2 ], x.length-1, 'row-major' );
+ y = ndarray( 'float64', y, [ 3 ], [ -1 ], y.length-1, 'row-major' );
+
+ copy( x, y );
+
+ t.deepEqual( y.data, ye, 'returns expected value' );
+ t.notEqual( y.data, ye, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the returned function supports complex access patterns', function test( t ) {
+ var copy;
+ var ye;
+ var x;
+ var y;
+
+ copy = factory( dcopy, 'float64' );
+
+ x = new Float64Array([
+ 1.0, // 0
+ 2.0,
+ 3.0, // 1
+ 4.0,
+ 5.0, // 2
+ 6.0
+ ]);
+ y = new Float64Array([
+ 7.0, // 2
+ 8.0, // 1
+ 9.0 // 0
+ ]);
+
+ ye = new Float64Array( [ 5.0, 3.0, 1.0 ] );
+
+ x = ndarray( 'float64', x, [ 3 ], [ 2 ], 0, 'row-major' );
+ y = ndarray( 'float64', y, [ 3 ], [ -1 ], y.length-1, 'row-major' );
+
+ copy( x, y );
+
+ t.deepEqual( y.data, ye, 'returns expected value' );
+ t.notEqual( y.data, ye, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the returned function supports strided vectors having offsets', function test( t ) {
+ var copy;
+ var ye;
+ var x;
+ var y;
+
+ copy = factory( dcopy, 'float64' );
+
+ x = new Float64Array([
+ 1.0,
+ 2.0, // 2
+ 3.0,
+ 4.0, // 1
+ 5.0,
+ 6.0 // 0
+ ]);
+ y = new Float64Array([
+ 7.0,
+ 8.0,
+ 9.0,
+ 10.0, // 0
+ 11.0, // 1
+ 12.0 // 2
+ ]);
+
+ ye = new Float64Array( [ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ] );
+
+ x = ndarray( 'float64', x, [ 3 ], [ -2 ], x.length-1, 'row-major' );
+ y = ndarray( 'float64', y, [ 3 ], [ 1 ], 3, 'row-major' );
+
+ copy( x, y );
+
+ t.deepEqual( y.data, ye, 'returns expected value' );
+ t.notEqual( y.data, ye, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the returned function supports underlying data buffers with view offsets', function test( t ) {
+ var copy;
+ var x0;
+ var y0;
+ var x1;
+ var y1;
+ var ye;
+
+ copy = factory( dcopy, 'float64' );
+
+ x0 = new Float64Array([
+ 1.0,
+ 2.0, // 0
+ 3.0,
+ 4.0, // 1
+ 5.0,
+ 6.0 // 2
+ ]);
+ y0 = new Float64Array([
+ 7.0,
+ 8.0,
+ 9.0,
+ 10.0, // 0
+ 11.0, // 1
+ 12.0 // 2
+ ]);
+
+ x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
+ y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 );
+
+ ye = new Float64Array( [ 7.0, 8.0, 9.0, 2.0, 4.0, 6.0 ] );
+
+ x1 = ndarray( 'float64', x1, [ 3 ], [ 2 ], 0, 'row-major' );
+ y1 = ndarray( 'float64', y1, [ 3 ], [ 1 ], 0, 'row-major' );
+
+ copy( x1, y1 );
+
+ t.deepEqual( y0, ye, 'returns expected value' );
+ t.notEqual( y0, ye, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the returned function returns a reference to the second input array', function test( t ) {
+ var copy;
+ var out;
+ var x;
+ var y;
+
+ copy = factory( dcopy, 'float64' );
+
+ x = array( new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) );
+ y = array( new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ) );
+
+ out = copy( x, y );
+
+ t.strictEqual( out, y, 'returns expected value' );
+ t.end();
+});