Skip to content

Commit e0495db

Browse files
committed
Auto-generated commit
1 parent 7d6413a commit e0495db

7 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+
- [`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)
1314
- [`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)
1415
- [`b5ff3b6`](https://github.com/stdlib-js/stdlib/commit/b5ff3b66fe639b073761be77dfe1a3b57773d6f6) - add `entries` method to `array/uint64` [(#13888)](https://github.com/stdlib-js/stdlib/pull/13888)
1516
- [`24405b6`](https://github.com/stdlib-js/stdlib/commit/24405b647f170b8737700ebc9d08752bd5cc1ea5) - add `at` method to `array/uint64` [(#13830)](https://github.com/stdlib-js/stdlib/pull/13830)
@@ -80,6 +81,7 @@ This release closes the following issue:
8081

8182
<details>
8283

84+
- [`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)_
8385
- [`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)_
8486
- [`ad9d109`](https://github.com/stdlib-js/stdlib/commit/ad9d1092d73c1635a10bb0ac4400c92dd50722eb) - **chore:** clean-up [(#13949)](https://github.com/stdlib-js/stdlib/pull/13949) _(by Philipp Burckhardt, Athan Reines)_
8587
- [`1935a5f`](https://github.com/stdlib-js/stdlib/commit/1935a5f7306c6e1f01f3880f4374dfeadf52f371) - **chore:** clean-up [(#13951)](https://github.com/stdlib-js/stdlib/pull/13951) _(by Philipp Burckhardt)_

full-like/benchmark/benchmark.js

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

102+
bench( format( '%s:dtype=float16', pkg ), function benchmark( b ) {
103+
var arr;
104+
var x;
105+
var i;
106+
107+
x = empty( 0, 'float16' );
108+
109+
b.tic();
110+
for ( i = 0; i < b.iterations; i++ ) {
111+
arr = fullLike( x, 1.0 );
112+
if ( arr.length !== 0 ) {
113+
b.fail( 'should have length 0' );
114+
}
115+
}
116+
b.toc();
117+
if ( !isTypedArrayLike( arr ) ) {
118+
b.fail( 'should return a typed array' );
119+
}
120+
b.pass( 'benchmark finished' );
121+
b.end();
122+
});
123+
102124
bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) {
103125
var arr;
104126
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 fullLike = 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 = fullLike( x, 1.0 );
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=float16,len=%d', pkg, len ), f );
93+
}
94+
}
95+
96+
main();

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

Lines changed: 39 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, BooleanArray, AnyArray, DataType } from '@stdlib/types/array';
23+
import { Complex128Array, Complex64Array, Float16Array, BooleanArray, AnyArray, DataType } from '@stdlib/types/array';
2424
import { ComplexLike } from '@stdlib/types/complex';
2525

2626
/**
@@ -61,6 +61,25 @@ declare function fullLike( x: AnyArray, value: number, dtype: 'float64' ): Float
6161
*/
6262
declare function fullLike( x: AnyArray, value: number, dtype: 'float32' ): Float32Array;
6363

64+
/**
65+
* Creates a filled array having the same length as a provided input array.
66+
*
67+
* @param x - input array from which to derive the output array length
68+
* @param value - fill value
69+
* @param dtype - data type
70+
* @returns filled array
71+
*
72+
* @example
73+
* var zeros = require( '@stdlib/array/zeros' );
74+
*
75+
* var x = zeros( 2, 'float64' );
76+
* // returns <Float64Array>[ 0.0, 0.0 ]
77+
*
78+
* var y = fullLike( x, 1.0, 'float16' );
79+
* // returns <Float16Array>[ 1.0, 1.0 ]
80+
*/
81+
declare function fullLike( x: AnyArray, value: number, dtype: 'float16' ): Float16Array;
82+
6483
/**
6584
* Creates a filled array having the same length as a provided input array.
6685
*
@@ -316,6 +335,25 @@ declare function fullLike( x: Float64Array, value: number, dtype?: DataType ): F
316335
*/
317336
declare function fullLike( x: Float32Array, value: number, dtype?: DataType ): Float32Array;
318337

338+
/**
339+
* Creates a filled array having the same length and data type as a provided input array.
340+
*
341+
* @param x - input array from which to derive the output array length
342+
* @param value - fill value
343+
* @param dtype - data type
344+
* @returns filled array
345+
*
346+
* @example
347+
* var zeros = require( '@stdlib/array/zeros' );
348+
*
349+
* var x = zeros( 2, 'float16' );
350+
* // returns <Float16Array>[ 0.0, 0.0 ]
351+
*
352+
* var y = fullLike( x, 1.0 );
353+
* // returns <Float16Array>[ 1.0, 1.0 ]
354+
*/
355+
declare function fullLike( x: Float16Array, value: number, dtype?: DataType ): Float16Array;
356+
319357
/**
320358
* Creates a filled array having the same length and data type as a provided input array.
321359
*

full-like/docs/types/test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import BooleanArray = require( './../../../bool' );
2020
import Complex128Array = require( './../../../complex128' );
2121
import Complex64Array = require( './../../../complex64' );
22+
import Float16Array = require( './../../../float16' );
2223
import Complex128 = require( '@stdlib/complex/float64/ctor' );
2324
import Complex64 = require( '@stdlib/complex/float32/ctor' );
2425
import fullLike = require( './index' );
@@ -31,6 +32,7 @@ import fullLike = require( './index' );
3132
fullLike( [ 0, 0 ], 1 ); // $ExpectType any[]
3233
fullLike( new Float64Array( [ 0, 0 ] ), 1 ); // $ExpectType Float64Array
3334
fullLike( new Float32Array( [ 0, 0 ] ), 1 ); // $ExpectType Float32Array
35+
fullLike( new Float16Array( [ 0, 0 ] ), 1 ); // $ExpectType Float16ArrayFallback
3436
fullLike( new Complex128Array( [ 0, 0 ] ), 1 ); // $ExpectType Complex128Array
3537
fullLike( new Complex128Array( [ 0, 0 ] ), new Complex128( 1.0, 1.0 ) ); // $ExpectType Complex128Array
3638
fullLike( new Complex64Array( [ 0, 0 ] ), 1 ); // $ExpectType Complex64Array
@@ -46,6 +48,7 @@ import fullLike = require( './index' );
4648

4749
fullLike( [ 0, 0 ], 1, 'float64' ); // $ExpectType Float64Array
4850
fullLike( [ 0, 0 ], 1, 'float32' ); // $ExpectType Float32Array
51+
fullLike( [ 0, 0 ], 1, 'float16' ); // $ExpectType Float16ArrayFallback
4952
fullLike( [ 0, 0 ], 1, 'complex128' ); // $ExpectType Complex128Array
5053
fullLike( [ 0, 0 ], new Complex128( 1.0, 1.0 ), 'complex128' ); // $ExpectType Complex128Array
5154
fullLike( [ 0, 0 ], 1, 'complex64' ); // $ExpectType Complex64Array

full-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",

full-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' );
@@ -207,6 +208,38 @@ tape( 'the function returns a filled array (dtype=float32)', function test( t )
207208
t.end();
208209
});
209210

211+
tape( 'the function returns a filled array (float16)', function test( t ) {
212+
var expected;
213+
var arr;
214+
var x;
215+
216+
x = new Float16Array( 5 );
217+
expected = new Float16Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
218+
219+
arr = fullLike( x, 1.0 );
220+
t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' );
221+
t.strictEqual( arr.length, expected.length, 'returns expected value' );
222+
t.deepEqual( arr, expected, 'returns expected value' );
223+
224+
t.end();
225+
});
226+
227+
tape( 'the function returns a filled array (dtype=float16)', function test( t ) {
228+
var expected;
229+
var arr;
230+
var x;
231+
232+
x = new Float64Array( 5 );
233+
expected = new Float16Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
234+
235+
arr = fullLike( x, 1.0, 'float16' );
236+
t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' );
237+
t.strictEqual( arr.length, expected.length, 'returns expected value' );
238+
t.deepEqual( arr, expected, 'returns expected value' );
239+
240+
t.end();
241+
});
242+
210243
tape( 'the function returns a filled array (bool)', function test( t ) {
211244
var expected;
212245
var arr;

0 commit comments

Comments
 (0)