Skip to content

Conversation

@farhadrclass
Copy link
Contributor

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.

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.
Copilot AI review requested due to automatic review settings January 24, 2026 23:41
@codecov
Copy link

codecov bot commented Jan 24, 2026

Codecov Report

❌ Patch coverage is 72.09302% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.50%. Comparing base (32dbc5e) to head (bc20ec1).
⚠️ Report is 60 commits behind head on main.

Files with missing lines Patch % Lines
src/shifted_operators.jl 72.09% 12 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a 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 ShiftedOperator type 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.
@dpo dpo self-requested a review January 26, 2026 15:12
farhadrclass and others added 6 commits January 26, 2026 12:36
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.
@farhadrclass
Copy link
Contributor Author

@dpo thanks for your review, I have updated the files and also added the tests now

farhadrclass and others added 3 commits February 2, 2026 13:51
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.
@farhadrclass farhadrclass requested a review from dpo February 3, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants