I am trying to do a matrix multiplication with two numpy arrays, one is a 2x2 and the other I want to treat as a 2x1, but there is a third dimension due to a linspace variable. This makes it not possible to apply the transformation as I intend
The code:
import numpy as np
t = 0
delt = 0
theta = 0
n = np.linspace(0,1,0.1)
E_z = np.exp((t - n) * 1j)
E_y = np.exp((t - n - delt) * 1j)
QW = np.array([[np.cos(theta)**2 + 1j * np.sin(theta)**2, (1 - 1j) * np.sin(theta) * np.cos(theta)],
[1j * np.cos(theta)**2 + np.sin(theta)**2, (1 - 1j) * np.sin(theta) * np.cos(theta)]])
QW = np.multiply(QW, np.exp(-(pi/4) * 1j))
E = np.array([[E_y],[E_z]])
E = np.dot(QW, E)
The error received is
"ValueError: shapes (2,2) and (2,1,14) not aligned: 2 (dim 1) != 1 (dim 1)"
Thanks for the help!
self,tetc in it. It's also unclear as to what you're trying to achieve - Rocky Lidot. That function expects the last dim ofQWto match the 2nd to the last ofE. Are those the expected dimensions for those variables? You should have a clear idea of what array dimensions are at each step. Printshapeperiodically to verify your intuitions. Test pieces interactively if needed. - hpauljEto be (2,1) or (2,14)? - hpaulj