diff --git a/lib/node_modules/@stdlib/array/filled-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/array/filled-by/benchmark/benchmark.js index 9b64a0505e7c..6f74be722893 100644 --- a/lib/node_modules/@stdlib/array/filled-by/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/array/filled-by/benchmark/benchmark.js @@ -99,6 +99,28 @@ bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { b.end(); }); +bench( format( '%s:dtype=float16', pkg ), function benchmark( b ) { + var clbk; + var arr; + var i; + + clbk = constantFunction( 0.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarrayBy( 0, 'float16', clbk ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isTypedArrayLike( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { var clbk; var arr; diff --git a/lib/node_modules/@stdlib/array/filled-by/benchmark/benchmark.length.float16.js b/lib/node_modules/@stdlib/array/filled-by/benchmark/benchmark.length.float16.js new file mode 100644 index 000000000000..d079f7ae5e55 --- /dev/null +++ b/lib/node_modules/@stdlib/array/filled-by/benchmark/benchmark.length.float16.js @@ -0,0 +1,98 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isTypedArray = require( '@stdlib/assert/is-typed-array' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var filledarray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var clbk; + var arr; + var i; + + clbk = constantFunction( 1.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( len, 'float16', clbk ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=float16,len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/filled-by/docs/types/test.ts b/lib/node_modules/@stdlib/array/filled-by/docs/types/test.ts index bb876ed20093..795b6e6badbd 100644 --- a/lib/node_modules/@stdlib/array/filled-by/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/filled-by/docs/types/test.ts @@ -64,6 +64,7 @@ function clbk( i: number ): number { { filledarrayBy(); // $ExpectType ArrayOrTypedArray filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray + filledarrayBy( 'float16' ); // $ExpectType ArrayOrTypedArray filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray diff --git a/lib/node_modules/@stdlib/array/filled-by/package.json b/lib/node_modules/@stdlib/array/filled-by/package.json index 13b17ee0d861..c36c81d36715 100644 --- a/lib/node_modules/@stdlib/array/filled-by/package.json +++ b/lib/node_modules/@stdlib/array/filled-by/package.json @@ -63,6 +63,7 @@ "matrix", "float64array", "float32array", + "float16array", "int32array", "uint32array", "int16array", @@ -78,6 +79,9 @@ "float", "single-precision", "float32", + "half", + "half-precision", + "float16", "ieee754", "integer", "int32", diff --git a/lib/node_modules/@stdlib/array/filled-by/test/test.js b/lib/node_modules/@stdlib/array/filled-by/test/test.js index 1a34dba8d6ff..13e85ec10ee1 100644 --- a/lib/node_modules/@stdlib/array/filled-by/test/test.js +++ b/lib/node_modules/@stdlib/array/filled-by/test/test.js @@ -26,6 +26,7 @@ var tape = require( 'tape' ); var proxyquire = require( 'proxyquire' ); var Float64Array = require( '@stdlib/array/float64' ); var Float32Array = require( '@stdlib/array/float32' ); +var Float16Array = require( '@stdlib/array/float16' ); var Int32Array = require( '@stdlib/array/int32' ); var Uint32Array = require( '@stdlib/array/uint32' ); var Int16Array = require( '@stdlib/array/int16' ); @@ -1831,6 +1832,20 @@ tape( 'the function returns a filled array (dtype=float32)', function test( t ) t.end(); }); +tape( 'the function returns a filled array (dtype=float16)', function test( t ) { + var expected; + var arr; + + expected = new Float16Array( 0 ); + arr = filledarrayBy( 'float16' ); + + t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled array (dtype=bool)', function test( t ) { var expected; var arr; @@ -2185,6 +2200,23 @@ tape( 'the function returns a filled array (dtype=float32, length)', function te t.end(); }); +tape( 'the function returns a filled array (dtype=float16, length)', function test( t ) { + var expected; + var clbk; + var arr; + + expected = new Float16Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + clbk = constantFunction( 1.0 ); + arr = filledarrayBy( 5, 'float16', clbk ); + + t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled array (dtype=bool, length)', function test( t ) { var expected; var clbk; @@ -2495,6 +2527,25 @@ tape( 'the function returns a filled array (dtype=float32, array)', function tes t.end(); }); +tape( 'the function returns a filled array (dtype=float16, array)', function test( t ) { + var expected; + var clbk; + var arr; + var out; + + expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); + + clbk = constantFunction( 1.0 ); + arr = [ 1.0, 2.0, 3.0 ]; + out = filledarrayBy( arr, 'float16', clbk ); + + t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled array (dtype=bool, array)', function test( t ) { var expected; var clbk; @@ -2826,6 +2877,25 @@ tape( 'the function returns a filled array (dtype=float32, typed array)', functi t.end(); }); +tape( 'the function returns a filled array (dtype=float16, typed array)', function test( t ) { + var expected; + var clbk; + var arr; + var out; + + expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); + + clbk = constantFunction( 1.0 ); + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = filledarrayBy( arr, 'float16', clbk ); + + t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled array (dtype=bool, typed array)', function test( t ) { var expected; var clbk; @@ -3158,6 +3228,25 @@ tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', t.end(); }); +tape( 'the function returns a filled typed array (dtype=float16, arraybuffer)', function test( t ) { + var expected; + var clbk; + var buf; + var out; + + expected = new Float16Array( [ 1.0, 1.0 ] ); + + clbk = constantFunction( 1.0 ); + buf = new ArrayBuffer( 4 ); + out = filledarrayBy( buf, 'float16', clbk ); + + t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled typed array (dtype=bool, arraybuffer)', function test( t ) { var expected; var clbk; @@ -3491,6 +3580,25 @@ tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, by t.end(); }); +tape( 'the function returns a filled typed array (dtype=float16, arraybuffer, byteoffset)', function test( t ) { + var expected; + var clbk; + var buf; + var out; + + expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); + + clbk = constantFunction( 1.0 ); + buf = new ArrayBuffer( 8 ); + out = filledarrayBy( buf, 2, 'float16', clbk ); + + t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { var expected; var clbk; @@ -3822,6 +3930,25 @@ tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, by t.end(); }); +tape( 'the function returns a filled typed array (dtype=float16, arraybuffer, byteoffset, length)', function test( t ) { + var expected; + var clbk; + var buf; + var out; + + expected = new Float16Array( [ 1.0, 1.0 ] ); + + clbk = constantFunction( 1.0 ); + buf = new ArrayBuffer( 8 ); + out = filledarrayBy( buf, 2, 2, 'float16', clbk ); + + t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { var expected; var clbk; @@ -4165,6 +4292,27 @@ tape( 'the function returns a filled array (dtype=float32, iterator)', opts, fun t.end(); }); +tape( 'the function returns a filled array (dtype=float16, iterator)', opts, function test( t ) { + var expected; + var clbk; + var arr; + var out; + + expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); + + clbk = constantFunction( 1.0 ); + arr = iterConstant( 3.0, { + 'iter': 3 + }); + out = filledarrayBy( arr, 'float16', clbk ); + + t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled array (dtype=bool, iterator)', opts, function test( t ) { var expected; var clbk;