But how could I Compute A11,B11, . . . , A22,B22 % by computing m=n/2 in c?
The easy way:
You allocate your local
A??
and
B??
and copy the appropriate pieces of the
A
and
B
matrices into these and then call
MMult
recursively. This will use lots of additional memory.
The harder (more thinking!) way:
Use a different function for the recursive calls to
MMult
(e.g.,
InternalMMult
)
This function will take as parameters the original
A
and
B
but will also include the information about the row and column ranges of interest for
A
and
B
at each recursive call. This function will do its calculations based on the specified regions of interest of the
A
and
B
.
It
may be possible to pass common intermediate (
X
) and result (
C
) matrices with ranges in a similar manner. This would take some serious analysis!
(Are you "up" for a challenge?!)
Note:
As I noted in my comment above on the original question:
However, the algorithm you show will work correctly only for square matrices with rank equal to a power of 2.
Is it really more efficient than the triple-nested loop that handles the general case of an
NxK
mult
KxM
giving a
NxM
?