Skip to content

Commit 5518b90

Browse files
committed
Auto-generated commit
1 parent 3aff460 commit 5518b90

9 files changed

Lines changed: 163 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Features
1212

13+
- [`0078b7e`](https://github.com/stdlib-js/stdlib/commit/0078b7ed60fc8040a9d11a6d1c4d94bc34e4df5a) - add float16 dtype support to `array/ones-like` [(#14124)](https://github.com/stdlib-js/stdlib/pull/14124)
1314
- [`2e31902`](https://github.com/stdlib-js/stdlib/commit/2e31902b44dfa195f9caa5ece57b1649a000e47a) - add float16 dtype support to `array/ones` [(#14123)](https://github.com/stdlib-js/stdlib/pull/14123)
1415
- [`4d0ce60`](https://github.com/stdlib-js/stdlib/commit/4d0ce60011997633aac407dbba435da1763a2550) - add float16 dtype support to `array/convert-same` [(#14126)](https://github.com/stdlib-js/stdlib/pull/14126)
1516
- [`823ccaa`](https://github.com/stdlib-js/stdlib/commit/823ccaae2a34ef2fc8d0795f885b0503394ddae8) - add float16 dtype support to `array/convert` [(#14125)](https://github.com/stdlib-js/stdlib/pull/14125)
@@ -87,6 +88,7 @@ This release closes the following issue:
8788

8889
<details>
8990

91+
- [`0078b7e`](https://github.com/stdlib-js/stdlib/commit/0078b7ed60fc8040a9d11a6d1c4d94bc34e4df5a) - **feat:** add float16 dtype support to `array/ones-like` [(#14124)](https://github.com/stdlib-js/stdlib/pull/14124) _(by Gururaj Gurram)_
9092
- [`2e31902`](https://github.com/stdlib-js/stdlib/commit/2e31902b44dfa195f9caa5ece57b1649a000e47a) - **feat:** add float16 dtype support to `array/ones` [(#14123)](https://github.com/stdlib-js/stdlib/pull/14123) _(by Gururaj Gurram)_
9193
- [`4d0ce60`](https://github.com/stdlib-js/stdlib/commit/4d0ce60011997633aac407dbba435da1763a2550) - **feat:** add float16 dtype support to `array/convert-same` [(#14126)](https://github.com/stdlib-js/stdlib/pull/14126) _(by Gururaj Gurram)_
9294
- [`823ccaa`](https://github.com/stdlib-js/stdlib/commit/823ccaae2a34ef2fc8d0795f885b0503394ddae8) - **feat:** add float16 dtype support to `array/convert` [(#14125)](https://github.com/stdlib-js/stdlib/pull/14125) _(by Gururaj Gurram)_

ones-like/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ The function supports the following data types:
5555

5656
- `float64`: double-precision floating-point numbers (IEEE 754)
5757
- `float32`: single-precision floating-point numbers (IEEE 754)
58+
- `float16`: half-precision floating-point numbers (IEEE 754)
5859
- `complex128`: double-precision complex floating-point numbers
5960
- `complex64`: single-precision complex floating-point numbers
6061
- `int32`: 32-bit two's complement signed integers

ones-like/benchmark/benchmark.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,28 @@ bench( format( '%s:dtype=%s', pkg, 'float32' ), function benchmark( b ) {
9797
b.end();
9898
});
9999

100+
bench( format( '%s:dtype=%s', pkg, 'float16' ), function benchmark( b ) {
101+
var arr;
102+
var x;
103+
var i;
104+
105+
x = empty( 0, 'float16' );
106+
107+
b.tic();
108+
for ( i = 0; i < b.iterations; i++ ) {
109+
arr = onesLike( x );
110+
if ( arr.length !== 0 ) {
111+
b.fail( 'should have length 0' );
112+
}
113+
}
114+
b.toc();
115+
if ( !isTypedArrayLike( arr ) ) {
116+
b.fail( 'should return a typed array' );
117+
}
118+
b.pass( 'benchmark finished' );
119+
b.end();
120+
});
121+
100122
bench( format( '%s:dtype=%s', pkg, 'complex128' ), function benchmark( b ) {
101123
var arr;
102124
var x;
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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' );
24+
var pow = require( '@stdlib/math/base/special/pow' );
25+
var isTypedArray = require( '@stdlib/assert/is-typed-array' );
26+
var empty = require( './../../empty' );
27+
var format = require( '@stdlib/string/format' );
28+
var pkg = require( './../package.json' ).name;
29+
var onesLike = require( './../lib' );
30+
31+
32+
// FUNCTIONS //
33+
34+
/**
35+
* Creates a benchmark function.
36+
*
37+
* @private
38+
* @param {PositiveInteger} len - array length
39+
* @returns {Function} benchmark function
40+
*/
41+
function createBenchmark( len ) {
42+
var x = empty( len, 'float16' );
43+
return benchmark;
44+
45+
/**
46+
* Benchmark function.
47+
*
48+
* @private
49+
* @param {Benchmark} b - benchmark instance
50+
*/
51+
function benchmark( b ) {
52+
var arr;
53+
var i;
54+
55+
b.tic();
56+
for ( i = 0; i < b.iterations; i++ ) {
57+
arr = onesLike( x );
58+
if ( arr.length !== len ) {
59+
b.fail( 'unexpected length' );
60+
}
61+
}
62+
b.toc();
63+
if ( !isTypedArray( arr ) ) {
64+
b.fail( 'should return a typed array' );
65+
}
66+
b.pass( 'benchmark finished' );
67+
b.end();
68+
}
69+
}
70+
71+
72+
// MAIN //
73+
74+
/**
75+
* Main execution sequence.
76+
*
77+
* @private
78+
*/
79+
function main() {
80+
var len;
81+
var min;
82+
var max;
83+
var f;
84+
var i;
85+
86+
min = 1; // 10^min
87+
max = 6; // 10^max
88+
89+
for ( i = min; i <= max; i++ ) {
90+
len = pow( 10, i );
91+
f = createBenchmark( len );
92+
bench( format( '%s:dtype=%s,len=%d', pkg, 'float16', len ), f );
93+
}
94+
}
95+
96+
main();

ones-like/docs/repl.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
- float64: double-precision floating-point numbers (IEEE 754).
99
- float32: single-precision floating-point numbers (IEEE 754).
10+
- float16: half-precision floating-point numbers (IEEE 754).
1011
- complex128: double-precision complex floating-point numbers.
1112
- complex64: single-precision complex floating-point numbers.
1213
- int32: 32-bit two's complement signed integers.

ones-like/docs/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ declare function onesLike<T extends TypedArray | ComplexTypedArray>( x: T ): T;
6363
*
6464
* - `float64`: double-precision floating-point numbers (IEEE 754)
6565
* - `float32`: single-precision floating-point numbers (IEEE 754)
66+
* - `float16`: half-precision floating-point numbers (IEEE 754)
6667
* - `complex128`: double-precision complex floating-point numbers
6768
* - `complex64`: single-precision complex floating-point numbers
6869
* - `int32`: 32-bit two's complement signed integers

ones-like/docs/types/test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import Complex128Array = require( './../../../complex128' );
2020
import Complex64Array = require( './../../../complex64' );
21+
import Float16Array = require( './../../../float16' );
2122
import onesLike = require( './index' );
2223

2324

@@ -28,6 +29,7 @@ import onesLike = require( './index' );
2829
onesLike( [ 0, 0 ] ); // $ExpectType number[]
2930
onesLike( new Float64Array( [ 0, 0 ] ) ); // $ExpectType Float64Array
3031
onesLike( new Float32Array( [ 0, 0 ] ) ); // $ExpectType Float32Array
32+
onesLike( new Float16Array( [ 0, 0 ] ) ); // $ExpectType Float16Array
3133
onesLike( new Complex128Array( [ 0, 0 ] ) ); // $ExpectType Complex128Array
3234
onesLike( new Complex64Array( [ 0, 0 ] ) ); // $ExpectType Complex64Array
3335
onesLike( new Int32Array( [ 0, 0 ] ) ); // $ExpectType Int32Array
@@ -41,6 +43,7 @@ import onesLike = require( './index' );
4143

4244
onesLike( [ 0, 0 ], 'float64' ); // $ExpectType Float64Array
4345
onesLike( [ 0, 0 ], 'float32' ); // $ExpectType Float32Array
46+
onesLike( [ 0, 0 ], 'float16' ); // $ExpectType Float16ArrayFallback
4447
onesLike( [ 0, 0 ], 'complex128' ); // $ExpectType Complex128Array
4548
onesLike( [ 0, 0 ], 'complex64' ); // $ExpectType Complex64Array
4649
onesLike( [ 0, 0 ], 'int32' ); // $ExpectType Int32Array

ones-like/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"matrix",
6464
"float64array",
6565
"float32array",
66+
"float16array",
6667
"int32array",
6768
"uint32array",
6869
"int16array",
@@ -84,6 +85,9 @@
8485
"float",
8586
"single-precision",
8687
"float32",
88+
"half",
89+
"half-precision",
90+
"float16",
8791
"ieee754",
8892
"integer",
8993
"int32",

ones-like/test/test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var tape = require( 'tape' );
2424
var Float64Array = require( './../../float64' );
2525
var Float32Array = require( './../../float32' );
26+
var Float16Array = require( './../../float16' );
2627
var Int32Array = require( './../../int32' );
2728
var Uint32Array = require( './../../uint32' );
2829
var Int16Array = require( './../../int16' );
@@ -203,6 +204,38 @@ tape( 'the function returns a ones-filled array (dtype=float32)', function test(
203204
t.end();
204205
});
205206

207+
tape( 'the function returns a ones-filled array (float16)', function test( t ) {
208+
var expected;
209+
var arr;
210+
var x;
211+
212+
x = new Float16Array( 5 );
213+
expected = new Float16Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
214+
215+
arr = onesLike( x );
216+
t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' );
217+
t.strictEqual( arr.length, expected.length, 'returns expected value' );
218+
t.deepEqual( arr, expected, 'returns expected value' );
219+
220+
t.end();
221+
});
222+
223+
tape( 'the function returns a ones-filled array (dtype=float16)', function test( t ) {
224+
var expected;
225+
var arr;
226+
var x;
227+
228+
x = new Float64Array( 5 );
229+
expected = new Float16Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
230+
231+
arr = onesLike( x, 'float16' );
232+
t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' );
233+
t.strictEqual( arr.length, expected.length, 'returns expected value' );
234+
t.deepEqual( arr, expected, 'returns expected value' );
235+
236+
t.end();
237+
});
238+
206239
tape( 'the function returns a ones-filled array (complex128)', function test( t ) {
207240
var expected;
208241
var arr;

0 commit comments

Comments
 (0)