Bugfix in Makefile.
[Faustine.git] / dsp_files / tests / matrix_mul_test.dsp
1 vectorize = +;
2 serialize = _ , 1 : +;
3 concat = * ;
4 nth = / ;
5
6 concat1 = case {
7 (1) => _, 1 : vectorize ;
8 (m) => concat1(m - 1), ( _, 1 : vectorize) : concat;
9 };
10
11 concat2 = case {
12 (1, m) => concat1(m), 1 : vectorize;
13 (n, m) => concat2(n - 1, m), (concat1(m), 1 : vectorize) : concat;
14 };
15
16 make_input_matrix(n, m) = _, m : vectorize : _, n : vectorize ;
17
18 make_output_matrix(n, m) = concat2(n, m);
19
20 accumulate_vector(k) = _ <: sum(i, k, ( _, i : nth));
21
22 get_column(k, j) = _ <: par(p, k, ( _, p : nth : _, j : nth)) : concat1(k);
23
24 get_line(i) = _, i : nth;
25
26 make_line(i, k, m) = par(j, m, ( get_line(i), get_column(k, j) : * : accumulate_vector(k)));
27
28 multiply(n, k, m) = par(i, n, make_line(i, k, m));
29
30 matrix_mul(n, k, m) = make_input_matrix(n, k), make_input_matrix(k, m) <: multiply(n, k, m) : make_output_matrix(n, m);
31
32 matrix_output(n, m) = _ <: par(i, n, ( _, i : nth));
33
34 process = matrix_mul(10, 10, 10) : matrix_output(10, 10);
35