{"action":"created","issue":{"url":"https://api.github.com/repos/scipy/scipy/issues/5103","labels_url":"https://api.github.com/repos/scipy/scipy/issues/5103/labels{/name}","comments_url":"https://api.github.com/repos/scipy/scipy/issues/5103/comments","events_url":"https://api.github.com/repos/scipy/scipy/issues/5103/events","html_url":"https://github.com/scipy/scipy/issues/5103","id":98498988,"number":5103,"title":"Docs suggest scipy.sparse.linalg.expm_multiply supports LinearOperator but it doesn't","user":{"login":"wschudy","id":13595659,"avatar_url":"https://avatars.githubusercontent.com/u/13595659?v=3","gravatar_id":"","url":"https://api.github.com/users/wschudy","html_url":"https://github.com/wschudy","followers_url":"https://api.github.com/users/wschudy/followers","following_url":"https://api.github.com/users/wschudy/following{/other_user}","gists_url":"https://api.github.com/users/wschudy/gists{/gist_id}","starred_url":"https://api.github.com/users/wschudy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wschudy/subscriptions","organizations_url":"https://api.github.com/users/wschudy/orgs","repos_url":"https://api.github.com/users/wschudy/repos","events_url":"https://api.github.com/users/wschudy/events{/privacy}","received_events_url":"https://api.github.com/users/wschudy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/scipy/scipy/labels/defect","name":"defect","color":"e11d21"},{"url":"https://api.github.com/repos/scipy/scipy/labels/scipy.sparse.linalg","name":"scipy.sparse.linalg","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-01T02:17:02Z","updated_at":"2015-08-01T21:48:28Z","closed_at":null,"body":"According to [the docs] (http://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.expm_multiply.html#scipy.sparse.linalg.expm_multiply) the first parameter to expm_multiply is a \"transposable linear operator\", which presumably includes LinearOperator. However expm_multiply actually appears to accept numpy arrays or scipy sparse matrices only. For example:\r\n```python\r\nimport numpy as np\r\nimport scipy.sparse.linalg as spsl\r\nspsl.expm_multiply(spsl.aslinearoperator(np.array([[2]])), np.array([1]))\r\n```\r\nfails because [_trace()] (https://github.com/scipy/scipy/blob/v0.16.0/scipy/sparse/linalg/_expm_multiply.py#L31) assumes its parameter is either a numpy array or a scipy sparse matrix.\r\n\r\nIt seems expm_multiply uses the trace, 1-norm and infinity-norm of its parameter, none of which are available for LinearOperator. <del>Fixing this bug by supporting LinearOperator would therefore require some non-trivial algorithm design so you may want to fix the documentation now and defer adding LinearOperator support until later.</del>"},"comment":{"url":"https://api.github.com/repos/scipy/scipy/issues/comments/126955835","html_url":"https://github.com/scipy/scipy/issues/5103#issuecomment-126955835","issue_url":"https://api.github.com/repos/scipy/scipy/issues/5103","id":126955835,"user":{"login":"larsmans","id":335383,"avatar_url":"https://avatars.githubusercontent.com/u/335383?v=3","gravatar_id":"","url":"https://api.github.com/users/larsmans","html_url":"https://github.com/larsmans","followers_url":"https://api.github.com/users/larsmans/followers","following_url":"https://api.github.com/users/larsmans/following{/other_user}","gists_url":"https://api.github.com/users/larsmans/gists{/gist_id}","starred_url":"https://api.github.com/users/larsmans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larsmans/subscriptions","organizations_url":"https://api.github.com/users/larsmans/orgs","repos_url":"https://api.github.com/users/larsmans/repos","events_url":"https://api.github.com/users/larsmans/events{/privacy}","received_events_url":"https://api.github.com/users/larsmans/received_events","type":"User","site_admin":false},"created_at":"2015-08-01T21:48:28Z","updated_at":"2015-08-01T21:48:28Z","body":"The trace can also be computed explicitly, using (naive implementation)\r\n\r\n```py\r\ndef trace(x):\r\n    tr = 0\r\n    for i in xrange(x.shape[0]):\r\n        v = np.zeros(x.shape[0])\r\n        v[i] = 1\r\n        tr += x.dot(v)[i]\r\n    return tr\r\n```\r\n\r\nIt's probably smarter to add a `_trace` method for this, though."}}