From 53621aaf1e43afa856ff9d7c8c1f13ad2e8de9c5 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 17 Jan 2026 21:16:47 +0530 Subject: [PATCH] feat: add float16 array types --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/types/index.d.ts | 68 +++++++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/types/index.d.ts b/lib/node_modules/@stdlib/types/index.d.ts index ceea7b48c9c4..67c7a836f1b5 100644 --- a/lib/node_modules/@stdlib/types/index.d.ts +++ b/lib/node_modules/@stdlib/types/index.d.ts @@ -55,7 +55,7 @@ declare module '@stdlib/types/array' { /** * Data type for floating-point typed arrays. */ - type RealFloatingPointDataType = 'float64' | 'float32'; // "real_floating_point" + type RealFloatingPointDataType = 'float64' | 'float32' | 'float16'; // "real_floating_point" /** * Data type for floating-point typed arrays. @@ -464,8 +464,9 @@ declare module '@stdlib/types/array' { * @example * const x: FloatTypedArray = new Float64Array( 10 ); * const y: FloatTypedArray = new Float32Array( 10 ); + * const z: FloatTypedArray = new Float16Array( 10 ); */ - type FloatTypedArray = Float32Array | Float64Array; + type FloatTypedArray = Float16Array | Float32Array | Float64Array; /** * A complex number typed array. @@ -790,6 +791,7 @@ declare module '@stdlib/types/array' { type RealFloatingPointDataTypeMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions 'float64': Float64Array; 'float32': Float32Array; + 'float16': Float16Array; }; /** @@ -1462,7 +1464,7 @@ declare module '@stdlib/types/ndarray' { /** * Data type string for floating-point ndarrays. */ - type RealFloatingPointDataTypeString = 'float64' | 'float32'; // "real_floating_point" + type RealFloatingPointDataTypeString = 'float64' | 'float32' | 'float16'; // "real_floating_point" /** * Data type string for floating-point ndarrays. @@ -2157,7 +2159,7 @@ declare module '@stdlib/types/ndarray' { /** * Data type object for floating-point ndarrays. */ - type RealFloatingPointDataTypeObject = Float64DataTypeObject | Float32DataTypeObject; // "real_floating_point" + type RealFloatingPointDataTypeObject = Float64DataTypeObject | Float32DataTypeObject | Float16DataTypeObject; // "real_floating_point" /** * Data type object for floating-point ndarrays. @@ -3150,6 +3152,63 @@ declare module '@stdlib/types/ndarray' { set( ...args: Array ): float32ndarray; } + /** + * Interface describing an ndarray having a half-precision floating-point data type. + * + * @example + * const arr: float16ndarray = { + * 'byteLength': 6, + * 'BYTES_PER_ELEMENT': 2, + * 'data': new Float16Array( [ 1, 2, 3 ] ), + * 'dtype': 'float16', + * 'flags': { + * 'ROW_MAJOR_CONTIGUOUS': true, + * 'COLUMN_MAJOR_CONTIGUOUS': false + * }, + * 'length': 3, + * 'ndims': 1, + * 'offset': 0, + * 'order': 'row-major', + * 'shape': [ 3 ], + * 'strides': [ 1 ], + * 'get': function get( i ) { + * return this.data[ i ]; + * }, + * 'set': function set( i, v ) { + * this.data[ i ] = v; + * return this; + * } + * }; + */ + interface float16ndarray extends floatndarray { + /** + * Size (in bytes) of each array element. + */ + BYTES_PER_ELEMENT: 2; + + /** + * A reference to the underlying data buffer. + */ + data: Float16Array; + + /** + * Underlying data type. + */ + dtype: Float16DataType; + + /** + * Sets an array element specified according to provided subscripts. + * + * ## Notes + * + * - The number of provided subscripts should equal the number of dimensions. + * + * @param args - subscripts and value to set + * @returns ndarray instance + */ + set( ...args: Array ): float16ndarray; + } + /** * Interface describing an ndarray having an integer data type. * @@ -4400,6 +4459,7 @@ declare module '@stdlib/types/ndarray' { type RealFloatingPointDataTypeMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions 'float64': float64ndarray; 'float32': float32ndarray; + 'float16': float16ndarray; }; /**