Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
4e48d21
feat: add array/float16
udaykakade25 Jun 21, 2025
8c52f25
chore: update copyright years
stdlib-bot Jun 21, 2025
8611f89
Refactored Polyfill.js
udaykakade25 Jun 29, 2025
12e4814
Refactored polyfill.js
udaykakade25 Jun 29, 2025
1f18925
Update package.json
udaykakade25 Jul 1, 2025
f73e84e
Update polyfill.js
udaykakade25 Jul 22, 2025
fb6fd3a
Merge remote-tracking branch 'upstream/develop' into arrayFloat16Final
stdlib-bot Sep 22, 2025
55b7090
Merge remote-tracking branch 'upstream/develop' into arrayFloat16Final
stdlib-bot Oct 17, 2025
004f5b8
fix: benchmarks
gururaj1512 Oct 18, 2025
641fa20
refactor: implementation
gururaj1512 Oct 18, 2025
673b831
Merge remote-tracking branch 'upstream/develop' into arrayFloat16Final
stdlib-bot Dec 10, 2025
96f487a
refactor: implmentation and add test cases
gururaj1512 Dec 13, 2025
3a39709
chore: apply suggested changes
gururaj1512 Dec 17, 2025
406cbbe
feat: enhance Float16Array constructor to handle Float16Array instances
gururaj1512 Dec 17, 2025
2177682
docs: add readme
gururaj1512 Dec 18, 2025
8e7101a
docs: update README and examples
gururaj1512 Dec 18, 2025
5e33e5c
chore: add and refactor benchmarks
gururaj1512 Dec 19, 2025
a998861
chore: update copyright years
stdlib-bot Dec 19, 2025
3d56a8f
chore: clean-up
kgryte Dec 20, 2025
f5df2eb
refactor: use format for benchmark names
gururaj1512 Dec 21, 2025
4f951f7
fix: handle Float16Array input in Float16Array constructor
gururaj1512 Dec 22, 2025
b3a827f
fix: improve buffer initialization in Float16Array constructor
gururaj1512 Dec 22, 2025
4236133
refactor: fix docs and types
gururaj1512 Dec 22, 2025
f2bd8ba
fix: clarify return type
gururaj1512 Dec 22, 2025
a4991cf
feat: add copyArray function to copy elements between Uint16Arrays
gururaj1512 Dec 24, 2025
3d623ea
fix: remove copyArray function and replace with gcopy in Float16Array…
gururaj1512 Dec 25, 2025
00e3d4a
fix: lint error
gururaj1512 Dec 25, 2025
59ad0b2
Merge remote-tracking branch 'upstream/develop' into arrayFloat16Final
stdlib-bot Feb 28, 2026
49d642c
chore: update copyright years
stdlib-bot Feb 28, 2026
da6789a
bench: fix allocations to ensure 1:1 comparison across array types
kgryte Mar 2, 2026
26de0eb
bench: fix allocations to ensure 1:1 comparison across array types
kgryte Mar 2, 2026
0833917
bench: fix allocations to ensure 1:1 comparison across array types
kgryte Mar 2, 2026
0e0cbfb
bench: use string interpolation
kgryte Mar 2, 2026
ce07df2
docs: fix examples and remove `get` documentation
kgryte Mar 2, 2026
b24ee7b
fix: ensure `set` is consistent with actual `Float16Array`
kgryte Mar 2, 2026
4b84b02
Merge branch 'develop' into arrayFloat16Final
kgryte May 9, 2026
80dcd15
chore: clean-up tests
kgryte May 9, 2026
a243dee
docs: fix examples
kgryte May 9, 2026
889fbde
test: remove obsolete tests
kgryte May 9, 2026
673682a
bench: update condition
kgryte May 9, 2026
d422dba
bench: update condition
kgryte May 9, 2026
10d05dd
bench: update assertion messages
kgryte May 9, 2026
526fcaa
test: fix failing tests
kgryte May 9, 2026
803ece2
bench: relax assertions
kgryte May 9, 2026
0f09c4c
bench: fix assertion
kgryte May 9, 2026
d540e45
bench: fix assertion
kgryte May 9, 2026
7eb0693
bench: fix assertion
kgryte May 9, 2026
4bf6cb6
refactor: update to support exporting built-in and move polyfill test…
kgryte May 9, 2026
4b9e23e
style: re-enable lint rule
kgryte May 9, 2026
4673f3c
style: resolve lint failures
kgryte May 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,564 changes: 1,564 additions & 0 deletions lib/node_modules/@stdlib/array/float16/README.md

Large diffs are not rendered by default.

79 changes: 79 additions & 0 deletions lib/node_modules/@stdlib/array/float16/benchmark/benchmark.at.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* @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 isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
var uniform = require( '@stdlib/random/array/uniform' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var Float16Array = require( './../lib' );


// MAIN //

bench( format( '%s::nonnegative_indices:at', pkg ), function benchmark( b ) {
var arr;
var N;
var v;
var i;

arr = new Float16Array( uniform( 10, 0.0, 10.0 ) );
N = arr.length;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
v = arr.at( i%N );
if ( typeof v !== 'number' ) {
b.fail( 'should return a number' );
}
}
b.toc();
if ( !isNumber( v ) ) {
b.fail( 'should return a number' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( format( '%s::negative_indices:at', pkg ), function benchmark( b ) {
var arr;
var N;
var v;
var i;

arr = new Float16Array( uniform( 10, 1.0, 10.0 ) );
N = arr.length;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
v = arr.at( -(i%N)-1 );
if ( typeof v !== 'number' ) {
b.fail( 'should return a number' );
}
}
b.toc();
if ( !isNumber( v ) ) {
b.fail( 'should return a number' );
}
b.pass( 'benchmark finished' );
b.end();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @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 uniform = require( '@stdlib/random/array/uniform' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var Float16Array = require( './../lib' );


// MAIN //

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

arr = new Float16Array( uniform( 2, 0.0, 10.0 ) );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr[ 0 ] = i;
arr = arr.copyWithin( 1, 0 );
if ( arr[ 0 ] !== arr[ 0 ] ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( arr[ 0 ] !== arr[ 0 ] ) {
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,95 @@
/**
* @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 uniform = require( '@stdlib/random/array/uniform' );
var format = require( '@stdlib/string/format' );
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( uniform( len, 0.0, 10.0 ) );
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 ] !== arr[ 0 ] ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( arr[ 0 ] !== arr[ 0 ] ) {
b.fail( 'should not return 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( format( '%s:copyWithin:len=%d', pkg, len ), f );
}
}

main();
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @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 uniform = require( '@stdlib/random/array/uniform' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var Float16Array = require( './../lib' );


// MAIN //

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

arr = new Float16Array( uniform( 2, 0.0, 10.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,83 @@
/**
* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
var uniform = require( '@stdlib/random/array/uniform' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var Float16Array = require( './../lib' );


// MAIN //

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

arr = new Float16Array( uniform( 2, 0.0, 10.0 ) );

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( format( '%s::this_context:every', pkg ), function benchmark( b ) {
var bool;
var arr;
var i;

arr = new Float16Array( uniform( 2, 0.0, 10.0 ) );

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