Mercurial > touhou
comparison pytouhou/utils/matrix.pyx @ 411:2428296cccab
Remove indirect access to Matrix values.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 12 Jun 2013 16:07:22 +0200 |
parents | 74471afbac37 |
children | 5fe6cd6ceb48 |
comparison
equal
deleted
inserted
replaced
410:9d790ca73c13 | 411:2428296cccab |
---|---|
22 [0, 1, 0, 0], | 22 [0, 1, 0, 0], |
23 [0, 0, 1, 0], | 23 [0, 0, 1, 0], |
24 [0, 0, 0, 1]] | 24 [0, 0, 0, 1]] |
25 | 25 |
26 | 26 |
27 def __getitem__(Matrix self, key): | |
28 return self.data[key] | |
29 | |
30 | |
31 def __mul__(Matrix self, Matrix other): | 27 def __mul__(Matrix self, Matrix other): |
32 out = Matrix() | 28 out = Matrix() |
29 d1 = self.data | |
30 d2 = other.data | |
31 d3 = out.data | |
33 for i in xrange(4): | 32 for i in xrange(4): |
34 for j in xrange(4): | 33 for j in xrange(4): |
35 out[i][j] = sum(self[i][k] * other[k][j] for k in xrange(4)) | 34 d3[i][j] = sum(d1[i][k] * d2[k][j] for k in xrange(4)) |
36 return out | 35 return out |
37 | 36 |
38 | 37 |
39 def get_c_data(Matrix self): | 38 def get_c_data(Matrix self): |
40 data = sum(self.data, []) | 39 data = sum(self.data, []) |