Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

PARITY

Transformational Intrinsic Function (Generic): Reduces an array by using an exclusive OR (.NEQV.) operation.

result = PARITY (mask)

result = PARITY (mask, dim)

mask

(Input) Must be an array of type logical.

dim

(Input) Must be a scalar integer with a value in the range 1 <= dim <= n, where n is the rank of mask.

Results

The result has the same type and kind parameters as mask. It is scalar if dim is not specified; otherwise, the result has rank n - 1 and shape [d1, d2, ..., ddim-1, ddim+1 , ..., dn] where [d1, d2,..., dn] is the shape of mask.

The result of PARITY(mask) has the value .TRUE. if an odd number of the elements of mask are true; otherwise, .FALSE..

If mask has rank one, PARITY(mask, dim) is equal to PARITY(mask). Otherwise, the value of element (s1, s2, ..., sdim-1, sdim+1 , ..., sn) of PARITY(mask, dim) is equal to PARITY (mask (s1, s2, ..., sdim-1 , :, sdim+1 , ..., sn)).

Example

If A is the array

  [ T  F  T ]
  [ T  T  F ]

and T has the value .TRUE. and F has the value .FALSE., then

PARITY (A, DIM=1) has the value [F, T, T] and PARITY (A, DIM=2) has the value [F, F].