Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. #!/usr/bin/python
  2.  
  3. def 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.  
  16. print "#version 120"
  17. # 1.10
  18. gen_matrix(2)
  19. gen_matrix(3)
  20. gen_matrix(4)
  21.  
  22. # 1.20
  23. gen_matrix(2,3) # mat2x3 means 2 columns, 3 rows
  24. gen_matrix(3,2)
  25. gen_matrix(2,4)
  26. gen_matrix(4,2)
  27. gen_matrix(3,4)
  28. gen_matrix(4,3)
  29.