diff --git a/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/README.md b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/README.md
new file mode 100644
index 000000000000..cf1b8824cba0
--- /dev/null
+++ b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/README.md
@@ -0,0 +1,177 @@
+
+
+# broadcastArrayExceptDimensions
+
+> Broadcast an input [ndarray][@stdlib/ndarray/base/ctor] to a target shape keeping the specified dimensions unchanged.
+
+
+
+
+
+
+
+
+
+
+
+## Usage
+
+
+
+```javascript
+var broadcastArrayExceptDimensions = require( '@stdlib/ndarray/base/broadcast-array-except-dimensions' );
+```
+
+#### broadcastArrayExceptDimensions( arr, shape\[, dims] )
+
+Broadcast an input [ndarray][@stdlib/ndarray/base/ctor] to a target shape keeping the specified dimensions unchanged.
+
+```javascript
+var array = require( '@stdlib/ndarray/array' );
+
+// Create a 2x2 ndarray:
+var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
+// returns
+
+// Perform broadcasting:
+var y = broadcastArrayExceptDimensions( x, [ 3, 2, 2 ] );
+// returns
+
+var ysh = y.shape;
+// returns [ 3, 2, 2 ]
+```
+
+The function accepts the following arguments:
+
+- **arr**: input ndarray.
+- **shape**: target shape.
+- **dims**: list of dimensions which are exculded from broadcasting. Default: `[ -1 ]` (_optional_).
+
+To exclude specific dimensions from broadcasting, provide a `dims` parameter.
+
+```javascript
+var array = require( '@stdlib/ndarray/array' );
+
+// Create a 2x2 ndarray:
+var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
+// returns
+
+// Perform broadcasting:
+var y = broadcastArrayExceptDimensions( x, [ 3, 2, 2 ], [ -2 ] );
+// returns
+
+var ysh = y.shape;
+// returns [ 3, 2, 2 ]
+```
+
+
+
+
+
+
+
+
+
+## Notes
+
+- The function throws an error if a provided [ndarray][@stdlib/ndarray/base/ctor] is [incompatible][@stdlib/ndarray/base/broadcast-shapes] with a provided shape.
+- The returned [ndarray][@stdlib/ndarray/base/ctor] is a "base" [ndarray][@stdlib/ndarray/base/ctor], and, thus, the returned [ndarray][@stdlib/ndarray/base/ctor] does not perform bounds checking or afford any of the guarantees of the non-base [ndarray][@stdlib/ndarray/ctor] constructor. The primary intent of this function is to broadcast an ndarray-like object within internal implementations and to do so with minimal overhead.
+- The function always returns a new [ndarray][@stdlib/ndarray/base/ctor] instance even if the input [ndarray][@stdlib/ndarray/base/ctor] shape and the desired shape are the same.
+
+
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var array = require( '@stdlib/ndarray/array' );
+var numel = require( '@stdlib/ndarray/base/numel' );
+var ind2sub = require( '@stdlib/ndarray/ind2sub' );
+var broadcastArrayExceptDimensions = require( '@stdlib/ndarray/base/broadcast-array-except-dimensions' );
+
+// Create a 1x3 array:
+var x = array( [ [ 1, 2, 3 ] ] );
+// returns
+
+// Broadcast the array to 3x2x2:
+var y = broadcastArrayExceptDimensions( x, [ 2, 2, 3 ], [ -2 ] );
+// returns
+
+// Retrieve the shape:
+var sh = y.shape;
+// returns [ 2, 1, 3 ]
+
+// Retrieve the number of elements:
+var N = numel( sh );
+
+// Loop through the array elements...
+var sub;
+var v;
+var i;
+for ( i = 0; i < N; i++ ) {
+ v = y.iget( i );
+ sub = ind2sub( sh, i );
+ console.log( 'Y[%s] = %d', sub.join( ', ' ), v );
+}
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/ctor
+
+[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor
+
+[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/broadcast-shapes
+
+
+
+
diff --git a/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/benchmark/benchmark.js
new file mode 100644
index 000000000000..1933c79e81a0
--- /dev/null
+++ b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/benchmark/benchmark.js
@@ -0,0 +1,161 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 Float64Array = require( '@stdlib/array/float64' );
+var ndarrayBase = require( '@stdlib/ndarray/base/ctor' );
+var ndarray = require( '@stdlib/ndarray/ctor' );
+var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
+var pkg = require( './../package.json' ).name;
+var broadcastArrayExceptDimensions = require( './../lib' );
+
+
+// MAIN //
+
+bench( pkg+'::base_ndarray,2d', function benchmark( b ) {
+ var strides;
+ var values;
+ var buffer;
+ var offset;
+ var dtype;
+ var shape;
+ var order;
+ var out;
+ var i;
+
+ dtype = 'float64';
+ buffer = new Float64Array( 4 );
+ shape = [ 2, 2 ];
+ strides = [ 2, 1 ];
+ offset = 0;
+ order = 'row-major';
+
+ values = [
+ ndarrayBase( dtype, buffer, shape, strides, offset, order ),
+ ndarrayBase( dtype, buffer, shape, strides, offset, order ),
+ ndarrayBase( dtype, buffer, shape, strides, offset, order ),
+ ndarrayBase( dtype, buffer, shape, strides, offset, order ),
+ ndarrayBase( dtype, buffer, shape, strides, offset, order )
+ ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ out = broadcastArrayExceptDimensions( values[ i%values.length ], [ 2, 2, 2 ] );
+ if ( typeof out !== 'object' ) {
+ b.fail( 'should return an object' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( out ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::ndarray,2d', function benchmark( b ) {
+ var strides;
+ var values;
+ var buffer;
+ var offset;
+ var dtype;
+ var shape;
+ var order;
+ var out;
+ var i;
+
+ dtype = 'float64';
+ buffer = new Float64Array( 4 );
+ shape = [ 2, 2 ];
+ strides = [ 2, 1 ];
+ offset = 0;
+ order = 'row-major';
+
+ values = [
+ ndarray( dtype, buffer, shape, strides, offset, order ),
+ ndarray( dtype, buffer, shape, strides, offset, order ),
+ ndarray( dtype, buffer, shape, strides, offset, order ),
+ ndarray( dtype, buffer, shape, strides, offset, order ),
+ ndarray( dtype, buffer, shape, strides, offset, order )
+ ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ out = broadcastArrayExceptDimensions( values[ i%values.length ], [ 2, 2, 2 ] );
+ if ( typeof out !== 'object' ) {
+ b.fail( 'should return an object' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( out ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::ndarray_like,2d', function benchmark( b ) {
+ var strides;
+ var values;
+ var buffer;
+ var offset;
+ var dtype;
+ var shape;
+ var order;
+ var out;
+ var obj;
+ var i;
+
+ dtype = 'float64';
+ buffer = new Float64Array( 4 );
+ shape = [ 2, 2 ];
+ strides = [ 2, 1 ];
+ offset = 0;
+ order = 'row-major';
+
+ values = [];
+ for ( i = 0; i < 5; i++ ) {
+ obj = {
+ 'dtype': dtype,
+ 'data': buffer,
+ 'shape': shape,
+ 'strides': strides,
+ 'offset': offset,
+ 'order': order
+ };
+ values.push( obj );
+ }
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ out = broadcastArrayExceptDimensions( values[ i%values.length ], [ 2, 2, 2 ] );
+ if ( typeof out !== 'object' ) {
+ b.fail( 'should return an object' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( out ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
diff --git a/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/docs/repl.txt
new file mode 100644
index 000000000000..077e2307d25e
--- /dev/null
+++ b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/docs/repl.txt
@@ -0,0 +1,58 @@
+
+{{alias}}( arr, shape[, dims] )
+ Broadcasts an input ndarray to a target shape keeping the specified
+ dimensions unchanged.
+
+ The returned array is a "base" ndarray, and, thus, the returned array does
+ not perform bounds checking or afford any of the guarantees of the non-base
+ ndarray constructor. The primary intent of this function is to broadcast an
+ ndarray-like object within internal implementations and to do so with
+ minimal overhead.
+
+ The function always returns a new ndarray instance even if the input ndarray
+ shape and the desired shape are the same.
+
+ The function throws an error if a provided ndarray is incompatible with a
+ provided shape.
+
+ Parameters
+ ----------
+ arr: ndarray
+ Input array.
+
+ shape: ArrayLikeObject
+ Desired shape.
+
+ dims: Array (optional)
+ List of dimensions to exclude from broadcasting.
+
+ Returns
+ -------
+ out: ndarray
+ Broadcasted array.
+
+ Examples
+ --------
+ > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2, 3 ] ] )
+
+ > var sh = x.shape
+ [ 1, 3 ]
+ > var y = {{alias}}( x, [ 2, 2, 3 ], [ -2 ] )
+
+ > sh = y.shape
+ [ 2, 1, 3 ]
+ > var v = y.get( 0, 0, 0 )
+ 1
+ > v = y.get( 0, 0, 1 )
+ 2
+ > v = y.get( 0, 0, 2 )
+ 3
+ > v = y.get( 1, 0, 0 )
+ 1
+ > v = y.get( 1, 0, 1 )
+ 2
+ > v = y.get( 1, 0, 2 )
+ 3
+
+ See Also
+ --------
diff --git a/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/docs/types/index.d.ts
new file mode 100644
index 000000000000..fd6062082898
--- /dev/null
+++ b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/docs/types/index.d.ts
@@ -0,0 +1,83 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 { ArrayLike } from '@stdlib/types/array';
+import { ndarray } from '@stdlib/types/ndarray';
+
+/**
+* Broadcasts an input ndarray to a target shape keeping the specified dimension unchanged.
+*
+* ## Notes
+*
+* - The function throws an error if a provided ndarray is incompatible with a provided shape.
+* - The returned array is a view on the input array data buffer. The view is typically **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to the view may affect multiple elements. If you need to write to the returned array, copy the array before performing operations which may mutate elements.
+* - The returned array is a "base" ndarray, and, thus, the returned array does not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to broadcast an ndarray-like object within internal implementations and to do so with minimal overhead.
+* - The function always returns a new ndarray instance even if the input ndarray shape and the desired shape are the same.
+*
+* @param arr - input array
+* @param shape - desired shape
+* @param dims - list of dimensions to exclude
+* @throws input array cannot have more dimensions than the desired shape
+* @throws input array and desired shape must be broadcast compatible
+* @throws dimension indices must not exceed desired shape bounds
+* @throws must provide unique dimension indices
+* @returns broadcasted array
+*
+* @example
+* var array = require( '@stdlib/ndarray/array' );
+*
+* var x = array( [ [ 1, 2, 3 ] ] );
+* // returns
+*
+* var shx = x.shape;
+* // returns [ 1, 3 ]
+*
+* var y = broadcastArrayExceptDimensionsExceptDimensions( x, [ 2, 2, 3 ], [ -2 ] );
+* // returns
+*
+* var shy = y.shape;
+* // returns [ 2, 1, 3 ]
+*
+* var v = y.get( 0, 0, 0 );
+* // returns 1
+*
+* v = y.get( 0, 0, 1 );
+* // returns 2
+*
+* v = y.get( 0, 0, 2 );
+* // returns 3
+*
+* v = y.get( 1, 0, 0 );
+* // returns 1
+*
+* v = y.get( 1, 0, 1 );
+* // returns 2
+*
+* v = y.get( 1, 0, 2 );
+* // returns 3
+*/
+declare function broadcastArrayExceptDimensions( arr: ndarray, shape: ArrayLike, dims?: ArrayLike ): ndarray;
+
+
+// EXPORTS //
+
+export = broadcastArrayExceptDimensions;
diff --git a/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/docs/types/test.ts
new file mode 100644
index 000000000000..07b82ebf48d3
--- /dev/null
+++ b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/docs/types/test.ts
@@ -0,0 +1,126 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 { ndarray } from '@stdlib/types/ndarray';
+import broadcastArrayExceptDimensions = require( './index' );
+
+/**
+* Mock function to create an ndarray-like object.
+*
+* @returns ndarray-like object
+*/
+function array(): ndarray {
+ const obj: ndarray = {
+ 'byteLength': 80,
+ 'BYTES_PER_ELEMENT': 8,
+ 'data': new Float64Array( 10 ),
+ 'dtype': 'float64',
+ 'flags': {
+ 'ROW_MAJOR_CONTIGUOUS': true,
+ 'COLUMN_MAJOR_CONTIGUOUS': false
+ },
+ 'length': 10,
+ 'ndims': 1,
+ 'offset': 0,
+ 'order': 'row-major',
+ 'shape': [ 10 ],
+ 'strides': [ 1 ],
+ 'get': (): number => 0,
+ 'set': (): ndarray => obj
+ };
+ return obj;
+}
+
+
+// TESTS //
+
+// The function returns an ndarray...
+{
+ const x = array();
+
+ broadcastArrayExceptDimensions( x, [ 2, 2, 2 ] ); // $ExpectType ndarray
+ broadcastArrayExceptDimensions( x, [ 2, 2, 2 ], [ -2 ] ); // $ExpectType ndarray
+}
+
+// The compiler throws an error if the function is not provided a first argument which is an ndarray...
+{
+ broadcastArrayExceptDimensions( '5', [ 2, 2, 2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( 5, [ 2, 2, 2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( true, [ 2, 2, 2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( false, [ 2, 2, 2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( null, [ 2, 2, 2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( {}, [ 2, 2, 2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( [ '5' ], [ 2, 2, 2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( ( x: number ): number => x, [ 2, 2, 2 ] ); // $ExpectError
+
+ broadcastArrayExceptDimensions( '5', [ 2, 2, 2 ], [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( 5, [ 2, 2, 2 ], [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( true, [ 2, 2, 2 ], [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( false, [ 2, 2, 2 ], [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( null, [ 2, 2, 2 ], [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( {}, [ 2, 2, 2 ], [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( [ '5' ], [ 2, 2, 2 ], [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( ( x: number ): number => x, [ 2, 2, 2 ], [ -2 ] ); // $ExpectError
+}
+
+// The compiler throws an error if the function is not provided a second argument which is an array-like object containing numbers...
+{
+ const x = array();
+
+ broadcastArrayExceptDimensions( x, '5' ); // $ExpectError
+ broadcastArrayExceptDimensions( x, 5 ); // $ExpectError
+ broadcastArrayExceptDimensions( x, true ); // $ExpectError
+ broadcastArrayExceptDimensions( x, false ); // $ExpectError
+ broadcastArrayExceptDimensions( x, null ); // $ExpectError
+ broadcastArrayExceptDimensions( x, {} ); // $ExpectError
+ broadcastArrayExceptDimensions( x, [ '5' ] ); // $ExpectError
+ broadcastArrayExceptDimensions( x, ( x: number ): number => x ); // $ExpectError
+
+ broadcastArrayExceptDimensions( x, '5', [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( x, 5, [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( x, true, [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( x, false, [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( x, null, [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( x, {}, [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( x, [ '5' ], [ -2 ] ); // $ExpectError
+ broadcastArrayExceptDimensions( x, ( x: number ): number => x, [ -2 ] ); // $ExpectError
+}
+
+// The compiler throws an error if the function is not provided a third argument which is not an array-like object containing numbers...
+{
+ const x = array();
+
+ broadcastArrayExceptDimensions( x, [ 2, 2, 2 ], '5' ); // $ExpectError
+ broadcastArrayExceptDimensions( x, [ 2, 2, 2 ], 5 ); // $ExpectError
+ broadcastArrayExceptDimensions( x, [ 2, 2, 2 ], true ); // $ExpectError
+ broadcastArrayExceptDimensions( x, [ 2, 2, 2 ], false ); // $ExpectError
+ broadcastArrayExceptDimensions( x, [ 2, 2, 2 ], null ); // $ExpectError
+ broadcastArrayExceptDimensions( x, [ 2, 2, 2 ], [ '5' ] ); // $ExpectError
+ broadcastArrayExceptDimensions( x, [ 2, 2, 2 ], ( x: number ): number => x ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ const x = array();
+
+ broadcastArrayExceptDimensions(); // $ExpectError
+ broadcastArrayExceptDimensions( x ); // $ExpectError
+ broadcastArrayExceptDimensions( x, [ 1, 2, 3 ], [ -2 ], {} ); // $ExpectError
+}
diff --git a/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/examples/index.js
new file mode 100644
index 000000000000..e47cf7dd89ff
--- /dev/null
+++ b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/examples/index.js
@@ -0,0 +1,49 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 array = require( '@stdlib/ndarray/array' );
+var numel = require( '@stdlib/ndarray/base/numel' );
+var ind2sub = require( '@stdlib/ndarray/ind2sub' );
+var broadcastArrayExceptDimensions = require( './../lib' );
+
+// Create a 1x3 array:
+var x = array( [ [ 1, 2, 3 ] ] );
+// returns
+
+// Broadcast the array to 2x1x3:
+var y = broadcastArrayExceptDimensions( x, [ 2, 2, 3 ], [ -2 ] );
+// returns
+
+// Retrieve the shape:
+var sh = y.shape;
+// returns [ 2, 1, 3 ]
+
+// Retrieve the number of elements:
+var N = numel( sh );
+
+// Loop through the array elements...
+var sub;
+var v;
+var i;
+for ( i = 0; i < N; i++ ) {
+ v = y.iget( i );
+ sub = ind2sub( sh, i );
+ console.log( 'Y[%s] = %d', sub.join( ', ' ), v );
+}
diff --git a/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/lib/index.js
new file mode 100644
index 000000000000..237b0f99d235
--- /dev/null
+++ b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/lib/index.js
@@ -0,0 +1,68 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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';
+
+/**
+* Broadcast an input ndarray to a target shape keeping the specified dimensions unchanged.
+*
+* @module @stdlib/ndarray/base/broadcast-array-except-dimensions
+*
+* @example
+* var array = require( '@stdlib/ndarray/array' );
+* var broadcastArrayExceptDimensions = require( '@stdlib/ndarray/base/broadcast-array-except-dimensions' );
+*
+* var x = array( [ [ 1, 2, 3 ] ] );
+* // returns
+*
+* var shx = x.shape;
+* // returns [ 1, 3 ]
+*
+* var y = broadcastArrayExceptDimensionsExceptDimensions( x, [ 2, 2, 3 ], [ -2 ] );
+* // returns
+*
+* var shy = y.shape;
+* // returns [ 2, 1, 3 ]
+*
+* var v = y.get( 0, 0, 0 );
+* // returns 1
+*
+* v = y.get( 0, 0, 1 );
+* // returns 2
+*
+* v = y.get( 0, 0, 2 );
+* // returns 3
+*
+* v = y.get( 1, 0, 0 );
+* // returns 1
+*
+* v = y.get( 1, 0, 1 );
+* // returns 2
+*
+* v = y.get( 1, 0, 2 );
+* // returns 3
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/lib/main.js
new file mode 100644
index 000000000000..4b68ab0f0935
--- /dev/null
+++ b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/lib/main.js
@@ -0,0 +1,159 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 copy = require( '@stdlib/array/base/copy-indexed' );
+var ndarray = require( '@stdlib/ndarray/base/ctor' );
+var getShape = require( '@stdlib/ndarray/base/shape' );
+var getStrides = require( '@stdlib/ndarray/base/strides' );
+var getOffset = require( '@stdlib/ndarray/base/offset' );
+var getOrder = require( '@stdlib/ndarray/base/order' );
+var getDType = require( '@stdlib/ndarray/base/dtype' );
+var getData = require( '@stdlib/ndarray/base/data-buffer' );
+var normalizeIndices = require( '@stdlib/ndarray/base/normalize-indices' );
+var format = require( '@stdlib/string/format' );
+var join = require( '@stdlib/array/base/join' );
+
+
+// MAIN //
+
+/**
+* Broadcasts an input ndarray to a target shape keeping the specified dimensions unchanged.
+*
+* @param {ndarray} arr - input array
+* @param {NonNegativeIntegerArray} shape - desired shape
+* @param {IntegerArray} [dims] - list of dimensions to exclude
+* @throws {Error} input array cannot have more dimensions than the desired shape
+* @throws {Error} input array and desired shape must be broadcast compatible
+* @throws {RangeError} dimension indices must not exceed desired shape bounds
+* @throws {Error} must provide unique dimension indices
+* @returns {ndarray} broadcasted array
+*
+* @example
+* var array = require( '@stdlib/ndarray/array' );
+*
+* var x = array( [ [ 1, 2, 3 ] ] );
+* // returns
+*
+* var shx = x.shape;
+* // returns [ 1, 3 ]
+*
+* var y = broadcastArrayExceptDimensions( x, [ 2, 2, 3 ], [ -2 ] );
+* // returns
+*
+* var shy = y.shape;
+* // returns [ 2, 1, 3 ]
+*
+* var v = y.get( 0, 0, 0 );
+* // returns 1
+*
+* v = y.get( 0, 0, 1 );
+* // returns 2
+*
+* v = y.get( 0, 0, 2 );
+* // returns 3
+*
+* v = y.get( 1, 0, 0 );
+* // returns 1
+*
+* v = y.get( 1, 0, 1 );
+* // returns 2
+*
+* v = y.get( 1, 0, 2 );
+* // returns 3
+*/
+function broadcastArrayExceptDimensions( arr, shape, dims ) {
+ var strides;
+ var dim;
+ var sh;
+ var st;
+ var dl;
+ var di;
+ var N;
+ var M;
+ var d;
+ var i;
+ var j;
+
+ N = shape.length;
+ sh = getShape( arr, false );
+ M = sh.length;
+ if ( N < M ) {
+ throw new Error( 'invalid argument. Cannot broadcast an array to a shape having fewer dimensions. Arrays can only be broadcasted to shapes having the same or more dimensions.' );
+ }
+ // Initialize a strides array...
+ strides = [];
+ for ( i = 0; i < N; i++ ) {
+ strides.push( 0 );
+ }
+ // Determine the output array strides...
+ st = getStrides( arr, false );
+
+ if ( !dims ) {
+ dims = [ -1 ];
+ }
+ // Verify that we've been provided a list of unique dimension indices...
+ dl = dims.length;
+ dims = normalizeIndices( dims, N - 1 );
+ if ( dims === null ) {
+ throw new RangeError( format( 'invalid argument. Third argument contains an out-of-bounds dimension index. Value: [%s].', join( dims, ',' ) ) );
+ }
+ dims.sort();
+ if ( dims.length !== dl ) {
+ throw new Error( format( 'invalid argument. Third argument must contain a list of unique dimension indices. Value: [%s].', join( dims, ',' ) ) );
+ }
+ di = dims.length - 1;
+ for ( i = N-1; i >= 0; i-- ) {
+ j = M - N + i;
+ if ( di >= 0 && dims[ di ] === i ) {
+ if ( j >= 0 ) {
+ shape[ i ] = sh[ j ];
+ strides[ i ] = st[ j ];
+ }
+ di -= 1;
+ continue;
+ }
+ if ( j < 0 ) {
+ // Prepended singleton dimension; stride is zero...
+ continue;
+ }
+ d = sh[ j ];
+ dim = shape[ i ];
+ if ( dim !== 0 && dim < d ) {
+ throw new Error( format( 'invalid argument. Input array cannot be broadcast to the specified shape, as the specified shape has a dimension whose size is less than the size of the corresponding dimension in the input array. Array shape: (%s). Desired shape: (%s). Dimension: %u.', copy( sh ).join( ', ' ), copy( shape ).join( ', ' ), i ) );
+ }
+ if ( d === dim ) {
+ strides[ i ] = st[ j ];
+ } else if ( d === 1 ) {
+ // In order to broadcast dimensions, we set the stride for that dimension to zero...
+ strides[ i ] = 0;
+ } else {
+ // At this point, we know that `dim > d` and that `d` does not equal `1` (e.g., `dim=3` and `d=2`); in which case, the shapes are considered incompatible (even for desired shapes which are multiples of array dimensions, as might be desired when "tiling" an array; e.g., `dim=4` and `d=2`)...
+ throw new Error( format( 'invalid argument. Input array and the specified shape are broadcast incompatible. Array shape: (%s). Desired shape: (%s). Dimension: %u.', copy( sh ).join( ', ' ), copy( shape ).join( ', ' ), i ) );
+ }
+ }
+ return ndarray( getDType( arr ), getData( arr ), copy( shape ), strides, getOffset( arr ), getOrder( arr ) ); // eslint-disable-line max-len
+}
+
+
+// EXPORTS //
+
+module.exports = broadcastArrayExceptDimensions;
diff --git a/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/package.json b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/package.json
new file mode 100644
index 000000000000..45866e8db369
--- /dev/null
+++ b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/package.json
@@ -0,0 +1,68 @@
+{
+ "name": "@stdlib/ndarray/base/broadcast-array-except-dimensions",
+ "version": "0.0.0",
+ "description": "Broadcast an input ndarray to a target shape keeping the specified dimensions unchanged.",
+ "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",
+ "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",
+ "stdtypes",
+ "types",
+ "base",
+ "ndarray",
+ "broadcast",
+ "broadcasting",
+ "reshape",
+ "multidimensional",
+ "array",
+ "utilities",
+ "utility",
+ "utils",
+ "util"
+ ],
+ "__stdlib__": {}
+}
diff --git a/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/test/test.js b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/test/test.js
new file mode 100644
index 000000000000..80618a87e2c4
--- /dev/null
+++ b/lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/test/test.js
@@ -0,0 +1,882 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 array = require( '@stdlib/ndarray/array' );
+var ndarray = require( '@stdlib/ndarray/base/ctor' );
+var broadcastArrayExceptDimensions = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof broadcastArrayExceptDimensions, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function throws an error if provided a desired shape which has fewer dimensions than input array', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = array({
+ 'shape': [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
+ });
+
+ values = [
+ [],
+ [ 2 ],
+ [ 2, 2 ],
+ [ 2, 2, 2 ],
+ [ 2, 2, 2, 2 ],
+ [ 2, 2, 2, 2, 2 ],
+ [ 2, 2, 2, 2, 2, 2 ],
+ [ 2, 2, 2, 2, 2, 2, 2 ],
+ [ 2, 2, 2, 2, 2, 2, 2, 2 ],
+ [ 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided a shape with '+values[ i ].length+' dimension' );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ broadcastArrayExceptDimensions( x, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a desired shape which has fewer dimensions than input array (dims)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = array({
+ 'shape': [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
+ });
+
+ values = [
+ [],
+ [ 2 ],
+ [ 2, 2 ],
+ [ 2, 2, 2 ],
+ [ 2, 2, 2, 2 ],
+ [ 2, 2, 2, 2, 2 ],
+ [ 2, 2, 2, 2, 2, 2 ],
+ [ 2, 2, 2, 2, 2, 2, 2 ],
+ [ 2, 2, 2, 2, 2, 2, 2, 2 ],
+ [ 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided a shape with '+values[ i ].length+' dimension' );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ broadcastArrayExceptDimensions( x, value, [ -2 ] );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a desired shape having a dimension whose size is less than the corresponding dimension in the input array', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = array({
+ 'shape': [ 10, 10 ]
+ });
+
+ values = [
+ [ 10, 10, 1 ],
+ [ 10, 10, 2 ],
+ [ 10, 10, 9 ],
+ [ 10, 1, 10 ],
+ [ 10, 2, 10 ],
+ [ 10, 9, 10 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided shape ('+values[ i ].join( ',')+')' );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ broadcastArrayExceptDimensions( x, value, [ -3 ] );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a desired shape and an input array shape are broadcast-incompatible', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = array({
+ 'shape': [ 10, 10 ]
+ });
+
+ values = [
+ [ 10, 20, 10 ],
+ [ 10, 100, 10 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided shape ('+values[ i ].join( ',')+')' );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ broadcastArrayExceptDimensions( x, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a desired shape and an input array shape are broadcast-incompatible (dims)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = array({
+ 'shape': [ 10, 10 ]
+ });
+
+ values = [
+ [ 10, 10, 20 ],
+ [ 10, 100, 10 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided shape ('+values[ i ].join( ',')+')' );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ broadcastArrayExceptDimensions( x, value, [ -3 ] );
+ };
+ }
+});
+
+tape( 'the function returns a "base" ndarray instance', function test( t ) {
+ var x;
+ var y;
+
+ x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
+ y = broadcastArrayExceptDimensions( x, [ 2, 2, 2 ] );
+
+ t.notEqual( y, x, 'returns new instance' );
+ t.strictEqual( y instanceof ndarray, true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function returns a "base" ndarray instance (dims)', function test( t ) {
+ var x;
+ var y;
+
+ x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
+ y = broadcastArrayExceptDimensions( x, [ 2, 2, 2 ], [ -2 ] );
+
+ t.notEqual( y, x, 'returns new instance' );
+ t.strictEqual( y instanceof ndarray, true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function returns a view over the input array data buffer', function test( t ) {
+ var x;
+ var y;
+
+ x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
+ y = broadcastArrayExceptDimensions( x, [ 2, 2, 2 ] );
+
+ t.strictEqual( y.data, x.data, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function returns a view over the input array data buffer (dims)', function test( t ) {
+ var x;
+ var y;
+
+ x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
+ y = broadcastArrayExceptDimensions( x, [ 2, 2, 2 ], [ -2 ] );
+
+ t.strictEqual( y.data, x.data, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (row-major)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4 ];
+ x = array( data, {
+ 'dtype': 'generic',
+ 'shape': [ 2, 2 ],
+ 'order': 'row-major'
+ });
+
+ expected = [ 5, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, data[ 2 ], 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, data[ 3 ], 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (row-major, dims)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4 ];
+ x = array( data, {
+ 'dtype': 'generic',
+ 'shape': [ 2, 2 ],
+ 'order': 'row-major'
+ });
+
+ expected = [ 5, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected, [ -2 ] );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, data[ 2 ], 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, data[ 3 ], 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (row-major, strides)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4 ];
+ x = ndarray( 'generic', data, [ 2, 2 ], [ -2, -1 ], 3, 'row-major' );
+
+ expected = [ 5, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 3 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 2 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (row-major, strides, dims)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4 ];
+ x = ndarray( 'generic', data, [ 2, 2 ], [ -2, -1 ], 3, 'row-major' );
+
+ expected = [ 5, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected, [ -2 ] );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 3 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 2 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (row-major, strides)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4 ];
+ x = ndarray( 'generic', data, [ 2, 2 ], [ -2, 1 ], 2, 'row-major' );
+
+ expected = [ 5, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 2 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 3 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (row-major, strides, dims)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4 ];
+ x = ndarray( 'generic', data, [ 2, 2 ], [ -2, 1 ], 2, 'row-major' );
+
+ expected = [ 5, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected, [ -2 ] );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 2 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 3 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (row-major, non-contiguous)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4, 5, 6, 7, 8 ];
+ x = ndarray( 'generic', data, [ 2, 2 ], [ 4, 2 ], 1, 'row-major' );
+
+ expected = [ 5, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 3 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, data[ 5 ], 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, data[ 7 ], 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (row-major, non-contiguous, dims)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4, 5, 6, 7, 8 ];
+ x = ndarray( 'generic', data, [ 2, 2 ], [ 4, 2 ], 1, 'row-major' );
+
+ expected = [ 5, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected, [ -2 ] );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 3 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, data[ 5 ], 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, data[ 7 ], 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (column-major)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4 ];
+ x = array( data, {
+ 'dtype': 'generic',
+ 'shape': [ 2, 2 ],
+ 'order': 'column-major'
+ });
+
+ expected = [ 5, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 2 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, data[ 3 ], 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (column-major, dims)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4 ];
+ x = array( data, {
+ 'dtype': 'generic',
+ 'shape': [ 2, 2 ],
+ 'order': 'column-major'
+ });
+
+ expected = [ 5, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected, [ -2 ] );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 2 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, data[ 3 ], 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (same shape)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4, 5, 6, 7, 8 ];
+ x = array( data, {
+ 'dtype': 'generic',
+ 'shape': [ 2, 2, 2 ],
+ 'order': 'row-major'
+ });
+
+ expected = [ 2, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, x.get( i, 0, 0 ), 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, x.get( i, 0, 1 ), 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, x.get( i, 1, 0 ), 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, x.get( i, 1, 1 ), 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (same shape, dims)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4, 5, 6, 7, 8 ];
+ x = array( data, {
+ 'dtype': 'generic',
+ 'shape': [ 2, 2, 2 ],
+ 'order': 'row-major'
+ });
+
+ expected = [ 2, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected, [ -2 ] );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, x.get( i, 0, 0 ), 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, x.get( i, 0, 1 ), 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, x.get( i, 1, 0 ), 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, x.get( i, 1, 1 ), 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (same number of dimensions)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4 ];
+ x = array( data, {
+ 'dtype': 'generic',
+ 'shape': [ 2, 1, 2 ],
+ 'order': 'row-major'
+ });
+
+ expected = [ 2, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, x.get( i, 0, 0 ), 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, x.get( i, 0, 1 ), 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, x.get( i, 0, 0 ), 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, x.get( i, 0, 1 ), 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (same number of dimensions, dims)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2, 3, 4 ];
+ x = array( data, {
+ 'dtype': 'generic',
+ 'shape': [ 2, 1, 2 ],
+ 'order': 'row-major'
+ });
+
+ y = broadcastArrayExceptDimensions( x, [ 2, 2, 2 ], [ -2 ] );
+ expected = [ 2, 1, 2 ];
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, x.get( i, 0, 0 ), 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, x.get( i, 0, 1 ), 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, x.get( i, 0, 0 ), 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, x.get( i, 0, 1 ), 'returns expected value for element ('+i+',0,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (singleton dimension)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2 ];
+ x = array( data, {
+ 'dtype': 'generic',
+ 'shape': [ 1, 2 ],
+ 'order': 'row-major'
+ });
+
+ expected = [ 5, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (singleton dimension, dims)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1, 2 ];
+ x = array( data, {
+ 'dtype': 'generic',
+ 'shape': [ 1, 2 ],
+ 'order': 'row-major'
+ });
+
+ y = broadcastArrayExceptDimensions( x, [ 5, 2, 2 ], [ -2 ] );
+ expected = [ 5, 1, 2 ];
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 1 ], 'returns expected value for element ('+i+',0,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (0-dimensional array)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1 ];
+ x = ndarray( 'generic', data, [], [ 0 ], 0, 'row-major' );
+
+ expected = [ 5, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});
+
+tape( 'the function broadcasts an input array (0-dimensional array, dims)', function test( t ) {
+ var expected;
+ var actual;
+ var data;
+ var x;
+ var y;
+ var v;
+ var i;
+
+ data = [ 1 ];
+ x = ndarray( 'generic', data, [], [ 0 ], 0, 'row-major' );
+
+ expected = [ 5, 2, 2 ];
+ y = broadcastArrayExceptDimensions( x, expected, [ -2 ] );
+
+ actual = y.shape;
+ t.deepEqual( actual, expected, 'returns expected shape' );
+
+ for ( i = 0; i < expected[ 0 ]; i++ ) {
+ v = y.get( i, 0, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,0)' );
+
+ v = y.get( i, 0, 1 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',0,1)' );
+
+ v = y.get( i, 1, 0 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',1,0)' );
+
+ v = y.get( i, 1, 1 );
+ t.strictEqual( v, data[ 0 ], 'returns expected value for element ('+i+',1,1)' );
+ }
+ t.end();
+});