|
22 | 22 |
|
23 | 23 | /* eslint-disable max-lines */ |
24 | 24 |
|
25 | | -import { typedndarray, DataType, Order, float64ndarray, float32ndarray, complex128ndarray, complex64ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray } from '@stdlib/types/ndarray'; |
| 25 | +import { typedndarray, DataType, Order, 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 | /** |
@@ -139,6 +139,20 @@ interface Float32Options extends Options { |
139 | 139 | dtype?: 'float32'; |
140 | 140 | } |
141 | 141 |
|
| 142 | +/** |
| 143 | +* Interface describing function options. |
| 144 | +*/ |
| 145 | +interface Float16Options extends Options { |
| 146 | + /** |
| 147 | + * Output ndarray data type. |
| 148 | + * |
| 149 | + * ## Notes |
| 150 | + * |
| 151 | + * - This option overrides using the input ndarray's inferred data type. |
| 152 | + */ |
| 153 | + dtype?: 'float16'; |
| 154 | +} |
| 155 | + |
142 | 156 | /** |
143 | 157 | * Interface describing function options. |
144 | 158 | */ |
@@ -355,6 +369,37 @@ declare function filterMap<V = unknown>( x: float64ndarray, fcn: Callback<number |
355 | 369 | */ |
356 | 370 | declare function filterMap<V = unknown>( x: float32ndarray, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): float32ndarray; |
357 | 371 |
|
| 372 | +/** |
| 373 | +* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function. |
| 374 | +* |
| 375 | +* @param x - input ndarray |
| 376 | +* @param fcn - callback function |
| 377 | +* @param thisArg - callback function execution context |
| 378 | +* @returns output ndarray |
| 379 | +* |
| 380 | +* @example |
| 381 | +* var Float16Array = require( '@stdlib/array/float16' ); |
| 382 | +* var ndarray = require( '@stdlib/ndarray/ctor' ); |
| 383 | +* |
| 384 | +* function scale( z ) { |
| 385 | +* if ( z > 5.0 ) { |
| 386 | +* return z * 10.0; |
| 387 | +* } |
| 388 | +* } |
| 389 | +* |
| 390 | +* 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 ] ); |
| 391 | +* var shape = [ 2, 3 ]; |
| 392 | +* var strides = [ 6, 1 ]; |
| 393 | +* var offset = 1; |
| 394 | +* |
| 395 | +* var x = ndarray( 'float16', buffer, shape, strides, offset, 'row-major' ); |
| 396 | +* // returns <ndarray> |
| 397 | +* |
| 398 | +* var y = filterMap( x, scale ); |
| 399 | +* // returns <ndarray>[ 80.0, 90.0, 100.0 ] |
| 400 | +*/ |
| 401 | +declare function filterMap<V = unknown>( x: float16ndarray, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): float16ndarray; |
| 402 | + |
358 | 403 | /** |
359 | 404 | * Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function. |
360 | 405 | * |
@@ -767,6 +812,42 @@ declare function filterMap<V = unknown>( x: float64ndarray, options: OrderOption |
767 | 812 | */ |
768 | 813 | declare function filterMap<V = unknown>( x: float32ndarray, options: OrderOptions, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): float32ndarray; |
769 | 814 |
|
| 815 | +/** |
| 816 | +* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function. |
| 817 | +* |
| 818 | +* @param x - input ndarray |
| 819 | +* @param options - function options |
| 820 | +* @param options.order - iteration order |
| 821 | +* @param fcn - callback function |
| 822 | +* @param thisArg - callback function execution context |
| 823 | +* @returns output ndarray |
| 824 | +* |
| 825 | +* @example |
| 826 | +* var Float16Array = require( '@stdlib/array/float16' ); |
| 827 | +* var ndarray = require( '@stdlib/ndarray/ctor' ); |
| 828 | +* |
| 829 | +* function scale( z ) { |
| 830 | +* if ( z > 5.0 ) { |
| 831 | +* return z * 10.0; |
| 832 | +* } |
| 833 | +* } |
| 834 | +* |
| 835 | +* 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 ] ); |
| 836 | +* var shape = [ 2, 3 ]; |
| 837 | +* var strides = [ 6, 1 ]; |
| 838 | +* var offset = 1; |
| 839 | +* |
| 840 | +* var x = ndarray( 'float16', buffer, shape, strides, offset, 'row-major' ); |
| 841 | +* // returns <ndarray> |
| 842 | +* |
| 843 | +* var opts = { |
| 844 | +* 'order': 'row-major' |
| 845 | +* }; |
| 846 | +* var y = filterMap( x, opts, scale ); |
| 847 | +* // returns <ndarray>[ 80.0, 90.0, 100.0 ] |
| 848 | +*/ |
| 849 | +declare function filterMap<V = unknown>( x: float16ndarray, options: OrderOptions, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): float16ndarray; |
| 850 | + |
770 | 851 | /** |
771 | 852 | * Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function. |
772 | 853 | * |
@@ -1236,6 +1317,43 @@ declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarr |
1236 | 1317 | */ |
1237 | 1318 | declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Float32Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): float32ndarray; |
1238 | 1319 |
|
| 1320 | +/** |
| 1321 | +* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function. |
| 1322 | +* |
| 1323 | +* @param x - input ndarray |
| 1324 | +* @param options - options |
| 1325 | +* @param options.dtype - output ndarray data type |
| 1326 | +* @param options.order - iteration order |
| 1327 | +* @param fcn - callback function |
| 1328 | +* @param thisArg - callback function execution context |
| 1329 | +* @returns output ndarray |
| 1330 | +* |
| 1331 | +* @example |
| 1332 | +* var Float64Array = require( '@stdlib/array/float64' ); |
| 1333 | +* var ndarray = require( '@stdlib/ndarray/ctor' ); |
| 1334 | +* |
| 1335 | +* function scale( z ) { |
| 1336 | +* if ( z > 5.0 ) { |
| 1337 | +* return z * 10.0; |
| 1338 | +* } |
| 1339 | +* } |
| 1340 | +* |
| 1341 | +* 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 ] ); |
| 1342 | +* var shape = [ 2, 3 ]; |
| 1343 | +* var strides = [ 6, 1 ]; |
| 1344 | +* var offset = 1; |
| 1345 | +* |
| 1346 | +* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); |
| 1347 | +* // returns <ndarray> |
| 1348 | +* |
| 1349 | +* var opts = { |
| 1350 | +* 'dtype': 'float16' |
| 1351 | +* }; |
| 1352 | +* var y = filterMap( x, opts, scale ); |
| 1353 | +* // returns <ndarray>[ 80.0, 90.0, 100.0 ] |
| 1354 | +*/ |
| 1355 | +declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Float16Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): float16ndarray; |
| 1356 | + |
1239 | 1357 | /** |
1240 | 1358 | * Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function. |
1241 | 1359 | * |
|
0 commit comments