Great notes!
For those of us coming from Matlab trying to learn numpy, i.e. lecture 2.
Everything seems to be easy for vectors and 2D arrays. However, an example with 3D shows a big difference compared to Matlab, which maybe should be highlighted (as the normal 0-indexing).
Say we construct the following 3D array
m = np.arange(8).reshape(2,2,2)
Asking a Matlab person to get the first items (upper left) from the 2 dimensions would result in something like (knowing that indexing starts at 0...)
m[0,0,0] #first item in the first dimension
m[0,0,1] #first item in the second dimension
Expecting the numbers 0 and 4. But the result from the above is 0 and 1, respectively. Quite confusing for someone used to Matlab arrays.
Some clarification on accessing elements i higher dimensional arrays would be of great value.
Great notes! For those of us coming from Matlab trying to learn numpy, i.e. lecture 2. Everything seems to be easy for vectors and 2D arrays. However, an example with 3D shows a big difference compared to Matlab, which maybe should be highlighted (as the normal 0-indexing).
Say we construct the following 3D array m = np.arange(8).reshape(2,2,2)
Asking a Matlab person to get the first items (upper left) from the 2 dimensions would result in something like (knowing that indexing starts at 0...) m[0,0,0] #first item in the first dimension m[0,0,1] #first item in the second dimension
Expecting the numbers 0 and 4. But the result from the above is 0 and 1, respectively. Quite confusing for someone used to Matlab arrays.
Some clarification on accessing elements i higher dimensional arrays would be of great value.