What is the code for this algorithm ?

This is the pseudocode for this algorithm :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  
SQUARE-MATRIX-MULTIPLY-RECURSIVE(A,B) 
n = A.rows 
 let C be a new n*  n matrix
 if n ==1 
 c11 = a11 b11 
else partition A, B, and C 

C11 = SQUARE-MATRIX-MULTIPLY-RECURSIVE(A11,B11) +
SQUARE-MATRIX-MULTIPLY-RECURSIVE(A12,B21)

 C12 = SQUARE-MATRIX-MULTIPLY-RECURSIVE(A11,B12) +
SQUARE-MATRIX-MULTIPLY-RECURSIVE(A12,B22)

 C21 = SQUARE-MATRIX-MULTIPLY-RECURSIVE(A21,B11) +
SQUARE-MATRIX-MULTIPLY-RECURSIVE(A22,B21)

 C22 = SQUARE-MATRIX-MULTIPLY-RECURSIVE(A21,B12) +
SQUARE-MATRIX-MULTIPLY-RECURSIVE(A22,B22)

 return C

I came across this algorithm(matrix multiplication algorithm) while reading "Introduction to algorithm " and when I write code for this this algorithm(using divide and conquer) it does not run successfully . Please provide the code for this algorithm in c or c++ using divide and conquer method and not by using strassen's algorithm .
Topic archived. No new replies allowed.