This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,3 @@
function table = timesTable(N)
table = [(0:N); (1:N)' triu( kron((1:N),(1:N)') )];
end

View file

@ -0,0 +1,17 @@
function table = timesTable(N)
%Generates a column vector with integers from 1 to N
rowLabels = (1:N)';
%Generate a row vector with integers from 0 to N
columnLabels = (0:N);
%Generate the multiplication table using the kronecker tensor product
%of two vectors one a column vector and the other a row vector
table = kron((1:N),(1:N)');
%Make it upper triangular and concatenate the rowLabels and
%columnLabels to the table
table = [columnLabels; rowLabels triu(table)];
end

View file

@ -0,0 +1,17 @@
timesTable(12)
ans =
0 1 2 3 4 5 6 7 8 9 10 11 12
1 1 2 3 4 5 6 7 8 9 10 11 12
2 0 4 6 8 10 12 14 16 18 20 22 24
3 0 0 9 12 15 18 21 24 27 30 33 36
4 0 0 0 16 20 24 28 32 36 40 44 48
5 0 0 0 0 25 30 35 40 45 50 55 60
6 0 0 0 0 0 36 42 48 54 60 66 72
7 0 0 0 0 0 0 49 56 63 70 77 84
8 0 0 0 0 0 0 0 64 72 80 88 96
9 0 0 0 0 0 0 0 0 81 90 99 108
10 0 0 0 0 0 0 0 0 0 100 110 120
11 0 0 0 0 0 0 0 0 0 0 121 132
12 0 0 0 0 0 0 0 0 0 0 0 144