I'm looking to express in pure python what is being done by the np.kron function.
Let's say i have these lists:
v1 = [1, 0, 0, 1]
v2 = [1, 0, 0, 1]
i would like to define a function that would create a list of lists by multiplying v1 by each element in v2. So these two lists would produce 4 lists:
[[1 * v1[0]],[0 * v1[1]],[ * v1[3]],[1 * v1[3]]]
Currently, i've been messing around with a bunch of stuff. but cant get it to work. for example, when i run this code i get a 4x2 matrix:
i = [[a*b for a in eye] for b in eye2]
>>[[1, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 1]]
when i convert to np.array and reformat it, it doesn't quite look right:
print(np.array(i).reshape(4,4))
[[1 0 0 1]
[0 0 0 0]
[0 0 0 0]
[1 0 0 1]]
if np.kron is passed (v1, v2), it would give:
[[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]]
which is a beautiful 4 x 4 identity matrix; thats what im looking for.