Repository navigation
Keep is_self_adjoint hint in LinearOperatorScaledIdentity.inverse() - #129948
Merged
copybara-service[bot] merged 1 commit intoNov 9, 2026
Merged
copybara-service[bot] merged 1 commit into
copybara-service[bot] merged 1 commit into
Conversation
The inverse of a scaled identity with a complex multiplier was always marked self-adjoint, so inverse().adjoint() returned the inverse itself: for multiplier 1j it gave -1j * I instead of 1j * I. Pass the operator's own hint instead; real multipliers are still auto-set to self-adjoint by the constructor.
Contributor
There was a problem hiding this comment.
Code Review
This pull request fixes a bug in LinearOperatorScaledIdentity._linop_inverse where the inverse operator was always marked as self-adjoint. It now correctly propagates the is_self_adjoint property of the original operator, which is necessary when dealing with complex multipliers. A corresponding unit test test_scaled_identity_inverse_complex_multiplier has been added to verify this behavior for both complex and real multipliers. I have no feedback to provide as the changes are correct and well-tested.
dmiltr3
approved these changes
Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LinearOperatorScaledIdentity._linop_inversealways setsis_self_adjoint=True. That holds for a real multiplier, but not for a complex one, andadjoint()returnsselfwhen the hint is True, so the adjoint of the inverse comes out wrong:The same wrong
selfis used byinv.H,inv.matmul(other_operator, adjoint=True)andinv.solve(other_operator, adjoint=True), andinv.assert_self_adjoint()fails.The fix passes
self.is_self_adjoint, like_linop_adjointand the other operators'_linop_inversealready do. For a real multiplier nothing changes: the constructor setsis_self_adjoint=Trueon its own.test_scaled_identity_inverse_complex_multipliercomparesinverse().adjoint()with the dense adjoint for multiplier1j, and checks that a real multiplier still gives a self-adjoint inverse. It fails before the fix (graph and eager) and passes after. The wholelinear_operator_identity_test.py(2689 tests),linear_operator_diag_test.pyandlinear_operator_addition_test.pypass with the change. I ran them against tf-nightly 2.23.0.dev20261103 with the patched module, not a source build.