:param matrix_a: A square Matrix. :param matrix_b: Another square Matrix with the same dimensions as matrix_a. :param result: Result matrix :param i: Index used for iteration during multiplication. :param j: Index used for iteration during multiplication.
(
i_loop: int,
j_loop: int,
k_loop: int,
matrix_a: Matrix,
matrix_b: Matrix,
result: Matrix,
)
| 117 | |
| 118 | # Recursive multiplication of matrices |
| 119 | def multiply( |
| 120 | i_loop: int, |
| 121 | j_loop: int, |
| 122 | k_loop: int, |
| 123 | matrix_a: Matrix, |
| 124 | matrix_b: Matrix, |
| 125 | result: Matrix, |
| 126 | ) -> None: |
| 127 | """ |
| 128 | :param matrix_a: A square Matrix. |
| 129 | :param matrix_b: Another square Matrix with the same dimensions as matrix_a. |
| 130 | :param result: Result matrix |
| 131 | :param i: Index used for iteration during multiplication. |
| 132 | :param j: Index used for iteration during multiplication. |
| 133 | :param k: Index used for iteration during multiplication. |
| 134 | >>> 0 > 1 # Doctests in inner functions are never run |
| 135 | True |
| 136 | """ |
| 137 | if i_loop >= len(matrix_a): |
| 138 | return |
| 139 | if j_loop >= len(matrix_b[0]): |
| 140 | return multiply(i_loop + 1, 0, 0, matrix_a, matrix_b, result) |
| 141 | if k_loop >= len(matrix_b): |
| 142 | return multiply(i_loop, j_loop + 1, 0, matrix_a, matrix_b, result) |
| 143 | result[i_loop][j_loop] += matrix_a[i_loop][k_loop] * matrix_b[k_loop][j_loop] |
| 144 | return multiply(i_loop, j_loop, k_loop + 1, matrix_a, matrix_b, result) |
| 145 | |
| 146 | # Perform the recursive matrix multiplication |
| 147 | multiply(0, 0, 0, matrix_a, matrix_b, result) |
no outgoing calls
no test coverage detected