composition_utils Module



Functions

public elemental function n_compositions(k, n) result(res)

Return the number of compositions for k summands and a sum of n

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: k
integer, intent(in) :: n

Return Value integer(kind=int64)

public pure function next_composition(previous) result(res)

Return the next composition.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: previous(:)

Return Value integer, (size(previous))

public pure function get_compositions(k, n) result(res)

Get the ordered compositions of n into k summands.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: k
integer, intent(in) :: n

Return Value integer, allocatable, (:,:)

public pure function composition_idx(composition) result(idx)

Return the composition index for a given composition.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: composition(:)

Return Value integer(kind=int64)

public pure function composition_from_idx(k, N, idx) result(composition)

Return the composition for a given composition index

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: k

k is the number of summands (k == size(composition)).

integer, intent(in) :: N

N is the sum over the composition (N == sum(composition)).

integer(kind=int64), intent(in) :: idx

The composition index.

Return Value integer, (k)