fabien van mook

all packages "fvm-*"

package "fvm-miscellaneous"

function file "isnear.m"

Function tf = isnear(a,b,atol,rtol)
         tf = isnear(a,b,atol,rtol,m)

returns true when a and b are approximate within a given
absolute tolerance atol and/or relative tolerance rtol.

Input arguments a and b are numerical matrices. Each
element in a is compared in pair-wise manner with the
corresponding element in b. The rules of broadcasting are
applied in this process. Output argument tf is a matrix of
booleans.

If input argument atol or rtol is empty or has a
non-finite value, atol or rtol is set to zero and thus no
absolute or relative tolerance, respectively, is taken
into account. Input arguments atol and rtol may also
contain the string 'tight' to indicate a tolerance of
1e-6, when a and/or b are of type 'single', or a tolerance
of 1e-12, otherwise (i.e. a and b are assumingly of type
'double').

At default, atol is 'tight', and rtol is zero.

If input argument m is not empty and has a finite value,
the values in a and b are compared by intermediation of
modulo m. Then, rtol is internally set to zero.

At default, m is set to empty [].

In short, the function applies:
  tf = ( abs(a-b) <= max( abs(atol), abs(rtol)*max(abs(a),abs(b)) ) )
if m is empty; and:
  tf = ( moddiff(a,b,m) <= abs(atol) )
otherwise.

The function internally calls the following non-standard
m-file:
-- moddiff.m


(c) 2026 fabien van mook

2026.08.20 release of this file within package "fvm-miscellaneous" under GNU GPLv3+