home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
draco
/
draco-1.ark
/
MATTIME.DRC
< prev
next >
Wrap
Text File
|
1986-11-12
|
768b
|
35 lines
int SIZE = 75;
type TYPE = word;
proc matrixMultiply([*, *] TYPE x; [*, *] TYPE y; [*, *] TYPE z)void:
TYPE i, j, k, sum;
for i from 0 upto dim(z, 1) - 1 do
for j from 0 upto dim(z, 2) - 1 do
sum := 0;
for k from 0 upto dim(x, 2) - 1 do
sum := sum + x[i, k] * y[k, j];
od;
z[i, j] := sum;
od;
od;
corp;
proc main()void:
[SIZE, SIZE] TYPE a, b;
TYPE i, j;
for i from 0 upto SIZE - 1 do
for j from 0 upto SIZE - 1 do
a[i, j] := i + j;
od;
od;
writeln("Starting square:");
matrixMultiply(a, a, b);
writeln("Squaring done. Diagonal of squared matrix is:");
for i from 0 upto SIZE - 1 do
write(b[i, i], ' ');
od;
writeln();
corp;