-
Notifications
You must be signed in to change notification settings - Fork 39
Add ShiftedOperator for shifted linear operators #394
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
base: main
Are you sure you want to change the base?
Add ShiftedOperator for shifted linear operators #394
Conversation
Introduces the ShiftedOperator type to represent operators of the form H + σI, supporting efficient multiplication and adjoint/transpose operations. Includes comprehensive tests for real symmetric, complex non-Hermitian, and mutable shift scenarios. The new operator is integrated into the main module.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #394 +/- ##
==========================================
- Coverage 95.00% 94.50% -0.50%
==========================================
Files 17 21 +4
Lines 1100 1183 +83
==========================================
+ Hits 1045 1118 +73
- Misses 55 65 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new ShiftedOperator type to represent linear operators of the form H + σI, where H is a linear operator and σ is a scalar shift. The implementation uses closures for efficient multiplication operations and includes support for transpose and adjoint operations with proper handling of complex shifts.
Changes:
- Added
ShiftedOperatortype with mutable shift support via closures - Implemented three product functions: forward, transpose, and adjoint with proper shift conjugation
- Added comprehensive tests for real symmetric, complex non-Hermitian, and mutable shift scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| src/shifted_operators.jl | New implementation of ShiftedOperator with ShiftedData helper struct, product functions, and operator methods |
| test/test_shifted_operator.jl | Test suite covering symmetric, complex, and mutable shift scenarios |
| src/LinearOperators.jl | Integration of shifted_operators.jl module into main package |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Updated ShiftedOperator to promote types between operator and shift value, ensuring consistent output types. Added tests to verify type promotion and correct behavior when mixing Float32 and Float64 inputs. Also added a reset! function to ShiftedOperator for resetting operation counters.
Co-authored-by: Dominique <dominique.orban@gmail.com>
Co-authored-by: Dominique <dominique.orban@gmail.com>
Co-authored-by: Dominique <dominique.orban@gmail.com>
Co-authored-by: Dominique <dominique.orban@gmail.com>
Co-authored-by: Dominique <dominique.orban@gmail.com>
Simplifies ShiftedOperator construction by removing internal constructors and enforces that the shift σ matches the element type of the operator H. Updates ishermitian to check for real σ at runtime. Adjusts tests to reflect strict type constraints, ensuring σ and operator types are consistent, and adds test coverage for these constraints.
|
@dpo thanks for your review, I have updated the files and also added the tests now |
Co-authored-by: Dominique <dominique.orban@gmail.com>
Co-authored-by: Dominique <dominique.orban@gmail.com>
Update ShiftedOperator to set is_herm only when the underlying operator ishermitian and the shift σ is real (isreal(σ)). This fixes incorrect hermitian reporting for operators shifted by complex scalars. Added tests to verify that a complex σ makes the shifted operator non-symmetric/non-hermitian and a mutation test that toggling op.data.σ between real and complex updates the hermitian status accordingly.
Introduces the ShiftedOperator type to represent operators of the form H + σI, supporting efficient multiplication and adjoint/transpose operations. Includes comprehensive tests for real symmetric, complex non-Hermitian, and mutable shift scenarios. The new operator is integrated into the main module.