Skip to content

Commit 585171c

Browse files
committed
Auto-generated commit
1 parent ef9a94d commit 585171c

9 files changed

Lines changed: 149 additions & 3 deletions

File tree

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,4 @@ jsconfig.json
202202
####################
203203
CLAUDE.md
204204
GEMINI.md
205+
.claude/

CHANGELOG.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2026-08-09)
7+
## Unreleased (2026-08-12)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`29242e0`](https://github.com/stdlib-js/stdlib/commit/29242e0a53ae80a91a7d0b780c9a5e8b59f108cc) - add float16 dtype support to `array/empty` [(#14166)](https://github.com/stdlib-js/stdlib/pull/14166)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="bug-fixes">
1020

@@ -22,6 +32,7 @@
2232

2333
<details>
2434

35+
- [`29242e0`](https://github.com/stdlib-js/stdlib/commit/29242e0a53ae80a91a7d0b780c9a5e8b59f108cc) - **feat:** add float16 dtype support to `array/empty` [(#14166)](https://github.com/stdlib-js/stdlib/pull/14166) _(by Samarth Kolarkar, Athan Reines, Gururaj Gurram)_
2536
- [`ae32f26`](https://github.com/stdlib-js/stdlib/commit/ae32f26441101c24f0faf1a04ecceb3e66387578) - **fix:** ensure support for boolean arrays in polyfill _(by Athan Reines)_
2637
- [`6564170`](https://github.com/stdlib-js/stdlib/commit/6564170f3bf0724a927a23b64f3c624294978182) - **bench:** refactor to use string interpolation in `array/empty` [(#10439)](https://github.com/stdlib-js/stdlib/pull/10439) _(by Aman Singh)_
2738

@@ -35,10 +46,12 @@
3546

3647
### Contributors
3748

38-
A total of 2 people contributed to this release. Thank you to the following contributors:
49+
A total of 4 people contributed to this release. Thank you to the following contributors:
3950

4051
- Aman Singh
4152
- Athan Reines
53+
- Gururaj Gurram
54+
- Samarth Kolarkar
4255

4356
</section>
4457

benchmark/benchmark.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ bench( format( '%s:dtype=%s', pkg, 'float32' ), function benchmark( b ) {
8484
b.end();
8585
});
8686

87+
bench( format( '%s:dtype=%s', pkg, 'float16' ), function benchmark( b ) {
88+
var arr;
89+
var i;
90+
b.tic();
91+
for ( i = 0; i < b.iterations; i++ ) {
92+
arr = empty( 0, 'float16' );
93+
if ( arr.length !== 0 ) {
94+
b.fail( 'should have length 0' );
95+
}
96+
}
97+
b.toc();
98+
if ( !isTypedArrayLike( arr ) ) {
99+
b.fail( 'should return a typed array' );
100+
}
101+
b.pass( 'benchmark finished' );
102+
b.end();
103+
});
104+
87105
bench( format( '%s:dtype=%s', pkg, 'bool' ), function benchmark( b ) {
88106
var arr;
89107
var i;
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench-harness' );
24+
var pow = require( '@stdlib/math-base-special-pow' );
25+
var isTypedArray = require( '@stdlib/assert-is-typed-array' );
26+
var format = require( '@stdlib/string-format' );
27+
var pkg = require( './../package.json' ).name;
28+
var empty = require( './../lib' );
29+
30+
31+
// FUNCTIONS //
32+
33+
/**
34+
* Creates a benchmark function.
35+
*
36+
* @private
37+
* @param {PositiveInteger} len - array length
38+
* @returns {Function} benchmark function
39+
*/
40+
function createBenchmark( len ) {
41+
return benchmark;
42+
43+
/**
44+
* Benchmark function.
45+
*
46+
* @private
47+
* @param {Benchmark} b - benchmark instance
48+
*/
49+
function benchmark( b ) {
50+
var arr;
51+
var i;
52+
53+
b.tic();
54+
for ( i = 0; i < b.iterations; i++ ) {
55+
arr = empty( len, 'float16' );
56+
if ( arr.length !== len ) {
57+
b.fail( 'unexpected length' );
58+
}
59+
}
60+
b.toc();
61+
if ( !isTypedArray( arr ) ) {
62+
b.fail( 'should return a typed array' );
63+
}
64+
b.pass( 'benchmark finished' );
65+
b.end();
66+
}
67+
}
68+
69+
70+
// MAIN //
71+
72+
/**
73+
* Main execution sequence.
74+
*
75+
* @private
76+
*/
77+
function main() {
78+
var len;
79+
var min;
80+
var max;
81+
var f;
82+
var i;
83+
84+
min = 1; // 10^min
85+
max = 6; // 10^max
86+
87+
for ( i = min; i <= max; i++ ) {
88+
len = pow( 10, i );
89+
f = createBenchmark( len );
90+
bench( format( '%s:dtype=float16,len=%d', pkg, len ), f );
91+
}
92+
}
93+
94+
main();

docs/types/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ import { DataTypeMap } from '@stdlib/types/array';
4242
* @example
4343
* var arr = empty( 2, 'float32' );
4444
* // returns <Float32Array>
45+
*
46+
* @example
47+
* var arr = empty( 2, 'float16' );
48+
* // returns <Float16Array>
4549
*/
4650
declare function empty<T extends keyof DataTypeMap<number> = 'float64'>( length: number, dtype?: T ): DataTypeMap<number>[T];
4751

docs/types/test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import empty = require( './index' );
2626
empty( 10 ); // $ExpectType Float64Array
2727
empty( 10, 'float64' ); // $ExpectType Float64Array
2828
empty( 10, 'float32' ); // $ExpectType Float32Array
29+
empty( 10, 'float16' ); // $ExpectType Float16ArrayFallback
2930
empty( 10, 'complex128' ); // $ExpectType Complex128Array
3031
empty( 10, 'complex64' ); // $ExpectType Complex64Array
3132
empty( 10, 'bool' ); // $ExpectType BooleanArray

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"@stdlib/array-complex128": "^0.3.2",
5656
"@stdlib/array-complex64": "^0.3.2",
5757
"@stdlib/array-dtypes": "^0.4.1",
58+
"@stdlib/array-float16": "github:stdlib-js/array-float16#main",
5859
"@stdlib/array-float32": "^0.2.3",
5960
"@stdlib/array-float64": "^0.2.3",
6061
"@stdlib/array-int16": "^0.2.3",
@@ -108,6 +109,7 @@
108109
"matrix",
109110
"float64array",
110111
"float32array",
112+
"float16array",
111113
"int32array",
112114
"uint32array",
113115
"int16array",
@@ -129,6 +131,9 @@
129131
"float",
130132
"single-precision",
131133
"float32",
134+
"half",
135+
"half-precision",
136+
"float16",
132137
"ieee754",
133138
"integer",
134139
"int32",

test/test.main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var tape = require( 'tape' );
2424
var Float64Array = require( '@stdlib/array-float64' );
2525
var Float32Array = require( '@stdlib/array-float32' );
26+
var Float16Array = require( '@stdlib/array-float16' );
2627
var Int32Array = require( '@stdlib/array-int32' );
2728
var Uint32Array = require( '@stdlib/array-uint32' );
2829
var Int16Array = require( '@stdlib/array-int16' );
@@ -170,6 +171,16 @@ tape( 'the function returns an empty array (dtype=float32)', function test( t )
170171
t.end();
171172
});
172173

174+
tape( 'the function returns an empty array (dtype=float16)', function test( t ) {
175+
var arr;
176+
177+
arr = empty( 5, 'float16' );
178+
t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' );
179+
t.strictEqual( arr.length, 5, 'returns expected value' );
180+
181+
t.end();
182+
});
183+
173184
tape( 'the function returns an empty array (dtype=bool)', function test( t ) {
174185
var arr;
175186

0 commit comments

Comments
 (0)