Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

isAlmostSameValueArray

Test if two arguments are both generic arrays and contain respective elements which are approximately the same value within a specified number of ULPs (units in the last place).

Usage

var isAlmostSameValueArray = require( '@stdlib/assert/is-almost-same-value-array' );

isAlmostSameValueArray( v1, v2, maxULP )

Tests if two arguments are both generic arrays and contain respective elements which are approximately the same value within a specified number of ULPs (units in the last place).

var EPS = require( '@stdlib/constants/float64/eps' );

var x = [ 1.0, 2.0 ];
var y = [ 1.0+EPS, 2.0 ];

var bool = isAlmostSameValueArray( x, y, 0 );
// returns false

bool = isAlmostSameValueArray( x, y, 1 );
// returns true

bool = isAlmostSameValueArray( x, [ -1.0, 2.0 ], 1 );
// returns false

Examples

var isAlmostSameValueArray = require( '@stdlib/assert/is-almost-same-value-array' );

var x = [ 1.0, 2.0, 3.0 ];
var y = [ 1.0, 2.0, 3.0 ];
var out = isAlmostSameValueArray( x, y, 0 );
// returns true

x = [ -0.0, 0.0, -0.0 ];
y = [ 0.0, -0.0, 0.0 ];
out = isAlmostSameValueArray( x, y, 0 );
// returns false

x = [ NaN, NaN, NaN ];
y = [ NaN, NaN, NaN ];
out = isAlmostSameValueArray( x, y, 0 );
// returns true