diff --git a/base/lib/index.js b/base/lib/index.js
index c7aef6d1..22465a25 100644
--- a/base/lib/index.js
+++ b/base/lib/index.js
@@ -535,6 +535,15 @@ setReadOnly( ns, 'removeSingletonDimensions', require( './../../base/remove-sing
*/
setReadOnly( ns, 'reverse', require( './../../base/reverse' ) );
+/**
+* @name reverseDimension
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/reverse-dimension}
+*/
+setReadOnly( ns, 'reverseDimension', require( './../../base/reverse-dimension' ) );
+
/**
* @name serializeMetaData
* @memberof ns
diff --git a/base/reverse-dimension/README.md b/base/reverse-dimension/README.md
new file mode 100644
index 00000000..df92103a
--- /dev/null
+++ b/base/reverse-dimension/README.md
@@ -0,0 +1,167 @@
+
+
+# reverseDimension
+
+> Return a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+
+
+
+
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var reverseDimension = require( '@stdlib/ndarray/base/reverse-dimension' );
+```
+
+#### reverseDimension( x, dim, writable )
+
+Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+
+```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 y = reverseDimension( x, 0, false );
+// returns
+
+sh = y.shape;
+// returns [ 3, 2 ]
+
+arr = ndarray2array( y );
+// returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
+```
+
+The function accepts the following arguments:
+
+- **x**: input ndarray.
+- **dim**: index of dimension along which to reverse elements. If provided an integer less than zero, the dimension index is resolved relative to the last dimension, with the last dimension corresponding to the value `-1`.
+- **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 reverseDimension = require( '@stdlib/ndarray/base/reverse-dimension' );
+
+// Create a linear ndarray buffer:
+var buf = zeroTo( 16 );
+
+// Create a three-dimensional ndarray:
+var x = array( buf, {
+ 'shape': [ 2, 4, 2 ]
+});
+
+// Reverse the order of first axis:
+var y0 = reverseDimension( x, 0, false );
+// returns
+
+var a0 = ndarray2array( y0 );
+// returns [ [ [ 8, 9 ], [ 10, 11 ], [ 12, 13 ], [ 14, 15 ] ], [ [ 0, 1 ], [ 2, 3 ], [ 4, 5 ], [ 6, 7 ] ] ]
+
+// Reverse the order of second axis:
+var y1 = reverseDimension( x, 1, false );
+// returns
+
+var a1 = ndarray2array( y1 );
+// returns [ [ [ 6, 7 ], [ 4, 5 ], [ 2, 3 ], [ 0, 1 ] ], [ [ 14, 15 ], [ 12, 13 ], [ 10, 11 ], [ 8, 9 ] ] ]
+
+// Reverse the order of third axis:
+var y2 = reverseDimension( x, 2, false );
+// returns
+
+var a2 = ndarray2array( y2 );
+// returns [ [ [ 1, 0 ], [ 3, 2 ], [ 5, 4 ], [ 7, 6 ] ], [ [ 9, 8 ], [ 11, 10 ], [ 13, 12 ], [ 15, 14 ] ] ]
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/base/reverse-dimension/benchmark/benchmark.js b/base/reverse-dimension/benchmark/benchmark.js
new file mode 100644
index 00000000..5e2f0b81
--- /dev/null
+++ b/base/reverse-dimension/benchmark/benchmark.js
@@ -0,0 +1,331 @@
+/**
+* @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 reverseDimension = require( './../lib' );
+
+
+// MAIN //
+
+bench( pkg+'::1d,base', function benchmark( b ) {
+ var values;
+ var v;
+ 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' )
+ ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = reverseDimension( values[ i%values.length ], 0, 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 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 */
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = reverseDimension( values[ i%values.length ], 0, 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 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' )
+ ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = reverseDimension( values[ i%values.length ], i%2, 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 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 */
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = reverseDimension( values[ i%values.length ], i%2, 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 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' )
+ ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = reverseDimension( values[ i%values.length ], i%3, 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 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 */
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = reverseDimension( values[ i%values.length ], i%3, 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 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' )
+ ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = reverseDimension( values[ i%values.length ], i%4, 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 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 */
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = reverseDimension( values[ i%values.length ], i%4, 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 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' )
+ ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = reverseDimension( values[ i%values.length ], i%5, 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 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 */
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = reverseDimension( values[ i%values.length ], i%5, 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/reverse-dimension/docs/repl.txt b/base/reverse-dimension/docs/repl.txt
new file mode 100644
index 00000000..59531a75
--- /dev/null
+++ b/base/reverse-dimension/docs/repl.txt
@@ -0,0 +1,41 @@
+
+{{alias}}( x, dim, writable )
+ Returns a view of an input ndarray in which the order of elements along a
+ specified dimension is reversed.
+
+ Parameters
+ ----------
+ x: ndarray
+ Input array.
+
+ dim: integer
+ Index of dimension to reverse. If less than zero, the index is resolved
+ relative to the last dimension, with the last dimension corresponding to
+ the value `-1`.
+
+ 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 y = {{alias}}( x, 0, false )
+
+ > y.shape
+ [ 2, 2 ]
+ > {{alias:@stdlib/ndarray/to-array}}( y )
+ [ [ 3, 4 ], [ 1, 2 ] ]
+
+ See Also
+ --------
+
diff --git a/base/reverse-dimension/docs/types/index.d.ts b/base/reverse-dimension/docs/types/index.d.ts
new file mode 100644
index 00000000..3b239b62
--- /dev/null
+++ b/base/reverse-dimension/docs/types/index.d.ts
@@ -0,0 +1,510 @@
+/*
+* @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';
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param x - input array
+* @param dim - index of dimension to reverse
+* @param writable - boolean indicating whether a returned array should be writable
+* @returns output array
+*
+* @example
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
+*/
+declare function reverseDimension( x: float64ndarray, dim: number, writable: boolean ): float64ndarray;
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param x - input array
+* @param dim - index of dimension to reverse
+* @param writable - boolean indicating whether a returned array should be writable
+* @returns output array
+*
+* @example
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
+*/
+declare function reverseDimension( x: float32ndarray, dim: number, writable: boolean ): float32ndarray;
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param x - input array
+* @param dim - index of dimension to reverse
+* @param writable - boolean indicating whether a returned array should be writable
+* @returns output array
+*
+* @example
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ]
+*/
+declare function reverseDimension( x: int32ndarray, dim: number, writable: boolean ): int32ndarray;
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param x - input array
+* @param dim - index of dimension to reverse
+* @param writable - boolean indicating whether a returned array should be writable
+* @returns output array
+*
+* @example
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ]
+*/
+declare function reverseDimension( x: int16ndarray, dim: number, writable: boolean ): int16ndarray;
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param x - input array
+* @param dim - index of dimension to reverse
+* @param writable - boolean indicating whether a returned array should be writable
+* @returns output array
+*
+* @example
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ]
+*/
+declare function reverseDimension( x: int8ndarray, dim: number, writable: boolean ): int8ndarray;
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param x - input array
+* @param dim - index of dimension to reverse
+* @param writable - boolean indicating whether a returned array should be writable
+* @returns output array
+*
+* @example
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ]
+*/
+declare function reverseDimension( x: uint32ndarray, dim: number, writable: boolean ): uint32ndarray;
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param x - input array
+* @param dim - index of dimension to reverse
+* @param writable - boolean indicating whether a returned array should be writable
+* @returns output array
+*
+* @example
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ]
+*/
+declare function reverseDimension( x: uint16ndarray, dim: number, writable: boolean ): uint16ndarray;
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param x - input array
+* @param dim - index of dimension to reverse
+* @param writable - boolean indicating whether a returned array should be writable
+* @returns output array
+*
+* @example
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ]
+*/
+declare function reverseDimension( x: uint8ndarray, dim: number, writable: boolean ): uint8ndarray;
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param x - input array
+* @param dim - index of dimension to reverse
+* @param writable - boolean indicating whether a returned array should be writable
+* @returns output array
+*
+* @example
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ]
+*/
+declare function reverseDimension( x: uint8cndarray, dim: number, writable: boolean ): uint8cndarray;
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param x - input array
+* @param dim - index of dimension to reverse
+* @param writable - boolean indicating whether a returned array should be writable
+* @returns output array
+*
+* @example
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*/
+declare function reverseDimension( x: complex128ndarray, dim: number, writable: boolean ): complex128ndarray;
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param x - input array
+* @param dim - index of dimension to reverse
+* @param writable - boolean indicating whether a returned array should be writable
+* @returns output array
+*
+* @example
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*/
+declare function reverseDimension( x: complex64ndarray, dim: number, writable: boolean ): complex64ndarray;
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param x - input array
+* @param dim - index of dimension to reverse
+* @param writable - boolean indicating whether a returned array should be writable
+* @returns output array
+*
+* @example
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ]
+*/
+declare function reverseDimension( x: genericndarray, dim: number, writable: boolean ): genericndarray;
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param x - input array
+* @param dim - index of dimension to reverse
+* @param writable - boolean indicating whether a returned array should be writable
+* @returns output array
+*
+* @example
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ]
+*/
+declare function reverseDimension( x: typedndarray, dim: number, writable: boolean ): typedndarray;
+
+
+// EXPORTS //
+
+export = reverseDimension;
diff --git a/base/reverse-dimension/docs/types/test.ts b/base/reverse-dimension/docs/types/test.ts
new file mode 100644
index 00000000..fd9fcdad
--- /dev/null
+++ b/base/reverse-dimension/docs/types/test.ts
@@ -0,0 +1,119 @@
+/*
+* @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 reverseDimension = require( './index' );
+
+
+// TESTS //
+
+// The function returns an ndarray...
+{
+ const order = 'row-major';
+ const sh = [ 2, 2 ];
+
+ reverseDimension( empty( 'float64', sh, order ), 0, false ); // $ExpectType float64ndarray
+ reverseDimension( empty( 'float32', sh, order ), 0, false ); // $ExpectType float32ndarray
+ reverseDimension( empty( 'complex128', sh, order ), 0, false ); // $ExpectType complex128ndarray
+ reverseDimension( empty( 'complex64', sh, order ), 0, false ); // $ExpectType complex64ndarray
+ reverseDimension( empty( 'int32', sh, order ), 0, false ); // $ExpectType int32ndarray
+ reverseDimension( empty( 'int16', sh, order ), 0, false ); // $ExpectType int16ndarray
+ reverseDimension( empty( 'int8', sh, order ), 0, false ); // $ExpectType int8ndarray
+ reverseDimension( empty( 'uint32', sh, order ), 0, false ); // $ExpectType uint32ndarray
+ reverseDimension( empty( 'uint16', sh, order ), 0, false ); // $ExpectType uint16ndarray
+ reverseDimension( empty( 'uint8', sh, order ), 0, false ); // $ExpectType uint8ndarray
+ reverseDimension( empty( 'uint8c', sh, order ), 0, false ); // $ExpectType uint8cndarray
+
+ reverseDimension( empty( 'float64', sh, order ), 0, true ); // $ExpectType float64ndarray
+ reverseDimension( empty( 'float32', sh, order ), 0, true ); // $ExpectType float32ndarray
+ reverseDimension( empty( 'complex128', sh, order ), 0, true ); // $ExpectType complex128ndarray
+ reverseDimension( empty( 'complex64', sh, order ), 0, true ); // $ExpectType complex64ndarray
+ reverseDimension( empty( 'int32', sh, order ), 0, true ); // $ExpectType int32ndarray
+ reverseDimension( empty( 'int16', sh, order ), 0, true ); // $ExpectType int16ndarray
+ reverseDimension( empty( 'int8', sh, order ), 0, true ); // $ExpectType int8ndarray
+ reverseDimension( empty( 'uint32', sh, order ), 0, true ); // $ExpectType uint32ndarray
+ reverseDimension( empty( 'uint16', sh, order ), 0, true ); // $ExpectType uint16ndarray
+ reverseDimension( empty( 'uint8', sh, order ), 0, true ); // $ExpectType uint8ndarray
+ reverseDimension( empty( 'uint8c', sh, order ), 0, true ); // $ExpectType uint8cndarray
+}
+
+// The compiler throws an error if the function is provided a first argument which is not an ndarray...
+{
+ reverseDimension( '10', 0, false ); // $ExpectError
+ reverseDimension( 10, 0, false ); // $ExpectError
+ reverseDimension( false, 0, false ); // $ExpectError
+ reverseDimension( true, 0, false ); // $ExpectError
+ reverseDimension( null, 0, false ); // $ExpectError
+ reverseDimension( [], 0, false ); // $ExpectError
+ reverseDimension( {}, 0, false ); // $ExpectError
+ reverseDimension( ( x: number ): number => x, 0, false ); // $ExpectError
+
+ reverseDimension( '10', 0, true ); // $ExpectError
+ reverseDimension( 10, 0, true ); // $ExpectError
+ reverseDimension( false, 0, true ); // $ExpectError
+ reverseDimension( true, 0, true ); // $ExpectError
+ reverseDimension( null, 0, true ); // $ExpectError
+ reverseDimension( [], 0, true ); // $ExpectError
+ reverseDimension( {}, 0, true ); // $ExpectError
+ reverseDimension( ( x: number ): number => x, 0, true ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a second argument which is not a number...
+{
+ const x = empty( 'float64', [ 2, 2 ], 'row-major' );
+
+ reverseDimension( x, '5', false ); // $ExpectError
+ reverseDimension( x, true, false ); // $ExpectError
+ reverseDimension( x, false, false ); // $ExpectError
+ reverseDimension( x, null, false ); // $ExpectError
+ reverseDimension( x, undefined, false ); // $ExpectError
+ reverseDimension( x, [ '5' ], false ); // $ExpectError
+ reverseDimension( x, {}, false ); // $ExpectError
+ reverseDimension( x, ( x: number ): number => x, false ); // $ExpectError
+
+ reverseDimension( x, '5', true ); // $ExpectError
+ reverseDimension( x, true, true ); // $ExpectError
+ reverseDimension( x, false, true ); // $ExpectError
+ reverseDimension( x, null, true ); // $ExpectError
+ reverseDimension( x, undefined, true ); // $ExpectError
+ reverseDimension( x, [ '5' ], true ); // $ExpectError
+ reverseDimension( x, {}, true ); // $ExpectError
+ reverseDimension( x, ( x: number ): number => x, true ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a third argument which is not a boolean...
+{
+ const x = empty( 'float64', [ 2, 2 ], 'row-major' );
+
+ reverseDimension( x, 0, '5' ); // $ExpectError
+ reverseDimension( x, 0, 5 ); // $ExpectError
+ reverseDimension( x, 0, null ); // $ExpectError
+ reverseDimension( x, 0, undefined ); // $ExpectError
+ reverseDimension( x, 0, [ '5' ] ); // $ExpectError
+ reverseDimension( x, 0, {} ); // $ExpectError
+ reverseDimension( x, 0, ( 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' );
+
+ reverseDimension( x ); // $ExpectError
+ reverseDimension( x, 0 ); // $ExpectError
+ reverseDimension( x, 0, false, {} ); // $ExpectError
+}
diff --git a/base/reverse-dimension/examples/index.js b/base/reverse-dimension/examples/index.js
new file mode 100644
index 00000000..f5e1af9b
--- /dev/null
+++ b/base/reverse-dimension/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 reverseDimension = require( './../lib' );
+
+// Create a linear ndarray buffer:
+var buf = zeroTo( 16 );
+
+// Create a three-dimensional ndarray:
+var x = array( buf, {
+ 'shape': [ 2, 4, 2 ]
+});
+
+// Reverse the order of first axis:
+var y0 = reverseDimension( x, 0, false );
+// returns
+
+var a0 = ndarray2array( y0 );
+console.log( a0 );
+// => [ [ [ 8, 9 ], [ 10, 11 ], [ 12, 13 ], [ 14, 15 ] ], [ [ 0, 1 ], [ 2, 3 ], [ 4, 5 ], [ 6, 7 ] ] ]
+
+// Reverse the order of second axis:
+var y1 = reverseDimension( x, 1, false );
+// returns
+
+var a1 = ndarray2array( y1 );
+console.log( a1 );
+// => [ [ [ 6, 7 ], [ 4, 5 ], [ 2, 3 ], [ 0, 1 ] ], [ [ 14, 15 ], [ 12, 13 ], [ 10, 11 ], [ 8, 9 ] ] ]
+
+// Reverse the order of third axis:
+var y2 = reverseDimension( x, 2, false );
+// returns
+
+var a2 = ndarray2array( y2 );
+console.log( a2 );
+// => [ [ [ 1, 0 ], [ 3, 2 ], [ 5, 4 ], [ 7, 6 ] ], [ [ 9, 8 ], [ 11, 10 ], [ 13, 12 ], [ 15, 14 ] ] ]
diff --git a/base/reverse-dimension/lib/index.js b/base/reverse-dimension/lib/index.js
new file mode 100644
index 00000000..f8e97de2
--- /dev/null
+++ b/base/reverse-dimension/lib/index.js
@@ -0,0 +1,62 @@
+/**
+* @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 view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @module @stdlib/ndarray/base/reverse-dimension
+*
+* @example
+* var ndarray = require( '@stdlib/ndarray/ctor' );
+* var ndarray2array = require( '@stdlib/ndarray/to-array' );
+* var reverseDimension = require( '@stdlib/ndarray/base/reverse-dimension' );
+*
+* 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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/base/reverse-dimension/lib/main.js b/base/reverse-dimension/lib/main.js
new file mode 100644
index 00000000..2fa9a0d9
--- /dev/null
+++ b/base/reverse-dimension/lib/main.js
@@ -0,0 +1,103 @@
+/**
+* @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' );
+var filled = require( '@stdlib/array/base/filled' );
+var ndims = require( './../../../base/ndims' );
+var format = require( '@stdlib/string/format' );
+
+
+// MAIN //
+
+/**
+* Returns a view of an input ndarray in which the order of elements along a specified dimension is reversed.
+*
+* @param {ndarray} x - input array
+* @param {integer} dim - index of dimension to reverse
+* @param {boolean} writable - boolean indicating whether a returned array should be writable
+* @throws {TypeError} first argument must be an ndarray having one or more dimensions
+* @throws {RangeError} dimension index exceeds the number of dimensions
+* @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 y = reverseDimension( x, 0, false );
+* // returns
+*
+* sh = y.shape;
+* // returns [ 3, 2 ]
+*
+* arr = ndarray2array( y );
+* // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
+*/
+function reverseDimension( x, dim, writable ) {
+ var args;
+ var N;
+ var d;
+
+ // Retrieve the number of array dimensions:
+ N = ndims( x );
+
+ // Check whether we were provided a zero-dimensional array...
+ if ( N === 0 ) {
+ throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) );
+ }
+ // Normalize the dimension index...
+ d = dim;
+ if ( d < 0 ) {
+ d += N;
+ if ( d < 0 ) {
+ throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );
+ }
+ } else if ( d >= N ) {
+ throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );
+ }
+ // Define a list of MultiSlice constructor arguments:
+ args = filled( null, N );
+ args[ d ] = new Slice( null, null, -1 );
+
+ // Return a new array view:
+ return slice( x, args2multislice( args ), true, writable );
+}
+
+
+// EXPORTS //
+
+module.exports = reverseDimension;
diff --git a/base/reverse-dimension/package.json b/base/reverse-dimension/package.json
new file mode 100644
index 00000000..94a99846
--- /dev/null
+++ b/base/reverse-dimension/package.json
@@ -0,0 +1,67 @@
+{
+ "name": "@stdlib/ndarray/base/reverse-dimension",
+ "version": "0.0.0",
+ "description": "Return a view of an input ndarray in which the order of elements along a specified dimension is reversed.",
+ "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",
+ "reverse",
+ "flip",
+ "numpy.flip"
+ ]
+}
diff --git a/base/reverse-dimension/test/test.js b/base/reverse-dimension/test/test.js
new file mode 100644
index 00000000..043ea192
--- /dev/null
+++ b/base/reverse-dimension/test/test.js
@@ -0,0 +1,498 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var 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 ndarray2array = require( './../../../to-array' );
+var baseCtor = require( './../../../base/ctor' );
+var zeros = require( './../../../zeros' );
+var ctor = require( './../../../ctor' );
+var reverseDimension = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof reverseDimension, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function throws an error if provided a zero-dimensional array', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [] )
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error' );
+ }
+ t.end();
+
+ function badValue( x ) {
+ return function badValue() {
+ reverseDimension( x, 0, false );
+ };
+ }
+});
+
+tape( 'the function throws an error if the dimension index exceeds the number of dimensions', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 1 ] ),
+ zeros( [ 1, 1 ] ),
+ zeros( [ 1, 1, 1 ] ),
+ zeros( [ 1, 1, 1, 1 ] )
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ], 10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) );
+ t.throws( badValue( values[ i ], -10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) );
+ }
+ t.end();
+
+ function badValue( x, dim ) {
+ return function badValue() {
+ reverseDimension( x, dim, false );
+ };
+ }
+});
+
+tape( 'the function returns a 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 i;
+
+ buf = typedarray( zeroTo( 30 ), 'float64' );
+ sh = [ 6 ];
+ st = [ 2 ];
+ o = 4;
+ ord = 'row-major';
+
+ x = new ctor( 'float64', buf, sh, st, o, ord );
+
+ actual = reverseDimension( x, 0, 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' );
+ t.strictEqual( isReadOnly( actual ), true, 'returns expected value' );
+
+ expected = [ 14, 12, 10, 8, 6, 4 ];
+ for ( i = 0; i < expected.length; i++ ) {
+ t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
+ }
+
+ actual = reverseDimension( x, -1, 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' );
+ t.strictEqual( isReadOnly( actual ), true, 'returns expected value' );
+
+ expected = [ 14, 12, 10, 8, 6, 4 ];
+ for ( i = 0; i < expected.length; i++ ) {
+ t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
+ }
+ t.end();
+});
+
+tape( 'the function returns a 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;
+
+ 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 );
+
+ actual = reverseDimension( x, 0, 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' );
+ t.strictEqual( isReadOnly( actual ), true, 'returns expected value' );
+
+ expected = [
+ [ 22, 24, 26 ],
+ [ 16, 18, 20 ],
+ [ 10, 12, 14 ],
+ [ 4, 6, 8 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ actual = reverseDimension( x, -2, 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' );
+ t.strictEqual( isReadOnly( actual ), true, 'returns expected value' );
+
+ expected = [
+ [ 22, 24, 26 ],
+ [ 16, 18, 20 ],
+ [ 10, 12, 14 ],
+ [ 4, 6, 8 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ actual = reverseDimension( x, 1, 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' );
+ t.strictEqual( isReadOnly( actual ), true, 'returns expected value' );
+
+ expected = [
+ [ 8, 6, 4 ],
+ [ 14, 12, 10 ],
+ [ 20, 18, 16 ],
+ [ 26, 24, 22 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ actual = reverseDimension( x, -1, 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' );
+ t.strictEqual( isReadOnly( actual ), true, 'returns expected value' );
+
+ expected = [
+ [ 8, 6, 4 ],
+ [ 14, 12, 10 ],
+ [ 20, 18, 16 ],
+ [ 26, 24, 22 ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function returns a 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;
+
+ 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 );
+
+ actual = reverseDimension( x, 0, 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' );
+ t.strictEqual( isReadOnly( actual ), true, 'returns expected value' );
+
+ expected = [
+ [
+ [ 34, 36, 38 ],
+ [ 40, 42, 44 ],
+ [ 46, 48, 50 ],
+ [ 52, 54, 56 ]
+ ],
+ [
+ [ 10, 12, 14 ],
+ [ 16, 18, 20 ],
+ [ 22, 24, 26 ],
+ [ 28, 30, 32 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ actual = reverseDimension( x, -3, 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' );
+ t.strictEqual( isReadOnly( actual ), true, 'returns expected value' );
+
+ expected = [
+ [
+ [ 34, 36, 38 ],
+ [ 40, 42, 44 ],
+ [ 46, 48, 50 ],
+ [ 52, 54, 56 ]
+ ],
+ [
+ [ 10, 12, 14 ],
+ [ 16, 18, 20 ],
+ [ 22, 24, 26 ],
+ [ 28, 30, 32 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ actual = reverseDimension( x, 1, 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' );
+ t.strictEqual( isReadOnly( actual ), true, 'returns expected value' );
+
+ expected = [
+ [
+ [ 28, 30, 32 ],
+ [ 22, 24, 26 ],
+ [ 16, 18, 20 ],
+ [ 10, 12, 14 ]
+ ],
+ [
+ [ 52, 54, 56 ],
+ [ 46, 48, 50 ],
+ [ 40, 42, 44 ],
+ [ 34, 36, 38 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ actual = reverseDimension( x, -2, 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' );
+ t.strictEqual( isReadOnly( actual ), true, 'returns expected value' );
+
+ expected = [
+ [
+ [ 28, 30, 32 ],
+ [ 22, 24, 26 ],
+ [ 16, 18, 20 ],
+ [ 10, 12, 14 ]
+ ],
+ [
+ [ 52, 54, 56 ],
+ [ 46, 48, 50 ],
+ [ 40, 42, 44 ],
+ [ 34, 36, 38 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ actual = reverseDimension( x, 2, 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' );
+ t.strictEqual( isReadOnly( actual ), true, 'returns expected value' );
+
+ expected = [
+ [
+ [ 14, 12, 10 ],
+ [ 20, 18, 16 ],
+ [ 26, 24, 22 ],
+ [ 32, 30, 28 ]
+ ],
+ [
+ [ 38, 36, 34 ],
+ [ 44, 42, 40 ],
+ [ 50, 48, 46 ],
+ [ 56, 54, 52 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+
+ actual = reverseDimension( x, -1, 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' );
+ t.strictEqual( isReadOnly( actual ), true, 'returns expected value' );
+
+ expected = [
+ [
+ [ 14, 12, 10 ],
+ [ 20, 18, 16 ],
+ [ 26, 24, 22 ],
+ [ 32, 30, 28 ]
+ ],
+ [
+ [ 38, 36, 34 ],
+ [ 44, 42, 40 ],
+ [ 50, 48, 46 ],
+ [ 56, 54, 52 ]
+ ]
+ ];
+ actual = ndarray2array( actual );
+ t.deepEqual( actual, expected, 'returns expected value' );
+ t.end();
+});
+
+tape( 'if provided an ndarray having a constructor supporting read-only instances, the function supports returning a writable view (non-base, ndims=1)', function test( t ) {
+ var expected;
+ var actual;
+ var buf;
+ var ord;
+ var sh;
+ var st;
+ var o;
+ var x;
+ 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 );
+
+ actual = reverseDimension( x, 0, true );
+
+ 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' );
+ t.strictEqual( isReadOnly( actual ), false, 'returns expected value' );
+
+ expected = [ 14, 12, 10, 8, 6, 4 ];
+ for ( i = 0; i < expected.length; i++ ) {
+ t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
+ }
+
+ actual = reverseDimension( x, -1, true );
+
+ 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' );
+ t.strictEqual( isReadOnly( actual ), false, 'returns expected value' );
+
+ expected = [ 14, 12, 10, 8, 6, 4 ];
+ for ( i = 0; i < expected.length; i++ ) {
+ t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
+ }
+ t.end();
+});
+
+tape( 'if provided an ndarray having a constructor which does not support read-only instances, the function is not guaranteed to return either a read-only or writable view (base, ndims=1)', function test( t ) {
+ var expected;
+ var actual;
+ var buf;
+ var ord;
+ var sh;
+ var st;
+ var o;
+ var x;
+ var i;
+
+ buf = typedarray( zeroTo( 30 ), 'float64' );
+ sh = [ 6 ];
+ st = [ 2 ];
+ o = 4;
+ ord = 'row-major';
+
+ x = new baseCtor( 'float64', buf, sh, st, o, ord );
+
+ actual = reverseDimension( x, 0, 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' );
+ t.strictEqual( isReadOnly( actual ), false, 'returns expected value' );
+
+ expected = [ 14, 12, 10, 8, 6, 4 ];
+ for ( i = 0; i < expected.length; i++ ) {
+ t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
+ }
+
+ actual = reverseDimension( x, -1, 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' );
+ t.strictEqual( isReadOnly( actual ), false, 'returns expected value' );
+
+ expected = [ 14, 12, 10, 8, 6, 4 ];
+ for ( i = 0; i < expected.length; i++ ) {
+ t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
+ }
+ t.end();
+});
diff --git a/base/slice-dimension/test/test.js b/base/slice-dimension/test/test.js
index 12db0827..f8046149 100644
--- a/base/slice-dimension/test/test.js
+++ b/base/slice-dimension/test/test.js
@@ -392,6 +392,20 @@ tape( 'the function returns a view of a provided input array (ndims=1)', functio
t.strictEqual( actual.iget( i ), expected[ i ], 'returns expected value' );
}
+ s = new Slice( null );
+ actual = sliceDimension( x, -1, 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' );
+ }
+
// Reverse order and skip every other element:
s = new Slice( null, null, -2 );
actual = sliceDimension( x, 0, s, true, false );
@@ -491,6 +505,24 @@ tape( 'the function returns a view of a provided input array (ndims=2)', functio
actual = ndarray2array( actual );
t.deepEqual( actual, expected, 'returns expected value' );
+ s = new Slice( null );
+ actual = sliceDimension( x, -2, 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 = new Slice( null );
actual = sliceDimension( x, 1, s, true, false );
@@ -509,6 +541,24 @@ tape( 'the function returns a view of a provided input array (ndims=2)', functio
actual = ndarray2array( actual );
t.deepEqual( actual, expected, 'returns expected value' );
+ s = new Slice( null );
+ actual = sliceDimension( x, -1, 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' );
+
// Reverse order and skip every other element:
s = new Slice( null, null, -2 );
actual = sliceDimension( x, 0, s, true, false );
@@ -657,6 +707,32 @@ tape( 'the function returns a view of a provided input array (ndims=3)', functio
actual = ndarray2array( actual );
t.deepEqual( actual, expected, 'returns expected value' );
+ s = new Slice( null );
+ actual = sliceDimension( x, -3, 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 = new Slice( null );
actual = sliceDimension( x, 1, s, true, false );
diff --git a/dist/index.js b/dist/index.js
index b5aa4196..8b9e3d5e 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 Dv=V(function(BY,Rv){"use strict";function Lh(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 Ph(r){var a,e,i;for(a=[],e=1,i=0;i=0;t--)a[t]=i,i*=r[t];return a}function Bh(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}Fv.exports=Jh});var Te=V(function(JY,Kv){"use strict";var Zh=Yv();Kv.exports=Zh});var Jv=V(function(ZY,Gv){"use strict";function Xh(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]}qt.exports=q6});var St=V(function(fK,bt){"use strict";function h6(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}bt.exports=h6});var ce=V(function(dK,jt){"use strict";var b6=require("@stdlib/utils/define-nonenumerable-read-only-property"),wt=ht(),S6=St();b6(wt,"assign",S6);jt.exports=wt});var _t=V(function(lK,Et){"use strict";var w6=ce();function j6(r,a,e,i){var t=w6(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]}Ft.exports=L6});var Gt=V(function(jK,Kt){"use strict";function P6(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}Kt.exports=P6});var Zt=V(function(EK,Jt){"use strict";function V6(){var r,a;for(r=this._offset,a=0;a=0;s--)v=this.iget(this._length-1-s),r+=di(v)+", "+li(v),s>0&&(r+=", ");else for(s=2;s>=0;s--)r+=this.iget(this._length-1-s),s>0&&(r+=", ")}if(e=K6[this.dtype],i+=Y6(e,"{{data}}",r),i+=", ",a===0?i+="[]":i+="[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",a===0)i+="0";else for(s=0;sa?a:r}Ss.exports=Mb});var pi=V(function(BK,js){"use strict";var Bb=ws();js.exports=Bb});var _s=V(function(UK,Es){"use strict";function Ub(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)}Es.exports=Ub});var mi=V(function(FK,Os){"use strict";var Fb=_s();Os.exports=Fb});var ks=V(function(YK,Ts){"use strict";var Yb=pi(),Kb=mi(),Gb=require("@stdlib/string/format");function Jb(r,a,e){if(e==="clamp")return Yb(r,a);if(e==="wrap")return Kb(r,a);if(r<0||r>a)throw new RangeError(Gb("invalid argument. Index must be on the interval: [0, %d]. Value: `%d`.",a,r));return r}Ts.exports=Jb});var Le=V(function(KK,Is){"use strict";var Zb=ks();Is.exports=Zb});var Rs=V(function(GK,Ns){"use strict";var Xb=require("@stdlib/assert/is-integer").isPrimitive,Wb=Le(),Qb=ee(),Hb=require("@stdlib/string/format"),As=Qb.prototype.iget;function $b(r){if(this._ndims>0){if(!Xb(r))throw new TypeError(Hb("invalid argument. Index must be an integer. Value: `%s`.",r));return r=Wb(r,this._length-1,this._mode),As.call(this,r)}return As.call(this)}Ns.exports=$b});var Cs=V(function(JK,zs){"use strict";var r5=require("@stdlib/assert/is-integer").isPrimitive,e5=Le(),a5=ee(),i5=require("@stdlib/string/format"),Ds=a5.prototype.iset;function v5(r,a){if(this._flags.READONLY)throw new Error("invalid invocation. Cannot write to a read-only array.");if(this._ndims>0){if(!r5(r))throw new TypeError(i5("invalid argument. Index must be an integer. Value: `%s`.",r));r=e5(r,this._length-1,this._mode),Ds.call(this,r,a)}else Ds.call(this,r);return this}zs.exports=v5});var Vs=V(function(ZK,Ps){"use strict";var t5=require("@stdlib/assert/is-integer").isPrimitive,s5=Le(),Ls=require("@stdlib/string/format");function o5(){var r,a,e,i;if(arguments.length!==this._ndims)throw new RangeError(Ls("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(ne("invalid argument. Third argument must be an array-like object containing nonnegative integers. Value: `%s`.",e));if(o=e.length,o>eo)throw new RangeError(ne("invalid argument. Number of dimensions must not exceed %u due to stack limits. Value: `%u`.",eo,o));if(!S5(i))throw new TypeError(ne("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(ne("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(ne("invalid argument. Fourth argument must contain a single element equal to 0. Value: `%d`.",i[0]))}if(!b5(t))throw new TypeError(ne("invalid argument. Fifth argument must be a nonnegative integer. Value: `%s`.",t));if(!w5(v))throw new TypeError(ne("invalid argument. Sixth argument must be a supported order. Value: `%s`.",v));if(o>0&&!E5(a.length,e,i,t)&&_5(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=D5,u.readonly=z5,arguments.length>6&&(f=R5(u,s),f))throw f;return this._mode=u.mode,u.submode===void 0&&(u.submode=[this._mode]),this._submode=u.submode,n=ro(e,o),d=ro(i,o||1),ao.call(this,r,a,n,d,t,v),this._flags.READONLY=u.readonly,this}T5(ue,ao);ea(ue,"name","ndarray");ea(ue.prototype,"get",A5);ea(ue.prototype,"iget",k5);ea(ue.prototype,"set",N5);ea(ue.prototype,"iset",I5);io.exports=ue});var fe=V(function(eG,to){"use strict";var C5=vo();to.exports=C5});var so=V(function(aG,L5){L5.exports=["none","equiv","safe","mostly-safe","same-kind","unsafe"]});var no=V(function(iG,oo){"use strict";var P5=so();function V5(){return P5.slice()}oo.exports=V5});var fo=V(function(vG,uo){"use strict";function M5(){return{none:0,equiv:1,safe:2,"mostly-safe":3,"same-kind":4,unsafe:5}}uo.exports=M5});var gi=V(function(tG,co){"use strict";var B5=require("@stdlib/utils/define-nonenumerable-read-only-property"),lo=no(),U5=fo();B5(lo,"enum",U5);co.exports=lo});var mo=V(function(sG,po){"use strict";var F5=gi(),yo=F5(),Y5=yo.length;function K5(r){var a;for(a=0;a0}No.exports=pS});var Sa=V(function(gG,Do){"use strict";var mS=Ro();Do.exports=mS});var zo=V(function(qG,xS){xS.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 Po=V(function(hG,Lo){"use strict";var Co=require("@stdlib/utils/keys"),gS=require("@stdlib/assert/has-own-property"),qS=ae(),ja=zo(),wa;function hS(){var r,a,e,i,t,v,s,o,u;for(e={},r=Co(ja),a=r.length,u=0;u0}Mo.exports=_S});var Ea=V(function(wG,Uo){"use strict";var OS=Bo();Uo.exports=OS});var Fo=V(function(jG,TS){TS.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 Go=V(function(EG,Ko){"use strict";var Yo=require("@stdlib/utils/keys"),kS=require("@stdlib/assert/has-own-property"),IS=ae(),Oa=Fo(),_a;function AS(){var r,a,e,i,t,v,s,o,u;for(e={},r=Yo(Oa),a=r.length,u=0;u0}Zo.exports=LS});var wi=V(function(TG,Wo){"use strict";var PS=Xo();Wo.exports=PS});var Ho=V(function(kG,Qo){"use strict";var VS=Sa(),MS=Ea(),BS=wi();function US(r,a,e){return e==="unsafe"||r===a?!0:e==="none"||e==="equiv"?!1:e==="safe"?VS(r,a):e==="mostly-safe"?MS(r,a):BS(r,a)}Qo.exports=US});var ji=V(function(IG,$o){"use strict";var FS=Ho();$o.exports=FS});var en=V(function(AG,rn){"use strict";var YS=require("@stdlib/buffer/ctor"),KS=require("@stdlib/array/float64"),GS=require("@stdlib/array/float32"),JS=require("@stdlib/array/int16"),ZS=require("@stdlib/array/int32"),XS=require("@stdlib/array/int8"),WS=require("@stdlib/array/uint16"),QS=require("@stdlib/array/uint32"),HS=require("@stdlib/array/uint8"),$S=require("@stdlib/array/uint8c"),r8=require("@stdlib/array/complex64"),e8=require("@stdlib/array/complex128"),a8={binary:YS,float64:KS,float32:GS,generic:Array,int16:JS,int32:ZS,int8:XS,uint16:WS,uint32:QS,uint8:HS,uint8c:$S,complex64:r8,complex128:e8};rn.exports=a8});var vn=V(function(NG,an){"use strict";var i8=en();function v8(r){return i8[r]||null}an.exports=v8});var ia=V(function(RG,tn){"use strict";var t8=vn();tn.exports=t8});var on=V(function(DG,sn){"use strict";function s8(r){var a;for(a=0;a=0&&r.length=fj(a)}mu.exports=dj});var qu=V(function(dJ,gu){"use strict";var lj=xu();gu.exports=lj});var Su=V(function(lJ,bu){"use strict";var hu=require("@stdlib/math/base/special/abs");function cj(r){var a,e,i,t;if(a=r.length,a===0)return!1;for(e=hu(r[0]),t=1;te)return!1;e=i}return!0}vf.exports=r7});var Ri=V(function(zJ,sf){"use strict";var e7=tf();sf.exports=e7});var nf=V(function(CJ,of){"use strict";var a7=va(),i7=oe(),v7=Ri();function t7(r,a,e){return i7(a)!==0&&v7(a)&&a7(r,a,e)}of.exports=t7});var ff=V(function(LJ,uf){"use strict";var s7=nf();uf.exports=s7});var lf=V(function(PJ,df){"use strict";var o7=require("@stdlib/array/base/assert/contains").factory,n7=Fr(),u7=o7(n7("signed_integer"));df.exports=u7});var Da=V(function(VJ,cf){"use strict";var f7=lf();cf.exports=f7});var pf=V(function(MJ,yf){"use strict";var d7=require("@stdlib/array/base/assert/contains").factory,l7=Fr(),c7=d7(l7("unsigned_integer"));yf.exports=c7});var za=V(function(BJ,mf){"use strict";var y7=pf();mf.exports=y7});var gf=V(function(UJ,xf){"use strict";var Pr=require("@stdlib/utils/define-read-only-property"),Lr={};Pr(Lr,"isAllowedDataTypeCast",ji());Pr(Lr,"isBufferLengthCompatible",fi());Pr(Lr,"isBufferLengthCompatibleShape",qu());Pr(Lr,"isCastingMode",qi());Pr(Lr,"isColumnMajor",ki());Pr(Lr,"isColumnMajorContiguous",Iu());Pr(Lr,"isComplexFloatingPointDataType",ta());Pr(Lr,"isContiguous",Lu());Pr(Lr,"isDataType",Ce());Pr(Lr,"isFloatingPointDataType",Na());Pr(Lr,"isIndexMode",ra());Pr(Lr,"isIntegerDataType",Ii());Pr(Lr,"isMostlySafeDataTypeCast",Ea());Pr(Lr,"isNumericDataType",Ai());Pr(Lr,"isOrder",$r());Pr(Lr,"isReadOnly",je());Pr(Lr,"isRealDataType",Ra());Pr(Lr,"isRealFloatingPointDataType",Ni());Pr(Lr,"isRowMajor",Ri());Pr(Lr,"isRowMajorContiguous",ff());Pr(Lr,"isSafeDataTypeCast",Sa());Pr(Lr,"isSameKindDataTypeCast",wi());Pr(Lr,"isSignedIntegerDataType",Da());Pr(Lr,"isSingleSegmentCompatible",va());Pr(Lr,"isUnsignedIntegerDataType",za());xf.exports=Lr});var hf=V(function(FJ,qf){"use strict";function p7(r){return r.dtype}qf.exports=p7});var Zr=V(function(YJ,bf){"use strict";var m7=hf();bf.exports=m7});var wf=V(function(KJ,Sf){"use strict";var x7=require("@stdlib/array/base/copy-indexed");function g7(r,a){var e=r.shape;return a?x7(e):e}Sf.exports=g7});var Kr=V(function(GJ,jf){"use strict";var q7=wf();jf.exports=q7});var _f=V(function(JJ,Ef){"use strict";var h7=Yr(),b7=require("@stdlib/array/base/copy-indexed"),S7="row-major";function w7(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=S7),h7(i,e))):a?b7(t):t}Ef.exports=w7});var se=V(function(ZJ,Of){"use strict";var j7=_f();Of.exports=j7});var kf=V(function(XJ,Tf){"use strict";var E7=Gr();function _7(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:E7(e,a))}Tf.exports=_7});var de=V(function(WJ,If){"use strict";var O7=kf();If.exports=O7});var Nf=V(function(QJ,Af){"use strict";var T7=Te(),Di="row-major",k7="column-major";function I7(r){var a,e;return e=r.order,typeof e=="string"?e:(a=r.strides,typeof a!="object"||a===null||(e=T7(a),e===1||e===3)?Di:e===2?k7:r.shape.length===0?Di:null)}Af.exports=I7});var Xr=V(function(HJ,Rf){"use strict";var A7=Nf();Rf.exports=A7});var zf=V(function($J,Df){"use strict";function N7(r){return r.data}Df.exports=N7});var pe=V(function(rZ,Cf){"use strict";var R7=zf();Cf.exports=R7});var Pf=V(function(eZ,Lf){"use strict";var D7=require("@stdlib/array/base/assert/is-accessor-array"),z7=require("@stdlib/array/base/accessor-getter"),C7=require("@stdlib/array/base/accessor-setter"),L7=require("@stdlib/array/base/getter"),P7=require("@stdlib/array/base/setter"),V7=Cr(),M7=Zr(),B7=Kr(),U7=se(),F7=de(),Y7=Xr(),K7=pe();function G7(r){var a,e,i,t;return a=K7(r),i=B7(r,!0),t=M7(r),e=D7(a),{ref:r,dtype:t,data:a,length:V7(i),shape:i,strides:U7(r,!0),offset:F7(r),order:Y7(r),accessorProtocol:e,accessors:e?[z7(t),C7(t)]:[L7(t),P7(t)]}}Lf.exports=G7});var Be=V(function(aZ,Vf){"use strict";var J7=Pf();Vf.exports=J7});var Bf=V(function(iZ,Mf){"use strict";function Z7(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}}Mf.exports=Z7});var Yf=V(function(vZ,Ff){"use strict";var X7=require("@stdlib/array/base/zero-to"),W7=require("@stdlib/array/base/copy-indexed"),Uf=require("@stdlib/array/base/take"),Q7=Bf();function H7(r,a,e){var i;return i=X7(r.length),a=W7(a),Q7(a,i),r=Uf(r,i),e=Uf(e,i),{sh:r,sx:a,sy:e}}Ff.exports=H7});var kr=V(function(tZ,Kf){"use strict";var $7=Yf();Kf.exports=$7});var Jf=V(function(sZ,Gf){"use strict";var rE={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};Gf.exports=rE});var Wf=V(function(oZ,Xf){"use strict";var Zf=qe(),zi=Jf();function eE(r,a){var e,i;return e=Zf(r),i=Zf(a),e===null||i===null?zi.BLOCK_SIZE_IN_ELEMENTS:e>i?zi.BLOCK_SIZE_IN_BYTES/e|0:zi.BLOCK_SIZE_IN_BYTES/i|0}Xf.exports=eE});var Ir=V(function(nZ,Qf){"use strict";var aE=Wf();Qf.exports=aE});var $f=V(function(uZ,Hf){"use strict";var iE=kr(),vE=Ir();function tE(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=iE(r.shape,r.strides,a.strides),E=b.sh,h=b.sx,m=b.sy,e=vE(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(y_("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}a0.exports=p_});var le=V(function(VZ,v0){"use strict";var m_=i0();v0.exports=m_});var n0=V(function(MZ,o0){"use strict";var x_=Cr(),t0=le(),s0="throw";function g_(r,a){var e,i,t,v,s,o,u,f,n,d,q,E,y,p,h;for(f=r.shape,s=x_(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}}U0.exports=TO});var G0=V(function(aX,K0){"use strict";var kO=require("@stdlib/array/base/zero-to"),IO=require("@stdlib/array/base/copy-indexed"),Ca=require("@stdlib/array/base/take"),AO=require("@stdlib/array/base/filled"),Li=Te(),NO=F0(),Y0=3;function RO(r,a,e,i){var t,v,s,o,u,f,n,d,q,E;if(t=kO(r.length),f=Li(a),n=Li(e),d=Li(i),v=AO([],4),v[f].push(a),v[n].push(e),v[d].push(i),s=v[0].length,s===Y0)u=a;else if(s===Y0-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=IO(u),NO(u,t),r=Ca(r,t),a=a===u?u:Ca(a,t),e=e===u?u:Ca(e,t),i=i===u?u:Ca(i,t),{sh:r,sx:a,sy:e,sz:i}}K0.exports=RO});var Z0=V(function(iX,J0){"use strict";var DO=G0();J0.exports=DO});var W0=V(function(vX,X0){"use strict";var zO={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};X0.exports=zO});var H0=V(function(tX,Q0){"use strict";var Pi=qe(),La=W0();function CO(r,a,e){var i,t,v;return i=Pi(r),t=Pi(a),v=Pi(e),i===null||t===null||v===null?La.BLOCK_SIZE_IN_ELEMENTS:i>t&&i>v?La.BLOCK_SIZE_IN_BYTES/i|0:t>v?La.BLOCK_SIZE_IN_BYTES/t|0:La.BLOCK_SIZE_IN_BYTES/v|0}Q0.exports=CO});var rl=V(function(sX,$0){"use strict";var LO=H0();$0.exports=LO});var il=V(function(oX,al){"use strict";var PO=require("@stdlib/string/format"),Pa=require("@stdlib/math/base/special/trunc"),el=require("@stdlib/math/base/special/abs");function VO(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(PO("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=Pa(t/n),t-=f*n,f+=r[d]-1):(f=Pa(t/n),t-=f*n),u+=f*el(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}yl.exports=tT});var xl=V(function(yX,ml){"use strict";var sT=pl();ml.exports=sT});var ql=V(function(pX,gl){"use strict";var oT=aa(),nT=Ta();function uT(r){var a=nT(r);return a?oT(a):null}gl.exports=uT});var bl=V(function(mX,hl){"use strict";var fT=ql();hl.exports=fT});var wl=V(function(xX,Sl){"use strict";function dT(){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"}}Sl.exports=dT});var _l=V(function(gX,El){"use strict";var lT=ae(),jl=wl(),Vi;function cT(r){return arguments.length===0?jl():(Vi===void 0&&(Vi=jl()),Vi[lT(r)]||null)}El.exports=cT});var Mi=V(function(qX,Ol){"use strict";var yT=_l();Ol.exports=yT});var Al=V(function(hX,Il){"use strict";var Tl=require("@stdlib/utils/object-inverse"),kl=Mi(),Bi;function pT(r){return arguments.length===0?Tl(kl()):(Bi===void 0&&(Bi=Tl(kl())),Bi[r]||null)}Il.exports=pT});var Rl=V(function(bX,Nl){"use strict";var mT=Al();Nl.exports=mT});var zl=V(function(SX,Dl){"use strict";function xT(){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"}}Dl.exports=xT});var Pl=V(function(wX,Ll){"use strict";var gT=ae(),Cl=zl(),Ui;function qT(r){return arguments.length===0?Cl():(Ui===void 0&&(Ui=Cl()),Ui[gT(r)]||null)}Ll.exports=qT});var Ml=V(function(jX,Vl){"use strict";var hT=Pl();Vl.exports=hT});var Ul=V(function(EX,Bl){"use strict";var bT=qa(),ST=aa();function wT(r){var a=typeof r;return a==="number"?bT(r)?r:null:a==="string"?ST(r):null}Bl.exports=wT});var Fi=V(function(_X,Fl){"use strict";var jT=Ul();Fl.exports=jT});var Yl=V(function(OX,ET){ET.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 Gl=V(function(TX,Kl){"use strict";var _T=ae(),OT=Yl();function TT(r){return OT[_T(r)]||null}Kl.exports=TT});var Zl=V(function(kX,Jl){"use strict";var kT=Gl();Jl.exports=kT});var Ql=V(function(IX,Wl){"use strict";var IT=require("@stdlib/assert/is-array-like-object"),Xl=require("@stdlib/assert/is-nonnegative-integer").isPrimitive,AT=ae(),Yi=require("@stdlib/string/format");function NT(r,a,e){var i,t,v,s,o,u,f,n;if(!IT(r))throw new TypeError(Yi("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!Xl(a))throw new TypeError(Yi("invalid argument. Second argument must be a nonnegative integer. Value: `%s`.",a));if(!Xl(e))throw new TypeError(Yi("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=LT(a),s=DT(a,e)):(v=1,s=[0]),r==="binary"?t=VT(v):t=PT(v,r),new CT(r,t,a,s,zT(a,s),e)}$l.exports=MT});var a1=V(function(RX,e1){"use strict";var BT=r1();e1.exports=BT});var v1=V(function(DX,i1){"use strict";var UT=Yr(),FT=Gr(),YT=Cr(),KT=Zr(),GT=Kr(),JT=Xr(),ZT=require("@stdlib/array/empty"),XT=require("@stdlib/buffer/alloc-unsafe");function WT(r){var a,e,i,t,v,s,o;return o=KT(r),v=GT(r,!0),t=JT(r),a=v.length,a>0?(e=YT(v),s=UT(v,t)):(e=1,s=[0]),o==="binary"?i=XT(e):i=ZT(e,o),new r.constructor(o,i,v,s,FT(v,s),t)}i1.exports=WT});var s1=V(function(zX,t1){"use strict";var QT=v1();t1.exports=QT});var l1=V(function(CX,d1){"use strict";var HT=je(),o1=Zr(),$T=Kr(),rk=se(),n1=de(),ek=Xr(),u1=pe(),f1=require("@stdlib/string/format");function ak(r,a){var e,i,t,v,s,o,u;if(v=$T(r,!1),s=rk(r,!1),t=ek(r),o=v.length,e=[],i=[],a<0){if(a<-o-1)throw new RangeError(f1("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(f1("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;u=u&&(t=u-1);else if(v==="wrap")t<0?(t+=u,t<0&&(t%=u,t!==0&&(t+=u))):t>=u&&(t-=u,t>=u&&(t%=u));else if(t<0||t>=u)throw new RangeError(lk("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=Ma(t/n),t-=f*n,s[d]=r[d]-1+f):(f=Ma(t/n),t-=f*n,s[d]=f);return s}for(d=0;d0&&(t+=a[v]*(r[v]-1))}return t}j1.exports=gk});var O1=V(function(YX,_1){"use strict";var qk=E1();_1.exports=qk});var I1=V(function(KX,k1){"use strict";var T1=Va(),hk=Kr();function bk(r,a){var e,i,t;if(i=a.length,e=hk(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 Rk(r,a,e,i,t){var v,s;for(v=0;v0));v++);for(v+=1;v=v)return null;return a===Ak?Nk(v,r,e,i,t):Rk(v,r,e,i,t)}Y1.exports=Dk});var G1=V(function(rW,K1){"use strict";var zk=require("@stdlib/array/base/zeros"),Ck=Zi();function Lk(r,a,e,i){return Ck(r,a,e,i,zk(r.length))}K1.exports=Lk});var Ne=V(function(eW,Z1){"use strict";var Pk=require("@stdlib/utils/define-nonenumerable-read-only-property"),J1=G1(),Vk=Zi();Pk(J1,"assign",Vk);Z1.exports=J1});var W1=V(function(aW,X1){"use strict";function Mk(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}}$1.exports=Uk});var ac=V(function(tW,ec){"use strict";var Fk=require("@stdlib/array/base/zero-to"),Yk=require("@stdlib/array/base/copy-indexed"),Kk=require("@stdlib/array/base/take"),Gk=rc();function Jk(r,a){var e;return e=Fk(r.length),a=Yk(a),Gk(a,e),r=Kk(r,e),{sh:r,sx:a}}ec.exports=Jk});var Mr=V(function(sW,ic){"use strict";var Zk=ac();ic.exports=Zk});var tc=V(function(oW,vc){"use strict";var Xk={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};vc.exports=Xk});var nc=V(function(nW,oc){"use strict";var Wk=qe(),sc=tc();function Qk(r){var a=Wk(r);return a===null?sc.BLOCK_SIZE_IN_ELEMENTS:sc.BLOCK_SIZE_IN_BYTES/a|0}oc.exports=Qk});var Br=V(function(uW,uc){"use strict";var Hk=nc();uc.exports=Hk});var dc=V(function(fW,fc){"use strict";var $k=Mr(),rI=Br();function eI(r,a){var e,i,t,v,s,o,u,f,n,d,q,E,y,p,h,m,j;for(j=$k(r.shape,r.strides),u=j.sh,d=j.sx,e=rI(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(T0;)for(b0;)for(c0;)for(g0;)for(l0;)for(R0;)for(N0;)for(O0;)for(A0;)for(_0;)for(C0;)for(I0;)for(z0;)for(D0;)for(k0;)for(R0;)for(U