diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/README.md b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/README.md index 928492d2d6d4..fec3d0899c39 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/README.md +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/README.md @@ -54,6 +54,53 @@ var out = isEqual( a, b ); // returns true ``` +#### isEqual.words( ah, al, bh, bl ) + +Tests whether two 64-bit unsigned integers are equal using word comparison. + +```javascript +var bool = isEqual.words( 0, 5, 0, 5 ); +// returns true + +bool = isEqual.words( 0, 5, 0, 10 ); +// returns false +``` + +The function supports the following parameters: + +- **ah**: high 32-bit word of the first 64-bit unsigned integer. +- **al**: low 32-bit word of the first 64-bit unsigned integer. +- **bh**: high 32-bit word of the second 64-bit unsigned integer. +- **bl**: low 32-bit word of the second 64-bit unsigned integer. + +#### isEqual.strided( a, strideA, offsetA, b, strideB, offsetB ) + +Tests whether two 64-bit unsigned integers stored in integer-valued strided array views are equal. + +```javascript +var Uint32Array = require( '@stdlib/array/uint32' ); + +var a = new Uint32Array( [ 0, 5 ] ); +var b = new Uint32Array( [ 0, 5 ] ); + +var bool = isEqual.strided( a, 1, 0, b, 1, 0 ); +// returns true + +b = new Uint32Array( [ 0, 10 ] ); + +bool = isEqual.strided( a, 1, 0, b, 1, 0 ); +// returns false +``` + +The function supports the following parameters: + +- **a**: first 64-bit unsigned integer strided array view containing interleaved 32-bit unsigned integer high and low order words. +- **strideA**: stride length for `a`. +- **offsetA**: starting index for `a`. +- **b**: second 64-bit unsigned integer strided array view containing interleaved 32-bit unsigned integer high and low order words. +- **strideB**: stride length for `b`. +- **offsetB**: starting index for `b`. + @@ -76,6 +123,7 @@ var out = isEqual( a, b ); ```javascript var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var Uint32Array = require( '@stdlib/array/uint32' ); var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); var a = new Uint64( 1234 ); @@ -87,6 +135,21 @@ a = new Uint64( 1234 ); b = new Uint64( 5678 ); out = isEqual( a, b ); // returns false + +out = isEqual.words( 0, 1234, 0, 1234 ); +// returns true + +out = isEqual.words( 0, 1234, 0, 5678 ); +// returns false + +var x = new Uint32Array( [ 0, 1234 ] ); +var y = new Uint32Array( [ 0, 1234 ] ); +out = isEqual.strided( x, 1, 0, y, 1, 0 ); +// returns true + +y = new Uint32Array( [ 0, 5678 ] ); +out = isEqual.strided( x, 1, 0, y, 1, 0 ); +// returns false ``` diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.main.js b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.main.js new file mode 100644 index 000000000000..643c5e4f1db0 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.main.js @@ -0,0 +1,73 @@ +/** +* @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 UINT32_MAX = require( '@stdlib/constants/uint32/max' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var isEqual = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'uint32' +}; + +var N = 128; +var x = discreteUniform( 2*N, 0, UINT32_MAX, options ); +var y = discreteUniform( 2*N, 0, UINT32_MAX, options ); +var values1 = []; +var values2 = []; +var i; +var j; +x[0] = y[0]; +x[1] = y[1]; +for ( i = 0; i < N; i++ ) { + j = 2 * i; + values1.push( Uint64.of( x[ j ], x[ j+1 ] ) ); + values2.push( Uint64.of( y[ j ], y[ j+1 ] ) ); +} + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = isEqual( values1[ i%N ], values2[ i%N ] ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.js b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.strided.js similarity index 68% rename from lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.js rename to lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.strided.js index c4c340339c6a..9a5915aeb098 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.strided.js @@ -21,37 +21,44 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var MAX_SAFE_INTEGER = require( '@stdlib/constants/float64/max-safe-integer' ); -var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var isEqual = require( './../lib' ); +// VARIABLES // + +var options = { + 'dtype': 'uint32' +}; + +var N = 128; +var x = discreteUniform( 2*N, 0, UINT32_MAX, options ); +var y = discreteUniform( 2*N, 0, UINT32_MAX, options ); +x[0] = y[0]; +x[1] = y[1]; + + // MAIN // -bench( pkg, function benchmark( b ) { - var x; - var y; +bench( format( '%s:strided', pkg ), function benchmark( b ) { + var out; var i; - var v; - - x = discreteUniform( 100, 0, MAX_SAFE_INTEGER ); - y = []; - for ( i = 0; i < x.length; i++ ) { - y.push( new Uint64( x[i] ) ); - } + var j; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = isEqual( y[ i % y.length ], y[ (i+1) % y.length ] ); - if ( typeof v !== 'boolean' ) { + j = 2 * ( i % N ); + out = isEqual.strided( x, 1, j, y, 1, j ); + if ( typeof out !== 'boolean' ) { b.fail( 'should return a boolean' ); } } b.toc(); - if ( !isBoolean( v ) ) { + if ( !isBoolean( out ) ) { b.fail( 'should return a boolean' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.words.branched.js b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.words.branched.js new file mode 100644 index 000000000000..b8f41f72e54b --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.words.branched.js @@ -0,0 +1,66 @@ +/** +* @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 UINT32_MAX = require( '@stdlib/constants/uint32/max' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var words = require( './../lib/words_branched.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'uint32' +}; + +var N = 128; +var x = discreteUniform( 2*N, 0, UINT32_MAX, options ); +var y = discreteUniform( 2*N, 0, UINT32_MAX, options ); +x[0] = y[0]; +x[1] = y[1]; + + +// MAIN // + +bench( format( '%s:words::branched', pkg ), function benchmark( b ) { + var out; + var i; + var j; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + j = 2 * ( i % N ); + out = words( x[ j ], x[ j + 1 ], y[ j ], y[ j + 1 ] ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.words.js b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.words.js new file mode 100644 index 000000000000..f089ed2e1df4 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.words.js @@ -0,0 +1,66 @@ +/** +* @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 UINT32_MAX = require( '@stdlib/constants/uint32/max' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var isEqual = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'uint32' +}; + +var N = 128; +var x = discreteUniform( 2*N, 0, UINT32_MAX, options ); +var y = discreteUniform( 2*N, 0, UINT32_MAX, options ); +x[0] = y[0]; +x[1] = y[1]; + + +// MAIN // + +bench( format( '%s:words', pkg ), function benchmark( b ) { + var out; + var i; + var j; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + j = 2 * ( i % N ); + out = isEqual.words( x[ j ], x[ j + 1 ], y[ j ], y[ j + 1 ] ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/docs/repl.txt b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/docs/repl.txt index e9fd449f2985..d03e4dc5c613 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/docs/repl.txt @@ -22,6 +22,78 @@ > var v = {{alias}}( a, b ) true + +{{alias}}.words( ah, al, bh, bl ) + Tests whether two 64-bit unsigned integers are equal using word comparison. + + Parameters + ---------- + ah: integer + High 32-bit word of the first 64-bit unsigned integer. + + al: integer + Low 32-bit word of the first 64-bit unsigned integer. + + bh: integer + High 32-bit word of the second 64-bit unsigned integer. + + bl: integer + Low 32-bit word of the second 64-bit unsigned integer. + + Returns + ------- + out: boolean + Result. + + Examples + -------- + > var v = {{alias}}.words( 0, 5, 0, 5 ) + true + > v = {{alias}}.words( 0, 5, 0, 10 ) + false + + +{{alias}}.strided( a, strideA, offsetA, b, strideB, offsetB ) + Tests whether two 64-bit unsigned integers stored in integer-valued strided + array views are equal. + + Parameters + ---------- + a: ArrayLikeObject + First 64-bit unsigned integer strided array view containing interleaved + 32-bit unsigned integer high and low order words. + + strideA: integer + Stride length for `a`. + + offsetA: integer + Starting index for `a`. + + b: ArrayLikeObject + Second 64-bit unsigned integer strided array view containing interleaved + 32-bit unsigned integer high and low order words. + + strideB: integer + Stride length for `b`. + + offsetB: integer + Starting index for `b`. + + Returns + ------- + out: boolean + Result. + + Examples + -------- + > var a = new {{alias:@stdlib/array/uint32}}( [ 0, 5 ] ); + > var b = new {{alias:@stdlib/array/uint32}}( [ 0, 5 ] ); + > var v = {{alias}}.strided( a, 1, 0, b, 1, 0 ) + true + > b = new {{alias:@stdlib/array/uint32}}( [ 0, 10 ] ); + > v = {{alias}}.strided( a, 1, 0, b, 1, 0 ) + false + See Also -------- diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/docs/types/index.d.ts index caccbc5b3345..56048a37998f 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/docs/types/index.d.ts @@ -21,6 +21,70 @@ /// import { Uint64 } from '@stdlib/types/number'; +import { Collection, NumericArray } from '@stdlib/types/array'; + +/** +* Interface for testing whether two 64-bit unsigned integers are equal. +*/ +interface IsEqual { + /** + * Tests whether two 64-bit unsigned integers are equal. + * + * @param a - first 64-bit unsigned integer + * @param b - second 64-bit unsigned integer + * @returns boolean indicating if both 64-bit unsigned integers are equal + * + * @example + * var Uint64 = require( '@stdlib/number/uint64/ctor' ); + * + * var a = new Uint64( 1234 ); + * var b = Uint64.of( 0, 1234 ); + * + * var v = isEqual( a, b ); + * // returns true + */ + ( a: Uint64, b: Uint64 ): boolean; + + /** + * Tests whether two 64-bit unsigned integers are equal using word comparison. + * + * @param ah - high 32-bit word of the first 64-bit unsigned integer + * @param al - low 32-bit word of the first 64-bit unsigned integer + * @param bh - high 32-bit word of the second 64-bit unsigned integer + * @param bl - low 32-bit word of the second 64-bit unsigned integer + * @returns boolean indicating if both 64-bit unsigned integers are equal + * + * @example + * var v = isEqual.words( 0, 5, 0, 5 ); + * // returns true + * + * var v = isEqual.words( 0, 5, 0, 10 ); + * // returns false + */ + words( ah: number, al: number, bh: number, bl: number ): boolean; + + /** + * Tests whether two 64-bit unsigned integers stored in integer-valued strided array views are equal. + * + * @param a - first 64-bit unsigned integer strided array view containing interleaved 32-bit unsigned integer high and low order words + * @param strideA - stride length for `a` + * @param offsetA - starting index for `a` + * @param b - second 64-bit unsigned integer strided array view containing interleaved 32-bit unsigned integer high and low order words + * @param strideB - stride length for `b` + * @param offsetB - starting index for `b` + * @returns boolean indicating if both 64-bit unsigned integers are equal + * + * @example + * var Uint32Array = require( '@stdlib/array/uint32' ); + * + * var a = new Uint32Array( [ 0, 5 ] ); + * var b = new Uint32Array( [ 0, 5 ] ); + * + * var v = isEqual.strided( a, 1, 0, b, 1, 0 ); + * // returns true + */ + strided, U extends NumericArray | Collection>( a: T, strideA: number, offsetA: number, b: U, strideB: number, offsetB: number ): boolean; +} /** * Tests whether two 64-bit unsigned integers are equal. @@ -37,8 +101,21 @@ import { Uint64 } from '@stdlib/types/number'; * * var v = isEqual( a, b ); * // returns true +* +* @example +* var v = isEqual.words( 0, 5, 0, 5 ); +* // returns true +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* +* var a = new Uint32Array( [ 0, 5 ] ); +* var b = new Uint32Array( [ 0, 5 ] ); +* +* var v = isEqual.strided( a, 1, 0, b, 1, 0 ); +* // returns true */ -declare function isEqual( a: Uint64, b: Uint64 ): boolean; +declare var isEqual: IsEqual; // EXPORTS // diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/docs/types/test.ts b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/docs/types/test.ts index c8ba85e1d8f6..f8a46414cbc7 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/docs/types/test.ts +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/docs/types/test.ts @@ -38,6 +38,8 @@ import isEqual = require( './index' ); isEqual( 123, b ); // $ExpectError isEqual( true, b ); // $ExpectError isEqual( false, b ); // $ExpectError + isEqual( null, b ); // $ExpectError + isEqual( undefined, b ); // $ExpectError isEqual( [], b ); // $ExpectError isEqual( {}, b ); // $ExpectError isEqual( ( x: number ): number => x, b ); // $ExpectError @@ -51,6 +53,8 @@ import isEqual = require( './index' ); isEqual( a, 123 ); // $ExpectError isEqual( a, true ); // $ExpectError isEqual( a, false ); // $ExpectError + isEqual( a, null ); // $ExpectError + isEqual( a, undefined ); // $ExpectError isEqual( a, [] ); // $ExpectError isEqual( a, {} ); // $ExpectError isEqual( a, ( x: number ): number => x ); // $ExpectError @@ -65,3 +69,177 @@ import isEqual = require( './index' ); isEqual( a ); // $ExpectError isEqual( a, b, {} ); // $ExpectError } + +// Attached to the main export is a `words` method which returns a boolean... +{ + isEqual.words( 1, 2, 3, 4 ); // $ExpectType boolean +} + +// The compiler throws an error if the `words` method is provided a first argument which is not a number... +{ + isEqual.words( true, 2, 3, 4 ); // $ExpectError + isEqual.words( false, 2, 3, 4 ); // $ExpectError + isEqual.words( null, 2, 3, 4 ); // $ExpectError + isEqual.words( undefined, 2, 3, 4 ); // $ExpectError + isEqual.words( '5', 2, 3, 4 ); // $ExpectError + isEqual.words( [], 2, 3, 4 ); // $ExpectError + isEqual.words( {}, 2, 3, 4 ); // $ExpectError + isEqual.words( ( x: number ): number => x, 2, 3, 4 ); // $ExpectError +} + +// The compiler throws an error if the `words` method is provided a second argument which is not a number... +{ + isEqual.words( 1, true, 3, 4 ); // $ExpectError + isEqual.words( 1, false, 3, 4 ); // $ExpectError + isEqual.words( 1, null, 3, 4 ); // $ExpectError + isEqual.words( 1, undefined, 3, 4 ); // $ExpectError + isEqual.words( 1, '5', 3, 4 ); // $ExpectError + isEqual.words( 1, [], 3, 4 ); // $ExpectError + isEqual.words( 1, {}, 3, 4 ); // $ExpectError + isEqual.words( 1, ( x: number ): number => x, 3, 4 ); // $ExpectError +} + +// The compiler throws an error if the `words` method is provided a third argument which is not a number... +{ + isEqual.words( 1, 2, true, 4 ); // $ExpectError + isEqual.words( 1, 2, false, 4 ); // $ExpectError + isEqual.words( 1, 2, null, 4 ); // $ExpectError + isEqual.words( 1, 2, undefined, 4 ); // $ExpectError + isEqual.words( 1, 2, '5', 4 ); // $ExpectError + isEqual.words( 1, 2, [], 4 ); // $ExpectError + isEqual.words( 1, 2, {}, 4 ); // $ExpectError + isEqual.words( 1, 2, ( x: number ): number => x, 4 ); // $ExpectError +} + +// The compiler throws an error if the `words` method is provided a fourth argument which is not a number... +{ + isEqual.words( 1, 2, 3, true ); // $ExpectError + isEqual.words( 1, 2, 3, false ); // $ExpectError + isEqual.words( 1, 2, 3, null ); // $ExpectError + isEqual.words( 1, 2, 3, undefined ); // $ExpectError + isEqual.words( 1, 2, 3, '5' ); // $ExpectError + isEqual.words( 1, 2, 3, [] ); // $ExpectError + isEqual.words( 1, 2, 3, {} ); // $ExpectError + isEqual.words( 1, 2, 3, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `words` method is provided an unsupported number of arguments... +{ + isEqual.words(); // $ExpectError + isEqual.words( 1 ); // $ExpectError + isEqual.words( 1, 2 ); // $ExpectError + isEqual.words( 1, 2, 3 ); // $ExpectError + isEqual.words( 1, 2, 3, 4, 5 ); // $ExpectError +} + +// Attached to the main export is a `strided` method which returns a boolean... +{ + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + + isEqual.strided( a, 1, 0, b, 1, 0 ); // $ExpectType boolean + isEqual.strided( new Float64Array( 2 ), 1, 0, new Float64Array( 2 ), 1, 0 ); // $ExpectType boolean + isEqual.strided( [ 0, 0 ], 1, 0, [ 0, 0 ], 1, 0 ); // $ExpectType boolean +} + +// The compiler throws an error if the `strided` method is provided a first argument which is not a collection... +{ + const b = new Uint32Array( 2 ); + + isEqual.strided( true, 1, 0, b, 1, 0 ); // $ExpectError + isEqual.strided( false, 1, 0, b, 1, 0 ); // $ExpectError + isEqual.strided( null, 1, 0, b, 1, 0 ); // $ExpectError + isEqual.strided( undefined, 1, 0, b, 1, 0 ); // $ExpectError + isEqual.strided( '5', 1, 0, b, 1, 0 ); // $ExpectError + isEqual.strided( [ '5' ], 1, 0, b, 1, 0 ); // $ExpectError + isEqual.strided( {}, 1, 0, b, 1, 0 ); // $ExpectError + isEqual.strided( ( x: number ): number => x, 1, 0, b, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a second argument which is not a number... +{ + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + + isEqual.strided( a, true, 0, b, 1, 0 ); // $ExpectError + isEqual.strided( a, false, 0, b, 1, 0 ); // $ExpectError + isEqual.strided( a, null, 0, b, 1, 0 ); // $ExpectError + isEqual.strided( a, undefined, 0, b, 1, 0 ); // $ExpectError + isEqual.strided( a, '5', 0, b, 1, 0 ); // $ExpectError + isEqual.strided( a, [], 0, b, 1, 0 ); // $ExpectError + isEqual.strided( a, {}, 0, b, 1, 0 ); // $ExpectError + isEqual.strided( a, ( x: number ): number => x, 0, b, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a third argument which is not a number... +{ + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + + isEqual.strided( a, 1, true, b, 1, 0 ); // $ExpectError + isEqual.strided( a, 1, false, b, 1, 0 ); // $ExpectError + isEqual.strided( a, 1, null, b, 1, 0 ); // $ExpectError + isEqual.strided( a, 1, undefined, b, 1, 0 ); // $ExpectError + isEqual.strided( a, 1, '5', b, 1, 0 ); // $ExpectError + isEqual.strided( a, 1, [], b, 1, 0 ); // $ExpectError + isEqual.strided( a, 1, {}, b, 1, 0 ); // $ExpectError + isEqual.strided( a, 1, ( x: number ): number => x, b, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a fourth argument which is not a collection... +{ + const a = new Uint32Array( 2 ); + + isEqual.strided( a, 1, 0, true, 1, 0 ); // $ExpectError + isEqual.strided( a, 1, 0, false, 1, 0 ); // $ExpectError + isEqual.strided( a, 1, 0, null, 1, 0 ); // $ExpectError + isEqual.strided( a, 1, 0, undefined, 1, 0 ); // $ExpectError + isEqual.strided( a, 1, 0, '5', 1, 0 ); // $ExpectError + isEqual.strided( a, 1, 0, [ '5' ], 1, 0 ); // $ExpectError + isEqual.strided( a, 1, 0, {}, 1, 0 ); // $ExpectError + isEqual.strided( a, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a fifth argument which is not a number... +{ + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + + isEqual.strided( a, 1, 0, b, true, 0 ); // $ExpectError + isEqual.strided( a, 1, 0, b, false, 0 ); // $ExpectError + isEqual.strided( a, 1, 0, b, null, 0 ); // $ExpectError + isEqual.strided( a, 1, 0, b, undefined, 0 ); // $ExpectError + isEqual.strided( a, 1, 0, b, '5', 0 ); // $ExpectError + isEqual.strided( a, 1, 0, b, [], 0 ); // $ExpectError + isEqual.strided( a, 1, 0, b, {}, 0 ); // $ExpectError + isEqual.strided( a, 1, 0, b, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a sixth argument which is not a number... +{ + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + + isEqual.strided( a, 1, 0, b, 1, true ); // $ExpectError + isEqual.strided( a, 1, 0, b, 1, false ); // $ExpectError + isEqual.strided( a, 1, 0, b, 1, null ); // $ExpectError + isEqual.strided( a, 1, 0, b, 1, undefined ); // $ExpectError + isEqual.strided( a, 1, 0, b, 1, '5' ); // $ExpectError + isEqual.strided( a, 1, 0, b, 1, [] ); // $ExpectError + isEqual.strided( a, 1, 0, b, 1, {} ); // $ExpectError + isEqual.strided( a, 1, 0, b, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided an unsupported number of arguments... +{ + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + + isEqual.strided(); // $ExpectError + isEqual.strided( a ); // $ExpectError + isEqual.strided( a, 1 ); // $ExpectError + isEqual.strided( a, 1, 0 ); // $ExpectError + isEqual.strided( a, 1, 0, b ); // $ExpectError + isEqual.strided( a, 1, 0, b, 1 ); // $ExpectError + isEqual.strided( a, 1, 0, b, 1, 0, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/index.js b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/index.js index c06a0f392ce3..c1a323738584 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/index.js +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/index.js @@ -36,9 +36,20 @@ // MODULES // +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); var main = require( './main.js' ); +var words = require( './words.js' ); +var strided = require( './strided.js' ); + + +// MAIN // + +setReadOnly( main, 'words', words ); +setReadOnly( main, 'strided', strided ); // EXPORTS // module.exports = main; + +// exports: { "words": "main.words", "strided": "main.strided" } diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/main.js b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/main.js index b90944b5cc53..87141e85eb54 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/main.js +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/main.js @@ -21,6 +21,7 @@ // MODULES // var toWords = require( '@stdlib/number/uint64/base/to-words' ).assign; +var words = require( './words.js' ); // VARIABLES // @@ -49,10 +50,8 @@ var WORKSPACE = [ 0, 0, 0, 0 ]; function isEqual( a, b ) { toWords( a, WORKSPACE, 1, 0 ); toWords( b, WORKSPACE, 1, 2 ); - return ( - WORKSPACE[ 0 ] === WORKSPACE[ 2 ] && // high words - WORKSPACE[ 1 ] === WORKSPACE[ 3 ] // low words - ); + + return words( WORKSPACE[ 0 ], WORKSPACE[ 1 ], WORKSPACE[ 2 ], WORKSPACE[ 3 ] ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/strided.js b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/strided.js new file mode 100644 index 000000000000..6474d8bada5a --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/strided.js @@ -0,0 +1,55 @@ +/** +* @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 words = require( './words.js' ); + + +// MAIN // + +/** +* Tests whether two 64-bit unsigned integers stored in integer-valued strided array views are equal. +* +* @param {Collection} a - first 64-bit unsigned integer strided array view containing interleaved 32-bit unsigned integer high and low order words +* @param {integer} strideA - stride length for `a` +* @param {NonNegativeInteger} offsetA - starting index for `a` +* @param {Collection} b - second 64-bit unsigned integer strided array view containing interleaved 32-bit unsigned integer high and low order words +* @param {integer} strideB - stride length for `b` +* @param {NonNegativeInteger} offsetB - starting index for `b` +* @returns {boolean} boolean indicating if both 64-bit unsigned integers are equal +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* +* var a = new Uint32Array( [ 0, 5 ] ); +* var b = new Uint32Array( [ 0, 5 ] ); +* +* var bool = strided( a, 1, 0, b, 1, 0 ); +* // returns true +*/ +function strided( a, strideA, offsetA, b, strideB, offsetB ) { + return words( a[ offsetA ], a[ offsetA+strideA ], b[ offsetB ], b[ offsetB+strideB ] ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = strided; diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/words.js b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/words.js new file mode 100644 index 000000000000..2a8a29cb6b61 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/words.js @@ -0,0 +1,47 @@ +/** +* @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'; + +// MAIN // + +/** +* Tests whether two 64-bit unsigned integers are equal using word comparison. +* +* @param {uinteger} ah - high 32-bit word of the first 64-bit unsigned integer +* @param {uinteger} al - low 32-bit word of the first 64-bit unsigned integer +* @param {uinteger} bh - high 32-bit word of the second 64-bit unsigned integer +* @param {uinteger} bl - low 32-bit word of the second 64-bit unsigned integer +* @returns {boolean} boolean indicating if both 64-bit unsigned integers are equal +* +* @example +* var bool = words( 0, 5, 0, 5 ); +* // returns true +* +* bool = words( 0, 5, 0, 10 ); +* // returns false +*/ +function words( ah, al, bh, bl ) { + return ( ( ( ah ^ bh ) | ( al ^ bl ) ) === 0 ); +} + + +// EXPORTS // + +module.exports = words; +// module.exports = require( './words_branched.js' ); diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/words_branched.js b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/words_branched.js new file mode 100644 index 000000000000..396c9b8cacd5 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/lib/words_branched.js @@ -0,0 +1,51 @@ +/** +* @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'; + +// MAIN // + +/** +* Tests whether two 64-bit unsigned integers are equal using word comparison. +* +* @param {uinteger} ah - high 32-bit word of the first 64-bit unsigned integer +* @param {uinteger} al - low 32-bit word of the first 64-bit unsigned integer +* @param {uinteger} bh - high 32-bit word of the second 64-bit unsigned integer +* @param {uinteger} bl - low 32-bit word of the second 64-bit unsigned integer +* @returns {boolean} boolean indicating if both 64-bit unsigned integers are equal +* +* @example +* var bool = words( 0, 5, 0, 5 ); +* // returns true +* +* bool = words( 0, 5, 0, 10 ); +* // returns false +*/ +function words( ah, al, bh, bl ) { + ah >>>= 0; + al >>>= 0; + bh >>>= 0; + bl >>>= 0; + + return ( ah === bh && al === bl ); +} + + +// EXPORTS // + +module.exports = words; diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/test/test.js b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/test/test.js index ed6dfb0febd7..6c4232570e93 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/test/test.js +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/test/test.js @@ -21,17 +21,10 @@ // MODULES // var tape = require( 'tape' ); -var hasBigIntSupport = require( '@stdlib/assert/has-bigint-support' ); -var BigInt = require( '@stdlib/bigint/ctor' ); -var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var isMethod = require( '@stdlib/assert/is-method' ); var isEqual = require( './../lib' ); -// VARIABLES // - -var HAS_BIGINT = hasBigIntSupport(); - - // TESTS // tape( 'main export is a function', function test( t ) { @@ -40,34 +33,12 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function tests whether two 64-bit unsigned integers are equal', function test( t ) { - var a; - var b; - - a = new Uint64( 1234 ); - t.strictEqual( isEqual( a, a ), true, 'returns expected value' ); - - a = new Uint64( 1234 ); - b = Uint64.of( 0, 1234 ); - t.strictEqual( isEqual( a, b ), true, 'returns expected value' ); - - a = Uint64.from( [ 0, 1234 ] ); - b = Uint64.of( 0, 1234 ); - t.strictEqual( isEqual( a, b ), true, 'returns expected value' ); - - a = new Uint64( 1234 ); - b = new Uint64( 5678 ); - t.strictEqual( isEqual( a, b ), false, 'returns expected value' ); - - if ( HAS_BIGINT ) { - a = new Uint64( 1234 ); - b = new Uint64( BigInt( 1234 ) ); - t.strictEqual( isEqual( a, b ), true, 'returns expected value' ); - - a = new Uint64( 1234 ); - b = new Uint64( BigInt( 5678 ) ); - t.strictEqual( isEqual( a, b ), false, 'returns expected value' ); - } +tape( 'attached to the main export is a `words` method', function test( t ) { + t.strictEqual( isMethod( isEqual, 'words' ), true, 'returns expected value' ); + t.end(); +}); +tape( 'attached to the main export is a `strided` method', function test( t ) { + t.strictEqual( isMethod( isEqual, 'strided' ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/test/test.main.js b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/test/test.main.js new file mode 100644 index 000000000000..ed6dfb0febd7 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/test/test.main.js @@ -0,0 +1,73 @@ +/** +* @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 tape = require( 'tape' ); +var hasBigIntSupport = require( '@stdlib/assert/has-bigint-support' ); +var BigInt = require( '@stdlib/bigint/ctor' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var isEqual = require( './../lib' ); + + +// VARIABLES // + +var HAS_BIGINT = hasBigIntSupport(); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isEqual, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function tests whether two 64-bit unsigned integers are equal', function test( t ) { + var a; + var b; + + a = new Uint64( 1234 ); + t.strictEqual( isEqual( a, a ), true, 'returns expected value' ); + + a = new Uint64( 1234 ); + b = Uint64.of( 0, 1234 ); + t.strictEqual( isEqual( a, b ), true, 'returns expected value' ); + + a = Uint64.from( [ 0, 1234 ] ); + b = Uint64.of( 0, 1234 ); + t.strictEqual( isEqual( a, b ), true, 'returns expected value' ); + + a = new Uint64( 1234 ); + b = new Uint64( 5678 ); + t.strictEqual( isEqual( a, b ), false, 'returns expected value' ); + + if ( HAS_BIGINT ) { + a = new Uint64( 1234 ); + b = new Uint64( BigInt( 1234 ) ); + t.strictEqual( isEqual( a, b ), true, 'returns expected value' ); + + a = new Uint64( 1234 ); + b = new Uint64( BigInt( 5678 ) ); + t.strictEqual( isEqual( a, b ), false, 'returns expected value' ); + } + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/test/test.strided.js b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/test/test.strided.js new file mode 100644 index 000000000000..a12ed3079be2 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/test/test.strided.js @@ -0,0 +1,86 @@ +/** +* @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 tape = require( 'tape' ); +var Uint32Array = require( '@stdlib/array/uint32' ); +var isEqual = require( './../lib/strided.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isEqual, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function tests whether two 64-bit unsigned integers stored in strided array views are equal', function test( t ) { + var a; + var b; + var v; + + // Trivial stride and offset: + a = new Uint32Array( [ 1, 2 ] ); + b = new Uint32Array( [ 1, 2 ] ); + v = isEqual( a, 1, 0, b, 1, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + b = new Uint32Array( [ 1, 3 ] ); + v = isEqual( a, 1, 0, b, 1, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + b = new Uint32Array( [ 2, 2 ] ); + v = isEqual( a, 1, 0, b, 1, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + // Positive stride: + a = new Uint32Array( [ 1, 0, 0, 2, 0, 0 ] ); + b = new Uint32Array( [ 1, 0, 2, 0 ] ); + v = isEqual( a, 3, 0, b, 2, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + b = new Uint32Array( [ 1, 0, 3, 0 ] ); + v = isEqual( a, 3, 0, b, 2, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + // Positive stride and non-zero offset: + a = new Uint32Array( [ 0, 0, 1, 0, 0, 2 ] ); + b = new Uint32Array( [ 0, 1, 0, 2 ] ); + v = isEqual( a, 3, 2, b, 2, 1 ); + t.strictEqual( v, true, 'returns expected value' ); + + b = new Uint32Array( [ 0, 0, 0, 2 ] ); + v = isEqual( a, 3, 2, b, 2, 1 ); + t.strictEqual( v, false, 'returns expected value' ); + + // Negative stride and non-zero offset: + a = new Uint32Array( [ 0, 0, 2, 0, 0, 1 ] ); + b = new Uint32Array( [ 0, 2, 0, 1 ] ); + v = isEqual( a, -3, 5, b, -2, 3 ); + t.strictEqual( v, true, 'returns expected value' ); + + b = new Uint32Array( [ 0, 1, 0, 1 ] ); + v = isEqual( a, -3, 5, b, -2, 3 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/test/test.words.js b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/test/test.words.js new file mode 100644 index 000000000000..71bcadf41f28 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/test/test.words.js @@ -0,0 +1,58 @@ +/** +* @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 tape = require( 'tape' ); +var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); +var isEqual = require( './../lib/words.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isEqual, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function tests whether two 64-bit unsigned integers are equal', function test( t ) { + var v; + + v = isEqual( 1, 2, 1, 2 ); + t.strictEqual( v, true, 'returns expected value' ); + + v = isEqual( 1, 2, 1, 3 ); + t.strictEqual( v, false, 'returns expected value' ); + + v = isEqual( 1, 2, 2, 2 ); + t.strictEqual( v, false, 'returns expected value' ); + + v = isEqual( UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX ); + t.strictEqual( v, true, 'returns expected value' ); + + v = isEqual( UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX - 1 ); + t.strictEqual( v, false, 'returns expected value' ); + + v = isEqual( UINT32_MAX, UINT32_MAX, UINT32_MAX - 1, UINT32_MAX ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +});