Manual Reference Pages  - isequal (3m_sets)

NAME

isequal(3f) - [M_sets] Report if vector A is equal to vector B

CONTENTS

Synopsis
Description
Options
Returns
Examples
Authors
License

SYNOPSIS

isequal(A,B,TOLERANCE)

     character(len=:)intent(in) :: A,B
       or
     integer|real|complex(in) :: A,B
     real,optional            :: TOLERANCE

DESCRIPTION

Report if A is equal to B. Equality is defined as the same element values in the same order.

A 1 (true) is returned when the elements of A have a one-to-one correspondence to the elements of B with the same values in the
same order.
  0 (false) is returned otherwise.

OPTIONS

A input array to compare against
B input array to compare to A
TOLERANCE
  for numeric values consider the corresponding elements of A and B equal if they are equal within the specified tolerance.
A,B and TOLERANCE are of the same type and kind.

RETURNS

1 if input array A is to array B, 0 otherwise

EXAMPLES

sample program:

   program demo_isequal
   use M_sets, only: isequal
   character(len=*),parameter :: g=’(*(g0,1x))’
   integer,allocatable        :: A(:)
   integer,allocatable        :: B(:)

write(*,g) ’isequal’,’Find if A is equal to B. ’ A = [10, -10, 0, 1, 2, 3, 3, 2, 1,-10] B = [10, -10, 0, 1, 2, 3, 3, 2, 1, 10] write(*,g) ’A=’, A write(*,g) ’B=’, B write(*,g) isequal(A,B) write(*,g) ’isequal’,’Find if A is equal to A. ’ write(*,g) isequal(A,A)

end program demo_isequal

Results:

 > isequal Find the isequal elements of vector A.
 > A= 10 -10 0 1 2 3 3 2 1 -10
 > 0
 > A= -10 10 100 201
 > 1

AUTHORS

John S. Urban, 2023-07-20

LICENSE

CC0-1.0