eqv

Date:

10-12-2011

NAME

EQV, NEQV, XOR - Compute logical equivalence or difference

SYNOPSIS

EQV ([I=]i,[J=]j)
NEQV ([I=]i,[J=]j)
XOR ([I=]i,[J=]j)

IMPLEMENTATION

Cray Linux Environment (CLE)

STANDARDS

Fortran extensions

DESCRIPTION

EQV computes a logical equivalence.

NEQV and XOR are two names for the same routine. These functions compute a logical difference.

These functions accept the following arguments:

i

Must be of type Boolean, integer, real, logical, or Cray pointer.

j

Must be of type Boolean, integer, real, logical, or Cray pointer. For EQV, j need not be the same type as i, but j must be the same size as i.

These are elemental functions. The names of these intrinsics cannot be passed as arguments.

NOTES

These routines are outmoded. Refer to the Cray Fortran Reference Manual for information about outmoded features and their preferred standard alternatives.

CAUTIONS

Unexpected results can occur when Boolean functions are declared external and then used with logical arguments. The external Boolean functions always treat their arguments as type Boolean and return a Boolean result.

RETURN VALUES

EQV, when given two arguments of type Boolean, real, integer, or pointer, computes a bit-wise logical equivalence and returns a Boolean. When both i and j are of type logical, the result is of type logical. The following tables show both the logical equivalence and bit-wise logical equivalence:

--------------------------------------------------------
Logical       Logical       (Logical Variable 1) EQV
Variable 1    Variable 2    (Logical Variable 2)
--------------------------------------------------------
T             T             T
T             F             F
F             T             F
F             F             T
--------------------------------------------------------

--------------------------------------------------------
Bit of        Bit of        (Bit of Variable 1) EQV
Variable 1    Variable 2    (Bit of Variable 2)
--------------------------------------------------------
1             1             1
1             0             0
0             1             0
0             0             1
--------------------------------------------------------

NEQV and XOR, when given two arguments of type logical, compute a logical difference and return a logical result. When given two arguments of type Boolean, integer, real, or pointer, NEQV and XOR compute a bit-wise logical difference and return a Boolean result. The following tables show both the logical difference and bit-wise logical difference. NEQV is shown in the tables, but XOR produces identical results.

--------------------------------------------------------
Logical       Logical       (Logical Variable 1) NEQV
Variable 1    Variable 2    (Logical Variable 2)
--------------------------------------------------------
T             T             F
T             F             T
F             T             T
F             F             F
--------------------------------------------------------

--------------------------------------------------------
Bit of        Bit of        (Bit of Variable 1) NEQV
Variable 1    Variable 2    (Bit of Variable 2)
--------------------------------------------------------
1             1             0
1             0             1
0             1             1
0             0             0
--------------------------------------------------------

EXAMPLES

Example 1. The following section of Fortran code shows the EQV function used with two arguments of type logical:

LOGICAL L1, L2, L3
...
L3 = EQV(L1,L2)

Example 2. The following section of Fortran code shows the EQV function used with two arguments of type integer. The bit patterns of the arguments and result are also given. For clarity, only the rightmost 8 bits are shown.

INTEGER I1, I2, I3
I1 = 12
I2 = 10
...
I3 = EQV(I1,I2)
       -------------------------------     -------------------------------
      | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |   | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
       -------------------------------     -------------------------------
                    I1                              I2
                     -------------------------------
                    | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 1 |
                     -------------------------------
                                     I3

Example 3. The following section of Fortran code shows the NEQV function used with two arguments of type logical. XOR is used in the same manner and produces the same results.

LOGICAL L1, L2, L3
...
L3 = NEQV(L1,L2)

Example 4. The following section of Fortran code shows the NEQV function used with two arguments of type integer. XOR is used in the same manner and produces the same results. The bit patterns of the arguments and results are also given. For clarity, only the rightmost 8 bits are shown.

INTEGER I1, I2, I3
I1 = 12
I2 = 10
...
I3 = NEQV(I1,I2)
    -------------------------------     -------------------------------
   | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |   | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
    -------------------------------     -------------------------------
                     I1                               I2
                  -------------------------------
                 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 |
                  -------------------------------
                                    I3