I\'m implementing Strassen\'s Matrix Multiplication using python. In divide step, we divide a larger matrix into smaller sub-matrices. Is there a built-in numpy function to
I ran into the same problem and found some built-in numpy functions to split my matrix into 4 submatrices (my matrices are of size 2^N*2^N)
Here is the code i wrote:
upper_half = np.hsplit(np.vsplit(my_matrix, 2)[0], 2)
lower_half = np.hsplit(np.vsplit(my_matrix, 2)[1], 2)
upper_left = upper_half[0]
upper_right = upper_half[1]
lower_left = lower_half[0]
lower_right = lower_half[1]
Bonus to recombine them using numpy:
C=np.vstack([np.hstack([c11, c12]), np.hstack([c21, c22])])
vsplit hsplit hstack and vstack seem to be made for that purpose