X-Git-Url: https://svn.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/06159b51a934937f647ec7119b47cb466d8e50b1..e1705e136ab823be2e76e63728db1a5359d5d443:/dsp_files/matrix_mul.dsp?ds=sidebyside diff --git a/dsp_files/matrix_mul.dsp b/dsp_files/matrix_mul.dsp index 637954f..0b6ef9b 100644 --- a/dsp_files/matrix_mul.dsp +++ b/dsp_files/matrix_mul.dsp @@ -1,27 +1,22 @@ -vectorize = +; -serialize = _ , 1 : +; -concat = * ; -nth = / ; - concat1 = case { (1) => _, 1 : vectorize ; - (m) => concat1(m - 1), ( _, 1 : vectorize) : concat; + (m) => concat1(m - 1), ( _, 1 : vectorize) : #; }; concat2 = case { (1, m) => concat1(m), 1 : vectorize; - (n, m) => concat2(n - 1, m), (concat1(m), 1 : vectorize) : concat; + (n, m) => concat2(n - 1, m), (concat1(m), 1 : vectorize) : #; }; make_input_matrix(n, m) = _, m : vectorize : _, n : vectorize ; make_output_matrix(n, m) = concat2(n, m); -accumulate_vector(k) = _ <: sum(i, k, ( _, i : nth)); +accumulate_vector(k) = _ <: sum(i, k, ( _, i : [])); -get_column(k, j) = _ <: par(p, k, ( _, p : nth : _, j : nth)) : concat1(k); +get_column(k, j) = _ <: par(p, k, ( _, p : [] : _, j : [])) : concat1(k); -get_line(i) = _, i : nth; +get_line(i) = _, i : []; make_line(i, k, m) = par(j, m, ( get_line(i), get_column(k, j) : * : accumulate_vector(k))); @@ -29,7 +24,11 @@ multiply(n, k, m) = par(i, n, make_line(i, k, m)); matrix_mul(n, k, m) = make_input_matrix(n, k), make_input_matrix(k, m) <: multiply(n, k, m) : make_output_matrix(n, m); -matrix_output(n, m) = _ <: par(i, n, ( _, i : nth)); +matrix_output(n, m) = _ <: par(i, n, ( _, i : [])); + +matrix_mul_square(n) = matrix_mul(n, n, n) : matrix_output(n, n); + +//process = matrix_mul(3, 2, 3) : matrix_output(3, 3); -process = matrix_mul(10, 10, 10) : matrix_output(10, 10); - \ No newline at end of file +process = matrix_mul_square(3); + \ No newline at end of file