0
我有這樣的功能,但問題是,它取代了第一列,當它替換下一列時,以前的列將不會回到它的原始形式。如何在numpy中只替換一列?
import numpy as np
from numpy import linalg as la
def CramersRule(A,b):
for c in range (n):
detA1 = la.det(A)
A[:,c] = b.transpose()
print A
x = la.det(A)/detA1
print ("X%d: ")%(c+1),x
n = input ("Enter size of matrix nxn: ")
coeff_matrix = input ("\nEnter coefficient matrix A: ")
vec_constants = input ("Enter vector of constants b: ")
A = np.array(coeff_matrix)
b = np.array(vec_constants)
print A
CramersRule(A, b)