我試圖在Python中實現複數的矩陣。但是我被困在程序的某個特定點上。我有兩個模塊Matrix.py,Complex.py和一個測試程序test.py.該模塊實現在Github上在https://github.com/Soumya1234/Math_Repository/tree/dev_branch主辦,我test.py下面Python中的矩陣實現
from Matrix import *
from Complex import *
C_init = Complex(2, 0)
print C_init
m1 = Matrix(2, 2, C_init)
m1.print_matrix()
C2= Complex(3, 3)
m1.addValue(1, 1, C2)//This is where all values of the matrix are getting
changed. But I want only the (1,1)th value to be changed to C2
m1.print_matrix()
中給出。在評論中提到,在Matrix.py中的addValue(個體經營,I,J)應該改變僅在第(i,j)位置處的值。那麼爲什麼整個矩陣被替換?我做錯了什麼?
請不要引用外部代碼的問題(這將讓他們關閉),而不是發佈最低工作例如這裏。 –