occurrences(3f) - [M_orderpack:MULTIPLICITY] Give the multiplicity for each array value (number of times that it appears in the array)
Synopsis
Description
Options
Examples
Author
Maintainer
License
Subroutine Occurrences (INVALS, IMULT)
${TYPE} (kind=${KIND}), Intent (In) :: INVALS(:) Integer, Intent (Out) :: IMULT(:)Where ${TYPE}(kind=${KIND}) may be
o Real(kind=real32) o Real(kind=real64) o Integer(kind=int8) o Integer(kind=int16) o Integer(kind=int32) o Integer(kind=int64) o Character(kind=selected_char_kind("DEFAULT"),len=*)
OCCURRENCES(3f) Gives, for each array element, its multiplicity (number of times that it appears in the array).Internally, the number of times that a value appears in the array is computed by using inverse ranking, counting for each rank the number of values that "collide" to this rank, and returning this sum to the locations in the original set. It uses subroutine RANK_ORDERS(3f).
INVALS input array IMULT array containing how often the value in INVALS appears in INVALS
Sample program:
program demo_occurrences use M_orderpack, only : occurrences ! determine how many times each value appears in an input array implicit none character(len=*),parameter :: g=(*(g0,1x)) character(len=20),allocatable :: strings(:) integer,allocatable :: cindx(:) integer :: csz integer :: i ! each name appears the number of times its name represents strings= [ character(len=20) :: & & two , four , three, five, five, & & two , four , three, five, five, & & four , four , three, one , five] csz=size(strings) if(allocated(cindx))deallocate(cindx) allocate(cindx(csz)) call occurrences(strings,cindx) write(*,g)(trim(strings(i)),i=1,csz) write(*,g)cindx end program demo_occurrencesResults:
two four three five five two four three five five four four three one five 2 4 3 5 5 2 4 3 5 5 4 4 3 1 5
Michel Olagnon, Mar 2000
John Urban, 2022.04.16
CC0-1.0
Nemo Release 3.1 | occurrences (3) | February 23, 2025 |