From 35bd236f4f07a2eb383efb35c9817bfd944d97bf Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Tue, 15 Sep 2026 16:24:03 +0530 Subject: [PATCH] feat: add float16 dtype support to ndarray/for-each --- .../ndarray/for-each/docs/types/index.d.ts | 28 ++++++++++++++++++- .../ndarray/for-each/docs/types/test.ts | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/ndarray/for-each/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/for-each/docs/types/index.d.ts index 1280c2cbf2d3..079d6fd1bff4 100644 --- a/lib/node_modules/@stdlib/ndarray/for-each/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/for-each/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { typedndarray, float64ndarray, float32ndarray, complex128ndarray, complex64ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray } from '@stdlib/types/ndarray'; +import { typedndarray, float64ndarray, float32ndarray, float16ndarray, complex128ndarray, complex64ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray } from '@stdlib/types/ndarray'; import { Complex64, Complex128 } from '@stdlib/types/complex'; /** @@ -113,6 +113,32 @@ declare function forEach( x: float64ndarray, fcn: Callback( x: float32ndarray, fcn: Callback, thisArg?: ThisParameterType> ): void; +/** +* Invokes a callback function once for each ndarray element. +* +* @param x - input ndarray +* @param fcn - callback function +* @param thisArg - callback function execution context +* +* @example +* var Float16Array = require( '@stdlib/array/float16' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* var naryFunction = require( '@stdlib/utils/nary-function' ); +* var log = require( '@stdlib/console/log' ); +* +* 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 = [ 3, 1 ]; +* var offset = 0; +* +* var x = ndarray( 'float16', buffer, shape, strides, offset, 'row-major' ); +* // returns +* +* // Apply the callback function: +* forEach( x, naryFunction( log, 1 ) ); +*/ +declare function forEach( x: float16ndarray, fcn: Callback, thisArg?: ThisParameterType> ): void; + /** * Invokes a callback function once for each ndarray element. * diff --git a/lib/node_modules/@stdlib/ndarray/for-each/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/for-each/docs/types/test.ts index 5dbe274fed91..30ac4bf3ffde 100644 --- a/lib/node_modules/@stdlib/ndarray/for-each/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/for-each/docs/types/test.ts @@ -43,6 +43,8 @@ function clbk( v: any ): void { forEach( zeros( 'float64', sh, ord ), clbk, {} ); // $ExpectType void forEach( zeros( 'float32', sh, ord ), clbk ); // $ExpectType void forEach( zeros( 'float32', sh, ord ), clbk, {} ); // $ExpectType void + forEach( zeros( 'float16', sh, ord ), clbk ); // $ExpectType void + forEach( zeros( 'float16', sh, ord ), clbk, {} ); // $ExpectType void forEach( zeros( 'complex64', sh, ord ), clbk ); // $ExpectType void forEach( zeros( 'complex64', sh, ord ), clbk, {} ); // $ExpectType void forEach( zeros( 'complex128', sh, ord ), clbk ); // $ExpectType void