|
22 | 22 |
|
23 | 23 | /* eslint-disable max-lines */ |
24 | 24 |
|
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'; |
26 | 26 | import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; |
27 | 27 |
|
28 | 28 | /** |
@@ -111,6 +111,20 @@ interface Float32Options extends Options { |
111 | 111 | dtype?: 'float32'; |
112 | 112 | } |
113 | 113 |
|
| 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 | + |
114 | 128 | /** |
115 | 129 | * Interface describing function options. |
116 | 130 | */ |
@@ -323,6 +337,35 @@ declare function map<W = unknown>( x: float64ndarray, fcn: Callback<number, floa |
323 | 337 | */ |
324 | 338 | declare function map<W = unknown>( x: float32ndarray, fcn: Callback<number, float32ndarray, number, W>, thisArg?: ThisParameterType<Callback<number, float32ndarray, number, W>> ): float32ndarray; |
325 | 339 |
|
| 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 | + |
326 | 369 | /** |
327 | 370 | * Applies a callback function to elements in an input ndarray and assigns results to elements in a new output ndarray. |
328 | 371 | * |
@@ -709,6 +752,40 @@ declare function map<T = unknown, W = unknown>( x: typedndarray<T>, options: Flo |
709 | 752 | */ |
710 | 753 | 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; |
711 | 754 |
|
| 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 | + |
712 | 789 | /** |
713 | 790 | * Applies a callback function to elements in an input ndarray and assigns results to elements in a new output ndarray. |
714 | 791 | * |
|
0 commit comments