Multiple, add, and divide element-wise and more with matrices.
Matrix arithmetics
In [2]:
import numpy as np
In [7]:
# create first 2D numpy array
lst = [[1, 2, 3], [4, 5, 6]]
array = np.array(lst_2, float)
array
Out[7]:
In [10]:
# create second 2D numpy array
lst_2 = [[7, 8, 9], [10, 11, 12]]
array_2 = np.array(lst_2)
array_2
Out[10]:
In [11]:
# element-wise addition
array + array_2
Out[11]:
In [12]:
# element-wise subtractaction
array_2 - array
Out[12]:
In [13]:
# element-wise multiplication
array * array_2
Out[13]: