If I knew the dimensions of each square submatrix m (2x2), and that the dimensionality of a large square matrix M was evenly divisible by the dimensionality m: M modulo m == 0.
Is there an efficient way to sum the following matrix M:
M = array([[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.]])
Such that the result is:
M' = array([[ 4., 4.],
[ 4., 4.])
where (0, 0) in M' is the sum of (0, 0), (0, 1), (1, 0), (1, 1) in M?
I've found that for-loops are exceedingly slow here.