9951 explained code solutions for 126 technologies


python-numpyHow to sum Numpy matrices


import numpy as np
a = np.matrix([[1, 1], [1, 1]])
b = np.matrix([[1, 1], [1, 1]])
sum_ar = np.add(a, b)ctrl + c
import numpy as np

load Numpy module for Python

np.matrix

creates matrix from given data

np.add

sums given matrices element-wise

sum_ar

will contain resulting matrix