From 7c2020e9b3347cd61250fb0dadae12c6413a748d Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Thu, 14 Jan 2021 11:09:03 +0100 Subject: a slightly different matrix product --- test/monniaux/many_temporaries/matrix_product2.py | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/monniaux/many_temporaries/matrix_product2.py (limited to 'test') diff --git a/test/monniaux/many_temporaries/matrix_product2.py b/test/monniaux/many_temporaries/matrix_product2.py new file mode 100644 index 00000000..7baeb09b --- /dev/null +++ b/test/monniaux/many_temporaries/matrix_product2.py @@ -0,0 +1,24 @@ +m=4 +n=5 +p=6 +number_type='double' +with open('matrix_product2.c', 'w') as cfile: + cfile.write(f'void matrix_product({number_type} c[{m}][{p}], const {number_type} a[{m}][{n}], const {number_type} b[{n}][{p}]) {{\n') + for i in range(m): + for j in range(n): + for k in range(p): + cfile.write(f' const {number_type} p_{i}_{j}_{k} = a[{i}][{j}] * b[{j}][{k}];\n') + for i in range(m): + for k in range(p): + cfile.write(f' const {number_type} r_{i}_{k} = ') + for j in range(n): + if j>0: + cfile.write(' + ') + cfile.write(f'p_{i}_{j}_{k}') + cfile.write(';\n') + for i in range(m): + for k in range(p): + cfile.write(f' c[{i}][{k}] = r_{i}_{k};\n') + + cfile.write('}\n') + -- cgit