Solve a for a minimal cost partition of the integers [1,...,nrow(x)] problem where for j>=i x(i,j). is the cost of choosing the partition element [i,...,j]. Returned solution is an ordered vector v of length k<=kmax where: v==1, v[k]==nrow(x)+1, and the partition is of the form [v[i], v[i+1]) (intervals open on the right).
square NumericMatix, for j>=i x(i,j) is the cost of partition element [i,...,j] (inclusive).
int, maximum number of segments in solution.
dynamic program solution.