PARITY

8.190 PARITY — Reduction with exclusive OR

Description:
Calculates the parity, i.e. the reduction using .XOR., of MASK along dimension DIM.
Standard:
Fortran 2008 and later
Class:
Transformational function
Syntax:
RESULT = PARITY(MASK[, DIM])
Arguments:
LOGICAL Shall be an array of type LOGICAL
DIM (Optional) shall be a scalar of type INTEGER with a value in the range from 1 to n, where n equals the rank of MASK.
Return value:
The result is of the same type as MASK.

If DIM is absent, a scalar with the parity of all elements in MASK is returned, i.e. true if an odd number of elements is .true. and false otherwise. If DIM is present, an array of rank n-1, where n equals the rank of ARRAY, and a shape similar to that of MASK with dimension DIM dropped is returned.

Example:
PROGRAM test_sum
  LOGICAL :: x(2) = [ .true., .false. ]
  print *, PARITY(x) ! prints "T" (true).
END PROGRAM

© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-4.9.3/gfortran/PARITY.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部