]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/fortran/doc/gfortran/intrinsic-procedures/iparity.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / iparity.rst
CommitLineData
c63539ff
ML
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:: IPARITY, array, parity, array, XOR, bits, XOR of array elements
7
8.. _iparity:
9
10IPARITY --- Bitwise XOR of array elements
11*****************************************
12
13.. function:: IPARITY(ARRAY, DIM, MASK)
14
15 Reduces with bitwise XOR (exclusive or) the elements of :samp:`{ARRAY}` along
16 dimension :samp:`{DIM}` if the corresponding element in :samp:`{MASK}` is ``TRUE``.
17
18 :param ARRAY:
19 Shall be an array of type ``INTEGER``
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:`{ARRAY}`.
25
26 :param MASK:
27 (Optional) shall be of type ``LOGICAL``
28 and either be a scalar or an array of the same shape as :samp:`{ARRAY}`.
29
30 :return:
31 The result is of the same type as :samp:`{ARRAY}`.
32
33 Standard:
34 Fortran 2008 and later
35
36 Class:
37 Transformational function
38
39 Syntax:
40 .. code-block:: fortran
41
42 RESULT = IPARITY(ARRAY[, MASK])
43 RESULT = IPARITY(ARRAY, DIM[, MASK])
44
45 Example:
46 .. code-block:: fortran
47
48 PROGRAM test_iparity
49 INTEGER(1) :: a(2)
50
51 a(1) = int(b'00100100', 1)
52 a(2) = int(b'01101010', 1)
53
54 ! prints 01001110
55 PRINT '(b8.8)', IPARITY(a)
56 END PROGRAM
57
58 See also:
59 :ref:`IANY`,
60 :ref:`IALL`,
61 :ref:`IEOR`,
3ed1b4ce 62 :ref:`PARITY`