The information above concerning basic mathematical operations on matrices should be enough to take on the tasks below. These are a bit more involved, and also more relevant to operations we'll use in data compression.
-
Type: Implement
-
Tasks: Write functions to ...
- Get the
shape(m- and n-dimensions) of any 1- or 2-D array. - 'Pad' (expand) an array to double the length and width (4x the size in total) with zeros to the right and below.
- Reduce an array to half the length and width (1/4 total), taking the top and left most block.
- Implement the dot product above for 2-D arrays from scratch.
- Get the
-
Reference implementations:
matrix_basics.get_m_n()matrix_basics.pad_2x2()matrix_basics.back_to_half()(this complementspad_2x2)- Locally
matrix_basics.dot_from_scratch(), as well as innumpy:np.dot(a, b),np.matmul(a, b)anda @ b(where a and b are np.arrays)- Bonus: check your work with
np.allclose.