Is there a way to convert a complex matrix to an integer matrix in python? Solution in Wolfram Mathematica . E. g.
import numpy as np
A=np.zeros((6,6),dtype=complex)
A[1,1]= 1.+1j
A[3,2]= 2.1-1j
print(A)
returns
[[0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[0. +0.j 1. +1.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[0. +0.j 0. +0.j 2.1-1.j 0. +0.j 0. +0.j 0. +0.j]
[0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j]
[0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j]]
But i would like to have something like
[[0 0 ...
[0 1+j ...
I have tried
A.astype(np.int64)
but returns
... ComplexWarning: Casting complex values to real discards the imaginary part
Entry point for launching an IPython kernel.
array([[0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 2, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0]])