質問

I tried to compute the eigenvectors of a matrix with scipy. The results where some numbers like this one: -3.47686396e-01+0.j. What does the j stand for and mean? i.e. how to interpret this number?!

Also how to make convert/print it in usual format i.e. -1.00 or something like this. The format usually known.

役に立ちましたか?

解決

Numbers with j are complex numbers:

>>> 1j * 1j
(-1+0j)

You can extract real part and imaginary part using real, imag attributes:

>>> c = 1 + 2j
>>> c.real
1.0
>>> c.imag
2.0

To convert numpy array with complex numbers to array with float: same; use real, imag attributes.

>>> np.array([1+0j, 2+0j]).real
array([ 1.,  2.])
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top