diff --git a/base/lib/index.js b/base/lib/index.js
index ff978c33..a793104a 100644
--- a/base/lib/index.js
+++ b/base/lib/index.js
@@ -625,6 +625,15 @@ setReadOnly( ns, 'sliceAssign', require( './../../base/slice-assign' ) );
*/
setReadOnly( ns, 'sliceDimension', require( './../../base/slice-dimension' ) );
+/**
+* @name sliceTo
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/slice-to}
+*/
+setReadOnly( ns, 'sliceTo', require( './../../base/slice-to' ) );
+
/**
* @name strides
* @memberof ns
diff --git a/base/slice-to/README.md b/base/slice-to/README.md
new file mode 100644
index 00000000..0eac02b3
--- /dev/null
+++ b/base/slice-to/README.md
@@ -0,0 +1,169 @@
+
+
+# sliceTo
+
+> Return a truncated view of an input ndarray.
+
+
+
+
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var sliceTo = require( '@stdlib/ndarray/base/slice-to' );
+```
+
+#### sliceTo( x, stop, strict, writable )
+
+Returns a truncated view of an input ndarray.
+
+```javascript
+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 = [ 2, null ];
+var y = sliceTo( x, s, false, false );
+// returns
+
+sh = y.shape;
+// returns [ 2, 2 ]
+
+arr = ndarray2array( y );
+// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]
+```
+
+The function accepts the following arguments:
+
+- **x**: input ndarray.
+- **stop**: an array of ending indices (exclusive). Each element must be either `null`, `undefined`, or an integer. A value of `null` or `undefined` indicates to include all elements along a corresponding dimension. A negative integer indicates to resolve an ending index relative to the last element along a corresponding dimension, with the last element having index `-1`.
+- **strict**: boolean indicating whether to enforce strict bounds checking.
+- **writable**: boolean indicating whether a returned ndarray should be writable.
+
+
+
+
+
+
+
+
+
+## Notes
+
+- The `writable` parameter **only** applies to ndarray constructors supporting **read-only** instances.
+
+
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var array = require( '@stdlib/ndarray/array' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var zeroTo = require( '@stdlib/array/base/zero-to' );
+var sliceTo = require( '@stdlib/ndarray/base/slice-to' );
+
+// Create a linear ndarray buffer:
+var buf = zeroTo( 27 );
+
+// Create an ndarray:
+var x = array( buf, {
+ 'shape': [ 3, 3, 3 ]
+});
+
+// Get the first two rows of each matrix:
+var y1 = sliceTo( x, [ null, 2, null ], false, false );
+// returns
+
+var a1 = ndarray2array( y1 );
+// returns [ [ [ 0, 1, 2 ], [ 3, 4, 5 ] ], [ [ 9, 10, 11 ], [ 12, 13, 14 ] ], [ [ 18, 19, 20 ], [ 21, 22, 23 ] ] ]
+
+// Get the first two rows and columns of each matrix:
+var y2 = sliceTo( x, [ null, 2, 2 ], false, false );
+// returns
+
+var a2 = ndarray2array( y2 );
+// returns [ [ [ 0, 1 ], [ 3, 4 ] ], [ [ 9, 10 ], [ 12, 13 ] ], [ [ 18, 19 ], [ 21, 22 ] ] ]
+
+// Get the first two 2x2 matrices:
+var y3 = sliceTo( x, [ 2, 2, 2 ], false, false );
+// returns
+
+var a3 = ndarray2array( y3 );
+// returns [ [ [ 0, 1 ], [ 3, 4 ] ], [ [ 9, 10 ], [ 12, 13 ] ] ]
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/base/slice-to/benchmark/benchmark.js b/base/slice-to/benchmark/benchmark.js
new file mode 100644
index 00000000..60cb45ae
--- /dev/null
+++ b/base/slice-to/benchmark/benchmark.js
@@ -0,0 +1,746 @@
+/**
+* @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 baseEmpty = require( './../../../base/empty' );
+var empty = require( './../../../empty' );
+var pkg = require( './../package.json' ).name;
+var sliceTo = 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 = [];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1 ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1 ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ -20 ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ -20 ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, 1 ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, 1 ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ -20, null ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ -20, null ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, 1, 1 ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, 1, 1 ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, -20, null ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, -20, null ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, 1, 1, 1 ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, 1, 1, 1 ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, 1, -20, null ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, 1, -20, null ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, 1, 1, 1, 1 ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, 1, 1, 1, 1 ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, 1, 1, -20, null ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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 = [ 1, 1, 1, -20, null ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = sliceTo( values[ i%values.length ], s, false, 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-to/docs/repl.txt b/base/slice-to/docs/repl.txt
new file mode 100644
index 00000000..6484c140
--- /dev/null
+++ b/base/slice-to/docs/repl.txt
@@ -0,0 +1,46 @@
+
+{{alias}}( x, stop, strict, writable )
+ Returns a truncated view of an input ndarray.
+
+ Parameters
+ ----------
+ x: ndarray
+ Input array.
+
+ stop: Array
+ Ending indices (exclusive). If an element is either `null` or
+ `undefined`, the function returns a view containing all elements along
+ that dimension. A negative integer indicates to resolve an ending index
+ relative to the last element along a corresponding dimension, with the
+ last element having index `-1`.
+
+ strict: boolean
+ Boolean indicating whether to enforce strict bounds checking.
+
+ writable: boolean
+ Boolean indicating whether a returned ndarray should be writable. This
+ parameter only applies to ndarray constructors which support read-only
+ instances.
+
+ Returns
+ -------
+ out: ndarray
+ Output array view.
+
+ Examples
+ --------
+ > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] )
+
+ > x.shape
+ [ 2, 2 ]
+ > var s = [ 1, 1 ];
+ > var y = {{alias}}( x, s, false, false )
+
+ > y.shape
+ [ 1, 1 ]
+ > {{alias:@stdlib/ndarray/to-array}}( y )
+ [ [ 1 ] ]
+
+ See Also
+ --------
+
diff --git a/base/slice-to/docs/types/index.d.ts b/base/slice-to/docs/types/index.d.ts
new file mode 100644
index 00000000..3093b5dc
--- /dev/null
+++ b/base/slice-to/docs/types/index.d.ts
@@ -0,0 +1,573 @@
+/*
+* @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 { ArrayLike } from '@stdlib/types/array';
+
+/**
+* Ending index.
+*
+* ## Notes
+*
+* - A value of `null` or `undefined` indicates to include all elements along a corresponding dimension.
+* - A negative integer indicates to resolve an ending index relative to the last element along a corresponding dimension, with the last element having index `-1`.
+*/
+type StopArgument = null | undefined | number;
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param x - input array
+* @param stop - ending indices (exclusive)
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param writable - boolean indicating whether a returned array should be writable
+* @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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]
+*/
+declare function sliceTo( x: float64ndarray, stop: ArrayLike, strict: boolean, writable: boolean ): float64ndarray;
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param x - input array
+* @param stop - ending indices (exclusive)
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param writable - boolean indicating whether a returned array should be writable
+* @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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]
+*/
+declare function sliceTo( x: float32ndarray, stop: ArrayLike, strict: boolean, writable: boolean ): float32ndarray;
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param x - input array
+* @param stop - ending indices (exclusive)
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param writable - boolean indicating whether a returned array should be writable
+* @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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 1, 2 ], [ 3, 4 ] ]
+*/
+declare function sliceTo( x: int32ndarray, stop: ArrayLike, strict: boolean, writable: boolean ): int32ndarray;
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param x - input array
+* @param stop - ending indices (exclusive)
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param writable - boolean indicating whether a returned array should be writable
+* @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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 1, 2 ], [ 3, 4 ] ]
+*/
+declare function sliceTo( x: int16ndarray, stop: ArrayLike, strict: boolean, writable: boolean ): int16ndarray;
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param x - input array
+* @param stop - ending indices (exclusive)
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param writable - boolean indicating whether a returned array should be writable
+* @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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 1, 2 ], [ 3, 4 ] ]
+*/
+declare function sliceTo( x: int8ndarray, stop: ArrayLike, strict: boolean, writable: boolean ): int8ndarray;
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param x - input array
+* @param stop - ending indices (exclusive)
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param writable - boolean indicating whether a returned array should be writable
+* @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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 1, 2 ], [ 3, 4 ] ]
+*/
+declare function sliceTo( x: uint32ndarray, stop: ArrayLike, strict: boolean, writable: boolean ): uint32ndarray;
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param x - input array
+* @param stop - ending indices (exclusive)
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param writable - boolean indicating whether a returned array should be writable
+* @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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 1, 2 ], [ 3, 4 ] ]
+*/
+declare function sliceTo( x: uint16ndarray, stop: ArrayLike, strict: boolean, writable: boolean ): uint16ndarray;
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param x - input array
+* @param stop - ending indices (exclusive)
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param writable - boolean indicating whether a returned array should be writable
+* @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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 1, 2 ], [ 3, 4 ] ]
+*/
+declare function sliceTo( x: uint8ndarray, stop: ArrayLike, strict: boolean, writable: boolean ): uint8ndarray;
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param x - input array
+* @param stop - ending indices (exclusive)
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param writable - boolean indicating whether a returned array should be writable
+* @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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 1, 2 ], [ 3, 4 ] ]
+*/
+declare function sliceTo( x: uint8cndarray, stop: ArrayLike, strict: boolean, writable: boolean ): uint8cndarray;
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param x - input array
+* @param stop - ending indices (exclusive)
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param writable - boolean indicating whether a returned array should be writable
+* @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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*/
+declare function sliceTo( x: complex128ndarray, stop: ArrayLike, strict: boolean, writable: boolean ): complex128ndarray;
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param x - input array
+* @param stop - ending indices (exclusive)
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param writable - boolean indicating whether a returned array should be writable
+* @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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*/
+declare function sliceTo( x: complex64ndarray, stop: ArrayLike, strict: boolean, writable: boolean ): complex64ndarray;
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param x - input array
+* @param stop - ending indices (exclusive)
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param writable - boolean indicating whether a returned array should be writable
+* @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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 1, 2 ], [ 3, 4 ] ]
+*/
+declare function sliceTo( x: genericndarray, stop: ArrayLike, strict: boolean, writable: boolean ): genericndarray;
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param x - input arraToy
+* @param stop - ending indices (exclusive)
+* @param strict - boolean indicating whether to enforce strict bounds checking
+* @param writable - boolean indicating whether a returned array should be writable
+* @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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 1, 2 ], [ 3, 4 ] ]
+*/
+declare function sliceTo( x: typedndarray, stop: ArrayLike, strict: boolean, writable: boolean ): typedndarray;
+
+
+// EXPORTS //
+
+export = sliceTo;
diff --git a/base/slice-to/docs/types/test.ts b/base/slice-to/docs/types/test.ts
new file mode 100644
index 00000000..6366de0a
--- /dev/null
+++ b/base/slice-to/docs/types/test.ts
@@ -0,0 +1,141 @@
+/*
+* @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 sliceTo = require( './index' );
+
+
+// TESTS //
+
+// The function returns an ndarray...
+{
+ const order = 'row-major';
+ const sh = [ 2, 2 ];
+ const s = [ 1, null ];
+
+ sliceTo( empty( 'float64', sh, order ), s, false, false ); // $ExpectType float64ndarray
+ sliceTo( empty( 'float32', sh, order ), s, false, false ); // $ExpectType float32ndarray
+ sliceTo( empty( 'complex128', sh, order ), s, false, false ); // $ExpectType complex128ndarray
+ sliceTo( empty( 'complex64', sh, order ), s, false, false ); // $ExpectType complex64ndarray
+ sliceTo( empty( 'int32', sh, order ), s, false, false ); // $ExpectType int32ndarray
+ sliceTo( empty( 'int16', sh, order ), s, false, false ); // $ExpectType int16ndarray
+ sliceTo( empty( 'int8', sh, order ), s, false, false ); // $ExpectType int8ndarray
+ sliceTo( empty( 'uint32', sh, order ), s, false, false ); // $ExpectType uint32ndarray
+ sliceTo( empty( 'uint16', sh, order ), s, false, false ); // $ExpectType uint16ndarray
+ sliceTo( empty( 'uint8', sh, order ), s, false, false ); // $ExpectType uint8ndarray
+ sliceTo( empty( 'uint8c', sh, order ), s, false, false ); // $ExpectType uint8cndarray
+
+ sliceTo( empty( 'float64', sh, order ), s, true, true ); // $ExpectType float64ndarray
+ sliceTo( empty( 'float32', sh, order ), s, true, true ); // $ExpectType float32ndarray
+ sliceTo( empty( 'complex128', sh, order ), s, true, true ); // $ExpectType complex128ndarray
+ sliceTo( empty( 'complex64', sh, order ), s, true, true ); // $ExpectType complex64ndarray
+ sliceTo( empty( 'int32', sh, order ), s, true, true ); // $ExpectType int32ndarray
+ sliceTo( empty( 'int16', sh, order ), s, true, true ); // $ExpectType int16ndarray
+ sliceTo( empty( 'int8', sh, order ), s, true, true ); // $ExpectType int8ndarray
+ sliceTo( empty( 'uint32', sh, order ), s, true, true ); // $ExpectType uint32ndarray
+ sliceTo( empty( 'uint16', sh, order ), s, true, true ); // $ExpectType uint16ndarray
+ sliceTo( empty( 'uint8', sh, order ), s, true, true ); // $ExpectType uint8ndarray
+ sliceTo( empty( 'uint8c', sh, order ), s, true, true ); // $ExpectType uint8cndarray
+}
+
+// The compiler throws an error if the function is provided a first argument which is not an ndarray...
+{
+ const s = [ 1, null ];
+
+ sliceTo( '10', s, false, false ); // $ExpectError
+ sliceTo( 10, s, false, false ); // $ExpectError
+ sliceTo( false, s, false, false ); // $ExpectError
+ sliceTo( true, s, false, false ); // $ExpectError
+ sliceTo( null, s, false, false ); // $ExpectError
+ sliceTo( [], s, false, false ); // $ExpectError
+ sliceTo( {}, s, false, false ); // $ExpectError
+ sliceTo( ( x: number ): number => x, s, false, false ); // $ExpectError
+
+ sliceTo( '10', s, true, true ); // $ExpectError
+ sliceTo( 10, s, true, true ); // $ExpectError
+ sliceTo( false, s, true, true ); // $ExpectError
+ sliceTo( true, s, true, true ); // $ExpectError
+ sliceTo( null, s, true, true ); // $ExpectError
+ sliceTo( [], s, true, true ); // $ExpectError
+ sliceTo( {}, s, true, true ); // $ExpectError
+ sliceTo( ( x: number ): number => x, s, true, true ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a second argument which is not an array of stop arguments...
+{
+ const x = empty( 'float64', [ 2, 2 ], 'row-major' );
+
+ sliceTo( x, '5', false, false ); // $ExpectError
+ sliceTo( x, 5, false, false ); // $ExpectError
+ sliceTo( x, false, false, false ); // $ExpectError
+ sliceTo( x, true, false, false ); // $ExpectError
+ sliceTo( x, null, false, false ); // $ExpectError
+ sliceTo( x, undefined, false, false ); // $ExpectError
+ sliceTo( x, [ '5' ], false, false ); // $ExpectError
+ sliceTo( x, {}, false, false ); // $ExpectError
+ sliceTo( x, ( x: number ): number => x, false, false ); // $ExpectError
+
+ sliceTo( x, '5', true, true ); // $ExpectError
+ sliceTo( x, 5, true, true ); // $ExpectError
+ sliceTo( x, false, true, true ); // $ExpectError
+ sliceTo( x, true, true, true ); // $ExpectError
+ sliceTo( x, null, true, true ); // $ExpectError
+ sliceTo( x, undefined, true, true ); // $ExpectError
+ sliceTo( x, [ '5' ], true, true ); // $ExpectError
+ sliceTo( x, {}, true, true ); // $ExpectError
+ sliceTo( x, ( x: number ): number => x, true, true ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a third argument which is not a boolean...
+{
+ const x = empty( 'float64', [ 2, 2 ], 'row-major' );
+ const s = [ 1, null ];
+
+ sliceTo( x, s, '5', false ); // $ExpectError
+ sliceTo( x, s, 5, false ); // $ExpectError
+ sliceTo( x, s, null, false ); // $ExpectError
+ sliceTo( x, s, undefined, false ); // $ExpectError
+ sliceTo( x, s, [ '5' ], false ); // $ExpectError
+ sliceTo( x, s, {}, false ); // $ExpectError
+ sliceTo( x, s, ( x: number ): number => x, false ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a fourth argument which is not a boolean...
+{
+ const x = empty( 'float64', [ 2, 2 ], 'row-major' );
+ const s = [ 1, null ];
+
+ sliceTo( x, s, false, '5' ); // $ExpectError
+ sliceTo( x, s, false, 5 ); // $ExpectError
+ sliceTo( x, s, false, null ); // $ExpectError
+ sliceTo( x, s, false, undefined ); // $ExpectError
+ sliceTo( x, s, false, [ '5' ] ); // $ExpectError
+ sliceTo( x, s, false, {} ); // $ExpectError
+ sliceTo( x, s, false, ( 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 = [ 1, null ];
+
+ sliceTo( x ); // $ExpectError
+ sliceTo( x, s ); // $ExpectError
+ sliceTo( x, s, false ); // $ExpectError
+ sliceTo( x, s, false, false, {} ); // $ExpectError
+}
diff --git a/base/slice-to/examples/index.js b/base/slice-to/examples/index.js
new file mode 100644
index 00000000..02a0db14
--- /dev/null
+++ b/base/slice-to/examples/index.js
@@ -0,0 +1,56 @@
+/**
+* @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';
+
+var array = require( './../../../array' );
+var ndarray2array = require( './../../../to-array' );
+var zeroTo = require( '@stdlib/array/base/zero-to' );
+var sliceTo = require( './../lib' );
+
+// Create a linear ndarray buffer:
+var buf = zeroTo( 27 );
+
+// Create an ndarray:
+var x = array( buf, {
+ 'shape': [ 3, 3, 3 ]
+});
+
+// Get the first two rows of each matrix:
+var y1 = sliceTo( x, [ null, 2, null ], false, false );
+// returns
+
+var a1 = ndarray2array( y1 );
+console.log( a1 );
+// => [ [ [ 0, 1, 2 ], [ 3, 4, 5 ] ], [ [ 9, 10, 11 ], [ 12, 13, 14 ] ], [ [ 18, 19, 20 ], [ 21, 22, 23 ] ] ]
+
+// Get the first two rows and columns of each matrix:
+var y2 = sliceTo( x, [ null, 2, 2 ], false, false );
+// returns
+
+var a2 = ndarray2array( y2 );
+console.log( a2 );
+// => [ [ [ 0, 1 ], [ 3, 4 ] ], [ [ 9, 10 ], [ 12, 13 ] ], [ [ 18, 19 ], [ 21, 22 ] ] ]
+
+// Get the first two 2x2 matrices:
+var y3 = sliceTo( x, [ 2, 2, 2 ], false, false );
+// returns
+
+var a3 = ndarray2array( y3 );
+console.log( a3 );
+// => [ [ [ 0, 1 ], [ 3, 4 ] ], [ [ 9, 10 ], [ 12, 13 ] ] ]
diff --git a/base/slice-to/lib/index.js b/base/slice-to/lib/index.js
new file mode 100644
index 00000000..23773e32
--- /dev/null
+++ b/base/slice-to/lib/index.js
@@ -0,0 +1,63 @@
+/**
+* @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 truncated view of an input ndarray.
+*
+* @module @stdlib/ndarray/base/slice-to
+*
+* @example
+* var ndarray = require( '@stdlib/ndarray/ctor' );
+* var ndarray2array = require( '@stdlib/ndarray/to-array' );
+* var sliceTo = require( '@stdlib/ndarray/base/slice-to' );
+*
+* 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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/base/slice-to/lib/main.js b/base/slice-to/lib/main.js
new file mode 100644
index 00000000..e2bcd206
--- /dev/null
+++ b/base/slice-to/lib/main.js
@@ -0,0 +1,87 @@
+/**
+* @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 args2multislice = require( '@stdlib/slice/base/args2multislice' );
+var Slice = require( '@stdlib/slice/ctor' );
+var slice = require( './../../../base/slice' );
+
+
+// MAIN //
+
+/**
+* Returns a truncated view of an input ndarray.
+*
+* @param {ndarray} x - input array
+* @param {Array} stop - ending indices (exclusive)
+* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking
+* @param {boolean} writable - boolean indicating whether a returned array should be writable
+* @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 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 = [ 2, null ];
+* var y = sliceTo( x, s, false, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 2, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]
+*/
+function sliceTo( x, stop, strict, writable ) {
+ var args;
+ var i;
+
+ args = [];
+ for ( i = 0; i < stop.length; i++ ) {
+ if ( typeof stop[ i ] === 'number' ) {
+ args.push( new Slice( stop[ i ] ) );
+ } else {
+ args.push( null );
+ }
+ }
+ return slice( x, args2multislice( args ), strict, writable );
+}
+
+
+// EXPORTS //
+
+module.exports = sliceTo;
diff --git a/base/slice-to/package.json b/base/slice-to/package.json
new file mode 100644
index 00000000..9e2bee75
--- /dev/null
+++ b/base/slice-to/package.json
@@ -0,0 +1,66 @@
+{
+ "name": "@stdlib/ndarray/base/slice-to",
+ "version": "0.0.0",
+ "description": "Return a truncated 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",
+ "truncate"
+ ]
+}
diff --git a/base/slice-to/test/test.js b/base/slice-to/test/test.js
new file mode 100644
index 00000000..d8b00782
--- /dev/null
+++ b/base/slice-to/test/test.js
@@ -0,0 +1,578 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/* eslint-disable object-curly-newline */
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
+var isReadOnly = require( './../../../base/assert/is-read-only' );
+var zeroTo = require( '@stdlib/array/base/zero-to' );
+var typedarray = require( '@stdlib/array/typed' );
+var zeros = require( './../../../zeros' );
+var numel = require( './../../../base/numel' );
+var scalar2ndarray = require( './../../../base/from-scalar' );
+var ndarray2array = require( './../../../to-array' );
+var baseCtor = require( './../../../base/ctor' );
+var ctor = require( './../../../ctor' );
+var sliceTo = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof sliceTo, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function throws an error if the number of stopping indices does not match the number of array dimensions (strict=false)', function test( t ) {
+ var values;
+ var stop;
+ var i;
+
+ values = [
+ zeros( [] ),
+ zeros( [ 1 ] ),
+ zeros( [ 1, 1 ] ),
+ zeros( [ 1, 1, 1 ] ),
+ zeros( [ 1, 1, 1, 1 ] )
+ ];
+ stop = [
+ [ null ],
+ [ null, null, null ],
+ [ null ],
+ [ null, null ],
+ [ null, null, null ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValues( values[ i ], stop[ i ] ), RangeError, 'throws an error when provided ' + stop[ i ].toString() );
+ }
+ t.end();
+
+ function badValues( x, s ) {
+ return function badValues() {
+ sliceTo( x, s, false, false );
+ };
+ }
+});
+
+tape( 'the function throws an error if the number of stopping indices does not match the number of array dimensions (strict=true)', function test( t ) {
+ var values;
+ var stop;
+ var i;
+
+ values = [
+ zeros( [] ),
+ zeros( [ 1 ] ),
+ zeros( [ 1, 1 ] ),
+ zeros( [ 1, 1, 1 ] ),
+ zeros( [ 1, 1, 1, 1 ] )
+ ];
+ stop = [
+ [ null ],
+ [ null, null, null ],
+ [ null ],
+ [ null, null ],
+ [ null, null, null ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValues( values[ i ], stop[ i ] ), RangeError, 'throws an error when provided ' + stop[ i ].toString() );
+ }
+ t.end();
+
+ function badValues( x, s ) {
+ return function badValues() {
+ sliceTo( x, s, true, false );
+ };
+ }
+});
+
+tape( 'in strict mode, the function throws an error when a stopping index exceeds array bounds', function test( t ) {
+ var values;
+ var stop;
+ var i;
+
+ values = [
+ zeros( [ 1 ] ),
+ zeros( [ 1, 1 ] ),
+ zeros( [ 1, 1, 1 ] ),
+ zeros( [ 1, 1, 1, 1 ] )
+ ];
+
+ stop = [
+ [ 10 ],
+ [ null, 20 ],
+ [ 20, null, null ],
+ [ 20, 20, null, null ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValues( values[ i ], stop[ i ] ), RangeError, 'throws an error when provided ' + stop[ i ].toString() );
+ }
+ t.end();
+
+ function badValues( x, s ) {
+ return function badValues() {
+ sliceTo( x, s, true, false );
+ };
+ }
+});
+
+tape( 'in non-strict mode, the function returns an empty array when an ending index exceeds array bounds', function test( t ) {
+ var actual;
+ var values;
+ var stop;
+ var i;
+
+ values = [
+ zeros( [ 1 ], { 'dtype': 'float64' } ),
+ zeros( [ 1, 1 ], { 'dtype': 'float32' } ),
+ zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ),
+ zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ),
+ zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } )
+ ];
+
+ stop = [
+ [ -10 ],
+ [ null, -20 ],
+ [ -20, null, null ],
+ [ -20, -20, null, null ],
+ [ null, null, null, null, -10 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ actual = sliceTo( values[ i ], stop[ i ], false, false );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( numel( actual.shape ), 0, 'returns expected value' );
+ t.strictEqual( actual.dtype, values[ i ].dtype, 'returns expected value' );
+ }
+ t.end();
+});
+
+tape( 'the function returns an empty array when an ending index is the first element along a dimension', function test( t ) {
+ var actual;
+ var values;
+ var stop;
+ var i;
+
+ values = [
+ zeros( [ 1 ], { 'dtype': 'float64' } ),
+ zeros( [ 1, 1 ], { 'dtype': 'float32' } ),
+ zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ),
+ zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ),
+ zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } )
+ ];
+
+ stop = [
+ [ 0 ],
+ [ null, 0 ],
+ [ 0, null, null ],
+ [ 0, 0, null, null ],
+ [ null, null, null, null, 0 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ actual = sliceTo( values[ i ], stop[ i ], false, false );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( numel( actual.shape ), 0, 'returns expected value' );
+ t.strictEqual( actual.dtype, values[ i ].dtype, 'returns expected value' );
+ }
+ t.end();
+});
+
+tape( 'when provided a zero-dimensional input array, the function returns a zero-dimensional array view (base)', function test( t ) {
+ var actual;
+ var x;
+ var s;
+
+ x = scalar2ndarray( 3.14, 'float64', 'row-major' );
+ s = [];
+
+ actual = sliceTo( x, s, true, false );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 0, 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.get(), x.get(), 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'when provided a zero-dimensional input array, the function returns a zero-dimensional array view (base, offset)', function test( t ) {
+ var actual;
+ var x;
+ var s;
+
+ x = new baseCtor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' );
+ s = [];
+
+ actual = sliceTo( x, s, true, false );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 0, 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.get(), 3, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'when provided a zero-dimensional input array, the function returns a zero-dimensional array view (non-base, offset, read-only)', function test( t ) {
+ var actual;
+ var x;
+ var s;
+
+ x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' );
+ s = [];
+
+ actual = sliceTo( x, s, true, false );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 0, 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.get(), 3, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+ t.strictEqual( isReadOnly( actual ), true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'when provided a zero-dimensional input array, the function returns a zero-dimensional array view (non-base, offset, writable)', function test( t ) {
+ var actual;
+ var x;
+ var s;
+
+ x = new ctor( 'float64', typedarray( zeroTo( 4 ), 'float64' ), [], [ 0 ], 3, 'row-major' );
+ s = [];
+
+ actual = sliceTo( x, s, true, true );
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 0, 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.get(), 3, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+ t.strictEqual( isReadOnly( actual ), false, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function returns a truncated view of a provided input array (ndims=1)', function test( t ) {
+ var expected;
+ var actual;
+ var buf;
+ var ord;
+ var sh;
+ var st;
+ var o;
+ var x;
+ var s;
+ var i;
+
+ buf = typedarray( zeroTo( 30 ), 'float64' );
+ sh = [ 6 ];
+ st = [ 2 ];
+ o = 4;
+ ord = 'row-major';
+
+ x = new ctor( 'float64', buf, sh, st, o, ord );
+
+ s = [ null ];
+ actual = sliceTo( x, s, true, false );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 1, 'returns expected value' );
+ t.strictEqual( actual.length, 6, 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ expected = [ 4, 6, 8, 10, 12, 14 ];
+ for ( i = 0; i < expected.length; i++ ) {
+ t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
+ }
+
+ s = [ void 0 ];
+ actual = sliceTo( x, s, true, false );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 1, 'returns expected value' );
+ t.strictEqual( actual.length, 6, 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ expected = [ 4, 6, 8, 10, 12, 14 ];
+ for ( i = 0; i < expected.length; i++ ) {
+ t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
+ }
+
+ s = [ 4 ];
+ actual = sliceTo( x, s, true, false );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 1, 'returns expected value' );
+ t.strictEqual( actual.length, 4, 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ expected = [ 4, 6, 8, 10 ];
+ for ( i = 0; i < expected.length; i++ ) {
+ t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
+ }
+ t.end();
+});
+
+tape( 'the function returns a truncated view of a provided input array (ndims=2)', function test( t ) {
+ var expected;
+ var actual;
+ var buf;
+ var ord;
+ var sh;
+ var st;
+ var o;
+ var x;
+ var s;
+
+ buf = typedarray( zeroTo( 30 ), 'float64' );
+ sh = [ 4, 3 ];
+ st = [ 6, 2 ];
+ o = 4;
+ ord = 'row-major';
+
+ x = new ctor( 'float64', buf, sh, st, o, ord );
+
+ s = [ null, null ];
+ actual = sliceTo( x, s, true, false );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 2, 'returns expected value' );
+ t.deepEqual( actual.shape, [ 4, 3 ], 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ expected = [
+ [ 4, 6, 8 ],
+ [ 10, 12, 14 ],
+ [ 16, 18, 20 ],
+ [ 22, 24, 26 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ s = [ void 0, void 0 ];
+ actual = sliceTo( x, s, true, false );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 2, 'returns expected value' );
+ t.deepEqual( actual.shape, [ 4, 3 ], 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ expected = [
+ [ 4, 6, 8 ],
+ [ 10, 12, 14 ],
+ [ 16, 18, 20 ],
+ [ 22, 24, 26 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ s = [ 2, null ];
+ actual = sliceTo( x, s, true, false );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 2, 'returns expected value' );
+ t.deepEqual( actual.shape, [ 2, 3 ], 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ expected = [
+ [ 4, 6, 8 ],
+ [ 10, 12, 14 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ s = [ null, 2 ];
+ actual = sliceTo( x, s, true, false );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 2, 'returns expected value' );
+ t.deepEqual( actual.shape, [ 4, 2 ], 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ expected = [
+ [ 4, 6 ],
+ [ 10, 12 ],
+ [ 16, 18 ],
+ [ 22, 24 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ s = [ 3, 2 ];
+ actual = sliceTo( x, s, true, false );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 2, 'returns expected value' );
+ t.deepEqual( actual.shape, [ 3, 2 ], 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ expected = [
+ [ 4, 6 ],
+ [ 10, 12 ],
+ [ 16, 18 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function returns a truncated view of a provided input array (ndims=3)', function test( t ) {
+ var expected;
+ var actual;
+ var buf;
+ var ord;
+ var sh;
+ var st;
+ var o;
+ var x;
+ var s;
+
+ buf = typedarray( zeroTo( 100 ), 'float64' );
+ sh = [ 2, 4, 3 ];
+ st = [ 24, 6, 2 ];
+ o = 10;
+ ord = 'row-major';
+
+ x = new ctor( 'float64', buf, sh, st, o, ord );
+
+ s = [ null, null, null ];
+ actual = sliceTo( x, s, true, false );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 3, 'returns expected value' );
+ t.deepEqual( actual.shape, [ 2, 4, 3 ], 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ expected = [
+ [
+ [ 10, 12, 14 ],
+ [ 16, 18, 20 ],
+ [ 22, 24, 26 ],
+ [ 28, 30, 32 ]
+ ],
+ [
+ [ 34, 36, 38 ],
+ [ 40, 42, 44 ],
+ [ 46, 48, 50 ],
+ [ 52, 54, 56 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ s = [ 1, null, null ];
+ actual = sliceTo( x, s, true, false );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 3, 'returns expected value' );
+ t.deepEqual( actual.shape, [ 1, 4, 3 ], 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ expected = [
+ [
+ [ 10, 12, 14 ],
+ [ 16, 18, 20 ],
+ [ 22, 24, 26 ],
+ [ 28, 30, 32 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ s = [ null, 3, null ];
+ actual = sliceTo( x, s, true, false );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 3, 'returns expected value' );
+ t.deepEqual( actual.shape, [ 2, 3, 3 ], 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ expected = [
+ [
+ [ 10, 12, 14 ],
+ [ 16, 18, 20 ],
+ [ 22, 24, 26 ]
+ ],
+ [
+ [ 34, 36, 38 ],
+ [ 40, 42, 44 ],
+ [ 46, 48, 50 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ s = [ null, null, 1 ];
+ actual = sliceTo( x, s, true, false );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 3, 'returns expected value' );
+ t.deepEqual( actual.shape, [ 2, 4, 1 ], 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ expected = [
+ [
+ [ 10 ],
+ [ 16 ],
+ [ 22 ],
+ [ 28 ]
+ ],
+ [
+ [ 34 ],
+ [ 40 ],
+ [ 46 ],
+ [ 52 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ s = [ 1, 2, 1 ];
+ actual = sliceTo( x, s, true, false );
+
+ t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
+ t.strictEqual( actual.ndims, 3, 'returns expected value' );
+ t.deepEqual( actual.shape, [ 1, 2, 1 ], 'returns expected value' );
+ t.strictEqual( actual.dtype, x.dtype, 'returns expected value' );
+ t.strictEqual( actual.data, x.data, 'returns expected value' );
+
+ expected = [
+ [
+ [ 10 ],
+ [ 16 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+ t.end();
+});
diff --git a/dist/index.js b/dist/index.js
index 89e8a078..d95ee7f4 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1,4 +1,4 @@
-"use strict";var V=function(r,a){return function(){return a||r((a={exports:{}}).exports,a),a.exports}};var Cv=V(function(qK,zv){"use strict";function Hh(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 $h(r){var a,e,i;for(a=[],e=1,i=0;i=0;t--)a[t]=i,i*=r[t];return a}function a6(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}Kv.exports=n6});var Te=V(function(EK,Jv){"use strict";var u6=Gv();Jv.exports=u6});var Xv=V(function(_K,Zv){"use strict";function f6(r){var a,e,i;if(a=r.length,a===0)return 0;for(e=1,i=0;i0?v+=s*(r[o]-1):s<0&&(t+=s*(r[o]-1))}return[t,v]}bt.exports=D6});var jt=V(function(UK,wt){"use strict";function z6(r,a,e,i){var t,v,s,o,u;for(t=r.length,v=e,s=e,u=0;u0?s+=o*(r[u]-1):o<0&&(v+=o*(r[u]-1))}return i[0]=v,i[1]=s,i}wt.exports=z6});var ye=V(function(FK,_t){"use strict";var C6=require("@stdlib/utils/define-nonenumerable-read-only-property"),Et=St(),L6=jt();C6(Et,"assign",L6);_t.exports=Et});var Tt=V(function(YK,Ot){"use strict";var P6=ye();function V6(r,a,e,i){var t=P6(a,e,i);return t[0]>=0&&t[1]=0;s--)v=r%e[s],r-=v,r/=e[s],t+=v*a[s];return this._accessors?this._buffer.get(t):this._buffer[t]}Kt.exports=H6});var Zt=V(function(aG,Jt){"use strict";function $6(r,a){var e,i,t,v,s,o;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(o=0;o=0;o--)s=r%i[o],r-=s,r/=i[o],v+=s*e[o];return this._accessors?this._buffer.set(a,v):this._buffer[v]=a,this}Jt.exports=$6});var Wt=V(function(iG,Xt){"use strict";function rb(){var r,a;for(r=this._offset,a=0;a=0;s--)v=this.iget(this._length-1-s),r+=li(v)+", "+ci(v),s>0&&(r+=", ");else for(s=2;s>=0;s--)r+=this.iget(this._length-1-s),s>0&&(r+=", ")}if(e=sb[this.dtype],i+=tb(e,"{{data}}",r),i+=", ",a===0?i+="[]":i+="[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",a===0)i+="0";else for(s=0;sa?a:r}js.exports=e5});var mi=V(function(qG,_s){"use strict";var a5=Es();_s.exports=a5});var Ts=V(function(hG,Os){"use strict";function i5(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)}Os.exports=i5});var xi=V(function(bG,ks){"use strict";var v5=Ts();ks.exports=v5});var As=V(function(SG,Is){"use strict";var t5=mi(),s5=xi(),o5=require("@stdlib/string/format");function n5(r,a,e){if(e==="clamp")return t5(r,a);if(e==="wrap")return s5(r,a);if(r<0||r>a)throw new RangeError(o5("invalid argument. Index must be on the interval: [0, %d]. Value: `%d`.",a,r));return r}Is.exports=n5});var Pe=V(function(wG,Ns){"use strict";var u5=As();Ns.exports=u5});var zs=V(function(jG,Ds){"use strict";var f5=require("@stdlib/assert/is-integer").isPrimitive,d5=Pe(),l5=ae(),c5=require("@stdlib/string/format"),Rs=l5.prototype.iget;function y5(r){if(this._ndims>0){if(!f5(r))throw new TypeError(c5("invalid argument. Index must be an integer. Value: `%s`.",r));return r=d5(r,this._length-1,this._mode),Rs.call(this,r)}return Rs.call(this)}Ds.exports=y5});var Ps=V(function(EG,Ls){"use strict";var p5=require("@stdlib/assert/is-integer").isPrimitive,m5=Pe(),x5=ae(),g5=require("@stdlib/string/format"),Cs=x5.prototype.iset;function q5(r,a){if(this._flags.READONLY)throw new Error("invalid invocation. Cannot write to a read-only array.");if(this._ndims>0){if(!p5(r))throw new TypeError(g5("invalid argument. Index must be an integer. Value: `%s`.",r));r=m5(r,this._length-1,this._mode),Cs.call(this,r,a)}else Cs.call(this,r);return this}Ls.exports=q5});var Bs=V(function(_G,Ms){"use strict";var h5=require("@stdlib/assert/is-integer").isPrimitive,b5=Pe(),Vs=require("@stdlib/string/format");function S5(){var r,a,e,i;if(arguments.length!==this._ndims)throw new RangeError(Vs("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(ue("invalid argument. Third argument must be an array-like object containing nonnegative integers. Value: `%s`.",e));if(o=e.length,o>io)throw new RangeError(ue("invalid argument. Number of dimensions must not exceed %u due to stack limits. Value: `%u`.",io,o));if(!L5(i))throw new TypeError(ue("invalid argument. Fourth argument must be an array-like object containing integers. Value: `%s`.",i));if(o>0){if(i.length!==o)throw new RangeError(ue("invalid argument. Fourth argument length must match the number of dimensions. Expected number of dimensions: `%u`. Strides length: `%u`.",o,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(ue("invalid argument. Fourth argument must contain a single element equal to 0. Value: `%d`.",i[0]))}if(!C5(t))throw new TypeError(ue("invalid argument. Fifth argument must be a nonnegative integer. Value: `%s`.",t));if(!P5(v))throw new TypeError(ue("invalid argument. Sixth argument must be a supported order. Value: `%s`.",v));if(o>0&&!M5(a.length,e,i,t)&&B5(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=X5,u.readonly=W5,arguments.length>6&&(f=Z5(u,s),f))throw f;return this._mode=u.mode,u.submode===void 0&&(u.submode=[this._mode]),this._submode=u.submode,n=ao(e,o),d=ao(i,o||1),vo.call(this,r,a,n,d,t,v),this._flags.READONLY=u.readonly,this}F5(fe,vo);aa(fe,"name","ndarray");aa(fe.prototype,"get",G5);aa(fe.prototype,"iget",Y5);aa(fe.prototype,"set",J5);aa(fe.prototype,"iset",K5);to.exports=fe});var de=V(function(RG,oo){"use strict";var Q5=so();oo.exports=Q5});var no=V(function(DG,H5){H5.exports=["none","equiv","safe","mostly-safe","same-kind","unsafe"]});var fo=V(function(zG,uo){"use strict";var $5=no();function rS(){return $5.slice()}uo.exports=rS});var co=V(function(CG,lo){"use strict";function eS(){return{none:0,equiv:1,safe:2,"mostly-safe":3,"same-kind":4,unsafe:5}}lo.exports=eS});var qi=V(function(LG,po){"use strict";var aS=require("@stdlib/utils/define-nonenumerable-read-only-property"),yo=fo(),iS=co();aS(yo,"enum",iS);po.exports=yo});var go=V(function(PG,xo){"use strict";var vS=qi(),mo=vS(),tS=mo.length;function sS(r){var a;for(a=0;a0}Do.exports=IS});var wa=V(function(WG,Co){"use strict";var AS=zo();Co.exports=AS});var Lo=V(function(QG,NS){NS.exports={float64:{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},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:0,int8:0,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:0,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:0,uint8:0,uint8c:0,complex128:1,complex64:0,binary:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,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:1},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:1},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 Mo=V(function(HG,Vo){"use strict";var Po=require("@stdlib/utils/keys"),RS=require("@stdlib/assert/has-own-property"),DS=ie(),Ea=Lo(),ja;function zS(){var r,a,e,i,t,v,s,o,u;for(e={},r=Po(Ea),a=r.length,u=0;u0}Uo.exports=BS});var _a=V(function(eJ,Yo){"use strict";var US=Fo();Yo.exports=US});var Ko=V(function(aJ,FS){FS.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 Zo=V(function(iJ,Jo){"use strict";var Go=require("@stdlib/utils/keys"),YS=require("@stdlib/assert/has-own-property"),KS=ie(),Ta=Ko(),Oa;function GS(){var r,a,e,i,t,v,s,o,u;for(e={},r=Go(Ta),a=r.length,u=0;u0}Wo.exports=HS});var ji=V(function(sJ,Ho){"use strict";var $S=Qo();Ho.exports=$S});var rn=V(function(oJ,$o){"use strict";var r8=wa(),e8=_a(),a8=ji();function i8(r,a,e){return e==="unsafe"||r===a?!0:e==="none"||e==="equiv"?!1:e==="safe"?r8(r,a):e==="mostly-safe"?e8(r,a):a8(r,a)}$o.exports=i8});var Ei=V(function(nJ,en){"use strict";var v8=rn();en.exports=v8});var vn=V(function(uJ,an){"use strict";var t8=require("@stdlib/buffer/ctor"),s8=require("@stdlib/array/float64"),o8=require("@stdlib/array/float32"),n8=require("@stdlib/array/int16"),u8=require("@stdlib/array/int32"),f8=require("@stdlib/array/int8"),d8=require("@stdlib/array/uint16"),l8=require("@stdlib/array/uint32"),c8=require("@stdlib/array/uint8"),y8=require("@stdlib/array/uint8c"),p8=require("@stdlib/array/complex64"),m8=require("@stdlib/array/complex128"),x8={binary:t8,float64:s8,float32:o8,generic:Array,int16:n8,int32:u8,int8:f8,uint16:d8,uint32:l8,uint8:c8,uint8c:y8,complex64:p8,complex128:m8};an.exports=x8});var sn=V(function(fJ,tn){"use strict";var g8=vn();function q8(r){return g8[r]||null}tn.exports=q8});var va=V(function(dJ,on){"use strict";var h8=sn();on.exports=h8});var un=V(function(lJ,nn){"use strict";function b8(r){var a;for(a=0;a=0&&r.length=Ej(a)}gu.exports=_j});var bu=V(function(FJ,hu){"use strict";var Oj=qu();hu.exports=Oj});var ju=V(function(YJ,wu){"use strict";var Su=require("@stdlib/math/base/special/abs");function Tj(r){var a,e,i,t;if(a=r.length,a===0)return!1;for(e=Su(r[0]),t=1;te)return!1;e=i}return!0}sf.exports=p7});var Di=V(function(cZ,nf){"use strict";var m7=of();nf.exports=m7});var ff=V(function(yZ,uf){"use strict";var x7=ta(),g7=ne(),q7=Di();function h7(r,a,e){return g7(a)!==0&&q7(a)&&x7(r,a,e)}uf.exports=h7});var lf=V(function(pZ,df){"use strict";var b7=ff();df.exports=b7});var yf=V(function(mZ,cf){"use strict";var S7=require("@stdlib/array/base/assert/contains").factory,w7=Fr(),j7=S7(w7("signed_integer"));cf.exports=j7});var za=V(function(xZ,pf){"use strict";var E7=yf();pf.exports=E7});var xf=V(function(gZ,mf){"use strict";var _7=require("@stdlib/array/base/assert/contains").factory,O7=Fr(),T7=_7(O7("unsigned_integer"));mf.exports=T7});var Ca=V(function(qZ,gf){"use strict";var k7=xf();gf.exports=k7});var hf=V(function(hZ,qf){"use strict";var Pr=require("@stdlib/utils/define-read-only-property"),Lr={};Pr(Lr,"isAllowedDataTypeCast",Ei());Pr(Lr,"isBufferLengthCompatible",di());Pr(Lr,"isBufferLengthCompatibleShape",bu());Pr(Lr,"isCastingMode",hi());Pr(Lr,"isColumnMajor",Ii());Pr(Lr,"isColumnMajorContiguous",Nu());Pr(Lr,"isComplexFloatingPointDataType",sa());Pr(Lr,"isContiguous",Vu());Pr(Lr,"isDataType",Le());Pr(Lr,"isFloatingPointDataType",Ra());Pr(Lr,"isIndexMode",ea());Pr(Lr,"isIntegerDataType",Ai());Pr(Lr,"isMostlySafeDataTypeCast",_a());Pr(Lr,"isNumericDataType",Ni());Pr(Lr,"isOrder",re());Pr(Lr,"isReadOnly",je());Pr(Lr,"isRealDataType",Da());Pr(Lr,"isRealFloatingPointDataType",Ri());Pr(Lr,"isRowMajor",Di());Pr(Lr,"isRowMajorContiguous",lf());Pr(Lr,"isSafeDataTypeCast",wa());Pr(Lr,"isSameKindDataTypeCast",ji());Pr(Lr,"isSignedIntegerDataType",za());Pr(Lr,"isSingleSegmentCompatible",ta());Pr(Lr,"isUnsignedIntegerDataType",Ca());qf.exports=Lr});var Sf=V(function(bZ,bf){"use strict";function I7(r){return r.dtype}bf.exports=I7});var Zr=V(function(SZ,wf){"use strict";var A7=Sf();wf.exports=A7});var Ef=V(function(wZ,jf){"use strict";var N7=require("@stdlib/array/base/copy-indexed");function R7(r,a){var e=r.shape;return a?N7(e):e}jf.exports=R7});var Kr=V(function(jZ,_f){"use strict";var D7=Ef();_f.exports=D7});var Tf=V(function(EZ,Of){"use strict";var z7=Yr(),C7=require("@stdlib/array/base/copy-indexed"),L7="row-major";function P7(r,a){var e,i,t;return t=r.strides,typeof t!="object"||t===null?(i=r.shape,i.length===0?[0]:(e=r.order,typeof e!="string"&&(e=L7),z7(i,e))):a?C7(t):t}Of.exports=P7});var oe=V(function(_Z,kf){"use strict";var V7=Tf();kf.exports=V7});var Af=V(function(OZ,If){"use strict";var M7=Gr();function B7(r){var a,e,i;return i=r.offset,typeof i=="number"?i:(e=r.shape,e.length===0||(a=r.strides,typeof a!="object"||a===null)?0:M7(e,a))}If.exports=B7});var le=V(function(TZ,Nf){"use strict";var U7=Af();Nf.exports=U7});var Df=V(function(kZ,Rf){"use strict";var F7=Te(),zi="row-major",Y7="column-major";function K7(r){var a,e;return e=r.order,typeof e=="string"?e:(a=r.strides,typeof a!="object"||a===null||(e=F7(a),e===1||e===3)?zi:e===2?Y7:r.shape.length===0?zi:null)}Rf.exports=K7});var Xr=V(function(IZ,zf){"use strict";var G7=Df();zf.exports=G7});var Lf=V(function(AZ,Cf){"use strict";function J7(r){return r.data}Cf.exports=J7});var me=V(function(NZ,Pf){"use strict";var Z7=Lf();Pf.exports=Z7});var Mf=V(function(RZ,Vf){"use strict";var X7=require("@stdlib/array/base/assert/is-accessor-array"),W7=require("@stdlib/array/base/accessor-getter"),Q7=require("@stdlib/array/base/accessor-setter"),H7=require("@stdlib/array/base/getter"),$7=require("@stdlib/array/base/setter"),rE=Cr(),eE=Zr(),aE=Kr(),iE=oe(),vE=le(),tE=Xr(),sE=me();function oE(r){var a,e,i,t;return a=sE(r),i=aE(r,!0),t=eE(r),e=X7(a),{ref:r,dtype:t,data:a,length:rE(i),shape:i,strides:iE(r,!0),offset:vE(r),order:tE(r),accessorProtocol:e,accessors:e?[W7(t),Q7(t)]:[H7(t),$7(t)]}}Vf.exports=oE});var Ue=V(function(DZ,Bf){"use strict";var nE=Mf();Bf.exports=nE});var Ff=V(function(zZ,Uf){"use strict";function uE(r,a){var e,i,t,v,s,o,u,f,n,d;for(t=1,v=1,d=1;d=0&&(n=r[s],i=n<0?-n:n,!(i<=e));)r[s+1]=n,a[o+1]=a[o],s-=1,o-=1;r[s+1]=u,a[o+1]=f,t+=1,v+=1}}Uf.exports=uE});var Gf=V(function(CZ,Kf){"use strict";var fE=require("@stdlib/array/base/zero-to"),dE=require("@stdlib/array/base/copy-indexed"),Yf=require("@stdlib/array/base/take"),lE=Ff();function cE(r,a,e){var i;return i=fE(r.length),a=dE(a),lE(a,i),r=Yf(r,i),e=Yf(e,i),{sh:r,sx:a,sy:e}}Kf.exports=cE});var kr=V(function(LZ,Jf){"use strict";var yE=Gf();Jf.exports=yE});var Xf=V(function(PZ,Zf){"use strict";var pE={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};Zf.exports=pE});var Hf=V(function(VZ,Qf){"use strict";var Wf=qe(),Ci=Xf();function mE(r,a){var e,i;return e=Wf(r),i=Wf(a),e===null||i===null?Ci.BLOCK_SIZE_IN_ELEMENTS:e>i?Ci.BLOCK_SIZE_IN_BYTES/e|0:Ci.BLOCK_SIZE_IN_BYTES/i|0}Qf.exports=mE});var Ir=V(function(MZ,$f){"use strict";var xE=Hf();$f.exports=xE});var ed=V(function(BZ,rd){"use strict";var gE=kr(),qE=Ir();function hE(r,a){var e,i,t,v,s,o,u,f,n,d,q,E,y,p,h,m,j,T,x,S,w,l,g,c,b;for(b=gE(r.shape,r.strides,a.strides),E=b.sh,h=b.sx,m=b.sy,e=qE(r.dtype,a.dtype),j=r.offset,T=a.offset,i=r.data,t=a.data,o=h[0],f=m[0],v=r.accessors[0],s=a.accessors[1],c=E[1];c>0;)for(c0;)for(g0;)for(k0;)for(R0;)for(N0;)for(M0;)for(P0;)for(L0;)for(C0;)for(J0;)for(Y0;)for(G0;)for(K0;)for(F0;)for(er0;)for(H0;)for($0;)for(X0;)for(Q0;)for(W0;)for(or0;)for(sr0;)for(tr0;)for(ar0;)for(vr0;)for(rr0;)for(ir0;)for(yr0;)for(lr0;)for(cr0;)for(fr0;)for(dr0;)for(ur0;)for(nr0;)for(or0;)for(br0;)for(mr0;)for(qr0;)for(gr0;)for(hr0;)for(xr0;)for(pr0;)for(yr0;)for(lr0;)for(Nr0;)for(Ar0;)for(Tr0;)for(Or0;)for(_r0;)for(Er0;)for(Sr0;)for(br0;)for(mr0;)for(qr0;)for(l0;)for(w0;)for(N0;)for(O0;)for(A0;)for(L0;)for(C0;)for(I0;)for(z0;)for(G0;)for(K0;)for(F0;)for(U0;)for(B0;)for($0;)for(X0;)for(Q0;)for(W0;)for(Z0;)for(J0;)for(tr0;)for(ar0;)for(vr0;)for(rr0;)for(ir0;)for(er0;)for(H0;)for(cr0;)for(fr0;)for(dr0;)for(ur0;)for(nr0;)for(or0;)for(sr0;)for(tr0;)for(qr0;)for(gr0;)for(hr0;)for(xr0;)for(pr0;)for(yr0;)for(lr0;)for(cr0;)for(fr0;)for(Tr0;)for(Or0;)for(_r0;)for(Er0;)for(Sr0;)for(br0;)for(mr0;)for(qr0;)for(gr0;)for(hr=o&&(t=o-1);else if(v==="wrap")t<0?(t+=o,t<0&&(t%=o,t!==0&&(t+=o))):t>=o&&(t-=o,t>=o&&(t%=o));else if(t<0||t>=o)throw new RangeError(k_("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",o,t));if(u=e,i==="column-major"){for(n=0;n=0;n--)f=t%r[n],t-=f,t/=r[n],u+=f*a[n];return u}v0.exports=I_});var ce=V(function(xX,s0){"use strict";var A_=t0();s0.exports=A_});var f0=V(function(gX,u0){"use strict";var N_=Cr(),o0=ce(),n0="throw";function R_(r,a){var e,i,t,v,s,o,u,f,n,d,q,E,y,p,h;for(f=r.shape,s=N_(f),e=r.data,i=a.data,n=r.strides,d=a.strides,q=r.offset,E=a.offset,t=r.order,v=a.order,o=r.accessors[0],u=a.accessors[1],h=0;h=0&&(n=r[s],i=n<0?-n:n,!(i<=e));)r[s+1]=n,a[o+1]=a[o],s-=1,o-=1;r[s+1]=u,a[o+1]=f,t+=1,v+=1}}Y0.exports=FO});var Z0=V(function(DX,J0){"use strict";var YO=require("@stdlib/array/base/zero-to"),KO=require("@stdlib/array/base/copy-indexed"),La=require("@stdlib/array/base/take"),GO=require("@stdlib/array/base/filled"),Pi=Te(),JO=K0(),G0=3;function ZO(r,a,e,i){var t,v,s,o,u,f,n,d,q,E;if(t=YO(r.length),f=Pi(a),n=Pi(e),d=Pi(i),v=GO([],4),v[f].push(a),v[n].push(e),v[d].push(i),s=v[0].length,s===G0)u=a;else if(s===G0-1){for(q=1;q<4;q++)if(v[q].length){u=v[q][0];break}}else{for(E=0,q=1;q<4;q++)o=v[q].length,o>=s&&(s=o,E=q);u=v[E][0]}return u=KO(u),JO(u,t),r=La(r,t),a=a===u?u:La(a,t),e=e===u?u:La(e,t),i=i===u?u:La(i,t),{sh:r,sx:a,sy:e,sz:i}}J0.exports=ZO});var W0=V(function(zX,X0){"use strict";var XO=Z0();X0.exports=XO});var H0=V(function(CX,Q0){"use strict";var WO={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};Q0.exports=WO});var rl=V(function(LX,$0){"use strict";var Vi=qe(),Pa=H0();function QO(r,a,e){var i,t,v;return i=Vi(r),t=Vi(a),v=Vi(e),i===null||t===null||v===null?Pa.BLOCK_SIZE_IN_ELEMENTS:i>t&&i>v?Pa.BLOCK_SIZE_IN_BYTES/i|0:t>v?Pa.BLOCK_SIZE_IN_BYTES/t|0:Pa.BLOCK_SIZE_IN_BYTES/v|0}$0.exports=QO});var al=V(function(PX,el){"use strict";var HO=rl();el.exports=HO});var tl=V(function(VX,vl){"use strict";var $O=require("@stdlib/string/format"),Va=require("@stdlib/math/base/special/trunc"),il=require("@stdlib/math/base/special/abs");function rT(r,a,e,i,t,v){var s,o,u,f,n,d;for(s=r.length,o=1,d=0;d=o&&(t=o-1);else if(v==="wrap")t<0?(t+=o,t<0&&(t%=o,t!==0&&(t+=o))):t>=o&&(t-=o,t>=o&&(t%=o));else if(t<0||t>=o)throw new RangeError($O("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",o,t));if(u=0,i==="column-major"){for(d=s-1;d>=0;d--)n=a[d],n<0?(f=Va(t/n),t-=f*n,f+=r[d]-1):(f=Va(t/n),t-=f*n),u+=f*il(n);return u}for(d=0;d=0;f--)if(n=o-s+f,!(n<0)){if(u=t[n],i=a[f],i!==0&&if&&(f=a[n]);for(n=0;n=0;){for(v=a[0]-f+n,v>=0?i=t[v]:i=1,d=1;d=0?o=r[d][s]:o=1,i===1){i=o;continue}if(!(o===1||i===o))return null}e[n]=i,n-=1}return e}ml.exports=hT});var ql=V(function(GX,gl){"use strict";var bT=xl();gl.exports=bT});var bl=V(function(JX,hl){"use strict";var ST=ia(),wT=ka();function jT(r){var a=wT(r);return a?ST(a):null}hl.exports=jT});var wl=V(function(ZX,Sl){"use strict";var ET=bl();Sl.exports=ET});var El=V(function(XX,jl){"use strict";function _T(){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"}}jl.exports=_T});var Tl=V(function(WX,Ol){"use strict";var OT=ie(),_l=El(),Mi;function TT(r){return arguments.length===0?_l():(Mi===void 0&&(Mi=_l()),Mi[OT(r)]||null)}Ol.exports=TT});var Bi=V(function(QX,kl){"use strict";var kT=Tl();kl.exports=kT});var Rl=V(function(HX,Nl){"use strict";var Il=require("@stdlib/utils/object-inverse"),Al=Bi(),Ui;function IT(r){return arguments.length===0?Il(Al()):(Ui===void 0&&(Ui=Il(Al())),Ui[r]||null)}Nl.exports=IT});var zl=V(function($X,Dl){"use strict";var AT=Rl();Dl.exports=AT});var Ll=V(function(rW,Cl){"use strict";function NT(){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"}}Cl.exports=NT});var Ml=V(function(eW,Vl){"use strict";var RT=ie(),Pl=Ll(),Fi;function DT(r){return arguments.length===0?Pl():(Fi===void 0&&(Fi=Pl()),Fi[RT(r)]||null)}Vl.exports=DT});var Ul=V(function(aW,Bl){"use strict";var zT=Ml();Bl.exports=zT});var Yl=V(function(iW,Fl){"use strict";var CT=ha(),LT=ia();function PT(r){var a=typeof r;return a==="number"?CT(r)?r:null:a==="string"?LT(r):null}Fl.exports=PT});var Yi=V(function(vW,Kl){"use strict";var VT=Yl();Kl.exports=VT});var Gl=V(function(tW,MT){MT.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 Zl=V(function(sW,Jl){"use strict";var BT=ie(),UT=Gl();function FT(r){return UT[BT(r)]||null}Jl.exports=FT});var Wl=V(function(oW,Xl){"use strict";var YT=Zl();Xl.exports=YT});var $l=V(function(nW,Hl){"use strict";var KT=require("@stdlib/assert/is-array-like-object"),Ql=require("@stdlib/assert/is-nonnegative-integer").isPrimitive,GT=ie(),Ki=require("@stdlib/string/format");function JT(r,a,e){var i,t,v,s,o,u,f,n;if(!KT(r))throw new TypeError(Ki("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!Ql(a))throw new TypeError(Ki("invalid argument. Second argument must be a nonnegative integer. Value: `%s`.",a));if(!Ql(e))throw new TypeError(Ki("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(o=a+e,i%o!==0)throw new RangeError("invalid arguments. Length of the first argument is incompatible with the second and third arguments.");for(t=[],v=[],u=2*o,n=2*a,f=0;f<=u;f++)f===0?f===n?v.push("() => ("):v.push("("):f===u?f===n?v.push(") => ()"):v.push(")"):f===n?v.push(") => ("):f%2===1?v.push(""):v.push(", ");for(f=0;f0?(v=HT(a),s=XT(a,e)):(v=1,s=[0]),r==="binary"?t=rk(v):t=$T(v,r),new QT(r,t,a,s,WT(a,s),e)}e1.exports=ek});var v1=V(function(dW,i1){"use strict";var ak=a1();i1.exports=ak});var s1=V(function(lW,t1){"use strict";var ik=Yr(),vk=Gr(),tk=Cr(),sk=Zr(),ok=Kr(),nk=Xr(),uk=require("@stdlib/array/empty"),fk=require("@stdlib/buffer/alloc-unsafe");function dk(r){var a,e,i,t,v,s,o;return o=sk(r),v=ok(r,!0),t=nk(r),a=v.length,a>0?(e=tk(v),s=ik(v,t)):(e=1,s=[0]),o==="binary"?i=fk(e):i=uk(e,o),new r.constructor(o,i,v,s,vk(v,s),t)}t1.exports=dk});var n1=V(function(cW,o1){"use strict";var lk=s1();o1.exports=lk});var y1=V(function(yW,c1){"use strict";var ck=je(),u1=Zr(),yk=Kr(),pk=oe(),f1=le(),mk=Xr(),d1=me(),l1=require("@stdlib/string/format");function xk(r,a){var e,i,t,v,s,o,u;if(v=yk(r,!1),s=pk(r,!1),t=mk(r),o=v.length,e=[],i=[],a<0){if(a<-o-1)throw new RangeError(l1("invalid argument. Specified axis is out-of-bounds. Must be on the interval: [-%u-1, %u]. Value: `%d`.",o,o,a));a+=o+1}else if(a>o)throw new RangeError(l1("invalid argument. Specified axis is out-of-bounds. Must be on the interval: [-%u-1, %u]. Value: `%d`.",o,o,a));if(a===0)for(i.push(1),e.push(s[0]),u=0;u0&&(q=Ek(q.length))}else q=j1(E);return E1(q)===0?Rk(d,s,Ji(q,f),u,!i):(v=Ak(E,t,v),q=Ji(q,f),q.length===0?new d(s,Zi(r),[],[0],v,u,{readonly:!i}):(t=Nk(E,t,f),new d(s,Zi(r),q,t,v,u,{readonly:!i})))}O1.exports=Dk});var $r=V(function(hW,k1){"use strict";var zk=T1();k1.exports=zk});var A1=V(function(bW,I1){"use strict";function Ck(r){var a=r.ndims;return typeof a=="number"?a:r.shape.length}I1.exports=Ck});var Ne=V(function(SW,N1){"use strict";var Lk=A1();N1.exports=Lk});var D1=V(function(wW,R1){"use strict";var Pk=require("@stdlib/slice/base/args2multislice"),Vk=require("@stdlib/slice/ctor"),Mk=$r(),Bk=require("@stdlib/array/base/filled"),Uk=Ne(),Xi=require("@stdlib/string/format");function Fk(r,a,e){var i,t,v;if(t=Uk(r),t===0)throw new TypeError(Xi("invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.",t));if(v=a,v<0){if(v+=t,v<0)throw new RangeError(Xi("invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.",t,a))}else if(v>=t)throw new RangeError(Xi("invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.",t,a));return i=Bk(null,t),i[v]=new Vk(null,null,-1),Mk(r,Pk(i),!0,e)}R1.exports=Fk});var Ba=V(function(jW,z1){"use strict";var Yk=D1();z1.exports=Yk});var L1=V(function(EW,C1){"use strict";var Kk=require("@stdlib/slice/multi"),Gk=Ba(),Jk=$r(),Zk=Ne();function Xk(r,a){return Zk(r)===0?Jk(r,new Kk,!0,a):Gk(r,-1,a)}C1.exports=Xk});var V1=V(function(_W,P1){"use strict";var Wk=L1();P1.exports=Wk});var F1=V(function(OW,U1){"use strict";var M1=require("@stdlib/slice/multi"),Qk=Ba(),B1=$r(),Hk=Ne();function $k(r,a){var e=Hk(r);return e===0?B1(r,new M1,!0,a):e===1?B1(r,new M1(null),!0,a):Qk(r,-2,a)}U1.exports=$k});var K1=V(function(TW,Y1){"use strict";var rI=F1();Y1.exports=rI});var J1=V(function(kW,G1){"use strict";var eI=require("@stdlib/array/base/assert/is-accessor-array"),aI=require("@stdlib/array/base/accessor-setter"),iI=require("@stdlib/array/base/setter"),vI=ve(),tI=ae(),sI=require("@stdlib/string/format");function oI(r,a,e){var i,t;if(i=vI(a,1),i===null)throw new TypeError(sI("invalid argument. Second argument must be a recognized data type. Value: `%s`.",a));return/^complex/.test(a)&&typeof r=="number"&&(r=[r,0]),eI(i)?t=aI(a):t=iI(a),t(i,0,r),new tI(a,i,[],[0],0,e)}G1.exports=oI});var X1=V(function(IW,Z1){"use strict";var nI=J1();Z1.exports=nI});var Wi=V(function(AW,W1){"use strict";var uI=require("@stdlib/string/format"),Ua=require("@stdlib/math/base/special/trunc");function fI(r,a,e,i,t,v,s){var o,u,f,n,d;for(o=r.length,u=1,d=0;d=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(uI("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--)n=t%r[d],t-=n,t/=r[d],s[d]=n;return s}if(i==="column-major"){for(d=o-1;d>=0;d--)n=a[d],n<0?(f=Ua(t/n),t-=f*n,s[d]=r[d]-1+f):(f=Ua(t/n),t-=f*n,s[d]=f);return s}for(d=0;d0&&(t+=a[v]*(r[v]-1))}return t}ec.exports=pI});var vc=V(function(zW,ic){"use strict";var mI=ac();ic.exports=mI});var oc=V(function(CW,sc){"use strict";var tc=Ma(),xI=Kr();function gI(r,a){var e,i,t;if(i=a.length,e=xI(r,!1),e.length===i){for(t=0;ti;v--)t[v]=e[v];for(v=i;v>=0&&(s=(e[v]+1)%a[v],t[v]=s,!(s>0));v--);for(v-=1;v>=0;v--)t[v]=e[v];return t}function TI(r,a,e,i,t){var v,s;for(v=0;v0));v++);for(v+=1;v=v)return null;return a===_I?OI(v,r,e,i,t):TI(v,r,e,i,t)}gc.exports=kI});var hc=V(function(FW,qc){"use strict";var II=require("@stdlib/array/base/zeros"),AI=Hi();function NI(r,a,e,i){return AI(r,a,e,i,II(r.length))}qc.exports=NI});var Re=V(function(YW,Sc){"use strict";var RI=require("@stdlib/utils/define-nonenumerable-read-only-property"),bc=hc(),DI=Hi();RI(bc,"assign",DI);Sc.exports=bc});var jc=V(function(KW,wc){"use strict";function zI(r){var a,e;for(a=0,e=0;e=0&&(n=r[s],i=n<0?-n:n,!(i<=e));)r[s+1]=n,a[o+1]=a[o],s-=1,o-=1;r[s+1]=u,a[o+1]=f,t+=1,v+=1}}Oc.exports=LI});var Ic=V(function(ZW,kc){"use strict";var PI=require("@stdlib/array/base/zero-to"),VI=require("@stdlib/array/base/copy-indexed"),MI=require("@stdlib/array/base/take"),BI=Tc();function UI(r,a){var e;return e=PI(r.length),a=VI(a),BI(a,e),r=MI(r,e),{sh:r,sx:a}}kc.exports=UI});var Mr=V(function(XW,Ac){"use strict";var FI=Ic();Ac.exports=FI});var Rc=V(function(WW,Nc){"use strict";var YI={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};Nc.exports=YI});var Cc=V(function(QW,zc){"use strict";var KI=qe(),Dc=Rc();function GI(r){var a=KI(r);return a===null?Dc.BLOCK_SIZE_IN_ELEMENTS:Dc.BLOCK_SIZE_IN_BYTES/a|0}zc.exports=GI});var Br=V(function(HW,Lc){"use strict";var JI=Cc();Lc.exports=JI});var Vc=V(function($W,Pc){"use strict";var ZI=Mr(),XI=Br();function WI(r,a){var e,i,t,v,s,o,u,f,n,d,q,E,y,p,h,m,j;for(j=ZI(r.shape,r.strides),u=j.sh,d=j.sx,e=XI(r.dtype),q=r.offset,i=r.data,v=d[0],t=r.accessors[1],m=u[1];m>0;)for(m0;)for(h0;)for(w0;)for(S0;)for(x0;)for(_0;)for(b0;)for(c0;)for(g0;)for(k0;)for(R0;)for(N0;)for(O0;)for(A0;)for(L0;)for(C0;)for(I0;)for(z0;)for(D0;)for(k0;)for(F0;)for(U0;)for(B0;)for(M0;)for(P0;)for(L0;)for(C0;)for(Z0;)for(J0;)for(Y0;)for(G0;)for(K0;)for(F0;)for(U0;)for(B0;)for(H0;)for($0;)for(X0;)for(Q0;)for(W0;)for(Z0;)for(J0;)for(Y0;)for(G0;)for(ar0;)for(vr0;)for(rr0;)for(ir0;)for(er0;)for(H0;)for($0;)for(X0;)for(Q0;)for(W0;)for(h0;)for(p0;)for(S0;)for(x0;)for(T