J'essaye de réduire une matrice à sa forme echlon en utilisant une fonction mais en appelant la fonction, elle change aussi ses arguments. Voici le codeAppel de fonction changeant son argument python
def GaussE(E,r):
N = np.size(r)
for i in range(0,N-1):
for j in range(i+1,N):
f=(E[j,i]/E[i,i])
r[j]= r[j] -(f)*r[i]
for k in range(i,N):
E[j,k] = E[j,k]-(f*E[i,k])
return(E,r)
A = np.array([[5.10,8.70],[2.40,4.10]])
b = np.array([9.48,4.48])
print(A,b)
sortie: [[5.1 8.7] [2.4 4.1]] [9,48 4,48]
X = GaussE(A[:],b[:])
print(A,b) # Why is A and b changing? they should not change
sortie: [[5.10000000e + 00 8.70000000e +00] [0.00000000e + 00 5.88235294e-03]] [9,48 0,01882353]