Calculates the parity (i.e. the reduction using .xor.
) of mask
along dimension dim
.
Fortran 2008 and later
Transformational function?
result = parity(mask[, dim])
mask
- 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 array
.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: .true.
if an odd number of elements are .true.
and .false.
otherwise. If dim
is present, an array of rank , where equals the rank of mask
, and a shape similar to that of mask
with dimension dim
dropped is returned.
program test_parity
logical :: x(2) = [ .true., .false. ]
print *, parity(x) ! T
end program