Skip to content

Commit

Permalink
#59 let matrix_add_recursive accumulate the matrix sum into the third…
Browse files Browse the repository at this point in the history
… matrix
  • Loading branch information
wojtask committed Mar 5, 2024
1 parent 3cb385f commit 5b19414
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/solutions/chapter4/section1/exercise4.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ def matrix_add_recursive(A: Matrix, B: Matrix, C: Matrix, n: int) -> None:
Args:
A: the first square matrix to add
B: the second square matrix to add
C: the matrix to store the matrix sum
C: the matrix to add the matrix sum
n: the dimension of matrices A and B
"""
if n == 1:
C[1, 1] = A[1, 1] + B[1, 1]
C[1, 1] += A[1, 1] + B[1, 1]
return
(A11, A12, A21, A22), (B11, B12, B21, B22), (C11, C12, C21, C22) = __partition_matrices(A, B, C, n)
matrix_add_recursive(A11, B11, C11, n // 2)
Expand Down

0 comments on commit 5b19414

Please sign in to comment.