@stdlib/array-base-assert-has-almost-equal-values
v0.1.1
Published
Test if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place).
Readme
hasAlmostEqualValues
Test if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place).
Installation
npm install @stdlib/array-base-assert-has-almost-equal-valuesUsage
var hasAlmostEqualValues = require( '@stdlib/array-base-assert-has-almost-equal-values' );hasAlmostEqualValues( x, y, maxULP )
Tests if two arrays have respective elements which are approximately equal 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 = hasAlmostEqualValues( x, y, 1 );
// returns trueNotes
- If provided arrays of unequal length, the function returns
false. - The function does not skip
undefinedelements and is thus not optimized for sparse arrays.
Examples
var uniform = require( '@stdlib/random-array-uniform' );
var Complex128Array = require( '@stdlib/array-complex128' );
var hasAlmostEqualValues = require( '@stdlib/array-base-assert-has-almost-equal-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 = hasAlmostEqualValues( x, y, 1 );
// returns trueNotice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
