Anonymous user
Matrix multiplication: Difference between revisions
m
→[[Matrix multiplication#ALGOL 68]]: use BOLD as per specification.
m (→[[Matrix multiplication#ELLA]]: move to E section.) |
m (→[[Matrix multiplication#ALGOL 68]]: use BOLD as per specification.) |
||
Line 142:
Alternatively, for multicore CPUs, the following recursive algorithm can be used:
¢ crude exception handling ¢
¢ define an operator to slice array into quarters ¢
a[⌈a] × b[⌈b]
[]
);
schedule[1], ¢ assume parent CPU ¢
( ↓idle cpus; schedule[2]; ↑idle cpus)
)
begin+end
);
a[⌊a, ] × b[, 2 ⌈b] ¢ dot product ¢
[⌈a, 2 ⌈b]
[]
(
( ⌊a ≠ ⌈a, ¢ calculate bottom left corner ¢
( 2 ⌊b ≠ 2 ⌈b, ¢ calculate top right corner ¢
( (⌊a, 2 ⌊b) ≠ (⌈a, 2 ⌈b) , ¢ calculate bottom right corner ¢
);
thread →schedule[1], ¢ thread is always required, and assume parent CPU ¢
( required →schedule[4] | ↓idle cpus; thread →schedule[4]; ↑idle cpus),
Line 209:
( required →schedule[2] | ↓idle cpus; thread →schedule[2]; ↑idle cpus)
)
out
¢ finally print the result ¢
printf((matrix fmt,m))
Line 222:
¢ Some sample matrices to test ¢
(2, 4, 8, 16),
(3, 9, 27, 81),
(4, 16, 64, 256));
(-13/3, 19/4, -7/3, 11/24),
( 3/2, -2 , 7/6, -1/4 ),
( -1/6, 1/4, -1/6, 1/24));
print((" A x B =",new line));
real matrix printf(real fmt, c)
exception index error:
|