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