Skip to content
1,481 changes: 1,481 additions & 0 deletions lib/node_modules/@stdlib/array/float16/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 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 pkg = require( './../package.json' ).name;
var Float16Array = require( './../lib' );


// MAIN //

bench( pkg+':copyWithin', function benchmark( b ) {
var arr;
var i;

arr = new Float16Array( 2 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr[ 0 ] = i;
arr = arr.copyWithin( 1, 0 );
if ( arr[ 0 ] !== i ) {
b.fail( 'unexpected result' );
}
}
b.toc();
if ( arr[ 0 ] !== arr[ 0 ] ) {
b.fail( 'should not be NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 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 pkg = require( './../package.json' ).name;
var Float16Array = require( './../lib' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var arr = new Float16Array( len );
return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr[ 0 ] = i;
arr = arr.copyWithin( 1, 0 );
if ( arr[ 0 ] !== i ) {
b.fail( 'unexpected result' );
}
}
b.toc();
if ( arr[ 0 ] !== arr[ 0 ] ) {
b.fail( 'should not be NaN' );
}
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( pkg+':copyWithin:len='+len, f );
}
}

main();
75 changes: 75 additions & 0 deletions lib/node_modules/@stdlib/array/float16/benchmark/benchmark.data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 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 pkg = require( './../package.json' ).name;
var Float16Array = require( './../lib' );


// MAIN //

bench( pkg+'::get,index', function benchmark( b ) {
var arr;
var N;
var v;
var i;

arr = new Float16Array( 2 );
N = arr.length;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
v = arr[ i%N ];
if ( v !== v ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( v !== v ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( pkg+'::set,index', function benchmark( b ) {
var arr;
var N;
var i;

arr = new Float16Array( 2 );
N = arr.length;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr[ i%N ] = i;
if ( arr[ 0 ] !== arr[ 0 ] ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 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 pkg = require( './../package.json' ).name;
var Float16Array = require( './../lib' );


// MAIN //

bench( pkg+':entries', function benchmark( b ) {
var iter;
var arr;
var i;

arr = new Float16Array( [ 1.0, 2.0 ] );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
iter = arr.entries();
if ( typeof iter !== 'object' ) {
b.fail( 'should return an object' );
}
}
b.toc();
if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) {
b.fail( 'should return an iterator protocol-compliant object' );
}
b.pass( 'benchmark finished' );
b.end();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
var pkg = require( './../package.json' ).name;
var Float16Array = require( './../lib' );


// MAIN //

bench( pkg+':every', function benchmark( b ) {
var bool;
var arr;
var i;

arr = new Float16Array( 2 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = arr.every( predicate );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
}
b.toc();
if ( !isBoolean( bool ) ) {
b.fail( 'should return a boolean' );
}
b.pass( 'benchmark finished' );
b.end();

function predicate( v ) {
return v >= 0.0;
}
});

bench( pkg+'::this_context:every', function benchmark( b ) {
var bool;
var arr;
var i;

arr = new Float16Array( 2 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = arr.every( predicate, {} );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
}
b.toc();
if ( !isBoolean( bool ) ) {
b.fail( 'should return a boolean' );
}
b.pass( 'benchmark finished' );
b.end();

function predicate( v ) {
return v >= 0.0;
}
});
Loading
Loading