{"action":"created","issue":{"url":"https://api.github.com/repos/scipy/scipy/issues/8140","repository_url":"https://api.github.com/repos/scipy/scipy","labels_url":"https://api.github.com/repos/scipy/scipy/issues/8140/labels{/name}","comments_url":"https://api.github.com/repos/scipy/scipy/issues/8140/comments","events_url":"https://api.github.com/repos/scipy/scipy/issues/8140/events","html_url":"https://github.com/scipy/scipy/issues/8140","id":272923379,"number":8140,"title":"sparse LU decomposition does solve with complex right-hand side","user":{"login":"sebastianGl31415","id":11094972,"avatar_url":"https://avatars1.githubusercontent.com/u/11094972?v=4","gravatar_id":"","url":"https://api.github.com/users/sebastianGl31415","html_url":"https://github.com/sebastianGl31415","followers_url":"https://api.github.com/users/sebastianGl31415/followers","following_url":"https://api.github.com/users/sebastianGl31415/following{/other_user}","gists_url":"https://api.github.com/users/sebastianGl31415/gists{/gist_id}","starred_url":"https://api.github.com/users/sebastianGl31415/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebastianGl31415/subscriptions","organizations_url":"https://api.github.com/users/sebastianGl31415/orgs","repos_url":"https://api.github.com/users/sebastianGl31415/repos","events_url":"https://api.github.com/users/sebastianGl31415/events{/privacy}","received_events_url":"https://api.github.com/users/sebastianGl31415/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-10T12:53:46Z","updated_at":"2017-11-10T14:46:35Z","closed_at":null,"author_association":"NONE","body":"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.\r\n\r\n### Reproducing code example:\r\n```\r\nimport numpy as np\r\nfrom scipy.sparse import csr_matrix\r\nimport scipy.sparse.linalg as sp_sparse_la\r\n\r\nA = csr_matrix([[2.,-1.],[-1.,2.]])\r\nn = A.shape[0]\r\n\r\nv_real = np.random.randn(n)\r\nv_cmplx = np.random.randn(n) + 1.0J * np.random.randn(n)\r\n\r\nluA = sp_sparse_la.splu(A)\r\nx_real = luA.solve(v_real)\r\nx_cmplx = luA.solve(v_cmplx)\r\n```\r\n\r\n### Error message:\r\n```\r\nTraceback (most recent call last):\r\n  File \"dump.py\", line 20, in <module>\r\n    x_cmplx = luA.solve(v_cmplx)\r\nTypeError: Cannot cast array data from dtype('complex128') to dtype('float64') according to the rule 'safe'\r\n```\r\n\r\n### Scipy/Numpy/Python version information:\r\n```\r\n('1.0.0', '1.13.3', sys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0))\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/scipy/scipy/issues/comments/343491997","html_url":"https://github.com/scipy/scipy/issues/8140#issuecomment-343491997","issue_url":"https://api.github.com/repos/scipy/scipy/issues/8140","id":343491997,"user":{"login":"ilayn","id":1303842,"avatar_url":"https://avatars2.githubusercontent.com/u/1303842?v=4","gravatar_id":"","url":"https://api.github.com/users/ilayn","html_url":"https://github.com/ilayn","followers_url":"https://api.github.com/users/ilayn/followers","following_url":"https://api.github.com/users/ilayn/following{/other_user}","gists_url":"https://api.github.com/users/ilayn/gists{/gist_id}","starred_url":"https://api.github.com/users/ilayn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilayn/subscriptions","organizations_url":"https://api.github.com/users/ilayn/orgs","repos_url":"https://api.github.com/users/ilayn/repos","events_url":"https://api.github.com/users/ilayn/events{/privacy}","received_events_url":"https://api.github.com/users/ilayn/received_events","type":"User","site_admin":false},"created_at":"2017-11-10T14:46:35Z","updated_at":"2017-11-10T14:46:35Z","author_association":"MEMBER","body":"if you cast your A matrix as complex, then it works in both cases. So probably when the LHS is real it selects a real-typed solver and complains."}}
{"actor":{"display_login":"ilayn"}}