Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing complex conjugation in scipy.sparse.linalg.LinearOperator #8900

Closed
ktgeier opened this issue Jun 4, 2018 · 1 comment
Closed

Missing complex conjugation in scipy.sparse.linalg.LinearOperator #8900

ktgeier opened this issue Jun 4, 2018 · 1 comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.linalg
Milestone

Comments

@ktgeier
Copy link

ktgeier commented Jun 4, 2018

I noticed that there is a complex conjugation missing in the implementation of scipy.sparse.linalg.interface._ScaledLinearOperator._adjoint:

    def _adjoint(self):
        A, alpha = self.args
        return A.H * alpha

The correct version should be:

    def _adjoint(self):
        A, alpha = self.args
        return A.H * np.conj(alpha)

Considering also the other issues posted for the LinearOperator class, I have the impression that the implementation is not very mature yet. However, in my opinion, it is a very useful interface for linear operators, especially for matrix-free implementations, and therefore I consider it worth to further improve on it.

Reproducing code example:

>>> import numpy as np
>>> from scipy.sparse.linalg import aslinearoperator

>>> mat = np.arange(9.0).reshape((3, 3))
>>> vec = np.arange(3.0)

>>> result_array = (1j * mat).conj().T.dot(vec)
>>> result_linop = (1j * aslinearoperator(mat)).adjoint().dot(vec)

>>> print(result_array)
[0.-15.j 0.-18.j 0.-21.j]

>>> print(result_linop)
[0.+15.j 0.+18.j 0.+21.j]

Scipy/Numpy/Python version information:

1.1.0 1.14.3 sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0)
@rgommers
Copy link
Member

Thanks for the report @laplacesdemon64. Fixed in gh-8962

@rgommers rgommers added this to the 1.2.0 milestone Jun 24, 2018
@rgommers rgommers added the defect A clear bug or issue that prevents SciPy from being installed or used as expected label Jun 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.linalg
Projects
None yet
Development

No branches or pull requests

3 participants