I wrote a function that is supposed to horizontally stack a matrix and a vector, using hstack() method in numpy. But when I import it in another python file it is not doing what it is supposed to. Here is the function and where it is used:
I have tried directly write the code without the function and it worked. The problem is occuring when I try to call it as a function.
def augmented_matrix(A, b):
A = np.hstack((A, b))
return A
A = np.array([[2., 2., 3., 4., 6.],
[3., 0., 3., 1., 11.],
[2., 4., 0., 2., 5.],
[5., 2., 12., 0., 6.],
[6., 4., 1., 5., 8.]])
b = np.array([[1.], [2.], [4.], [6.], [8.]])
augmented_matrix(A, b)
It still gives the result:
[[ 2. 2. 3. 4. 6.]
[ 3. 0. 3. 1. 11.]
[ 2. 4. 0. 2. 5.]
[ 5. 2. 12. 0. 6.]
[ 6. 4. 1. 5. 8.]]
I expect the 5x6 matrix:
[[ 2. 2. 3. 4. 6. 1.]
[ 3. 0. 3. 1. 11. 2.]
[ 2. 4. 0. 2. 5. 4.]
[ 5. 2. 12. 0. 6. 6.]
[ 6. 4. 1. 5. 8. 8.]]