# Storage of complex numbers in arrays

I have problem to understand what happens in the next code:

```A=np.array([[3.+4.j, 2.+8.j, 6.+5.j, 8.+3.j, 4.+8.j],
[0.+3.j, 4.+5.j, 3.+9.j, 0.+6.j, 0.+8.j],
[2.+7.j, 3.+5.j, 2.+3.j, 3.+9.j, 3.+6.j],
[6.+0.j, 1.+2.j, 0.+1.j, 6.+5.j, 2.+7.j],
[6.+1.j, 3.+4.j, 2.+2.j, 3.+8.j, 7.+6.j]])
```

I am trying to store the next coeficients

```B=np.identity(5)
for i in range(1,l):
B[i][0]=-(A[i][0]/A[0][0])
```

when I print the matrix B I obtain

```B=array([[ 1.  ,  0.  ,  0.  ,  0.  ,  0.  ],
[-0.48,  1.  ,  0.  ,  0.  ,  0.  ],
[-1.36,  0.  ,  1.  ,  0.  ,  0.  ],
[-0.72,  0.  ,  0.  ,  1.  ,  0.  ],
[-0.88,  0.  ,  0.  ,  0.  ,  1.  ]])
```

but of course I know that for example

```-A[1][0]/A[0][0]=-0.48-0.36j
```

and I don’t know why the loop just takes the real part.

Any help is welcome. Thank you very much for your advice.

## Answer

Use:

```B = np.identity(5, dtype=np.complex)
```

To avoid:

```ComplexWarning: Casting complex values to real discards the imaginary part
B[i][0]=-(A[i][0]/A[0][0])
```

And get:

```>>> B
array([[ 1.  +0.j  ,  0.  +0.j  ,  0.  +0.j  ,  0.  +0.j  ,  0.  +0.j  ],
[-0.48-0.36j,  1.  +0.j  ,  0.  +0.j  ,  0.  +0.j  ,  0.  +0.j  ],
[-1.36-0.52j,  0.  +0.j  ,  1.  +0.j  ,  0.  +0.j  ,  0.  +0.j  ],
[-0.72+0.96j,  0.  +0.j  ,  0.  +0.j  ,  1.  +0.j  ,  0.  +0.j  ],
[-0.88+0.84j,  0.  +0.j  ,  0.  +0.j  ,  0.  +0.j  ,  1.  +0.j  ]])
```