Added a ".gitignore" file (to ease git status reading on untracked files).
[Faustine.git] / dsp_files / matrix_mul.dsp
1 concat1 = case {
2 (1) => _, 1 : vectorize ;
3 (m) => concat1(m - 1), ( _, 1 : vectorize) : #;
4 };
5
6 concat2 = case {
7 (1, m) => concat1(m), 1 : vectorize;
8 (n, m) => concat2(n - 1, m), (concat1(m), 1 : vectorize) : #;
9 };
10
11 make_input_matrix(n, m) = _, m : vectorize : _, n : vectorize ;
12
13 make_output_matrix(n, m) = concat2(n, m);
14
15 accumulate_vector(k) = _ <: sum(i, k, ( _, i : []));
16
17 get_column(k, j) = _ <: par(p, k, ( _, p : [] : _, j : [])) : concat1(k);
18
19 get_line(i) = _, i : [];
20
21 make_line(i, k, m) = par(j, m, ( get_line(i), get_column(k, j) : * : accumulate_vector(k)));
22
23 multiply(n, k, m) = par(i, n, make_line(i, k, m));
24
25 matrix_mul(n, k, m) = make_input_matrix(n, k), make_input_matrix(k, m) <: multiply(n, k, m) : make_output_matrix(n, m);
26
27 matrix_output(n, m) = _ <: par(i, n, ( _, i : []));
28
29 matrix_mul_square(n) = matrix_mul(n, n, n) : matrix_output(n, n);
30
31 //process = matrix_mul(3, 2, 3) : matrix_output(3, 3);
32
33 process = matrix_mul_square(3);
34