Skip to content

Commit 3f3e4f8

Browse files
committed
Auto-generated commit
1 parent f0b62fe commit 3f3e4f8

4 files changed

Lines changed: 112 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Features
1212

13+
- [`a2aaa2b`](https://github.com/stdlib-js/stdlib/commit/a2aaa2b22422a3b5db27fb5ce0b50ba5c0023fe1) - add float16 dtype support to `ndarray/map` [(#15250)](https://github.com/stdlib-js/stdlib/pull/15250)
1314
- [`24f7b25`](https://github.com/stdlib-js/stdlib/commit/24f7b25084a90d7d02896ae1086b90b6869a9b15) - add float16 dtype support to `ndarray/filter` [(#15232)](https://github.com/stdlib-js/stdlib/pull/15232)
1415
- [`b116ddc`](https://github.com/stdlib-js/stdlib/commit/b116ddc030b397cc478e69e37cec904d41db4fdf) - add float16 dtype support to `ndarray/empty` [(#15181)](https://github.com/stdlib-js/stdlib/pull/15181)
1516
- [`024e902`](https://github.com/stdlib-js/stdlib/commit/024e9026cf58fa31b126ae55a345bd5617d915ec) - add float16 dtype support to `ndarray/empty-like` [(#15231)](https://github.com/stdlib-js/stdlib/pull/15231)
@@ -104,6 +105,7 @@ A total of 4 issues were closed in this release:
104105

105106
<details>
106107

108+
- [`a2aaa2b`](https://github.com/stdlib-js/stdlib/commit/a2aaa2b22422a3b5db27fb5ce0b50ba5c0023fe1) - **feat:** add float16 dtype support to `ndarray/map` [(#15250)](https://github.com/stdlib-js/stdlib/pull/15250) _(by Samarth Kolarkar)_
107109
- [`24f7b25`](https://github.com/stdlib-js/stdlib/commit/24f7b25084a90d7d02896ae1086b90b6869a9b15) - **feat:** add float16 dtype support to `ndarray/filter` [(#15232)](https://github.com/stdlib-js/stdlib/pull/15232) _(by Samarth Kolarkar)_
108110
- [`b116ddc`](https://github.com/stdlib-js/stdlib/commit/b116ddc030b397cc478e69e37cec904d41db4fdf) - **feat:** add float16 dtype support to `ndarray/empty` [(#15181)](https://github.com/stdlib-js/stdlib/pull/15181) _(by Samarth Kolarkar)_
109111
- [`024e902`](https://github.com/stdlib-js/stdlib/commit/024e9026cf58fa31b126ae55a345bd5617d915ec) - **feat:** add float16 dtype support to `ndarray/empty-like` [(#15231)](https://github.com/stdlib-js/stdlib/pull/15231) _(by Samarth Kolarkar)_

‎map/docs/types/index.d.ts‎

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
/* eslint-disable max-lines */
2424

25-
import { typedndarray, DataType, float64ndarray, float32ndarray, complex128ndarray, complex64ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray } from '@stdlib/types/ndarray';
25+
import { typedndarray, DataType, float64ndarray, float32ndarray, float16ndarray, complex128ndarray, complex64ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray } from '@stdlib/types/ndarray';
2626
import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex';
2727

2828
/**
@@ -111,6 +111,20 @@ interface Float32Options extends Options {
111111
dtype?: 'float32';
112112
}
113113

114+
/**
115+
* Interface describing function options.
116+
*/
117+
interface Float16Options extends Options {
118+
/**
119+
* Output ndarray data type.
120+
*
121+
* ## Notes
122+
*
123+
* - This option overrides using the input ndarray's inferred data type.
124+
*/
125+
dtype?: 'float16';
126+
}
127+
114128
/**
115129
* Interface describing function options.
116130
*/
@@ -323,6 +337,35 @@ declare function map<W = unknown>( x: float64ndarray, fcn: Callback<number, floa
323337
*/
324338
declare function map<W = unknown>( x: float32ndarray, fcn: Callback<number, float32ndarray, number, W>, thisArg?: ThisParameterType<Callback<number, float32ndarray, number, W>> ): float32ndarray;
325339

340+
/**
341+
* Applies a callback function to elements in an input ndarray and assigns results to elements in a new output ndarray.
342+
*
343+
* @param x - input ndarray
344+
* @param fcn - callback function
345+
* @param thisArg - callback function execution context
346+
* @returns output ndarray
347+
*
348+
* @example
349+
* var Float16Array = require( '@stdlib/array/float16' );
350+
* var ndarray = require( '@stdlib/ndarray/ctor' );
351+
*
352+
* function scale( z ) {
353+
* return z * 10.0;
354+
* }
355+
*
356+
* 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 ] );
357+
* var shape = [ 2, 3 ];
358+
* var strides = [ 6, 1 ];
359+
* var offset = 1;
360+
*
361+
* var x = ndarray( 'float16', buffer, shape, strides, offset, 'row-major' );
362+
* // returns <ndarray>
363+
*
364+
* var y = map( x, scale );
365+
* // returns <ndarray>[ [ 20.0, 30.0, 40.0 ], [ 80.0, 90.0, 100.0 ] ]
366+
*/
367+
declare function map<W = unknown>( x: float16ndarray, fcn: Callback<number, float16ndarray, number, W>, thisArg?: ThisParameterType<Callback<number, float16ndarray, number, W>> ): float16ndarray;
368+
326369
/**
327370
* Applies a callback function to elements in an input ndarray and assigns results to elements in a new output ndarray.
328371
*
@@ -709,6 +752,40 @@ declare function map<T = unknown, W = unknown>( x: typedndarray<T>, options: Flo
709752
*/
710753
declare function map<T = unknown, W = unknown>( x: typedndarray<T>, options: Float32Options, fcn: Callback<T, typedndarray<T>, number, W>, thisArg?: ThisParameterType<Callback<T, typedndarray<T>, number, W>> ): float32ndarray;
711754

755+
/**
756+
* Applies a callback function to elements in an input ndarray and assigns results to elements in a new output ndarray.
757+
*
758+
* @param x - input ndarray
759+
* @param options - options
760+
* @param options.dtype - output ndarray data type
761+
* @param fcn - callback function
762+
* @param thisArg - callback function execution context
763+
* @returns output ndarray
764+
*
765+
* @example
766+
* var Float64Array = require( '@stdlib/array/float64' );
767+
* var ndarray = require( '@stdlib/ndarray/ctor' );
768+
*
769+
* function scale( z ) {
770+
* return z * 10.0;
771+
* }
772+
*
773+
* 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 ] );
774+
* var shape = [ 2, 3 ];
775+
* var strides = [ 6, 1 ];
776+
* var offset = 1;
777+
*
778+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
779+
* // returns <ndarray>
780+
*
781+
* var opts = {
782+
* 'dtype': 'float16'
783+
* };
784+
* var y = map( x, opts, scale );
785+
* // returns <ndarray>[ [ 20.0, 30.0, 40.0 ], [ 80.0, 90.0, 100.0 ] ]
786+
*/
787+
declare function map<T = unknown, W = unknown>( x: typedndarray<T>, options: Float16Options, fcn: Callback<T, typedndarray<T>, number, W>, thisArg?: ThisParameterType<Callback<T, typedndarray<T>, number, W>> ): float16ndarray;
788+
712789
/**
713790
* Applies a callback function to elements in an input ndarray and assigns results to elements in a new output ndarray.
714791
*

‎map/docs/types/test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ function identity( x: any ): any {
4141
map( zeros( 'float64', sh, ord ), identity, {} ); // $ExpectType float64ndarray
4242
map( zeros( 'float32', sh, ord ), identity ); // $ExpectType float32ndarray
4343
map( zeros( 'float32', sh, ord ), identity, {} ); // $ExpectType float32ndarray
44+
map( zeros( 'float16', sh, ord ), identity ); // $ExpectType float16ndarray
45+
map( zeros( 'float16', sh, ord ), identity, {} ); // $ExpectType float16ndarray
4446
map( zeros( 'complex64', sh, ord ), identity ); // $ExpectType complex64ndarray
4547
map( zeros( 'complex64', sh, ord ), identity, {} ); // $ExpectType complex64ndarray
4648
map( zeros( 'complex128', sh, ord ), identity ); // $ExpectType complex128ndarray
@@ -69,6 +71,8 @@ function identity( x: any ): any {
6971
map( zeros( 'generic', sh, ord ), { 'dtype': 'float64' }, identity, {} ); // $ExpectType float64ndarray
7072
map( zeros( 'generic', sh, ord ), { 'dtype': 'float32' }, identity ); // $ExpectType float32ndarray
7173
map( zeros( 'generic', sh, ord ), { 'dtype': 'float32' }, identity, {} ); // $ExpectType float32ndarray
74+
map( zeros( 'generic', sh, ord ), { 'dtype': 'float16' }, identity ); // $ExpectType float16ndarray
75+
map( zeros( 'generic', sh, ord ), { 'dtype': 'float16' }, identity, {} ); // $ExpectType float16ndarray
7276
map( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' }, identity ); // $ExpectType complex64ndarray
7377
map( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' }, identity, {} ); // $ExpectType complex64ndarray
7478
map( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' }, identity ); // $ExpectType complex128ndarray

‎map/test/test.js‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ var shape2strides = require( './../../base/shape2strides' );
2727
var strides2offset = require( './../../base/strides2offset' );
2828
var Float64Array = require( '@stdlib/array/float64' );
2929
var Float32Array = require( '@stdlib/array/float32' );
30+
var Float16Array = require( '@stdlib/array/float16' );
3031
var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' );
3132
var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' );
33+
var isSameFloat16Array = require( '@stdlib/assert/is-same-float16array' );
3234
var numel = require( './../../base/numel' );
3335
var dfill = require( '@stdlib/blas/ext/base/dfill' );
3436
var sfill = require( '@stdlib/blas/ext/base/sfill' );
@@ -324,6 +326,19 @@ tape( 'the function applies a callback to each indexed element in an input ndarr
324326
]);
325327
t.strictEqual( isSameFloat32Array( y.data, expected ), true, 'returns expected value' );
326328

329+
opts = {
330+
'dtype': 'float16'
331+
};
332+
y = map( x, opts, scale );
333+
334+
expected = new Float16Array([
335+
10.0,
336+
10.0,
337+
10.0,
338+
10.0
339+
]);
340+
t.strictEqual( isSameFloat16Array( y.data, expected ), true, 'returns expected value' );
341+
327342
t.end();
328343

329344
function scale( z ) {
@@ -373,6 +388,19 @@ tape( 'the function applies a callback to each indexed element in an input ndarr
373388
]);
374389
t.strictEqual( isSameFloat32Array( y.data, expected ), true, 'returns expected value' );
375390

391+
opts = {
392+
'dtype': 'float16'
393+
};
394+
y = map( x, opts, scale );
395+
396+
expected = new Float16Array([
397+
10.0,
398+
10.0,
399+
10.0,
400+
10.0
401+
]);
402+
t.strictEqual( isSameFloat16Array( y.data, expected ), true, 'returns expected value' );
403+
376404
t.end();
377405

378406
function scale( z ) {

0 commit comments

Comments
 (0)