diff --git a/base/data-buffer/README.md b/base/data-buffer/README.md
new file mode 100644
index 00000000..bab05232
--- /dev/null
+++ b/base/data-buffer/README.md
@@ -0,0 +1,154 @@
+
+
+# data
+
+> Return the underlying [data buffer][@stdlib/ndarray/base/buffer] of a provided [ndarray][@stdlib/ndarray/base/ctor].
+
+
+
+
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var data = require( '@stdlib/ndarray/base/data-buffer' );
+```
+
+#### data( x )
+
+Returns the underlying [data buffer][@stdlib/ndarray/base/buffer] of a provided [ndarray][@stdlib/ndarray/base/ctor].
+
+```javascript
+var zeros = require( '@stdlib/ndarray/zeros' );
+
+var x = zeros( [ 3, 2, 3 ], {
+ 'dtype': 'float64'
+});
+// returns
+
+var out = data( x );
+// returns
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var zeros = require( '@stdlib/ndarray/zeros' );
+var data = require( '@stdlib/ndarray/base/data-buffer' );
+
+// Create a 'float64' array...
+var opts = {
+ 'dtype': 'float64'
+};
+var x = zeros( [ 2, 2 ], opts );
+// returns
+
+var buf = data( x );
+// returns
+
+// Create a 'float32' array...
+opts = {
+ 'dtype': 'float32'
+};
+x = zeros( [ 2, 2 ], opts );
+// returns
+
+buf = data( x );
+// returns
+
+// Create a 'complex128' array...
+opts = {
+ 'dtype': 'complex128'
+};
+x = zeros( [ 2, 2 ], opts );
+// returns
+
+buf = data( x );
+// returns
+
+// Create an 'int32' array...
+opts = {
+ 'dtype': 'int32'
+};
+x = zeros( [ 2, 2 ], opts );
+// returns
+
+buf = data( x );
+// returns
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray/tree/main/base/ctor
+
+[@stdlib/ndarray/base/buffer]: https://github.com/stdlib-js/ndarray/tree/main/base/buffer
+
+
+
+
diff --git a/base/data-buffer/benchmark/benchmark.js b/base/data-buffer/benchmark/benchmark.js
new file mode 100644
index 00000000..2df0b349
--- /dev/null
+++ b/base/data-buffer/benchmark/benchmark.js
@@ -0,0 +1,57 @@
+/**
+* @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 isCollection = require( '@stdlib/assert/is-collection' );
+var typedarray = require( '@stdlib/array/typed' );
+var ndarray = require( './../../../ctor' );
+var pkg = require( './../package.json' ).name;
+var data = require( './../lib' );
+
+
+// MAIN //
+
+bench( pkg, function benchmark( b ) {
+ var values;
+ var out;
+ var i;
+
+ values = [
+ ndarray( 'float64', typedarray( 20000, 'float64' ), [ 10, 10, 10, 1 ], [ 1000, 100, 10, 1 ], 100, 'row-major' ),
+ ndarray( 'int32', typedarray( 20000, 'int32' ), [ 5, 5, 5, 1, 1 ], [ 125, 25, 5, 1, 1 ], 50, 'row-major' ),
+ ndarray( 'uint8', typedarray( 20000, 'uint8' ), [ 3, 4, 5 ], [ 20, 5, 1 ], 72, 'row-major' )
+ ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ out = data( values[ i%values.length ] );
+ if ( typeof out !== 'object' ) {
+ b.fail( 'should return a collection' );
+ }
+ }
+ b.toc();
+ if ( !isCollection( out ) ) {
+ b.fail( 'should return a collection' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
diff --git a/base/data-buffer/docs/repl.txt b/base/data-buffer/docs/repl.txt
new file mode 100644
index 00000000..e15618a8
--- /dev/null
+++ b/base/data-buffer/docs/repl.txt
@@ -0,0 +1,23 @@
+
+{{alias}}( x )
+ Returns the underlying data buffer of a provided ndarray.
+
+ Parameters
+ ----------
+ x: ndarray
+ Input ndarray.
+
+ Returns
+ -------
+ out: ArrayLikeObject
+ Underlying data buffer.
+
+ Examples
+ --------
+ > var opts = { 'dtype': 'float64' };
+ > var out = {{alias}}( {{alias:@stdlib/ndarray/zeros}}( [ 3, 3, 3 ], opts ) )
+
+
+ See Also
+ --------
+
diff --git a/base/data-buffer/docs/types/index.d.ts b/base/data-buffer/docs/types/index.d.ts
new file mode 100644
index 00000000..b999144f
--- /dev/null
+++ b/base/data-buffer/docs/types/index.d.ts
@@ -0,0 +1,262 @@
+/*
+* @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 the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'float64'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: float64ndarray ): float64ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'float32'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: float32ndarray ): float32ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'int32'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: int32ndarray ): int32ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'int16'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: int16ndarray ): int16ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'int8'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: int8ndarray ): int8ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'uint32'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: uint32ndarray ): uint32ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'uint16'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: uint16ndarray ): uint16ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'uint8'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: uint8ndarray ): uint8ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'uint8c'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: uint8cndarray ): uint8cndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'complex128'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: complex128ndarray ): complex128ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'complex64'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: complex64ndarray ): complex64ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'generic'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: genericndarray ): genericndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'float64'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: typedndarray ): typedndarray[ 'data' ];
+
+
+// EXPORTS //
+
+export = data;
diff --git a/base/data-buffer/docs/types/test.ts b/base/data-buffer/docs/types/test.ts
new file mode 100644
index 00000000..8417a7cd
--- /dev/null
+++ b/base/data-buffer/docs/types/test.ts
@@ -0,0 +1,58 @@
+/*
+* @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 zeros = require( './../../../../zeros' );
+import data = require( './index' );
+
+
+// TESTS //
+
+// The function returns an ndarray buffer...
+{
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'float64' } ) ); // $ExpectType Float64Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'float32' } ) ); // $ExpectType Float32Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'int32' } ) ); // $ExpectType Int32Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'int16' } ) ); // $ExpectType Int16Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'int8' } ) ); // $ExpectType Int8Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'uint32' } ) ); // $ExpectType Uint32Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'uint16' } ) ); // $ExpectType Uint16Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'uint8' } ) ); // $ExpectType Uint8Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'uint8c' } ) ); // $ExpectType Uint8ClampedArray
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'complex128' } ) ); // $ExpectType Complex128Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'complex64' } ) ); // $ExpectType Complex64Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'generic' } ) ); // $ExpectType ArrayLike
+}
+
+// The compiler throws an error if the function is provided a value other than an ndarray...
+{
+ data( '5' ); // $ExpectError
+ data( 5 ); // $ExpectError
+ data( true ); // $ExpectError
+ data( false ); // $ExpectError
+ data( null ); // $ExpectError
+ data( undefined ); // $ExpectError
+ data( [ '1', '2' ] ); // $ExpectError
+ data( {} ); // $ExpectError
+ data( ( x: number ): number => x ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ data(); // $ExpectError
+ data( zeros( [ 2, 2 ] ), {} ); // $ExpectError
+}
diff --git a/base/data-buffer/examples/index.js b/base/data-buffer/examples/index.js
new file mode 100644
index 00000000..de684549
--- /dev/null
+++ b/base/data-buffer/examples/index.js
@@ -0,0 +1,70 @@
+/**
+* @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 zeros = require( './../../../zeros' );
+var data = require( './../lib' );
+
+// Create a 'float64' array...
+var opts = {
+ 'dtype': 'float64'
+};
+var x = zeros( [ 2, 2 ], opts );
+// returns
+
+var buf = data( x );
+// returns
+
+console.log( buf );
+
+// Create a 'float32' array...
+opts = {
+ 'dtype': 'float32'
+};
+x = zeros( [ 2, 2 ], opts );
+// returns
+
+buf = data( x );
+// returns
+
+console.log( buf );
+
+// Create a 'complex128' array...
+opts = {
+ 'dtype': 'complex128'
+};
+x = zeros( [ 2, 2 ], opts );
+// returns
+
+buf = data( x );
+// returns
+
+console.log( buf );
+
+// Create an 'int32' array...
+opts = {
+ 'dtype': 'int32'
+};
+x = zeros( [ 2, 2 ], opts );
+// returns
+
+buf = data( x );
+// returns
+
+console.log( buf );
diff --git a/base/data-buffer/lib/index.js b/base/data-buffer/lib/index.js
new file mode 100644
index 00000000..6c99bfca
--- /dev/null
+++ b/base/data-buffer/lib/index.js
@@ -0,0 +1,45 @@
+/**
+* @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 the underlying data buffer of a provided ndarray.
+*
+* @module @stdlib/ndarray/base/data-buffer
+*
+* @example
+* var zeros = require( '@stdlib/ndarray/zeros' );
+* var data = require( '@stdlib/ndarray/base/data-buffer' );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'float64'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/base/data-buffer/lib/main.js b/base/data-buffer/lib/main.js
new file mode 100644
index 00000000..05ac855c
--- /dev/null
+++ b/base/data-buffer/lib/main.js
@@ -0,0 +1,46 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MAIN //
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param {ndarrayLike} x - input ndarray
+* @returns {Collection} underlying data buffer
+*
+* @example
+* var zeros = require( '@stdlib/ndarray/zeros' );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'float64'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+function data( x ) {
+ return x.data;
+}
+
+
+// EXPORTS //
+
+module.exports = data;
diff --git a/base/data-buffer/package.json b/base/data-buffer/package.json
new file mode 100644
index 00000000..9959e13e
--- /dev/null
+++ b/base/data-buffer/package.json
@@ -0,0 +1,69 @@
+{
+ "name": "@stdlib/ndarray/base/data-buffer",
+ "version": "0.0.0",
+ "description": "Return the underlying data buffer of a provided ndarray.",
+ "license": "Apache-2.0",
+ "author": {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ },
+ "contributors": [
+ {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ }
+ ],
+ "main": "./lib",
+ "directories": {
+ "benchmark": "./benchmark",
+ "doc": "./docs",
+ "example": "./examples",
+ "lib": "./lib",
+ "test": "./test"
+ },
+ "types": "./docs/types",
+ "scripts": {},
+ "homepage": "https://github.com/stdlib-js/stdlib",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/stdlib-js/stdlib.git"
+ },
+ "bugs": {
+ "url": "https://github.com/stdlib-js/stdlib/issues"
+ },
+ "dependencies": {},
+ "devDependencies": {},
+ "engines": {
+ "node": ">=0.10.0",
+ "npm": ">2.7.0"
+ },
+ "os": [
+ "aix",
+ "darwin",
+ "freebsd",
+ "linux",
+ "macos",
+ "openbsd",
+ "sunos",
+ "win32",
+ "windows"
+ ],
+ "keywords": [
+ "stdlib",
+ "stdtypes",
+ "types",
+ "base",
+ "ndarray",
+ "data",
+ "buffer",
+ "memory",
+ "storage",
+ "multidimensional",
+ "array",
+ "utilities",
+ "utility",
+ "utils",
+ "util"
+ ],
+ "__stdlib__": {}
+}
diff --git a/base/data-buffer/test/test.js b/base/data-buffer/test/test.js
new file mode 100644
index 00000000..8b1a03e2
--- /dev/null
+++ b/base/data-buffer/test/test.js
@@ -0,0 +1,121 @@
+/**
+* @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 zeros = require( './../../../zeros' );
+var buffer = require( './../../../base/buffer' );
+var data = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof data, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function returns the underlying data buffer of a provided ndarray', function test( t ) {
+ var expected;
+ var values;
+ var actual;
+ var i;
+
+ values = [
+ zeros( [], {
+ 'dtype': 'float64'
+ }),
+ zeros( [ 3, 3, 3 ], {
+ 'dtype': 'float32'
+ }),
+ zeros( [ 1, 1 ], {
+ 'dtype': 'int32'
+ }),
+ zeros( [ 3, 3, 0, 3 ], {
+ 'dtype': 'uint32'
+ }),
+ zeros( [ 1, 2, 3, 4 ], {
+ 'dtype': 'int8'
+ }),
+ zeros( [ 5 ], {
+ 'dtype': 'uint8'
+ })
+ ];
+
+ expected = [
+ values[ 0 ].data,
+ values[ 1 ].data,
+ values[ 2 ].data,
+ values[ 3 ].data,
+ values[ 4 ].data,
+ values[ 5 ].data
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ actual = data( values[ i ] );
+ t.strictEqual( actual, expected[ i ], 'returns expected value' );
+ }
+ t.end();
+});
+
+tape( 'the function accepts minimal ndarray-like objects (data)', function test( t ) {
+ var expected;
+ var values;
+ var actual;
+ var i;
+
+ values = [
+ {
+ 'data': buffer( 'float64', 10 )
+ },
+ {
+ 'data': buffer( 'float32', 10 )
+ },
+ {
+ 'data': buffer( 'int32', 10 )
+ },
+ {
+ 'data': buffer( 'uint32', 10 )
+ },
+ {
+ 'data': buffer( 'int8', 10 )
+ },
+ {
+ 'data': buffer( 'uint8', 10 )
+ }
+ ];
+
+ expected = [
+ values[ 0 ].data,
+ values[ 1 ].data,
+ values[ 2 ].data,
+ values[ 3 ].data,
+ values[ 4 ].data,
+ values[ 5 ].data
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ actual = data( values[ i ] );
+ t.strictEqual( actual, expected[ i ], 'returns expected value' );
+ }
+ t.end();
+});
diff --git a/base/lib/index.js b/base/lib/index.js
index 63136742..56c004f8 100644
--- a/base/lib/index.js
+++ b/base/lib/index.js
@@ -175,6 +175,15 @@ setReadOnly( ns, 'clampIndex', require( './../../base/clamp-index' ) );
*/
setReadOnly( ns, 'ndarray', require( './../../base/ctor' ) );
+/**
+* @name data
+* @memberof ns
+* @readonly
+* @type {Function}
+* @see {@link module:@stdlib/ndarray/base/data-buffer}
+*/
+setReadOnly( ns, 'data', require( './../../base/data-buffer' ) );
+
/**
* @name dtype
* @memberof ns
diff --git a/data-buffer/README.md b/data-buffer/README.md
new file mode 100644
index 00000000..2895ce37
--- /dev/null
+++ b/data-buffer/README.md
@@ -0,0 +1,152 @@
+
+
+# data
+
+> Return the underlying data buffer of a provided [ndarray][@stdlib/ndarray/ctor].
+
+
+
+
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var data = require( '@stdlib/ndarray/data-buffer' );
+```
+
+#### data( x )
+
+Returns the underlying data buffer of a provided [ndarray][@stdlib/ndarray/ctor].
+
+```javascript
+var zeros = require( '@stdlib/ndarray/zeros' );
+
+var x = zeros( [ 3, 2, 3 ], {
+ 'dtype': 'float64'
+});
+// returns
+
+var out = data( x );
+// returns
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var zeros = require( '@stdlib/ndarray/zeros' );
+var data = require( '@stdlib/ndarray/data-buffer' );
+
+// Create a 'float64' array...
+var opts = {
+ 'dtype': 'float64'
+};
+var x = zeros( [ 2, 2 ], opts );
+// returns
+
+var buf = data( x );
+// returns
+
+// Create a 'float32' array...
+opts = {
+ 'dtype': 'float32'
+};
+x = zeros( [ 2, 2 ], opts );
+// returns
+
+buf = data( x );
+// returns
+
+// Create a 'complex128' array...
+opts = {
+ 'dtype': 'complex128'
+};
+x = zeros( [ 2, 2 ], opts );
+// returns
+
+buf = data( x );
+// returns
+
+// Create an 'int32' array...
+opts = {
+ 'dtype': 'int32'
+};
+x = zeros( [ 2, 2 ], opts );
+// returns
+
+buf = data( x );
+// returns
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray/tree/main/ctor
+
+
+
+
diff --git a/data-buffer/benchmark/benchmark.js b/data-buffer/benchmark/benchmark.js
new file mode 100644
index 00000000..ddef0beb
--- /dev/null
+++ b/data-buffer/benchmark/benchmark.js
@@ -0,0 +1,57 @@
+/**
+* @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 isCollection = require( '@stdlib/assert/is-collection' );
+var typedarray = require( '@stdlib/array/typed' );
+var ndarray = require( './../../ctor' );
+var pkg = require( './../package.json' ).name;
+var data = require( './../lib' );
+
+
+// MAIN //
+
+bench( pkg, function benchmark( b ) {
+ var values;
+ var out;
+ var i;
+
+ values = [
+ ndarray( 'float64', typedarray( 20000, 'float64' ), [ 10, 10, 10, 1 ], [ 1000, 100, 10, 1 ], 100, 'row-major' ),
+ ndarray( 'int32', typedarray( 20000, 'int32' ), [ 5, 5, 5, 1, 1 ], [ 125, 25, 5, 1, 1 ], 50, 'row-major' ),
+ ndarray( 'uint8', typedarray( 20000, 'uint8' ), [ 3, 4, 5 ], [ 20, 5, 1 ], 72, 'row-major' )
+ ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ out = data( values[ i%values.length ] );
+ if ( typeof out !== 'object' ) {
+ b.fail( 'should return a collection' );
+ }
+ }
+ b.toc();
+ if ( !isCollection( out ) ) {
+ b.fail( 'should return a collection' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
diff --git a/data-buffer/docs/repl.txt b/data-buffer/docs/repl.txt
new file mode 100644
index 00000000..e15618a8
--- /dev/null
+++ b/data-buffer/docs/repl.txt
@@ -0,0 +1,23 @@
+
+{{alias}}( x )
+ Returns the underlying data buffer of a provided ndarray.
+
+ Parameters
+ ----------
+ x: ndarray
+ Input ndarray.
+
+ Returns
+ -------
+ out: ArrayLikeObject
+ Underlying data buffer.
+
+ Examples
+ --------
+ > var opts = { 'dtype': 'float64' };
+ > var out = {{alias}}( {{alias:@stdlib/ndarray/zeros}}( [ 3, 3, 3 ], opts ) )
+
+
+ See Also
+ --------
+
diff --git a/data-buffer/docs/types/index.d.ts b/data-buffer/docs/types/index.d.ts
new file mode 100644
index 00000000..b999144f
--- /dev/null
+++ b/data-buffer/docs/types/index.d.ts
@@ -0,0 +1,262 @@
+/*
+* @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 the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'float64'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: float64ndarray ): float64ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'float32'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: float32ndarray ): float32ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'int32'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: int32ndarray ): int32ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'int16'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: int16ndarray ): int16ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'int8'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: int8ndarray ): int8ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'uint32'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: uint32ndarray ): uint32ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'uint16'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: uint16ndarray ): uint16ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'uint8'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: uint8ndarray ): uint8ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'uint8c'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: uint8cndarray ): uint8cndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'complex128'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: complex128ndarray ): complex128ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'complex64'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: complex64ndarray ): complex64ndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'generic'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: genericndarray ): genericndarray[ 'data' ];
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param x - input ndarray
+* @returns underlying data buffer
+*
+* @example
+* var zeros = require( `@stdlib/ndarray/zeros` );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'float64'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+declare function data( x: typedndarray ): typedndarray[ 'data' ];
+
+
+// EXPORTS //
+
+export = data;
diff --git a/data-buffer/docs/types/test.ts b/data-buffer/docs/types/test.ts
new file mode 100644
index 00000000..a7dcadb1
--- /dev/null
+++ b/data-buffer/docs/types/test.ts
@@ -0,0 +1,58 @@
+/*
+* @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 zeros = require( './../../../zeros' );
+import data = require( './index' );
+
+
+// TESTS //
+
+// The function returns an ndarray buffer...
+{
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'float64' } ) ); // $ExpectType Float64Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'float32' } ) ); // $ExpectType Float32Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'int32' } ) ); // $ExpectType Int32Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'int16' } ) ); // $ExpectType Int16Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'int8' } ) ); // $ExpectType Int8Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'uint32' } ) ); // $ExpectType Uint32Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'uint16' } ) ); // $ExpectType Uint16Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'uint8' } ) ); // $ExpectType Uint8Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'uint8c' } ) ); // $ExpectType Uint8ClampedArray
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'complex128' } ) ); // $ExpectType Complex128Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'complex64' } ) ); // $ExpectType Complex64Array
+ data( zeros( [ 3, 2, 1 ], { 'dtype': 'generic' } ) ); // $ExpectType ArrayLike
+}
+
+// The compiler throws an error if the function is provided a value other than an ndarray...
+{
+ data( '5' ); // $ExpectError
+ data( 5 ); // $ExpectError
+ data( true ); // $ExpectError
+ data( false ); // $ExpectError
+ data( null ); // $ExpectError
+ data( undefined ); // $ExpectError
+ data( [ '1', '2' ] ); // $ExpectError
+ data( {} ); // $ExpectError
+ data( ( x: number ): number => x ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ data(); // $ExpectError
+ data( zeros( [ 2, 2 ] ), {} ); // $ExpectError
+}
diff --git a/data-buffer/examples/index.js b/data-buffer/examples/index.js
new file mode 100644
index 00000000..4d1b8c46
--- /dev/null
+++ b/data-buffer/examples/index.js
@@ -0,0 +1,70 @@
+/**
+* @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 zeros = require( './../../zeros' );
+var data = require( './../lib' );
+
+// Create a 'float64' array...
+var opts = {
+ 'dtype': 'float64'
+};
+var x = zeros( [ 2, 2 ], opts );
+// returns
+
+var buf = data( x );
+// returns
+
+console.log( buf );
+
+// Create a 'float32' array...
+opts = {
+ 'dtype': 'float32'
+};
+x = zeros( [ 2, 2 ], opts );
+// returns
+
+buf = data( x );
+// returns
+
+console.log( buf );
+
+// Create a 'complex128' array...
+opts = {
+ 'dtype': 'complex128'
+};
+x = zeros( [ 2, 2 ], opts );
+// returns
+
+buf = data( x );
+// returns
+
+console.log( buf );
+
+// Create an 'int32' array...
+opts = {
+ 'dtype': 'int32'
+};
+x = zeros( [ 2, 2 ], opts );
+// returns
+
+buf = data( x );
+// returns
+
+console.log( buf );
diff --git a/data-buffer/lib/index.js b/data-buffer/lib/index.js
new file mode 100644
index 00000000..8626003f
--- /dev/null
+++ b/data-buffer/lib/index.js
@@ -0,0 +1,45 @@
+/**
+* @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 the underlying data buffer of a provided ndarray.
+*
+* @module @stdlib/ndarray/data-buffer
+*
+* @example
+* var zeros = require( '@stdlib/ndarray/zeros' );
+* var data = require( '@stdlib/ndarray/data-buffer' );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'float64'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/data-buffer/lib/main.js b/data-buffer/lib/main.js
new file mode 100644
index 00000000..e99f476b
--- /dev/null
+++ b/data-buffer/lib/main.js
@@ -0,0 +1,64 @@
+/**
+* @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 isCollection = require( '@stdlib/assert/is-collection' );
+var format = require( '@stdlib/string/format' );
+
+
+// MAIN //
+
+/**
+* Returns the underlying data buffer of a provided ndarray.
+*
+* @param {ndarrayLike} x - input ndarray
+* @throws {TypeError} must provide an ndarray
+* @returns {Collection} underlying data buffer
+*
+* @example
+* var zeros = require( '@stdlib/ndarray/zeros' );
+*
+* var x = zeros( [ 3, 3, 3 ], {
+* 'dtype': 'float64'
+* });
+*
+* var out = data( x );
+* // returns
+*/
+function data( x ) {
+ var out;
+
+ // Note: we intentionally avoid rigorous ndarray checks to minimize performance impacts. This obviously means that non-ndarray-like objects can sneak through, but this is likely all right for the purposes of this function...
+ if ( typeof x !== 'object' || x === null ) {
+ throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );
+ }
+ out = x.data;
+ if ( isCollection( out ) ) {
+ return out;
+ }
+ // A data buffer is essential for operating on an ndarray object, so no fallbacks or workarounds for data buffer resolution...
+ throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );
+}
+
+
+// EXPORTS //
+
+module.exports = data;
diff --git a/data-buffer/package.json b/data-buffer/package.json
new file mode 100644
index 00000000..b633e817
--- /dev/null
+++ b/data-buffer/package.json
@@ -0,0 +1,68 @@
+{
+ "name": "@stdlib/ndarray/data-buffer",
+ "version": "0.0.0",
+ "description": "Return the underlying data buffer of a provided ndarray.",
+ "license": "Apache-2.0",
+ "author": {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ },
+ "contributors": [
+ {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ }
+ ],
+ "main": "./lib",
+ "directories": {
+ "benchmark": "./benchmark",
+ "doc": "./docs",
+ "example": "./examples",
+ "lib": "./lib",
+ "test": "./test"
+ },
+ "types": "./docs/types",
+ "scripts": {},
+ "homepage": "https://github.com/stdlib-js/stdlib",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/stdlib-js/stdlib.git"
+ },
+ "bugs": {
+ "url": "https://github.com/stdlib-js/stdlib/issues"
+ },
+ "dependencies": {},
+ "devDependencies": {},
+ "engines": {
+ "node": ">=0.10.0",
+ "npm": ">2.7.0"
+ },
+ "os": [
+ "aix",
+ "darwin",
+ "freebsd",
+ "linux",
+ "macos",
+ "openbsd",
+ "sunos",
+ "win32",
+ "windows"
+ ],
+ "keywords": [
+ "stdlib",
+ "stdtypes",
+ "types",
+ "ndarray",
+ "data",
+ "buffer",
+ "memory",
+ "storage",
+ "multidimensional",
+ "array",
+ "utilities",
+ "utility",
+ "utils",
+ "util"
+ ],
+ "__stdlib__": {}
+}
diff --git a/data-buffer/test/test.js b/data-buffer/test/test.js
new file mode 100644
index 00000000..598c283e
--- /dev/null
+++ b/data-buffer/test/test.js
@@ -0,0 +1,155 @@
+/**
+* @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 zeros = require( './../../zeros' );
+var buffer = require( './../../base/buffer' );
+var data = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof data, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function throws an error if not provided a minimal ndarray-like object', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ {},
+ [],
+ function noop() {},
+ {
+ 'data': {}
+ },
+ {
+ 'data': null
+ }
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ data( value );
+ };
+ }
+});
+
+tape( 'the function returns the underlying data buffer of a provided ndarray', function test( t ) {
+ var expected;
+ var values;
+ var actual;
+ var i;
+
+ values = [
+ zeros( [], {
+ 'dtype': 'float64'
+ }),
+ zeros( [ 3, 3, 3 ], {
+ 'dtype': 'float32'
+ }),
+ zeros( [ 1, 1 ], {
+ 'dtype': 'int32'
+ }),
+ zeros( [ 3, 3, 0, 3 ], {
+ 'dtype': 'uint32'
+ }),
+ zeros( [ 1, 2, 3, 4 ], {
+ 'dtype': 'int8'
+ }),
+ zeros( [ 5 ], {
+ 'dtype': 'uint8'
+ })
+ ];
+
+ expected = [
+ values[ 0 ].data,
+ values[ 1 ].data,
+ values[ 2 ].data,
+ values[ 3 ].data,
+ values[ 4 ].data,
+ values[ 5 ].data
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ actual = data( values[ i ] );
+ t.strictEqual( actual, expected[ i ], 'returns expected value' );
+ }
+ t.end();
+});
+
+tape( 'the function accepts minimal ndarray-like objects (data)', function test( t ) {
+ var expected;
+ var values;
+ var actual;
+ var i;
+
+ values = [
+ {
+ 'data': buffer( 'float64', 10 )
+ },
+ {
+ 'data': buffer( 'float32', 10 )
+ },
+ {
+ 'data': buffer( 'int32', 10 )
+ },
+ {
+ 'data': buffer( 'uint32', 10 )
+ },
+ {
+ 'data': buffer( 'int8', 10 )
+ },
+ {
+ 'data': buffer( 'uint8', 10 )
+ }
+ ];
+
+ expected = [
+ values[ 0 ].data,
+ values[ 1 ].data,
+ values[ 2 ].data,
+ values[ 3 ].data,
+ values[ 4 ].data,
+ values[ 5 ].data
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ actual = data( values[ i ] );
+ t.strictEqual( actual, expected[ i ], 'returns expected value' );
+ }
+ t.end();
+});
diff --git a/dist/index.js b/dist/index.js
index 64514231..67a52686 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1,4 +1,4 @@
-"use strict";var k=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var yt=k(function(kV,ct){"use strict";function Hq(r){var e,a,i,s;for(e=r.length,a=[],s=0;s=0;s--)a[s]=i,i*=r[s];return a}function $q(r){var e,a,i;for(e=[],a=1,i=0;i=0;s--)e[s]=i,i*=r[s];return e}function ah(r,e){var a,i;for(a=1,i=0;is&&(i=!1),i||e)s=t;else return 0;return i&&e?3:i?1:2}St.exports=nh});var he=k(function(LV,_t){"use strict";var uh=jt();_t.exports=uh});var Ot=k(function(zV,Et){"use strict";function fh(r){var e,a,i;if(e=r.length,e===0)return 0;for(a=1,i=0;i0?t+=v*(r[o]-1):v<0&&(s+=v*(r[o]-1))}return[s,t]}$t.exports=Ch});var as=k(function($V,es){"use strict";function Dh(r,e,a,i){var s,t,v,o,u;for(s=r.length,t=a,v=a,u=0;u0?v+=o*(r[u]-1):o<0&&(t+=o*(r[u]-1))}return i[0]=t,i[1]=v,i}es.exports=Dh});var ue=k(function(rP,ts){"use strict";var Lh=require("@stdlib/utils/define-nonenumerable-read-only-property"),is=rs(),zh=as();Lh(is,"assign",zh);ts.exports=is});var vs=k(function(eP,ss){"use strict";var Vh=ue();function Ph(r,e,a,i){var s=Vh(e,a,i);return s[0]>=0&&s[1]=0;v--)t=r%a[v],r-=t,r/=a[v],s+=t*e[v];return this._accessors?this._buffer.get(s):this._buffer[s]}Ss.exports=Hh});var Es=k(function(cP,_s){"use strict";function $h(r,e){var a,i,s,t,v,o;if(s=this._ndims,s===0)return this._accessors?this._buffer.set(r,this._offset):this._buffer[this._offset]=r,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(e,this._offset+r):this._buffer[this._offset+r]=e,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(e,this._offset-r):this._buffer[this._offset-r]=e,this}if(i=this._shape,a=this._strides,t=this._offset,this._order==="column-major"){for(o=0;o=0;o--)v=r%i[o],r-=v,r/=i[o],t+=v*a[o];return this._accessors?this._buffer.set(e,t):this._buffer[t]=e,this}_s.exports=$h});var Ts=k(function(yP,Os){"use strict";function rg(){var r,e;for(r=this._offset,e=0;e=0;v--)t=this.iget(this._length-1-v),r+=Ga(t)+", "+Ja(t),v>0&&(r+=", ");else for(v=2;v>=0;v--)r+=this.iget(this._length-1-v),v>0&&(r+=", ")}if(a=vg[this.dtype],i+=sg(a,"{{data}}",r),i+=", ",e===0?i+="[]":i+="[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",e===0)i+="0";else for(v=0;ve?e:r}av.exports=e4});var Wa=k(function(kP,tv){"use strict";var a4=iv();tv.exports=a4});var vv=k(function(AP,sv){"use strict";function i4(r,e){var a=e+1;return r<0?(r+=a,r<0&&(r%=a,r!==0&&(r+=a)),r):(r>e&&(r-=a,r>e&&(r%=a)),r)}sv.exports=i4});var Qa=k(function(NP,ov){"use strict";var t4=vv();ov.exports=t4});var uv=k(function(RP,nv){"use strict";var s4=Wa(),v4=Qa(),o4=require("@stdlib/string/format");function n4(r,e,a){if(a==="clamp")return s4(r,e);if(a==="wrap")return v4(r,e);if(r<0||r>e)throw new RangeError(o4("invalid argument. Index must be on the interval: [0, %d]. Value: `%d`.",e,r));return r}nv.exports=n4});var Oe=k(function(CP,fv){"use strict";var u4=uv();fv.exports=u4});var cv=k(function(DP,lv){"use strict";var f4=require("@stdlib/assert/is-integer").isPrimitive,d4=Oe(),l4=re(),c4=require("@stdlib/string/format"),dv=l4.prototype.iget;function y4(r){if(this._ndims>0){if(!f4(r))throw new TypeError(c4("invalid argument. Index must be an integer. Value: `%s`.",r));return r=d4(r,this._length-1,this._mode),dv.call(this,r)}return dv.call(this)}lv.exports=y4});var mv=k(function(LP,pv){"use strict";var p4=require("@stdlib/assert/is-integer").isPrimitive,m4=Oe(),x4=re(),q4=require("@stdlib/string/format"),yv=x4.prototype.iset;function h4(r,e){if(this._flags.READONLY)throw new Error("invalid invocation. Cannot write to a read-only array.");if(this._ndims>0){if(!p4(r))throw new TypeError(q4("invalid argument. Index must be an integer. Value: `%s`.",r));r=m4(r,this._length-1,this._mode),yv.call(this,r,e)}else yv.call(this,r);return this}pv.exports=h4});var hv=k(function(zP,qv){"use strict";var g4=require("@stdlib/assert/is-integer").isPrimitive,b4=Oe(),xv=require("@stdlib/string/format");function w4(){var r,e,a,i;if(arguments.length!==this._ndims)throw new RangeError(xv("invalid arguments. Number of indices must match the number of dimensions. ndims: `%u`. nargs: `%u`.",this._ndims,arguments.length));for(r=this._offset,a=this._submode.length,i=0;i0))throw new TypeError(ee("invalid argument. Third argument must be an array-like object containing nonnegative integers. Value: `%s`.",a));if(o=a.length,o>Dv)throw new RangeError(ee("invalid argument. Number of dimensions must not exceed %u due to stack limits. Value: `%u`.",Dv,o));if(!z4(i))throw new TypeError(ee("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(ee("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(ee("invalid argument. Fourth argument must contain a single element equal to 0. Value: `%d`.",i[0]))}if(!L4(s))throw new TypeError(ee("invalid argument. Fifth argument must be a nonnegative integer. Value: `%s`.",s));if(!V4(t))throw new TypeError(ee("invalid argument. Sixth argument must be a supported order. Value: `%s`.",t));if(o>0&&!M4(e.length,a,i,s)&&B4(a)>0)throw new Error("invalid arguments. Input buffer is incompatible with the specified meta data. Ensure that the offset is valid with regard to the strides array and that the buffer has enough elements to satisfy the desired array shape.");if(u={},u.mode=X4,u.readonly=W4,arguments.length>6&&(f=Z4(u,v),f))throw f;return this._mode=u.mode,u.submode===void 0&&(u.submode=[this._mode]),this._submode=u.submode,n=Cv(a,o),d=Cv(i,o||1),Lv.call(this,r,e,n,d,s,t),this._flags.READONLY=u.readonly,this}F4(ae,Lv);Be(ae,"name","ndarray");Be(ae.prototype,"get",G4);Be(ae.prototype,"iget",Y4);Be(ae.prototype,"set",J4);Be(ae.prototype,"iset",K4);zv.exports=ae});var ie=k(function(YP,Pv){"use strict";var Q4=Vv();Pv.exports=Q4});var Mv=k(function(KP,H4){H4.exports=["none","equiv","safe","same-kind","unsafe"]});var Uv=k(function(GP,Bv){"use strict";var $4=Mv();function rb(){return $4.slice()}Bv.exports=rb});var Yv=k(function(JP,Fv){"use strict";function eb(){return{none:0,equiv:1,safe:2,"same-kind":3,unsafe:4}}Fv.exports=eb});var $a=k(function(ZP,Gv){"use strict";var ab=require("@stdlib/utils/define-nonenumerable-read-only-property"),Kv=Uv(),ib=Yv();ab(Kv,"enum",ib);Gv.exports=Kv});var Xv=k(function(XP,Zv){"use strict";var tb=$a(),Jv=tb(),sb=Jv.length;function vb(r){var e;for(e=0;e0}lo.exports=kb});var Fe=k(function(o9,yo){"use strict";var Ab=co();yo.exports=Ab});var po=k(function(n9,Nb){Nb.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 qo=k(function(u9,xo){"use strict";var mo=require("@stdlib/utils/keys"),Rb=require("@stdlib/assert/has-own-property"),Cb=te(),fa=po(),ua;function Db(){var r,e,a,i,s,t,v,o,u;for(a={},r=mo(fa),e=r.length,u=0;u0}go.exports=Bb});var da=k(function(l9,wo){"use strict";var Ub=bo();wo.exports=Ub});var jo=k(function(c9,So){"use strict";var Fb=Fe(),Yb=da();function Kb(r,e,a){return a==="unsafe"||r===e?!0:a==="none"||a==="equiv"?!1:a==="safe"?Fb(r,e):Yb(r,e)}So.exports=Kb});var ii=k(function(y9,_o){"use strict";var Gb=jo();_o.exports=Gb});var Oo=k(function(p9,Eo){"use strict";var Jb=require("@stdlib/buffer/ctor"),Zb=require("@stdlib/array/float64"),Xb=require("@stdlib/array/float32"),Wb=require("@stdlib/array/int16"),Qb=require("@stdlib/array/int32"),Hb=require("@stdlib/array/int8"),$b=require("@stdlib/array/uint16"),r6=require("@stdlib/array/uint32"),e6=require("@stdlib/array/uint8"),a6=require("@stdlib/array/uint8c"),i6=require("@stdlib/array/complex64"),t6=require("@stdlib/array/complex128"),s6={binary:Jb,float64:Zb,float32:Xb,generic:Array,int16:Wb,int32:Qb,int8:Hb,uint16:$b,uint32:r6,uint8:e6,uint8c:a6,complex64:i6,complex128:t6};Eo.exports=s6});var Io=k(function(m9,To){"use strict";var v6=Oo();function o6(r){return v6[r]||null}To.exports=o6});var Ye=k(function(x9,ko){"use strict";var n6=Io();ko.exports=n6});var No=k(function(q9,Ao){"use strict";function u6(r){var e;for(e=0;e=0&&r.length=S5(e)}cn.exports=j5});var mn=k(function(D9,pn){"use strict";var _5=yn();pn.exports=_5});var hn=k(function(L9,qn){"use strict";var xn=require("@stdlib/math/base/special/abs");function E5(r){var e,a,i,s;if(e=r.length,e===0)return!1;for(a=xn(r[0]),s=1;sa)return!1;a=i}return!0}ru.exports=cw});var ni=k(function(sM,au){"use strict";var yw=eu();au.exports=yw});var tu=k(function(vM,iu){"use strict";var pw=Ke(),mw=se(),xw=ni();function qw(r,e,a){return mw(e)!==0&&xw(e)&&pw(r,e,a)}iu.exports=qw});var vu=k(function(oM,su){"use strict";var hw=tu();su.exports=hw});var nu=k(function(nM,ou){"use strict";var gw=require("@stdlib/array/base/assert/contains").factory,bw=Fr(),ww=gw(bw("signed_integer"));ou.exports=ww});var ma=k(function(uM,uu){"use strict";var Sw=nu();uu.exports=Sw});var du=k(function(fM,fu){"use strict";var jw=require("@stdlib/array/base/assert/contains").factory,_w=Fr(),Ew=jw(_w("unsigned_integer"));fu.exports=Ew});var xa=k(function(dM,lu){"use strict";var Ow=du();lu.exports=Ow});var yu=k(function(lM,cu){"use strict";var Vr=require("@stdlib/utils/define-read-only-property"),zr={};Vr(zr,"isAllowedDataTypeCast",ii());Vr(zr,"isBufferLengthCompatible",Ka());Vr(zr,"isBufferLengthCompatibleShape",mn());Vr(zr,"isCastingMode",ri());Vr(zr,"isColumnMajor",ti());Vr(zr,"isColumnMajorContiguous",On());Vr(zr,"isComplexFloatingPointDataType",Ge());Vr(zr,"isContiguous",Cn());Vr(zr,"isDataType",Ee());Vr(zr,"isFloatingPointDataType",Je());Vr(zr,"isIndexMode",Me());Vr(zr,"isIntegerDataType",si());Vr(zr,"isNumericDataType",vi());Vr(zr,"isOrder",Xr());Vr(zr,"isReadOnly",ce());Vr(zr,"isRealDataType",pa());Vr(zr,"isRealFloatingPointDataType",oi());Vr(zr,"isRowMajor",ni());Vr(zr,"isRowMajorContiguous",vu());Vr(zr,"isSafeDataTypeCast",Fe());Vr(zr,"isSameKindDataTypeCast",da());Vr(zr,"isSignedIntegerDataType",ma());Vr(zr,"isSingleSegmentCompatible",Ke());Vr(zr,"isUnsignedIntegerDataType",xa());cu.exports=zr});var mu=k(function(cM,pu){"use strict";function Tw(r,e){var a,i,s,t,v,o,u,f,n,d;for(s=1,t=1,d=1;d=0&&(n=r[v],i=n<0?-n:n,!(i<=a));)r[v+1]=n,e[o+1]=e[o],v-=1,o-=1;r[v+1]=u,e[o+1]=f,s+=1,t+=1}}pu.exports=Tw});var hu=k(function(yM,qu){"use strict";var Iw=require("@stdlib/array/base/zero-to"),kw=require("@stdlib/array/base/copy-indexed"),qa=require("@stdlib/array/base/take"),Aw=require("@stdlib/array/base/filled"),ui=he(),Nw=mu(),xu=3;function Rw(r,e,a,i){var s,t,v,o,u,f,n,d,y,x;if(s=Iw(r.length),f=ui(e),n=ui(a),d=ui(i),t=Aw([],4),t[f].push(e),t[n].push(a),t[d].push(i),v=t[0].length,v===xu)u=e;else if(v===xu-1){for(y=1;y<4;y++)if(t[y].length){u=t[y][0];break}}else{for(x=0,y=1;y<4;y++)o=t[y].length,o>=v&&(v=o,x=y);u=t[x][0]}return u=kw(u),Nw(u,s),r=qa(r,s),e=e===u?u:qa(e,s),a=a===u?u:qa(a,s),i=i===u?u:qa(i,s),{sh:r,sx:e,sy:a,sz:i}}qu.exports=Rw});var bu=k(function(pM,gu){"use strict";var Cw=hu();gu.exports=Cw});var Su=k(function(mM,wu){"use strict";var Dw={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};wu.exports=Dw});var _u=k(function(xM,ju){"use strict";var fi=fe(),ha=Su();function Lw(r,e,a){var i,s,t;return i=fi(r),s=fi(e),t=fi(a),i===null||s===null||t===null?ha.BLOCK_SIZE_IN_ELEMENTS:i>s&&i>t?ha.BLOCK_SIZE_IN_BYTES/i|0:s>t?ha.BLOCK_SIZE_IN_BYTES/s|0:ha.BLOCK_SIZE_IN_BYTES/t|0}ju.exports=Lw});var Ou=k(function(qM,Eu){"use strict";var zw=_u();Eu.exports=zw});var ku=k(function(hM,Iu){"use strict";var Vw=require("@stdlib/string/format"),ga=require("@stdlib/math/base/special/trunc"),Tu=require("@stdlib/math/base/special/abs");function Pw(r,e,a,i,s,t){var v,o,u,f,n,d;for(v=r.length,o=1,d=0;d=o&&(s=o-1);else if(t==="wrap")s<0?(s+=o,s<0&&(s%=o,s!==0&&(s+=o))):s>=o&&(s-=o,s>=o&&(s%=o));else if(s<0||s>=o)throw new RangeError(Vw("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",o,s));if(u=0,i==="column-major"){for(d=v-1;d>=0;d--)n=e[d],n<0?(f=ga(s/n),s-=f*n,f+=r[d]-1):(f=ga(s/n),s-=f*n),u+=f*Tu(n);return u}for(d=0;d=0;f--)if(n=o-v+f,!(n<0)){if(u=s[n],i=e[f],i!==0&&if&&(f=e[n]);for(n=0;n=0;){for(t=e[0]-f+n,t>=0?i=s[t]:i=1,d=1;d=0?o=r[d][v]:o=1,i===1){i=o;continue}if(!(o===1||i===o))return null}a[n]=i,n-=1}return a}Bu.exports=$w});var Yu=k(function(EM,Fu){"use strict";var rS=Uu();Fu.exports=rS});var Gu=k(function(OM,Ku){"use strict";var eS=Ue(),aS=la();function iS(r){var e=aS(r);return e?eS(e):null}Ku.exports=iS});var Zu=k(function(TM,Ju){"use strict";var tS=Gu();Ju.exports=tS});var Wu=k(function(IM,Xu){"use strict";function sS(){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"}}Xu.exports=sS});var $u=k(function(kM,Hu){"use strict";var vS=te(),Qu=Wu(),di;function oS(r){return arguments.length===0?Qu():(di===void 0&&(di=Qu()),di[vS(r)]||null)}Hu.exports=oS});var li=k(function(AM,rf){"use strict";var nS=$u();rf.exports=nS});var sf=k(function(NM,tf){"use strict";var ef=require("@stdlib/utils/object-inverse"),af=li(),ci;function uS(r){return arguments.length===0?ef(af()):(ci===void 0&&(ci=ef(af())),ci[r]||null)}tf.exports=uS});var of=k(function(RM,vf){"use strict";var fS=sf();vf.exports=fS});var uf=k(function(CM,nf){"use strict";function dS(r){return r.dtype}nf.exports=dS});var df=k(function(DM,ff){"use strict";var lS=uf();ff.exports=lS});var cf=k(function(LM,lf){"use strict";function cS(){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"}}lf.exports=cS});var mf=k(function(zM,pf){"use strict";var yS=te(),yf=cf(),yi;function pS(r){return arguments.length===0?yf():(yi===void 0&&(yi=yf()),yi[yS(r)]||null)}pf.exports=pS});var qf=k(function(VM,xf){"use strict";var mS=mf();xf.exports=mS});var gf=k(function(PM,hf){"use strict";var xS=va(),qS=Ue();function hS(r){var e=typeof r;return e==="number"?xS(r)?r:null:e==="string"?qS(r):null}hf.exports=hS});var pi=k(function(MM,bf){"use strict";var gS=gf();bf.exports=gS});var wf=k(function(BM,bS){bS.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 jf=k(function(UM,Sf){"use strict";var wS=te(),SS=wf();function jS(r){return SS[wS(r)]||null}Sf.exports=jS});var Ef=k(function(FM,_f){"use strict";var _S=jf();_f.exports=_S});var If=k(function(YM,Tf){"use strict";var ES=require("@stdlib/assert/is-array-like-object"),Of=require("@stdlib/assert/is-nonnegative-integer").isPrimitive,OS=te(),mi=require("@stdlib/string/format");function TS(r,e,a){var i,s,t,v,o,u,f,n;if(!ES(r))throw new TypeError(mi("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!Of(e))throw new TypeError(mi("invalid argument. Second argument must be a nonnegative integer. Value: `%s`.",e));if(!Of(a))throw new TypeError(mi("invalid argument. Third argument must be a nonnegative integer. Value: `%s`.",a));if(i=r.length,i===0)throw new RangeError("invalid argument. First argument must contain at least one element.");if(o=e+a,i%o!==0)throw new RangeError("invalid arguments. Length of the first argument is incompatible with the second and third arguments.");for(s=[],t=[],u=2*o,n=2*e,f=0;f<=u;f++)f===0?f===n?t.push("() => ("):t.push("("):f===u?f===n?t.push(") => ()"):t.push(")"):f===n?t.push(") => ("):f%2===1?t.push(""):t.push(", ");for(f=0;f0?(t=RS(e),v=kS(e,a)):(t=1,v=[0]),r==="binary"?s=DS(t):s=CS(t,r),new NS(r,s,e,v,AS(e,v),a)}Af.exports=LS});var Cf=k(function(JM,Rf){"use strict";var zS=Nf();Rf.exports=zS});var Lf=k(function(ZM,Df){"use strict";var VS=Yr(),PS=Kr(),MS=Dr(),BS=require("@stdlib/array/empty"),US=require("@stdlib/buffer/alloc-unsafe");function FS(r){var e,a,i,s,t,v,o;return o=r.dtype,t=r.shape,s=r.order,e=t.length,e>0?(a=MS(t),v=VS(t,s)):(a=1,v=[0]),o==="binary"?i=US(a):i=BS(a,o),new r.constructor(o,i,t,v,PS(t,v),s)}Df.exports=FS});var Vf=k(function(XM,zf){"use strict";var YS=Lf();zf.exports=YS});var Bf=k(function(WM,Mf){"use strict";var KS=ce(),Pf=require("@stdlib/string/format");function GS(r,e){var a,i,s,t,v,o,u;if(t=r.shape,v=r.strides,s=r.order,o=t.length,a=[],i=[],e<0){if(e<-o-1)throw new RangeError(Pf("invalid argument. Specified axis is out-of-bounds. Must be on the interval: [-%u-1, %u]. Value: `%d`.",o,o,e));e+=o+1}else if(e>o)throw new RangeError(Pf("invalid argument. Specified axis is out-of-bounds. Must be on the interval: [-%u-1, %u]. Value: `%d`.",o,o,e));if(e===0)for(i.push(1),a.push(v[0]),u=0;u=u&&(s=u-1);else if(t==="wrap")s<0?(s+=u,s<0&&(s%=u,s!==0&&(s+=u))):s>=u&&(s-=u,s>=u&&(s%=u));else if(s<0||s>=u)throw new RangeError(a8("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",u,s));if(a===0){if(i==="column-major"){for(d=0;d=0;d--)n=s%r[d],s-=n,s/=r[d],v[d]=n;return v}if(i==="column-major"){for(d=o-1;d>=0;d--)n=e[d],n<0?(f=wa(s/n),s-=f*n,v[d]=r[d]-1+f):(f=wa(s/n),s-=f*n,v[d]=f);return v}for(d=0;d0&&(s+=e[t]*(r[t]-1))}return s}$f.exports=n8});var ad=k(function(tB,ed){"use strict";var u8=rd();ed.exports=u8});var sd=k(function(sB,td){"use strict";var id=ba();function f8(r,e){var a,i,s;if(i=e.length,a=r.shape,a.length===i){for(s=0;si;t--)s[t]=a[t];for(t=i;t>=0&&(v=(a[t]+1)%e[t],s[t]=v,!(v>0));t--);for(t-=1;t>=0;t--)s[t]=a[t];return s}function k8(r,e,a,i,s){var t,v;for(t=0;t0));t++);for(t+=1;t=t)return null;return e===T8?I8(t,r,a,i,s):k8(t,r,a,i,s)}wd.exports=A8});var jd=k(function(mB,Sd){"use strict";var N8=require("@stdlib/array/base/zeros"),R8=bi();function C8(r,e,a,i){return R8(r,e,a,i,N8(r.length))}Sd.exports=C8});var we=k(function(xB,Ed){"use strict";var D8=require("@stdlib/utils/define-nonenumerable-read-only-property"),_d=jd(),L8=bi();D8(_d,"assign",L8);Ed.exports=_d});var Td=k(function(qB,Od){"use strict";function z8(r){var e,a;for(e=0,a=0;a=0&&(n=r[v],i=n<0?-n:n,!(i<=a));)r[v+1]=n,e[o+1]=e[o],v-=1,o-=1;r[v+1]=u,e[o+1]=f,s+=1,t+=1}}Ad.exports=P8});var Cd=k(function(bB,Rd){"use strict";var M8=require("@stdlib/array/base/zero-to"),B8=require("@stdlib/array/base/copy-indexed"),U8=require("@stdlib/array/base/take"),F8=Nd();function Y8(r,e){var a;return a=M8(r.length),e=B8(e),F8(e,a),r=U8(r,a),{sh:r,sx:e}}Rd.exports=Y8});var Mr=k(function(wB,Dd){"use strict";var K8=Cd();Dd.exports=K8});var zd=k(function(SB,Ld){"use strict";var G8={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};Ld.exports=G8});var Md=k(function(jB,Pd){"use strict";var J8=fe(),Vd=zd();function Z8(r){var e=J8(r);return e===null?Vd.BLOCK_SIZE_IN_ELEMENTS:Vd.BLOCK_SIZE_IN_BYTES/e|0}Pd.exports=Z8});var Br=k(function(_B,Bd){"use strict";var X8=Md();Bd.exports=X8});var Fd=k(function(EB,Ud){"use strict";var W8=Mr(),Q8=Br();function H8(r,e){var a,i,s,t,v,o,u,f,n,d,y,x,h,p,g,m,b;for(b=W8(r.shape,r.strides),u=b.sh,d=b.sx,a=Q8(r.dtype),y=r.offset,i=r.data,t=d[0],s=r.accessors[1],m=u[1];m>0;)for(m0;)for(g0;)for(E0;)for(q0;)for(w0;)for(S0;)for(O0;)for(l0;)for(_0;)for(I0;)for(R0;)for(N0;)for(T0;)for(A0;)for(P0;)for(z0;)for(C0;)for(L0;)for(D0;)for(I0;)for(F0;)for(U0;)for(B0;)for(M0;)for(V0;)for(P0;)for(z0;)for(G0;)for(Z0;)for(K0;)for(J0;)for(Y0;)for(F0;)for(U0;)for(B0;)for(H0;)for($0;)for(W0;)for(Q0;)for(X0;)for(G0;)for(Z0;)for(K0;)for(J0;)for(ar0;)for(sr0;)for(er0;)for(ir0;)for(rr0;)for(H0;)for($0;)for(W0;)for(Q0;)for(X0;)for(g0;)for(p0;)for(q0;)for(w0;)for(j0;)for(O0;)for(l0;)for(_0;)for(c0;)for(R0;)for(N0;)for(T0;)for(A0;)for(S0;)for(z0;)for(C0;)for(L0;)for(D0;)for(I0;)for(R0;)for(U0;)for(B0;)for(M0;)for(V0;)for(P0;)for(z0;)for(C0;)for(Z0;)for(K0;)for(J0;)for(Y0;)for(F0;)for(U0;)for(B0;)for(M0;)for($0;)for(W0;)for(Q0;)for(X0;)for(G0;)for(Z0;)for(K0;)for(J0;)for(Y0;)for(sr0;)for(er0;)for(ir0;)for(rr0;)for(H0;)for($0;)for(W0;)for(Q0;)for(X0;)for(G=o&&(s=o-1);else if(t==="wrap")s<0?(s+=o,s<0&&(s%=o,s!==0&&(s+=o))):s>=o&&(s-=o,s>=o&&(s%=o));else if(s<0||s>=o)throw new RangeError(o_("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",o,s));if(u=a,i==="column-major"){for(n=0;n=0;n--)f=s%r[n],s-=f,s/=r[n],u+=f*e[n];return u}G0.exports=n_});var ye=k(function(aU,Z0){"use strict";var u_=J0();Z0.exports=u_});var W0=k(function(iU,X0){"use strict";var f_=Dr(),d_=ye(),l_="throw";function c_(r,e){var a,i,s,t,v,o,u,f,n;for(v=r.shape,s=f_(v),a=r.data,o=r.strides,u=r.offset,i=r.order,t=r.accessors[1],n=0;n0&&(y=U7(y.length))}else y=Cc(x);return Dc(y)===0?K7(d,v,Ei(y,f),u,!i):(t=F7(x,s,t),y=Ei(y,f),y.length===0?new d(v,r.data,[],[0],t,u,{readonly:!i}):(s=Y7(x,s,f),new d(v,r.data,y,s,t,u,{readonly:!i})))}zc.exports=G7});var me=k(function(WU,Pc){"use strict";var J7=Vc();Pc.exports=J7});var Bc=k(function(QU,Mc){"use strict";function Z7(r,e){var a,i,s,t,v,o,u,f,n,d;for(s=1,t=1,d=1;d=0&&(n=r[v],i=n<0?-n:n,!(i<=a));)r[v+1]=n,e[o+1]=e[o],v-=1,o-=1;r[v+1]=u,e[o+1]=f,s+=1,t+=1}}Mc.exports=Z7});var Yc=k(function(HU,Fc){"use strict";var X7=require("@stdlib/array/base/zero-to"),W7=require("@stdlib/array/base/copy-indexed"),Uc=require("@stdlib/array/base/take"),Q7=Bc();function H7(r,e,a){var i;return i=X7(r.length),e=W7(e),Q7(e,i),r=Uc(r,i),a=Uc(a,i),{sh:r,sx:e,sy:a}}Fc.exports=H7});var kr=k(function($U,Kc){"use strict";var $7=Yc();Kc.exports=$7});var Jc=k(function(rF,Gc){"use strict";var rO={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};Gc.exports=rO});var Wc=k(function(eF,Xc){"use strict";var Zc=fe(),Oi=Jc();function eO(r,e){var a,i;return a=Zc(r),i=Zc(e),a===null||i===null?Oi.BLOCK_SIZE_IN_ELEMENTS:a>i?Oi.BLOCK_SIZE_IN_BYTES/a|0:Oi.BLOCK_SIZE_IN_BYTES/i|0}Xc.exports=eO});var Ar=k(function(aF,Qc){"use strict";var aO=Wc();Qc.exports=aO});var $c=k(function(iF,Hc){"use strict";var iO=kr(),tO=Ar();function sO(r,e,a){var i,s,t,v,o,u,f,n,d,y,x,h,p,g,m,b,j,w,q,E,c,_,l,O,S;for(S=iO(r.shape,r.strides,e.strides),h=S.sh,m=S.sx,b=S.sy,i=tO(r.dtype,e.dtype),j=r.offset,w=e.offset,s=r.data,t=e.data,u=m[0],n=b[0],v=r.accessors[0],o=e.accessors[1],O=h[1];O>0;)for(O0;)for(l0;)for(D0;)for(I0;)for(R0;)for(B0;)for(M0;)for(V0;)for(P0;)for(G0;)for(Z0;)for(K0;)for(J0;)for(Y0;)for(ir0;)for(rr0;)for(H0;)for($0;)for(W0;)for(Q0;)for(nr0;)for(or0;)for(vr0;)for(tr0;)for(ar0;)for(sr0;)for(er0;)for(xr0;)for(lr0;)for(yr0;)for(cr0;)for(dr0;)for(fr0;)for(ur0;)for(nr0;)for(Sr0;)for(wr0;)for(hr0;)for(jr0;)for(gr0;)for(br0;)for(qr0;)for(xr0;)for(lr0;)for(Lr0;)for(Cr0;)for(Ir0;)for(Tr0;)for(Or0;)for(Er0;)for(_r0;)for(Sr0;)for(wr0;)for(hr0;)for(_0;)for(c0;)for(R0;)for(N0;)for(T0;)for(V0;)for(P0;)for(z0;)for(C0;)for(K0;)for(J0;)for(Y0;)for(F0;)for(U0;)for(H0;)for($0;)for(W0;)for(Q0;)for(X0;)for(G0;)for(vr0;)for(tr0;)for(ar0;)for(sr0;)for(er0;)for(ir0;)for(rr0;)for(yr0;)for(cr0;)for(dr0;)for(fr0;)for(ur0;)for(nr0;)for(or0;)for(vr0;)for(hr0;)for(jr0;)for(gr0;)for(br0;)for(qr0;)for(xr0;)for(lr0;)for(yr0;)for(cr0;)for(Ir0;)for(Tr0;)for(Or0;)for(Er0;)for(_r0;)for(Sr0;)for(wr0;)for(hr0;)for(jr0;)for(gr=v)throw new RangeError(ki("invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.",v,e));return t=zI(null,v),t[o]=a,a=CI.apply(null,t),LI(r,a,i,s)}Uy.exports=VI});var Ky=k(function(WF,Yy){"use strict";var PI=Fy();Yy.exports=PI});var Jy=k(function(QF,Gy){"use strict";var MI=require("@stdlib/array/base/copy-indexed");function BI(r,e){var a=r.strides;return e?MI(a):a}Gy.exports=BI});var Xy=k(function(HF,Zy){"use strict";var UI=Jy();Zy.exports=UI});var Qy=k(function($F,Wy){"use strict";var FI=require("@stdlib/string/format");function YI(){var r,e,a,i,s,t,v,o,u,f,n,d;for(i=arguments[0],r=arguments[1],e=arguments[2],s=i.length,t=arguments[3+s],a=t.length,o=e,d=0;d=u&&(n=u-1);else if(v==="wrap")n<0?(n+=u,n<0&&(n%=u,n!==0&&(n+=u))):n>=u&&(n-=u,n>=u&&(n%=u));else if(n<0||n>=u)throw new RangeError(FI("invalid argument. Subscripts must not exceed array dimensions. Subscript: `%u`. Value: `%d`.",d,n));f=r[d],f<0&&e===0?o-=n*f:o+=n*f}return o}Wy.exports=YI});var Ai=k(function(rY,Hy){"use strict";var KI=Qy();Hy.exports=KI});var ep=k(function(eY,rp){"use strict";function $y(r,e,a,i,s,t){var v,o,u,f,n;if(t>=e.length)return r.accessors[0](r.data,i);for(u=[],f=e[t],v=a[t],n=0;n0;)for(A0;)for(S0;)for(C0;)for(L0;)for(D0;)for(F0;)for(U0;)for(B0;)for(M0;)for(Q0;)for(X0;)for(G0;)for(Z0;)for(K0;)for(sr0;)for(er0;)for(ir0;)for(rr0;)for(H0;)for($0;)for(fr0;)for(ur0;)for(nr0;)for(or0;)for(vr0;)for(tr0;)for(ar0;)for(br0;)for(qr0;)for(xr0;)for(lr0;)for(yr0;)for(cr0;)for(dr0;)for(fr0;)for(Er0;)for(_r0;)for(Sr0;)for(wr0;)for(hr0;)for(jr0;)for(gr0;)for(br0;)for(qr0;)for(Gr0;)for(Ur0;)for(Lr0;)for(Cr0;)for(Ir0;)for(Tr