Clicky
Showing changes from revision #3 to #4:
(追記) Added (追記ここまで) | (削除) Removed (削除ここまで) | (削除) Chan (削除ここまで)(追記) ged (追記ここまで)
(削除) (追記) Counts the number of (追記ここまで)count(mask [, dim [, kind]])
(削除ここまで)(削除) counts the number of (削除ここまで).true.
elements(削除) of (削除ここまで)(追記) in (追記ここまで)(追記) a (追記ここまで)(追記) logical (追記ここまで)mask
(削除) (削除ここまで)(追記) , (追記ここまで)(削除) along (削除ここまで)(追記) or, (追記ここまで)(追記) if (追記ここまで) the(削除) dimension (削除ここまで)(削除) of (削除ここまで)dim
(削除) . (削除ここまで)(追記) (追記ここまで)(削除) If (削除ここまで)(追記) argument (追記ここまで)(追記) is (追記ここまで)(追記) supplied, (追記ここまで)(追記) counts (追記ここまで)(追記) the (追記ここまで)(追記) number (追記ここまで)(追記) of (追記ここまで)(追記) elements (追記ここまで)(追記) along (追記ここまで)(追記) each (追記ここまで)(追記) row (追記ここまで)(追記) of (追記ここまで)(追記) the (追記ここまで)(追記) array (追記ここまで)(追記) in (追記ここまで)(追記) the (追記ここまで)dim
(削除) is (削除ここまで)(追記) direction. (追記ここまで)(削除) omitted (削除ここまで)(追記) If (追記ここまで)(削除) then (削除ここまで) the(削除) number (削除ここまで)(追記) array (追記ここまで)(追記) has (追記ここまで)(追記) zero (追記ここまで)(追記) size, (追記ここまで)(追記) or (追記ここまで)(追記) all (追記ここまで) of(削除) ‘.true.’ (削除ここまで)(削除) is (削除ここまで)(削除) counted (削除ここまで)(削除) over (削除ここまで) the(削除) entire (削除ここまで)(追記) elements (追記ここまで)(削除) array. (削除ここまで)(追記) of (追記ここまで)(削除) dim
(削除ここまで)(削除) is a scaler of type (削除ここまで)(削除) integer
(削除ここまで)(削除) in the range of (削除ここまで)(削除) 1 \\leq \\text{DIM} \\leq n)
(削除ここまで)(削除) where (削除ここまで)(削除) (削除ここまで)(削除) is the rank of (削除ここまで)mask
(追記) are (追記ここまで)(追記) .false.
(追記ここまで)(追記) , then the result is (追記ここまで)(追記) 0
(追記ここまで).
Fortran 95 and later, with kind
argument Fortran 2003 and later
Transformational function
result = count(mask [, dim [, kind]])
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 (削除ここまで)(追記) If (追記ここまで)(削除) result (削除ここまで)(削除) has (削除ここまで)(削除) a (削除ここまで)(削除) rank (削除ここまで)(削除) equal (削除ここまで)(削除) to (削除ここまで)(削除) that (削除ここまで)(削除) of (削除ここまで)(削除) mask (削除ここまで)(追記) dim (追記ここまで)(削除) . (削除ここまで)(追記) (追記ここまで)(追記) is (追記ここまで)(追記) present, (追記ここまで)(追記) the (追記ここまで)(追記) result (追記ここまで)(追記) is (追記ここまで)(追記) an (追記ここまで)(追記) array (追記ここまで)(追記) with (追記ここまで)(追記) a (追記ここまで)(追記) rank (追記ここまで)(追記) one (追記ここまで)(追記) less (追記ここまで)(追記) than (追記ここまで)(追記) the (追記ここまで)(追記) rank (追記ここまで)(追記) of (追記ここまで)(追記) array
(追記ここまで)(追記) , and a size corresponding to the shape of (追記ここまで)(追記) array
(追記ここまで)(追記) with the (追記ここまで)(追記) dim
(追記ここまで)(追記) dimension removed. (追記ここまで)
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