Processing math: 100%

get_compositions Function

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

Get the ordered compositions of n into k summands.

Get all possible solutions for the k dimensional hypersurface. x1+...+xk=n by taking into account the order. 1+0=1 is different from 0+1=1. The German wikipedia has a nice article https://de.wikipedia.org/wiki/Partitionsfunktion#Geordnete_Zahlcompositionen

The compositions are returned in lexicographically decreasing order.

Arguments

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

Return Value integer, allocatable, (:,:)


Contents