0

Consider the following two real 2D-array

real = [x_00,x_01,....,x_0m]
       [x_10,x_11,....,x_1m]
       ......
       [x_n0,x_n1,....,x_nm]

imag = [y_00,y_01,....,y_0m]
       [y_10,y_11,....,y_1m]
       ......
       [y_n0,y_n1,....,y_nm]

Im looking for a fast method (in my case n = 10**7) to convert the imag array to a complex one and add it to the reall array

z = x + i*imag

In the end i want a complex array with the following output (basic matrix addition):

z = [x_00 + i * y_00, x_01 + i * y_01, ... , x_0m + i*y_0m]
     ....
    [x_n0 + i * y_n0, x_n1 + i * y_n1, ... , x_nm + i*y_nm]

Example Code:

real = np.array([[1,2],[3,4]])
imag = np.array([[1,2],[3,4]])

Looking for output:

z = np.array([[1+1j, 2+2j],[3+3j, 4+4j]])

1 Answer 1

1

It is simply

z=real+1j*imag

(using your np.arrays)

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.