Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Study the function matrix_mult that takes two 2D arrays and performs a matrix multiplication and returns a new two-dimensional array. Each array should be represented
Study the function matrix_mult that takes two 2D arrays and performs a matrix multiplication and returns a new two-dimensional array. Each array should be represented as a list of lists. For example, A = [[1, 2, 3], [-2, 3, 7]] B = [[1,0,0],[0,1,0],[0,0,1]] matrix_mult(A,B) [[1, 2, 3], [-2, 3, 7]] Identify all lines that are in error - that is, select all answers that are correct. 1. def matrix_mult (A, B): 2. A_n = len(A) 3. A_m - len(A[@]) 4. Bun = len(B) B_m = len (B[@]) assert A_m = B_n 7. R_N = A_n R_m = B_m R = [[e for j in range(R_m)] for i in range(R_n)] def row(M,r); return v[c] for v in M def col(M, c): return M[r] def dot (vi, v2); return sum([x*y for x, y in zip(vi, v2)]) for i in range(R_n): for j in range(R_m): R[i][j] = dot(row(A,i), col(8,3)) 5. 6. 8. 9. 10. 11. 12. 13. 14. return R
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started