I have this problem in python. I have a function which take the following inputs
import numpy;
from numpy import *;
def GetInf(G, X, m, n):
g = G[m - 1, :].T;
Y = X;
Y[m - 1, :] = 0;
Y[:, n - 1] = 0;
# Here I modify Y. The problem is that X is modified too. Why?
# In fact, I add Y after I see that X is changing but X keeps changing.
result = sum(Y * G);
return result;
G = array([[1., 2., 3.], [4., 5., 6.]]);
X = array([[1., 0., 0.], [0., 0., 1.]]);
I = GetInf(G, X, 1, 1);
My problem is that when I debug the program I see that after modifying Y
, X
is also modified. I cannot understand why.