I have the following code, for constructing a matrix of multiples of 4:
import numpy as np width, height = 4, 4 vector = np.zeros (width * height) for i in the range (1, width * height): vector[i] = vector[i-1] 4 matrix = vector.reshape ((width, height)) matrix >>> table ([[ 0., 4., 8., 12.], [16., 20., 24., 28.], [32., 36., 40., 44.], [48., 52., 56., 60.]])
I'm looking for a line of code that gives some coordinates [x, y] from the matrix above directly returns me the values, that is, for coordinates [0,0] I want 0, for coordinates [1,1] I want 20.
My problem is that my width and height values can be extremely large and that I only need the value of a few positions. Not all. I know this should be possible in an expression involving width, height, and x and y coordinates. Something like: width times x position plus 4 …
Thank you for your time.