I am trying to multiply a matrix using numpy by itself N times, this is my current code
import numpy as np
fil1=3
col1=2
mat1 = random.random((fil1,col1))
mat3 = np.zeros((fil1,col1))
iter = 2
print('Matriz A:\n',mat1)
for r in range(0,fil1):
for c in range (0,col1):
for i in range(iter):
mat3[r,c]=mat1[r,c]*mat1[r,c]
print('Pot:\n',mat3)
The error I have is that in mat3[r,c]=mat1[r,c]*mat1[r,c]
the result does not multiply well, how could I implement it for N times?
#Example Mat1^3 =
[ 1 2 3 [ 1 2 3 [ 1 2 3 [ 30 36 42
4 5 6 = 4 5 6 * 4 5 6 = 66 81 96
7 8 9 ] 7 8 9 ] 7 8 9 ] 102 126 150 ]
[ 30 36 42 [ 1 2 3 [ ? ? ?
66 81 96 * 4 5 6 = ? ? ?
102 126 150 ] 7 8 9 ] ? ? ?]