In [43]:
from numpy import matrix
from numpy import empty
In [14]:
a=matrix(((2,5),(4,6)))
b=matrix(((1,3),(6,4)))
In [22]:
a
Out[22]:
In [23]:
b
Out[23]:
In [42]:
# shape es una tupla que indica número de filas y número de columnas
suma = empty((a.shape))
#el primer for que recorre las filas
for i in range(0, a.shape[0]):
#el segundo for recorre las columnas
for j in range(0, a.shape[1]):
suma[i,j] = a[i,j] + b[i,j]
print (suma)
In [26]:
suma = a+b
print(suma)