diff --git a/lib/node_modules/@stdlib/ndarray/filter-map/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/filter-map/docs/types/index.d.ts index b2a813db9c1b..deaa07cfdb3e 100644 --- a/lib/node_modules/@stdlib/ndarray/filter-map/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/filter-map/docs/types/index.d.ts @@ -22,7 +22,7 @@ /* eslint-disable max-lines */ -import { typedndarray, DataType, Order, float64ndarray, float32ndarray, complex128ndarray, complex64ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray } from '@stdlib/types/ndarray'; +import { typedndarray, DataType, Order, float64ndarray, float32ndarray, float16ndarray, complex128ndarray, complex64ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray } from '@stdlib/types/ndarray'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; /** @@ -139,6 +139,20 @@ interface Float32Options extends Options { dtype?: 'float32'; } +/** +* Interface describing function options. +*/ +interface Float16Options extends Options { + /** + * Output ndarray data type. + * + * ## Notes + * + * - This option overrides using the input ndarray's inferred data type. + */ + dtype?: 'float16'; +} + /** * Interface describing function options. */ @@ -355,6 +369,37 @@ declare function filterMap( x: float64ndarray, fcn: Callback( x: float32ndarray, fcn: Callback, thisArg?: ThisParameterType> ): float32ndarray; +/** +* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function. +* +* @param x - input ndarray +* @param fcn - callback function +* @param thisArg - callback function execution context +* @returns output ndarray +* +* @example +* var Float16Array = require( '@stdlib/array/float16' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* function scale( z ) { +* if ( z > 5.0 ) { +* return z * 10.0; +* } +* } +* +* var buffer = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* var shape = [ 2, 3 ]; +* var strides = [ 6, 1 ]; +* var offset = 1; +* +* var x = ndarray( 'float16', buffer, shape, strides, offset, 'row-major' ); +* // returns +* +* var y = filterMap( x, scale ); +* // returns [ 80.0, 90.0, 100.0 ] +*/ +declare function filterMap( x: float16ndarray, fcn: Callback, thisArg?: ThisParameterType> ): float16ndarray; + /** * Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function. * @@ -767,6 +812,42 @@ declare function filterMap( x: float64ndarray, options: OrderOption */ declare function filterMap( x: float32ndarray, options: OrderOptions, fcn: Callback, thisArg?: ThisParameterType> ): float32ndarray; +/** +* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function. +* +* @param x - input ndarray +* @param options - function options +* @param options.order - iteration order +* @param fcn - callback function +* @param thisArg - callback function execution context +* @returns output ndarray +* +* @example +* var Float16Array = require( '@stdlib/array/float16' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* function scale( z ) { +* if ( z > 5.0 ) { +* return z * 10.0; +* } +* } +* +* var buffer = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* var shape = [ 2, 3 ]; +* var strides = [ 6, 1 ]; +* var offset = 1; +* +* var x = ndarray( 'float16', buffer, shape, strides, offset, 'row-major' ); +* // returns +* +* var opts = { +* 'order': 'row-major' +* }; +* var y = filterMap( x, opts, scale ); +* // returns [ 80.0, 90.0, 100.0 ] +*/ +declare function filterMap( x: float16ndarray, options: OrderOptions, fcn: Callback, thisArg?: ThisParameterType> ): float16ndarray; + /** * Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function. * @@ -1236,6 +1317,43 @@ declare function filterMap( x: typedndarr */ declare function filterMap( x: typedndarray, options: Float32Options, fcn: Callback, thisArg?: ThisParameterType> ): float32ndarray; +/** +* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function. +* +* @param x - input ndarray +* @param options - options +* @param options.dtype - output ndarray data type +* @param options.order - iteration order +* @param fcn - callback function +* @param thisArg - callback function execution context +* @returns output ndarray +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* function scale( z ) { +* if ( z > 5.0 ) { +* return z * 10.0; +* } +* } +* +* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* var shape = [ 2, 3 ]; +* var strides = [ 6, 1 ]; +* var offset = 1; +* +* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); +* // returns +* +* var opts = { +* 'dtype': 'float16' +* }; +* var y = filterMap( x, opts, scale ); +* // returns [ 80.0, 90.0, 100.0 ] +*/ +declare function filterMap( x: typedndarray, options: Float16Options, fcn: Callback, thisArg?: ThisParameterType> ): float16ndarray; + /** * Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function. * diff --git a/lib/node_modules/@stdlib/ndarray/filter-map/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/filter-map/docs/types/test.ts index 2e03ec2e1f62..bc1625e9f6ab 100644 --- a/lib/node_modules/@stdlib/ndarray/filter-map/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/filter-map/docs/types/test.ts @@ -72,6 +72,8 @@ function identity3( x: ComplexLike ): ComplexLike { filterMap( zeros( 'float64', sh, ord ), identity1, {} ); // $ExpectType float64ndarray filterMap( zeros( 'float32', sh, ord ), identity1 ); // $ExpectType float32ndarray filterMap( zeros( 'float32', sh, ord ), identity1, {} ); // $ExpectType float32ndarray + filterMap( zeros( 'float16', sh, ord ), identity1 ); // $ExpectType float16ndarray + filterMap( zeros( 'float16', sh, ord ), identity1, {} ); // $ExpectType float16ndarray filterMap( zeros( 'complex64', sh, ord ), identity3 ); // $ExpectType complex64ndarray filterMap( zeros( 'complex64', sh, ord ), identity3, {} ); // $ExpectType complex64ndarray filterMap( zeros( 'complex128', sh, ord ), identity3 ); // $ExpectType complex128ndarray @@ -100,6 +102,8 @@ function identity3( x: ComplexLike ): ComplexLike { filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'float64' }, fcn, {} ); // $ExpectType float64ndarray filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'float32' }, fcn ); // $ExpectType float32ndarray filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'float32' }, fcn, {} ); // $ExpectType float32ndarray + filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'float16' }, fcn ); // $ExpectType float16ndarray + filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'float16' }, fcn, {} ); // $ExpectType float16ndarray filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' }, fcn ); // $ExpectType complex64ndarray filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' }, fcn, {} ); // $ExpectType complex64ndarray filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' }, fcn ); // $ExpectType complex128ndarray @@ -128,6 +132,8 @@ function identity3( x: ComplexLike ): ComplexLike { filterMap( zeros( 'float64', sh, ord ), { 'order': ord }, identity1, {} ); // $ExpectType float64ndarray filterMap( zeros( 'float32', sh, ord ), { 'order': ord }, identity1 ); // $ExpectType float32ndarray filterMap( zeros( 'float32', sh, ord ), { 'order': ord }, identity1, {} ); // $ExpectType float32ndarray + filterMap( zeros( 'float16', sh, ord ), { 'order': ord }, identity1 ); // $ExpectType float16ndarray + filterMap( zeros( 'float16', sh, ord ), { 'order': ord }, identity1, {} ); // $ExpectType float16ndarray filterMap( zeros( 'complex64', sh, ord ), { 'order': ord }, identity3 ); // $ExpectType complex64ndarray filterMap( zeros( 'complex64', sh, ord ), { 'order': ord }, identity3, {} ); // $ExpectType complex64ndarray filterMap( zeros( 'complex128', sh, ord ), { 'order': ord }, identity3 ); // $ExpectType complex128ndarray diff --git a/lib/node_modules/@stdlib/ndarray/filter-map/test/test.js b/lib/node_modules/@stdlib/ndarray/filter-map/test/test.js index d3643cd3f1d5..9774b8e9e5e4 100644 --- a/lib/node_modules/@stdlib/ndarray/filter-map/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/filter-map/test/test.js @@ -27,8 +27,10 @@ var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); var Float64Array = require( '@stdlib/array/float64' ); var Float32Array = require( '@stdlib/array/float32' ); +var Float16Array = require( '@stdlib/array/float16' ); var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' ); +var isSameFloat16Array = require( '@stdlib/assert/is-same-float16array' ); var filterMap = require( './../lib' ); @@ -369,6 +371,17 @@ tape( 'the function filters and maps an array according to a callback function ( ]); t.strictEqual( isSameFloat32Array( y.data, expected ), true, 'returns expected value' ); + opts = { + 'dtype': 'float16' + }; + y = filterMap( x, opts, fcn ); + + expected = new Float16Array([ + 10.0, + 30.0 + ]); + t.strictEqual( isSameFloat16Array( y.data, expected ), true, 'returns expected value' ); + t.end(); function fcn( z ) { @@ -418,6 +431,17 @@ tape( 'the function filters and maps an array according to a callback function ( ]); t.strictEqual( isSameFloat32Array( y.data, expected ), true, 'returns expected value' ); + opts = { + 'dtype': 'float16' + }; + y = filterMap( x, opts, fcn ); + + expected = new Float16Array([ + 10.0, + 30.0 + ]); + t.strictEqual( isSameFloat16Array( y.data, expected ), true, 'returns expected value' ); + t.end(); function fcn( z ) {