Clicky
Showing changes from revision #2 to #3:
(追記) Added (追記ここまで) | (削除) Removed (削除ここまで) | (削除) Chan (削除ここまで)(追記) ged (追記ここまで)
count(mask [, dim [, kind]])
counts the number of .true.
elements of mask
along the dimension of dim
. If dim
is omitted(削除) it (削除ここまで)(追記) then (追記ここまで)(追記) the (追記ここまで)(追記) number (追記ここまで)(追記) of (追記ここまで)(追記) ‘.true.’ (追記ここまで) is(削除) taken (削除ここまで)(追記) counted (追記ここまで)(削除) to (削除ここまで)(追記) over (追記ここまで)(削除) be (削除ここまで)(追記) the (追記ここまで)(追記) entire (追記ここまで)(追記) array. (追記ここまで)(削除) 1
(削除ここまで)(削除) . (削除ここまで)dim
is a scaler of type integer
in the range of 1 \\leq \\text{DIM} \\leq n)
where is the rank of mask
.
Fortran 95 and later, with kind
argument Fortran 2003 and later
Transformational function
result = count(mask [, dim [, kind]])
mask
- The type shall be logical
.dim
- (Optional) The type shall be integer
.kind
- (Optional) An integer
initialization expression indicating the kind parameter of the result.The return value is of type integer
and of kind kind
. If kind
is absent, the return value is of default integer kind. The result has a rank equal to that of mask
.
program test_count
integer, dimension(2,3) :: a, b
logical, dimension(2,3) :: mask
a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
print '(3i3)', a(1,:)
print '(3i3)', a(2,:)
print *
print '(3i3)', b(1,:)
print '(3i3)', b(2,:)
print *
mask = a.ne.b
print '(3l3)', mask(1,:)
print '(3l3)', mask(2,:)
print *
print '(3i3)', count(mask)
print *
print '(3i3)', count(mask, 1)
print *
print '(3i3)', count(mask, 2)
end program test_count