diff --git a/base/lib/index.js b/base/lib/index.js
index 86cdabb4..6572138f 100644
--- a/base/lib/index.js
+++ b/base/lib/index.js
@@ -490,6 +490,15 @@ setReadOnly( ns, 'shape2strides', require( './../../base/shape2strides' ) );
*/
setReadOnly( ns, 'singletonDimensions', require( './../../base/singleton-dimensions' ) );
+/**
+* @name slice
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/slice}
+*/
+setReadOnly( ns, 'slice', require( './../../base/slice' ) );
+
/**
* @name strides2offset
* @memberof ns
diff --git a/base/slice/README.md b/base/slice/README.md
new file mode 100644
index 00000000..b9bf1fcf
--- /dev/null
+++ b/base/slice/README.md
@@ -0,0 +1,205 @@
+
+
+# slice
+
+> Return a read-only view of an input ndarray.
+
+
+
+
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var slice = require( '@stdlib/ndarray/base/slice' );
+```
+
+#### slice( x, slice, strict )
+
+Returns a **read-only** view of an input ndarray.
+
+```javascript
+var Slice = require( '@stdlib/slice/ctor' );
+var MultiSlice = require( '@stdlib/slice/multi' );
+var ndarray = require( '@stdlib/ndarray/ctor' );
+var ndarray2array = require( '@stdlib/ndarray/to-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 ] ]
+
+var s0 = new Slice( null, null, -2 );
+var s1 = new Slice( null, null, -1 );
+var s = new MultiSlice( s0, s1 );
+// returns
+
+var y = slice( x, s, false );
+// returns
+
+sh = y.shape;
+// returns [ 2, 2 ]
+
+arr = ndarray2array( y );
+// returns [ [ 6.0, 5.0 ], [ 2.0, 1.0 ] ]
+```
+
+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.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+## Examples
+
+
+
+
+
+```javascript
+var S = require( '@stdlib/slice/ctor' );
+var E = require( '@stdlib/slice/multi' );
+var array = require( '@stdlib/ndarray/array' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var zeroTo = require( '@stdlib/array/base/zero-to' );
+var slice = require( '@stdlib/ndarray/base/slice' );
+
+// Alias `null` to allow for more compact indexing expressions:
+var _ = null;
+
+// Create a linear ndarray buffer:
+var buf = zeroTo( 27 );
+
+// Create an ndarray:
+var x = array( buf, {
+ 'shape': [ 3, 3, 3 ]
+});
+
+// Get each matrix...
+var s1 = E( 0, _, _ );
+var y1 = slice( x, s1, 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 );
+// 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 );
+// returns
+
+var a3 = ndarray2array( y3 );
+// returns [ [ 18, 19, 20 ], [ 21, 22, 23 ], [ 24, 25, 26 ] ]
+
+// Reverse all elements:
+var s = S( _, _, -1 );
+var s4 = E( s, s, s );
+var y4 = slice( x, s4, false );
+// returns
+
+var a4 = ndarray2array( y4 );
+// returns [...]
+
+// Get the second rows from each matrix:
+var s5 = E( _, 1, _ );
+var y5 = slice( x, s5, false );
+// returns
+
+var a5 = ndarray2array( y5 );
+// returns [ [ 3, 4, 5 ], [ 12, 13, 14 ], [ 21, 22, 23 ] ]
+
+// Get the second columns from each matrix:
+var s6 = E( _, _, 1 );
+var y6 = slice( x, s6, false );
+// returns
+
+var a6 = ndarray2array( y6 );
+// returns [ [ 1, 4, 7 ], [ 10, 13, 16 ], [ 19, 22, 25 ] ]
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[@stdlib/slice/multi]: https://github.com/stdlib-js/stdlib
+
+
+
+
diff --git a/base/slice/benchmark/benchmark.js b/base/slice/benchmark/benchmark.js
new file mode 100644
index 00000000..d6ef377e
--- /dev/null
+++ b/base/slice/benchmark/benchmark.js
@@ -0,0 +1,1073 @@
+/**
+* @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 empty = require( './../../../empty' );
+var pkg = require( './../package.json' ).name;
+var slice = require( './../lib' );
+
+
+// MAIN //
+
+bench( pkg+'::0d,base', function benchmark( b ) {
+ var values;
+ var v;
+ var s;
+ var i;
+
+ values = [
+ baseEmpty( 'float64', [], 'row-major' ),
+ baseEmpty( 'float32', [], 'row-major' ),
+ baseEmpty( 'int32', [], 'row-major' ),
+ baseEmpty( 'complex128', [], 'row-major' ),
+ baseEmpty( 'generic', [], 'row-major' )
+ ];
+ s = new MultiSlice();
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* eslint-disable object-curly-newline */
+
+ values = [
+ empty( [], { 'dtype': 'float64' } ),
+ empty( [], { 'dtype': 'float32' } ),
+ empty( [], { 'dtype': 'int32' } ),
+ empty( [], { 'dtype': 'complex128' } ),
+ empty( [], { 'dtype': 'generic' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice();
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( 1 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( 1 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( new Slice( 10, 20, 1 ) );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( new Slice( 10, 20, 1 ) );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( 0, 1 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( 0, 1 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( 0, 1, 0 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( 0, 1, 0 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( null, new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( null, null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( 0, 1, 0, 1 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( 0, 1, 0, 1 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( null, null, new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* 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++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( null, null, null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( null, null, null, null, null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( 0, 1, 0, 1, 0 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* eslint-enable object-curly-newline */
+
+ s = new MultiSlice( 0, 1, 0, 1, 0 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ 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' )
+ ];
+ s = new MultiSlice( null, null, null, new Slice( 10, 20, 1 ), null );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = slice( values[ i%values.length ], 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 s;
+ var i;
+
+ /* 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' } )
+ ];
+
+ /* 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++ ) {
+ v = slice( values[ i%values.length ], 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/docs/repl.txt b/base/slice/docs/repl.txt
new file mode 100644
index 00000000..1ec9377e
--- /dev/null
+++ b/base/slice/docs/repl.txt
@@ -0,0 +1,38 @@
+
+{{alias}}( x, slice, strict )
+ Returns a read-only view of an input ndarray.
+
+ Parameters
+ ----------
+ x: ndarray
+ Input array.
+
+ slice: MultiSlice
+ Multi-slice object.
+
+ strict: boolean
+ Boolean indicating whether to enforce strict bounds checking.
+
+ Returns
+ -------
+ out: ndarray
+ Output array view.
+
+ Examples
+ --------
+ > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] )
+
+ > x.shape
+ [ 2, 2 ]
+ > var s = new {{alias:@stdlib/slice/multi}}( null, 1 )
+
+ > var y = {{alias}}( x, s, false )
+
+ > y.shape
+ [ 2 ]
+ > {{alias:@stdlib/ndarray/to-array}}( y )
+ [ 2, 4 ]
+
+ See Also
+ --------
+
diff --git a/base/slice/docs/types/index.d.ts b/base/slice/docs/types/index.d.ts
new file mode 100644
index 00000000..2e1b191e
--- /dev/null
+++ b/base/slice/docs/types/index.d.ts
@@ -0,0 +1,576 @@
+/*
+* @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 { typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray';
+import { MultiSlice } from '@stdlib/types/slice';
+
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param x - input array
+* @param s - multi-slice object
+* @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 ndarray2array = require( `@stdlib/ndarray/to-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 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6.0, 5.0 ], [ 2.0, 1.0 ] ]
+*/
+declare function slice( x: float64ndarray, slice: MultiSlice, strict: boolean ): float64ndarray;
+
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param x - input array
+* @param s - multi-slice object
+* @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 ndarray2array = require( `@stdlib/ndarray/to-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 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6.0, 5.0 ], [ 2.0, 1.0 ] ]
+*/
+declare function slice( x: float32ndarray, slice: MultiSlice, strict: boolean ): float32ndarray;
+
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param x - input array
+* @param s - multi-slice object
+* @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 ndarray2array = require( `@stdlib/ndarray/to-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 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6, 5 ], [ 2, 1 ] ]
+*/
+declare function slice( x: int32ndarray, slice: MultiSlice, strict: boolean ): int32ndarray;
+
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param x - input array
+* @param s - multi-slice object
+* @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 ndarray2array = require( `@stdlib/ndarray/to-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 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6, 5 ], [ 2, 1 ] ]
+*/
+declare function slice( x: int16ndarray, slice: MultiSlice, strict: boolean ): int16ndarray;
+
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param x - input array
+* @param s - multi-slice object
+* @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 ndarray2array = require( `@stdlib/ndarray/to-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 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6, 5 ], [ 2, 1 ] ]
+*/
+declare function slice( x: int8ndarray, slice: MultiSlice, strict: boolean ): int8ndarray;
+
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param x - input array
+* @param s - multi-slice object
+* @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 ndarray2array = require( `@stdlib/ndarray/to-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 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6, 5 ], [ 2, 1 ] ]
+*/
+declare function slice( x: uint32ndarray, slice: MultiSlice, strict: boolean ): uint32ndarray;
+
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param x - input array
+* @param s - multi-slice object
+* @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 ndarray2array = require( `@stdlib/ndarray/to-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 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6, 5 ], [ 2, 1 ] ]
+*/
+declare function slice( x: uint16ndarray, slice: MultiSlice, strict: boolean ): uint16ndarray;
+
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param x - input array
+* @param s - multi-slice object
+* @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 ndarray2array = require( `@stdlib/ndarray/to-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 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6, 5 ], [ 2, 1 ] ]
+*/
+declare function slice( x: uint8ndarray, slice: MultiSlice, strict: boolean ): uint8ndarray;
+
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param x - input array
+* @param s - multi-slice object
+* @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 ndarray2array = require( `@stdlib/ndarray/to-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 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6, 5 ], [ 2, 1 ] ]
+*/
+declare function slice( x: uint8cndarray, slice: MultiSlice, strict: boolean ): uint8cndarray;
+
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param x - input array
+* @param s - multi-slice object
+* @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 ndarray2array = require( `@stdlib/ndarray/to-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 ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*/
+declare function slice( x: complex128ndarray, slice: MultiSlice, strict: boolean ): complex128ndarray;
+
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param x - input array
+* @param s - multi-slice object
+* @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 ndarray2array = require( `@stdlib/ndarray/to-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 ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*/
+declare function slice( x: complex64ndarray, slice: MultiSlice, strict: boolean ): complex64ndarray;
+
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param x - input array
+* @param s - multi-slice object
+* @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 ndarray2array = require( `@stdlib/ndarray/to-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 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6, 5 ], [ 2, 1 ] ]
+*/
+declare function slice( x: genericndarray, slice: MultiSlice, strict: boolean ): genericndarray;
+
+/**
+* Returns a read-only view of an input ndarray.
+*
+* @param x - input array
+* @param s - multi-slice object
+* @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 ndarray2array = require( `@stdlib/ndarray/to-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 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6, 5 ], [ 2, 1 ] ]
+*/
+declare function slice( x: typedndarray, slice: MultiSlice, strict: boolean ): typedndarray;
+
+
+// EXPORTS //
+
+export = slice;
diff --git a/base/slice/docs/types/test.ts b/base/slice/docs/types/test.ts
new file mode 100644
index 00000000..e940bf64
--- /dev/null
+++ b/base/slice/docs/types/test.ts
@@ -0,0 +1,128 @@
+/*
+* @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 MultiSlice = require( '@stdlib/slice/multi' );
+import slice = require( './index' );
+
+
+// TESTS //
+
+// The function returns an ndarray...
+{
+ const order = 'row-major';
+ 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
+}
+
+// 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
+}
+
+// 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
+}
+
+// The compiler throws an error if the function is provided a third argument which is not a boolean...
+{
+ 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
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ const x = empty( 'float64', [ 2, 2 ], 'row-major' );
+ const s = new MultiSlice( null, null );
+
+ slice( x ); // $ExpectError
+ slice( x, s ); // $ExpectError
+ slice( x, s, false, {} ); // $ExpectError
+}
diff --git a/base/slice/examples/index.js b/base/slice/examples/index.js
new file mode 100644
index 00000000..b82eaee7
--- /dev/null
+++ b/base/slice/examples/index.js
@@ -0,0 +1,92 @@
+/**
+* @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 S = require( '@stdlib/slice/ctor' );
+var E = require( '@stdlib/slice/multi' );
+var array = require( './../../../array' );
+var ndarray2array = require( './../../../to-array' );
+var zeroTo = require( '@stdlib/array/base/zero-to' );
+var slice = require( './../lib' );
+
+// Alias `null` to allow for more compact indexing expressions:
+var _ = null;
+
+// Create a linear ndarray buffer:
+var buf = zeroTo( 27 );
+
+// Create an ndarray:
+var x = array( buf, {
+ 'shape': [ 3, 3, 3 ]
+});
+
+// Get each matrix...
+var s1 = E( 0, _, _ );
+var y1 = slice( x, s1, false );
+// returns
+
+var a1 = ndarray2array( y1 );
+console.log( a1 );
+// => [ [ 0, 1, 2 ], [ 3, 4, 5 ], [ 6, 7, 8 ] ]
+
+var s2 = E( 1, _, _ );
+var y2 = slice( x, s2, false );
+// returns
+
+var a2 = ndarray2array( y2 );
+console.log( a2 );
+// => [ [ 9, 10, 11 ], [ 12, 13, 14 ], [ 15, 16, 17 ] ]
+
+var s3 = E( 2, _, _ );
+var y3 = slice( x, s3, false );
+// returns
+
+var a3 = ndarray2array( y3 );
+console.log( a3 );
+// => [ [ 18, 19, 20 ], [ 21, 22, 23 ], [ 24, 25, 26 ] ]
+
+// Reverse all elements:
+var s = S( _, _, -1 );
+var s4 = E( s, s, s );
+var y4 = slice( x, s4, false );
+// returns
+
+var a4 = ndarray2array( y4 );
+console.log( a4 );
+// => [...]
+
+// Get the second rows from each matrix:
+var s5 = E( _, 1, _ );
+var y5 = slice( x, s5, false );
+// returns
+
+var a5 = ndarray2array( y5 );
+console.log( a5 );
+// => [ [ 3, 4, 5 ], [ 12, 13, 14 ], [ 21, 22, 23 ] ]
+
+// Get the second columns from each matrix:
+var s6 = E( _, _, 1 );
+var y6 = slice( x, s6, false );
+// returns
+
+var a6 = ndarray2array( y6 );
+console.log( a6 );
+// => [ [ 1, 4, 7 ], [ 10, 13, 16 ], [ 19, 22, 25 ] ]
diff --git a/fancy/lib/empty.js b/base/slice/lib/empty.js
similarity index 93%
rename from fancy/lib/empty.js
rename to base/slice/lib/empty.js
index e57c8afa..15c125cc 100644
--- a/fancy/lib/empty.js
+++ b/base/slice/lib/empty.js
@@ -20,9 +20,9 @@
// MODULES //
-var buffer = require( './../../base/buffer' );
+var buffer = require( './../../../base/buffer' );
var zeros = require( '@stdlib/array/base/zeros' );
-var options = require( './array_options.js' );
+var options = require( './options.js' );
// MAIN //
diff --git a/base/slice/lib/index.js b/base/slice/lib/index.js
new file mode 100644
index 00000000..6c78dde1
--- /dev/null
+++ b/base/slice/lib/index.js
@@ -0,0 +1,67 @@
+/**
+* @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';
+
+/**
+* Return a read-only view of an input ndarray.
+*
+* @module @stdlib/ndarray/base/slice
+*
+* @example
+* var Slice = require( '@stdlib/slice/ctor' );
+* var MultiSlice = require( '@stdlib/slice/multi' );
+* var ndarray = require( '@stdlib/ndarray/ctor' );
+* var ndarray2array = require( '@stdlib/ndarray/to-array' );
+* var slice = require( '@stdlib/ndarray/base/slice' );
+*
+* 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 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6.0, 5.0 ], [ 2.0, 1.0 ] ]
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/base/slice/lib/main.js b/base/slice/lib/main.js
new file mode 100644
index 00000000..b60b00e9
--- /dev/null
+++ b/base/slice/lib/main.js
@@ -0,0 +1,161 @@
+/**
+* @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 normalizeMultiSlice = require( '@stdlib/slice/base/normalize-multi-slice' );
+var nonreducedDimensions = require( '@stdlib/slice/base/nonreduced-dimensions' );
+var sliceShape = require( '@stdlib/slice/base/shape' );
+var take = require( '@stdlib/array/base/take' );
+var zeros = require( '@stdlib/array/base/zeros' );
+var vind2bind = require( './../../../base/vind2bind' );
+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.
+*
+* @param {ndarray} x - input array
+* @param {MultiSlice} s - multi-slice object
+* @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
+* @returns {ndarray} ndarray view
+*
+* @example
+* var Slice = require( '@stdlib/slice/ctor' );
+* var MultiSlice = require( '@stdlib/slice/multi' );
+* var ndarray = require( '@stdlib/ndarray/ctor' );
+* var ndarray2array = require( '@stdlib/ndarray/to-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 ] ]
+*
+* var s = new MultiSlice( new Slice( null, null, -2 ), new Slice( null, null, -1 ) );
+* // returns
+*
+* var y = slice( x, s, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 6.0, 5.0 ], [ 2.0, 1.0 ] ]
+*/
+function slice( x, s, strict ) {
+ var strides;
+ var offset;
+ var dtype;
+ var shape;
+ var order;
+ var sdims;
+ var ndims;
+ var ctor;
+ var sh;
+ var ns;
+
+ // Retrieve array meta data:
+ dtype = x.dtype;
+ shape = x.shape;
+ strides = x.strides;
+ offset = x.offset;
+ order = x.order;
+ ndims = shape.length;
+
+ // Ensure that the number of array dimensions matches the number of slices:
+ if ( s.ndims !== ndims ) {
+ throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', shape.join( ',' ), s.ndims ) );
+ }
+ // Resolve the output array constructor:
+ ctor = x.constructor;
+
+ // 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
+ }
+ // Resolve the indices of the non-reduced dimensions:
+ sdims = nonreducedDimensions( s );
+
+ // Normalize the slice object based on the array shape:
+ ns = normalizeMultiSlice( s, shape, true );
+
+ // Check whether the slice exceeds array bounds...
+ if ( ns.code ) {
+ if ( strict ) {
+ throw new RangeError( format( 'invalid argument. Slice exceeds array bounds. Array shape: (%s).', shape.join( ',' ) ) );
+ }
+ // Normalize again, this time allowing for out-of-bounds indices:
+ ns = normalizeMultiSlice( s, shape, false );
+
+ // Compute the slice shape:
+ sh = sliceShape( ns );
+
+ // If the non-reduced dimensions contain elements, this means that at least one reduced dimension exceeded array bounds; in which case, we generate a shape containing zeros:
+ if ( numel( take( sh, sdims ) ) > 0 ) {
+ sh = zeros( sh.length );
+ }
+ } else {
+ // Compute the slice shape:
+ sh = sliceShape( ns );
+ }
+ // If the slice does not contain any elements, return an empty array...
+ if ( numel( sh ) === 0 ) {
+ return empty( ctor, dtype, take( sh, sdims ), order );
+ }
+ // Resolve the index offset of the first element indexed by the slice:
+ offset = vind2bind( shape, strides, offset, order, sliceStart( ns, shape, strides, 0 ), 'throw' ); // TODO: @stdlib/ndarray/base/sind2bind
+
+ // Remove reduced dimensions from the slice shape:
+ sh = take( sh, sdims );
+
+ // If all dimensions were reduced, return a zero-dimensional array...
+ if ( sh.length === 0 ) {
+ return new ctor( dtype, x.data, [], [ 0 ], offset, order, options() );
+ }
+ // 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() );
+}
+
+
+// EXPORTS //
+
+module.exports = slice;
diff --git a/base/slice/lib/options.js b/base/slice/lib/options.js
new file mode 100644
index 00000000..64564512
--- /dev/null
+++ b/base/slice/lib/options.js
@@ -0,0 +1,39 @@
+/**
+* @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';
+
+// MAIN //
+
+/**
+* Returns array creation options.
+*
+* @private
+* @returns {Object} options
+*/
+function options() {
+ return {
+ // Default to always returning read-only arrays:
+ 'readonly': true
+ };
+}
+
+
+// EXPORTS //
+
+module.exports = options;
diff --git a/fancy/lib/slice_start.js b/base/slice/lib/slice_start.js
similarity index 97%
rename from fancy/lib/slice_start.js
rename to base/slice/lib/slice_start.js
index 149f8ca6..87f351b3 100644
--- a/fancy/lib/slice_start.js
+++ b/base/slice/lib/slice_start.js
@@ -20,7 +20,7 @@
// MODULES //
-var sub2ind = require( './../../base/sub2ind' );
+var sub2ind = require( './../../../base/sub2ind' );
// MAIN //
diff --git a/fancy/lib/slice_strides.js b/base/slice/lib/slice_strides.js
similarity index 65%
rename from fancy/lib/slice_strides.js
rename to base/slice/lib/slice_strides.js
index d53e4b09..f44b466e 100644
--- a/fancy/lib/slice_strides.js
+++ b/base/slice/lib/slice_strides.js
@@ -26,10 +26,20 @@
* @private
* @param {MultiSlice} slice - normalized multi-slice object
* @param {IntegerArray} strides - array strides
-* @param {NonNegativeIntegerArray} sdims - indices of non-reduced dimensions
+* @param {NonNegativeIntegerArray} rdims - indices of non-reduced dimensions
* @returns {IntegerArray} slice strides
+*
+* @example
+* var Slice = require( '@stdlib/slice/ctor' );
+* var MultiSlice = require( '@stdlib/slice/multi' );
+*
+* var s = new MultiSlice( new Slice( 2, 3, 1 ), new Slice( 10, null, -2 ) );
+* // returns
+*
+* var strides = slice2strides( s, [ 8, 2 ], [ 1 ] );
+* // returns [ -4 ]
*/
-function sliceStrides( slice, strides, sdims ) {
+function slice2strides( slice, strides, rdims ) {
var data;
var out;
var i;
@@ -37,9 +47,9 @@ function sliceStrides( slice, strides, sdims ) {
data = slice.data;
out = [];
- for ( i = 0; i < sdims.length; i++ ) {
- j = sdims[ i ];
- out.push( strides[j]*data[j].step );
+ for ( i = 0; i < rdims.length; i++ ) {
+ j = rdims[ i ];
+ out.push( strides[j] * data[j].step );
}
return out;
}
@@ -47,4 +57,4 @@ function sliceStrides( slice, strides, sdims ) {
// EXPORTS //
-module.exports = sliceStrides;
+module.exports = slice2strides;
diff --git a/base/slice/package.json b/base/slice/package.json
new file mode 100644
index 00000000..05c21cb7
--- /dev/null
+++ b/base/slice/package.json
@@ -0,0 +1,65 @@
+{
+ "name": "@stdlib/ndarray/base/slice",
+ "version": "0.0.0",
+ "description": "Return a read-only view of an input ndarray.",
+ "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"
+ ]
+}
diff --git a/base/slice/test/test.js b/base/slice/test/test.js
new file mode 100644
index 00000000..6ebc4353
--- /dev/null
+++ b/base/slice/test/test.js
@@ -0,0 +1,35 @@
+/**
+* @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 tape = require( 'tape' );
+var slice = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof slice, 'function', 'main export is a function' );
+ t.end();
+});
+
+// TODO: add tests
diff --git a/dist/index.js b/dist/index.js
index 691759d5..d7e05a0d 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1,4 +1,4 @@
-"use strict";var P=function(r,a){return function(){return a||r((a={exports:{}}).exports,a),a.exports}};var ci=P(function(Hk,li){"use strict";function Yp(r){var a,e,i,t;for(a=r.length,e=[],t=0;t=0;t--)e[t]=i,i*=r[t];return e}function Kp(r){var a,e,i;for(a=[],e=1,i=0;i=0;t--)a[t]=i,i*=r[t];return a}function Jp(r,a){var e,i;for(e=1,i=0;it&&(i=!1),i||a)t=v;else return 0;return i&&a?3:i?1:2}Si.exports=r3});var wa=P(function(iI,wi){"use strict";var a3=ji();wi.exports=a3});var Ei=P(function(vI,_i){"use strict";function e3(r){var a,e,i;if(a=r.length,a===0)return 0;for(e=1,i=0;i0?v+=n*(r[s]-1):n<0&&(t+=n*(r[s]-1))}return[t,v]}Qi.exports=E3});var av=P(function(gI,rv){"use strict";function O3(r,a,e,i){var t,v,n,s,u;for(t=r.length,v=e,n=e,u=0;u0?n+=s*(r[u]-1):s<0&&(v+=s*(r[u]-1))}return i[0]=v,i[1]=n,i}rv.exports=O3});var sa=P(function(bI,iv){"use strict";var T3=require("@stdlib/utils/define-nonenumerable-read-only-property"),ev=$i(),k3=av();T3(ev,"assign",k3);iv.exports=ev});var tv=P(function(SI,vv){"use strict";var I3=sa();function A3(r,a,e,i){var t=I3(a,e,i);return t[0]>=0&&t[1]=0;n--)v=r%e[n],r-=v,r/=e[n],t+=v*a[n];return this._accessors?this._buffer.get(t):this._buffer[t]}Sv.exports=Y3});var _v=P(function(RI,wv){"use strict";function K3(r,a){var e,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(a,this._offset+r):this._buffer[this._offset+r]=a,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(a,this._offset-r):this._buffer[this._offset-r]=a,this}if(i=this._shape,e=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*e[s];return this._accessors?this._buffer.set(a,v):this._buffer[v]=a,this}wv.exports=K3});var Ov=P(function(DI,Ev){"use strict";function Z3(){var r,a;for(r=this._offset,a=0;a=0;n--)v=this.iget(this._length-1-n),r+=me(v)+", "+he(v),n>0&&(r+=", ");else for(n=2;n>=0;n--)r+=this.iget(this._length-1-n),n>0&&(r+=", ")}if(e=Q3[this.dtype],i+=H3(e,"{{data}}",r),i+=", ",a===0?i+="[]":i+="[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",a===0)i+="0";else for(n=0;na?a:r}at.exports=Gx});var be=P(function(HI,it){"use strict";var Jx=et();it.exports=Jx});var tt=P(function(QI,vt){"use strict";function Xx(r,a){var e=a+1;return r<0?(r+=e,r<0&&(r%=e,r!==0&&(r+=e)),r):(r>a&&(r-=e,r>a&&(r%=e)),r)}vt.exports=Xx});var Se=P(function($I,st){"use strict";var Wx=tt();st.exports=Wx});var nt=P(function(rA,ot){"use strict";var Hx=be(),Qx=Se(),$x=require("@stdlib/string/format");function rm(r,a,e){if(e==="clamp")return Hx(r,a);if(e==="wrap")return Qx(r,a);if(r<0||r>a)throw new RangeError($x("invalid argument. Index must be on the interval: [0, %f]. Value: `%f`.",a,r));return r}ot.exports=rm});var ha=P(function(aA,ut){"use strict";var am=nt();ut.exports=am});var lt=P(function(eA,dt){"use strict";var em=require("@stdlib/assert/is-integer").isPrimitive,im=ha(),vm=Qr(),tm=require("@stdlib/string/format"),ft=vm.prototype.iget;function sm(r){if(this._ndims>0){if(!em(r))throw new TypeError(tm("invalid argument. Index must be an integer. Value: `%s`.",r));return r=im(r,this._length-1,this._mode),ft.call(this,r)}return ft.call(this)}dt.exports=sm});var pt=P(function(iA,yt){"use strict";var om=require("@stdlib/assert/is-integer").isPrimitive,nm=ha(),um=Qr(),fm=require("@stdlib/string/format"),ct=um.prototype.iset;function dm(r,a){if(this._flags.READONLY)throw new Error("invalid invocation. Cannot write to a read-only array.");if(this._ndims>0){if(!om(r))throw new TypeError(fm("invalid argument. Index must be an integer. Value: `%s`.",r));r=nm(r,this._length-1,this._mode),ct.call(this,r,a)}else ct.call(this,r);return this}yt.exports=dm});var ht=P(function(vA,mt){"use strict";var lm=require("@stdlib/assert/is-integer").isPrimitive,cm=ha(),xt=require("@stdlib/string/format");function ym(){var r,a,e,i;if(arguments.length!==this._ndims)throw new RangeError(xt("invalid arguments. Number of indices must match the number of dimensions. ndims: `%u`. nargs: `%u`.",this._ndims,arguments.length));for(r=this._offset,e=this._submode.length,i=0;i0))throw new TypeError($r("invalid argument. Third argument must be an array-like object containing nonnegative integers. Value: `%s`.",e));if(s=e.length,s>Rt)throw new RangeError($r("invalid argument. Number of dimensions must not exceed %u due to stack limits. Value: `%u`.",Rt,s));if(!km(i))throw new TypeError($r("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($r("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($r("invalid argument. Fourth argument must contain a single element equal to 0. Value: `%d`.",i[0]))}if(!Tm(t))throw new TypeError($r("invalid argument. Fifth argument must be a nonnegative integer. Value: `%s`.",t));if(!Im(v))throw new TypeError($r("invalid argument. Sixth argument must be a supported order. Value: `%s`.",v));if(s>0&&!Nm(a.length,e,i,t)&&zm(e)>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=Vm,u.readonly=Um,arguments.length>6&&(f=Mm(u,n),f))throw f;return this._mode=u.mode,u.submode===void 0&&(u.submode=[this._mode]),this._submode=u.submode,o=zt(e,s),d=zt(i,s||1),Dt.call(this,r,a,o,d,t,v),this._flags.READONLY=u.readonly,this}Dm(ra,Dt);ka(ra,"name","ndarray");ka(ra.prototype,"get",Pm);ka(ra.prototype,"iget",Cm);ka(ra.prototype,"set",Bm);ka(ra.prototype,"iset",Lm);Ct.exports=ra});var da=P(function(dA,Pt){"use strict";var Fm=Lt();Pt.exports=Fm});var Bt=P(function(lA,Ym){Ym.exports=["none","equiv","safe","same-kind","unsafe"]});var Vt=P(function(cA,Mt){"use strict";var Km=Bt();function Zm(){return Km.slice()}Mt.exports=Zm});var Ft=P(function(yA,Ut){"use strict";function Gm(){return{none:0,equiv:1,safe:2,"same-kind":3,unsafe:4}}Ut.exports=Gm});var we=P(function(pA,Kt){"use strict";var Jm=require("@stdlib/utils/define-nonenumerable-read-only-property"),Yt=Vt(),Xm=Ft();Jm(Yt,"enum",Xm);Kt.exports=Yt});var Jt=P(function(xA,Gt){"use strict";var Wm=we(),Zt=Wm(),Hm=Zt.length;function Qm(r){var a;for(a=0;a0}fs.exports=S4});var Oe=P(function(TA,ls){"use strict";var j4=ds();ls.exports=j4});var cs=P(function(kA,w4){w4.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 xs=P(function(IA,ps){"use strict";var ys=require("@stdlib/utils/keys"),_4=require("@stdlib/assert/has-own-property"),E4=aa(),Ga=cs(),Za;function O4(){var r,a,e,i,t,v,n,s,u;for(e={},r=ys(Ga),a=r.length,u=0;u0}hs.exports=z4});var ke=P(function(zA,gs){"use strict";var R4=qs();gs.exports=R4});var Ss=P(function(RA,bs){"use strict";var D4=Oe(),C4=ke();function L4(r,a,e){return e==="unsafe"||r===a?!0:e==="none"||e==="equiv"?!1:e==="safe"?D4(r,a):C4(r,a)}bs.exports=L4});var Ie=P(function(DA,js){"use strict";var P4=Ss();js.exports=P4});var _s=P(function(CA,ws){"use strict";var B4=require("@stdlib/buffer/ctor"),M4=require("@stdlib/array/float64"),V4=require("@stdlib/array/float32"),U4=require("@stdlib/array/int16"),F4=require("@stdlib/array/int32"),Y4=require("@stdlib/array/int8"),K4=require("@stdlib/array/uint16"),Z4=require("@stdlib/array/uint32"),G4=require("@stdlib/array/uint8"),J4=require("@stdlib/array/uint8c"),X4=require("@stdlib/array/complex64"),W4=require("@stdlib/array/complex128"),H4={binary:B4,float64:M4,float32:V4,generic:Array,int16:U4,int32:F4,int8:Y4,uint16:K4,uint32:Z4,uint8:G4,uint8c:J4,complex64:X4,complex128:W4};ws.exports=H4});var Os=P(function(LA,Es){"use strict";var Q4=_s();function $4(r){return Q4[r]||null}Es.exports=$4});var Aa=P(function(PA,Ts){"use strict";var rh=Os();Ts.exports=rh});var Is=P(function(BA,ks){"use strict";function ah(r){var a;for(a=0;a=0&&r.length=p6(a)}fo.exports=x6});var yo=P(function(e9,co){"use strict";var m6=lo();co.exports=m6});var mo=P(function(i9,xo){"use strict";var po=require("@stdlib/math/base/special/abs");function h6(r){var a,e,i,t;if(a=r.length,a===0)return!1;for(e=po(r[0]),t=1;te)return!1;e=i}return!0}Qo.exports=tq});var Pe=P(function(E9,rn){"use strict";var sq=$o();rn.exports=sq});var en=P(function(O9,an){"use strict";var oq=Na(),nq=ia(),uq=Pe();function fq(r,a,e){return nq(a)!==0&&uq(a)&&oq(r,a,e)}an.exports=fq});var tn=P(function(T9,vn){"use strict";var dq=en();vn.exports=dq});var on=P(function(k9,sn){"use strict";var lq=require("@stdlib/array/base/assert/contains").factory,cq=Fr(),yq=lq(cq("signed_integer"));sn.exports=yq});var Be=P(function(I9,nn){"use strict";var pq=on();nn.exports=pq});var fn=P(function(A9,un){"use strict";var xq=require("@stdlib/array/base/assert/contains").factory,mq=Fr(),hq=xq(mq("unsigned_integer"));un.exports=hq});var Me=P(function(N9,dn){"use strict";var qq=fn();dn.exports=qq});var cn=P(function(z9,ln){"use strict";var Dr=require("@stdlib/utils/define-read-only-property"),Rr={};Dr(Rr,"isAllowedDataTypeCast",Ie());Dr(Rr,"isBufferLengthCompatible",xe());Dr(Rr,"isBufferLengthCompatibleShape",yo());Dr(Rr,"isCastingMode",_e());Dr(Rr,"isColumnMajor",Ae());Dr(Rr,"isColumnMajorContiguous",_o());Dr(Rr,"isComplexFloatingPointDataType",Ne());Dr(Rr,"isContiguous",No());Dr(Rr,"isDataType",_a());Dr(Rr,"isFloatingPointDataType",ze());Dr(Rr,"isIndexMode",Ta());Dr(Rr,"isIntegerDataType",Re());Dr(Rr,"isNumericDataType",De());Dr(Rr,"isOrder",ma());Dr(Rr,"isReadOnly",za());Dr(Rr,"isRealDataType",Ce());Dr(Rr,"isRealFloatingPointDataType",Le());Dr(Rr,"isRowMajor",Pe());Dr(Rr,"isRowMajorContiguous",tn());Dr(Rr,"isSafeDataTypeCast",Oe());Dr(Rr,"isSameKindDataTypeCast",ke());Dr(Rr,"isSignedIntegerDataType",Be());Dr(Rr,"isSingleSegmentCompatible",Na());Dr(Rr,"isUnsignedIntegerDataType",Me());ln.exports=Rr});var pn=P(function(R9,yn){"use strict";function gq(r,a){var e,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<=e));)r[n+1]=o,a[s+1]=a[s],n-=1,s-=1;r[n+1]=u,a[s+1]=f,t+=1,v+=1}}yn.exports=gq});var hn=P(function(D9,mn){"use strict";var bq=require("@stdlib/array/base/zero-to"),Sq=require("@stdlib/array/base/copy-indexed"),Ha=require("@stdlib/array/base/take"),jq=require("@stdlib/array/base/filled"),Ve=wa(),wq=pn(),xn=3;function _q(r,a,e,i){var t,v,n,s,u,f,o,d,x,h;if(t=bq(r.length),f=Ve(a),o=Ve(e),d=Ve(i),v=jq([],4),v[f].push(a),v[o].push(e),v[d].push(i),n=v[0].length,n===xn)u=a;else if(n===xn-1){for(x=1;x<4;x++)if(v[x].length){u=v[x][0];break}}else{for(h=0,x=1;x<4;x++)s=v[x].length,s>=n&&(n=s,h=x);u=v[h][0]}return u=Sq(u),wq(u,t),r=Ha(r,t),a=a===u?u:Ha(a,t),e=e===u?u:Ha(e,t),i=i===u?u:Ha(i,t),{sh:r,sx:a,sy:e,sz:i}}mn.exports=_q});var gn=P(function(C9,qn){"use strict";var Eq=hn();qn.exports=Eq});var Sn=P(function(L9,bn){"use strict";var Oq={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};bn.exports=Oq});var wn=P(function(P9,jn){"use strict";var Ue=oa(),Qa=Sn();function Tq(r,a,e){var i,t,v;return i=Ue(r),t=Ue(a),v=Ue(e),i===null||t===null||v===null?Qa.BLOCK_SIZE_IN_ELEMENTS:i>t&&i>v?Qa.BLOCK_SIZE_IN_BYTES/i|0:t>v?Qa.BLOCK_SIZE_IN_BYTES/t|0:Qa.BLOCK_SIZE_IN_BYTES/v|0}jn.exports=Tq});var En=P(function(B9,_n){"use strict";var kq=wn();_n.exports=kq});var kn=P(function(M9,Tn){"use strict";var Iq=require("@stdlib/string/format"),$a=require("@stdlib/math/base/special/trunc"),On=require("@stdlib/math/base/special/abs");function Aq(r,a,e,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(Iq("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=a[d],o<0?(f=$a(t/o),t-=f*o,f+=r[d]-1):(f=$a(t/o),t-=f*o),u+=f*On(o);return u}for(d=0;d=0;f--)if(o=s-n+f,!(o<0)){if(u=t[o],i=a[f],i!==0&&if&&(f=a[o]);for(o=0;o=0;){for(v=a[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}e[o]=i,o-=1}return e}Mn.exports=Kq});var Fn=P(function(G9,Un){"use strict";var Zq=Vn();Un.exports=Zq});var Kn=P(function(J9,Yn){"use strict";var Gq=Ia(),Jq=Ja();function Xq(r){var a=Jq(r);return a?Gq(a):null}Yn.exports=Xq});var Gn=P(function(X9,Zn){"use strict";var Wq=Kn();Zn.exports=Wq});var Xn=P(function(W9,Jn){"use strict";function Hq(){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"}}Jn.exports=Hq});var Qn=P(function(H9,Hn){"use strict";var Qq=aa(),Wn=Xn(),Ye;function $q(r){return arguments.length===0?Wn():(Ye===void 0&&(Ye=Wn()),Ye[Qq(r)]||null)}Hn.exports=$q});var Ke=P(function(Q9,$n){"use strict";var rg=Qn();$n.exports=rg});var iu=P(function($9,eu){"use strict";var ru=require("@stdlib/utils/object-inverse"),au=Ke(),Ze;function ag(r){return arguments.length===0?ru(au()):(Ze===void 0&&(Ze=ru(au())),Ze[r]||null)}eu.exports=ag});var tu=P(function(rN,vu){"use strict";var eg=iu();vu.exports=eg});var ou=P(function(aN,su){"use strict";function ig(){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"}}su.exports=ig});var fu=P(function(eN,uu){"use strict";var vg=aa(),nu=ou(),Ge;function tg(r){return arguments.length===0?nu():(Ge===void 0&&(Ge=nu()),Ge[vg(r)]||null)}uu.exports=tg});var lu=P(function(iN,du){"use strict";var sg=fu();du.exports=sg});var yu=P(function(vN,cu){"use strict";var og=Fa(),ng=Ia();function ug(r){var a=typeof r;return a==="number"?og(r)?r:null:a==="string"?ng(r):null}cu.exports=ug});var Je=P(function(tN,pu){"use strict";var fg=yu();pu.exports=fg});var xu=P(function(sN,dg){dg.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 hu=P(function(oN,mu){"use strict";var lg=aa(),cg=xu();function yg(r){return cg[lg(r)]||null}mu.exports=yg});var gu=P(function(nN,qu){"use strict";var pg=hu();qu.exports=pg});var ju=P(function(uN,Su){"use strict";var xg=require("@stdlib/assert/is-array-like-object"),bu=require("@stdlib/assert/is-nonnegative-integer").isPrimitive,mg=aa(),Xe=require("@stdlib/string/format");function hg(r,a,e){var i,t,v,n,s,u,f,o;if(!xg(r))throw new TypeError(Xe("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!bu(a))throw new TypeError(Xe("invalid argument. Second argument must be a nonnegative integer. Value: `%s`.",a));if(!bu(e))throw new TypeError(Xe("invalid argument. Third argument must be a nonnegative integer. Value: `%s`.",e));if(i=r.length,i===0)throw new RangeError("invalid argument. First argument must contain at least one element.");if(s=a+e,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*a,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=jg(a),n=gg(a,e)):(v=1,n=[0]),r==="binary"?t=_g(v):t=wg(v,r),new Sg(r,t,a,n,bg(a,n),e)}_u.exports=Eg});var Tu=P(function(lN,Ou){"use strict";var Og=Eu();Ou.exports=Og});var Iu=P(function(cN,ku){"use strict";var Tg=Yr(),kg=Zr(),Ig=Br(),Ag=require("@stdlib/array/empty"),Ng=require("@stdlib/buffer/alloc-unsafe");function zg(r){var a,e,i,t,v,n,s;return s=r.dtype,v=r.shape,t=r.order,a=v.length,a>0?(e=Ig(v),n=Tg(v,t)):(e=1,n=[0]),s==="binary"?i=Ng(e):i=Ag(e,s),new r.constructor(s,i,v,n,kg(v,n),t)}ku.exports=zg});var Nu=P(function(yN,Au){"use strict";var Rg=Iu();Au.exports=Rg});var Du=P(function(pN,Ru){"use strict";var Dg=za(),zu=require("@stdlib/string/format");function Cg(r,a){var e,i,t,v,n,s,u;if(v=r.shape,n=r.strides,t=r.order,s=v.length,e=[],i=[],a<0){if(a<-s-1)throw new RangeError(zu("invalid argument. Specified axis is out-of-bounds. Must be on the interval: [-%u-1, %u]. Value: `%d`.",s,s,a));a+=s+1}else if(a>s)throw new RangeError(zu("invalid argument. Specified axis is out-of-bounds. Must be on the interval: [-%u-1, %u]. Value: `%d`.",s,s,a));if(a===0)for(i.push(1),e.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(Zg("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",u,t));if(e===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=a[d],o<0?(f=re(t/o),t-=f*o,n[d]=r[d]-1+f):(f=re(t/o),t-=f*o,n[d]=f);return n}for(d=0;d0&&(t+=a[v]*(r[v]-1))}return t}Gu.exports=Qg});var Wu=P(function(jN,Xu){"use strict";var $g=Ju();Xu.exports=$g});var $u=P(function(wN,Qu){"use strict";var Hu=Fe();function rb(r,a){var e,i,t;if(i=a.length,e=r.shape,e.length===i){for(t=0;t=0&&(o=r[n],i=o<0?-o:o,!(i<=e));)r[n+1]=o,a[s+1]=a[s],n-=1,s-=1;r[n+1]=u,a[s+1]=f,t+=1,v+=1}}hf.exports=hb});var bf=P(function(DN,gf){"use strict";var qb=require("@stdlib/array/base/zero-to"),gb=require("@stdlib/array/base/copy-indexed"),bb=require("@stdlib/array/base/take"),Sb=qf();function jb(r,a){var e;return e=qb(r.length),a=gb(a),Sb(a,e),r=bb(r,e),{sh:r,sx:a}}gf.exports=jb});var Mr=P(function(CN,Sf){"use strict";var wb=bf();Sf.exports=wb});var wf=P(function(LN,jf){"use strict";var _b={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};jf.exports=_b});var Of=P(function(PN,Ef){"use strict";var Eb=oa(),_f=wf();function Ob(r){var a=Eb(r);return a===null?_f.BLOCK_SIZE_IN_ELEMENTS:_f.BLOCK_SIZE_IN_BYTES/a|0}Ef.exports=Ob});var Vr=P(function(BN,Tf){"use strict";var Tb=Of();Tf.exports=Tb});var If=P(function(MN,kf){"use strict";var kb=Mr(),Ib=Vr();function Ab(r,a){var e,i,t,v,n,s,u,f,o,d,x,h,b,p,j,y,q;for(q=kb(r.shape,r.strides),u=q.sh,d=q.sx,e=Ib(r.dtype),x=r.offset,i=r.data,v=d[0],t=r.accessors[1],y=u[1];y>0;)for(y0;)for(j0;)for(E0;)for(m0;)for(g0;)for(S0;)for(O0;)for(l0;)for(_0;)for(k0;)for(N0;)for(A0;)for(T0;)for(I0;)for(B0;)for(C0;)for(z0;)for(D0;)for(R0;)for(k0;)for(F0;)for(U0;)for(V0;)for(M0;)for(L0;)for(B0;)for(C0;)for(Z0;)for(J0;)for(K0;)for(G0;)for(Y0;)for(F0;)for(U0;)for(V0;)for(Q0;)for($0;)for(W0;)for(H0;)for(X0;)for(Z0;)for(J0;)for(K0;)for(G0;)for(er0;)for(tr0;)for(ar0;)for(ir0;)for(rr0;)for(Q0;)for($0;)for(W0;)for(H0;)for(X0;)for(j0;)for(p0;)for(m0;)for(g0;)for(w0;)for(O0;)for(l0;)for(_0;)for(c0;)for(N0;)for(A0;)for(T0;)for(I0;)for(S0;)for(C0;)for(z0;)for(D0;)for(R0;)for(k0;)for(N0;)for(U0;)for(V0;)for(M0;)for(L0;)for(B0;)for(C0;)for(z0;)for(J0;)for(K0;)for(G0;)for(Y0;)for(F0;)for(U0;)for(V0;)for(M0;)for($0;)for(W0;)for(H0;)for(X0;)for(Z0;)for(J0;)for(K0;)for(G0;)for(Y0;)for(tr0;)for(ar0;)for(ir0;)for(rr0;)for(Q0;)for($0;)for(W0;)for(H0;)for(X0;)for(Z=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(M5("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",s,t));if(u=e,i==="column-major"){for(o=0;o=0;o--)f=t%r[o],t-=f,t/=r[o],u+=f*a[o];return u}z0.exports=V5});var la=P(function(xz,D0){"use strict";var U5=R0();D0.exports=U5});var L0=P(function(mz,C0){"use strict";var F5=Br(),Y5=la(),K5="throw";function Z5(r,a){var e,i,t,v,n,s,u,f,o;for(n=r.shape,t=F5(n),e=r.data,s=r.strides,u=r.offset,i=r.order,v=r.accessors[1],o=0;o=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(tj("invalid argument. Subscripts must not exceed array dimensions. Subscript: `%u`. Value: `%d`.",d,o));f=r[d],f<0&&a===0?s-=o*f:s+=o*f}return s}el.exports=sj});var ei=P(function(aR,vl){"use strict";var oj=il();vl.exports=oj});var ol=P(function(eR,sl){"use strict";function tl(r,a,e,i,t,v){var n,s,u,f,o;if(v>=a.length)return r.accessors[0](r.data,i);for(u=[],f=a[v],n=e[v],o=0;o=0&&(o=r[n],i=o<0?-o:o,!(i<=e));)r[n+1]=o,a[s+1]=a[s],n-=1,s-=1;r[n+1]=u,a[s+1]=f,t+=1,v+=1}}pl.exports=pj});var ql=P(function(nR,hl){"use strict";var xj=require("@stdlib/array/base/zero-to"),mj=require("@stdlib/array/base/copy-indexed"),ml=require("@stdlib/array/base/take"),hj=xl();function qj(r,a,e){var i;return i=xj(r.length),a=mj(a),hj(a,i),r=ml(r,i),e=ml(e,i),{sh:r,sx:a,sy:e}}hl.exports=qj});var Ir=P(function(uR,gl){"use strict";var gj=ql();gl.exports=gj});var Sl=P(function(fR,bl){"use strict";var bj={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};bl.exports=bj});var _l=P(function(dR,wl){"use strict";var jl=oa(),vi=Sl();function Sj(r,a){var e,i;return e=jl(r),i=jl(a),e===null||i===null?vi.BLOCK_SIZE_IN_ELEMENTS:e>i?vi.BLOCK_SIZE_IN_BYTES/e|0:vi.BLOCK_SIZE_IN_BYTES/i|0}wl.exports=Sj});var Ar=P(function(lR,El){"use strict";var jj=_l();El.exports=jj});var Tl=P(function(cR,Ol){"use strict";var wj=Ir(),_j=Ar();function Ej(r,a,e){var i,t,v,n,s,u,f,o,d,x,h,b,p,j,y,q,w,g,m,E,c,_,l,O,S;for(S=wj(r.shape,r.strides,a.strides),b=S.sh,y=S.sx,q=S.sy,i=_j(r.dtype,a.dtype),w=r.offset,g=a.offset,t=r.data,v=a.data,u=y[0],o=q[0],n=r.accessors[0],s=a.accessors[1],O=b[1];O>0;)for(O0;)for(l0;)for(R0;)for(k0;)for(N0;)for(V0;)for(M0;)for(L0;)for(B0;)for(Z0;)for(J0;)for(K0;)for(G0;)for(Y0;)for(ir0;)for(rr0;)for(Q0;)for($0;)for(W0;)for(H0;)for(nr0;)for(or0;)for(sr0;)for(vr0;)for(er0;)for(tr0;)for(ar0;)for(pr0;)for(lr0;)for(yr0;)for(cr0;)for(dr0;)for(fr0;)for(ur0;)for(nr0;)for(jr0;)for(Sr0;)for(mr0;)for(wr0;)for(hr0;)for(gr0;)for(xr0;)for(pr0;)for(lr0;)for(zr0;)for(Nr0;)for(kr0;)for(Tr0;)for(Or0;)for(Er0;)for(_r0;)for(jr0;)for(Sr0;)for(mr0;)for(_0;)for(c0;)for(N