Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

</section>

<!-- /.usage -->
Expand All @@ -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 );
Expand All @@ -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
```

</section>
Expand Down
Original file line number Diff line number Diff line change
@@ -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' );

Check warning on line 25 in lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

only the `of` property of the required module is used; require the property directly
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();
});
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
});
Original file line number Diff line number Diff line change
@@ -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' );

Check warning on line 29 in lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/benchmark/benchmark.words.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

only the `words` property of the required module is used; require the property directly


// 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();
});
Loading
Loading