How to make 2d complex number array in numpy?

I would like to make a 2d array of even distribution of complex numbers, a part of complex plane, for example (-1, 1i), (-1, -1i), (1, 1i), (1, -1i) with 20 numbers in each dimension. I know I can do this for complex numbers in 1 d with np.linspace like this: import numpy as np… Read More How to make 2d complex number array in numpy?

Splitting a dataframe with complex numbers into real and imaginary numbers with python

I would like to split the following complex dataframe into two columns, df = pd.DataFrame({"AB": [‘0.316227766016838-0.316227766016838i’, ‘0.316227766016838-0.316227766016838i’, ‘0.316227766016838-0.316227766016838i’, ‘0.316227766016838-0.316227766016838i’, ‘0.316227766016838+0.316227766016838i’, ‘0.3162277660168380.316227766016838i’]}) I tried in the following way but it works either for – or + df1=df[‘AB’].str.split(‘-‘, n=1, expand=True) How can I get two new columns for real and imaginary values only? Thanks! >Solution : Convert… Read More Splitting a dataframe with complex numbers into real and imaginary numbers with python

Problem using numpy to obtain the complex conjugate of a matrix

I have the following code: import numpy as np A=np.array([[2, 2-9j, -5j], [4-1j, 0, 9+6j], [4j, 6+7j, 6]]) print(A) print(A.getH()) It doesn’t work. I have checked different webs and followed this webpage (geeksforgeeks), and this other(official numpy documentation) but I still get an error and I don’t know where. Can someone please help me? The… Read More Problem using numpy to obtain the complex conjugate of a matrix

Why I am not able to plot a complex function (obtained with parsing) with matplotlib?

I am trying to plot a complex numbers function, but I have some problems (I don’t usually use matplotlib, so may be a very stupid error). First of all, I’ve created a function to parse the real and complex part of a given mathematical function (n is a function index and x is the variable):… Read More Why I am not able to plot a complex function (obtained with parsing) with matplotlib?