I'm trying to make submatrices to multiply two matrices into one. I've already been given the pseudocode, thus all attempts to find the proper way of implementing it in java, I'm still stuck on the basics. What would the overall structure of the java code for this pseoudocode look like ?
SQUARE-MATRIX-MULTITPLY-RECURSIVE(A,B)
n = A.rows
let C be a n x n matrix
if n == 1
c11 = a11 * b11
else partition A, B and C
C11 = SQURAE-MATRIX-MULTIPLY.RECURSIVE(A11,B11)
+ SQUARE-MARTIX-MULTIPLY-RECURSIVE(A12,B21)
C12 = SQUARE-MATRIX-MULTIPLY-RECURSUÌVE(A11,B12)
+ SQUARE-MATRIX-MULTIPLY-RECURSIVE(A11,B12)
C21 = SQUARE-MATRIX-MULTIPLY-RECURSUÌVE(A12,B22)
+ SQUARE-MATRIX-MULTIPLY-RECURSUÌVE(A22,B21)
C22 = SQUARE-MATRIX-MULTIPLY-RECURSUÌVE()A21,B12)
+ SQUARE-MATRIX-MULTIPLY-RECURSUÌVE(A22,B22)
return C;
Since the matrices A and B are n x n matrices, they can be represented by regular arrays of size n^2. The coefficient Cij in matrix (0-indexed) era accessed in array a with a[in + j].
My task is to implement two editions: one that copies the submatrices into new arrays, and one that use two index-variables to set what part of the matrix is being used