specfun_combinerepeat — Returns repeated combinations with replacement.
c = specfun_combinerepeat ( x , k )
a m-by-n matrix, the matrix to produce combination from.
a 1-by-1 matrix of floating point integers, the number of repeted combinations, must be greater than 1.
a (k*m)-by-(n^k) matrix, same type as x
Uses a fast algorithm to produce repeated combinations of x with itself.
For performance reasons, the combinations are stored column-by-column, that is, the combination #k is in c(:,k), with k=1,2,...,n^k.
Can process x if x is double, strings boolean and integer (signed,unsigned, 8-bits, 16-bits, 32-bits).
The algorithm makes use of the Kronecker product for good performances.
// Compute repeated combinations of x: x = [1 2 3]; specfun_combinerepeat ( x , 1 ) specfun_combinerepeat ( x , 2 ) specfun_combinerepeat ( x , 3 ) specfun_combinerepeat ( x , 4 ) // Compare to specfun_combine // Same as k=2 specfun_combine ( x , x ) // Same as k=3 specfun_combine ( x , x , x ) // Same as k=4 specfun_combine ( x , x , x , x ) // Repeated combinations of booleans computed = specfun_combinerepeat ( [%t %f] , 2 ) // Repeated combinations of strings computed = specfun_combinerepeat ( ["A" "C" "T" "G"] , 2 ) // Repeated combinations of integers computed = specfun_combinerepeat ( uint8(1:3) , 2 ) // Compare combinerepeat, perms and subset // Scilab/perms compute permutations without replacement perms ( 1:3 ) // specfun_combinerepeat compute combinations with replacement specfun_combinerepeat(1:3,3)' // specfun_subset compute subsets with k elements specfun_subset(1:3,3)'