Skip to content

Commit b96b8d4

Browse files
committed
Auto-generated commit
1 parent 05d801c commit b96b8d4

9 files changed

Lines changed: 199 additions & 1 deletion

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+
- [`28c1b87`](https://github.com/stdlib-js/stdlib/commit/28c1b877001ac4db853b9a958d9ec33bd1bd8288) - add float16 dtype support to `array/one-to-like` [(#14148)](https://github.com/stdlib-js/stdlib/pull/14148)
1314
- [`7816c92`](https://github.com/stdlib-js/stdlib/commit/7816c92b5fac04969200126d7516f89cf056f7ec) - add float16 dtype support to `array/full` [(#14149)](https://github.com/stdlib-js/stdlib/pull/14149)
1415
- [`de466c1`](https://github.com/stdlib-js/stdlib/commit/de466c1c7555e09de12ae363285fffaefedce4ef) - add float16 dtype support to `array/full-like` [(#14150)](https://github.com/stdlib-js/stdlib/pull/14150)
1516
- [`7cc4708`](https://github.com/stdlib-js/stdlib/commit/7cc47082117a2d68d704d4d54a49d068da41477b) - add float16 dtype support to `array/one-to` [(#14151)](https://github.com/stdlib-js/stdlib/pull/14151)
@@ -82,6 +83,7 @@ This release closes the following issue:
8283

8384
<details>
8485

86+
- [`28c1b87`](https://github.com/stdlib-js/stdlib/commit/28c1b877001ac4db853b9a958d9ec33bd1bd8288) - **feat:** add float16 dtype support to `array/one-to-like` [(#14148)](https://github.com/stdlib-js/stdlib/pull/14148) _(by Gururaj Gurram)_
8587
- [`7816c92`](https://github.com/stdlib-js/stdlib/commit/7816c92b5fac04969200126d7516f89cf056f7ec) - **feat:** add float16 dtype support to `array/full` [(#14149)](https://github.com/stdlib-js/stdlib/pull/14149) _(by Gururaj Gurram)_
8688
- [`de466c1`](https://github.com/stdlib-js/stdlib/commit/de466c1c7555e09de12ae363285fffaefedce4ef) - **feat:** add float16 dtype support to `array/full-like` [(#14150)](https://github.com/stdlib-js/stdlib/pull/14150) _(by Gururaj Gurram)_
8789
- [`7cc4708`](https://github.com/stdlib-js/stdlib/commit/7cc47082117a2d68d704d4d54a49d068da41477b) - **feat:** add float16 dtype support to `array/one-to` [(#14151)](https://github.com/stdlib-js/stdlib/pull/14151) _(by Gururaj Gurram)_

one-to-like/README.md

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

5454
- `float64`: double-precision floating-point numbers (IEEE 754)
5555
- `float32`: single-precision floating-point numbers (IEEE 754)
56+
- `float16`: half-precision floating-point numbers (IEEE 754)
5657
- `complex128`: double-precision complex floating-point numbers
5758
- `complex64`: single-precision complex floating-point numbers
5859
- `int32`: 32-bit two's complement signed integers

one-to-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 = oneToLike( 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 oneToLike = 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 = oneToLike( 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();

one-to-like/docs/repl.txt

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

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

one-to-like/docs/types/index.d.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
/// <reference types="@stdlib/types"/>
2222

23-
import { Complex128Array, Complex64Array, AnyArray, NumericDataType } from '@stdlib/types/array';
23+
import { Complex128Array, Complex64Array, Float16Array, AnyArray, NumericDataType } from '@stdlib/types/array';
2424

2525
/**
2626
* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array.
@@ -58,6 +58,24 @@ declare function oneToLike( x: AnyArray, dtype: 'float64' ): Float64Array;
5858
*/
5959
declare function oneToLike( x: AnyArray, dtype: 'float32' ): Float32Array;
6060

61+
/**
62+
* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array.
63+
*
64+
* @param x - input array from which to derive the output array length
65+
* @param dtype - data type
66+
* @returns linearly spaced numeric array
67+
*
68+
* @example
69+
* var zeros = require( '@stdlib/array/zeros' );
70+
*
71+
* var x = zeros( 2, 'float64' );
72+
* // returns <Float64Array>[ 0.0, 0.0 ]
73+
*
74+
* var y = oneToLike( x, 'float16' );
75+
* // returns <Float16Array>[ 1.0, 2.0 ]
76+
*/
77+
declare function oneToLike( x: AnyArray, dtype: 'float16' ): Float16Array;
78+
6179
/**
6280
* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array.
6381
*
@@ -282,6 +300,24 @@ declare function oneToLike( x: Float64Array, dtype?: NumericDataType ): Float64A
282300
*/
283301
declare function oneToLike( x: Float32Array, dtype?: NumericDataType ): Float32Array;
284302

303+
/**
304+
* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array.
305+
*
306+
* @param x - input array from which to derive the output array length
307+
* @param dtype - data type
308+
* @returns linearly spaced numeric array
309+
*
310+
* @example
311+
* var zeros = require( '@stdlib/array/zeros' );
312+
*
313+
* var x = zeros( 2, 'float16' );
314+
* // returns <Float16Array>[ 0.0, 0.0 ]
315+
*
316+
* var y = oneToLike( x );
317+
* // returns <Float16Array>[ 1.0, 2.0 ]
318+
*/
319+
declare function oneToLike( x: Float16Array, dtype?: NumericDataType ): Float16Array;
320+
285321
/**
286322
* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array.
287323
*

one-to-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 oneToLike = require( './index' );
2223

2324

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

4143
oneToLike( [ 0, 0 ], 'float64' ); // $ExpectType Float64Array
4244
oneToLike( [ 0, 0 ], 'float32' ); // $ExpectType Float32Array
45+
oneToLike( [ 0, 0 ], 'float16' ); // $ExpectType Float16ArrayFallback
4346
oneToLike( [ 0, 0 ], 'complex128' ); // $ExpectType Complex128Array
4447
oneToLike( [ 0, 0 ], 'complex64' ); // $ExpectType Complex64Array
4548
oneToLike( [ 0, 0 ], 'int32' ); // $ExpectType Int32Array

one-to-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",

one-to-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 filled array (dtype=float32)', function test( t )
203204
t.end();
204205
});
205206

207+
tape( 'the function returns a 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, 2.0, 3.0, 4.0, 5.0 ] );
214+
215+
arr = oneToLike( 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 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, 2.0, 3.0, 4.0, 5.0 ] );
230+
231+
arr = oneToLike( 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 filled array (complex128)', function test( t ) {
207240
var expected;
208241
var arr;

0 commit comments

Comments
 (0)