diff --git a/lib/node_modules/@stdlib/array/empty/benchmark/benchmark.js b/lib/node_modules/@stdlib/array/empty/benchmark/benchmark.js index 9e9a5f102e47..67eeecbd51c4 100644 --- a/lib/node_modules/@stdlib/array/empty/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/array/empty/benchmark/benchmark.js @@ -84,6 +84,24 @@ bench( format( '%s:dtype=%s', pkg, 'float32' ), function benchmark( b ) { b.end(); }); +bench( format( '%s:dtype=%s', pkg, 'float16' ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = empty( 0, 'float16' ); + 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=%s', pkg, 'bool' ), function benchmark( b ) { var arr; var i; diff --git a/lib/node_modules/@stdlib/array/empty/benchmark/benchmark.length.float16.js b/lib/node_modules/@stdlib/array/empty/benchmark/benchmark.length.float16.js new file mode 100644 index 000000000000..3342cd506cb7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/empty/benchmark/benchmark.length.float16.js @@ -0,0 +1,94 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var empty = 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 arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = empty( len, 'float16' ); + 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/empty/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/empty/docs/types/index.d.ts index 598c2b369f5b..0b6ccb616526 100644 --- a/lib/node_modules/@stdlib/array/empty/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/empty/docs/types/index.d.ts @@ -42,6 +42,10 @@ import { DataTypeMap } from '@stdlib/types/array'; * @example * var arr = empty( 2, 'float32' ); * // returns +* +* @example +* var arr = empty( 2, 'float16' ); +* // returns */ declare function empty = 'float64'>( length: number, dtype?: T ): DataTypeMap[T]; diff --git a/lib/node_modules/@stdlib/array/empty/docs/types/test.ts b/lib/node_modules/@stdlib/array/empty/docs/types/test.ts index 78de0828f21e..a97c1d269b5a 100644 --- a/lib/node_modules/@stdlib/array/empty/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/empty/docs/types/test.ts @@ -26,6 +26,7 @@ import empty = require( './index' ); empty( 10 ); // $ExpectType Float64Array empty( 10, 'float64' ); // $ExpectType Float64Array empty( 10, 'float32' ); // $ExpectType Float32Array + empty( 10, 'float16' ); // $ExpectType Float16ArrayFallback empty( 10, 'complex128' ); // $ExpectType Complex128Array empty( 10, 'complex64' ); // $ExpectType Complex64Array empty( 10, 'bool' ); // $ExpectType BooleanArray diff --git a/lib/node_modules/@stdlib/array/empty/package.json b/lib/node_modules/@stdlib/array/empty/package.json index fbc53bc9e542..75ae8d3fda29 100644 --- a/lib/node_modules/@stdlib/array/empty/package.json +++ b/lib/node_modules/@stdlib/array/empty/package.json @@ -64,6 +64,7 @@ "matrix", "float64array", "float32array", + "float16array", "int32array", "uint32array", "int16array", @@ -85,6 +86,9 @@ "float", "single-precision", "float32", + "half", + "half-precision", + "float16", "ieee754", "integer", "int32", diff --git a/lib/node_modules/@stdlib/array/empty/test/test.main.js b/lib/node_modules/@stdlib/array/empty/test/test.main.js index 0c1aeddcc8b4..c635cf4a2709 100644 --- a/lib/node_modules/@stdlib/array/empty/test/test.main.js +++ b/lib/node_modules/@stdlib/array/empty/test/test.main.js @@ -23,6 +23,7 @@ var tape = require( 'tape' ); 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' ); @@ -170,6 +171,16 @@ tape( 'the function returns an empty array (dtype=float32)', function test( t ) t.end(); }); +tape( 'the function returns an empty array (dtype=float16)', function test( t ) { + var arr; + + arr = empty( 5, 'float16' ); + t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, 5, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an empty array (dtype=bool)', function test( t ) { var arr;