0

I'm trying to do these kind of operations:

width = 23
alpha_i = np.array([1.84704762, 1.7878235 , 1.72701305, 1.66501652, 1.60228591,
   1.53930674, 1.47657613, 1.41457961, 1.35376915, 1.29454503])

w_s_i = (wc / c) * d * np.cos(alpha_i) 
ws_idx = np.zeros((width, 1)) # vettore che contiene "width" elementi spaziati di 1
ii = 0
for i in range(np.int(np.floor(width / 2)),-np.int(np.floor(width / 2))-1,-1):
   ws_idx[ii,:] =  i
   ii = ii + 1


# eq.(7)
steer_vecs = np.zeros((width, alpha_i.shape[0]));
   for i in range(0,10):
   steer_vecs[:, i] = np.squeeze(np.exp(1j * np.multiply(ws_idx ,w_s_i[i])),axis=1)

But I don't know why at the end of the last for loop the imaginary part get discarded.. I get the following error:

ComplexWarning: Casting complex values to real discards the imaginary part

Any suggestions? thanks!

1 Answer 1

1

The left hand side steer_vecs[:, i] is an array of type float64, the default type. So if you try to assign complex values to a float array you get the warning.

So you need to declare steer_vecs as a complex array:

steer_vecs = np.zeros((width, alpha_i.shape[0]), dtype=np.complex)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.