I have matrices of different sizes and I try to increase the value in each row with each iteration.
I managed to increase the value in each row, but when the iteration moves to the next matrix, it only increases the value from the first row of the previous matrix I would need it to proceed from the last row of the matrix
Is the way to save the last iteration from the previous matrix and continue the iteration in the next matrix?
here is the part of the code where I iterate the arrays
c1=c1 + 10 * (np.arange(c1.shape[1]) + 1)*p
p +=1
My result
#first iteration
11 12 13
21 22 23
#second iteration
21 22 23
41 42 43
61 62 63
#third iteration
31 32 33
61 62 63
I need
11 12 13
21 22 23
31 32 33
41 42 43
51 52 53
61 62 63
71 72 63
This is my full code where reading input from text file
demofile.txt
>=2 1 2 3
>=3 1 2 3
>=2 1 2 3
full code
import os
import sys
import numpy as np
import re
f = open("demofile.txt", "r")
lines = f.readlines()
p=1
#sys.stdout = open("results.txt", "w")
for i in list(lines):
if i[0] != '<' and i[0] != '>' and i[0] != '=':# change txt file for np.array
p = str(' '.join(i.split()))
print(p)
else:
w = i[3:]
frst=i[2]
w = ', '.join(w.split())
y = i[2]
y=int(y)+1
#INSERT input to array
c=np.array([w])
c1 = [int(i) for i in c[0].replace(" ", "").split(",")]
frst=str(frst).replace("[",'')
frst=str(frst).replace("]",'')
frst=int(frst)
c1=np.array(c1)
sest2=c1
c1=np.array([c1]*frst) #frst is the first value by which the matrix is multiplied
c1=np.transpose(c1)#transpose
#change value every iteration
c1=c1 + 10 * (np.arange(c1.shape[1]) + 1)*p
left=c1*-1
sedem=np.transpose(left)*-1 #transpose matrix
p +=1
#editing outputs
sedem=str(sedem).replace("[",'')
sedem=str(sedem).replace("]",' 0')
sedem=str(sedem).replace(".",'')
sedem = sedem[:-1]
sedem=str(sedem).replace("\n ",'\n')
sedem=str(sedem).replace(" ",' ')
sedem=str(sedem).replace("\n ",'\n')
sedem=str(sedem).lstrip()
print(sedem,'\n')