]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/doc/gfortran/intrinsic-procedures/parity.rst
sphinx: copy files from texi2rst-generated repository
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / parity.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. index:: PARITY, Parity, Reduction, XOR, XOR reduction
7
8 .. _parity:
9
10 PARITY --- Reduction with exclusive OR
11 **************************************
12
13 .. function:: PARITY(MASK, DIM)
14
15 Calculates the parity, i.e. the reduction using ``.XOR.``,
16 of :samp:`{MASK}` along dimension :samp:`{DIM}`.
17
18 :param MASK:
19 Shall be an array of type ``LOGICAL``
20
21 :param DIM:
22 (Optional) shall be a scalar of type
23 ``INTEGER`` with a value in the range from 1 to n, where n
24 equals the rank of :samp:`{MASK}`.
25
26 :return:
27 The result is of the same type as :samp:`{MASK}`.
28
29 Standard:
30 Fortran 2008 and later
31
32 Class:
33 Transformational function
34
35 Syntax:
36 .. code-block:: fortran
37
38 RESULT = PARITY(MASK[, DIM])
39
40 Example:
41 .. code-block:: fortran
42
43 PROGRAM test_sum
44 LOGICAL :: x(2) = [ .true., .false. ]
45 print *, PARITY(x) ! prints "T" (true).
46 END PROGRAM