Generation

generate functionThu, 30 Mar 2023

There is a matrix A1 = array([[0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0], [1, 0, 0, 1, 0, 1]]) Multiply the vector vector = [1,2,3,4] by the matrix A1

def matrix_multiplication(matrix,vector): matrix_dot_vector = [] for i in range(len(matrix)): sum_of_row = 0 for j in range(len(matrix[0])): sum_of_row += matrix[i][j] * vector[j] matrix_dot_vector.append(sum_of_row) return matrix_dot_vector vector = [1,2,3,4] A1 = array([[0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0], [1, 0, 0, 1, 0, 1]]) matrix_multiplication(A1,vector)

Questions about programming?Chat with your personal AI assistant