annotate general/numerical/nary.m @ 6:0ce3c2070089
Removed duplicate code and fixed doc in timed_action.
author |
samer |
date |
Mon, 14 Jan 2013 14:33:37 +0000 |
parents |
e44f49929e56 |
children |
|
rev |
line source |
samer@4
|
1 % binary - return array contain binary sequece over N columns
|
samer@4
|
2 %
|
samer@4
|
3 % binary :: M:natural, N:natural -> [[M^N,N]->1..M].
|
samer@4
|
4
|
samer@4
|
5 function B=nary(M,N)
|
samer@4
|
6
|
samer@4
|
7 if (N==1), B=(1:M)';
|
samer@4
|
8 else
|
samer@4
|
9 b=nary(M,N-1);
|
samer@4
|
10 m=size(b,1);
|
samer@4
|
11 B=[ kron((1:M)',ones(m,1)), repmat(b,M,1)];
|
samer@4
|
12 end
|