diff --git a/base/lib/index.js b/base/lib/index.js
index 6572138f..019a27e5 100644
--- a/base/lib/index.js
+++ b/base/lib/index.js
@@ -499,6 +499,15 @@ setReadOnly( ns, 'singletonDimensions', require( './../../base/singleton-dimensi
*/
setReadOnly( ns, 'slice', require( './../../base/slice' ) );
+/**
+* @name sliceAssign
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/slice-assign}
+*/
+setReadOnly( ns, 'sliceAssign', require( './../../base/slice-assign' ) );
+
/**
* @name strides2offset
* @memberof ns
diff --git a/base/slice-assign/README.md b/base/slice-assign/README.md
new file mode 100644
index 00000000..2bb824c0
--- /dev/null
+++ b/base/slice-assign/README.md
@@ -0,0 +1,232 @@
+
+
+# sliceAssign
+
+> Assign element values from a broadcasted input `ndarray` to corresponding elements in an output `ndarray` view.
+
+
+
+
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var sliceAssign = require( '@stdlib/ndarray/base/slice-assign' );
+```
+
+#### slice( x, y, slice, strict )
+
+Assigns element values from a broadcasted input `ndarray` to corresponding elements in an output `ndarray` view.
+
+```javascript
+var Slice = require( '@stdlib/slice/ctor' );
+var MultiSlice = require( '@stdlib/slice/multi' );
+var ndarray = require( '@stdlib/ndarray/ctor' );
+var ndzeros = require( '@stdlib/ndarray/zeros' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+
+// Define an input array:
+var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
+var shape = [ 3, 2 ];
+var strides = [ 2, 1 ];
+var offset = 0;
+
+var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
+// returns
+
+var sh = x.shape;
+// returns [ 3, 2 ]
+
+var arr = ndarray2array( x );
+// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
+
+// Define an output array:
+var y = ndzeros( [ 2, 3, 2 ], {
+ 'dtype': x.dtype
+});
+
+// Create a slice:
+var s0 = null;
+var s1 = new Slice( null, null, -1 );
+var s2 = new Slice( null, null, -1 );
+var s = new MultiSlice( s0, s1, s2 );
+// returns
+
+// Perform assignment:
+var out = sliceAssign( x, y, s, false );
+// returns
+
+var bool = ( out === y );
+// returns true
+
+arr = ndarray2array( y );
+// returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]
+```
+
+The function accepts the following arguments:
+
+- **x**: input `ndarray`.
+- **y**: output `ndarray`.
+- **slice**: a [`MultiSlice`][@stdlib/slice/multi] instance specifying the output `ndarray` view.
+- **strict**: boolean indicating whether to enforce strict bounds checking.
+
+
+
+
+
+
+
+
+
+## Notes
+
+- The input `ndarray` **must** be [broadcast compatible][@stdlib/ndarray/base/broadcast-shapes] with the output `ndarray` view.
+- The input `ndarray` must have a [data type][@stdlib/ndarray/dtypes] which can be [safely cast][@stdlib/ndarray/safe-casts] to the output `ndarray` data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the [same kind][@stdlib/ndarray/same-kind-casts] (e.g., element values from a `'float64'` input `ndarray` can be assigned to corresponding elements in a `'float32'` output `ndarray`).
+
+
+
+
+
+
+
+
+
+## Examples
+
+
+
+
+
+```javascript
+var E = require( '@stdlib/slice/multi' );
+var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var ndzeros = require( '@stdlib/ndarray/zeros' );
+var slice = require( '@stdlib/ndarray/base/slice' );
+var sliceAssign = require( '@stdlib/ndarray/base/slice-assign' );
+
+// Alias `null` to allow for more compact indexing expressions:
+var _ = null;
+
+// Create an output ndarray:
+var y = ndzeros( [ 3, 3, 3 ] );
+
+// Update each matrix...
+var s1 = E( 0, _, _ );
+sliceAssign( scalar2ndarray( 100 ), y, s1, false );
+
+var a1 = ndarray2array( slice( y, s1, false ) );
+// returns [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ]
+
+var s2 = E( 1, _, _ );
+sliceAssign( scalar2ndarray( 200 ), y, s2, false );
+
+var a2 = ndarray2array( slice( y, s2, false ) );
+// returns [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ]
+
+var s3 = E( 2, _, _ );
+sliceAssign( scalar2ndarray( 300 ), y, s3, false );
+
+var a3 = ndarray2array( slice( y, s3, false ) );
+// returns [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ]
+
+// Update the second rows in each matrix:
+var s4 = E( _, 1, _ );
+sliceAssign( scalar2ndarray( 400 ), y, s4, false );
+
+var a4 = ndarray2array( slice( y, s4, false ) );
+// returns [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ]
+
+// Update the second columns in each matrix:
+var s5 = E( _, _, 1 );
+sliceAssign( scalar2ndarray( 500 ), y, s5, false );
+
+var a5 = ndarray2array( slice( y, s5, false ) );
+// returns [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ]
+
+// Return the contents of the entire ndarray:
+var a6 = ndarray2array( y );
+/* returns
+ [
+ [
+ [ 100, 500, 100 ],
+ [ 400, 500, 400 ],
+ [ 100, 500, 100 ]
+ ],
+ [
+ [ 200, 500, 200 ],
+ [ 400, 500, 400 ],
+ [ 200, 500, 200 ]
+ ],
+ [
+ [ 300, 500, 300 ],
+ [ 400, 500, 400 ],
+ [ 300, 500, 300 ]
+ ]
+ ]
+*/
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[@stdlib/slice/multi]: https://github.com/stdlib-js/stdlib
+
+[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray/tree/main/base/broadcast-shapes
+
+[@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/ndarray/tree/main/safe-casts
+
+[@stdlib/ndarray/same-kind-casts]: https://github.com/stdlib-js/ndarray/tree/main/same-kind-casts
+
+[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray/tree/main/dtypes
+
+
+
+
diff --git a/base/slice-assign/benchmark/benchmark.js b/base/slice-assign/benchmark/benchmark.js
new file mode 100644
index 00000000..107b274f
--- /dev/null
+++ b/base/slice-assign/benchmark/benchmark.js
@@ -0,0 +1,1824 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
+var MultiSlice = require( '@stdlib/slice/multi' );
+var Slice = require( '@stdlib/slice/ctor' );
+var baseEmpty = require( './../../../base/empty' );
+var baseZeros = require( './../../../base/zeros' );
+var empty = require( './../../../empty' );
+var zeros = require( './../../../zeros' );
+var pkg = require( './../package.json' ).name;
+var sliceAssign = require( './../lib' );
+
+
+// MAIN //
+
+bench( pkg+'::0d,base', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [], 'row-major' ),
+ baseEmpty( 'float32', [], 'row-major' ),
+ baseEmpty( 'int32', [], 'row-major' ),
+ baseEmpty( 'complex128', [], 'row-major' ),
+ baseEmpty( 'generic', [], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [], 'row-major' ),
+ baseZeros( 'float32', [], 'row-major' ),
+ baseZeros( 'int32', [], 'row-major' ),
+ baseZeros( 'complex128', [], 'row-major' ),
+ baseZeros( 'generic', [], 'row-major' )
+ ];
+ s = new MultiSlice();
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::0d,non-base', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [], { 'dtype': 'float64' } ),
+ empty( [], { 'dtype': 'float32' } ),
+ empty( [], { 'dtype': 'int32' } ),
+ empty( [], { 'dtype': 'complex128' } ),
+ empty( [], { 'dtype': 'generic' } )
+ ];
+
+ y = [
+ zeros( [], { 'dtype': 'float64' } ),
+ zeros( [], { 'dtype': 'float32' } ),
+ zeros( [], { 'dtype': 'int32' } ),
+ zeros( [], { 'dtype': 'complex128' } ),
+ zeros( [], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice();
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::1d,base', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [ 2 ], 'row-major' ),
+ baseEmpty( 'float32', [ 2 ], 'row-major' ),
+ baseEmpty( 'int32', [ 2 ], 'row-major' ),
+ baseEmpty( 'complex128', [ 2 ], 'row-major' ),
+ baseEmpty( 'generic', [ 2 ], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::1d,non-base', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [ 2 ], { 'dtype': 'float64' } ),
+ empty( [ 2 ], { 'dtype': 'float32' } ),
+ empty( [ 2 ], { 'dtype': 'int32' } ),
+ empty( [ 2 ], { 'dtype': 'complex128' } ),
+ empty( [ 2 ], { 'dtype': 'generic' } )
+ ];
+
+ y = [
+ zeros( [ 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::1d,base,reduced', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [], 'row-major' ),
+ baseEmpty( 'float32', [], 'row-major' ),
+ baseEmpty( 'int32', [], 'row-major' ),
+ baseEmpty( 'complex128', [], 'row-major' ),
+ baseEmpty( 'generic', [], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( 1 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::1d,non-base,reduced', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [], { 'dtype': 'float64' } ),
+ empty( [], { 'dtype': 'float32' } ),
+ empty( [], { 'dtype': 'int32' } ),
+ empty( [], { 'dtype': 'complex128' } ),
+ empty( [], { 'dtype': 'generic' } )
+ ];
+
+ y = [
+ zeros( [ 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( 1 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::1d,base,broadcasted', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [], 'row-major' ),
+ baseEmpty( 'float32', [], 'row-major' ),
+ baseEmpty( 'int32', [], 'row-major' ),
+ baseEmpty( 'complex128', [], 'row-major' ),
+ baseEmpty( 'generic', [], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::1d,non-base,broadcasted', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [], { 'dtype': 'float64' } ),
+ empty( [], { 'dtype': 'float32' } ),
+ empty( [], { 'dtype': 'int32' } ),
+ empty( [], { 'dtype': 'complex128' } ),
+ empty( [], { 'dtype': 'generic' } )
+ ];
+
+ y = [
+ zeros( [ 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [ 1 ], 'row-major' ),
+ baseEmpty( 'float32', [ 1 ], 'row-major' ),
+ baseEmpty( 'int32', [ 1 ], 'row-major' ),
+ baseEmpty( 'complex128', [ 1 ], 'row-major' ),
+ baseEmpty( 'generic', [ 1 ], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( new Slice( 10, 20, 1 ) );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [ 1 ], { 'dtype': 'float64' } ),
+ empty( [ 1 ], { 'dtype': 'float32' } ),
+ empty( [ 1 ], { 'dtype': 'int32' } ),
+ empty( [ 1 ], { 'dtype': 'complex128' } ),
+ empty( [ 1 ], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( new Slice( 10, 20, 1 ) );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::2d,base', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [ 2, 2 ], 'row-major' ),
+ baseEmpty( 'float32', [ 2, 2 ], 'row-major' ),
+ baseEmpty( 'int32', [ 2, 2 ], 'row-major' ),
+ baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ),
+ baseEmpty( 'generic', [ 2, 2 ], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::2d,non-base', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [ 2, 2 ], { 'dtype': 'float64' } ),
+ empty( [ 2, 2 ], { 'dtype': 'float32' } ),
+ empty( [ 2, 2 ], { 'dtype': 'int32' } ),
+ empty( [ 2, 2 ], { 'dtype': 'complex128' } ),
+ empty( [ 2, 2 ], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::2d,base,reduced', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [], 'row-major' ),
+ baseEmpty( 'float32', [], 'row-major' ),
+ baseEmpty( 'int32', [], 'row-major' ),
+ baseEmpty( 'complex128', [], 'row-major' ),
+ baseEmpty( 'generic', [], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( 0, 1 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::2d,non-base,reduced', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [], { 'dtype': 'float64' } ),
+ empty( [], { 'dtype': 'float32' } ),
+ empty( [], { 'dtype': 'int32' } ),
+ empty( [], { 'dtype': 'complex128' } ),
+ empty( [], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( 0, 1 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::2d,base,broadcasted', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [], 'row-major' ),
+ baseEmpty( 'float32', [], 'row-major' ),
+ baseEmpty( 'int32', [], 'row-major' ),
+ baseEmpty( 'complex128', [], 'row-major' ),
+ baseEmpty( 'generic', [], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::2d,non-base,broadcasted', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [], { 'dtype': 'float64' } ),
+ empty( [], { 'dtype': 'float32' } ),
+ empty( [], { 'dtype': 'int32' } ),
+ empty( [], { 'dtype': 'complex128' } ),
+ empty( [], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [ 1, 1 ], 'row-major' ),
+ baseEmpty( 'float32', [ 1, 1 ], 'row-major' ),
+ baseEmpty( 'int32', [ 1, 1 ], 'row-major' ),
+ baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ),
+ baseEmpty( 'generic', [ 1, 1 ], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [ 1, 1 ], { 'dtype': 'float64' } ),
+ empty( [ 1, 1 ], { 'dtype': 'float32' } ),
+ empty( [ 1, 1 ], { 'dtype': 'int32' } ),
+ empty( [ 1, 1 ], { 'dtype': 'complex128' } ),
+ empty( [ 1, 1 ], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::3d,base', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ),
+ baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ),
+ baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ),
+ baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ),
+ baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::3d,non-base', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ),
+ empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ),
+ empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ),
+ empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ empty( [ 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::3d,base,reduced', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [], 'row-major' ),
+ baseEmpty( 'float32', [], 'row-major' ),
+ baseEmpty( 'int32', [], 'row-major' ),
+ baseEmpty( 'complex128', [], 'row-major' ),
+ baseEmpty( 'generic', [], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( 0, 1, 0 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::3d,non-base,reduced', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [], { 'dtype': 'float64' } ),
+ empty( [], { 'dtype': 'float32' } ),
+ empty( [], { 'dtype': 'int32' } ),
+ empty( [], { 'dtype': 'complex128' } ),
+ empty( [], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( 0, 1, 0 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::3d,base,broadcasted', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [], 'row-major' ),
+ baseEmpty( 'float32', [], 'row-major' ),
+ baseEmpty( 'int32', [], 'row-major' ),
+ baseEmpty( 'complex128', [], 'row-major' ),
+ baseEmpty( 'generic', [], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::3d,non-base,broadcasted', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [], { 'dtype': 'float64' } ),
+ empty( [], { 'dtype': 'float32' } ),
+ empty( [], { 'dtype': 'int32' } ),
+ empty( [], { 'dtype': 'complex128' } ),
+ empty( [], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ),
+ baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ),
+ baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ),
+ baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ),
+ baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( null, new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ),
+ empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ),
+ empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ),
+ empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ),
+ empty( [ 1, 1, 1 ], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::4d,base', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( null, null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::4d,non-base', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
+ empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
+ empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
+ empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::4d,base,reduced', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [], 'row-major' ),
+ baseEmpty( 'float32', [], 'row-major' ),
+ baseEmpty( 'int32', [], 'row-major' ),
+ baseEmpty( 'complex128', [], 'row-major' ),
+ baseEmpty( 'generic', [], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( 0, 1, 0, 1 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::4d,non-base,reduced', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [], { 'dtype': 'float64' } ),
+ empty( [], { 'dtype': 'float32' } ),
+ empty( [], { 'dtype': 'int32' } ),
+ empty( [], { 'dtype': 'complex128' } ),
+ empty( [], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( 0, 1, 0, 1 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::4d,base,broadcasted', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [], 'row-major' ),
+ baseEmpty( 'float32', [], 'row-major' ),
+ baseEmpty( 'int32', [], 'row-major' ),
+ baseEmpty( 'complex128', [], 'row-major' ),
+ baseEmpty( 'generic', [], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( null, null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::4d,non-base,broadcasted', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [], { 'dtype': 'float64' } ),
+ empty( [], { 'dtype': 'float32' } ),
+ empty( [], { 'dtype': 'int32' } ),
+ empty( [], { 'dtype': 'complex128' } ),
+ empty( [], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ),
+ baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ),
+ baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ),
+ baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ),
+ baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ),
+ empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ),
+ empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ),
+ empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ),
+ empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::5d,base', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( null, null, null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::5d,non-base', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
+ empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
+ empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
+ empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null, null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::5d,base,reduced', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [], 'row-major' ),
+ baseEmpty( 'float32', [], 'row-major' ),
+ baseEmpty( 'int32', [], 'row-major' ),
+ baseEmpty( 'complex128', [], 'row-major' ),
+ baseEmpty( 'generic', [], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( 0, 1, 0, 1, 0 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::5d,non-base,reduced', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [], { 'dtype': 'float64' } ),
+ empty( [], { 'dtype': 'float32' } ),
+ empty( [], { 'dtype': 'int32' } ),
+ empty( [], { 'dtype': 'complex128' } ),
+ empty( [], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( 0, 1, 0, 1, 0 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::5d,base,broadcasted', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [], 'row-major' ),
+ baseEmpty( 'float32', [], 'row-major' ),
+ baseEmpty( 'int32', [], 'row-major' ),
+ baseEmpty( 'complex128', [], 'row-major' ),
+ baseEmpty( 'generic', [], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( null, null, null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::5d,non-base,broadcasted', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [], { 'dtype': 'float64' } ),
+ empty( [], { 'dtype': 'float32' } ),
+ empty( [], { 'dtype': 'int32' } ),
+ empty( [], { 'dtype': 'complex128' } ),
+ empty( [], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null, null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ values = [
+ baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ),
+ baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ),
+ baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ),
+ baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ),
+ baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' )
+ ];
+ y = [
+ baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ),
+ baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' )
+ ];
+ s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) {
+ var values;
+ var v;
+ var y;
+ var s;
+ var i;
+ var j;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ),
+ empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ),
+ empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ),
+ empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ),
+ empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } )
+ ];
+ y = [
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ j = i % values.length;
+ v = sliceAssign( values[ j ], y[ j ], s, false );
+ if ( typeof v !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( !isndarrayLike( v ) ) {
+ b.fail( 'should return an ndarray' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
diff --git a/base/slice-assign/docs/repl.txt b/base/slice-assign/docs/repl.txt
new file mode 100644
index 00000000..9004b705
--- /dev/null
+++ b/base/slice-assign/docs/repl.txt
@@ -0,0 +1,47 @@
+
+{{alias}}( x, y, slice, strict )
+ Assigns element values from a broadcasted input ndarray to corresponding
+ elements in an output ndarray view.
+
+ Parameters
+ ----------
+ x: ndarray
+ Input array. The input array must be broadcast compatible with the
+ output array view and must have a data type which can be safely cast to
+ the output array data type. Floating-point data types (both real and
+ complex) are allowed to downcast to a lower precision data type of the
+ same kind (e.g., element values from a 'float64' input array can be
+ assigned to corresponding elements in a 'float32' output array).
+
+ y: ndarray
+ Output array.
+
+ slice: MultiSlice
+ Multi-slice object specifying the output array view.
+
+ strict: boolean
+ Boolean indicating whether to enforce strict bounds checking.
+
+ Returns
+ -------
+ out: ndarray
+ Output array.
+
+ Examples
+ --------
+ > var y = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ] )
+
+ > var x = {{alias:@stdlib/ndarray/from-scalar}}( 3.0 )
+
+ > var s = new {{alias:@stdlib/slice/multi}}( null, 1 )
+
+ > var out = {{alias}}( x, y, s, false )
+
+ > var bool = ( out === y )
+ true
+ > {{alias:@stdlib/ndarray/to-array}}( y )
+ [ [ 0.0, 3.0 ], [ 0.0, 3.0 ] ]
+
+ See Also
+ --------
+
diff --git a/base/slice-assign/docs/types/index.d.ts b/base/slice-assign/docs/types/index.d.ts
new file mode 100644
index 00000000..56f61e37
--- /dev/null
+++ b/base/slice-assign/docs/types/index.d.ts
@@ -0,0 +1,810 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2023 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// TypeScript Version: 4.1
+
+///
+
+import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray';
+import { MultiSlice } from '@stdlib/types/slice';
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* ## Notes
+*
+* - The input array must be broadcast compatible with the output array view to which elements will be assigned.
+* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array).
+*
+* @param x - input array
+* @param y - output array
+* @param s - multi-slice object for the output array
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @returns output array
+*
+* @example
+* var Slice = require( `@stdlib/slice/ctor` );
+* var MultiSlice = require( `@stdlib/slice/multi` );
+* var typedarray = require( `@stdlib/array/typed` );
+* var ndarray = require( `@stdlib/ndarray/ctor` );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( `@stdlib/ndarray/to-array` );
+*
+* // Define an input array:
+* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' );
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*
+* arr = ndarray2array( y );
+* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]
+*/
+declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, strict: boolean ): float64ndarray;
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* ## Notes
+*
+* - The input array must be broadcast compatible with the output array view to which elements will be assigned.
+* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array).
+*
+* @param x - input array
+* @param y - output array
+* @param s - multi-slice object for the output array
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @returns output array
+*
+* @example
+* var Slice = require( `@stdlib/slice/ctor` );
+* var MultiSlice = require( `@stdlib/slice/multi` );
+* var typedarray = require( `@stdlib/array/typed` );
+* var ndarray = require( `@stdlib/ndarray/ctor` );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( `@stdlib/ndarray/to-array` );
+*
+* // Define an input array:
+* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float32' );
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*
+* arr = ndarray2array( y );
+* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]
+*/
+declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, strict: boolean ): float32ndarray;
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* ## Notes
+*
+* - The input array must be broadcast compatible with the output array view to which elements will be assigned.
+* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array).
+*
+* @param x - input array
+* @param y - output array
+* @param s - multi-slice object for the output array
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @returns output array
+*
+* @example
+* var Slice = require( `@stdlib/slice/ctor` );
+* var MultiSlice = require( `@stdlib/slice/multi` );
+* var typedarray = require( `@stdlib/array/typed` );
+* var ndarray = require( `@stdlib/ndarray/ctor` );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( `@stdlib/ndarray/to-array` );
+*
+* // Define an input array:
+* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int32' );
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*
+* arr = ndarray2array( y );
+* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ]
+*/
+declare function sliceAssign( x: ndarray, y: int32ndarray, s: MultiSlice, strict: boolean ): int32ndarray;
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* ## Notes
+*
+* - The input array must be broadcast compatible with the output array view to which elements will be assigned.
+* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array).
+*
+* @param x - input array
+* @param y - output array
+* @param s - multi-slice object for the output array
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @returns output array
+*
+* @example
+* var Slice = require( `@stdlib/slice/ctor` );
+* var MultiSlice = require( `@stdlib/slice/multi` );
+* var typedarray = require( `@stdlib/array/typed` );
+* var ndarray = require( `@stdlib/ndarray/ctor` );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( `@stdlib/ndarray/to-array` );
+*
+* // Define an input array:
+* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int16' );
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*
+* arr = ndarray2array( y );
+* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ]
+*/
+declare function sliceAssign( x: ndarray, y: int16ndarray, s: MultiSlice, strict: boolean ): int16ndarray;
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* ## Notes
+*
+* - The input array must be broadcast compatible with the output array view to which elements will be assigned.
+* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array).
+*
+* @param x - input array
+* @param y - output array
+* @param s - multi-slice object for the output array
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @returns output array
+*
+* @example
+* var Slice = require( `@stdlib/slice/ctor` );
+* var MultiSlice = require( `@stdlib/slice/multi` );
+* var typedarray = require( `@stdlib/array/typed` );
+* var ndarray = require( `@stdlib/ndarray/ctor` );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( `@stdlib/ndarray/to-array` );
+*
+* // Define an input array:
+* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'int8' );
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*
+* arr = ndarray2array( y );
+* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ]
+*/
+declare function sliceAssign( x: ndarray, y: int8ndarray, s: MultiSlice, strict: boolean ): int8ndarray;
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* ## Notes
+*
+* - The input array must be broadcast compatible with the output array view to which elements will be assigned.
+* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array).
+*
+* @param x - input array
+* @param y - output array
+* @param s - multi-slice object for the output array
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @returns output array
+*
+* @example
+* var Slice = require( `@stdlib/slice/ctor` );
+* var MultiSlice = require( `@stdlib/slice/multi` );
+* var typedarray = require( `@stdlib/array/typed` );
+* var ndarray = require( `@stdlib/ndarray/ctor` );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( `@stdlib/ndarray/to-array` );
+*
+* // Define an input array:
+* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint32' );
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*
+* arr = ndarray2array( y );
+* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ]
+*/
+declare function sliceAssign( x: ndarray, y: uint32ndarray, s: MultiSlice, strict: boolean ): uint32ndarray;
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* ## Notes
+*
+* - The input array must be broadcast compatible with the output array view to which elements will be assigned.
+* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array).
+*
+* @param x - input array
+* @param y - output array
+* @param s - multi-slice object for the output array
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @returns output array
+*
+* @example
+* var Slice = require( `@stdlib/slice/ctor` );
+* var MultiSlice = require( `@stdlib/slice/multi` );
+* var typedarray = require( `@stdlib/array/typed` );
+* var ndarray = require( `@stdlib/ndarray/ctor` );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( `@stdlib/ndarray/to-array` );
+*
+* // Define an input array:
+* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint16' );
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*
+* arr = ndarray2array( y );
+* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ]
+*/
+declare function sliceAssign( x: ndarray, y: uint16ndarray, s: MultiSlice, strict: boolean ): uint16ndarray;
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* ## Notes
+*
+* - The input array must be broadcast compatible with the output array view to which elements will be assigned.
+* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array).
+*
+* @param x - input array
+* @param y - output array
+* @param s - multi-slice object for the output array
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @returns output array
+*
+* @example
+* var Slice = require( `@stdlib/slice/ctor` );
+* var MultiSlice = require( `@stdlib/slice/multi` );
+* var typedarray = require( `@stdlib/array/typed` );
+* var ndarray = require( `@stdlib/ndarray/ctor` );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( `@stdlib/ndarray/to-array` );
+*
+* // Define an input array:
+* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8' );
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*
+* arr = ndarray2array( y );
+* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ]
+*/
+declare function sliceAssign( x: ndarray, y: uint8ndarray, s: MultiSlice, strict: boolean ): uint8ndarray;
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* ## Notes
+*
+* - The input array must be broadcast compatible with the output array view to which elements will be assigned.
+* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array).
+*
+* @param x - input array
+* @param y - output array
+* @param s - multi-slice object for the output array
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @returns output array
+*
+* @example
+* var Slice = require( `@stdlib/slice/ctor` );
+* var MultiSlice = require( `@stdlib/slice/multi` );
+* var typedarray = require( `@stdlib/array/typed` );
+* var ndarray = require( `@stdlib/ndarray/ctor` );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( `@stdlib/ndarray/to-array` );
+*
+* // Define an input array:
+* var buffer = typedarray( [ 1, 2, 3, 4, 5, 6 ], 'uint8c' );
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*
+* arr = ndarray2array( y );
+* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ]
+*/
+declare function sliceAssign( x: ndarray, y: uint8cndarray, s: MultiSlice, strict: boolean ): uint8cndarray;
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* ## Notes
+*
+* - The input array must be broadcast compatible with the output array view to which elements will be assigned.
+* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array).
+*
+* @param x - input array
+* @param y - output array
+* @param s - multi-slice object for the output array
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @returns output array
+*
+* @example
+* var Slice = require( `@stdlib/slice/ctor` );
+* var MultiSlice = require( `@stdlib/slice/multi` );
+* var typedarray = require( `@stdlib/array/typed` );
+* var ndarray = require( `@stdlib/ndarray/ctor` );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( `@stdlib/ndarray/to-array` );
+*
+* // Define an input array:
+* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex128' );
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*/
+declare function sliceAssign( x: ndarray, y: complex128ndarray, s: MultiSlice, strict: boolean ): complex128ndarray;
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* ## Notes
+*
+* - The input array must be broadcast compatible with the output array view to which elements will be assigned.
+* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array).
+*
+* @param x - input array
+* @param y - output array
+* @param s - multi-slice object for the output array
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @returns output array
+*
+* @example
+* var Slice = require( `@stdlib/slice/ctor` );
+* var MultiSlice = require( `@stdlib/slice/multi` );
+* var typedarray = require( `@stdlib/array/typed` );
+* var ndarray = require( `@stdlib/ndarray/ctor` );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( `@stdlib/ndarray/to-array` );
+*
+* // Define an input array:
+* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], 'complex64' );
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*/
+declare function sliceAssign( x: ndarray, y: complex64ndarray, s: MultiSlice, strict: boolean ): complex64ndarray;
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* ## Notes
+*
+* - The input array must be broadcast compatible with the output array view to which elements will be assigned.
+* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array).
+*
+* @param x - input array
+* @param y - output array
+* @param s - multi-slice object for the output array
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @returns output array
+*
+* @example
+* var Slice = require( `@stdlib/slice/ctor` );
+* var MultiSlice = require( `@stdlib/slice/multi` );
+* var typedarray = require( `@stdlib/array/typed` );
+* var ndarray = require( `@stdlib/ndarray/ctor` );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( `@stdlib/ndarray/to-array` );
+*
+* // Define an input array:
+* var buffer = [ 1, 2, 3, 4, 5, 6 ];
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*
+* arr = ndarray2array( y );
+* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ]
+*/
+declare function sliceAssign( x: ndarray, y: genericndarray, s: MultiSlice, strict: boolean ): genericndarray;
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* ## Notes
+*
+* - The input array must be broadcast compatible with the output array view to which elements will be assigned.
+* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array).
+*
+* @param x - input array
+* @param y - output array
+* @param s - multi-slice object for the output array
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @returns output array
+*
+* @example
+* var Slice = require( `@stdlib/slice/ctor` );
+* var MultiSlice = require( `@stdlib/slice/multi` );
+* var typedarray = require( `@stdlib/array/typed` );
+* var ndarray = require( `@stdlib/ndarray/ctor` );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( `@stdlib/ndarray/to-array` );
+*
+* // Define an input array:
+* var buffer = [ 1, 2, 3, 4, 5, 6 ];
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*
+* arr = ndarray2array( y );
+* // returns [ [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ], [ [ 6, 5 ], [ 4, 3 ], [ 2, 1 ] ] ]
+*/
+declare function sliceAssign( x: ndarray, y: typedndarray, s: MultiSlice, strict: boolean ): typedndarray;
+
+
+// EXPORTS //
+
+export = sliceAssign;
diff --git a/base/slice-assign/docs/types/test.ts b/base/slice-assign/docs/types/test.ts
new file mode 100644
index 00000000..5b439cd8
--- /dev/null
+++ b/base/slice-assign/docs/types/test.ts
@@ -0,0 +1,158 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2023 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import empty = require( './../../../../base/empty' );
+import zeros = require( './../../../../zeros' );
+import MultiSlice = require( '@stdlib/slice/multi' );
+import sliceAssign = require( './index' );
+
+
+// TESTS //
+
+// The function returns an ndarray...
+{
+ const order = 'row-major';
+ const sh = [ 2, 2 ];
+ const s = new MultiSlice( null, null );
+
+ sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, false ); // $ExpectType float64ndarray
+ sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, false ); // $ExpectType float32ndarray
+ sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, false ); // $ExpectType complex128ndarray
+ sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, false ); // $ExpectType complex64ndarray
+ sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, false ); // $ExpectType int32ndarray
+ sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, false ); // $ExpectType int16ndarray
+ sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, false ); // $ExpectType int8ndarray
+ sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, false ); // $ExpectType uint32ndarray
+ sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, false ); // $ExpectType uint16ndarray
+ sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, false ); // $ExpectType uint8ndarray
+ sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, false ); // $ExpectType uint8cndarray
+
+ sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, true ); // $ExpectType float64ndarray
+ sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, true ); // $ExpectType float32ndarray
+ sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, true ); // $ExpectType complex128ndarray
+ sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, true ); // $ExpectType complex64ndarray
+ sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, true ); // $ExpectType int32ndarray
+ sliceAssign( zeros( sh ), empty( 'int16', sh, order ), s, true ); // $ExpectType int16ndarray
+ sliceAssign( zeros( sh ), empty( 'int8', sh, order ), s, true ); // $ExpectType int8ndarray
+ sliceAssign( zeros( sh ), empty( 'uint32', sh, order ), s, true ); // $ExpectType uint32ndarray
+ sliceAssign( zeros( sh ), empty( 'uint16', sh, order ), s, true ); // $ExpectType uint16ndarray
+ sliceAssign( zeros( sh ), empty( 'uint8', sh, order ), s, true ); // $ExpectType uint8ndarray
+ sliceAssign( zeros( sh ), empty( 'uint8c', sh, order ), s, true ); // $ExpectType uint8cndarray
+}
+
+// The compiler throws an error if the function is provided a first argument which is not an ndarray...
+{
+ const y = empty( 'float64', [ 2, 2 ], 'row-major' );
+ const s = new MultiSlice( null, null );
+
+ sliceAssign( '10', y, s, false ); // $ExpectError
+ sliceAssign( 10, y, s, false ); // $ExpectError
+ sliceAssign( false, y, s, false ); // $ExpectError
+ sliceAssign( true, y, s, false ); // $ExpectError
+ sliceAssign( null, y, s, false ); // $ExpectError
+ sliceAssign( [], y, s, false ); // $ExpectError
+ sliceAssign( {}, y, s, false ); // $ExpectError
+ sliceAssign( ( x: number ): number => y, y, s, false ); // $ExpectError
+
+ sliceAssign( '10', y, s, true ); // $ExpectError
+ sliceAssign( 10, y, s, true ); // $ExpectError
+ sliceAssign( false, y, s, true ); // $ExpectError
+ sliceAssign( true, y, s, true ); // $ExpectError
+ sliceAssign( null, y, s, true ); // $ExpectError
+ sliceAssign( [], y, s, true ); // $ExpectError
+ sliceAssign( {}, y, s, true ); // $ExpectError
+ sliceAssign( ( x: number ): number => x, y, s, true ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a second argument which is not an ndarray...
+{
+ const x = zeros( [ 2, 2 ] );
+ const s = new MultiSlice( null, null );
+
+ sliceAssign( x, '10', s, false ); // $ExpectError
+ sliceAssign( x, 10, s, false ); // $ExpectError
+ sliceAssign( x, false, s, false ); // $ExpectError
+ sliceAssign( x, true, s, false ); // $ExpectError
+ sliceAssign( x, null, s, false ); // $ExpectError
+ sliceAssign( x, [], s, false ); // $ExpectError
+ sliceAssign( x, {}, s, false ); // $ExpectError
+ sliceAssign( x, ( x: number ): number => x, s, false ); // $ExpectError
+
+ sliceAssign( x, '10', s, true ); // $ExpectError
+ sliceAssign( x, 10, s, true ); // $ExpectError
+ sliceAssign( x, false, s, true ); // $ExpectError
+ sliceAssign( x, true, s, true ); // $ExpectError
+ sliceAssign( x, null, s, true ); // $ExpectError
+ sliceAssign( x, [], s, true ); // $ExpectError
+ sliceAssign( x, {}, s, true ); // $ExpectError
+ sliceAssign( x, ( x: number ): number => x, s, true ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a third argument which is not a multi-slice object...
+{
+ const x = zeros( [ 2, 2 ] );
+ const y = empty( 'float64', [ 2, 2 ], 'row-major' );
+
+ sliceAssign( x, y, '5', false ); // $ExpectError
+ sliceAssign( x, y, 5, false ); // $ExpectError
+ sliceAssign( x, y, false, false ); // $ExpectError
+ sliceAssign( x, y, true, false ); // $ExpectError
+ sliceAssign( x, y, null, false ); // $ExpectError
+ sliceAssign( x, y, undefined, false ); // $ExpectError
+ sliceAssign( x, y, [ '5' ], false ); // $ExpectError
+ sliceAssign( x, y, {}, false ); // $ExpectError
+ sliceAssign( x, y, ( x: number ): number => x, false ); // $ExpectError
+
+ sliceAssign( x, y, '5', true ); // $ExpectError
+ sliceAssign( x, y, 5, true ); // $ExpectError
+ sliceAssign( x, y, false, true ); // $ExpectError
+ sliceAssign( x, y, true, true ); // $ExpectError
+ sliceAssign( x, y, null, true ); // $ExpectError
+ sliceAssign( x, y, undefined, true ); // $ExpectError
+ sliceAssign( x, y, [ '5' ], true ); // $ExpectError
+ sliceAssign( x, y, {}, true ); // $ExpectError
+ sliceAssign( x, y, ( x: number ): number => x, true ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a fourth argument which is not a boolean...
+{
+ const x = zeros( [ 2, 2 ] );
+ const y = empty( 'float64', [ 2, 2 ], 'row-major' );
+ const s = new MultiSlice( null, null );
+
+ sliceAssign( x, y, s, '5' ); // $ExpectError
+ sliceAssign( x, y, s, 5 ); // $ExpectError
+ sliceAssign( x, y, s, null ); // $ExpectError
+ sliceAssign( x, y, s, undefined ); // $ExpectError
+ sliceAssign( x, y, s, [ '5' ] ); // $ExpectError
+ sliceAssign( x, y, s, {} ); // $ExpectError
+ sliceAssign( x, y, s, ( x: number ): number => x ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ const x = zeros( [ 2, 2 ] );
+ const y = empty( 'float64', [ 2, 2 ], 'row-major' );
+ const s = new MultiSlice( null, null );
+
+ sliceAssign(); // $ExpectError
+ sliceAssign( x ); // $ExpectError
+ sliceAssign( x, y ); // $ExpectError
+ sliceAssign( x, y, s ); // $ExpectError
+ sliceAssign( x, y, s, false, {} ); // $ExpectError
+}
diff --git a/base/slice-assign/examples/index.js b/base/slice-assign/examples/index.js
new file mode 100644
index 00000000..a8da26dc
--- /dev/null
+++ b/base/slice-assign/examples/index.js
@@ -0,0 +1,95 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/* eslint-disable new-cap */
+
+'use strict';
+
+var E = require( '@stdlib/slice/multi' );
+var scalar2ndarray = require( './../../../from-scalar' );
+var ndarray2array = require( './../../../to-array' );
+var ndzeros = require( './../../../zeros' );
+var slice = require( './../../../base/slice' );
+var sliceAssign = require( './../lib' );
+
+// Alias `null` to allow for more compact indexing expressions:
+var _ = null;
+
+// Create an output ndarray:
+var y = ndzeros( [ 3, 3, 3 ] );
+
+// Update each matrix...
+var s1 = E( 0, _, _ );
+sliceAssign( scalar2ndarray( 100 ), y, s1, false );
+
+var a1 = ndarray2array( slice( y, s1, false ) );
+console.log( a1 );
+// => [ [ 100, 100, 100 ], [ 100, 100, 100 ], [ 100, 100, 100 ] ]
+
+var s2 = E( 1, _, _ );
+sliceAssign( scalar2ndarray( 200 ), y, s2, false );
+
+var a2 = ndarray2array( slice( y, s2, false ) );
+console.log( a2 );
+// => [ [ 200, 200, 200 ], [ 200, 200, 200 ], [ 200, 200, 200 ] ]
+
+var s3 = E( 2, _, _ );
+sliceAssign( scalar2ndarray( 300 ), y, s3, false );
+
+var a3 = ndarray2array( slice( y, s3, false ) );
+console.log( a3 );
+// => [ [ 300, 300, 300 ], [ 300, 300, 300 ], [ 300, 300, 300 ] ]
+
+// Update the second rows in each matrix:
+var s4 = E( _, 1, _ );
+sliceAssign( scalar2ndarray( 400 ), y, s4, false );
+
+var a4 = ndarray2array( slice( y, s4, false ) );
+console.log( a4 );
+// => [ [ 400, 400, 400 ], [ 400, 400, 400 ], [ 400, 400, 400 ] ]
+
+// Update the second columns in each matrix:
+var s5 = E( _, _, 1 );
+sliceAssign( scalar2ndarray( 500 ), y, s5, false );
+
+var a5 = ndarray2array( slice( y, s5, false ) );
+console.log( a5 );
+// => [ [ 500, 500, 500 ], [ 500, 500, 500 ], [ 500, 500, 500 ] ]
+
+// Return the contents of the entire ndarray:
+var a6 = ndarray2array( y );
+console.log( a6 );
+/* =>
+ [
+ [
+ [ 100, 500, 100 ],
+ [ 400, 500, 400 ],
+ [ 100, 500, 100 ]
+ ],
+ [
+ [ 200, 500, 200 ],
+ [ 400, 500, 400 ],
+ [ 200, 500, 200 ]
+ ],
+ [
+ [ 300, 500, 300 ],
+ [ 400, 500, 400 ],
+ [ 300, 500, 300 ]
+ ]
+ ]
+*/
diff --git a/base/slice-assign/lib/index.js b/base/slice-assign/lib/index.js
new file mode 100644
index 00000000..371d3209
--- /dev/null
+++ b/base/slice-assign/lib/index.js
@@ -0,0 +1,79 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+/**
+* Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* @module @stdlib/ndarray/base/slice-assign
+*
+* @example
+* var Slice = require( '@stdlib/slice/ctor' );
+* var MultiSlice = require( '@stdlib/slice/multi' );
+* var ndarray = require( '@stdlib/ndarray/ctor' );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( '@stdlib/ndarray/to-array' );
+* var sliceAssign = require( '@stdlib/ndarray/base/slice-assign' );
+*
+* // Define an input array:
+* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*
+* arr = ndarray2array( y );
+* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/base/slice-assign/lib/main.js b/base/slice-assign/lib/main.js
new file mode 100644
index 00000000..c734aae9
--- /dev/null
+++ b/base/slice-assign/lib/main.js
@@ -0,0 +1,139 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var isSafeCast = require( './../../../base/assert/is-safe-data-type-cast' );
+var isSameKindCast = require( './../../../base/assert/is-same-kind-data-type-cast' );
+var isFloatingPointDataType = require( './../../../base/assert/is-floating-point-data-type' );
+var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' );
+var isRealDataType = require( './../../../base/assert/is-real-data-type' );
+var broadcast = require( './../../../base/broadcast-array' );
+var unary = require( './../../../base/unary' ); // TODO: replace with `@stdlib/ndarray/base/assign` and add native add-on support
+var identity = require( '@stdlib/utils/identity-function' ); // TODO: remove once use `@stdlib/ndarray/base/assign`
+var castReturn = require( '@stdlib/complex/base/cast-return' );
+var complexCtors = require( '@stdlib/complex/ctors' );
+var slice = require( './../../../base/slice' );
+var format = require( '@stdlib/string/format' );
+
+
+// MAIN //
+
+/**
+* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.
+*
+* @param {ndarray} x - input array
+* @param {ndarray} y - output array
+* @param {MultiSlice} s - multi-slice object for the output array
+* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking
+* @throws {RangeError} number of slice dimensions must match the number of array dimensions
+* @throws {RangeError} slice exceeds array bounds
+* @throws {Error} input array must be broadcast compatible with an output array view
+* @throws {TypeError} input array cannot be safely cast to the output array data type
+* @returns {ndarray} output array
+*
+* @example
+* var Slice = require( '@stdlib/slice/ctor' );
+* var MultiSlice = require( '@stdlib/slice/multi' );
+* var ndarray = require( '@stdlib/ndarray/ctor' );
+* var ndzeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray2array = require( '@stdlib/ndarray/to-array' );
+*
+* // Define an input array:
+* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
+* var shape = [ 3, 2 ];
+* var strides = [ 2, 1 ];
+* var offset = 0;
+*
+* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
+* // returns
+*
+* var sh = x.shape;
+* // returns [ 3, 2 ]
+*
+* var arr = ndarray2array( x );
+* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
+*
+* // Define an output array:
+* var y = ndzeros( [ 2, 3, 2 ], {
+* 'dtype': x.dtype
+* });
+*
+* // Create a slice:
+* var s0 = null;
+* var s1 = new Slice( null, null, -1 );
+* var s2 = new Slice( null, null, -1 );
+* var s = new MultiSlice( s0, s1, s2 );
+* // returns
+*
+* // Perform assignment:
+* var out = sliceAssign( x, y, s, false );
+* // returns
+*
+* var bool = ( out === y );
+* // returns true
+*
+* arr = ndarray2array( y );
+* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ]
+*/
+function sliceAssign( x, y, s, strict ) {
+ var view;
+ var fcn;
+ var xdt;
+ var ydt;
+
+ xdt = x.dtype;
+ ydt = y.dtype;
+
+ // Safe casts are always allowed...
+ if ( isSafeCast( xdt, ydt ) ) {
+ // Check for real-to-complex conversion...
+ if ( isRealDataType( xdt ) && isComplexDataType( ydt ) ) {
+ // Need to cast a real number to a complex number:
+ fcn = castReturn( identity, 1, complexCtors( ydt ) );
+ } else {
+ // Should only be real->real and complex->complex:
+ fcn = identity;
+ }
+ }
+ // Allow same kind casts (i.e., downcasts) only when the output data type is floating-point...
+ else if ( isFloatingPointDataType( ydt ) && isSameKindCast( xdt, ydt ) ) {
+ // At this point, we know that the input data type and output data type are of the same "kind" (e.g., real->real and complex->complex), and, thus, we don't need to perform any special conversions:
+ fcn = identity;
+ } else {
+ throw new TypeError( format( 'invalid argument. Input array values cannot be safely cast to the output array data type. Data types: [%s, %s].', xdt, ydt ) );
+ }
+ // Resolve a mutable output array view:
+ view = slice( y, s, strict, true );
+
+ // Broadcast the input array:
+ x = broadcast( x, view.shape );
+
+ // Set elements from `x` in `y`:
+ unary( [ x, view ], fcn );
+
+ // Return the original output array:
+ return y;
+}
+
+
+// EXPORTS //
+
+module.exports = sliceAssign;
diff --git a/base/slice-assign/package.json b/base/slice-assign/package.json
new file mode 100644
index 00000000..855d8053
--- /dev/null
+++ b/base/slice-assign/package.json
@@ -0,0 +1,69 @@
+{
+ "name": "@stdlib/ndarray/base/slice-assign",
+ "version": "0.0.0",
+ "description": "Assign element values from a broadcasted input ndarray to corresponding elements in an output ndarray view.",
+ "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",
+ "data",
+ "structure",
+ "vector",
+ "ndarray",
+ "matrix",
+ "slice",
+ "view",
+ "copy",
+ "assign",
+ "assignment",
+ "setitem",
+ "set"
+ ]
+}
diff --git a/base/slice-assign/test/test.js b/base/slice-assign/test/test.js
new file mode 100644
index 00000000..67814807
--- /dev/null
+++ b/base/slice-assign/test/test.js
@@ -0,0 +1,1470 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/* eslint-disable object-curly-newline, max-len */
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
+var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' );
+var MultiSlice = require( '@stdlib/slice/multi' );
+var Slice = require( '@stdlib/slice/ctor' );
+var Complex64 = require( '@stdlib/complex/float32' );
+var Complex128 = require( '@stdlib/complex/float64' );
+var real = require( '@stdlib/complex/real' );
+var imag = require( '@stdlib/complex/imag' );
+var zeroTo = require( '@stdlib/array/base/zero-to' );
+var azeros = require( '@stdlib/array/zeros' );
+var typedarray = require( '@stdlib/array/typed' );
+var array = require( './../../../array' );
+var zeros = require( './../../../zeros' );
+var numel = require( './../../../base/numel' );
+var scalar2ndarray = require( './../../../base/from-scalar' );
+var ndarray2array = require( './../../../to-array' );
+var baseCtor = require( './../../../base/ctor' );
+var ctor = require( './../../../ctor' );
+var sliceAssign = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (strict=false)', function test( t ) {
+ var values;
+ var slices;
+ var x;
+ var i;
+
+ x = zeros( [] );
+
+ values = [
+ zeros( [] ),
+ zeros( [ 1 ] ),
+ zeros( [ 1, 1 ] ),
+ zeros( [ 1, 1, 1 ] ),
+ zeros( [ 1, 1, 1, 1 ] )
+ ];
+ slices = [
+ new MultiSlice( null ),
+ new MultiSlice( null, null, null ),
+ new MultiSlice( null ),
+ new MultiSlice( null, null ),
+ new MultiSlice( null, null, null )
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() );
+ }
+ t.end();
+
+ function badValues( y, s ) {
+ return function badValues() {
+ sliceAssign( x, y, s, false );
+ };
+ }
+});
+
+tape( 'the function throws an error if the number of slice dimensions does not match the number of output array dimensions (strict=true)', function test( t ) {
+ var values;
+ var slices;
+ var x;
+ var i;
+
+ x = zeros( [] );
+
+ values = [
+ zeros( [] ),
+ zeros( [ 1 ] ),
+ zeros( [ 1, 1 ] ),
+ zeros( [ 1, 1, 1 ] ),
+ zeros( [ 1, 1, 1, 1 ] )
+ ];
+ slices = [
+ new MultiSlice( null ),
+ new MultiSlice( null, null, null ),
+ new MultiSlice( null ),
+ new MultiSlice( null, null ),
+ new MultiSlice( null, null, null )
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() );
+ }
+ t.end();
+
+ function badValues( y, s ) {
+ return function badValues() {
+ sliceAssign( x, y, s, true );
+ };
+ }
+});
+
+tape( 'in strict mode, the function throws an error when a slice exceeds output array bounds', function test( t ) {
+ var values;
+ var slices;
+ var x;
+ var s;
+ var i;
+
+ x = zeros( [] );
+
+ values = [
+ zeros( [ 1 ] ),
+ zeros( [ 1, 1 ] ),
+ zeros( [ 1, 1, 1 ] ),
+ zeros( [ 1, 1, 1, 1 ] )
+ ];
+
+ s = new Slice( 10, 20, 1 );
+ slices = [
+ new MultiSlice( 10 ),
+ new MultiSlice( null, s ),
+ new MultiSlice( s, null, null ),
+ new MultiSlice( s, s, null, null )
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValues( values[ i ], slices[ i ] ), RangeError, 'throws an error when provided ' + slices[ i ].toString() );
+ }
+ t.end();
+
+ function badValues( y, s ) {
+ return function badValues() {
+ sliceAssign( x, y, s, true );
+ };
+ }
+});
+
+tape( 'in non-strict mode, the function does not set element values when a slice exceeds output array bounds', function test( t ) {
+ var actual;
+ var values;
+ var slices;
+ var z;
+ var x;
+ var s;
+ var v;
+ var i;
+
+ x = scalar2ndarray( 3, 'uint8', 'row-major' );
+
+ values = [
+ zeros( [ 1 ], { 'dtype': 'float64' } ),
+ zeros( [ 1, 1 ], { 'dtype': 'float32' } ),
+ zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ),
+ zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ),
+ zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } )
+ ];
+
+ s = new Slice( 10, 20, 1 );
+ slices = [
+ new MultiSlice( 10 ),
+ new MultiSlice( null, s ),
+ new MultiSlice( s, null, null ),
+ new MultiSlice( s, s, null, null ),
+ new MultiSlice( 0, null, null, null, 10 )
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ v = values[ i ];
+ actual = sliceAssign( x, v, slices[ i ], false );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( numel( actual.shape ), numel( v.shape ), 'returns expected value' );
+ t.strictEqual( actual.dtype, v.dtype, 'returns expected value' );
+
+ z = actual.iget( 0 );
+ if ( v.dtype === 'complex128' ) {
+ t.strictEqual( real( z ), 0, 'returns expected value' );
+ t.strictEqual( imag( z ), 0, 'returns expected value' );
+ } else {
+ t.strictEqual( z, 0, 'returns expected value' );
+ }
+ }
+ t.end();
+});
+
+tape( 'the function throws an error if provided an input array which is not broadcast compatible with an output array view', function test( t ) {
+ var values;
+ var slices;
+ var x;
+ var i;
+
+ x = [
+ zeros( [ 10 ] ),
+ zeros( [ 10, 10 ] ),
+ zeros( [ 10, 10, 10 ] ),
+ zeros( [ 10, 10 ] )
+ ];
+
+ values = [
+ zeros( [ 2 ] ),
+ zeros( [ 2, 2 ] ),
+ zeros( [ 2, 2, 2 ] ),
+ zeros( [ 2, 2, 2, 2 ] )
+ ];
+
+ slices = [
+ new MultiSlice( null ),
+ new MultiSlice( null, null ),
+ new MultiSlice( null, null, null ),
+ new MultiSlice( 0, 0, null, null )
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), Error, 'throws an error when provided ' + slices[ i ].toString() );
+ }
+ t.end();
+
+ function badValues( x, y, s ) {
+ return function badValues() {
+ sliceAssign( x, y, s, true );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an input array having a data type which cannot be safely cast to the data type of the output array', function test( t ) {
+ var values;
+ var slices;
+ var x;
+ var i;
+
+ x = [
+ zeros( [ 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } )
+ ];
+
+ values = [
+ zeros( [ 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2, 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ),
+ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } )
+ ];
+
+ slices = [
+ new MultiSlice( null ),
+ new MultiSlice( null, null ),
+ new MultiSlice( null, null, null ),
+ new MultiSlice( null, null, null, null )
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValues( x[ i ], values[ i ], slices[ i ] ), TypeError, 'throws an error when provided ' + slices[ i ].toString() );
+ }
+ t.end();
+
+ function badValues( x, y, s ) {
+ return function badValues() {
+ sliceAssign( x, y, s, true );
+ };
+ }
+});
+
+tape( 'the function supports assigning to a zero-dimensional array view (base)', function test( t ) {
+ var actual;
+ var x;
+ var y;
+ var s;
+
+ x = scalar2ndarray( 3.14, 'float64', 'row-major' );
+ y = scalar2ndarray( 0.0, x.dtype, x.order );
+ s = new MultiSlice();
+
+ actual = sliceAssign( x, y, s, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( actual.get(), 3.14, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports assigning to a zero-dimensional array view (base, offset)', function test( t ) {
+ var actual;
+ var x;
+ var y;
+ var s;
+
+ x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' );
+ y = new baseCtor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order );
+ s = new MultiSlice();
+
+ actual = sliceAssign( x, y, s, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( actual.get(), 3, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) {
+ var actual;
+ var x;
+ var y;
+ var s;
+
+ x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' );
+ y = new ctor( x.dtype, typedarray( zeroTo( 10 ), x.dtype ), [], [ 0 ], 7, x.order );
+ s = new MultiSlice();
+
+ actual = sliceAssign( x, y, s, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( actual.get(), 3, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base)', function test( t ) {
+ var expected;
+ var actual;
+ var values;
+ var slices;
+ var idx;
+ var x;
+ var y;
+ var s;
+ var i;
+
+ x = [
+ scalar2ndarray( 100, 'float64', 'row-major' ),
+ scalar2ndarray( 50, 'float32', 'row-major' ),
+ scalar2ndarray( 200, 'int32', 'row-major' ),
+ scalar2ndarray( 300, 'uint32', 'row-major' )
+ ];
+
+ values = [
+ array( typedarray( zeroTo( 4 ), 'float64' ), {
+ 'shape': [ 2, 2 ],
+ 'dtype': 'float64'
+ }),
+ array( typedarray( zeroTo( 8 ), 'float32' ), {
+ 'shape': [ 2, 2, 2 ],
+ 'dtype': 'float32'
+ }),
+ array( typedarray( zeroTo( 2 ), 'int32' ), {
+ 'shape': [ 2 ],
+ 'dtype': 'int32'
+ }),
+ array( typedarray( zeroTo( 16 ), 'uint32' ), {
+ 'shape': [ 2, 2, 2, 2 ],
+ 'dtype': 'uint32'
+ })
+ ];
+ idx = [
+ [ 0, 1 ],
+ [ 0, 1, 0 ],
+ [ 0 ],
+ [ 0, 1, 0, 1 ]
+ ];
+ slices = [
+ MultiSlice.apply( null, idx[ 0 ] ),
+ MultiSlice.apply( null, idx[ 1 ] ),
+ MultiSlice.apply( null, idx[ 2 ] ),
+ MultiSlice.apply( null, idx[ 3 ] )
+ ];
+ expected = [
+ 100,
+ 50,
+ 200,
+ 300
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ y = values[ i ];
+ s = slices[ i ];
+ actual = sliceAssign( x[ i ], y, s, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( actual.get.apply( actual, idx[ i ] ), expected[ i ], 'returns expected value' );
+ }
+ t.end();
+});
+
+tape( 'if all output array dimensions are reduced, the function supports assigning to a zero-dimensional array view (non-base, offset)', function test( t ) {
+ var actual;
+ var buf;
+ var ord;
+ var sh;
+ var st;
+ var dt;
+ var o;
+ var x;
+ var y;
+ var s;
+
+ ord = 'row-major';
+ dt = 'float64';
+ buf = typedarray( zeroTo( 30 ), dt );
+
+ sh = [ 6 ];
+ st = [ 2 ];
+ o = 5;
+ y = new ctor( dt, buf, sh, st, o, ord );
+ s = new MultiSlice( 1 );
+
+ x = scalar2ndarray( 3.14, dt, ord );
+
+ actual = sliceAssign( x, y, s, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( actual.get( 1 ), 3.14, 'returns expected value' );
+
+ sh = [ 3, 3 ];
+ st = [ 6, 2 ];
+ o = 10;
+ y = new ctor( dt, buf, sh, st, o, ord );
+ s = new MultiSlice( 0, 1 );
+
+ x = scalar2ndarray( 6.28, dt, ord );
+
+ actual = sliceAssign( x, y, s, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( actual.get( 0, 1 ), 6.28, 'returns expected value' );
+
+ sh = [ 2, 2, 3 ];
+ st = [ 12, 6, 2 ];
+ o = 3;
+ y = new ctor( dt, buf, sh, st, o, ord );
+ s = new MultiSlice( 1, 1, 2 );
+
+ x = scalar2ndarray( 9.52, dt, ord );
+
+ actual = sliceAssign( x, y, s, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( actual.get( 1, 1, 2 ), 9.52, 'returns expected value' );
+
+ sh = [ 2, 2, 3 ];
+ st = [ -12, -6, -2 ];
+ o = 25;
+ y = new ctor( dt, buf, sh, st, o, ord );
+ s = new MultiSlice( 1, 1, 2 );
+
+ x = scalar2ndarray( -1.0, dt, ord );
+
+ actual = sliceAssign( x, y, s, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( actual.get( 1, 1, 2 ), -1.0, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=1)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var ybuf;
+ var x;
+ var y;
+ var s;
+
+ xbuf = typedarray( zeroTo( 30 ), 'float64' );
+
+ // Full slice:
+ x = new ctor( 'float64', xbuf, [ 6 ], [ 2 ], 4, 'row-major' ); // [ 4, 6, 8, 10, 12, 14 ]
+
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( null );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [ 4, 6, 8, 10, 12, 14 ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip every other element:
+ x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 6, 'row-major' ); // [ 6, 10, 14 ]
+
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( new Slice( null, null, -2 ) );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [ 0, 14, 0, 10, 0, 6 ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip every other element, starting from second-to-last element:
+ x = new ctor( 'float64', xbuf, [ 3 ], [ 4 ], 4, 'row-major' ); // [ 4, 8, 12 ]
+
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( new Slice( 4, null, -2 ) );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [ 12, 0, 8, 0, 4, 0 ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Skip every three elements, starting from second element:
+ x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 6, 'row-major' ); // [ 6, 12 ]
+
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( new Slice( 1, null, 3 ) );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [ 0, 6, 0, 0, 12, 0 ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Set a sub-array:
+ x = new ctor( 'float64', xbuf, [ 3 ], [ 2 ], 8, 'row-major' ); // [ 8, 10, 12 ]
+
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( new Slice( 4, 1, -1 ) );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [ 0, 0, 12, 10, 8, 0 ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var ybuf;
+ var s0;
+ var s1;
+ var x;
+ var y;
+ var s;
+
+ xbuf = typedarray( zeroTo( 30 ), 'float64' );
+
+ // Full slice:
+ x = new ctor( 'float64', xbuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' ); // [ [ 4, 6, 8 ], [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ] ]
+
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( null, null );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [ 4, 6, 8 ],
+ [ 10, 12, 14 ],
+ [ 16, 18, 20 ],
+ [ 22, 24, 26 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip every other element:
+ x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 4 ], 10, 'row-major' ); // [ [ 10, 14 ], [ 22, 26 ] ]
+
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' );
+
+ s0 = new Slice( null, null, -2 );
+ s1 = new Slice( null, null, -2 );
+ s = new MultiSlice( s0, s1 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [ 0, 0, 0 ],
+ [ 26, 0, 22 ],
+ [ 0, 0, 0 ],
+ [ 14, 0, 10 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip every other row, starting from second-to-last row:
+ x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 12, 2 ], 4, 'row-major' ); // [ [ 4, 6 ], [ 16, 18 ] ]
+
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' );
+
+ s0 = new Slice( 2, null, -2 );
+ s1 = new Slice( 1, null, -1 );
+ s = new MultiSlice( s0, s1 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [ 18, 16, 0 ],
+ [ 0, 0, 0 ],
+ [ 6, 4, 0 ],
+ [ 0, 0, 0 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Set a sub-array:
+ x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 6, 2 ], 10, 'row-major' ); // [ [ 10, 12 ], [ 16, 18 ] ]
+
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' );
+
+ s0 = new Slice( 2, 0, -1 );
+ s1 = new Slice( 0, 2, 1 );
+ s = new MultiSlice( s0, s1 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [ 0, 0, 0 ],
+ [ 16, 18, 0 ],
+ [ 10, 12, 0 ],
+ [ 0, 0, 0 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=2, partial reduction)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var ybuf;
+ var s0;
+ var s1;
+ var x;
+ var y;
+ var s;
+
+ xbuf = typedarray( zeroTo( 30 ), 'float64' );
+
+ // Second column:
+ x = new ctor( 'float64', xbuf, [ 4 ], [ 6 ], 7, 'row-major' ); // [ 7, 13, 19, 25 ]
+
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' );
+
+ s = new MultiSlice( null, 1 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [ 0, 7, 0 ],
+ [ 0, 13, 0 ],
+ [ 0, 19, 0 ],
+ [ 0, 25, 0 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip every other element:
+ x = new ctor( 'float64', xbuf, [ 2 ], [ 4 ], 11, 'row-major' ); // [ 11, 15 ]
+
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' );
+
+ s0 = 1;
+ s1 = new Slice( null, null, -2 );
+ s = new MultiSlice( s0, s1 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [ 0, 0, 0 ],
+ [ 15, 0, 11 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip every other element, starting from second-to-last element:
+ x = new ctor( 'float64', xbuf, [ 2 ], [ 12 ], 9, 'row-major' ); // [ 9, 21 ]
+
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' );
+
+ s0 = new Slice( 2, null, -2 );
+ s1 = 2;
+ s = new MultiSlice( s0, s1 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [ 0, 0, 21 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 9 ],
+ [ 0, 0, 0 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Set part of a row:
+ x = new ctor( 'float64', xbuf, [ 2 ], [ 2 ], 11, 'row-major' ); // [ 11, 13 ]
+
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 5, 'row-major' );
+
+ s0 = 1;
+ s1 = new Slice( 0, 2, 1 );
+ s = new MultiSlice( s0, s1 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [ 0, 0, 0 ],
+ [ 11, 13, 0 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var ybuf;
+ var s0;
+ var s1;
+ var s2;
+ var x;
+ var y;
+ var s;
+
+ xbuf = typedarray( zeroTo( 100 ), 'float64' );
+
+ // Full slice:
+ x = new ctor( 'float64', xbuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 10, 'row-major' ); // [ [ [ 10, 12, 14 ], [ 16, 18, 20 ], [ 22, 24, 26 ], [ 28, 30, 32 ] ], [ [ 34, 36, 38 ], [ 40, 42, 44 ], [ 46, 48, 50 ], [ 52, 54, 56 ] ] ]
+
+ ybuf = azeros( 100, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( null, null, null );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [
+ [ 10, 12, 14 ],
+ [ 16, 18, 20 ],
+ [ 22, 24, 26 ],
+ [ 28, 30, 32 ]
+ ],
+ [
+ [ 34, 36, 38 ],
+ [ 40, 42, 44 ],
+ [ 46, 48, 50 ],
+ [ 52, 54, 56 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip every other element:
+ x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 4 ], 16, 'row-major' ); // [ [ [ 16, 20 ], [ 28, 32 ] ], [ [ 40, 44 ], [ 52, 56 ] ] ]
+
+ ybuf = azeros( 100, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' );
+
+ s0 = new Slice( null, null, -1 );
+ s1 = new Slice( null, null, -2 );
+ s2 = new Slice( null, null, -2 );
+ s = new MultiSlice( s0, s1, s2 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [
+ [ 0, 0, 0 ],
+ [ 56, 0, 52 ],
+ [ 0, 0, 0 ],
+ [ 44, 0, 40 ]
+ ],
+ [
+ [ 0, 0, 0 ],
+ [ 32, 0, 28 ],
+ [ 0, 0, 0 ],
+ [ 20, 0, 16 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip elements, starting from specified elements:
+ x = new ctor( 'float64', xbuf, [ 2, 2, 2 ], [ 24, 12, 2 ], 10, 'row-major' ); // [ [ [ 10, 12 ], [ 22, 24 ] ], [ [ 34, 36 ], [ 46, 48 ] ] ]
+
+ ybuf = azeros( 100, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' );
+
+ s0 = new Slice( null, null, 1 );
+ s1 = new Slice( 2, null, -2 );
+ s2 = new Slice( 1, null, -1 );
+ s = new MultiSlice( s0, s1, s2 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [
+ [ 24, 22, 0 ],
+ [ 0, 0, 0 ],
+ [ 12, 10, 0 ],
+ [ 0, 0, 0 ]
+ ],
+ [
+ [ 48, 46, 0 ],
+ [ 0, 0, 0 ],
+ [ 36, 34, 0 ],
+ [ 0, 0, 0 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Set a sub-array:
+ x = new ctor( 'float64', xbuf, [ 1, 2, 2 ], [ 24, 6, 2 ], 16, 'row-major' ); // [ [ [ 16, 118 ], [ 22, 24 ] ] ] ]
+
+ ybuf = azeros( 100, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' );
+
+ s0 = new Slice( 0, 1, 1 );
+ s1 = new Slice( 2, 0, -1 );
+ s2 = new Slice( 0, 2, 1 );
+ s = new MultiSlice( s0, s1, s2 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [
+ [ 0, 0, 0 ],
+ [ 22, 24, 0 ],
+ [ 16, 18, 0 ],
+ [ 0, 0, 0 ]
+ ],
+ [
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function assigns input array element values to corresponding elements in an output array view (ndims=3, partial reduction)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var ybuf;
+ var s0;
+ var s1;
+ var s2;
+ var x;
+ var y;
+ var s;
+
+ xbuf = typedarray( zeroTo( 100 ), 'float64' );
+
+ // Second row and second column:
+ x = new ctor( 'float64', xbuf, [ 2 ], [ 24 ], 67, 'row-major' ); // [ 67, 91 ]
+
+ ybuf = azeros( 100, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' );
+
+ s = new MultiSlice( null, 1, 1 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [
+ [ 0, 0, 0 ],
+ [ 0, 67, 0 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ]
+ ],
+ [
+ [ 0, 0, 0 ],
+ [ 0, 91, 0 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip elements:
+ x = new ctor( 'float64', xbuf, [ 2, 3 ], [ 12, 2 ], 53, 'row-major' ); // [ [ 53, 55, 57 ], [ 65, 67, 69 ] ]
+
+ ybuf = azeros( 100, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' );
+
+ s0 = 1;
+ s1 = new Slice( null, null, -2 );
+ s2 = new Slice( null, null, -1 );
+ s = new MultiSlice( s0, s1, s2 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ]
+ ],
+ [
+ [ 0, 0, 0 ],
+ [ 69, 67, 65 ],
+ [ 0, 0, 0 ],
+ [ 57, 55, 53 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip elements:
+ x = new ctor( 'float64', xbuf, [ 2, 2 ], [ 24, 4 ], 59, 'row-major' ); // [ [ 59, 63 ], [ 83, 87 ] ]
+
+ ybuf = azeros( 100, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' );
+
+ s0 = new Slice( 1, null, -1 );
+ s1 = 2;
+ s2 = new Slice( null, null, 2 );
+ s = new MultiSlice( s0, s1, s2 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ],
+ [ 83, 0, 87 ],
+ [ 0, 0, 0 ]
+ ],
+ [
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ],
+ [ 59, 0, 63 ],
+ [ 0, 0, 0 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Set part of a column:
+ x = new ctor( 'float64', xbuf, [ 2 ], [ 6 ], 65, 'row-major' ); // [ 65, 71 ]
+
+ ybuf = azeros( 100, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ -24, -6, -2 ], 99, 'row-major' );
+
+ s0 = 1;
+ s1 = new Slice( 0, 2, 1 );
+ s2 = 2;
+ s = new MultiSlice( s0, s1, s2 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ]
+ ],
+ [
+ [ 0, 0, 65 ],
+ [ 0, 0, 71 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function supports broadcasting (ndims=1)', function test( t ) {
+ var expected;
+ var actual;
+ var ybuf;
+ var x;
+ var y;
+ var s;
+
+ x = scalar2ndarray( 10.0, 'float64', 'row-major' );
+
+ // Full slice:
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( null );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [ 10, 10, 10, 10, 10, 10 ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip every other element:
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( new Slice( null, null, -2 ) );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [ 0, 10, 0, 10, 0, 10 ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip every other element, starting from second-to-last element:
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( new Slice( 4, null, -2 ) );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [ 10, 0, 10, 0, 10, 0 ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Skip every three elements, starting from second element:
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( new Slice( 1, null, 3 ) );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [ 0, 10, 0, 0, 10, 0 ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Set a sub-array:
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 6 ], [ 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( new Slice( 4, 1, -1 ) );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [ 0, 0, 10, 10, 10, 0 ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports broadcasting (ndims=2)', function test( t ) {
+ var expected;
+ var actual;
+ var ybuf;
+ var s0;
+ var s1;
+ var x;
+ var y;
+ var s;
+
+ x = scalar2ndarray( 10.0, 'float64', 'row-major' );
+
+ // Full slice:
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( null, null );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [ 10, 10, 10 ],
+ [ 10, 10, 10 ],
+ [ 10, 10, 10 ],
+ [ 10, 10, 10 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip every other element:
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' );
+
+ s0 = new Slice( null, null, -2 );
+ s1 = new Slice( null, null, -2 );
+ s = new MultiSlice( s0, s1 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [ 0, 0, 0 ],
+ [ 10, 0, 10 ],
+ [ 0, 0, 0 ],
+ [ 10, 0, 10 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip every other row, starting from second-to-last row:
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' );
+
+ s0 = new Slice( 2, null, -2 );
+ s1 = new Slice( 1, null, -1 );
+ s = new MultiSlice( s0, s1 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [ 10, 10, 0 ],
+ [ 0, 0, 0 ],
+ [ 10, 10, 0 ],
+ [ 0, 0, 0 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Set a sub-array:
+ ybuf = azeros( 30, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 4, 3 ], [ 6, 2 ], 4, 'row-major' );
+
+ s0 = new Slice( 2, 0, -1 );
+ s1 = new Slice( 0, 2, 1 );
+ s = new MultiSlice( s0, s1 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [ 0, 0, 0 ],
+ [ 10, 10, 0 ],
+ [ 10, 10, 0 ],
+ [ 0, 0, 0 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function supports broadcasting (ndims=3)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var ybuf;
+ var s0;
+ var s1;
+ var s2;
+ var x;
+ var y;
+ var s;
+
+ xbuf = typedarray( [ 10.0 ], 'float64' );
+ x = new ctor( 'float64', xbuf, [ 1, 1 ], [ 1, 1 ], 0, 'row-major' );
+
+ // Full slice:
+ ybuf = azeros( 100, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' );
+
+ s = new MultiSlice( null, null, null );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [
+ [ 10, 10, 10 ],
+ [ 10, 10, 10 ],
+ [ 10, 10, 10 ],
+ [ 10, 10, 10 ]
+ ],
+ [
+ [ 10, 10, 10 ],
+ [ 10, 10, 10 ],
+ [ 10, 10, 10 ],
+ [ 10, 10, 10 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip every other element:
+ ybuf = azeros( 100, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' );
+
+ s0 = new Slice( null, null, -1 );
+ s1 = new Slice( null, null, -2 );
+ s2 = new Slice( null, null, -2 );
+ s = new MultiSlice( s0, s1, s2 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [
+ [ 0, 0, 0 ],
+ [ 10, 0, 10 ],
+ [ 0, 0, 0 ],
+ [ 10, 0, 10 ]
+ ],
+ [
+ [ 0, 0, 0 ],
+ [ 10, 0, 10 ],
+ [ 0, 0, 0 ],
+ [ 10, 0, 10 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Reverse order and skip elements, starting from specified elements:
+ ybuf = azeros( 100, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' );
+
+ s0 = new Slice( null, null, 1 );
+ s1 = new Slice( 2, null, -2 );
+ s2 = new Slice( 1, null, -1 );
+ s = new MultiSlice( s0, s1, s2 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [
+ [ 10, 10, 0 ],
+ [ 0, 0, 0 ],
+ [ 10, 10, 0 ],
+ [ 0, 0, 0 ]
+ ],
+ [
+ [ 10, 10, 0 ],
+ [ 0, 0, 0 ],
+ [ 10, 10, 0 ],
+ [ 0, 0, 0 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ // Set a sub-array:
+ ybuf = azeros( 100, x.dtype );
+ y = new ctor( x.dtype, ybuf, [ 2, 4, 3 ], [ 24, 6, 2 ], 4, 'row-major' );
+
+ s0 = new Slice( 0, 1, 1 );
+ s1 = new Slice( 2, 0, -1 );
+ s2 = new Slice( 0, 2, 1 );
+ s = new MultiSlice( s0, s1, s2 );
+ actual = sliceAssign( x, y, s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, y, 'returns expected value' );
+
+ expected = [
+ [
+ [ 0, 0, 0 ],
+ [ 10, 10, 0 ],
+ [ 10, 10, 0 ],
+ [ 0, 0, 0 ]
+ ],
+ [
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ],
+ [ 0, 0, 0 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function supports safely casting input array elements to the data type of the output array', function test( t ) {
+ var expected;
+ var values;
+ var actual;
+ var x;
+ var s;
+ var v;
+ var e;
+ var i;
+ var j;
+
+ s = new MultiSlice( null );
+
+ x = [
+ scalar2ndarray( 10, 'float32', 'row-major' ),
+ scalar2ndarray( 10, 'int8', 'row-major' ),
+ scalar2ndarray( 10, 'uint16', 'row-major' ),
+ scalar2ndarray( 10, 'float64', 'row-major' ),
+ scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' )
+ ];
+ values = [
+ zeros( [ 2 ], { 'dtype': 'float64' } ),
+ zeros( [ 2 ], { 'dtype': 'int16' } ),
+ zeros( [ 2 ], { 'dtype': 'uint32' } ),
+ zeros( [ 2 ], { 'dtype': 'complex128' } ),
+ zeros( [ 2 ], { 'dtype': 'complex128' } )
+ ];
+ expected = [
+ [ 10, 10 ],
+ [ 10, 10 ],
+ [ 10, 10 ],
+ [ 10, 10, 10, 10 ],
+ [ 3, 5, 3, 5 ]
+ ];
+ for ( i = 0; i < expected.length; i++ ) {
+ actual = sliceAssign( x[ i ], values[ i ], s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, values[ i ], 'returns expected value' );
+
+ v = actual.data;
+ e = expected[ i ];
+ if ( isComplexDataType( actual.dtype ) ) {
+ for ( j = 0; j < v.legnth; j++ ) {
+ t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' );
+ t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' );
+ }
+ } else {
+ for ( j = 0; j < v.length; j++ ) {
+ t.strictEqual( v[ j ], e[ j ], 'returns expected value' );
+ }
+ }
+ }
+ t.end();
+});
+
+tape( 'the function supports downcasting floating-point input array elements to an output array data type of the same kind', function test( t ) {
+ var expected;
+ var values;
+ var actual;
+ var x;
+ var s;
+ var v;
+ var e;
+ var i;
+ var j;
+
+ s = new MultiSlice( null );
+
+ x = [
+ scalar2ndarray( 10, 'float64', 'row-major' ),
+ scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' )
+ ];
+ values = [
+ zeros( [ 2 ], { 'dtype': 'float32' } ),
+ zeros( [ 2 ], { 'dtype': 'complex64' } )
+ ];
+ expected = [
+ [ 10, 10 ],
+ [ 3, 5, 3, 5 ]
+ ];
+ for ( i = 0; i < expected.length; i++ ) {
+ actual = sliceAssign( x[ i ], values[ i ], s, true );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual, values[ i ], 'returns expected value' );
+
+ v = actual.data;
+ e = expected[ i ];
+ if ( isComplexDataType( actual.dtype ) ) {
+ for ( j = 0; j < v.legnth; j++ ) {
+ t.strictEqual( real( v[ j ] ), e[ j*2 ], 'returns expected value' );
+ t.strictEqual( imag( v[ j ] ), e[ (j*2)+1 ], 'returns expected value' );
+ }
+ } else {
+ for ( j = 0; j < v.length; j++ ) {
+ t.strictEqual( v[ j ], e[ j ], 'returns expected value' );
+ }
+ }
+ }
+ t.end();
+});
diff --git a/base/slice/README.md b/base/slice/README.md
index b9bf1fcf..f3eb2769 100644
--- a/base/slice/README.md
+++ b/base/slice/README.md
@@ -20,7 +20,7 @@ limitations under the License.
# slice
-> Return a read-only view of an input ndarray.
+> Return a view of an input ndarray.
@@ -40,9 +40,9 @@ limitations under the License.
var slice = require( '@stdlib/ndarray/base/slice' );
```
-#### slice( x, slice, strict )
+#### slice( x, slice, strict, mutable )
-Returns a **read-only** view of an input ndarray.
+Returns a view of an input ndarray.
```javascript
var Slice = require( '@stdlib/slice/ctor' );
@@ -69,7 +69,7 @@ var s1 = new Slice( null, null, -1 );
var s = new MultiSlice( s0, s1 );
// returns
-var y = slice( x, s, false );
+var y = slice( x, s, false, false );
// returns
sh = y.shape;
@@ -84,6 +84,7 @@ The function accepts the following arguments:
- **x**: input ndarray.
- **slice**: a [`MultiSlice`][@stdlib/slice/multi] instance.
- **strict**: boolean indicating whether to enforce strict bounds checking.
+- **mutable**: boolean indicating whether a returned ndarray should be mutable.
@@ -128,21 +129,21 @@ var x = array( buf, {
// Get each matrix...
var s1 = E( 0, _, _ );
-var y1 = slice( x, s1, false );
+var y1 = slice( x, s1, false, false );
// returns
var a1 = ndarray2array( y1 );
// returns [ [ 0, 1, 2 ], [ 3, 4, 5 ], [ 6, 7, 8 ] ]
var s2 = E( 1, _, _ );
-var y2 = slice( x, s2, false );
+var y2 = slice( x, s2, false, false );
// returns
var a2 = ndarray2array( y2 );
// returns [ [ 9, 10, 11 ], [ 12, 13, 14 ], [ 15, 16, 17 ] ]
var s3 = E( 2, _, _ );
-var y3 = slice( x, s3, false );
+var y3 = slice( x, s3, false, false );
// returns
var a3 = ndarray2array( y3 );
@@ -151,7 +152,7 @@ var a3 = ndarray2array( y3 );
// Reverse all elements:
var s = S( _, _, -1 );
var s4 = E( s, s, s );
-var y4 = slice( x, s4, false );
+var y4 = slice( x, s4, false, false );
// returns
var a4 = ndarray2array( y4 );
@@ -159,7 +160,7 @@ var a4 = ndarray2array( y4 );
// Get the second rows from each matrix:
var s5 = E( _, 1, _ );
-var y5 = slice( x, s5, false );
+var y5 = slice( x, s5, false, false );
// returns
var a5 = ndarray2array( y5 );
@@ -167,7 +168,7 @@ var a5 = ndarray2array( y5 );
// Get the second columns from each matrix:
var s6 = E( _, _, 1 );
-var y6 = slice( x, s6, false );
+var y6 = slice( x, s6, false, false );
// returns
var a6 = ndarray2array( y6 );
diff --git a/base/slice/benchmark/benchmark.js b/base/slice/benchmark/benchmark.js
index d6ef377e..72b7fb55 100644
--- a/base/slice/benchmark/benchmark.js
+++ b/base/slice/benchmark/benchmark.js
@@ -49,7 +49,7 @@ bench( pkg+'::0d,base', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -84,7 +84,7 @@ bench( pkg+'::0d,non-base', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -114,7 +114,7 @@ bench( pkg+'::1d,base', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -149,7 +149,7 @@ bench( pkg+'::1d,non-base', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -179,7 +179,7 @@ bench( pkg+'::1d,base,reduced', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -214,7 +214,7 @@ bench( pkg+'::1d,non-base,reduced', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -244,7 +244,7 @@ bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -279,7 +279,7 @@ bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -309,7 +309,7 @@ bench( pkg+'::2d,base', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -344,7 +344,7 @@ bench( pkg+'::2d,non-base', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -374,7 +374,7 @@ bench( pkg+'::2d,base,reduced', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -409,7 +409,7 @@ bench( pkg+'::2d,non-base,reduced', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -439,7 +439,7 @@ bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -474,7 +474,7 @@ bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -504,7 +504,7 @@ bench( pkg+'::3d,base', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -539,7 +539,7 @@ bench( pkg+'::3d,non-base', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -569,7 +569,7 @@ bench( pkg+'::3d,base,reduced', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -604,7 +604,7 @@ bench( pkg+'::3d,non-base,reduced', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -634,7 +634,7 @@ bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -669,7 +669,7 @@ bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -699,7 +699,7 @@ bench( pkg+'::4d,base', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -734,7 +734,7 @@ bench( pkg+'::4d,non-base', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -764,7 +764,7 @@ bench( pkg+'::4d,base,reduced', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -799,7 +799,7 @@ bench( pkg+'::4d,non-base,reduced', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -829,7 +829,7 @@ bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -864,7 +864,7 @@ bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -894,7 +894,7 @@ bench( pkg+'::5d,base', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -929,7 +929,7 @@ bench( pkg+'::5d,non-base', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -959,7 +959,7 @@ bench( pkg+'::5d,base,reduced', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -994,7 +994,7 @@ bench( pkg+'::5d,non-base,reduced', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -1024,7 +1024,7 @@ bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
@@ -1059,7 +1059,7 @@ bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
- v = slice( values[ i%values.length ], s, false );
+ v = slice( values[ i%values.length ], s, false, false );
if ( typeof v !== 'object' ) {
b.fail( 'should return an ndarray' );
}
diff --git a/base/slice/docs/repl.txt b/base/slice/docs/repl.txt
index 1ec9377e..49739574 100644
--- a/base/slice/docs/repl.txt
+++ b/base/slice/docs/repl.txt
@@ -1,6 +1,6 @@
-{{alias}}( x, slice, strict )
- Returns a read-only view of an input ndarray.
+{{alias}}( x, slice, strict, mutable )
+ Returns a view of an input ndarray.
Parameters
----------
@@ -13,6 +13,9 @@
strict: boolean
Boolean indicating whether to enforce strict bounds checking.
+ mutable: boolean
+ Boolean indicating whether a returned array should be mutable.
+
Returns
-------
out: ndarray
@@ -26,7 +29,7 @@
[ 2, 2 ]
> var s = new {{alias:@stdlib/slice/multi}}( null, 1 )
- > var y = {{alias}}( x, s, false )
+ > var y = {{alias}}( x, s, false, false )
> y.shape
[ 2 ]
diff --git a/base/slice/docs/types/index.d.ts b/base/slice/docs/types/index.d.ts
index 2e1b191e..f4728616 100644
--- a/base/slice/docs/types/index.d.ts
+++ b/base/slice/docs/types/index.d.ts
@@ -24,11 +24,12 @@ import { typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndar
import { MultiSlice } from '@stdlib/types/slice';
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param x - input array
* @param s - multi-slice object
* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param mutable - boolean indicating whether a returned array should be mutable
* @returns output array
*
* @example
@@ -55,7 +56,7 @@ import { MultiSlice } from '@stdlib/types/slice';
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
@@ -64,14 +65,15 @@ import { MultiSlice } from '@stdlib/types/slice';
* arr = ndarray2array( y );
* // returns [ [ 6.0, 5.0 ], [ 2.0, 1.0 ] ]
*/
-declare function slice( x: float64ndarray, slice: MultiSlice, strict: boolean ): float64ndarray;
+declare function slice( x: float64ndarray, s: MultiSlice, strict: boolean, mutable: boolean ): float64ndarray;
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param x - input array
* @param s - multi-slice object
* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param mutable - boolean indicating whether a returned array should be mutable
* @returns output array
*
* @example
@@ -98,7 +100,7 @@ declare function slice( x: float64ndarray, slice: MultiSlice, strict: boolean ):
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
@@ -107,14 +109,15 @@ declare function slice( x: float64ndarray, slice: MultiSlice, strict: boolean ):
* arr = ndarray2array( y );
* // returns [ [ 6.0, 5.0 ], [ 2.0, 1.0 ] ]
*/
-declare function slice( x: float32ndarray, slice: MultiSlice, strict: boolean ): float32ndarray;
+declare function slice( x: float32ndarray, s: MultiSlice, strict: boolean, mutable: boolean ): float32ndarray;
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param x - input array
* @param s - multi-slice object
* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param mutable - boolean indicating whether a returned array should be mutable
* @returns output array
*
* @example
@@ -141,7 +144,7 @@ declare function slice( x: float32ndarray, slice: MultiSlice, strict: boolean ):
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
@@ -150,14 +153,15 @@ declare function slice( x: float32ndarray, slice: MultiSlice, strict: boolean ):
* arr = ndarray2array( y );
* // returns [ [ 6, 5 ], [ 2, 1 ] ]
*/
-declare function slice( x: int32ndarray, slice: MultiSlice, strict: boolean ): int32ndarray;
+declare function slice( x: int32ndarray, s: MultiSlice, strict: boolean, mutable: boolean ): int32ndarray;
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param x - input array
* @param s - multi-slice object
* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param mutable - boolean indicating whether a returned array should be mutable
* @returns output array
*
* @example
@@ -184,7 +188,7 @@ declare function slice( x: int32ndarray, slice: MultiSlice, strict: boolean ): i
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
@@ -193,14 +197,15 @@ declare function slice( x: int32ndarray, slice: MultiSlice, strict: boolean ): i
* arr = ndarray2array( y );
* // returns [ [ 6, 5 ], [ 2, 1 ] ]
*/
-declare function slice( x: int16ndarray, slice: MultiSlice, strict: boolean ): int16ndarray;
+declare function slice( x: int16ndarray, s: MultiSlice, strict: boolean, mutable: boolean ): int16ndarray;
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param x - input array
* @param s - multi-slice object
* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param mutable - boolean indicating whether a returned array should be mutable
* @returns output array
*
* @example
@@ -227,7 +232,7 @@ declare function slice( x: int16ndarray, slice: MultiSlice, strict: boolean ): i
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
@@ -236,14 +241,15 @@ declare function slice( x: int16ndarray, slice: MultiSlice, strict: boolean ): i
* arr = ndarray2array( y );
* // returns [ [ 6, 5 ], [ 2, 1 ] ]
*/
-declare function slice( x: int8ndarray, slice: MultiSlice, strict: boolean ): int8ndarray;
+declare function slice( x: int8ndarray, s: MultiSlice, strict: boolean, mutable: boolean ): int8ndarray;
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param x - input array
* @param s - multi-slice object
* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param mutable - boolean indicating whether a returned array should be mutable
* @returns output array
*
* @example
@@ -270,7 +276,7 @@ declare function slice( x: int8ndarray, slice: MultiSlice, strict: boolean ): in
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
@@ -279,14 +285,15 @@ declare function slice( x: int8ndarray, slice: MultiSlice, strict: boolean ): in
* arr = ndarray2array( y );
* // returns [ [ 6, 5 ], [ 2, 1 ] ]
*/
-declare function slice( x: uint32ndarray, slice: MultiSlice, strict: boolean ): uint32ndarray;
+declare function slice( x: uint32ndarray, s: MultiSlice, strict: boolean, mutable: boolean ): uint32ndarray;
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param x - input array
* @param s - multi-slice object
* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param mutable - boolean indicating whether a returned array should be mutable
* @returns output array
*
* @example
@@ -313,7 +320,7 @@ declare function slice( x: uint32ndarray, slice: MultiSlice, strict: boolean ):
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
@@ -322,14 +329,15 @@ declare function slice( x: uint32ndarray, slice: MultiSlice, strict: boolean ):
* arr = ndarray2array( y );
* // returns [ [ 6, 5 ], [ 2, 1 ] ]
*/
-declare function slice( x: uint16ndarray, slice: MultiSlice, strict: boolean ): uint16ndarray;
+declare function slice( x: uint16ndarray, s: MultiSlice, strict: boolean, mutable: boolean ): uint16ndarray;
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param x - input array
* @param s - multi-slice object
* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param mutable - boolean indicating whether a returned array should be mutable
* @returns output array
*
* @example
@@ -356,7 +364,7 @@ declare function slice( x: uint16ndarray, slice: MultiSlice, strict: boolean ):
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
@@ -365,14 +373,15 @@ declare function slice( x: uint16ndarray, slice: MultiSlice, strict: boolean ):
* arr = ndarray2array( y );
* // returns [ [ 6, 5 ], [ 2, 1 ] ]
*/
-declare function slice( x: uint8ndarray, slice: MultiSlice, strict: boolean ): uint8ndarray;
+declare function slice( x: uint8ndarray, s: MultiSlice, strict: boolean, mutable: boolean ): uint8ndarray;
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param x - input array
* @param s - multi-slice object
* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param mutable - boolean indicating whether a returned array should be mutable
* @returns output array
*
* @example
@@ -399,7 +408,7 @@ declare function slice( x: uint8ndarray, slice: MultiSlice, strict: boolean ): u
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
@@ -408,14 +417,15 @@ declare function slice( x: uint8ndarray, slice: MultiSlice, strict: boolean ): u
* arr = ndarray2array( y );
* // returns [ [ 6, 5 ], [ 2, 1 ] ]
*/
-declare function slice( x: uint8cndarray, slice: MultiSlice, strict: boolean ): uint8cndarray;
+declare function slice( x: uint8cndarray, s: MultiSlice, strict: boolean, mutable: boolean ): uint8cndarray;
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param x - input array
* @param s - multi-slice object
* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param mutable - boolean indicating whether a returned array should be mutable
* @returns output array
*
* @example
@@ -439,20 +449,21 @@ declare function slice( x: uint8cndarray, slice: MultiSlice, strict: boolean ):
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
* // returns [ 2, 2 ]
*/
-declare function slice( x: complex128ndarray, slice: MultiSlice, strict: boolean ): complex128ndarray;
+declare function slice( x: complex128ndarray, s: MultiSlice, strict: boolean, mutable: boolean ): complex128ndarray;
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param x - input array
* @param s - multi-slice object
* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param mutable - boolean indicating whether a returned array should be mutable
* @returns output array
*
* @example
@@ -476,20 +487,21 @@ declare function slice( x: complex128ndarray, slice: MultiSlice, strict: boolean
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
* // returns [ 2, 2 ]
*/
-declare function slice( x: complex64ndarray, slice: MultiSlice, strict: boolean ): complex64ndarray;
+declare function slice( x: complex64ndarray, s: MultiSlice, strict: boolean, mutable: boolean ): complex64ndarray;
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param x - input array
* @param s - multi-slice object
* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param mutable - boolean indicating whether a returned array should be mutable
* @returns output array
*
* @example
@@ -516,7 +528,7 @@ declare function slice( x: complex64ndarray, slice: MultiSlice, strict: boolean
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
@@ -525,14 +537,15 @@ declare function slice( x: complex64ndarray, slice: MultiSlice, strict: boolean
* arr = ndarray2array( y );
* // returns [ [ 6, 5 ], [ 2, 1 ] ]
*/
-declare function slice( x: genericndarray, slice: MultiSlice, strict: boolean ): genericndarray;
+declare function slice( x: genericndarray, s: MultiSlice, strict: boolean, mutable: boolean ): genericndarray;
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param x - input array
* @param s - multi-slice object
* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param mutable - boolean indicating whether a returned array should be mutable
* @returns output array
*
* @example
@@ -559,7 +572,7 @@ declare function slice( x: genericndarray, slice: MultiSlice, st
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
@@ -568,7 +581,7 @@ declare function slice( x: genericndarray, slice: MultiSlice, st
* arr = ndarray2array( y );
* // returns [ [ 6, 5 ], [ 2, 1 ] ]
*/
-declare function slice( x: typedndarray, slice: MultiSlice, strict: boolean ): typedndarray;
+declare function slice( x: typedndarray, s: MultiSlice, strict: boolean, mutable: boolean ): typedndarray;
// EXPORTS //
diff --git a/base/slice/docs/types/test.ts b/base/slice/docs/types/test.ts
index 7c1bcc0c..6cef1560 100644
--- a/base/slice/docs/types/test.ts
+++ b/base/slice/docs/types/test.ts
@@ -29,77 +29,77 @@ import slice = require( './index' );
const sh = [ 2, 2 ];
const s = new MultiSlice( null, null );
- slice( empty( 'float64', sh, order ), s, false ); // $ExpectType float64ndarray
- slice( empty( 'float32', sh, order ), s, false ); // $ExpectType float32ndarray
- slice( empty( 'complex128', sh, order ), s, false ); // $ExpectType complex128ndarray
- slice( empty( 'complex64', sh, order ), s, false ); // $ExpectType complex64ndarray
- slice( empty( 'int32', sh, order ), s, false ); // $ExpectType int32ndarray
- slice( empty( 'int16', sh, order ), s, false ); // $ExpectType int16ndarray
- slice( empty( 'int8', sh, order ), s, false ); // $ExpectType int8ndarray
- slice( empty( 'uint32', sh, order ), s, false ); // $ExpectType uint32ndarray
- slice( empty( 'uint16', sh, order ), s, false ); // $ExpectType uint16ndarray
- slice( empty( 'uint8', sh, order ), s, false ); // $ExpectType uint8ndarray
- slice( empty( 'uint8c', sh, order ), s, false ); // $ExpectType uint8cndarray
-
- slice( empty( 'float64', sh, order ), s, true ); // $ExpectType float64ndarray
- slice( empty( 'float32', sh, order ), s, true ); // $ExpectType float32ndarray
- slice( empty( 'complex128', sh, order ), s, true ); // $ExpectType complex128ndarray
- slice( empty( 'complex64', sh, order ), s, true ); // $ExpectType complex64ndarray
- slice( empty( 'int32', sh, order ), s, true ); // $ExpectType int32ndarray
- slice( empty( 'int16', sh, order ), s, true ); // $ExpectType int16ndarray
- slice( empty( 'int8', sh, order ), s, true ); // $ExpectType int8ndarray
- slice( empty( 'uint32', sh, order ), s, true ); // $ExpectType uint32ndarray
- slice( empty( 'uint16', sh, order ), s, true ); // $ExpectType uint16ndarray
- slice( empty( 'uint8', sh, order ), s, true ); // $ExpectType uint8ndarray
- slice( empty( 'uint8c', sh, order ), s, true ); // $ExpectType uint8cndarray
+ slice( empty( 'float64', sh, order ), s, false, false ); // $ExpectType float64ndarray
+ slice( empty( 'float32', sh, order ), s, false, false ); // $ExpectType float32ndarray
+ slice( empty( 'complex128', sh, order ), s, false, false ); // $ExpectType complex128ndarray
+ slice( empty( 'complex64', sh, order ), s, false, false ); // $ExpectType complex64ndarray
+ slice( empty( 'int32', sh, order ), s, false, false ); // $ExpectType int32ndarray
+ slice( empty( 'int16', sh, order ), s, false, false ); // $ExpectType int16ndarray
+ slice( empty( 'int8', sh, order ), s, false, false ); // $ExpectType int8ndarray
+ slice( empty( 'uint32', sh, order ), s, false, false ); // $ExpectType uint32ndarray
+ slice( empty( 'uint16', sh, order ), s, false, false ); // $ExpectType uint16ndarray
+ slice( empty( 'uint8', sh, order ), s, false, false ); // $ExpectType uint8ndarray
+ slice( empty( 'uint8c', sh, order ), s, false, false ); // $ExpectType uint8cndarray
+
+ slice( empty( 'float64', sh, order ), s, true, true ); // $ExpectType float64ndarray
+ slice( empty( 'float32', sh, order ), s, true, true ); // $ExpectType float32ndarray
+ slice( empty( 'complex128', sh, order ), s, true, true ); // $ExpectType complex128ndarray
+ slice( empty( 'complex64', sh, order ), s, true, true ); // $ExpectType complex64ndarray
+ slice( empty( 'int32', sh, order ), s, true, true ); // $ExpectType int32ndarray
+ slice( empty( 'int16', sh, order ), s, true, true ); // $ExpectType int16ndarray
+ slice( empty( 'int8', sh, order ), s, true, true ); // $ExpectType int8ndarray
+ slice( empty( 'uint32', sh, order ), s, true, true ); // $ExpectType uint32ndarray
+ slice( empty( 'uint16', sh, order ), s, true, true ); // $ExpectType uint16ndarray
+ slice( empty( 'uint8', sh, order ), s, true, true ); // $ExpectType uint8ndarray
+ slice( empty( 'uint8c', sh, order ), s, true, true ); // $ExpectType uint8cndarray
}
// The compiler throws an error if the function is provided a first argument which is not an ndarray...
{
const s = new MultiSlice( null, null );
- slice( '10', s, false ); // $ExpectError
- slice( 10, s, false ); // $ExpectError
- slice( false, s, false ); // $ExpectError
- slice( true, s, false ); // $ExpectError
- slice( null, s, false ); // $ExpectError
- slice( [], s, false ); // $ExpectError
- slice( {}, s, false ); // $ExpectError
- slice( ( x: number ): number => x, s, false ); // $ExpectError
-
- slice( '10', s, true ); // $ExpectError
- slice( 10, s, true ); // $ExpectError
- slice( false, s, true ); // $ExpectError
- slice( true, s, true ); // $ExpectError
- slice( null, s, true ); // $ExpectError
- slice( [], s, true ); // $ExpectError
- slice( {}, s, true ); // $ExpectError
- slice( ( x: number ): number => x, s, true ); // $ExpectError
+ slice( '10', s, false, false ); // $ExpectError
+ slice( 10, s, false, false ); // $ExpectError
+ slice( false, s, false, false ); // $ExpectError
+ slice( true, s, false, false ); // $ExpectError
+ slice( null, s, false, false ); // $ExpectError
+ slice( [], s, false, false ); // $ExpectError
+ slice( {}, s, false, false ); // $ExpectError
+ slice( ( x: number ): number => x, s, false, false ); // $ExpectError
+
+ slice( '10', s, true, true ); // $ExpectError
+ slice( 10, s, true, true ); // $ExpectError
+ slice( false, s, true, true ); // $ExpectError
+ slice( true, s, true, true ); // $ExpectError
+ slice( null, s, true, true ); // $ExpectError
+ slice( [], s, true, true ); // $ExpectError
+ slice( {}, s, true, true ); // $ExpectError
+ slice( ( x: number ): number => x, s, true, true ); // $ExpectError
}
// The compiler throws an error if the function is provided a second argument which is not a multi-slice object...
{
const x = empty( 'float64', [ 2, 2 ], 'row-major' );
- slice( x, '5', false ); // $ExpectError
- slice( x, 5, false ); // $ExpectError
- slice( x, false, false ); // $ExpectError
- slice( x, true, false ); // $ExpectError
- slice( x, null, false ); // $ExpectError
- slice( x, undefined, false ); // $ExpectError
- slice( x, [ '5' ], false ); // $ExpectError
- slice( x, {}, false ); // $ExpectError
- slice( x, ( x: number ): number => x, false ); // $ExpectError
-
- slice( x, '5', true ); // $ExpectError
- slice( x, 5, true ); // $ExpectError
- slice( x, false, true ); // $ExpectError
- slice( x, true, true ); // $ExpectError
- slice( x, null, true ); // $ExpectError
- slice( x, undefined, true ); // $ExpectError
- slice( x, [ '5' ], true ); // $ExpectError
- slice( x, {}, true ); // $ExpectError
- slice( x, ( x: number ): number => x, true ); // $ExpectError
+ slice( x, '5', false, false ); // $ExpectError
+ slice( x, 5, false, false ); // $ExpectError
+ slice( x, false, false, false ); // $ExpectError
+ slice( x, true, false, false ); // $ExpectError
+ slice( x, null, false, false ); // $ExpectError
+ slice( x, undefined, false, false ); // $ExpectError
+ slice( x, [ '5' ], false, false ); // $ExpectError
+ slice( x, {}, false, false ); // $ExpectError
+ slice( x, ( x: number ): number => x, false, false ); // $ExpectError
+
+ slice( x, '5', true, true ); // $ExpectError
+ slice( x, 5, true, true ); // $ExpectError
+ slice( x, false, true, true ); // $ExpectError
+ slice( x, true, true, true ); // $ExpectError
+ slice( x, null, true, true ); // $ExpectError
+ slice( x, undefined, true, true ); // $ExpectError
+ slice( x, [ '5' ], true, true ); // $ExpectError
+ slice( x, {}, true, true ); // $ExpectError
+ slice( x, ( x: number ): number => x, true, true ); // $ExpectError
}
// The compiler throws an error if the function is provided a third argument which is not a boolean...
@@ -107,13 +107,27 @@ import slice = require( './index' );
const x = empty( 'float64', [ 2, 2 ], 'row-major' );
const s = new MultiSlice( null, null );
- slice( x, s, '5' ); // $ExpectError
- slice( x, s, 5 ); // $ExpectError
- slice( x, s, null ); // $ExpectError
- slice( x, s, undefined ); // $ExpectError
- slice( x, s, [ '5' ] ); // $ExpectError
- slice( x, s, {} ); // $ExpectError
- slice( x, s, ( x: number ): number => x ); // $ExpectError
+ slice( x, s, '5', false ); // $ExpectError
+ slice( x, s, 5, false ); // $ExpectError
+ slice( x, s, null, false ); // $ExpectError
+ slice( x, s, undefined, false ); // $ExpectError
+ slice( x, s, [ '5' ], false ); // $ExpectError
+ slice( x, s, {}, false ); // $ExpectError
+ slice( x, s, ( x: number ): number => x, false ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a fourth argument which is not a boolean...
+{
+ const x = empty( 'float64', [ 2, 2 ], 'row-major' );
+ const s = new MultiSlice( null, null );
+
+ slice( x, s, false, '5' ); // $ExpectError
+ slice( x, s, false, 5 ); // $ExpectError
+ slice( x, s, false, null ); // $ExpectError
+ slice( x, s, false, undefined ); // $ExpectError
+ slice( x, s, false, [ '5' ] ); // $ExpectError
+ slice( x, s, false, {} ); // $ExpectError
+ slice( x, s, false, ( x: number ): number => x ); // $ExpectError
}
// The compiler throws an error if the function is provided an unsupported number of arguments...
@@ -123,5 +137,6 @@ import slice = require( './index' );
slice( x ); // $ExpectError
slice( x, s ); // $ExpectError
- slice( x, s, false, {} ); // $ExpectError
+ slice( x, s, false ); // $ExpectError
+ slice( x, s, false, false, {} ); // $ExpectError
}
diff --git a/base/slice/examples/index.js b/base/slice/examples/index.js
index b82eaee7..8d5700d2 100644
--- a/base/slice/examples/index.js
+++ b/base/slice/examples/index.js
@@ -40,7 +40,7 @@ var x = array( buf, {
// Get each matrix...
var s1 = E( 0, _, _ );
-var y1 = slice( x, s1, false );
+var y1 = slice( x, s1, false, false );
// returns
var a1 = ndarray2array( y1 );
@@ -48,7 +48,7 @@ console.log( a1 );
// => [ [ 0, 1, 2 ], [ 3, 4, 5 ], [ 6, 7, 8 ] ]
var s2 = E( 1, _, _ );
-var y2 = slice( x, s2, false );
+var y2 = slice( x, s2, false, false );
// returns
var a2 = ndarray2array( y2 );
@@ -56,7 +56,7 @@ console.log( a2 );
// => [ [ 9, 10, 11 ], [ 12, 13, 14 ], [ 15, 16, 17 ] ]
var s3 = E( 2, _, _ );
-var y3 = slice( x, s3, false );
+var y3 = slice( x, s3, false, false );
// returns
var a3 = ndarray2array( y3 );
@@ -66,7 +66,7 @@ console.log( a3 );
// Reverse all elements:
var s = S( _, _, -1 );
var s4 = E( s, s, s );
-var y4 = slice( x, s4, false );
+var y4 = slice( x, s4, false, false );
// returns
var a4 = ndarray2array( y4 );
@@ -75,7 +75,7 @@ console.log( a4 );
// Get the second rows from each matrix:
var s5 = E( _, 1, _ );
-var y5 = slice( x, s5, false );
+var y5 = slice( x, s5, false, false );
// returns
var a5 = ndarray2array( y5 );
@@ -84,7 +84,7 @@ console.log( a5 );
// Get the second columns from each matrix:
var s6 = E( _, _, 1 );
-var y6 = slice( x, s6, false );
+var y6 = slice( x, s6, false, false );
// returns
var a6 = ndarray2array( y6 );
diff --git a/base/slice/lib/empty.js b/base/slice/lib/empty.js
index 15c125cc..ab6f5b0f 100644
--- a/base/slice/lib/empty.js
+++ b/base/slice/lib/empty.js
@@ -22,7 +22,6 @@
var buffer = require( './../../../base/buffer' );
var zeros = require( '@stdlib/array/base/zeros' );
-var options = require( './options.js' );
// MAIN //
@@ -35,9 +34,10 @@ var options = require( './options.js' );
* @param {string} dtype - array data type
* @param {NonNegativeIntegerArray} shape - array shape
* @param {string} order - layout order
+* @param {boolean} readonly - boolean indicating whether a returned array should be read-only
* @returns {ndarray} empty ndarray
*/
-function empty( ctor, dtype, shape, order ) {
+function empty( ctor, dtype, shape, order, readonly ) {
var strides;
var ndims;
@@ -47,7 +47,9 @@ function empty( ctor, dtype, shape, order ) {
} else {
strides = zeros( ndims );
}
- return new ctor( dtype, buffer( dtype, 0 ), shape, strides, 0, order, options() ); // eslint-disable-line max-len
+ return new ctor( dtype, buffer( dtype, 0 ), shape, strides, 0, order, {
+ 'readonly': readonly
+ });
}
diff --git a/base/slice/lib/index.js b/base/slice/lib/index.js
index 6c78dde1..c3ed124e 100644
--- a/base/slice/lib/index.js
+++ b/base/slice/lib/index.js
@@ -19,7 +19,7 @@
'use strict';
/**
-* Return a read-only view of an input ndarray.
+* Return a view of an input ndarray.
*
* @module @stdlib/ndarray/base/slice
*
@@ -47,7 +47,7 @@
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
diff --git a/base/slice/lib/main.js b/base/slice/lib/main.js
index 2895cf35..74317bd3 100644
--- a/base/slice/lib/main.js
+++ b/base/slice/lib/main.js
@@ -29,18 +29,18 @@ var numel = require( './../../../base/numel' );
var format = require( '@stdlib/string/format' );
var sliceStart = require( './slice_start.js' );
var slice2strides = require( './slice_strides.js' );
-var options = require( './options.js' );
var empty = require( './empty.js' );
// MAIN //
/**
-* Returns a read-only view of an input ndarray.
+* Returns a view of an input ndarray.
*
* @param {ndarray} x - input array
* @param {MultiSlice} s - multi-slice object
* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking
+* @param {boolean} mutable - boolean indicating whether a returned array should be mutable
* @throws {RangeError} number of slice dimensions must match the number of array dimensions
* @throws {RangeError} slice exceeds array bounds
* @returns {ndarray} ndarray view
@@ -68,7 +68,7 @@ var empty = require( './empty.js' );
* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
* // returns
*
-* var y = slice( x, s, false );
+* var y = slice( x, s, false, false );
* // returns
*
* sh = y.shape;
@@ -77,7 +77,7 @@ var empty = require( './empty.js' );
* arr = ndarray2array( y );
* // returns [ [ 6.0, 5.0 ], [ 2.0, 1.0 ] ]
*/
-function slice( x, s, strict ) {
+function slice( x, s, strict, mutable ) {
var strides;
var offset;
var dtype;
@@ -106,7 +106,9 @@ function slice( x, s, strict ) {
// If provided a zero-dimensional input array, return a zero-dimensional array view...
if ( ndims === 0 ) {
- return new ctor( dtype, x.data, shape, strides, offset, order, options() ); // eslint-disable-line max-len
+ return new ctor( dtype, x.data, shape, strides, offset, order, {
+ 'readonly': !mutable
+ });
}
// Resolve the indices of the non-reduced dimensions:
sdims = nonreducedDimensions( s );
@@ -135,7 +137,7 @@ function slice( x, s, strict ) {
}
// If the slice does not contain any elements, return an empty array...
if ( numel( sh ) === 0 ) {
- return empty( ctor, dtype, take( sh, sdims ), order );
+ return empty( ctor, dtype, take( sh, sdims ), order, !mutable );
}
// Resolve the index offset of the first element indexed by the slice:
offset = sliceStart( ns, strides, offset ); // TODO: @stdlib/ndarray/base/sind2bind
@@ -145,13 +147,17 @@ function slice( x, s, strict ) {
// If all dimensions were reduced, return a zero-dimensional array...
if ( sh.length === 0 ) {
- return new ctor( dtype, x.data, [], [ 0 ], offset, order, options() );
+ return new ctor( dtype, x.data, [], [ 0 ], offset, order, {
+ 'readonly': !mutable
+ });
}
// Update strides according to slice steps:
strides = slice2strides( ns, strides, sdims ); // TODO: @stdlib/ndarray/base/slice2strides???
// Return a slice view:
- return new ctor( dtype, x.data, sh, strides, offset, order, options() );
+ return new ctor( dtype, x.data, sh, strides, offset, order, {
+ 'readonly': !mutable
+ });
}
diff --git a/base/slice/package.json b/base/slice/package.json
index 05c21cb7..c71431b1 100644
--- a/base/slice/package.json
+++ b/base/slice/package.json
@@ -1,7 +1,7 @@
{
"name": "@stdlib/ndarray/base/slice",
"version": "0.0.0",
- "description": "Return a read-only view of an input ndarray.",
+ "description": "Return a view of an input ndarray.",
"license": "Apache-2.0",
"author": {
"name": "The Stdlib Authors",
diff --git a/base/slice/test/test.js b/base/slice/test/test.js
index d7745215..45d3e1af 100644
--- a/base/slice/test/test.js
+++ b/base/slice/test/test.js
@@ -73,7 +73,7 @@ tape( 'the function throws an error if the number of slice dimensions does not m
function badValues( x, s ) {
return function badValues() {
- slice( x, s, false );
+ slice( x, s, false, false );
};
}
});
@@ -104,7 +104,7 @@ tape( 'the function throws an error if the number of slice dimensions does not m
function badValues( x, s ) {
return function badValues() {
- slice( x, s, true );
+ slice( x, s, true, false );
};
}
});
@@ -136,7 +136,7 @@ tape( 'in strict mode, the function throws an error when a slice exceeds array b
function badValues( x, s ) {
return function badValues() {
- slice( x, s, true );
+ slice( x, s, true, false );
};
}
});
@@ -165,7 +165,7 @@ tape( 'in non-strict mode, the function returns an empty array when a slice exce
new MultiSlice( 0, null, null, null, 10 )
];
for ( i = 0; i < values.length; i++ ) {
- actual = slice( values[ i ], slices[ i ], false );
+ actual = slice( values[ i ], slices[ i ], false, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( numel( actual.shape ), 0, 'returns expected value' );
t.strictEqual( actual.dtype, values[ i ].dtype, 'returns expected value' );
@@ -181,7 +181,7 @@ tape( 'when provided a zero-dimensional input array, the function returns a zero
x = scalar2ndarray( 3.14, 'float64', 'row-major' );
s = new MultiSlice();
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 0, 'returns expected value' );
t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
@@ -199,7 +199,7 @@ tape( 'when provided a zero-dimensional input array, the function returns a zero
x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' );
s = new MultiSlice();
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 0, 'returns expected value' );
t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
@@ -209,7 +209,7 @@ tape( 'when provided a zero-dimensional input array, the function returns a zero
t.end();
});
-tape( 'when provided a zero-dimensional input array, the function returns a zero-dimensional array view (non-base, offset)', function test( t ) {
+tape( 'when provided a zero-dimensional input array, the function returns a zero-dimensional array view (non-base, offset, read-only)', function test( t ) {
var actual;
var x;
var s;
@@ -217,7 +217,7 @@ tape( 'when provided a zero-dimensional input array, the function returns a zero
x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' );
s = new MultiSlice();
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 0, 'returns expected value' );
t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
@@ -228,7 +228,26 @@ tape( 'when provided a zero-dimensional input array, the function returns a zero
t.end();
});
-tape( 'if all dimensions are reduced, the function returns a zero-dimensional array view (non-base)', function test( t ) {
+tape( 'when provided a zero-dimensional input array, the function returns a zero-dimensional array view (non-base, offset, mutable)', function test( t ) {
+ var actual;
+ var x;
+ var s;
+
+ x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' );
+ s = new MultiSlice();
+
+ actual = slice( x, s, true, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 0, 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.get(), 3, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+ t.strictEqual( isReadOnly( actual ), false, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'if all dimensions are reduced, the function returns a zero-dimensional array view (non-base, read-only)', function test( t ) {
var expected;
var actual;
var values;
@@ -270,7 +289,7 @@ tape( 'if all dimensions are reduced, the function returns a zero-dimensional ar
for ( i = 0; i < values.length; i++ ) {
x = values[ i ];
s = slices[ i ];
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
t.strictEqual( actual.ndims, 0, 'returns expected value' );
@@ -281,7 +300,60 @@ tape( 'if all dimensions are reduced, the function returns a zero-dimensional ar
t.end();
});
-tape( 'if all dimensions are reduced, the function returns a zero-dimensional array view (non-base, offset)', function test( t ) {
+tape( 'if all dimensions are reduced, the function returns a zero-dimensional array view (non-base, mutable)', function test( t ) {
+ var expected;
+ var actual;
+ var values;
+ var slices;
+ var x;
+ var s;
+ var i;
+
+ values = [
+ array( typedarray( zeroTo( 4 ), 'float64' ), {
+ 'shape': [ 2, 2 ],
+ 'dtype': 'float64'
+ }),
+ array( typedarray( zeroTo( 8 ), 'float32' ), {
+ 'shape': [ 2, 2, 2 ],
+ 'dtype': 'float32'
+ }),
+ array( typedarray( zeroTo( 2 ), 'int32' ), {
+ 'shape': [ 2 ],
+ 'dtype': 'int32'
+ }),
+ array( typedarray( zeroTo( 16 ), 'uint32' ), {
+ 'shape': [ 2, 2, 2, 2 ],
+ 'dtype': 'uint32'
+ })
+ ];
+ slices = [
+ new MultiSlice( 0, 1 ),
+ new MultiSlice( 0, 1, 0 ),
+ new MultiSlice( 0 ),
+ new MultiSlice( 0, 1, 0, 1 )
+ ];
+ expected = [
+ 1,
+ 2,
+ 0,
+ 5
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ x = values[ i ];
+ s = slices[ i ];
+ actual = slice( x, s, true, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.ndims, 0, 'returns expected value' );
+ t.strictEqual( actual.get(), expected[ i ], 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+ t.strictEqual( isReadOnly( actual ), false, 'returns expected value' );
+ }
+ t.end();
+});
+
+tape( 'if all dimensions are reduced, the function returns a zero-dimensional array view (non-base, offset, read-only)', function test( t ) {
var actual;
var buf;
var ord;
@@ -302,7 +374,7 @@ tape( 'if all dimensions are reduced, the function returns a zero-dimensional ar
x = new ctor( dt, buf, sh, st, o, ord );
s = new MultiSlice( 1 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
t.strictEqual( actual.ndims, 0, 'returns expected value' );
@@ -316,7 +388,7 @@ tape( 'if all dimensions are reduced, the function returns a zero-dimensional ar
x = new ctor( dt, buf, sh, st, o, ord );
s = new MultiSlice( 0, 1 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
t.strictEqual( actual.ndims, 0, 'returns expected value' );
@@ -330,7 +402,7 @@ tape( 'if all dimensions are reduced, the function returns a zero-dimensional ar
x = new ctor( dt, buf, sh, st, o, ord );
s = new MultiSlice( 1, 1, 2 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
t.strictEqual( actual.ndims, 0, 'returns expected value' );
@@ -344,7 +416,7 @@ tape( 'if all dimensions are reduced, the function returns a zero-dimensional ar
x = new ctor( dt, buf, sh, st, o, ord );
s = new MultiSlice( 1, 1, 2 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
t.strictEqual( actual.ndims, 0, 'returns expected value' );
@@ -355,6 +427,80 @@ tape( 'if all dimensions are reduced, the function returns a zero-dimensional ar
t.end();
});
+tape( 'if all dimensions are reduced, the function returns a zero-dimensional array view (non-base, offset, mutable)', function test( t ) {
+ var actual;
+ var buf;
+ var ord;
+ var sh;
+ var st;
+ var dt;
+ var o;
+ var x;
+ var s;
+
+ ord = 'row-major';
+ dt = 'float64';
+ buf = typedarray( zeroTo( 30 ), dt );
+
+ sh = [ 6 ];
+ st = [ 2 ];
+ o = 5;
+ x = new ctor( dt, buf, sh, st, o, ord );
+ s = new MultiSlice( 1 );
+
+ actual = slice( x, s, true, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.ndims, 0, 'returns expected value' );
+ t.strictEqual( actual.get(), 7, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+ t.strictEqual( isReadOnly( actual ), false, 'returns expected value' );
+
+ sh = [ 3, 3 ];
+ st = [ 6, 2 ];
+ o = 10;
+ x = new ctor( dt, buf, sh, st, o, ord );
+ s = new MultiSlice( 0, 1 );
+
+ actual = slice( x, s, true, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.ndims, 0, 'returns expected value' );
+ t.strictEqual( actual.get(), 12, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+ t.strictEqual( isReadOnly( actual ), false, 'returns expected value' );
+
+ sh = [ 2, 2, 3 ];
+ st = [ 12, 6, 2 ];
+ o = 3;
+ x = new ctor( dt, buf, sh, st, o, ord );
+ s = new MultiSlice( 1, 1, 2 );
+
+ actual = slice( x, s, true, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.ndims, 0, 'returns expected value' );
+ t.strictEqual( actual.get(), 25, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+ t.strictEqual( isReadOnly( actual ), false, 'returns expected value' );
+
+ sh = [ 2, 2, 3 ];
+ st = [ -12, -6, -2 ];
+ o = 25;
+ x = new ctor( dt, buf, sh, st, o, ord );
+ s = new MultiSlice( 1, 1, 2 );
+
+ actual = slice( x, s, true, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.ndims, 0, 'returns expected value' );
+ t.strictEqual( actual.get(), 3, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+ t.strictEqual( isReadOnly( actual ), false, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function returns a view of a provided input array (ndims=1)', function test( t ) {
var expected;
var actual;
@@ -376,7 +522,7 @@ tape( 'the function returns a view of a provided input array (ndims=1)', functio
x = new ctor( 'float64', buf, sh, st, o, ord );
s = new MultiSlice( null );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
@@ -391,7 +537,7 @@ tape( 'the function returns a view of a provided input array (ndims=1)', functio
// Reverse order and skip every other element:
s = new MultiSlice( new Slice( null, null, -2 ) );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
@@ -406,7 +552,7 @@ tape( 'the function returns a view of a provided input array (ndims=1)', functio
// Reverse order and skip every other element, starting from second-to-last element:
s = new MultiSlice( new Slice( 4, null, -2 ) );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
@@ -421,7 +567,7 @@ tape( 'the function returns a view of a provided input array (ndims=1)', functio
// Skip every three elements, starting from second element:
s = new MultiSlice( new Slice( 1, null, 3 ) );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
@@ -436,7 +582,7 @@ tape( 'the function returns a view of a provided input array (ndims=1)', functio
// Get a sub-array:
s = new MultiSlice( new Slice( 4, 1, -1 ) );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
@@ -473,7 +619,7 @@ tape( 'the function returns a view of a provided input array (ndims=2)', functio
x = new ctor( 'float64', buf, sh, st, o, ord );
s = new MultiSlice( null, null );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 2, 'returns expected value' );
@@ -494,7 +640,7 @@ tape( 'the function returns a view of a provided input array (ndims=2)', functio
s0 = new Slice( null, null, -2 );
s1 = new Slice( null, null, -2 );
s = new MultiSlice( s0, s1 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 2, 'returns expected value' );
@@ -513,7 +659,7 @@ tape( 'the function returns a view of a provided input array (ndims=2)', functio
s0 = new Slice( 2, null, -2 );
s1 = new Slice( 1, null, -1 );
s = new MultiSlice( s0, s1 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 2, 'returns expected value' );
@@ -532,7 +678,7 @@ tape( 'the function returns a view of a provided input array (ndims=2)', functio
s0 = new Slice( 2, 0, -1 );
s1 = new Slice( 0, 2, 1 );
s = new MultiSlice( s0, s1 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 2, 'returns expected value' );
@@ -571,7 +717,7 @@ tape( 'the function returns a view of a provided input array (ndims=2, partial r
x = new ctor( 'float64', buf, sh, st, o, ord );
s = new MultiSlice( null, 1 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
@@ -587,7 +733,7 @@ tape( 'the function returns a view of a provided input array (ndims=2, partial r
s0 = 1;
s1 = new Slice( null, null, -2 );
s = new MultiSlice( s0, s1 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
@@ -603,7 +749,7 @@ tape( 'the function returns a view of a provided input array (ndims=2, partial r
s0 = new Slice( 2, null, -2 );
s1 = 2;
s = new MultiSlice( s0, s1 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
@@ -619,7 +765,7 @@ tape( 'the function returns a view of a provided input array (ndims=2, partial r
s0 = 1;
s1 = new Slice( 0, 2, 1 );
s = new MultiSlice( s0, s1 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
@@ -656,7 +802,7 @@ tape( 'the function returns a view of a provided input array (ndims=3)', functio
x = new ctor( 'float64', buf, sh, st, o, ord );
s = new MultiSlice( null, null, null );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 3, 'returns expected value' );
@@ -686,7 +832,7 @@ tape( 'the function returns a view of a provided input array (ndims=3)', functio
s1 = new Slice( null, null, -2 );
s2 = new Slice( null, null, -2 );
s = new MultiSlice( s0, s1, s2 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 3, 'returns expected value' );
@@ -712,7 +858,7 @@ tape( 'the function returns a view of a provided input array (ndims=3)', functio
s1 = new Slice( 2, null, -2 );
s2 = new Slice( 1, null, -1 );
s = new MultiSlice( s0, s1, s2 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 3, 'returns expected value' );
@@ -738,7 +884,7 @@ tape( 'the function returns a view of a provided input array (ndims=3)', functio
s1 = new Slice( 2, 0, -1 );
s2 = new Slice( 0, 2, 1 );
s = new MultiSlice( s0, s1, s2 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 3, 'returns expected value' );
@@ -780,7 +926,7 @@ tape( 'the function returns a view of a provided input array (ndims=3, partial r
x = new ctor( 'float64', buf, sh, st, o, ord );
s = new MultiSlice( null, 1, 1 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
@@ -797,7 +943,7 @@ tape( 'the function returns a view of a provided input array (ndims=3, partial r
s1 = new Slice( null, null, -2 );
s2 = new Slice( null, null, -1 );
s = new MultiSlice( s0, s1, s2 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 2, 'returns expected value' );
@@ -817,7 +963,7 @@ tape( 'the function returns a view of a provided input array (ndims=3, partial r
s1 = 2;
s2 = new Slice( null, null, 2 );
s = new MultiSlice( s0, s1, s2 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 2, 'returns expected value' );
@@ -837,7 +983,7 @@ tape( 'the function returns a view of a provided input array (ndims=3, partial r
s1 = new Slice( 0, 2, 1 );
s2 = 2;
s = new MultiSlice( s0, s1, s2 );
- actual = slice( x, s, true );
+ actual = slice( x, s, true, false );
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
t.strictEqual( actual.ndims, 1, 'returns expected value' );
diff --git a/dist/index.js b/dist/index.js
index 498ac439..4644f23f 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1,4 +1,4 @@
-"use strict";var C=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var Ii=C(function(qR,Oi){"use strict";function Ym(r){var e,a,i,t;for(e=r.length,a=[],t=0;t=0;t--)a[t]=i,i*=r[t];return a}function Km(r){var e,a,i;for(e=[],a=1,i=0;i=0;t--)e[t]=i,i*=r[t];return e}function Jm(r,e){var a,i;for(a=1,i=0;it&&(i=!1),i||e)t=v;else return 0;return i&&e?3:i?1:2}Di.exports=rx});var Te=C(function(_R,Mi){"use strict";var ex=Pi();Mi.exports=ex});var Vi=C(function(ER,Bi){"use strict";function ax(r){var e,a,i;if(e=r.length,e===0)return 0;for(a=1,i=0;i0?v+=n*(r[s]-1):n<0&&(t+=n*(r[s]-1))}return[t,v]}cv.exports=Ex});var mv=C(function(UR,pv){"use strict";function Ox(r,e,a,i){var t,v,n,s,u;for(t=r.length,v=a,n=a,u=0;u0?n+=s*(r[u]-1):s<0&&(v+=s*(r[u]-1))}return i[0]=v,i[1]=n,i}pv.exports=Ox});var ne=C(function(FR,hv){"use strict";var Ix=require("@stdlib/utils/define-nonenumerable-read-only-property"),xv=yv(),Tx=mv();Ix(xv,"assign",Tx);hv.exports=xv});var gv=C(function(YR,qv){"use strict";var kx=ne();function Ax(r,e,a,i){var t=kx(e,a,i);return t[0]>=0&&t[1]=0;n--)v=r%a[n],r-=v,r/=a[n],t+=v*e[n];return this._accessors?this._buffer.get(t):this._buffer[t]}Dv.exports=Yx});var Bv=C(function(aN,Mv){"use strict";function Kx(r,e){var a,i,t,v,n,s;if(t=this._ndims,t===0)return this._accessors?this._buffer.set(r,this._offset):this._buffer[this._offset]=r,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(e,this._offset+r):this._buffer[this._offset+r]=e,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(e,this._offset-r):this._buffer[this._offset-r]=e,this}if(i=this._shape,a=this._strides,v=this._offset,this._order==="column-major"){for(s=0;s=0;s--)n=r%i[s],r-=n,r/=i[s],v+=n*a[s];return this._accessors?this._buffer.set(e,v):this._buffer[v]=e,this}Mv.exports=Kx});var Uv=C(function(iN,Vv){"use strict";function Gx(){var r,e;for(r=this._offset,e=0;e=0;n--)v=this.iget(this._length-1-n),r+=Ea(v)+", "+Oa(v),n>0&&(r+=", ");else for(n=2;n>=0;n--)r+=this.iget(this._length-1-n),n>0&&(r+=", ")}if(a=Hx[this.dtype],i+=Wx(a,"{{data}}",r),i+=", ",e===0?i+="[]":i+="[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",e===0)i+="0";else for(n=0;ne?e:r}mt.exports=Z3});var ka=C(function(qN,ht){"use strict";var J3=xt();ht.exports=J3});var gt=C(function(gN,qt){"use strict";function X3(r,e){var a=e+1;return r<0?(r+=a,r<0&&(r%=a,r!==0&&(r+=a)),r):(r>e&&(r-=a,r>e&&(r%=a)),r)}qt.exports=X3});var Aa=C(function(bN,bt){"use strict";var Q3=gt();bt.exports=Q3});var wt=C(function(SN,St){"use strict";var W3=ka(),H3=Aa(),$3=require("@stdlib/string/format");function r4(r,e,a){if(a==="clamp")return W3(r,e);if(a==="wrap")return H3(r,e);if(r<0||r>e)throw new RangeError($3("invalid argument. Index must be on the interval: [0, %d]. Value: `%d`.",e,r));return r}St.exports=r4});var ge=C(function(wN,jt){"use strict";var e4=wt();jt.exports=e4});var Ot=C(function(jN,Et){"use strict";var a4=require("@stdlib/assert/is-integer").isPrimitive,i4=ge(),v4=$r(),t4=require("@stdlib/string/format"),_t=v4.prototype.iget;function s4(r){if(this._ndims>0){if(!a4(r))throw new TypeError(t4("invalid argument. Index must be an integer. Value: `%s`.",r));return r=i4(r,this._length-1,this._mode),_t.call(this,r)}return _t.call(this)}Et.exports=s4});var kt=C(function(_N,Tt){"use strict";var o4=require("@stdlib/assert/is-integer").isPrimitive,n4=ge(),u4=$r(),f4=require("@stdlib/string/format"),It=u4.prototype.iset;function d4(r,e){if(this._flags.READONLY)throw new Error("invalid invocation. Cannot write to a read-only array.");if(this._ndims>0){if(!o4(r))throw new TypeError(f4("invalid argument. Index must be an integer. Value: `%s`.",r));r=n4(r,this._length-1,this._mode),It.call(this,r,e)}else It.call(this,r);return this}Tt.exports=d4});var Nt=C(function(EN,Rt){"use strict";var l4=require("@stdlib/assert/is-integer").isPrimitive,c4=ge(),At=require("@stdlib/string/format");function y4(){var r,e,a,i;if(arguments.length!==this._ndims)throw new RangeError(At("invalid arguments. Number of indices must match the number of dimensions. ndims: `%u`. nargs: `%u`.",this._ndims,arguments.length));for(r=this._offset,a=this._submode.length,i=0;i0))throw new TypeError(re("invalid argument. Third argument must be an array-like object containing nonnegative integers. Value: `%s`.",a));if(s=a.length,s>Xt)throw new RangeError(re("invalid argument. Number of dimensions must not exceed %u due to stack limits. Value: `%u`.",Xt,s));if(!T4(i))throw new TypeError(re("invalid argument. Fourth argument must be an array-like object containing integers. Value: `%s`.",i));if(s>0){if(i.length!==s)throw new RangeError(re("invalid argument. Fourth argument length must match the number of dimensions. Expected number of dimensions: `%u`. Strides length: `%u`.",s,i.length))}else{if(i.length!==1)throw new RangeError("invalid argument. Fourth argument length must be equal to 1 when creating a zero-dimensional ndarray.");if(i[0]!==0)throw new RangeError(re("invalid argument. Fourth argument must contain a single element equal to 0. Value: `%d`.",i[0]))}if(!I4(t))throw new TypeError(re("invalid argument. Fifth argument must be a nonnegative integer. Value: `%s`.",t));if(!k4(v))throw new TypeError(re("invalid argument. Sixth argument must be a supported order. Value: `%s`.",v));if(s>0&&!R4(e.length,a,i,t)&&N4(a)>0)throw new Error("invalid arguments. Input buffer is incompatible with the specified meta data. Ensure that the offset is valid with regard to the strides array and that the buffer has enough elements to satisfy the desired array shape.");if(u={},u.mode=V4,u.readonly=U4,arguments.length>6&&(f=B4(u,n),f))throw f;return this._mode=u.mode,u.submode===void 0&&(u.submode=[this._mode]),this._submode=u.submode,o=Jt(a,s),d=Jt(i,s||1),Qt.call(this,r,e,o,d,t,v),this._flags.READONLY=u.readonly,this}C4(ee,Qt);ze(ee,"name","ndarray");ze(ee.prototype,"get",P4);ze(ee.prototype,"iget",L4);ze(ee.prototype,"set",M4);ze(ee.prototype,"iset",D4);Wt.exports=ee});var ae=C(function(NN,$t){"use strict";var F4=Ht();$t.exports=F4});var rs=C(function(zN,Y4){Y4.exports=["none","equiv","safe","same-kind","unsafe"]});var as=C(function(CN,es){"use strict";var K4=rs();function G4(){return K4.slice()}es.exports=G4});var vs=C(function(LN,is){"use strict";function Z4(){return{none:0,equiv:1,safe:2,"same-kind":3,unsafe:4}}is.exports=Z4});var Na=C(function(DN,ss){"use strict";var J4=require("@stdlib/utils/define-nonenumerable-read-only-property"),ts=as(),X4=vs();J4(ts,"enum",X4);ss.exports=ts});var us=C(function(PN,ns){"use strict";var Q4=Na(),os=Q4(),W4=os.length;function H4(r){var e;for(e=0;e0}_s.exports=Sh});var La=C(function(QN,Os){"use strict";var wh=Es();Os.exports=wh});var Is=C(function(WN,jh){jh.exports={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,binary:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,binary:0,generic:0},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:0,generic:1},binary:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,binary:1,generic:0}}});var As=C(function(HN,ks){"use strict";var Ts=require("@stdlib/utils/keys"),_h=require("@stdlib/assert/has-own-property"),Eh=ie(),He=Is(),We;function Oh(){var r,e,a,i,t,v,n,s,u;for(a={},r=Ts(He),e=r.length,u=0;u0}Ns.exports=Nh});var Pa=C(function(ez,Cs){"use strict";var zh=zs();Cs.exports=zh});var Ds=C(function(az,Ls){"use strict";var Ch=La(),Lh=Pa();function Dh(r,e,a){return a==="unsafe"||r===e?!0:a==="none"||a==="equiv"?!1:a==="safe"?Ch(r,e):Lh(r,e)}Ls.exports=Dh});var Ma=C(function(iz,Ps){"use strict";var Ph=Ds();Ps.exports=Ph});var Bs=C(function(vz,Ms){"use strict";var Mh=require("@stdlib/buffer/ctor"),Bh=require("@stdlib/array/float64"),Vh=require("@stdlib/array/float32"),Uh=require("@stdlib/array/int16"),Fh=require("@stdlib/array/int32"),Yh=require("@stdlib/array/int8"),Kh=require("@stdlib/array/uint16"),Gh=require("@stdlib/array/uint32"),Zh=require("@stdlib/array/uint8"),Jh=require("@stdlib/array/uint8c"),Xh=require("@stdlib/array/complex64"),Qh=require("@stdlib/array/complex128"),Wh={binary:Mh,float64:Bh,float32:Vh,generic:Array,int16:Uh,int32:Fh,int8:Yh,uint16:Kh,uint32:Gh,uint8:Zh,uint8c:Jh,complex64:Xh,complex128:Qh};Ms.exports=Wh});var Us=C(function(tz,Vs){"use strict";var Hh=Bs();function $h(r){return Hh[r]||null}Vs.exports=$h});var Le=C(function(sz,Fs){"use strict";var rq=Us();Fs.exports=rq});var Ks=C(function(oz,Ys){"use strict";function eq(r){var e;for(e=0;e=0&&r.length=pg(e)}Eo.exports=mg});var To=C(function(jz,Io){"use strict";var xg=Oo();Io.exports=xg});var Ro=C(function(_z,Ao){"use strict";var ko=require("@stdlib/math/base/special/abs");function hg(r){var e,a,i,t;if(e=r.length,e===0)return!1;for(a=ko(r[0]),t=1;ta)return!1;a=i}return!0}yn.exports=t6});var Za=C(function(Jz,mn){"use strict";var s6=pn();mn.exports=s6});var hn=C(function(Xz,xn){"use strict";var o6=De(),n6=ve(),u6=Za();function f6(r,e,a){return n6(e)!==0&&u6(e)&&o6(r,e,a)}xn.exports=f6});var gn=C(function(Qz,qn){"use strict";var d6=hn();qn.exports=d6});var Sn=C(function(Wz,bn){"use strict";var l6=require("@stdlib/array/base/assert/contains").factory,c6=Fr(),y6=l6(c6("signed_integer"));bn.exports=y6});var Ja=C(function(Hz,wn){"use strict";var p6=Sn();wn.exports=p6});var _n=C(function($z,jn){"use strict";var m6=require("@stdlib/array/base/assert/contains").factory,x6=Fr(),h6=m6(x6("unsigned_integer"));jn.exports=h6});var Xa=C(function(rC,En){"use strict";var q6=_n();En.exports=q6});var In=C(function(eC,On){"use strict";var Dr=require("@stdlib/utils/define-read-only-property"),Cr={};Dr(Cr,"isAllowedDataTypeCast",Ma());Dr(Cr,"isBufferLengthCompatible",_a());Dr(Cr,"isBufferLengthCompatibleShape",To());Dr(Cr,"isCastingMode",za());Dr(Cr,"isColumnMajor",Ba());Dr(Cr,"isColumnMajorContiguous",Bo());Dr(Cr,"isComplexFloatingPointDataType",Va());Dr(Cr,"isContiguous",Zo());Dr(Cr,"isDataType",ke());Dr(Cr,"isFloatingPointDataType",Ua());Dr(Cr,"isIndexMode",Ne());Dr(Cr,"isIntegerDataType",Fa());Dr(Cr,"isNumericDataType",Ya());Dr(Cr,"isOrder",qe());Dr(Cr,"isReadOnly",Pe());Dr(Cr,"isRealDataType",Ka());Dr(Cr,"isRealFloatingPointDataType",Ga());Dr(Cr,"isRowMajor",Za());Dr(Cr,"isRowMajorContiguous",gn());Dr(Cr,"isSafeDataTypeCast",La());Dr(Cr,"isSameKindDataTypeCast",Pa());Dr(Cr,"isSignedIntegerDataType",Ja());Dr(Cr,"isSingleSegmentCompatible",De());Dr(Cr,"isUnsignedIntegerDataType",Xa());On.exports=Cr});var kn=C(function(aC,Tn){"use strict";function g6(r,e){var a,i,t,v,n,s,u,f,o,d;for(t=1,v=1,d=1;d=0&&(o=r[n],i=o<0?-o:o,!(i<=a));)r[n+1]=o,e[s+1]=e[s],n-=1,s-=1;r[n+1]=u,e[s+1]=f,t+=1,v+=1}}Tn.exports=g6});var Nn=C(function(iC,Rn){"use strict";var b6=require("@stdlib/array/base/zero-to"),S6=require("@stdlib/array/base/copy-indexed"),aa=require("@stdlib/array/base/take"),w6=require("@stdlib/array/base/filled"),Qa=Te(),j6=kn(),An=3;function _6(r,e,a,i){var t,v,n,s,u,f,o,d,y,h;if(t=b6(r.length),f=Qa(e),o=Qa(a),d=Qa(i),v=w6([],4),v[f].push(e),v[o].push(a),v[d].push(i),n=v[0].length,n===An)u=e;else if(n===An-1){for(y=1;y<4;y++)if(v[y].length){u=v[y][0];break}}else{for(h=0,y=1;y<4;y++)s=v[y].length,s>=n&&(n=s,h=y);u=v[h][0]}return u=S6(u),j6(u,t),r=aa(r,t),e=e===u?u:aa(e,t),a=a===u?u:aa(a,t),i=i===u?u:aa(i,t),{sh:r,sx:e,sy:a,sz:i}}Rn.exports=_6});var Cn=C(function(vC,zn){"use strict";var E6=Nn();zn.exports=E6});var Dn=C(function(tC,Ln){"use strict";var O6={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};Ln.exports=O6});var Mn=C(function(sC,Pn){"use strict";var Wa=ue(),ia=Dn();function I6(r,e,a){var i,t,v;return i=Wa(r),t=Wa(e),v=Wa(a),i===null||t===null||v===null?ia.BLOCK_SIZE_IN_ELEMENTS:i>t&&i>v?ia.BLOCK_SIZE_IN_BYTES/i|0:t>v?ia.BLOCK_SIZE_IN_BYTES/t|0:ia.BLOCK_SIZE_IN_BYTES/v|0}Pn.exports=I6});var Vn=C(function(oC,Bn){"use strict";var T6=Mn();Bn.exports=T6});var Yn=C(function(nC,Fn){"use strict";var k6=require("@stdlib/string/format"),va=require("@stdlib/math/base/special/trunc"),Un=require("@stdlib/math/base/special/abs");function A6(r,e,a,i,t,v){var n,s,u,f,o,d;for(n=r.length,s=1,d=0;d=s&&(t=s-1);else if(v==="wrap")t<0?(t+=s,t<0&&(t%=s,t!==0&&(t+=s))):t>=s&&(t-=s,t>=s&&(t%=s));else if(t<0||t>=s)throw new RangeError(k6("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",s,t));if(u=0,i==="column-major"){for(d=n-1;d>=0;d--)o=e[d],o<0?(f=va(t/o),t-=f*o,f+=r[d]-1):(f=va(t/o),t-=f*o),u+=f*Un(o);return u}for(d=0;d=0;f--)if(o=s-n+f,!(o<0)){if(u=t[o],i=e[f],i!==0&&if&&(f=e[o]);for(o=0;o=0;){for(v=e[0]-f+o,v>=0?i=t[v]:i=1,d=1;d=0?s=r[d][n]:s=1,i===1){i=s;continue}if(!(s===1||i===s))return null}a[o]=i,o-=1}return a}eu.exports=K6});var vu=C(function(pC,iu){"use strict";var G6=au();iu.exports=G6});var su=C(function(mC,tu){"use strict";var Z6=Ce(),J6=$e();function X6(r){var e=J6(r);return e?Z6(e):null}tu.exports=X6});var nu=C(function(xC,ou){"use strict";var Q6=su();ou.exports=Q6});var fu=C(function(hC,uu){"use strict";function W6(){return{binary:"r",bool:"x",complex64:"c",complex128:"z",float16:"h",bfloat16:"e",float32:"f",float64:"d",float128:"g",generic:"o",int8:"s",int16:"k",int32:"i",int64:"l",int128:"m",int256:"n",uint8:"b",uint8c:"a",uint16:"t",uint32:"u",uint64:"v",uint128:"w",uint256:"y"}}uu.exports=W6});var cu=C(function(qC,lu){"use strict";var H6=ie(),du=fu(),$a;function $6(r){return arguments.length===0?du():($a===void 0&&($a=du()),$a[H6(r)]||null)}lu.exports=$6});var ri=C(function(gC,yu){"use strict";var rb=cu();yu.exports=rb});var hu=C(function(bC,xu){"use strict";var pu=require("@stdlib/utils/object-inverse"),mu=ri(),ei;function eb(r){return arguments.length===0?pu(mu()):(ei===void 0&&(ei=pu(mu())),ei[r]||null)}xu.exports=eb});var gu=C(function(SC,qu){"use strict";var ab=hu();qu.exports=ab});var Su=C(function(wC,bu){"use strict";function ib(){return{binary:"byte",bool:"boolean",complex64:"single-precision floating-point complex number",complex128:"double-precision floating-point complex number",float16:"half-precision floating-point number",bfloat16:"brain floating-point number",float32:"single-precision floating-point number",float64:"double-precision floating-point number",float128:"quadruple-precision floating-point number",generic:"generic array value",int8:"signed 8-bit integer",int16:"signed 16-bit integer",int32:"signed 32-bit integer",int64:"signed 64-bit integer",int128:"signed 128-bit integer",int256:"signed 256-bit integer",uint8:"unsigned 8-bit integer",uint8c:"unsigned 8-bit integer (clamped)",uint16:"unsigned 16-bit integer",uint32:"unsigned 32-bit integer",uint64:"unsigned 64-bit integer",uint128:"unsigned 128-bit integer",uint256:"unsigned 256-bit integer"}}bu.exports=ib});var _u=C(function(jC,ju){"use strict";var vb=ie(),wu=Su(),ai;function tb(r){return arguments.length===0?wu():(ai===void 0&&(ai=wu()),ai[vb(r)]||null)}ju.exports=tb});var Ou=C(function(_C,Eu){"use strict";var sb=_u();Eu.exports=sb});var Tu=C(function(EC,Iu){"use strict";var ob=Je(),nb=Ce();function ub(r){var e=typeof r;return e==="number"?ob(r)?r:null:e==="string"?nb(r):null}Iu.exports=ub});var ii=C(function(OC,ku){"use strict";var fb=Tu();ku.exports=fb});var Au=C(function(IC,db){db.exports={binary:null,bool:"bool",complex64:"stdlib_complex64_t",complex128:"stdlib_complex128_t",float16:null,bfloat16:null,float32:"float",float64:"double",float128:null,generic:null,int8:"int8_t",int16:"int16_t",int32:"int32_t",int64:"int64_t",int128:null,int256:null,uint8:"uint8_t",uint8c:null,uint16:"uint16_t",uint32:"uint32_t",uint64:"uint64_t",uint128:null,uint256:null}});var Nu=C(function(TC,Ru){"use strict";var lb=ie(),cb=Au();function yb(r){return cb[lb(r)]||null}Ru.exports=yb});var Cu=C(function(kC,zu){"use strict";var pb=Nu();zu.exports=pb});var Pu=C(function(AC,Du){"use strict";var mb=require("@stdlib/assert/is-array-like-object"),Lu=require("@stdlib/assert/is-nonnegative-integer").isPrimitive,xb=ie(),vi=require("@stdlib/string/format");function hb(r,e,a){var i,t,v,n,s,u,f,o;if(!mb(r))throw new TypeError(vi("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!Lu(e))throw new TypeError(vi("invalid argument. Second argument must be a nonnegative integer. Value: `%s`.",e));if(!Lu(a))throw new TypeError(vi("invalid argument. Third argument must be a nonnegative integer. Value: `%s`.",a));if(i=r.length,i===0)throw new RangeError("invalid argument. First argument must contain at least one element.");if(s=e+a,i%s!==0)throw new RangeError("invalid arguments. Length of the first argument is incompatible with the second and third arguments.");for(t=[],v=[],u=2*s,o=2*e,f=0;f<=u;f++)f===0?f===o?v.push("() => ("):v.push("("):f===u?f===o?v.push(") => ()"):v.push(")"):f===o?v.push(") => ("):f%2===1?v.push(""):v.push(", ");for(f=0;f0?(v=wb(e),n=gb(e,a)):(v=1,n=[0]),r==="binary"?t=_b(v):t=jb(v,r),new Sb(r,t,e,n,bb(e,n),a)}Bu.exports=Eb});var Fu=C(function(zC,Uu){"use strict";var Ob=Vu();Uu.exports=Ob});var Ku=C(function(CC,Yu){"use strict";var Ib=Yr(),Tb=Gr(),kb=Pr(),Ab=require("@stdlib/array/empty"),Rb=require("@stdlib/buffer/alloc-unsafe");function Nb(r){var e,a,i,t,v,n,s;return s=r.dtype,v=r.shape,t=r.order,e=v.length,e>0?(a=kb(v),n=Ib(v,t)):(a=1,n=[0]),s==="binary"?i=Rb(a):i=Ab(a,s),new r.constructor(s,i,v,n,Tb(v,n),t)}Yu.exports=Nb});var Zu=C(function(LC,Gu){"use strict";var zb=Ku();Gu.exports=zb});var Qu=C(function(DC,Xu){"use strict";var Cb=Pe(),Ju=require("@stdlib/string/format");function Lb(r,e){var a,i,t,v,n,s,u;if(v=r.shape,n=r.strides,t=r.order,s=v.length,a=[],i=[],e<0){if(e<-s-1)throw new RangeError(Ju("invalid argument. Specified axis is out-of-bounds. Must be on the interval: [-%u-1, %u]. Value: `%d`.",s,s,e));e+=s+1}else if(e>s)throw new RangeError(Ju("invalid argument. Specified axis is out-of-bounds. Must be on the interval: [-%u-1, %u]. Value: `%d`.",s,s,e));if(e===0)for(i.push(1),a.push(n[0]),u=0;u=u&&(t=u-1);else if(v==="wrap")t<0?(t+=u,t<0&&(t%=u,t!==0&&(t+=u))):t>=u&&(t-=u,t>=u&&(t%=u));else if(t<0||t>=u)throw new RangeError(Gb("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",u,t));if(a===0){if(i==="column-major"){for(d=0;d=0;d--)o=t%r[d],t-=o,t/=r[d],n[d]=o;return n}if(i==="column-major"){for(d=s-1;d>=0;d--)o=e[d],o<0?(f=ta(t/o),t-=f*o,n[d]=r[d]-1+f):(f=ta(t/o),t-=f*o,n[d]=f);return n}for(d=0;d0&&(t+=e[v]*(r[v]-1))}return t}uf.exports=Hb});var lf=C(function(KC,df){"use strict";var $b=ff();df.exports=$b});var pf=C(function(GC,yf){"use strict";var cf=Ha();function r5(r,e){var a,i,t;if(i=e.length,a=r.shape,a.length===i){for(t=0;t=0&&(o=r[n],i=o<0?-o:o,!(i<=a));)r[n+1]=o,e[s+1]=e[s],n-=1,s-=1;r[n+1]=u,e[s+1]=f,t+=1,v+=1}}Nf.exports=h5});var Lf=C(function(iL,Cf){"use strict";var q5=require("@stdlib/array/base/zero-to"),g5=require("@stdlib/array/base/copy-indexed"),b5=require("@stdlib/array/base/take"),S5=zf();function w5(r,e){var a;return a=q5(r.length),e=g5(e),S5(e,a),r=b5(r,a),{sh:r,sx:e}}Cf.exports=w5});var Br=C(function(vL,Df){"use strict";var j5=Lf();Df.exports=j5});var Mf=C(function(tL,Pf){"use strict";var _5={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};Pf.exports=_5});var Uf=C(function(sL,Vf){"use strict";var E5=ue(),Bf=Mf();function O5(r){var e=E5(r);return e===null?Bf.BLOCK_SIZE_IN_ELEMENTS:Bf.BLOCK_SIZE_IN_BYTES/e|0}Vf.exports=O5});var Vr=C(function(oL,Ff){"use strict";var I5=Uf();Ff.exports=I5});var Kf=C(function(nL,Yf){"use strict";var T5=Br(),k5=Vr();function A5(r,e){var a,i,t,v,n,s,u,f,o,d,y,h,b,m,w,p,q;for(q=T5(r.shape,r.strides),u=q.sh,d=q.sx,a=k5(r.dtype),y=r.offset,i=r.data,v=d[0],t=r.accessors[1],p=u[1];p>0;)for(p0;)for(w0;)for(E0;)for(x0;)for(g0;)for(S0;)for(O0;)for(l0;)for(_0;)for(T0;)for(R0;)for(A0;)for(I0;)for(k0;)for(M0;)for(D0;)for(N0;)for(L0;)for(z0;)for(T0;)for(F0;)for(U0;)for(V0;)for(B0;)for(P0;)for(M0;)for(D0;)for(G0;)for(J0;)for(K0;)for(Z0;)for(Y0;)for(F0;)for(U0;)for(V0;)for(H0;)for($0;)for(Q0;)for(W0;)for(X0;)for(G0;)for(J0;)for(K0;)for(Z0;)for(ar0;)for(tr0;)for(er0;)for(ir0;)for(rr0;)for(H0;)for($0;)for(Q0;)for(W0;)for(X0;)for(w0;)for(m0;)for(x0;)for(g0;)for(j0;)for(O0;)for(l0;)for(_0;)for(c0;)for(R0;)for(A0;)for(I0;)for(k0;)for(S0;)for(D0;)for(N0;)for(L0;)for(z0;)for(T0;)for(R0;)for(U0;)for(V0;)for(B0;)for(P0;)for(M0;)for(D0;)for(N0;)for(J0;)for(K0;)for(Z0;)for(Y0;)for(F0;)for(U0;)for(V0;)for(B0;)for($0;)for(Q0;)for(W0;)for(X0;)for(G0;)for(J0;)for(K0;)for(Z0;)for(Y0;)for(tr0;)for(er0;)for(ir0;)for(rr0;)for(H0;)for($0;)for(Q0;)for(W0;)for(X0;)for(G=s&&(t=s-1);else if(v==="wrap")t<0?(t+=s,t<0&&(t%=s,t!==0&&(t+=s))):t>=s&&(t-=s,t>=s&&(t%=s));else if(t<0||t>=s)throw new RangeError(B8("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",s,t));if(u=a,i==="column-major"){for(o=0;o=0;o--)f=t%r[o],t-=f,t/=r[o],u+=f*e[o];return u}J0.exports=V8});var le=C(function(PL,Q0){"use strict";var U8=X0();Q0.exports=U8});var H0=C(function(ML,W0){"use strict";var F8=Pr(),Y8=le(),K8="throw";function G8(r,e){var a,i,t,v,n,s,u,f,o;for(n=r.shape,t=F8(n),a=r.data,s=r.strides,u=r.offset,i=r.order,v=r.accessors[1],o=0;o0&&(d=cj(d.length))}else d=_l(y);return El(d)===0?mj(o,v,li(d,u),s):(t=yj(y,i,t),d=li(d,u),d.length===0?new o(v,r.data,[],[0],t,s,ci()):(i=pj(y,i,u),new o(v,r.data,d,i,t,s,ci())))}Il.exports=xj});var we=C(function(O9,kl){"use strict";var hj=Tl();kl.exports=hj});var Rl=C(function(I9,Al){"use strict";var qj=require("@stdlib/string/format");function gj(){var r,e,a,i,t,v,n,s,u,f,o,d;for(i=arguments[0],r=arguments[1],e=arguments[2],t=i.length,v=arguments[3+t],a=v.length,s=e,d=0;d=u&&(o=u-1);else if(n==="wrap")o<0?(o+=u,o<0&&(o%=u,o!==0&&(o+=u))):o>=u&&(o-=u,o>=u&&(o%=u));else if(o<0||o>=u)throw new RangeError(qj("invalid argument. Subscripts must not exceed array dimensions. Subscript: `%u`. Value: `%d`.",d,o));f=r[d],f<0&&e===0?s-=o*f:s+=o*f}return s}Al.exports=gj});var yi=C(function(T9,Nl){"use strict";var bj=Rl();Nl.exports=bj});var Ll=C(function(k9,Cl){"use strict";function zl(r,e,a,i,t,v){var n,s,u,f,o;if(v>=e.length)return r.accessors[0](r.data,i);for(u=[],f=e[v],n=a[v],o=0;o=0&&(o=r[n],i=o<0?-o:o,!(i<=a));)r[n+1]=o,e[s+1]=e[s],n-=1,s-=1;r[n+1]=u,e[s+1]=f,t+=1,v+=1}}Yl.exports=Tj});var Jl=C(function(L9,Zl){"use strict";var kj=require("@stdlib/array/base/zero-to"),Aj=require("@stdlib/array/base/copy-indexed"),Gl=require("@stdlib/array/base/take"),Rj=Kl();function Nj(r,e,a){var i;return i=kj(r.length),e=Aj(e),Rj(e,i),r=Gl(r,i),a=Gl(a,i),{sh:r,sx:e,sy:a}}Zl.exports=Nj});var kr=C(function(D9,Xl){"use strict";var zj=Jl();Xl.exports=zj});var Wl=C(function(P9,Ql){"use strict";var Cj={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};Ql.exports=Cj});var rc=C(function(M9,$l){"use strict";var Hl=ue(),mi=Wl();function Lj(r,e){var a,i;return a=Hl(r),i=Hl(e),a===null||i===null?mi.BLOCK_SIZE_IN_ELEMENTS:a>i?mi.BLOCK_SIZE_IN_BYTES/a|0:mi.BLOCK_SIZE_IN_BYTES/i|0}$l.exports=Lj});var Ar=C(function(B9,ec){"use strict";var Dj=rc();ec.exports=Dj});var ic=C(function(V9,ac){"use strict";var Pj=kr(),Mj=Ar();function Bj(r,e,a){var i,t,v,n,s,u,f,o,d,y,h,b,m,w,p,q,j,g,x,E,c,_,l,O,S;for(S=Pj(r.shape,r.strides,e.strides),b=S.sh,p=S.sx,q=S.sy,i=Mj(r.dtype,e.dtype),j=r.offset,g=e.offset,t=r.data,v=e.data,u=p[0],o=q[0],n=r.accessors[0],s=e.accessors[1],O=b[1];O>0;)for(O0;)for(l0;)for(z0;)for(T0;)for(R0;)for(V0;)for(B0;)for(P0;)for(M0;)for(G0;)for(J0;)for(K0;)for(Z0;)for(Y0;)for(ir0;)for(rr0;)for(H0;)for($0;)for(Q0;)for(W0;)for(nr0;)for(or0;)for(sr0;)for(vr0;)for(ar0;)for(tr0;)for(er0;)for(pr0;)for(lr0;)for(yr0;)for(cr0;)for(dr0;)for(fr0;)for(ur0;)for(nr0;)for(wr0;)for(Sr0;)for(xr0;)for(jr0;)for(qr0;)for(br0;)for(mr0;)for(pr0;)for(lr0;)for(Nr0;)for(Rr0;)for(Tr0;)for(Ir0;)for(Or0;)for(Er0;)for(_r0;)for(wr0;)for(Sr0;)for(xr0;)for(_0;)for(c0;)for(R0;)for(A0;)for(I0;)for(P0;)for(M0;)for(D0;)for(N0;)for(K0;)for(Z0;)for(Y0;)for(F0;)for(U0;)for(H0;)for($0;)for(Q0;)for(W0;)for(X0;)for(G0;)for(sr0;)for(vr0;)for(ar0;)for(tr0;)for(er0;)for(ir0;)for(rr0;)for(yr0;)for(cr0;)for(dr0;)for(fr0;)for(ur0;)for(nr0;)for(or0;)for(sr0;)for(xr0;)for(jr0;)for(qr0;)for(br0;)for(mr0;)for(pr0;)for(lr0;)for(yr0;)for(cr0;)for(Tr0;)for(Ir0;)for(Or0;)for(Er0;)for(_r0;)for(wr0;)for(Sr0;)for(xr0;)for(jr