1 //vectorize = +;
2 //serialize = _ , 1 : +;
3 //concat = * ;
4 //nth = / ;
7 concat1 = case {
8 (1) => _, 1 : vectorize ;
9 (m) => concat1(m - 1), ( _, 1 : vectorize) : #;
10 };
12 concat2 = case {
13 (1, m) => concat1(m), 1 : vectorize;
14 (n, m) => concat2(n - 1, m), (concat1(m), 1 : vectorize) : #;
15 };
17 make_input_matrix(n, m) = _, m : vectorize : _, n : vectorize ;
19 make_output_matrix(n, m) = concat2(n, m);
21 accumulate_vector(k) = _ <: sum(i, k, ( _, i : []));
23 get_column(k, j) = _ <: par(p, k, ( _, p : [] : _, j : [])) : concat1(k);
25 get_line(i) = _, i : [];
27 make_line(i, k, m) = par(j, m, ( get_line(i), get_column(k, j) : * : accumulate_vector(k)));
29 multiply(n, k, m) = par(i, n, make_line(i, k, m));
31 matrix_mul(n, k, m) = make_input_matrix(n, k), make_input_matrix(k, m) <: multiply(n, k, m) : make_output_matrix(n, m);
33 matrix_output(n, m) = _ <: par(i, n, ( _, i : []));
35 matrix_mul_square(n) = matrix_mul(n, n, n) : matrix_output(n, n);
37 process = matrix_mul_square(10);