Test if two arrays have respective elements which are approximately the same value within a specified number of ULPs (units in the last place).
var hasAlmostSameValues = require( '@stdlib/array/base/assert/has-almost-same-values' );Tests if two arrays have respective elements which are approximately the same value within a specified number of ULPs (units in the last place).
var x = [ 0, 0, 1, 0 ];
var y = [ 0, 0, 1, 0 ];
var bool = hasAlmostSameValues( x, y, 1 );
// returns true- In contrast to the strict equality operator
===, the function distinguishes between+0and-0and treatsNaNsas the same value. - If provided arrays of unequal length, the function returns
false. - The function does not skip
undefinedelements and is thus not optimized for sparse arrays.
var uniform = require( '@stdlib/random/array/uniform' );
var Complex128Array = require( '@stdlib/array/complex128' );
var hasAlmostSameValues = require( '@stdlib/array/base/assert/has-almost-same-values' );
var buf = uniform( 10, 0, 10 );
// returns <Float64Array>
var x = new Complex128Array( buf );
// returns <Complex128Array>
var y = new Complex128Array( buf );
// returns <Complex128Array>
var out = hasAlmostSameValues( x, y, 1 );
// returns true