DOUBT: W3_Lab 3_LINEAR TRANSFORMATION

In this code how does the 2nd last line work?
We are NOT passing any arguments to T_hscaling. BUT we defined it with a parameter v above.

def T_hscaling(v):
    A = np.array([[2,0], [0,1]])
    w = A @ v
    
    return w
    
    
def transform_vectors(T, v1, v2):
    V = np.hstack((v1, v2))
    W = T(V)
    
    return W
    
e1 = np.array([[1], [0]])
e2 = np.array([[0], [1]])

transformation_result_hscaling = transform_vectors(T_hscaling, e1, e2)

print("Original vectors:\n e1= \n", e1, "\n e2=\n", e2, 
      "\n\n Result of the transformation (matrix form):\n", transformation_result_hscaling)

It because T_hscaling is passed as an argument to the transform_vectors(T, v1, v2) as T and then is called W = T(V), there the v parameter.

But where is v defined?
We are passing v as argument to T(v) but it is not defined! :hushed:

Here there is v defined as dependend on v1 and v2

1 Like

Oh, now I understood.
Thank you for responding quickly and clearing my confusion. :grinning:

1 Like