Home | History | Annotate | Download | only in tools
      1 #!/usr/bin/python
      2 
      3 def gen(x, y):
      4     origtype = "mat" + str(x)
      5     trantype = "mat" + str(y)
      6     if x != y:
      7         origtype = origtype + "x" + str(y)
      8         trantype = trantype + "x" + str(x)
      9     print trantype + " transpose(" + origtype + " m)\n{"
     10     print "    " + trantype + " t;"
     11 
     12     # The obvious implementation of transpose
     13     for i in range(x):
     14         for j in range(y):
     15             print "    t[" + str(j) + "][" + str(i) + "] =",
     16             print "m[" + str(i) + "][" + str(j) + "];"
     17     print "    return t;\n}"
     18 
     19 print "#version 120"
     20 gen(2,2)
     21 gen(2,3) # mat2x3 means 2 columns, 3 rows
     22 gen(2,4)
     23 gen(3,2)
     24 gen(3,3)
     25 gen(3,4)
     26 gen(4,2)
     27 gen(4,3)
     28 gen(4,4)
     29