1#!/usr/bin/python
2
3def gen_matrix(x, y = 0):
4    if y == 0:
5        y = x
6    type = "mat" + str(x)
7    if x != y:
8        type = type + "x" + str(y)
9    print type + " matrixCompMult(" + type + " x, " + type + " y)\n{"
10    print "    " + type + " z;"
11
12    for i in range(x):
13        print "    z[" + str(i) + "] = x[" + str(i) + "] * y[" + str(i) + "];"
14    print "    return z;\n}"
15
16print "#version 120"
17# 1.10
18gen_matrix(2)
19gen_matrix(3)
20gen_matrix(4)
21
22# 1.20
23gen_matrix(2,3) # mat2x3 means 2 columns, 3 rows
24gen_matrix(3,2)
25gen_matrix(2,4)
26gen_matrix(4,2)
27gen_matrix(3,4)
28gen_matrix(4,3)
29