diff --git a/lib/node_modules/@stdlib/ndarray/base/nans/README.md b/lib/node_modules/@stdlib/ndarray/base/nans/README.md index f0fd315dc627..05d6aa16edff 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nans/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/nans/README.md @@ -87,6 +87,7 @@ var nans = require( '@stdlib/ndarray/base/nans' ); var dt = [ 'float64', 'float32', + 'float16', 'complex128', 'complex64', 'generic' diff --git a/lib/node_modules/@stdlib/ndarray/base/nans/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/base/nans/benchmark/benchmark.js index 36d8cf533197..1ca5bda82511 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nans/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/ndarray/base/nans/benchmark/benchmark.js @@ -65,6 +65,24 @@ bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { b.end(); }); +bench( format( '%s:dtype=float16', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = nans( 'float16', [ 0 ], 'row-major' ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { var arr; var i; diff --git a/lib/node_modules/@stdlib/ndarray/base/nans/benchmark/benchmark.size.float16.js b/lib/node_modules/@stdlib/ndarray/base/nans/benchmark/benchmark.size.float16.js new file mode 100644 index 000000000000..38bbd2c50c47 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nans/benchmark/benchmark.size.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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var nans = 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 = nans( 'float16', [ len ], 'row-major' ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + 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,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/nans/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/nans/docs/types/index.d.ts index 957967419b50..786f8d629a74 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nans/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/nans/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { Shape, Order, typedndarray, genericndarray, float64ndarray, float32ndarray, complex128ndarray, complex64ndarray, FloatingPointAndGenericDataType, GenericDataType, Float64DataType, Float32DataType, Complex128DataType, Complex64DataType } from '@stdlib/types/ndarray'; +import { Shape, Order, typedndarray, genericndarray, float64ndarray, float32ndarray, float16ndarray, complex128ndarray, complex64ndarray, FloatingPointAndGenericDataType, GenericDataType, Float64DataType, Float32DataType, Float16DataType, Complex128DataType, Complex64DataType } from '@stdlib/types/ndarray'; /** * Creates a NaN-filled ndarray having a specified shape and data type. @@ -60,6 +60,25 @@ declare function nans( dtype: Float64DataType, shape: Shape, order: Order ): flo */ declare function nans( dtype: Float32DataType, shape: Shape, order: Order ): float32ndarray; +/** +* Creates a NaN-filled ndarray having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns NaN-filled ndarray +* +* @example +* var getDType = require( '@stdlib/ndarray/dtype' ); +* +* var arr = nans( 'float16', [ 2, 2 ], 'row-major' ); +* // returns [ [ NaN, NaN ], [ NaN, NaN ] ] +* +* var dt = String( getDType( arr ) ); +* // returns 'float16' +*/ +declare function nans( dtype: Float16DataType, shape: Shape, order: Order ): float16ndarray; + /** * Creates a NaN-filled ndarray having a specified shape and data type. * diff --git a/lib/node_modules/@stdlib/ndarray/base/nans/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/nans/docs/types/test.ts index 612bcf4e4309..b93ca4242b5e 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nans/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/base/nans/docs/types/test.ts @@ -25,12 +25,14 @@ import nans = require( './index' ); { nans( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray nans( 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray + nans( 'float16', [ 2, 2 ], 'row-major' ); // $ExpectType float16ndarray nans( 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray nans( 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray nans( 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray nans( 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray nans( 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray + nans( 'float16', [ 2, 2 ], 'column-major' ); // $ExpectType float16ndarray nans( 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray nans( 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray nans( 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray diff --git a/lib/node_modules/@stdlib/ndarray/base/nans/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/nans/examples/index.js index 31c65670552a..aa3be9650c98 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nans/examples/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/nans/examples/index.js @@ -24,6 +24,7 @@ var nans = require( './../lib' ); var dt = [ 'float64', 'float32', + 'float16', 'complex128', 'complex64', 'generic' diff --git a/lib/node_modules/@stdlib/ndarray/base/nans/test/test.js b/lib/node_modules/@stdlib/ndarray/base/nans/test/test.js index 3472ebca7a2f..55521761cf60 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nans/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/base/nans/test/test.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 Complex64Array = require( '@stdlib/array/complex64' ); var Complex128Array = require( '@stdlib/array/complex128' ); var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); @@ -164,6 +165,34 @@ tape( 'the function returns a NaN-filled array (dtype=float32, order=column-majo t.end(); }); +tape( 'the function returns a NaN-filled array (dtype=float16, order=row-major)', function test( t ) { + var arr; + + arr = nans( 'float16', [ 2, 2 ], 'row-major' ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'float16', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Float16Array ), true, 'returns expected value' ); + t.strictEqual( allNaN( getData( arr ) ), true, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a NaN-filled array (dtype=float16, order=column-major)', function test( t ) { + var arr; + + arr = nans( 'float16', [ 2, 2 ], 'column-major' ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'float16', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Float16Array ), true, 'returns expected value' ); + t.strictEqual( allNaN( getData( arr ) ), true, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a NaN-filled array (dtype=complex128, order=row-major)', function test( t ) { var arr;