Python Forum
Write the Matrix2 by using Matrix1
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write the Matrix2 by using Matrix1
#1
I have this matrix1 which has free values(means that not have numbers but have variables):
[[rho00 rho01 rho02 rho03 rho04 rho05 rho06 rho07]
 [rho10 rho11 rho12 rho13 rho14 rho15 rho16 rho17]
 [rho20 rho21 rho22 rho23 rho24 rho25 rho26 rho27]
 [rho30 rho31 rho32 rho33 rho34 rho35 rho36 rho37]
 [rho40 rho41 rho42 rho43 rho44 rho45 rho46 rho47]
 [rho50 rho51 rho52 rho53 rho54 rho55 rho56 rho57]
 [rho60 rho61 rho62 rho63 rho64 rho65 rho66 rho67]
 [rho70 rho71 rho72 rho73 rho74 rho75 rho76 rho77]]
here, we totally have 64 elements in the matrix since it is 8*8.
And first element is rho00=[1,0,0,0,0...0] #1*64 matrix
second element is rho01=[0,1,0,0,0...0] #1*64 matrix
last element is rho77=[0,0,0.......1] #1*64 matrix
my matrix2 is here:

[[rho00 rho01 rho02 rho03 rho04 rho05 rho07 rho06]
 [rho10 rho11 rho12 rho13 rho14 rho15 rho17 rho16]
 [rho20 rho21 rho22 rho23 rho24 rho25 rho27 rho26]
 [rho30 rho31 rho32 rho33 rho34 rho35 rho37 rho36]
 [rho40 rho41 rho42 rho43 rho44 rho45 rho47 rho46]
 [rho50 rho51 rho52 rho53 rho54 rho55 rho57 rho56]
 [rho70 rho71 rho72 rho73 rho74 rho75 rho77 rho76]
 [rho60 rho61 rho62 rho63 rho64 rho65 rho67 rho66]]
in the second matrix some values are changed.
If first matrix and second matrix has same element in the same index, then I can directly write the same row matrix to matrix2
For instance, matrix1[0][0]=rho00 and matrix2[0][0]=rho00, so these element of matrix2 will be the same of matrix1 and it will be [1,0,0,0........]
However matrix1[0][6]=rho06 and matrix2[0][6]=rho07. Here matrix2[0][6]=rho07 and I should put value of rho07 of matrix1 to matrix2

If the matrix elements are same, I could write the code but if they are not same I could not complete the algorithm
Here is my code
count = 0
for row in range(8):
    for column in range(8):
        if row==0 and column==0: count = 0
        else:    
            count+=1
        if count == 64: count = 63
        m = np.zeros((1,64))                         
        m[0][count]=1 
        
        if (rho_final[row][column]==rho[row][column]):
            #print('hey')
            rho[row][column]=m
            rho_final[row][column]=m
        else:
           #######here is the problem
            print('*',rho[row][column])
            print('**',rho_final[row][column])
            m = np.zeros((1,64))
            m[0][count]=1 
            rho_final[row][column]=rho[row][column]
           
print('rho_final',rho_final[0][6])
And I created this part with this code block
for row in range(8):
    for column in range(8):
        m = np.zeros((1,64))                         
        if (rho_final[row][column]==rho[row][column]):
            #print('hey')
            rho[row][column]=m
            rho_final[row][column]=m
Reply


Messages In This Thread
Write the Matrix2 by using Matrix1 - by quest - Jan-19-2022, 12:20 PM
RE: Write the Matrix2 by using Matrix1 - by quest - Jan-19-2022, 11:43 PM
RE: Write the Matrix2 by using Matrix1 - by quest - Jan-20-2022, 08:20 AM
RE: Write the Matrix2 by using Matrix1 - by quest - Jan-20-2022, 11:37 AM
RE: Write the Matrix2 by using Matrix1 - by quest - Jan-20-2022, 11:54 AM
RE: Write the Matrix2 by using Matrix1 - by quest - Jan-20-2022, 12:29 PM
RE: Write the Matrix2 by using Matrix1 - by quest - Jan-20-2022, 11:18 PM
RE: Write the Matrix2 by using Matrix1 - by quest - Jan-20-2022, 11:58 PM
RE: Write the Matrix2 by using Matrix1 - by quest - Jan-22-2022, 12:41 AM
RE: Write the Matrix2 by using Matrix1 - by quest - Jan-23-2022, 11:57 PM
RE: Write the Matrix2 by using Matrix1 - by quest - Jan-24-2022, 01:07 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020