I have 3 4x4 arrays (matrices) created with: arr=np.linspace(1,48,48).reshape(3,4,4)
The matrices appear as below: `
[[[ 1. 2. 3. 4.]
[ 5. 6. 7. 8.]
[ 9. 10. 11. 12.]
[13. 14. 15. 16.]]
[[17. 18. 19. 20.]
[21. 22. 23. 24.]
[25. 26. 27. 28.]
[29. 30. 31. 32.]]
[[33. 34. 35. 36.]
[37. 38. 39. 40.]
[41. 42. 43. 44.]
[45. 46. 47. 48.]]]`
I would like to perform indexing/splicing to obtain certain outputs eg:
[[36. 35.] [40. 39.] [44. 43.] [48. 47.]]
[[13. 9. 5. 1.] [29. 25. 21. 17.] [45. 41. 37. 33.]]
[[25. 26. 27. 28.], [29. 30. 31. 32.], [33. 34. 35. 36.], [37. 38. 39. 40.]]
4*. [[1. 4.] [45. 48.]]
I am struggling with exactly how to approach it. When working with a particular matrix, I have attempted to access that matrix and then splice/index from there. For example, the output [[36. 35.] [40. 39.] [44. 43.] [48. 47.]] lies in the third matrix. I access the matrix like this matrix3 = arr[array([2])]
Now I am only working with rows and columns in the third matrix and am finding it difficult to slice correctly. Should matrix3[::-1,::-1] invert both columns and rows? If yes then is this the best way to approach it? Instead, should I use reshape and should you use reshape on all 3 4x4 arrays or access the matrix you want to work with and then reshape?
edit: added 4.