Wenzel Jakob | 5708221 | 2015-09-04 23:42:12 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | from __future__ import print_function |
Wenzel Jakob | 38bd711 | 2015-07-05 20:05:44 +0200 | [diff] [blame] | 3 | import sys |
| 4 | sys.path.append('.') |
| 5 | |
| 6 | from example import Matrix |
Wenzel Jakob | fab881c | 2015-10-18 17:04:24 +0200 | [diff] [blame] | 7 | |
| 8 | try: |
| 9 | import numpy as np |
| 10 | except ImportError: |
| 11 | print('NumPy missing') |
| 12 | exit(0) |
Wenzel Jakob | 38bd711 | 2015-07-05 20:05:44 +0200 | [diff] [blame] | 13 | |
| 14 | m = Matrix(5, 5) |
| 15 | |
| 16 | print(m[2, 3]) |
| 17 | m[2, 3] = 4 |
| 18 | print(m[2, 3]) |
| 19 | |
| 20 | m2 = np.array(m, copy=False) |
| 21 | print(m2) |
| 22 | print(m2[2, 3]) |
| 23 | m2[2, 3] = 5 |
| 24 | print(m[2, 3]) |
| 25 | |
| 26 | m3 = np.array([[1,2,3],[4,5,6]]).astype(np.float32) |
| 27 | print(m3) |
| 28 | m4 = Matrix(m3) |
| 29 | for i in range(m4.rows()): |
| 30 | for j in range(m4.cols()): |
| 31 | print(m4[i, j], end = ' ') |
| 32 | print() |