Repository: scipy/scipy
Issue category: Bug Report

sparse LU decomposition does not solve with complex right-hand side
The `solve` method of the sparse LU-decomposition `splu` or `spilu` throws a `TypeError` if called with a `numpy.array` of type `numpy.complex`. I am actually using `spilu` for preconditioning a gmres-solver required to perform a linear solve in a non-symmetric generalized eigenvalue problem. The eigenvectors are complex and hence the right-hand side for the linear solve can be complex.

### Reproducing code example:
```
import numpy as np
from scipy.sparse import csr_matrix
import scipy.sparse.linalg as sp_sparse_la

A = csr_matrix([[2.,-1.],[-1.,2.]])
n = A.shape[0]

v_real = np.random.randn(n)
v_cmplx = np.random.randn(n) + 1.0J * np.random.randn(n)

luA = sp_sparse_la.splu(A)
x_real = luA.solve(v_real)
x_cmplx = luA.solve(v_cmplx)
```

### Error message:
```
Traceback (most recent call last):
  File "dump.py", line 20, in <module>
    x_cmplx = luA.solve(v_cmplx)
TypeError: Cannot cast array data from dtype('complex128') to dtype('float64') according to the rule 'safe'
```

### Scipy/Numpy/Python version information:
```
('1.0.0', '1.13.3', sys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0))
```


sparse LU decomposition does not solve with complex right-hand side
The `solve` method of the sparse LU-decomposition `splu` or `spilu` throws a `TypeError` if called with a `numpy.array` of type `numpy.complex`. I am actually using `spilu` for preconditioning a gmres-solver required to perform a linear solve in a non-symmetric generalized eigenvalue problem. The eigenvectors are complex and hence the right-hand side for the linear solve can be complex.

### Reproducing code example:
```
import numpy as np
from scipy.sparse import csr_matrix
import scipy.sparse.linalg as sp_sparse_la

A = csr_matrix([[2.,-1.],[-1.,2.]])
n = A.shape[0]

v_real = np.random.randn(n)
v_cmplx = np.random.randn(n) + 1.0J * np.random.randn(n)

luA = sp_sparse_la.splu(A)
x_real = luA.solve(v_real)
x_cmplx = luA.solve(v_cmplx)
```

### Error message:
```
Traceback (most recent call last):
  File "dump.py", line 20, in <module>
    x_cmplx = luA.solve(v_cmplx)
TypeError: Cannot cast array data from dtype('complex128') to dtype('float64') according to the rule 'safe'
```

### Scipy/Numpy/Python version information:
```
('1.0.0', '1.13.3', sys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0))
```




Functions to edit:
scipy/sparse/linalg/_dsolve/linsolve.py:splu
scipy/sparse/linalg/_dsolve/linsolve.py:spilu

Patch:
diff --git a/scipy/sparse/linalg/_dsolve/linsolve.py b/scipy/sparse/linalg/_dsolve/linsolve.py
index d1ab77883163..560cb75bbf99 100644
--- a/scipy/sparse/linalg/_dsolve/linsolve.py
+++ b/scipy/sparse/linalg/_dsolve/linsolve.py
@@ -371,6 +371,10 @@ def splu(A, permc_spec=None, diag_pivot_thresh=None,
 
     Notes
     -----
+    When a real array is factorized and the returned SuperLU object's ``solve()`` method 
+    is used with complex arguments an error is generated. Instead, cast the initial
+    array to complex and then factorize.
+
     This function uses the SuperLU library.
 
     References
@@ -468,6 +472,10 @@ def spilu(A, drop_tol=None, fill_factor=None, drop_rule=None, permc_spec=None,
 
     Notes
     -----
+    When a real array is factorized and the returned SuperLU object's ``solve()`` method
+    is used with complex arguments an error is generated. Instead, cast the initial 
+    array to complex and then factorize.
+
     To improve the better approximation to the inverse, you may need to
     increase `fill_factor` AND decrease `drop_tol`.