You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
537 B

  1. #!/usr/bin/env python
  2. from __future__ import print_function
  3. import sys
  4. sys.path.append('.')
  5. from example import Matrix
  6. try:
  7. import numpy as np
  8. except ImportError:
  9. print('NumPy missing')
  10. exit(0)
  11. m = Matrix(5, 5)
  12. print(m[2, 3])
  13. m[2, 3] = 4
  14. print(m[2, 3])
  15. m2 = np.array(m, copy=False)
  16. print(m2)
  17. print(m2[2, 3])
  18. m2[2, 3] = 5
  19. print(m[2, 3])
  20. m3 = np.array([[1,2,3],[4,5,6]]).astype(np.float32)
  21. print(m3)
  22. m4 = Matrix(m3)
  23. for i in range(m4.rows()):
  24. for j in range(m4.cols()):
  25. print(m4[i, j], end = ' ')
  26. print()