diff --git a/lib/node_modules/@stdlib/ndarray/data-buffer/README.md b/lib/node_modules/@stdlib/ndarray/data-buffer/README.md index 3d9d095f0bcf..a295b80ce2af 100644 --- a/lib/node_modules/@stdlib/ndarray/data-buffer/README.md +++ b/lib/node_modules/@stdlib/ndarray/data-buffer/README.md @@ -100,6 +100,16 @@ x = zeros( [ 2, 2 ], opts ); buf = data( x ); // returns +// Create a 'float16' array... +opts = { + 'dtype': 'float16' +}; +x = zeros( [ 2, 2 ], opts ); +// returns + +buf = data( x ); +// returns + // Create a 'complex128' array... opts = { 'dtype': 'complex128' diff --git a/lib/node_modules/@stdlib/ndarray/data-buffer/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/data-buffer/docs/types/index.d.ts index 33a824d8546d..19b079986640 100644 --- a/lib/node_modules/@stdlib/ndarray/data-buffer/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/data-buffer/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; +import { typedndarray, genericndarray, float64ndarray, float32ndarray, float16ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; /** * Returns the underlying data buffer of a provided ndarray. @@ -58,6 +58,24 @@ declare function data( x: float64ndarray ): float64ndarray[ 'data' ]; */ 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': 'float16' +* }); +* +* var out = data( x ); +* // returns +*/ +declare function data( x: float16ndarray ): float16ndarray[ 'data' ]; + /** * Returns the underlying data buffer of a provided ndarray. * diff --git a/lib/node_modules/@stdlib/ndarray/data-buffer/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/data-buffer/docs/types/test.ts index 7ba3b035ddcb..25a1b4dd969d 100644 --- a/lib/node_modules/@stdlib/ndarray/data-buffer/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/data-buffer/docs/types/test.ts @@ -26,6 +26,7 @@ import data = require( './index' ); { data( zeros( [ 3, 2, 1 ], { 'dtype': 'float64' } ) ); // $ExpectType Float64Array data( zeros( [ 3, 2, 1 ], { 'dtype': 'float32' } ) ); // $ExpectType Float32Array + data( zeros( [ 3, 2, 1 ], { 'dtype': 'float16' } ) ); // $ExpectType Float16ArrayFallback 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 diff --git a/lib/node_modules/@stdlib/ndarray/data-buffer/examples/index.js b/lib/node_modules/@stdlib/ndarray/data-buffer/examples/index.js index 84f49b7ad701..3be83acc28c4 100644 --- a/lib/node_modules/@stdlib/ndarray/data-buffer/examples/index.js +++ b/lib/node_modules/@stdlib/ndarray/data-buffer/examples/index.js @@ -45,6 +45,18 @@ buf = data( x ); console.log( buf ); +// Create a 'float16' array... +opts = { + 'dtype': 'float16' +}; +x = zeros( [ 2, 2 ], opts ); +// returns + +buf = data( x ); +// returns + +console.log( buf ); + // Create a 'complex128' array... opts = { 'dtype': 'complex128' diff --git a/lib/node_modules/@stdlib/ndarray/data-buffer/test/test.js b/lib/node_modules/@stdlib/ndarray/data-buffer/test/test.js index e192c1acc2e4..968d62d75abb 100644 --- a/lib/node_modules/@stdlib/ndarray/data-buffer/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/data-buffer/test/test.js @@ -81,6 +81,9 @@ tape( 'the function returns the underlying data buffer of a provided ndarray', f zeros( [ 3, 3, 3 ], { 'dtype': 'float32' }), + zeros( [ 2, 2 ], { + 'dtype': 'float16' + }), zeros( [ 1, 1 ], { 'dtype': 'int32' }), @@ -101,7 +104,8 @@ tape( 'the function returns the underlying data buffer of a provided ndarray', f values[ 2 ].data, values[ 3 ].data, values[ 4 ].data, - values[ 5 ].data + values[ 5 ].data, + values[ 6 ].data ]; for ( i = 0; i < values.length; i++ ) { @@ -124,6 +128,9 @@ tape( 'the function accepts minimal ndarray-like objects (data)', function test( { 'data': buffer( 'float32', 10 ) }, + { + 'data': buffer( 'float16', 10 ) + }, { 'data': buffer( 'int32', 10 ) }, @@ -144,7 +151,8 @@ tape( 'the function accepts minimal ndarray-like objects (data)', function test( values[ 2 ].data, values[ 3 ].data, values[ 4 ].data, - values[ 5 ].data + values[ 5 ].data, + values[ 6 ].data ]; for ( i = 0; i < values.length; i++ ) {